Search code examples
hl7-fhir

FHIR CodableConcept - All elements must be from ValueSet - Writing Profile Differential


I want to create a profile from base Observation, in that all code elements must be from the ValueSet. For example:

{
  "resourceType": "Observation",
  "id": "example",
  "meta": {
    "profile": ["http://my.own.profile/StructureDefinition/custom-observation-profile"]
  }

  ...

  "code": {
    "coding": [
      {
        "system": "http://loinc.org",
        "code": "8867-4",
        "display": "Body Weight"
      },
      {
        "system": "http://loinc.org",
        "code": "9843-4",
        "display": "Body Weight"
      }
    ]
  },
... 

All the elements from code.coding should be from a valueset, lets say http://my.value.set

In the differential, I have the following:

      {
        "id": "Observation.code",
        "path": "Observation.code",
        "short": "Body Weight",
        "type": [
          {
            "code": "CodeableConcept"
          }
        ],
        "binding": {
          "strength": "required",
          "description": "All LOINC  values whose SCALE is DOC in the LOINC database and the HL7 v3 Code System NullFlavor concept 'unknown'",
          "valueSet": "http://my.value.set"
        }
      },

But this one is validating only the first element in the list. It does not validate the other ones. It ignores even if they are invalid.

The list can be 1..*, and I want all of them should be from the valueSet.

How do I write differential for this one?


Solution

  • The expectation when there's a required binding on a CodeableConcept is that one of the CodeableConcept.coding repetitions must come from the binding. There's no requirement that the others must - and the primary use for additional codings is that you don't want them to be from the same value set. The purpose of additional codings is to convey other codes from other code systems that also convey the same meaning (so that other recipients of the instance who might not necessarily recognize the code preferred by your profile can still find a code they recognize - and also so that the 'original' coding can be retained in cases where that isn't from the bound value set).

    If you truly want to force all CodeableConcept.coding repetitions to be from a single value set (strongly discouraged and likely to impede interoperability), you could declare a binding on Observation.code.coding.