Stream: implementers
Topic: Order of elements in resources/elements
Brian Reinhold (Sep 20 2021 at 19:52):
I have never been able to get a solid answer on this: There is this statement in the spec
Elements must be in the same order as the baseDefinition, and child elements appear in depth-first order.
What I don't know is if this applies only to the structure definition or does it apply to the resources build on that structure definition?
If the structure definition has
"subject" : { Reference(Any) }, // The subject of the questions
"encounter" : { Reference(Encounter) }, // Encounter created as part of
is it an error if in the JSON representation the 'encounter' element precedes the subject as in
"encounter":"....,
"subject":"....
thanks!
Michael van der Zel (Sep 20 2021 at 19:54):
Yes
Michael van der Zel (Sep 20 2021 at 19:55):
The fhir validator reports on these issues. Even in the StructureDefinition.
Brian Reinhold (Sep 20 2021 at 20:30):
Michael van der Zel So if the 'encounter' element is before the 'subject' element in the JSON representation of the resource, this is an ERROR.
So while this is good
"item": [
{
"linkId": "/matrix/69671-6",
"text": "Stomach pain",
"answer": [
{
"valueCoding": {
"code": "LA18334-5",
"display": "Not bothered"
}
}
]
},
This is bad
"item": [
{
"answer": [
{
"valueCoding": {
"code": "LA18334-5",
"display": "Not bothered"
}
}
],
"linkId": "/matrix/69671-6",
"text": "Stomach pain"
},
Note that the structure definition has the 'linkId' and the 'text' elements before the 'answer'.
Lloyd McKenzie (Sep 20 2021 at 21:36):
We don't yell about order in JSON because many JSON serializers don't allow control over order. However, in XML order absolutely must be correct.
Grahame Grieve (Sep 20 2021 at 21:37):
this is a confusing question - what order are we talking about?
Brian Reinhold (Sep 20 2021 at 21:50):
Lloyd McKenzie said:
We don't yell about order in JSON because many JSON serializers don't allow control over order. However, in XML order absolutely must be correct.
Thanks. THat clarifies it!
Brian Reinhold (Sep 20 2021 at 23:27):
Grahame Grieve
The order here is referring to the order of the elements in a resource instance in xml/json and whether it must follow that of the structure definition.
Grahame Grieve (Sep 21 2021 at 01:46):
xml yes, json no
Lloyd McKenzie (Sep 21 2021 at 01:48):
RDF also no, I believe (if anyone cares :>)
Michael van der Zel (Sep 21 2021 at 07:41):
Grahame Grieve said:
xml yes, json no
Really? The validator gives a lot of errors when the elements are out of order.
Michael van der Zel (Sep 21 2021 at 07:47):
Ah. I found it. The order in the elements of a StructureDefinition give the errors.
Grahame Grieve (Sep 21 2021 at 13:36):
yes that's why I asked which order were we asking about
Last updated: Apr 12 2022 at 19:14 UTC