FHIR Chat · order of elements in a structuredefinition · IG creation

Stream: IG creation

Topic: order of elements in a structuredefinition


view this post on Zulip Michael van der Zel (Nov 02 2020 at 13:06):

The IG publisher (and/or validator) used to accept elements not in the order they are in the resource. The latest version does check for the order. I fail to understand why the order of the elements are so important in a differential part of a structure definition. Why cannot I add a differential element in an AllergyIntolerance profile with a path like "note" before a path like "category"? I would expect the snapshot generation step to correct this for me.

view this post on Zulip Lloyd McKenzie (Nov 02 2020 at 14:10):

If the order is wrong, the instance is non-conformant. It's reasonable for the tool to yell at you. (And the logic of snapshot generation is so over-the-top complicated, that trying to accommodate for 'out of order' and 'fix' it isn't a super reasonable ask.

view this post on Zulip Eric Haas (Nov 02 2020 at 17:58):

I was not aware that order mattered in JSON.

view this post on Zulip Lloyd McKenzie (Nov 02 2020 at 18:01):

Order of elements in an array (e.g. order of elements in the snapshot or differential) matters regardless of syntax. If it didn't, you couldn't differentiate first names from middle names in the collection of HumanName.given

view this post on Zulip Eric Haas (Nov 02 2020 at 18:03):

Yes I am confusing the instances with elements array.

view this post on Zulip Chris Moesel (Nov 02 2020 at 19:02):

I think the confusion is that elements, while being in an array, are generally keyed (i.e., identifiable by id). In theory, one should be able to reconstruct the element array in the correct order. That said, IIRC, some parts of the publisher do not use id but use path and element order instead. This is particularly important with slices; if nested parts of slices are out of order, then you can end up in a world of hurt because the publisher keeps track of the last sliceName and applies that to the following elements until the path goes out of scope of the slice or an element w/ a new sliceName is encountered.

view this post on Zulip Michael van der Zel (Nov 06 2020 at 12:37):

Yes. Most elements are keyed, so the order is irrelevant then. For arrays the story is different. I understand that too.

view this post on Zulip Chris Moesel (Nov 06 2020 at 13:31):

OK. But just to be clear, snapshot.element and differential.element are arrays, so they need to be in the right order (even though each element may appear to be keyed).


Last updated: Apr 12 2022 at 19:14 UTC