Skip to content

Translator (2.3.0) Unions Same Retrieve With Itself #841

@cmoesel

Description

@cmoesel

Given the following CQL:

library Example version '1.0.0'
using FHIR version '4.0.1'
valueset "Opioid Pain Medications": 'https://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1032.34'
define MyRetrieve: [MedicationRequest: "Opioid Pain Medications"]

the CQL-to-ELM Translator 2.3.0 produces the following definition:

{
   "name" : "MyRetrieve",
   "context" : "Patient",
   "accessLevel" : "Public",
   "expression" : {
      "type" : "Union",
      "operand" : [ {
         "dataType" : "{http://hl7.org/fhir}MedicationRequest",
         "templateId" : "http://hl7.org/fhir/StructureDefinition/MedicationRequest",
         "codeProperty" : "medication",
         "codeComparator" : "in",
         "type" : "Retrieve",
         "codes" : {
            "name" : "Opioid Pain Medications",
            "preserve" : true,
            "type" : "ValueSetRef"
         }
      }, {
         "dataType" : "{http://hl7.org/fhir}MedicationRequest",
         "templateId" : "http://hl7.org/fhir/StructureDefinition/MedicationRequest",
         "codeProperty" : "medication",
         "codeComparator" : "in",
         "type" : "Retrieve",
         "codes" : {
            "name" : "Opioid Pain Medications",
            "preserve" : true,
            "type" : "ValueSetRef"
         }
      } ]
   }
}

As you can see, it took the retrieve ([MedicationRequest: "Opioid Pain Medications"]) and unioned it with itself.

If I had to guess, I'd guess that the translator is trying to be smart and union a retrieve using medicationCodeableConcept and another retrieve using medicationReference -- but it's not doing it right.

Although the end result is logically equivalent (since duplicates are removed), it probably isn't great for performance, especially when the retrieves are large.

BTW -- changing the retrieve to [MedicationRequest: medication in "Opioid Pain Medications"] gives the expected definition even though it's basically just an explicit way of saying what the other retrieve said implicitly (since the primaryCodePath is medication):

{
   "name" : "MyRetrieve",
   "context" : "Patient",
   "accessLevel" : "Public",
   "expression" : {
      "dataType" : "{http://hl7.org/fhir}MedicationRequest",
      "templateId" : "http://hl7.org/fhir/StructureDefinition/MedicationRequest",
      "codeProperty" : "medication",
      "codeComparator" : "in",
      "type" : "Retrieve",
      "codes" : {
         "name" : "Opioid Pain Medications",
         "preserve" : true,
         "type" : "ValueSetRef"
      }
   }
}

As far as I can tell, this only happens for some resources (like MedicationRequest and MedicationStatement), hence my guess that it has to do with the primaryCodePath pointing to a choice element.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions