Id: |
UPPARFInitialExpressions |
Version: |
0.1.0 |
Url: |
UPPARFInitialExpressions |
Status: |
draft |
Type: |
code: logic-library
|
Date: |
2024-11-18 00:51:22+0000 |
Publisher: |
Clinical Quality Framework |
Jurisdiction: |
840 |
Related Artifacts: |
Dependencies
|
Parameters: |
Name | Type | Min | Max | In/Out |
Patient | Resource | 0 | 1 | Out |
Most Recent Medication Request | Resource | 0 | 1 | Out |
Urgency | string | 0 | 1 | Out |
Most Recent Medication | Resource | 0 | 1 | Out |
Most Recent Medication Name | string | 0 | 1 | Out |
Is Opioid Treatment | Resource | 0 | 1 | Out |
Prior Prescription | Resource | 0 | 1 | Out |
Is First Prior Authentication | boolean | 0 | 1 | Out |
Initial Request Date | dateTime | 0 | 1 | Out |
Is First Request > 12 Months | boolean | 0 | 1 | Out |
Prescription Date | dateTime | 0 | 1 | Out |
Requester | Resource | 0 | 1 | Out |
Prescriber Name | string | 0 | 1 | Out |
Prescriber Fax | string | 0 | 1 | Out |
Prescriber Phone | string | 0 | 1 | Out |
Prescriber Pager | string | 0 | 1 | Out |
Prescriber Address | string | 0 | 1 | Out |
Prescriber Contact | string | 0 | 1 | Out |
Prescriber NPI | string | 0 | 1 | Out |
Prescriber DEA | Resource | 0 | 1 | Out |
Prescriber Tax ID | string | 0 | 1 | Out |
RequesterRole | Resource | 0 | 1 | Out |
Prescriber Specialty | string | 0 | 1 | Out |
Prescriber Email Address | string | 0 | 1 | Out |
Request Type | string | 0 | 1 | Out |
ICD 10 Codes | string | 0 | * | Out |
Diagnosis Descriptions | string | 0 | * | Out |
Dosage Value as String | string | 0 | 1 | Out |
Dosage Unit | string | 0 | 1 | Out |
Unit Volume of Named Drugs | string | 0 | 1 | Out |
Dose | string | 0 | 1 | Out |
Route | string | 0 | 1 | Out |
Most Recent Dosage Instruction | Resource | 0 | 1 | Out |
Frequency | string | 0 | 1 | Out |
Refills | integer | 0 | 1 | Out |
Today | date | 0 | 1 | Out |
Start Date and Length | string | 0 | 1 | Out |
|
Data Requirements: |
Type | Profile | MS | Code Filter |
Patient |
http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient |
|
|
MedicationRequest |
http://hl7.org/fhir/us/core/StructureDefinition/us-core-medicationrequest |
|
|
Medication |
http://hl7.org/fhir/us/core/StructureDefinition/us-core-medication |
|
|
Medication |
http://hl7.org/fhir/us/core/StructureDefinition/us-core-medication |
;;;; |
|
Medication |
http://hl7.org/fhir/us/core/StructureDefinition/us-core-medication |
;;;; |
|
Practitioner |
http://hl7.org/fhir/us/core/StructureDefinition/us-core-practitioner |
;;;; |
|
Practitioner |
http://hl7.org/fhir/us/core/StructureDefinition/us-core-practitioner |
;;;; |
|
Practitioner |
http://hl7.org/fhir/us/core/StructureDefinition/us-core-practitioner |
;;;; |
|
PractitionerRole |
http://hl7.org/fhir/us/core/StructureDefinition/us-core-practitionerrole |
;;;; |
|
PractitionerRole |
http://hl7.org/fhir/us/core/StructureDefinition/us-core-practitionerrole |
;;;; |
|
PractitionerRole |
http://hl7.org/fhir/us/core/StructureDefinition/us-core-practitionerrole |
;;;; |
|
Condition |
http://hl7.org/fhir/us/core/StructureDefinition/us-core-condition |
|
|
Condition |
http://hl7.org/fhir/us/core/StructureDefinition/us-core-condition |
|
|
Condition |
http://hl7.org/fhir/us/core/StructureDefinition/us-core-condition |
;;; |
|
Condition |
http://hl7.org/fhir/us/core/StructureDefinition/us-core-condition |
;;; |
|
Condition |
http://hl7.org/fhir/us/core/StructureDefinition/us-core-condition |
;;; |
|
Condition |
http://hl7.org/fhir/us/core/StructureDefinition/us-core-condition |
;; |
|
Condition |
http://hl7.org/fhir/us/core/StructureDefinition/us-core-condition |
;; |
|
Practitioner |
http://hl7.org/fhir/us/core/StructureDefinition/us-core-practitioner |
;;;; |
|
Practitioner |
http://hl7.org/fhir/us/core/StructureDefinition/us-core-practitioner |
;;;; |
|
PractitionerRole |
http://hl7.org/fhir/us/core/StructureDefinition/us-core-practitionerrole |
;;;; |
|
Condition |
http://hl7.org/fhir/us/core/StructureDefinition/us-core-condition |
|
|
|
Content: text/cql |
library UPPARFInitialExpressions version '0.1.0'
using USCore version '3.1.1'
using FHIR version '4.0.1'
include FHIRHelpers version '4.1.0'
include USCoreCommon version '0.1.0' called UC
include USCoreElements version '0.1.0' called UCE
include CumulativeMedicationDuration called CMD
codesystem "Identifier Type": 'http://terminology.hl7.org/CodeSystem/v2-0203'
codesystem "Verification Status": 'http://terminology.hl7.org/CodeSystem/condition-ver-status'
codesystem "Condition Clinical": 'http://terminology.hl7.org/CodeSystem/condition-clinical'
codesystem "ICD10": 'http://hl7.org/fhir/sid/icd-10-cm'
valueset "ICD10 vs": 'http://hl7.org/fhir/sid/icd-10-cm/ValueSet'
code "ICD10 example code": 'example' from "ICD10"
code "Member Number": 'MB' from "Identifier Type"
code "Subscriber Number": 'SN' from "Identifier Type"
code "Confirmed": 'confirmed' from "Verification Status"
code "Active": 'active' from "Condition Clinical"
context Patient
define "Urgency":
"Most Recent Medication Request".priority P
return (
if P != 'routine' then 'Urgent'
else 'Not Urgent'
)
//TODO: name could also be retrieved by MedicationRequest as a codeable concept if there is no reference
define "Most Recent Medication Name":
"Most Recent Medication" M
return M.code.display
define "Is Opioid Treatment":
null //TBD
//TODO: can we assume that with a previous prior authentication there also has been a prior prescription?
define "Is First Prior Authentication":
IsNull("Prior Prescription")
//TODO: does the initial request date mean the exact same medication was requested before?
define "Initial Request Date":
if not "Is First Prior Authentication" then
singleton from (
UCE."All Medication Requests" M
where EndsWith(("Most Recent Medication Request".priorPrescription as USCore.Reference).reference, M.id)
return M.authoredOn
)
else
null
define "Is First Request > 12 Months":
if IsNull("Initial Request Date") then null else
(months between "Initial Request Date" and Now() > 12)
define "Prescription Date":
"Most Recent Medication Request".authoredOn
define "Prescriber Name":
First(Requester.name).family
//TODO: should this be First("Requester".name).family with double quotes?
//TODO: prefix, suffix and given do not work as expected.
define "Prescriber Fax":
UC.Fax(Requester.telecom).value
define "Prescriber Phone":
UC.Mobile(Requester.telecom).value
define "Prescriber Pager":
UC.Pager(Requester.telecom).value
define "Prescriber Address":
'TODO: remove hard coded address'
define "Prescriber Contact":
'TODO: remove hard coded contact'
//TBD: would this be a work phone or more something like an address?
define "Prescriber NPI":
First (
"Requester".identifier I
where I.system = 'http://hl7.org.fhir/sid/us-npi'
).value
//TODO: what is DEA?
define "Prescriber DEA":
null
define "Prescriber Tax ID":
First (
"Requester".identifier I
where I.system = 'urn:oid:2.16.840.1.113883.4.4'
).value
define "Prescriber Specialty":
First(RequesterRole.specialty.codes).display
define "Prescriber Email Address":
UC.Email(Requester.telecom).value
define "Request Type":
//TODO: is this logic correct?
if "Is First Prior Authentication" then
'New Request' else 'Reauthorization'
define "ICD 10 Codes":
UCE."Active Confirmed Problem List Items".code.codes C
where C.system ~ "ICD10 example code".system //"ICD10".id
return C.code
define "Diagnosis Descriptions":
UCE."Active Confirmed Problem List Items".code.display
define "Unit Volume of Named Drugs":
"Dosage Value as String" + "Dosage Unit"
define "Dose":
"Dosage Value as String"
define "Route":
First("Most Recent Medication Request".dosageInstruction).route.display
define "Most Recent Dosage Instruction":
singleton from ("Most Recent Medication Request".dosageInstruction)
define "Frequency":
"Most Recent Dosage Instruction" DI
return ToString(DI.timing.repeat.frequency) + ' times per '
+ ToString(DI.timing.repeat.period)
+ DI.timing.repeat.periodUnit
define "Refills":
"Most Recent Medication Request".dispenseRequest.numberOfRepeatsAllowed
define "Today":
Today()
define "Dosage Value as String":
ToString(("Most Recent Medication Request".dosageInstruction.doseAndRate[0].dose as System.Quantity).value)
define "Dosage Unit":
("Most Recent Medication Request".dosageInstruction.doseAndRate[0].dose as System.Quantity).unit
//helper definitions
//TODO: medications are not necessarily a reference but could also be represented by a codeeable concept
define "Most Recent Medication":
singleton from (
UCE."All Medications" M
where EndsWith((UCE."Most Recent Medication Request".medication as USCore.Reference).reference, M.id))
define "Most Recent Medication Request":
UCE."Most Recent Medication Request"
define "Prior Prescription":
"Most Recent Medication Request".priorPrescription
define "Requester":
UCE."Requester"
define "RequesterRole":
UCE."RequesterRole"
//email, pager, and fax functions moved to USCoreCommon.cql
//IMPORTANT NOTE: Missing the entire (or majority) of the "Prior Authorization Request for Drug Benefit" section of the quesstionnaire. Expect errors on Postman regarding the items in this section.
define "Start Date and Length":
null as System.String
|
|
Content: application/elm+xml |
Encoded data (114188 characters)
|
|
Content: application/elm+json |
Encoded data (202488 characters)
|
|