Open JSRankins opened 2 years ago
@JSRankins I was able to get a result by adding a subject.
{
"resourceType": "MedicationRequest",
"id": "numer-pos-HFACEIorARBorARNIforLVSDQICore4-5",
"status": "active",
"intent": "order",
"medicationReference": {
"reference": "Medication/numer-pos-HFACEIorARBorARNIforLVSDQICore4-6"
},
"subject": {
"reference": "Patient/hist-closed-HCC189"
}
}
=>
MedicationRequest Test=[MedicationRequest(id=numer-pos-HFACEIorARBorARNIforLVSDQICore4-5)]
Which would make sense if it were in Patient context.
But I also tried moving it out of Patient context:
define "MedicationRequest Test":
[MedicationRequest]
context Patient
and did not get a MR unless I had the subject.
I also tried no context at all:
library TestMR version '0.0.1'
using FHIR version '4.0.1'
define "MedicationRequest Test":
[MedicationRequest]
^that's my entire file... and no MR unless the MR resource has a subject.
Now that I think about it, I think there's something about the vs code plugin that behaves like there's patient context regardless. Like it expects the evaluation to be in context of a Patient.
IOW, I think what you're seeing is expected (albeit maybe surprising) behavior for the VS Code plugin.
But Bryn/JP would need to verify.
And you can get the behavior you expect by adding a subject reference to your MedicationRequest resource.
Thanks @rob-reynolds. I can confirm that the addition of a subject to the resource allowed me to return the MedicationRequest. Perhaps the missing required element caused the MedicationResource not to return. Not sure. If that's true, it would have been more user-friendly to identify that as the cause in the resulting output.
@JPercival and @brynrhodes , there does not appear to be a return of MedicationRequest resource when provided the following CQL and a Bundle containing a MedicationRequest Resource:
CQL
define "MedicationRequest Test": [MedicationRequest]
Resource Bundle
{ "resourceType": "Bundle", "id": "tests-numer-pos-HFACEIorARBorARNIforLVSDQICore4-bundle", "type": "transaction", "entry": [ { "resource": { "resourceType": "Medication", "id": "numer-pos-HFACEIorARBorARNIforLVSDQICore4-6", "meta": { "profile": [ "http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medication" ] }, "code": { "coding": [ { "system": "http://www.nlm.nih.gov/research/umls/rxnorm", "code": "1091646", "display": "azilsartan medoxomil 40 MG Oral Tablet" } ] } }, "request": { "method": "PUT", "url": "Medication/numer-pos-HFACEIorARBorARNIforLVSDQICore4-6" } }, { "resource": { "resourceType": "MedicationRequest", "id": "numer-pos-HFACEIorARBorARNIforLVSDQICore4-5", "meta": { "profile": [ "http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medicationrequest" ] }, "status": "active", "intent": "order", "medicationReference": { "reference": "Medication/numer-pos-HFACEIorARBorARNIforLVSDQICore4-6" }, "authoredOn": "2022-03-02T10:15:00.000Z", "note": [ { "text": "Patient told to take with food" } ], "dosageInstruction": [ { "sequence": 1, "text": "One tablet", "additionalInstruction": [ { "coding": [ { "system": "http://snomed.info/sct", "code": "311504000", "display": "With or after food" } ] } ], "timing": { "repeat": { "frequency": 1, "period": 1, "periodUnit": "d" } }, "route": { "coding": [ { "system": "http://snomed.info/sct", "code": "26643006", "display": "Oral Route" } ] }, "method": { "coding": [ { "system": "http://snomed.info/sct", "code": "421521009", "display": "Swallow - dosing instruction imperative (qualifier value)" } ] }, "doseAndRate": [ { "type": { "coding": [ { "system": "http://terminology.hl7.org/CodeSystem/dose-rate-type", "code": "ordered", "display": "Ordered" } ] }, "doseQuantity": { "value": 1, "unit": "TAB", "system": "http://terminology.hl7.org/CodeSystem/v3-orderableDrugForm", "code": "TAB" } } ] }, { "sequence": 2, "text": "One tablet daily", "additionalInstruction": [ { "coding": [ { "system": "http://snomed.info/sct", "code": "311504000", "display": "With or after food" } ] } ], "timing": { "repeat": { "frequency": 1, "period": 1, "periodUnit": "d" } }, "route": { "coding": [ { "system": "http://snomed.info/sct", "code": "26643006", "display": "Oral Route" } ] }, "doseAndRate": [ { "type": { "coding": [ { "system": "http://terminology.hl7.org/CodeSystem/dose-rate-type", "code": "ordered", "display": "Ordered" } ] }, "doseQuantity": { "value": 1, "unit": "TAB", "system": "http://terminology.hl7.org/CodeSystem/v3-orderableDrugForm", "code": "TAB" } } ] } ], "dispenseRequest": { "validityPeriod": { "start": "2022-03-02", "end": "2022-05-31" }, "numberOfRepeatsAllowed": 2, "quantity": { "value": 30, "unit": "TAB", "system": "http://terminology.hl7.org/CodeSystem/v3-orderableDrugForm", "code": "TAB" }, "expectedSupplyDuration": { "value": 30, "unit": "days", "system": "http://unitsofmeasure.org", "code": "d" } }, "substitution": { "allowedBoolean": true, "reason": { "coding": [ { "system": "http://terminology.hl7.org/CodeSystem/v3-ActReason", "code": "FP", "display": "formulary policy" } ] } } }, "request": { "method": "PUT", "url": "MedicationRequest/numer-pos-HFACEIorARBorARNIforLVSDQICore4-5" } } ] }
Result is an empty array: []
I even tried using a medicationCodeableConcept in the above MedicationRequest resource (as opposed to medicationReference), and still no result.
Thoughts?