1

I am still new to FHIR and trying to connect the dots.

If I have a resource that I want to contain other resources, can I refer to it by element name (#myElementName) or do I need to use the contained resource id? (#myDeviceId).

I've included sample code below. What I would like to accomplish is to have a Basic resource that has two extensions: TestConfiguration(Device) and DigitalSample(ImagingStudy). I would like for both of these resources to be contained.

PS: I generated the code below using custom classes and the .net API.

Thank you much!

{
  "resourceType": "TestInput",
  "contained": [
    {
      "resourceType": "TestConfiguration",
      "id": "TestConfigurationId",
      "contained": [
        {
          "resourceType": "DeviceDefinition",
          "modelNumber": "ABC123"
        }
      ],
      "definition": {
        "reference": "#definition"
      }
    },
    {
      "resourceType": "DigitalSample",
      "id": "DigitalSampleId"
    }
  ],
  "extension": [
    {
      "url": "http://MyOrganization.com/fhir/R4/StructureDefinition/Basic-TestConfiguration",
      "valueReference": {
        "reference": "#testConfiguration"
      }
    },
    {
      "url": "http://MyOrganization.com/fhir/R4/StructureDefinition/Basic-DigitalSample",
      "valueReference": {
        "reference": "#digitalSampleId"
      }
    }
  ]
}
Rjeymonk
  • 23
  • 4
  • 1
    TestInput and TestConfiguration aren't valid resource types. Also, a contained resource can't have contained resources. So you're pretty far outside the FHIR spec. Implementations aren't allowed to define their own resources - at least not if they want to be conformant. – Lloyd McKenzie Apr 24 '21 at 23:10

1 Answers1

0

Every local reference must point to an id of a contained resource. In your case it should be:

"reference": "#TestConfigurationId"
"reference":"#DigitalSampleId"

Always check https://www.hl7.org/fhir/ for what you need to do. Always check the FHIR version

bogdan ioan
  • 378
  • 3
  • 7