2

How does one "roll up" or aggregate differential elements with "base" elements to create a snapshot?

Chris Grenz
  • 161
  • 9

2 Answers2

1

Snapshot generation combines attributes from base elements (elements defined in the base profiles) with the differential elements in the constraint profile. Matching of elements from constraint to base is by name (if present in both) and path. A slice in a constraint ("homePhone") uses the bare path ("Patient.telecom") as the base element. Re-slices use the most complete slice from the base that matches.

Base elements can be sourced from either:

  1. A snapshot of the StructureDefinition identified by the constraint profiles's StructureDefinition.base value.
  2. A recursive application of these rules up the StructureDefinition "tree" (base to base to base ad nauseam).

IF the constraint profile includes elements from within a complex type (e.g. path=Patient.telecom.system), the base element will be found in the first of:

  • The profile identified in type.profile for the element (if any).
  • The HL7 provide datatype profile for the type (e.g. ContactPoint in this example).

Elements are brought into the snapshot using one of these methods:

  • K - matching keys that must be present in both base and constraint profiles for matching the element
  • F - fixed from the base and cannot be overriden. If present in the differential this value must match the base exactly
  • I - inherited from the base if not present in the constraint
  • N - not inherited and can be set in the constraint. If blank/missing in the differential, will be blank/missing in the snapshot.
  • F/N - if present in the base, the constraint must match. If not, a value may be set.
  • A - aggregated from the base - base instances are added to differential instances
  • R - restricted from base - the differential must be some subset of the base instances

Element by element:

  • path (K) - required in both base and constraint for matching.
  • representation (F)
  • name (K) - required in both base and constraint if appropriate
  • label (I)
  • code (A)
  • slicing (F/N) - if the base is sliced, the constraint must match. If not, a slicing can be introduced. Also see reslicing.
  • short (I)
  • definition (I)
  • comments (I)
  • alias (A)
  • min (I) - min in constraint must be greater or equal to base. Slices are relieved from this constraint (a slice may be min=0 when base is min=1 due to the possibility of other slices satisfying the base's min constraint).
  • max (I) - similar to min.
  • base (F)
  • type (R) - types must have a code present in the base element. They can add profiles and/or specify type code multiple times with different profiles.
  • nameReference (F)
  • defaultValue[x] (F)
  • meaningWhenMissing (F)
  • fixed[x] (F/N)
  • pattern[x] (F/N) - exception is that pattern can be refined to fixed.
  • example[x] (I)
  • minValue[x] (I)
  • maxValue[x] (I)
  • condition (A)
  • constraint (A)
  • mustSupport (F/N)
  • isModifier (F)
  • isSummary (F)
  • binding (A)
  • mapping (A)
Chris Grenz
  • 161
  • 9
  • Mostly agree, except: you could tighten a pattern into a fixed. I think that nameReference can change - it's got no meaning across derivations (but you need to change all uses). There are cases for re-slicing. We've agreed that you can handle this by [nameA].[nameB], where nameA is from the base, and nameB is from this profile. But we've not implemented that yet – Grahame Grieve Dec 09 '15 at 19:55
  • @GrahameGrieve - Updated taking into consideration your comments. Not sure about changing nameReference... – Chris Grenz Dec 09 '15 at 20:25
  • do you know by chance how i can increase the offset from 20 to lets say 100 in `_snapshot/:id/_start=100` ? – Paulquappe Sep 07 '22 at 06:54
0

Chris, I have started working on this, but this is really work in progress. Would love to cooperate with you:

https://github.com/ewoutkramer/strucdefdoc/wiki/SD's-expressing-constraints

(it's part of a wiki describing the StructureDefinition more in full)

Bert
  • 861
  • 9
  • 22
Ewout Kramer
  • 984
  • 6
  • 9
  • Good! Debated where to host this...SO is easily searchable and a good community resource. Would ideally like to see this "summary view" as part of the specification beyond what is on the Profiling page. What's best? – Chris Grenz Dec 09 '15 at 20:21
  • makes sense to add it to the spec to this page: http://hl7.org/fhir/elementdefinition.html or perhaps about here: http://hl7.org/fhir/structuredefinition.html#6.17.5.2 – Grahame Grieve Dec 10 '15 at 00:06
  • Yes, some of it needs to be reflected back into the spec, other parts are more explanatory. Maybe some parts need to be in a blog. – Ewout Kramer Dec 15 '15 at 11:01