Clinical Practice Guidelines Example Implementation Guide - Anthrax Post-Exposure Prophylaxis, published by HL7 International - Clinical Decision Support WG. This guide is not an authorized publication; it is the continuous build for version 1.1.0 built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/cqframework/cpg-example-anthrax/ and changes regularly. See the Directory of published versions
Draft as of 2024-08-23 |
@prefix fhir: <http://hl7.org/fhir/> . @prefix owl: <http://www.w3.org/2002/07/owl#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . # - resource ------------------------------------------------------------------- a fhir:Library ; fhir:nodeRole fhir:treeRoot ; fhir:id [ fhir:v "cds-connect-commons-library"] ; # fhir:text [ fhir:status [ fhir:v "generated" ] ; fhir:div "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p class=\"res-header-id\"><b>Generated Narrative: Library cds-connect-commons-library</b></p><a name=\"cds-connect-commons-library\"> </a><a name=\"hccds-connect-commons-library\"> </a><a name=\"cds-connect-commons-library-en-US\"> </a><h2>Participants</h2><table class=\"grid\"><tr><td>Author</td><td>Alliance to Modernize Healthcare FFRDC</td></tr><tr><td>Endorser</td><td>Centers for Disease Control and Prevention</td></tr></table><h2>Contents</h2><p><code>text/cql</code></p><pre><code>// CDS Connect Commons for FHIRv400\n// Change log:\n// - 1.3.1:\n// - Changed C.dateRecorded to C.dateRecorded.value in ConditionLookBack\n// - Changed G.statusDate to G.statusDate.value in GoalLookBack\n// - 1.3.2:\n// - Added NotCancelled() and EncounterLookback() functions.\nlibrary CDS_Connect_Commons_for_FHIRv400 version '1.3.2'\n\nusing FHIR version '4.0.0'\n\n// Include the FHIRHelpers library for simplifying interacton w/ the FHIR data model\ninclude FHIRHelpers version '4.0.0' called FHIRHelpers\n\ncodesystem "Condition Verification Status Codes": 'http://terminology.hl7.org/CodeSystem/condition-ver-status'\ncodesystem "Condition Clinical Status Codes": 'http://terminology.hl7.org/CodeSystem/condition-clinical'\ncodesystem "AllergyIntolerance Verification Status Codes": 'http://terminology.hl7.org/CodeSystem/allergyintolerance-verification'\n\ncode "Condition verificationStatus confirmed code": 'confirmed' from "Condition Verification Status Codes" display 'Confirmed'\ncode "Condition clinicalStatus active code": 'active' from "Condition Clinical Status Codes" display 'Active'\ncode "Condition clinicalStatus recurrence code": 'recurrence' from "Condition Clinical Status Codes" display 'Recurrence'\ncode "Condition clinicalStatus relapse code": 'relapse' from "Condition Clinical Status Codes" display 'Relapse'\ncode "AllergyIntolerance verificationStatus confirmed code": 'confirmed' from "AllergyIntolerance Verification Status Codes" display 'Confirmed'\n\n// -------------------------------------------------- GENERAL ---------------------------------------------------------\n\n/**\n * A null-safe version of ToConcept. Whereas FHIRHelpers.ToConcept will take a null argument and produce a\n * System.Concept that is empty, this implementation returns null instead.\n * @param C - a FHIR CodeableConcept\n * @returns {System.Concept} a CQL Concept or null if null was passed in\n */\ndefine function NullSafeToConcept(Cpt FHIR.CodeableConcept):\n if Cpt is not null then FHIRHelpers.ToConcept(Cpt) else null\n\n/**\n * A null-safe version of ToInterval for Period. Whereas FHIRHelpers.ToInterval will take a null argument and produce a\n * System.Interval that is empty, this implementation returns null instead.\n * @param P - a FHIR Period\n * @returns {System.Interval} a CQL Interval or null if null was passed in\n */\ndefine function NullSafePeriodToInterval(Pd FHIR.Period):\n if Pd is not null then Interval[Pd."start".value, Pd."end".value] else null\n\n/**\n * A null-safe version of ToInterval for Range. Whereas FHIRHelpers.ToInterval will take a null argument and produce a\n * System.Interval that is empty, this implementation returns null instead.\n * @param P - a FHIR Range\n * @returns {System.Interval} a CQL Interval or null if null was passed in\n */\ndefine function NullSafeRangeToInterval(Rg FHIR.Range):\n if Rg is not null\n then Interval[NullSafeToQuantity(Rg.low), NullSafeToQuantity(Rg.high)]\n else null\n\n/**\n * Same as NullSafePeriodToInterval; kept for backward compatibility. [Deprecated]\n * @param P - a FHIR Period\n * @returns {System.Interval} a CQL Interval or null if null was passed in\n */\ndefine function NullSafeToInterval(Pd FHIR.Period):\n NullSafePeriodToInterval(Pd)\n\n/**\n * A null-safe version of ToQuantity. Whereas FHIRHelpers.ToQuantity will take a null argument and produce a\n * System.Quantity that is empty, this implementation returns null instead.\n * @param C - a FHIR Quantity\n * @returns {System.Quantity} a CQL Quantity or null if null was passed in\n */\ndefine function NullSafeToQuantity(Qty FHIR.Quantity):\n if Qty is not null then\n System.Quantity {\n value: Qty.value.value,\n unit: Coalesce(Qty.unit.value, Qty.code.value)\n }\n else null\n\n// -------------------------------------------------- OBSERVATIONS -----------------------------------------------------\n\n/**\n * Filters Observations by a concept rather than by a ValueSet. In CQL 1.3, this will be built into the retrieve,\n * but for now, we must use a query where clause.\n * @param Koncept - the concept to filter on (intentionally mispelled to avoid naming clashes)\n * @returns {List<Observation>} a list of Observations matching the concept, or null if null was passed in\n */\ndefine function ObservationsByConcept(Koncept System.Concept):\n [Observation] O where NullSafeToConcept(O.code) ~ Koncept\n\n/**\n * Observations that are complete and verified. In FHIR R4, there are two statuses that indicate this state: 'final'\n * and 'amended'.\n * @see https://www.hl7.org/fhir/valueset-observation-status.html\n * @param ObsList - a list of Observations\n * @returns {List<Observation>} a list of verified Observations, or null if null was passed in\n */\ndefine function Verified(ObsList List<Observation>):\n ObsList O where O.status.value in {'final', 'amended'}\n\n/**\n * Observations that have quantity values recorded in the requested unit.\n * @param ObsList - a list of Observations\n * @param Unit - the unit to require in the Observations quantity value\n * @returns {List<Observation>} a list of Observations with the required unit, or null if null was passed in\n */\ndefine function WithUnit(ObsList List<Observation>, Unit String):\n ObsList O where O.value.unit.value = Unit or O.value.code.value = Unit\n\n/**\n * Observations with an effective or issued date in the specified "look back" period. For example, LDL-C Tests in the\n * last 6 years.\n * TODO: Rename to LookBack once the execution engine supports overloaded functions.\n * @param ObsList - a list of Observations\n * @returns {List<Observation>} a list of Observations with effective or issued date specified lookback period, or null\n * if null was passed in\n */\ndefine function ObservationLookBack(ObsList List<Observation>, LookBack System.Quantity):\n ObsList O\n let LookBackInterval: Interval[Now() - LookBack, Now()]\n where O.effective.value in LookBackInterval\n or NullSafeToInterval(O.effective) overlaps LookBackInterval\n or O.issued.value in LookBackInterval\n\n/**\n * The most recent observation. For each Observation, this algorithm will use the FindDate function, which uses the\n * first non-null date value from these fields: effectiveDateTime, effectivePeriod.end, effectivePeriod.start, issued.\n * The found date will be used to compare Observations and determine the most recent one.\n * @see FindDate(Observation)\n * @param ObsList - a list of Observations\n * @returns {Observation} the most recent Observation from the list, or null if null was passed in\n */\ndefine function MostRecent(ObsList List<Observation>):\n Last(ObsList O sort by Coalesce(effective.value, effective."end".value, effective."start".value, issued.value))\n\n/**\n * Extracts the quantity value from an Observation, returning it as a CQL Quantity\n * @param Obs - an observation\n * @returns {System.Quantity} the Observation's value as a quantity, or null if there is no quantity value\n */\ndefine function QuantityValue(Obs Observation):\n NullSafeToQuantity(Obs.value)\n\n/**\n * Extracts the CodeableConcept value from an Observation, returning it as a CQL Concept\n * @param Obs - an observation\n * @returns {System.Concept} the Observation's value as a concept, or null if there is no CodeabeConcept value\n */\ndefine function ConceptValue(Obs Observation):\n NullSafeToConcept(Obs.value)\n\n/**\n * Finds the first non-null meaningful date that can be associated with this Observation. This will look through the\n * following fields in the following order: effectiveDateTime, effectivePeriod.end, effectivePeriod.start, issued.\n * @param Obs - an Observation\n * @returns {System.DateTime} the first non-null meaningful date, or null if non is found\n */\ndefine function FindDate(Obs Observation):\n Coalesce(Obs.effective.value, Obs.effective."end".value, Obs.effective."start".value, Obs.issued.value)\n\n// TODO: Confirm that this works as expected\n/**\n * The highest observation.\n * The value will be used to compare Observations and determine the highest one.\n * @param ObsList - a list of Observations\n * @returns {System.Quantity} the quantity with the highest value from the list, or null if null was passed in\n */\ndefine function HighestObservation(ObsList List<Observation>):\n Max(ObsList O return NullSafeToQuantity(O.value))\n\n\n// -------------------------------------------------- CONDITIONS -------------------------------------------------------\n\n/**\n * Filters Conditions by a concept rather than by a ValueSet. In CQL 1.3, this will be built into the retrieve,\n * but for now, we must use a query where clause.\n * @param Koncept - the concept to filter on (intentionally mispelled to avoid naming clashes)\n * @returns {List<Observation>} a list of Conditions matching the concept, or null if null was passed in\n */\ndefine function ConditionsByConcept(Koncept System.Concept):\n [Condition] C where NullSafeToConcept(C.code) ~ Koncept\n\n/**\n * Conditions that are confirmed. In FHIR R4, this is reflected by verificationStatus: 'confirmed'.\n * @see https://www.hl7.org/fhir/valueset-condition-ver-status.html\n * @param CondList - a list of Conditions\n * @returns {List<Condition>} a list of confirmed Conditions, or null if null was passed in\n */\ndefine function Confirmed(CondList List<Condition>):\n CondList C where C.verificationStatus.coding ~ "Condition verificationStatus confirmed code"\n\n/**\n * Conditions that are active. In FHIR R4, this is reflected by clinicalStatus: 'active' and the absence of any\n * abatement information (i.e., if it abated, it is no longer active).\n * TODO: Rename to Active once the execution engine supports overloaded functions.\n * @see https://www.hl7.org/fhir/valueset-condition-clinical.html\n * @param CondList - a list of Conditions\n * @returns {List<Condition>} a list of active Conditions, or null if null was passed in\n */\ndefine function ActiveCondition(CondList List<Condition>):\n CondList C\n where C.clinicalStatus.coding ~ "Condition clinicalStatus active code"\n and C.abatement is null\n\n/**\n * Conditions that are active or recurring. In FHIR R4, this is reflected by clinicalStatus: 'active', 'recurrence', or 'relapse'.\n * We do not check for null abatement information because it may have dates from when the now recurring condition\n * initially went into remission.\n * @see https://www.hl7.org/fhir/valueset-condition-clinical.html\n * @param CondList - a list of Conditions\n * @returns {List<Condition>} a list of active or recurring Conditions, or null if null was passed in\n */\ndefine function ActiveOrRecurring(CondList List<Condition>):\n CondList C where C.clinicalStatus.coding ~ "Condition clinicalStatus active code"\n or C.clinicalStatus.coding ~ "Condition clinicalStatus recurrence code"\n or C.clinicalStatus.coding ~ "Condition clinicalStatus relapse code"\n\n/**\n * Conditions with an onset or recorded date in the specified "look back" period. For example, pregnancy in\n * the last 42 weeks.\n * TODO: Rename to LookBack once the execution engine supports overloaded functions.\n * @param CondList - a list of Conditions\n * @returns {List<Condition>} a list of Conditions with onset or recorded date specified lookback period, or null\n * if null was passed in\n */\ndefine function ConditionLookBack(CondList List<Condition>, LookBack System.Quantity):\n CondList C\n let LookBackInterval: Interval[Now() - LookBack, Now()]\n where C.onset.value in LookBackInterval\n or NullSafeToInterval(C.onset) overlaps LookBackInterval\n or C.recordedDate.value in LookBackInterval\n // TODO Confirm these are the correct fields to use\n\n// -------------------------------------------------- PROCEDURES -------------------------------------------------------\n\n /**\n * Filters Procedures by a concept rather than by a ValueSet. In CQL 1.3, this will be built into the retrieve,\n * but for now, we must use a query where clause.\n * @param Koncept - the concept to filter on (intentionally mispelled to avoid naming clashes)\n * @returns {List<Procedure>} a list of Procedures matching the concept, or null if null was passed in\n */\n define function ProceduresByConcept(Koncept System.Concept):\n [Procedure] P where NullSafeToConcept(P.code) ~ Koncept\n\n/**\n * Procedures that are completed. In FHIR R4, this is reflected by status: 'completed'. In addition, the\n * notDone flag must be checked to ensure it is not 'true'.\n * @see https://www.hl7.org/fhir/valueset-event-status.html\n * @param ProcList - a list of Procedures\n * @returns {List<Procedure>} a list of completed Procedures, or null if null was passed in\n */\ndefine function Completed(ProcList List<Procedure>):\n ProcList P\n where P.status.value = 'completed'\n\n/**\n * Procedures that are in progress. In FHIR R4, this is reflected by status: 'in-progress'. In addition, the\n * notDone flag must be checked to ensure it is not 'true'.\n * @see https://www.hl7.org/fhir/valueset-event-status.html\n * @param ProcList - a list of Procedures\n * @returns {List<Procedure>} a list of completed Procedures, or null if null was passed in\n */\ndefine function ProcedureInProgress(ProcList List<Procedure>):\n ProcList P\n where P.status.value = 'in-progress'\n\n/**\n * Procedures that actually happened or are happening. In FHIR R4, there are a few properties that negate the\n * procedure, most notably when status is 'entered-in-error' or notDone is true.\n * @see https://www.hl7.org/fhir/valueset-event-status.html\n * @param ProcList - a list of Procedures\n * @returns {List<Procedure>} a list of Procedures that actually happened or are happening, or null if null was passed in\n */\ndefine function ProcedurePerformance(ProcList List<Procedure>):\n ProcList P\n where P.status.value != 'entered-in-error'\n\n/**\n * Procedures performed in the specified "look back" period. For example, PCIs performed in the\n * past 2 weeks.\n * TODO: Rename to LookBack once the execution engine supports overloaded functions.\n * @param ProcList - a list of Procedures\n * @param LookBack - the lookback period for when the procedure was performed\n * @returns {List<Procedure>} a list of Procedures performed in the look back period, or null if null\n * was passed in\n */\ndefine function ProcedureLookBack(ProcList List<Procedure>, LookBack System.Quantity):\n ProcList P\n let LookBackInterval: Interval[Now() - LookBack, Now()]\n where P.performed.value in LookBackInterval\n or NullSafeToInterval(P.performed) overlaps LookBackInterval\n\n// Note: ProcedureRequest and ReferralRequest resources have been replaced in FHIR R4 with the ServiceRequest resource.\n// TODO: When needed, come back and ServiceRequest helper functions.\n// // ---------------------------------------------- PROCEDUREREQUESTS ----------------------------------------------------\n\n// /**\n// * Filters ProcedureRequests by a concept rather than by a ValueSet. In CQL 1.3, this will be built into the retrieve,\n// * but for now, we must use a query where clause.\n// * @param Koncept - the concept to filter on (intentionally mispelled to avoid naming clashes)\n// * @returns {List<ProcedureRequest>} a list of ProcedureRequests matching the concept, or null if null was passed in\n// */\n// define function ProcedureRequestsByConcept(Koncept System.Concept):\n// [ProcedureRequest] P where NullSafeToConcept(P.code) ~ Koncept\n\n// /**\n// * ProcedureRequests that are accepted, in progress, or completed. In FHIR DSTU2, this is reflected by the corresponding\n// * status status values.\n// * @see http://hl7.org/fhir/DSTU2/valueset-procedure-request-status.html\n// * @param ProcReqList - a list of ProcedureRequests\n// * @returns {List<ProcedureRequest>} a list of accepted, in-progress, or completed ProcedureRequests,\n// * or null if null was passed in\n// */\n// define function ProcedureRequestAcceptedOrInProgressOrCompleted(ProcReqList List<ProcedureRequest>):\n// ProcReqList P\n// where P.status.value in List{'accepted', 'in-progress', 'completed'}\n\n// /**\n// * ProcedureRequests ordered in the specified "look back" period. For example, PCIs ordered in the\n// * past 2 weeks.\n// * TODO: Rename to LookBack once the execution engine supports overloaded functions.\n// * @param ProcReqList - a list of ProcedureRequests\n// * @param LookBack - the lookback period for when the procedure was ordered\n// * @returns {List<ProcedureRequest>} a list of ProcedureRequests ordered in the look back period, or null if null\n// * was passed in\n// */\n// define function ProcedureRequestLookBack(ProcReqList List<ProcedureRequest>, LookBack System.Quantity):\n// ProcReqList P\n// where P.authoredOn.value in Interval[Now() - LookBack, Now()]\n\n// // ----------------------------------------------- REFERRALREQUESTS ----------------------------------------------------\n\n// /**\n// * Filters ReferralRequests by a concept rather than by a ValueSet. In CQL 1.3, this will be built into the retrieve,\n// * but for now, we must use a query where clause.\n// * @param Koncept - the concept to filter on (intentionally mispelled to avoid naming clashes)\n// * @returns {List<ReferralRequest>} a list of ReferralRequests matching the concept, or null if null was passed in\n// */\n// define function ReferralRequestsByServiceRequestedConcept(Koncept System.Concept):\n// [ReferralRequest] R\n// where exists((R.serviceRequested) SRC where NullSafeToConcept(SRC) ~ Koncept)\n\n// /**\n// * ReferralRequests that are accepted, active, or completed. In FHIR DSTU2, this is reflected by the corresponding\n// * status status values.\n// * @see http://hl7.org/fhir/DSTU2/valueset-referralstatus.html\n// * @param ReferralList - a list of ReferralRequests\n// * @returns {List<ReferralRequest>} a list of accepted, active, or completed ReferralRequests,\n// * or null if null was passed in\n// */\n// define function ReferralRequestAcceptedOrActiveOrCompleted(ReferralList List<ReferralRequest>):\n// ReferralList R\n// where R.status.value in List{'accepted', 'active', 'completed'}\n\n// /**\n// * ReferralRequests requested in the specified "look back" period. For example, pace make insertions referrals sent\n// * in the past 2 weeks.\n// * TODO: Rename to LookBack once the execution engine supports overloaded functions.\n// * @param ReferralList - a list of ReferralRequests\n// * @param LookBack - the lookback period for when the referral was sent\n// * @returns {List<ReferralRequest>} a list of ReferralRequests sent in the look back period, or null if null\n// * was passed in\n// */\n// define function ReferralRequestLookBack(ReferralList List<ReferralRequest>, LookBack System.Quantity):\n// ReferralList R\n// where R.authoredOn.value in Interval[Now() - LookBack, Now()]\n\n// -------------------------------------------------- MEDICATIONS ------------------------------------------------------\n\n/**\n * Filters MedicationStatements by a concept rather than by a ValueSet. In CQL 1.3, this will be built into the retrieve,\n * but for now, we must use a query where clause.\n * @param Koncept - the concept to filter on (intentionally mispelled to avoid naming clashes)\n * @returns {List<MedicationStatement>} a list of MedicationStatement matching the concept, or null if null was passed in\n */\ndefine function MedicationStatementsByConcept(Koncept System.Concept):\n [MedicationStatement] M where NullSafeToConcept(M.medication) ~ Koncept\n\n/**\n * Filters MedicationRequests by a concept rather than by a ValueSet. In CQL 1.3, this will be built into the retrieve,\n * but for now, we must use a query where clause.\n * @param Koncept - the concept to filter on (intentionally mispelled to avoid naming clashes)\n * @returns {List<MedicationRequest>} a list of MedicationRequests matching the concept, or null if null was passed in\n */\ndefine function MedicationRequestsByConcept(Koncept System.Concept):\n [MedicationRequest] M where NullSafeToConcept(M.medication) ~ Koncept\n\n/**\n * Medications that are active, according to a statement, but not necessarily verified via a prescription. For example,\n * medications that a patient has self-reported to be taking. In FHIR R4, this is reflected by MedicationStatement\n * with status 'active', no flag indicating it wasn't taken, and no end date or an end date in the future.\n * TODO: Rename to Active once the execution engine supports overloaded functions.\n * @see https://www.hl7.org/fhir/valueset-medication-statement-status.html\n * @param MedList - a list of MedicationStatements\n * @returns {List<MedicationStatement>} a list of active medication statements, or null if null was passed in\n */\ndefine function ActiveMedicationStatement(MedList List<MedicationStatement>):\n MedList M\n let EffectivePeriod: NullSafeToInterval(M.effective)\n where M.status.value = 'active'\n and (end of EffectivePeriod is null or end of EffectivePeriod after Now())\n\n/**\n * Medications that are active or completed, according to a statement, but not necessarily verified via a prescription.\n * For example, medications that a patient has self-reported to be taking. In FHIR R4, this is reflected by\n * MedicationStatement with status 'active' or 'completed', and no flag indicating it wasn't taken.\n * TODO: Rename to ActiveOrCompleted once the execution engine supports overloaded functions.\n * @see https://www.hl7.org/fhir/valueset-medication-statement-status.html\n * @param MedList - a list of MedicationStatements\n * @returns {List<MedicationStatement>} a list of active or completed medication statements, or null if null was passed\n * in\n */\ndefine function ActiveOrCompletedMedicationStatement(MedList List<MedicationStatement>):\n MedList M\n where M.status.value = 'active'\n or M.status.value = 'completed'\n\n/**\n* Medications that are active, according to a prescription. In FHIR R4, this is reflected by MedicationRequest\n* with status 'active' and no dateEnded. There is currently an open question in the FHIR chat to determine if this\n* is the right approach.\n* @see https://www.hl7.org/fhir/valueset-medicationrequest-status.html\n* @param MedList - a list of MedicationRequests\n* @returns {List<MedicationRequest>} a list of active medication orders, or null if null was passed in\n*/\ndefine function ActiveMedicationRequest(MedList List<MedicationRequest>):\n MedList M\n where M.status.value = 'active'\n\n/**\n* Medications that are active or completed, according to a prescription. In FHIR R4, this is reflected by MedicationRequest\n* with status 'active' or 'completed'\n* @see https://www.hl7.org/fhir/valueset-medicationrequest-status.html\n* @param MedList - a list of MedicationRequests\n* @returns {List<MedicationRequest>} a list of active medication orders, or null if null was passed in\n*/\ndefine function ActiveOrCompletedMedicationRequest(MedList List<MedicationRequest>):\n MedList M\n where M.status.value = 'active'\n or M.status.value = 'completed'\n\n/**\n* Medications that are active, completed, or stopped, according to a prescription. In FHIR R4, this is reflected by\n* MedicationRequest with status 'active', 'completed', or 'stopped'\n* @see https://www.hl7.org/fhir/valueset-medicationrequest-status.html\n* @param MedList - a list of MedicationRequests\n* @returns {List<MedicationRequest>} a list of active medication orders, or null if null was passed in\n*/\ndefine function ActiveCompletedOrStoppedMedicationRequest(MedList List<MedicationRequest>):\n MedList M\n where M.status.value = 'active'\n or M.status.value = 'completed'\n or M.status.value = 'stopped'\n\n/**\n * MedicationStatement with an effective date in the specified "look back" period. For example, statements about opioid\n * use in the last 180 days.\n * TODO: Rename to LookBack once the execution engine supports overloaded functions.\n * @param MedList - a list of MedicationStatements\n * @param LookBack - a duration Quantity indicating how far back to look for MedicationStatements\n * @returns {List<MedicationStatement>} a list of MedicationStatements with effective date in the specified lookback\n * period, or null if null was passed in\n */\ndefine function MedicationStatementLookBack(MedList List<MedicationStatement>, LookBack System.Quantity):\n MedList M\n let LookBackInterval: Interval[Now() - LookBack, Now()]\n where M.effective.value in LookBackInterval\n or NullSafeToInterval(M.effective) overlaps LookBackInterval\n\n/**\n * MedicationRequests with a written date in the specified "look back" period. For example, opioid orders in the last\n * 180 days.\n * TODO: Rename to LookBack once the execution engine supports overloaded functions.\n * @param OrderList - a list of MedicationRequests\n * @param LookBack - a duration Quantity indicating how far back to look for MedicationRequests\n * @returns {List<MedicationRequest>} a list of MedicationRequests with written date in the specified lookback period,\n * or null if null was passed in\n */\ndefine function MedicationRequestLookBack(MedList List<MedicationRequest>, LookBack System.Quantity):\n MedList M where M.authoredOn.value in Interval[Now() - LookBack, Now()]\n\n// -------------------------------------------------- ENCOUNTERS ------------------------------------------------------\n\n/**\n * Filters Encounters by a concept rather than by a ValueSet. In CQL 1.3, this will be built into the retrieve,\n * but for now, we must use a query where clause.\n * @param Koncept - the concept to filter on (intentionally mispelled to avoid naming clashes)\n * @returns {List<Encounter>} a list of Encounters matching the concept, or null if null was passed in\n */\ndefine function EncountersByConcept(Koncept System.Concept):\n [Encounter] E where exists( (E.type) ET where NullSafeToConcept(ET) ~ Koncept )\n\n/**\n * Encounters that are in progress. In FHIR R4, this is reflected by status: 'in-progress'.\n * @see https://www.hl7.org/fhir/valueset-encounter-status.html\n * @param EncList - a list of Encounters\n * @returns {List<Encounter>} a list of in progress encounters, or null if null was passed in\n */\ndefine function InProgress(EncList List<Encounter>):\n EncList E\n where E.status.value = 'in-progress'\n\n/**\n * Encounters that have not been cancelled. In FHIR R4, this is reflected by andy status other \n * than: 'cancelled'.\n * @see https://www.hl7.org/fhir/valueset-encounter-status.html\n * @param EncList - a list of Encounters\n * @returns {List<Encounter>} a list of in progress encounters, or null if null was passed in\n */\ndefine function NotCancelled(EncList List<Encounter>):\n EncList E\n where E.status.value != 'cancelled'\n\n/**\n * Encounters performed in the specified "look back" period.\n * TODO: Rename to LookBack once the execution engine supports overloaded functions.\n * @param EncList - a list of Encounters\n * @param LookBack - the lookback period for when the encounter occurred\n * @returns {List<Encounter>} a list of Encounters occurring during the look back period, or null if null\n * was passed in\n */\ndefine function EncounterLookBack(EncList List<Encounter>, LookBack System.Quantity):\n EncList E\n let LookBackInterval: Interval[Now() - LookBack, Now()]\n where NullSafeToInterval(E.period) overlaps LookBackInterval\n\n// -------------------------------------------------- ALLERGY INTOLERANCES ---------------------------------------------\n\n/**\n * Filters AllergyIntolerances by a concept rather than by a ValueSet. In CQL 1.3, this will be built into the retrieve,\n * but for now, we must use a query where clause.\n * @param Koncept - the concept to filter on (intentionally mispelled to avoid naming clashes)\n * @returns {List<AllergyIntolerance>} a list of Allergy Intolerances matching the concept, or null if null was passed in\n */\ndefine function AllergyIntolerancesByConcept(Koncept System.Concept):\n [AllergyIntolerance] A where NullSafeToConcept(A.code) ~ Koncept\n\n/**\n* AllergyIntolerances that are active or confirmed. In FHIR R4, this is reflected by AllergyIntolerance\n* with verificationStatus 'active' or 'confirmed'\n* @see https://www.hl7.org/fhir/valueset-allergyintolerance-verification.html\n* @param AllergyIntolList - a list of AllergyIntolerances\n* @returns {List<AllergyIntolerance>} a list of active or confirmed allergy intolerances, or null if null was passed in\n*/\ndefine function ConfirmedAllergyIntolerance(AllergyIntolList List<AllergyIntolerance>):\n AllergyIntolList A\n where A.verificationStatus.coding ~ "AllergyIntolerance verificationStatus confirmed code"\n\n// -------------------------------------------------------- GOALS ------------------------------------------------------\n\n/**\n * Goals with a start, target, or status date in the specified "look back" period. For example, Pain Management Goals\n * in the last 2 years.\n * TODO: Rename to LookBack once the execution engine supports overloaded functions.\n * @param GoalList - a list of Goals\n * @returns {List<Goal>} a list of Goals with a start, target, or status date in the specified lookback period, or null\n * if null was passed in\n */\ndefine function GoalLookBack(GoalList List<Goal>, LookBack System.Quantity):\n GoalList G\n let LookBackInterval: Interval[Now() - LookBack, Now()]\n where G.start.value in LookBackInterval\n or G.target.dueD in LookBackInterval\n or G.start.value in LookBackInterval\n or G.statusDate.value in LookBackInterval\n</code></pre><p><code>No Content</code> (<code>application/elm+xml</code>)</p></div>" ] ; # fhir:url [ fhir:v "http://hl7.org/fhir/uv/cpg/anthrax/Library/cds-connect-commons-library"^^xsd:anyURI] ; # fhir:identifier ( [ fhir:use [ fhir:v "official" ] ; fhir:value [ fhir:v "CDS_Connect_Commons_for_FHIRv400" ] ] ) ; # fhir:version [ fhir:v "1.1.0"] ; # fhir:name [ fhir:v "CDS_Connect_Commons_for_FHIRv400_Library"] ; # fhir:title [ fhir:v "CDS Connect Commons for FHIRv400"] ; # fhir:status [ fhir:v "draft"] ; # fhir:experimental [ fhir:v "true"^^xsd:boolean] ; # fhir:type [ ( fhir:coding [ fhir:system [ fhir:v "http://terminology.hl7.org/CodeSystem/library-type"^^xsd:anyURI ] ; fhir:code [ fhir:v "logic-library" ] ] ) ] ; # fhir:date [ fhir:v "2024-08-23T15:47:13+00:00"^^xsd:dateTime] ; # fhir:publisher [ fhir:v "HL7 International - Clinical Decision Support WG"] ; # fhir:contact ( [ fhir:name [ fhir:v "HL7 International - Clinical Decision Support WG" ] ; ( fhir:telecom [ fhir:system [ fhir:v "url" ] ; fhir:value [ fhir:v "http://www.hl7.org/Special/committees/dss/index.cfm" ] ] ) ] ) ; # fhir:description [ fhir:v "A library containing common methods used by CDS Connect-developed artifacts"] ; # fhir:jurisdiction ( [ ( fhir:coding [ fhir:system [ fhir:v "http://unstats.un.org/unsd/methods/m49/m49.htm"^^xsd:anyURI ] ; fhir:code [ fhir:v "001" ] ; fhir:display [ fhir:v "World" ] ] ) ] ) ; # fhir:topic ( [ fhir:text [ fhir:v "Anthrax" ] ] [ fhir:text [ fhir:v "Emergency Medicine" ] ] [ fhir:text [ fhir:v "Post-Exposure Prophylaxis" ] ] ) ; # fhir:author ( [ fhir:name [ fhir:v "Alliance to Modernize Healthcare FFRDC" ] ] ) ; # fhir:endorser ( [ fhir:name [ fhir:v "Centers for Disease Control and Prevention" ] ] ) ; # fhir:content ( [ fhir:contentType [ fhir:v "text/cql" ] ; fhir:data [ fhir:v "Ly8gQ0RTIENvbm5lY3QgQ29tbW9ucyBmb3IgRkhJUnY0MDAKLy8gQ2hhbmdlIGxvZ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jayBwZXJpb2QsIG9yIG51bGwKICogaWYgbnVsbCB3YXMgcGFzc2VkIGluCiAqLwpkZWZpbmUgZnVuY3Rpb24gR29hbExvb2tCYWNrKEdvYWxMaXN0IExpc3Q8R29hbD4sIExvb2tCYWNrIFN5c3RlbS5RdWFudGl0eSk6CiAgR29hbExpc3QgRwogICAgbGV0IExvb2tCYWNrSW50ZXJ2YWw6IEludGVydmFsW05vdygpIC0gTG9va0JhY2ssIE5vdygpXQogICAgd2hlcmUgRy5zdGFydC52YWx1ZSBpbiBMb29rQmFja0ludGVydmFsCiAgICAgIG9yIEcudGFyZ2V0LmR1ZUQgaW4gTG9va0JhY2tJbnRlcnZhbAogICAgICBvciBHLnN0YXJ0LnZhbHVlIGluIExvb2tCYWNrSW50ZXJ2YWwKICAgICAgb3IgRy5zdGF0dXNEYXRlLnZhbHVlIGluIExvb2tCYWNrSW50ZXJ2YWwK"^^xsd:base64Binary ] ] [ fhir:contentType [ fhir:v "application/elm+xml" ] ] ) . #
IG © (c) 2019 The MITRE Corporation HL7 International - Clinical Decision Support WG. Package hl7.fhir.uv.cpg.anthrax#1.1.0 based on FHIR 4.0.1. Generated 2024-08-23
Links: Table of Contents |
QA Report
| Version History |