Skip to content

Profiling

The FHIR specification defines a set of base resources. All those resources could be used by any fhir application. As those resources are very common so local rules could require more detailed validations. In this case every person or organisation who uses the FHIR server could create their own profiles.

Kodjin support two ways of adding, updating and deleting profiles:

  • You can add them using API
  • Or you can adjust fhir-server-fixture-worker and manage profiles through gitHub repository

Changing Cardinality

Changing cardinality allows you to redefine which elements should be required in the profile and which elements should be omitted. In the case of an array, you can define the minimum required amount of elements in it and the maximum. For example, you can restrict an array in your profile to always have not fewer than two elements in it and no more than four. Example of varying cardinality values:

Example of changed cardinality

```
{
"min": 2,
"max": "4",
"base": {
    "path": "Element.extension",
    "min": 0,
    "max": "*"
}
```

Whether an element is an object or an array is defined by its base cardinality, which is not to be changed: max>1 means array, and max=1 means object. In case of cardinality changes not in accordance with the FHIR specification, the Kodjin FHIR Server will notify users with an error during posting, updating, or operation $validate.

Extensions

While profiles are usually used to restrict existing elements, extensions are designed to add new ones to a resource. Every element in a resource can have extension child elements to represent additional information that is not part of the basic definition of the resource. The FHIR specification provides a list of standard extensions, it is useful to check that list before creating your own extension. In order to use an extension in a resource, you have to specify both the URL and value of such an extension.

Example with standard extension patient-religion

```
"extension": [
    {
        "url": "http://demo.kodjin.coma/fhir/StructureDefinition/extension-patient-religion",
        "valueCodeableConcept": {
            "coding": [
                {
                    "code": "5",
                    "system": "http://demo.kodjin.com/terminology/CodeSystem/extension-religion"
                }
            ]
        }
    }
]
```

If standard extensions do not cover your case, you can add your own extension to the Kodjin FHIR server, using the same tools as for adding profiles. In case you have a complex extension that has more than one value, you can add extensions inside the extension and slice them by the URL (read more about slicing here).

Example of a complex extension

    { // PatNationality
        "extension" : [ // sliced by value:url  in the specified order, Open 
        { // Nationality Code // I
            // from Element: extension
            "extension" : [ // sliced by value:url  in the specified order, Open ]
            "url" : "code", // R! 
            "valueCodeableConcept" : { CodeableConcept } // I R! Value of extension
        },
        { // Nationality Period // I
            // from Element: extension
            "extension" : [ // sliced by value:url  in the specified order, Open ]
            "url" : "period", // R! 
            "valuePeriod" : { Period } // I R! Value of extension
        }
        ],
        "extension" : [{ Extension }], // IAdditional content defined by implementations
        "extension" : { Extension }, // INationality Code
        "extension" : { Extension }, // INationality Period
        "url" : "http://hl7.org/fhir/StructureDefinition/patient-nationality" // R! 
    // value[x]: Value of extension: Prohibited
    }

This extension allows adding information about patients' citizenship to the resource. It consists of two more extensions, sliced by URL, - one for “code” and one for “period”.

Example of use in a resource

    "extension": [
            {
                "url": "http://hl7.org/fhir/StructureDefinition/patient-nationality",
                "extension": [
                    {
                        "url": "code",
                        "valueString": "some value"
                    },
            {
                        "url": "period",
                        "valuePeriod": {
                    “end”: “2022”
                }
                    }
                ]
            }
        ]

Slicing

Slicing allows users to restrict rules on which instances of backbone elements can or must be present in a list and with which characteristics. For example, a Blood Pressure Observation should contain two backbone elements in the "component" list: one with code "8480-6" to represent systolic blood pressure and one with code "8462-4" to represent diastolic blood pressure. Each backbone element should have a value of type quantity. These rules make two slices for the "component" element—"systolic" slice and "diastolic" slice. Another example can be restricting the "contact" list in the Patient resource to always have the organization specified if contact type is "Insurance Company" and telecom if it is "Emergency Contact". More slicing use cases and examples can be found here

Discriminator

Discriminator is used to distinguish one slice from another. FHIR declares the next discriminators for slicing:

type description status
value The slices have different values in the nominated element. supported
exists The slices are differentiated by the presence or absence of the nominated element. unsupported
pattern The slices have different values in the nominated element, as determined by testing them against the applicable ElementDefinition.pattern[x]. supported
type The slices are differentiated by type of the nominated element. supported
profile The slices are differentiated by conformance of the nominated element to a specified profile. unsupported

More information about slicing and discriminators can be found in fhir documentation