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

This page is part of the Common CQL Assets for FHIR (US-Based) (v1.0.0: Informative 1 - Informative) based on FHIR (HL7® FHIR® Standard) R4. This is the current published version. For a full list of available versions, 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 from http://terminology.hl7.org/CodeSystem/library-type
Dependency Description: Library FHIRHelpers
Resource: http://hl7.org/fhir/uv/cql/Library/FHIRHelpers|4.0.1
Canonical URL: http://hl7.org/fhir/uv/cql/Library/FHIRHelpers|4.0.1
Dependency Description: Library UC
Resource: US Core Common
Canonical URL: http://hl7.org/fhir/us/cql/Library/USCoreCommon
Dependency Description: Library UCE
Resource: US Core Elements
Canonical URL: http://hl7.org/fhir/us/cql/Library/USCoreElements
Dependency Description: Code System Identifier Type
Resource: identifierType
Canonical URL: http://terminology.hl7.org/CodeSystem/v2-0203
Data Requirement Type: ServiceRequest
Profile(s): ServiceRequest
Data Requirement Type: Coverage
Profile(s): Coverage
Parameters
Name Use Card. Type Documentation
Coverage In 0..1 Coverage
ServiceRequest In 0..1 ServiceRequest
Patient Out 0..1 Resource
Retrieve Service Request test parameter Out 0..1 ServiceRequest
Service Request Out 0..1 ServiceRequest
Retrieve Coverage test parameter Out 0..1 Coverage
Member Coverage Out 0..1 Coverage
Patient Name Out 0..1 HumanName
Date of Birth Out 0..1 date
Birth Sex Out 0..1 code
Medical Record Number Out 0..1 string
Phone Number Out 0..1 string
Email Address Out 0..1 string
Address Out 0..1 Address
City Out 0..1 string
State Out 0..1 string
Postal Code Out 0..1 string
Member ID Out 0..1 string
Policy Number Out 0..1 string
Requesting Provider Out 0..* Resource
Requesting Provider Name Out 0..* string
Requesting Provider Phone Out 0..1 string
Requesting Provider Address Out 0..* string
Requesting Provider NPI Out 0..* string
Requesting Provider Fax Out 0..1 string
Servicing Provider Out 0..* Resource
Servicing Provider Name Out 0..* HumanName
Servicing Provider Phone Out 0..1 string
Servicing Provider Address Out 0..1 string
Servicing Provider NPI Out 0..* string
Servicing Provider Fax Out 0..1 string
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 
ELM JSON Content
Encoded data 
Generated using version 0.5.3-cibuild of the sample-content-ig Liquid templates