FHIR Chat · Forge and element order in StructureDefinition · implementers

Stream: implementers

Topic: Forge and element order in StructureDefinition


view this post on Zulip Kirill (Jul 23 2018 at 16:03):

Hello!

I am using Forge to check profiles generated by my code. It appears that Forge would only correctly parse a profile if its element order exactly matches that of the base definition. Should I swap the order even a little bit, and Forge displays an error, and duplicates display for the element in question.

See, the following item order results in a correct parsing:
pasted image

And the moment I swap the two blocks, Forge displays an error and display of the structure breaks:
pasted image
pasted image

Is element order in a StructureDefinition anyhow mandated by the standard? If not, should such behavior in Forge be considered correct?

view this post on Zulip Ewout Kramer (Jul 23 2018 at 16:22):

In FHIR in general, the order of elements in the definitions of resources matters. This is important e.g. for the XML serialization, which depends on the order. Also, in StructureDefinition, the order is important, it's a flat list of elements and its interpretation depends on the order. So, indeed you cannot change the order. See also here: http://hl7.org/fhir/structuredefinition.html#interpretation

view this post on Zulip Lloyd McKenzie (Jul 23 2018 at 16:44):

More specifically, order of properties is mandatory in XML but only preferred in JSON. XML schema relies on consistent order. JSON parsers and serializers often don't have the ability to retain property order. Order of elements in an array is always retained however.

view this post on Zulip Kirill (Jul 24 2018 at 11:47):

Thank you. That helps!


Last updated: Apr 12 2022 at 19:14 UTC