References

Reference types:

  • absolute reference
  • relative reference, which is relative to the Service Base URL
  • logical Reference
  • conditional reference
  • urn:uuid
  • internal fragment reference (for "Contained Resources")

Absolute reference.

Absolute reference is a reference that points to other fhir server. Kodjin does not validate an absolute reference.

example of the reference:

{
    "reference": "https://any.name.for.fhir-server.com/Organization/12345"
}

Relative reference.

Relative reference is a reference that

  • consits of a resourceType and logical id of the resource.

    {
        "reference": "Organization/12345"
    }
    

  • or is an absolute referense that starts with the domain name.

    {
        "reference": "https://demo.kodjin.com/fhir/Organization/12345"
    }
    
    Kodjin validates that relative reference exists in the data base. If there is no such resource Kodjin will return an error. If this type of reference is present in the bundle with type transaction, then Kodjin validates that reference is in the data base or in the current Bindle.

Logical Reference.

Reference that does not exist in current data base could be presented in the type of identifier.

"identifier":{
    "system": "https://example.com/Organization",
    "value": "12345"
}
Kodjin validates reference as identifier according to the StructureDefinition.

Conditional reference.

When users do not know the logical reference of the resource they could use conditinal reference in the bundles.

{
    "reference": "Organization?identifier=12345"
}

Kodjin performs search during validating such reference. And only with a single match will return no error during validation. In all other case, like no matches, multiple match, validation will return an error. While saving resources with conditional reference to DB, Kodjin changes conditional reference to relative reference

urn:uuid

While posting a Bundle user could not know logical IDs for resources in the Bundle. In this case in oder to reference such resources in the Bundle from other resources in the same Bundle 'urn:uuid' fullUrl could be used.

{
    "resourceType": "Bundle",
    "id": "bundle_id",
    "type": "transaction",
    "entry": [
        {
            "fullUrl": "Patient/patient_id",
            "resource": {
                "resourceType": "Patient",
                "managingOrganization":{
                    "reference": "urn:uuid:7c6f767d-b302-4ef6-bd6f-29aab87a958b"
                }
            },
            "request": {
                "method": "POST",
                "url": "Patient"
            }
        },
        {
            "fullUrl": "urn:uuid:7c6f767d-b302-4ef6-bd6f-29aab87a958b",
            "resource": {
                "resourceType": "Organization",
                "id":"{{generated_organization_id}}",
                "name": "Organization"
            },
            "request": {
                "method": "POST",
                "url": "Organization"
            }
        }
    ]
}
When saving such resource Kodjin will change 'urn:uuid' reference to the relative reference of the resource. So that, for the example above the managingOrganization reference in the DB will look like

"managingOrganization": {
                    "reference": "Organization/{{generated_organization_id}}"
                }

Internal fragment reference (for "Contained Resources")

If user wants to reference a contained resource (more about contained resource here) the special type of reference should be used

{
    "reference": "#reference-to-contained-resource"
}
In the same way works references between contained resources.

Also the contained resource could reference resource for which it is a contained one

{
    "reference": "#"
}