Common CQL Artifacts for FHIR (US-Based)
1.0.0 - Informative 1 United States of America flag

Common CQL Artifacts for FHIR (US-Based), published by HL7 International / Clinical Decision Support. This guide is not an authorized publication; it is the continuous build for version 1.0.0 built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/HL7/us-cql-ig/ and changes regularly. See the Directory of published versions

Library: Expression Library for the Example Patient And Coverage Questionnaire (Experimental)

Official URL: http://hl7.org/fhir/us/cql/Library/ExamplePatientAndCoverageInitialExpressions Version: 1.0.0
Standards status: Informative Maturity Level: 3 Computable Name: ExamplePatientAndCoverageInitialExpressions

This library defines initial expressions for use in populating answers to questions in the Example Patient And Coverage questionnaire.

Metadata
Title Expression Library for the Example Patient And Coverage Questionnaire
Version 1.0.0
Status Draft
Experimental true
Jurisdiction United States of America
Steward (Publisher) HL7 International / Clinical Decision Support
Description

This library defines initial expressions for use in populating answers to questions in the Example Patient And Coverage questionnaire.

Type Logic Library
Parameter Name: Coverage
Use: In
Min Cardinality: 0
Max Cardinality: 1
Type: Coverage
Parameter Name: ServiceRequest
Use: In
Min Cardinality: 0
Max Cardinality: 1
Type: ServiceRequest
Parameter Name: Patient
Use: Out
Min Cardinality: 0
Max Cardinality: 1
Type: Resource
Parameter Name: Retrieve Service Request test parameter
Use: Out
Min Cardinality: 0
Max Cardinality: 1
Type: ServiceRequest
Parameter Name: Service Request
Use: Out
Min Cardinality: 0
Max Cardinality: 1
Type: ServiceRequest
Parameter Name: Retrieve Coverage test parameter
Use: Out
Min Cardinality: 0
Max Cardinality: 1
Type: Coverage
Parameter Name: Member Coverage
Use: Out
Min Cardinality: 0
Max Cardinality: 1
Type: Coverage
Parameter Name: Patient Name
Use: Out
Min Cardinality: 0
Max Cardinality: 1
Type: HumanName
Parameter Name: Date of Birth
Use: Out
Min Cardinality: 0
Max Cardinality: 1
Type: date
Parameter Name: Birth Sex
Use: Out
Min Cardinality: 0
Max Cardinality: 1
Type: code
Parameter Name: Medical Record Number
Use: Out
Min Cardinality: 0
Max Cardinality: 1
Type: string
Parameter Name: Phone Number
Use: Out
Min Cardinality: 0
Max Cardinality: 1
Type: string
Parameter Name: Email Address
Use: Out
Min Cardinality: 0
Max Cardinality: 1
Type: string
Parameter Name: Address
Use: Out
Min Cardinality: 0
Max Cardinality: 1
Type: Address
Parameter Name: City
Use: Out
Min Cardinality: 0
Max Cardinality: 1
Type: string
Parameter Name: State
Use: Out
Min Cardinality: 0
Max Cardinality: 1
Type: string
Parameter Name: Postal Code
Use: Out
Min Cardinality: 0
Max Cardinality: 1
Type: string
Parameter Name: Member ID
Use: Out
Min Cardinality: 0
Max Cardinality: 1
Type: string
Parameter Name: Policy Number
Use: Out
Min Cardinality: 0
Max Cardinality: 1
Type: string
Parameter Name: Requesting Provider
Use: Out
Min Cardinality: 0
Max Cardinality: *
Type: Resource
Parameter Name: Requesting Provider Name
Use: Out
Min Cardinality: 0
Max Cardinality: *
Type: string
Parameter Name: Requesting Provider Phone
Use: Out
Min Cardinality: 0
Max Cardinality: 1
Type: string
Parameter Name: Requesting Provider Address
Use: Out
Min Cardinality: 0
Max Cardinality: *
Type: string
Parameter Name: Requesting Provider NPI
Use: Out
Min Cardinality: 0
Max Cardinality: *
Type: string
Parameter Name: Requesting Provider Fax
Use: Out
Min Cardinality: 0
Max Cardinality: 1
Type: string
Parameter Name: Servicing Provider
Use: Out
Min Cardinality: 0
Max Cardinality: *
Type: Resource
Parameter Name: Servicing Provider Name
Use: Out
Min Cardinality: 0
Max Cardinality: *
Type: HumanName
Parameter Name: Servicing Provider Phone
Use: Out
Min Cardinality: 0
Max Cardinality: 1
Type: string
Parameter Name: Servicing Provider Address
Use: Out
Min Cardinality: 0
Max Cardinality: 1
Type: string
Parameter Name: Servicing Provider NPI
Use: Out
Min Cardinality: 0
Max Cardinality: *
Type: string
Parameter Name: Servicing Provider Fax
Use: Out
Min Cardinality: 0
Max Cardinality: 1
Type: string
Data Requirement Type: ServiceRequest
Profile(s): ServiceRequest
Data Requirement Type: Coverage
Profile(s): Coverage
Library Content
CQL Content
library ExamplePatientAndCoverageInitialExpressions

