clinical_quality_language icon indicating copy to clipboard operation
clinical_quality_language copied to clipboard

Add CQL operation for returning resources with subset of fields/properties

Open JPercival opened this issue 2 years ago • 2 comments

Being able to manipulate the values of individual elements in a return, rather than having to re-state the entire resource.

define function "MedicationRequestResource"(medicationRequest MedicationRequest, profileURLs List<FHIR.canonical>):
  medicationRequest m
  return MedicationRequest{
    id: FHIR.id {value: 'LCR-' + m.id},
    meta: MetaElement(medicationRequest, profileURLs),
    extension: m.extension,
    identifier: m.identifier,
    status: m.status,
    statusReason: m.statusReason,
    intent: m.intent,
    category: m.category,
    priority: m.priority,
    doNotPerform: m.doNotPerform,
    reported: m.reported,
    medication: m.medication,
    subject: m.subject,
    encounter: m.encounter,
    supportingInformation: m.supportingInformation,
    authoredOn: m.authoredOn,
    requester: m.requester,
    performer: m.performer,
    performerType: m.performerType,
    recorder: m.recorder,
    reasonCode: m.reasonCode,
    reasonReference: m.reasonReference,
    instantiatesCanonical: m.instantiatesCanonical,
    instantiatesUri: m.instantiatesUri,
    basedOn: m.basedOn,
    groupIdentifier: m.groupIdentifier,
    courseOfTherapyType: m.courseOfTherapyType,
    insurance: m.insurance,
    note: m.note,
    dosageInstruction: m.dosageInstruction,
    dispenseRequest: m.dispenseRequest,
    substitution: m.substitution,
    priorPrescription: m.priorPrescription,
    detectedIssue: m.detectedIssue,
    eventHistory: m.eventHistory
  }

JPercival avatar Sep 26 '23 17:09 JPercival

@brynrhodes - Looks to me that this is a request that would require updating the CQL spec. I don't think CQL has a story for this currently. Something like:

define "Clones":
  [Encounter] E return E.Clone({ id:  'Prefix-' + E.id})

Where the parameters are the set of key-value pairs to override. I think doing this in a type-safe way for arbitrary data types requires higher-kinded type parameters, which CQL doesn't support. The non-type-safe equivalent could result in runtime errors.

JPercival avatar Sep 27 '23 21:09 JPercival

Discussed with Bryn on a side-channel. This would require a change to the CQL specification and will be under consideration for the CQL 2.0 spec. So while it's not being closed forever, it'll be on the backlog a while before we decide what to do with it.

JPercival avatar Sep 28 '23 21:09 JPercival