cqf-tooling icon indicating copy to clipboard operation
cqf-tooling copied to clipboard

ModelInfo for observation-bp status binding is ambiguous

Open brynrhodes opened this issue 3 months ago • 1 comments

In profile-informed models, the mapping layer is intended to map all references to elements in profiles down to their base FHIR equivalents. In the case of a binding, the use of the element-binding-name extension is causing an ambiguity because the profile is overriding the element-binding-name. Specifically, for observation-bp, the status binding renames the base ObservationStatus to Status, resulting in an ambiguous type name.

Given the following expression (from https://github.com/cqframework/ecqm-content-qicore-2024/blob/main/input/cql/Status.cql#194):

define function "BloodPressure"(Obs List<"QICore.observation-bp">):
  Obs O
    where O.status in { 'final', 'amended', 'corrected' }

The ELM output is:

 "operand" : [ {
                     "locator" : "195:11-195:18",
                     "resultTypeName" : "{http://hl7.org/fhir}Status",
                     "path" : "value",
                     "type" : "Property",
                     "source" : {
                        "path" : "status",
                        "scope" : "O",
                        "type" : "Property"
                     }
                  },

As we can see, this refers to a FHIR binding {http://hl7.org/fhir}Status. This binding can indeed be found in the FHIR specification, but is used for VerificationResult.status. Since the CQL here is referring to Observation.status (for which the binding name is {http://hl7.org/fhir}ObservationStatus), our ELM->C# compiler reports a type error.

This is due to the elementdefinition-bindingname extension that appears on the binding of the status element in the profile (https://hl7.org/fhir/bp.profile.xml.html):

      <binding>
        <extension url="http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName">
          <valueString value="Status"/>
        </extension>
        <strength value="required"/>
        <valueSet value="http://hl7.org/fhir/ValueSet/observation-status"/>
      </binding>

The fix is most likely to use the elementdefinition-bindingname from the base resource definition, rather than the name of the binding in the profile.

brynrhodes avatar Mar 08 '24 16:03 brynrhodes