FHIR Chat · Restrict References to specific Profile · implementers

Stream: implementers

Topic: Restrict References to specific Profile


view this post on Zulip Sergej Reiser (Aug 19 2020 at 12:37):

Hi all,

i created two custom Profiles:

  • MyCareTeam
  • MyPatient

My goal is to restrict MyCareTeam.subject, so that only resources conforming to the MyPatient profile can be referenced inside the CareTeam resource.

I thought i will be able to achieve it by just removing the default target Profile and add my custom one. forge.png
But testing it on a HAPI 5.1.0 Server with validation enabled, i am still able to reference Patient-Resources that don't conform to the MyPatient Profile.

Update:
I uploaded my 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)

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.

view this post on Zulip Matthijs van der Wielen (Aug 20 2020 at 13:35):

Hi @Sergej Reiser ,

I have taken the liberty off adding your MyPatient and the two examples to a Simplifier project I created. Please have a look: https://simplifier.net/zullipchat . And please try the validation there as well. You will see that the validation goes as you expected.

I've taken a look at you examples and in the conforming example it had

in the meta data, but this was missing in the non-conforming example you created.

All I did was add that line to the meta in the non-conforming example and it works as intended.

Would this solve your issue in the HAPI setting as well?

Kind regards,
Matthijs

view this post on Zulip Sergej Reiser (Aug 20 2020 at 14:17):

Hi @Matthijs van der Wielen ,

thanks for your reply and effort, but that's not actually my issue. I guess my phrasing was confusing.
I omitted the "profile" attribute for the non confoming Patient on purpose. I want one Patient-Resource which conforms to the MyPatient profile and onther one which doesn't. There's not an issue with that and it works just fine with HAPI.

But now, when i create a CareTeam-Resource, which references the non conforming Patient, i expect it to be invalid if the CareTeam-Resource is equipped with

So this resource should be invalid:

{
  "resourceType": "CareTeam",
  "id": "1438249",
  "meta": {
    "profile": [ "http://example.org/fhir/StructureDefinition/MyCareTeam" ]
  },
  "subject": {
    "reference": "Patient/1438247",
    "display": "This patient is not conforming to the MyPatient profile"
  }
}

view this post on Zulip Matthijs van der Wielen (Aug 21 2020 at 07:59):

Hi @Sergej Reiser ,
Apologies for my misunderstanding. I will take a look at your clarification.

view this post on Zulip Lloyd McKenzie (Aug 23 2020 at 21:50):

If you don't yet have an answer @Sergej Reiser, I'd suggest raising this on #hapi

view this post on Zulip Sergej Reiser (Aug 24 2020 at 10:07):

@Lloyd McKenzie
I dont have an answer yet, but im also not sure if my expectations are correct. Am i misinterpreting the FHIR specification for targetProfile somehow?

view this post on Zulip Lloyd McKenzie (Aug 24 2020 at 14:37):

I think your expectations are correct

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

Update: 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