Search code examples
hl7-fhir

FHIR StructureDefinition - differential definitions


The DSTU2 May ballot version has a StructureDefintion resource (replaces Profile) that allows for "differential" definition of structures.

It's pretty straightforward to use this to add elements to an existing structure - all elements in the differential are "adds" to the base.

However, how does one modify or reduce an existing profile? More specifically:

How can an element in a base structure be reliably matched to an element in a differential structure so that the differential can modify the base?

I can see two possibilities:

  1. Use Path. A required element that works for non-sliced elements but not for slices (extensions are always slices).
  2. Use Name. Except it's optional, so if the base didn't name their element, this won't work.

Is there another way?

Working example here: http://hl7.org/fhir/2015May/extensibility-examples.html#1.16.2.1.2

In this example, matching by path would replace any other extension, and name matching won't work because neither element is named. The only option is to treat it as an addition (which luckily is the intent here). But if I wanted to further modify this structure using this one as the base (perhaps to set max="1") I'd be unable to.


Solution

  • Actually, adds aren't adds. Any additions would have to be slices of extension - you can't add new elements in a profile. So (unless you're defining resources - which only HL7 can do), every element you specify in a constraint StructureDefinition must specify a "path" that corresponds to an existing path in the base resource. To constrain an existing element, simply identify that path and assert your constraints. If what you want to constrain can't be identified just by a path (i.e. you want to constrain a slice defined in a parent profile), then you'll need to re-declare the slicing and assert the additional constraints on the relevant slice. Name is used to uniquely identify slices within a profile but isn't (presently) used across profiles.