Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix naloxone alert for active opioid meds only #217

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 28 additions & 4 deletions src/config/summary_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,34 @@
},
{
"flag": {
"ifOneOrMore": {
"table": "MedicationRequestsForNaloxoneConsideration",
"source": "RiskConsiderations"
}
"ifAnd": [
{
"ifEqualTo": {
"header": "Class",
"targetValue": "opioid"
}
},
{
"ifGreaterThanOrEqualTo": {
"header": "MME",
"targetValue": 50
}
},
{
"ifEqualTo": {
"header": "isActive",
"type": "boolean",
"targetValue": true
}
},
{
"ifEqualTo": {
"header": "isBup",
"type": "boolean",
"targetValue": false
}
}
]
},
"flagText": "Current MME 50 or more, consider prescribing Naloxone",
"flagClass": "info"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,8 @@ define ReportPDMPMedicationRequests:
CalculatedEnd: GetMedicationRequestEndDate(O),
dispenseRequest: O.dispenseRequest,
MME_Object: MMECalculator.MME(O),
c: (O.medication as FHIR.CodeableConcept)
c: (O.medication as FHIR.CodeableConcept),
RxnormCode: Coalesce((c.coding) c2 where c2.system.value ~ 'http://www.nlm.nih.gov/research/umls/rxnorm' return c2.code.value)
return {
Type: 'Request',
Name: ConceptText(c),
Expand All @@ -744,7 +745,9 @@ define ReportPDMPMedicationRequests:
Prescriber: O.requester.display.value,
Pharmacy: GetMedicationRequestPharmacy(O),
NDC_Code: Coalesce((c.coding) c2 where c2.system.value ~ 'http://hl7.org/fhir/sid/ndc' return c2.code.value),
RXNorm_Code: Coalesce((c.coding) c2 where c2.system.value ~ 'http://www.nlm.nih.gov/research/umls/rxnorm' return c2.code.value),
RXNorm_Code: RxnormCode,
isBup: RxnormCode in BuprenorphineRxCUIs,
isActive: CalculatedEnd same or after Today(),
Status: O.status.value,
Class: getMedicationRequestDrugClass(O),
AuthoredOn: O.authoredOn
Expand Down
111 changes: 70 additions & 41 deletions src/cql/r4/Factors_to_Consider_in_Managing_Chronic_Pain_FHIRv400.json
Original file line number Diff line number Diff line change
Expand Up @@ -4607,6 +4607,53 @@
"type" : "NamedTypeSpecifier"
}
}
}, {
"identifier" : "RxnormCode",
"expression" : {
"type" : "Coalesce",
"operand" : [ {
"type" : "Query",
"source" : [ {
"alias" : "c2",
"expression" : {
"path" : "coding",
"type" : "Property",
"source" : {
"name" : "c",
"type" : "QueryLetRef"
}
}
} ],
"relationship" : [ ],
"where" : {
"type" : "Equivalent",
"operand" : [ {
"path" : "value",
"type" : "Property",
"source" : {
"path" : "system",
"scope" : "c2",
"type" : "Property"
}
}, {
"valueType" : "{urn:hl7-org:elm-types:r1}String",
"value" : "http://www.nlm.nih.gov/research/umls/rxnorm",
"type" : "Literal"
} ]
},
"return" : {
"expression" : {
"path" : "value",
"type" : "Property",
"source" : {
"path" : "code",
"scope" : "c2",
"type" : "Property"
}
}
}
} ]
}
} ],
"relationship" : [ ],
"return" : {
Expand Down Expand Up @@ -4885,48 +4932,30 @@
}, {
"name" : "RXNorm_Code",
"value" : {
"type" : "Coalesce",
"name" : "RxnormCode",
"type" : "QueryLetRef"
}
}, {
"name" : "isBup",
"value" : {
"type" : "In",
"operand" : [ {
"type" : "Query",
"source" : [ {
"alias" : "c2",
"expression" : {
"path" : "coding",
"type" : "Property",
"source" : {
"name" : "c",
"type" : "QueryLetRef"
}
}
} ],
"relationship" : [ ],
"where" : {
"type" : "Equivalent",
"operand" : [ {
"path" : "value",
"type" : "Property",
"source" : {
"path" : "system",
"scope" : "c2",
"type" : "Property"
}
}, {
"valueType" : "{urn:hl7-org:elm-types:r1}String",
"value" : "http://www.nlm.nih.gov/research/umls/rxnorm",
"type" : "Literal"
} ]
},
"return" : {
"expression" : {
"path" : "value",
"type" : "Property",
"source" : {
"path" : "code",
"scope" : "c2",
"type" : "Property"
}
}
}
"name" : "RxnormCode",
"type" : "QueryLetRef"
}, {
"name" : "BuprenorphineRxCUIs",
"type" : "ExpressionRef"
} ]
}
}, {
"name" : "isActive",
"value" : {
"type" : "SameOrAfter",
"operand" : [ {
"name" : "CalculatedEnd",
"type" : "QueryLetRef"
}, {
"type" : "Today"
} ]
}
}, {
Expand Down
7 changes: 5 additions & 2 deletions src/helpers/flagit.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export default function flagit(entry, subSection, summary) {
function ifAnd(flagRulesArray, entry, subSection, summary) {
for (let i = 0; i < flagRulesArray.length; ++i) {
const flagRule = flagRulesArray[i];

let match;
if (typeof flagRule === 'string') {
match = functions[flagRule](entry, entry, subSection, summary);
Expand Down Expand Up @@ -120,14 +119,18 @@ function ifGreaterThanOrEqualTo(value, entry, subSection, summary) {
if (Array.isArray(targetEntry) && targetEntry.length) {
targetEntry = targetEntry[0]
}
return parseInt(targetEntry[value.header], 10) >= value.value;
const valueToCompare = value.targetValue != null ? value.targetValue : value.value;
return parseInt(targetEntry[value.header], 10) >= valueToCompare;
}
/*
* return true if an entry's value for a field matches the specified target value
*/
function ifEqualTo(value, entry, subSection, summary) {
if (!entry) return false;
if (Array.isArray(entry[value.header])) return entry[value.header].indexOf(value.targetValue) !== -1;
if (value.type === "boolean") {
return Boolean(entry[value.header]) === Boolean(value.targetValue);
}
return entry[value.header] === value.targetValue;
}
/*
Expand Down
Loading