FHIR Chat · Canonical references with fragment · hapi

Stream: hapi

Topic: Canonical references with fragment


view this post on Zulip Dave Carlson (May 23 2019 at 02:03):

The current HAPI test server (and HSPC R4 sandbox) will not load contained resources when they are referenced only via a canonical. The base resource is loaded successfully, but contained resources are ignored. This should be acceptable, as described here: https://www.hl7.org/fhir/references.html#canonical-fragments

view this post on Zulip Dave Carlson (May 23 2019 at 02:04):

I created a minimal sample resource to illustrate the problem:

view this post on Zulip Dave Carlson (May 23 2019 at 02:04):

{
"resourceType": "Questionnaire",
"id": "questionnaire-test-frag",
"url": "http://example.com/fhir/Questionnaire/test-1",
"status": "draft",
"item": [
{
"linkId": "q1",
"type": "choice",
"answerValueSet": "#options-1"
}
],
"contained": [
{
"resourceType": "ValueSet",
"id": "options-1",
"url": "http://example.com/fhir/ValueSet/options-1",
"status": "draft"
}
]
}

view this post on Zulip Dave Carlson (May 23 2019 at 02:09):

If I replace the canonical URI with a Reference type, then the contained resource is included. e.g.

view this post on Zulip Dave Carlson (May 23 2019 at 02:09):

  "answerOption": [
    {
      "valueReference": {
        "reference": "#options-1"
      }
    }
  ]

view this post on Zulip Grahame Grieve (May 23 2019 at 02:14):

this validates ok in the latest validator - it's probably a versioning issue (and I have a vague memory of needing to fix an invariant related to this)

view this post on Zulip Dave Carlson (May 23 2019 at 02:15):

Grahame, yes this resource loads in your test server, but fails in HAPI.

view this post on Zulip Dave Carlson (May 23 2019 at 02:17):

More precisely, this resource loads without error in HAPI, but omits the contained resource.

view this post on Zulip Grahame Grieve (May 23 2019 at 02:18):

oh. not a validation issue at all then

view this post on Zulip Dave Carlson (May 23 2019 at 02:20):

But the contained resource is retained if it has a Reference from primary resource. Seems like the invariant is considered with accepting contained resources, but incorrectly.

view this post on Zulip Grahame Grieve (May 23 2019 at 02:21):

I expect it's an issue in @James Agnew's persistence code, not in the validator at the front

view this post on Zulip Patrick Werner (May 23 2019 at 06:22):

its a known hapi issue: https://github.com/jamesagnew/hapi-fhir/issues/1184

view this post on Zulip Patrick Werner (May 23 2019 at 06:23):

it is on my todo list (as we need this for our questionnaire renderer) but i didn't had too much time for hapi contributions lately

view this post on Zulip Dave Carlson (May 23 2019 at 15:14):

Thanks, Patrick. For now I'll look for a workaround by stuffing the ValueSet references into some obscure Reference inside the Questionnaire so that contained resources are retained for my demo example work.

view this post on Zulip James Agnew (May 23 2019 at 17:59):

That's a good idea- FYI a dummy extension with a reference as the value would do the trick

view this post on Zulip Dave Carlson (May 24 2019 at 00:50):

Thanks, James. That's exactly what I did earlier today and it worked perfectly.


Last updated: Apr 12 2022 at 19:14 UTC