Clinical Quality Framework Common FHIR Assets (US-Based)
0.1.0 - CI Build United States of America (USA)

Clinical Quality Framework Common FHIR Assets (US-Based), published by Clinical Quality Framework. This guide is not an authorized publication; it is the continuous build for version 0.1.0 built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/cqframework/cqf-us/ and changes regularly. See the Directory of published versions

Library:

Official URL: http://fhir.org/guides/cqf/us/common/Library/GMTPInitialExpressions Version: 0.1.0
Draft as of 2024-11-18 Computable Name: GMTPInitialExpressions
Id: GMTPInitialExpressions
Version: 0.1.0
Url: GMTPInitialExpressions
Status: draft
Type:

code: logic-library

Date: 2024-11-18 00:51:22+0000
Publisher: Clinical Quality Framework
Jurisdiction: 840
Related Artifacts:

Dependencies

Parameters:
NameTypeMinMaxIn/Out
PatientResource01Out
Requesting Provider Namestring0*Out
Requesting Provider Phonestring01Out
Requesting Provider Addressstring0*Out
Requesting Provider NPIstring0*Out
Requesting Provider Faxstring0*Out
Servicing Provider Namestring01Out
Servicing Provider Phonestring01Out
Servicing Provider Addressstring0*Out
Servicing Provider NPIstring0*Out
Servicing Provider Faxstring0*Out
Billing Provider Namestring01Out
Billing Provider Phonestring01Out
Billing Provider Addressstring0*Out
Billing Provider NPIstring0*Out
Billing Provider Faxstring0*Out
Date of ServicedateTime01Out
Requested TestCodeableConcept01Out
Test IDstring01Out
Test namestring01Out
Test ICD CodesCoding0*Out
Test CPT CodesCoding0*Out
ALL ICD and CPT Test CodesCoding0*Out
Test Related ConditionCondition0*Out
Diagnosis Descriptionsstring0*Out
Billing Provider different from Servicing Providerstring01Out
Research SubjectResearchSubject0*Out
Clinical TrialResearchStudy0*Out
Clinical Trial OrganizationResource01Out
BillingProvider is Clinical Trial Organisationboolean01Out
Is Research Subjectboolean01Out
Part of clinical trialstring01Out
Clinical Trial IDstring0*Out
Previous genetic testing for conditionstring0*Out
Data Requirements:
TypeProfileMSCode Filter
Patient http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient
ServiceRequest http://hl7.org/fhir/StructureDefinition/ServiceRequest
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 ;;;;;;;;;;;
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 ;;;;;;;;;;;
Practitioner http://hl7.org/fhir/us/core/StructureDefinition/us-core-practitioner ;;;;;;;;;;;
Practitioner http://hl7.org/fhir/us/core/StructureDefinition/us-core-practitioner ;;;;;;;;;;;
Organization http://hl7.org/fhir/us/core/StructureDefinition/us-core-organization ;;;;;;
Organization http://hl7.org/fhir/us/core/StructureDefinition/us-core-organization ;;;;;;
Organization http://hl7.org/fhir/us/core/StructureDefinition/us-core-organization ;;;;;;
Coverage http://hl7.org/fhir/StructureDefinition/Coverage ;
Organization http://hl7.org/fhir/us/core/StructureDefinition/us-core-organization ;;;;;;
Organization http://hl7.org/fhir/us/core/StructureDefinition/us-core-organization ;;;;;;
Organization http://hl7.org/fhir/us/core/StructureDefinition/us-core-organization ;;;;;;
Condition http://hl7.org/fhir/StructureDefinition/Condition ;;;;;
Condition http://hl7.org/fhir/StructureDefinition/Condition ;;;;;
Condition http://hl7.org/fhir/StructureDefinition/Condition ;;;;;
Condition http://hl7.org/fhir/StructureDefinition/Condition ;;;;;
Condition http://hl7.org/fhir/StructureDefinition/Condition ;;;;;
Patient http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient
ResearchSubject http://hl7.org/fhir/StructureDefinition/ResearchSubject ;;;;
ResearchStudy http://hl7.org/fhir/StructureDefinition/ResearchStudy
ResearchSubject http://hl7.org/fhir/StructureDefinition/ResearchSubject ;;;;
Condition http://hl7.org/fhir/StructureDefinition/Condition ;;;;;
ResearchStudy http://hl7.org/fhir/StructureDefinition/ResearchStudy ;;
Organization http://hl7.org/fhir/us/core/StructureDefinition/us-core-organization
Organization http://hl7.org/fhir/us/core/StructureDefinition/us-core-organization ;;
ServiceRequest http://hl7.org/fhir/StructureDefinition/ServiceRequest ;;;;
Practitioner http://hl7.org/fhir/us/core/StructureDefinition/us-core-practitioner ;;;;;;;;;;;
Practitioner http://hl7.org/fhir/us/core/StructureDefinition/us-core-practitioner ;;;;;;;;;;;
Organization http://hl7.org/fhir/us/core/StructureDefinition/us-core-organization ;;;;;;
Organization http://hl7.org/fhir/us/core/StructureDefinition/us-core-organization ;;;;;;
Condition http://hl7.org/fhir/StructureDefinition/Condition ;;;;;
ResearchSubject http://hl7.org/fhir/StructureDefinition/ResearchSubject ;;;;
ResearchSubject http://hl7.org/fhir/StructureDefinition/ResearchSubject ;;;;
Content: text/cql
library GMTPInitialExpressions 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

