Stream: implementers
Topic: constraining of referenced profiles
Georg Fette (Sep 06 2019 at 12:02):
Hi,
Is it possible to constrain the profile referenced in another profile ? Like e.g. when I want to build some report about pregnancy and I reference a "Patient" resource I would like to ensure thate the "Patient.gender" can only be "female". If possible, with which standard mechanism from the FHIR cosmos are such constrains modeled ?
Grahame Grieve (Sep 06 2019 at 12:03):
either a FHIRPath statement using resolve() or a GraphDefinition (though that needs an extension). But either way it's fragile since the rule is only know from the context of a different resource
Alexander Zautke (Sep 06 2019 at 12:06):
And you need to be careful about the validity of the invariant itself. Patients with a gender = other might also be pregnant. You can't know that information.
Grahame Grieve (Sep 06 2019 at 12:10):
technnically, in super edge cases, it's possi ble for patients with an administrative gender of m to be pregnant (though I think it's pretty unlikely given hormone treatment etc)
Georg Fette (Sep 06 2019 at 12:17):
so, is it true that using the standard mechanisms that available by defining a profile merely through a StructureDefinition such a constraining is not possible ?
Alexander Zautke (Sep 06 2019 at 12:41):
Technical it is possible as @Grahame Grieve mentioned. Have a look at the resolve function defined here: https://www.hl7.org/fhir/fhirpath.html
With it you could in theory define invariants which cover multiple resources
Georg Fette (Sep 06 2019 at 12:45):
ah, cool, thank you. I will take a look at that.
Georg Fette (Sep 09 2019 at 12:24):
Can somebody give me an example of a structuredefinition in which a fhirpath statement has been used to constrain the profile? It does not need to be such a trans-profile constraint like i asked for in my initial question.
Chris Moesel (Sep 09 2019 at 14:42):
I suspect that in most cases if the constraint doesn't go across the reference boundary, then the profile will just use the normal (non-FHIRPath) approach to constraining the reference to a profile (using the type.targetProfile
). But if you did want to use a FHIRPath invariant to do that, I expect you'd chain resolve()
and conformsTo(structure: string)
together to accomplish it (see: http://hl7.org/fhir/R4/fhirpath.html#functions for doc on conformsTo
).
Richard Townley-O'Neill (Sep 12 2019 at 05:26):
https://github.com/AuDigitalHealth/ci-fhir-stu3/blob/master/resources/composition-sml-prac-1.xml contains an invariant to force a referenced practitioner to conform to a profile. See inv-dh-cmp-06.
<expression value="resolve().conformsTo('http://ns.electronichealth.net.au/ci/fhir/3.0/StructureDefinition/practitionerrole-withpractitionerident-1')" />
Michel Rutten (Sep 12 2019 at 11:22):
Why not use ElementDefinition.type.targetProfile
?
Lloyd McKenzie (Sep 12 2019 at 11:32):
That works unless the invariant is conditional
Last updated: Apr 12 2022 at 19:14 UTC