using USCore version '7.0.0'
using FHIR version '4.0.1'

include hl7.fhir.uv.cql.FHIRHelpers version '4.0.1'
include USCoreCommon called UC
include USCoreElements called UCE

codesystem "Identifier Type": 'http://terminology.hl7.org/CodeSystem/v2-0203'

code "Member Number": 'MB' from "Identifier Type"
code "Subscriber Number": 'SN' from "Identifier Type"

parameter "Coverage" FHIR.Coverage
parameter "ServiceRequest" FHIR.ServiceRequest

context Patient

define "Retrieve Service Request test parameter":
  // The VSCode extension doesn't support parameters
  // When executing CQL with the VSCode extension retrieve the resource specific for the test case
  //   the list of resource ids match the resources from the test case folders
  singleton from ([FHIR.ServiceRequest] SR where SR.id in { 
    'minimal-service-request-example'
  })

define "Service Request":
  Coalesce(
    ServiceRequest,
    "Retrieve Service Request test parameter"
  )

define "Retrieve Coverage test parameter":
  // The VSCode extension doesn't support parameters
  // When executing CQL with the VSCode extension retrieve the resource specific for the test case
  //   the list of resource ids match the resources from the test case folders
  singleton from ([FHIR.Coverage] CV where CV.id in { 
    'minimal-coverage-example'
  })

define "Member Coverage":
  Coalesce(
    Coverage,
    "Retrieve Coverage test parameter"
  )

define "Patient Name":
  Patient.name()

define "Date of Birth":
  Patient.birthDate

define "Birth Sex":
  Patient.birthSex()

define "Medical Record Number":
  Patient.medicalRecordNumber()

define "Phone Number":
  Patient.telecom.where(system = 'phone').first().value

define "Email Address":
  Patient.telecom.where(system = 'email').first().value

define "Address":
  Patient.address.where(use = 'home').first()

define "City":
  "Address".city

define "State":
  "Address".state

define "Postal Code":
  "Address".postalCode

// Coverage
// define "Coverage":
//   First(clinical C where C is FHIR.Coverage)

// TODO: is there a need to check for coverage period and order? 
//       also, do we need to check that the payor organization is the same as the source of the prior auth form?
define "Member ID":
  "Member Coverage".memberID()

// TODO: is there a need to check for coverage period and order?
//       also do we need to check that the payor organization is the same as the source of the prior auth form?
define "Policy Number":
  "Member Coverage".policyNumber()

define "Requesting Provider":
  UCE.RequestingProvider("Service Request")

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

define "Requesting Provider Phone":
  Work("Requesting Provider".telecom).value

define "Requesting Provider Address":
  "Requesting Provider".address.first().line

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

define "Requesting Provider Fax":
  Fax("Requesting Provider".telecom).value

define "Servicing Provider":
  UCE.ServicingProvider("Service Request")

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

define "Servicing Provider Phone":
  Work("Servicing Provider".telecom).value

define "Servicing Provider Address":
  (singleton from "Servicing Provider".address).text

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

define "Servicing Provider Fax":
  Fax("Servicing Provider".telecom).value

define function Work(contactPoints List<ContactPoint>):
  singleton from (contactPoints P where P.system = 'phone' and P.use = 'work')

define function Mobile(contactPoints List<ContactPoint>):
  singleton from (contactPoints P where P.system = 'phone' and P.use = 'mobile')

define function Email(contactPoints List<ContactPoint>):
  singleton from (contactPoints P where P.system = 'email')

define function Fax(contactPoints List<ContactPoint>):
  singleton from (contactPoints P where P.system = 'fax')
ELM XML Content
Encoded data (110312 characters)
ELM JSON Content
Encoded data (206028 characters)
Generated using version 0.4.9 of the sample-content-ig Liquid templates