codesystem "LOINC": 'http://loinc.org'
codesystem "Identifier Type": 'http://terminology.hl7.org/CodeSystem/v2-0203'
code "Member Number": 'MB' from "Identifier Type"

context Patient

// TODO: Error: Could not resolve data provider for package 'java.util'.

define "Requesting Provider Name":
  UCE."Requesting Provider".name.family 

define "Requesting Provider Phone":
  UC.Mobile(UCE."Requesting Provider".telecom).value
  //This definition looks for #mobile, but wouldn't a practitioner be #work?
/*
define "Requesting Provider Address":
  (singleton from "Requesting Provider".address).line
*/
define "Requesting Provider Address":
  { 'TODO: remove hard-coded address' }

define "Requesting Provider NPI":
  UCE."Requesting Provider".identifier I 
  where I.system = 'http://hl7.org/fhir/sid/us-npi'
  return I.value

define "Requesting Provider Fax":
  UCE."Requesting Provider".telecom T
  where T.system = 'fax'
  return T.value

define "Servicing Provider Name":
  UCE."Servicing Provider".name

define "Servicing Provider Phone":
  UC.Mobile(UCE."Servicing Provider".telecom).value

// TODO: Error: Could not resolve data provider for package 'java.util'.
/*
define "Servicing Provider Address":
  (singleton from "Servicing Provider".address).line
*/
define "Servicing Provider Address":
  { 'TODO: remove hard-coded address' }

define "Servicing Provider NPI":
  UCE."Servicing Provider".identifier I 
  where I.system = 'http://hl7.org/fhir/sid/us-npi'
  return I.value

define "Servicing Provider Fax":
  UCE."Servicing Provider".telecom T
  where T.system = 'fax'
  return T.value

define "Billing Provider Name":
  UCE."Billing Provider".name

define "Billing Provider Phone":
  UC.Mobile(UCE."Billing Provider".telecom).value

// TODO: Error: Could not resolve data provider for package 'java.util'.
/*
define "Billing Provider Address":
  (singleton from "Billing Provider".address).line
*/
define "Billing Provider Address":
  { 'TODO: remove hard-coded address' }

define "Billing Provider NPI":
  UCE."Billing Provider".identifier I 
  where I.system = 'http://hl7.org/fhir/sid/us-npi'
  return I.value

define "Billing Provider Fax":
  UCE."Billing Provider".telecom T
  where T.system = 'fax'
  return T.value

define "Date of Service":
  UCE."Most Recent ServiceRequest".occurrence.value

define "Requested Test":
  UCE."Most Recent ServiceRequest" SR
  return SR.code

define "Test ID":
  Combine("Requested Test".coding.code.value, ', ') 
  //"Requested Test".coding.code.value 
  /* feature req */

define "Test name":
   Combine("Requested Test".coding.display.value, ', ')
   //"Requested Test".coding.display.valu

define "ALL ICD and CPT Test Codes":
   "Test ICD Codes" union "Test CPT Codes" as List<FHIR.Coding>

define "Test ICD Codes":
 "Requested Test".coding C
  where C.system.value = 'http://hl7.org/fhir/sid/icd-10-cm'
  return C
  
define "Test CPT Codes":
  "Requested Test".coding C
  where C.system.value =  'http://www.ama-assn.org/go/cpt'
  return C

define "Test Related Condition":
  UCE."Test Related Condition"
  //.reasonReference changed to .reason in FHIR R5

define "Diagnosis Descriptions":
  "Test Related Condition".code.coding.display.value

define "Billing Provider different from Servicing Provider":
  if UCE."Billing Provider".id != UCE."Servicing Provider".id then
  'Yes'
  else 
  'No'

define "Clinical Trial Organization":
  First(UCE."Clinical Trial Organization" O 
    with "Clinical Trial"  T such that EndsWith(T.sponsor.reference, O.id))  
 //in FHIR R5 T.associatedParty instead of T.sponsor 

define "BillingProvider is Clinical Trial Organisation":
  UCE."Billing Provider" = "Clinical Trial Organization"

//TODO does not get populated properly
define "Part of clinical trial":
 if "Is Research Subject" and "BillingProvider is Clinical Trial Organisation" then
 'Yes'
 else
 'No'

define "Is Research Subject":
  exists("Research Subject")

define "Research Subject":
  UCE."Research Subject"
     //ResearchSubject.individual is from FHIR version v4.0.1 and has been replaced by R.subject in FHIR R5

define "Clinical Trial":
  UCE."All Clinical Trials" R 
    with "Research Subject" S such that EndsWith(S.study.reference, R.id)
    with  "Test Related Condition" C such that C.code in R.condition

define "Clinical Trial ID":
  "Clinical Trial".identifier C
  where C.system = 'https://clinicaltrials.gov'
  return C.value.value

define "Previous genetic testing for condition":
  from 
    UCE."All ServiceRequests" S,
    UCE."Most Recent ServiceRequest" SR 
  where S.occurrence before SR.occurrence
    and S.id != SR.id
    and S.reasonReference = SR.reasonReference
  return S.id.value

//define "Family history of genetic testing"
//too general to prefill?

//define "Patient history"
//too general to prefill?


Content: application/elm+xml
Encoded data (121540 characters)
Content: application/elm+json
Encoded data (215572 characters)