FHIR Chat · Restrict References to conform to a specific Profile · hapi

Stream: hapi

Topic: Restrict References to conform to a specific Profile


view this post on Zulip Sergej Reiser (Aug 25 2020 at 14:58):

Following the suggestion of @Lloyd McKenzie im posting my Question (which a already posted in #implementers ) once again in this stream.

If i'm not misunderstanding the FHIR specification for targetProfile, i'm supposed to be able to restrict a Reference, so that it's actual Resource-Content conforms to a specific Profile.

Definition
Used when the type is "Reference" or "canonical", and identifies a profile structure or implementation Guide that applies to the target of the reference this element refers to. If any profiles are specified, then the content must conform to at least one of them. The URL can be a local reference - to a contained StructureDefinition, or a reference to another StructureDefinition or Implementation Guide by a canonical URL. When an implementation guide is specified, the target resource SHALL conform to at least one profile defined in the implementation guide.

So with validation enabled, i would imagine HAPI to resolve References and check if they conform to one of the specified TargetProfiles.

I created a test scenario with two Profiles and uploaded the StructureDefinitions to http://hapi.fhir.org/baseR4:

  • MyPatient : needs to have a gender (by changing cardinality to 1..1)
  • MyCareTeam : only allows MyPatient-References in subject (by removing the default target Profiles and adding the cannonical URL for MyPatient) forge.png

Than i uploaded 2 resources of Patient and 2 resources of CareTeam:

Now when calling the $validate operation on the CareTeam resources, i would expect the first one to not contain any errors and the second one to contain one error, since the referenced Patient resource does not conform to the MyPatient profile.
To my surprise both CareTeam resources don't have any errors.

Than i tried another approch and added the following constraint to the StructureDefinition of MyCareTeam:

<constraint>
    <key value="req-01"/>
    <requirements value="Subject is not conforming"/>
    <severity value="warning"/>
    <human value="Subject is not conforming"/>
    <expression value="subject.reference.resolve().conformsTo('http://example.org/fhir/StructureDefinition/MyPatient')"/>
</constraint>

Now i am expecting to see a warning when validating the second CareTeam resource. But both CareTeam resources contain the warning! It seems like either the resolve() or the conformsTo() method is not working with the FHIRPath expression.

Is this a missing HAPI feature, or am i doing somthing wrong?

view this post on Zulip Sergej Reiser (Sep 09 2020 at 12:47):

I asked the same Question on Google Groups where i received a reply from @James Agnew .

To summarize: HAPI does support validation for TargetProfiles, but it's not enabled by default and it also wasn't enabled on hapi.fhir.org. James commited a configuration update to enable validation for TargetProfiles on hapi.fhir.org.


Last updated: Apr 12 2022 at 19:14 UTC