Skip to content

Commit

Permalink
Added QICoreUpdateProcess documentation and 143/159 examples
Browse files Browse the repository at this point in the history
  • Loading branch information
brynrhodes committed Dec 9, 2022
1 parent dfa746a commit 9b62860
Show file tree
Hide file tree
Showing 3 changed files with 358 additions and 0 deletions.
61 changes: 61 additions & 0 deletions QICoreUpdateProcess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# QICore Update Process

This document describes the process of updating a pure FHIR-based measure to a QICore-based measure

## Extract MAT Bundle

Place the MAT export in the bundles\mat directory and extract the contents into a sub-folder. For example:

```
bundles\mat\CMS143FHIR-v0-0-003-FHIR-4-0-1\CMS143FHIR-v0-0-003-FHIR-4-0-1.json
```

Use the CQFTooling ExtractMatBundle operation to extract the contents of the bundle:

```
java -jar input-cache\tooling-1.4.1-SNAPSHOT-jar-with-dependencies.jar -ExtractMatBundle bundles\mat\CMS143FHIR-v0-0-003-FHIR-4-0-1\CMS143FHIR-v0-0-003-FHIR-4-0-1.json
```

## Revert FHIR-based Library Changes

Revert the changes to the following CQL libraries, because they are the FHIR-based versions and we do not want those, there are QICore versions already in the repository:

1. FHIRHelpers
2. QICoreCommon

## Copy Primary Measure Library

Copy the primary measure library and rename it using the QICore4 postfix:

```
input\cql\POAGOpticNerveEvaluationQICore4.cql
```

## Update Primary Measure Library

1. Open the QICore named file
2. Update the postfix on the library name from FHIR to QICore4
3. Update the using statement to `using QICore version '4.1.1'`
3. Update the version of the FHIRHelpers reference to 4.0.013 (the current version for QICore support in this repository)
4. Change the SupplementalDataElementsFHIR4 reference to SupplementalDataElementsQICore4
5. Change the MATGlobalCommonFunctionsFHIR4 reference to MATGlobalCommonFunctionsQICore4
6. Remove the reference to FHIRCommon
7. Update references to MATGlobalCommonFunctionsFHIR4 functions that were moved to QICoreCommon:
1. Normalize Interval -> ToInterval
1. Abatement Period -> ToAbatementInterval
1. Prevalence Period -> ToPrevalenceInterval
1. Has Start -> HasStart
1. Has End -> HasEnd
1. Latest -> Latest
1. Earliest -> Earliest
1. Interval To Day Numbers -> Interval To Day Numbers
1. Days in Period -> Days in Period
8. Update references to QICore profiles (https://hl7.org/fhir/us/qicore/profiles.html)
1. Note that when the intent is looking for negation, use the negation profile: https://hl7.org/fhir/us/qicore/#negation-rationale
1. Note that for QICore profiles, the profiles will enforce any "fixed" constraints, so you don't need to check those values (for example status = 'not-done' in a negation profile isn't necessary because the profile enforces that specifically)
9. Update references to extensions that are using the extension functions to the element names (the "slice name" of the extension element defined in the profile)





195 changes: 195 additions & 0 deletions input/cql/DepressionRemissionatTwelveMonthsQICore4.cql
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
library DepressionRemissionatTwelveMonthsQICore4 version '0.0.001'

using QICore version '4.1.1'

include FHIRHelpers version '4.0.013' called FHIRHelpers
include SupplementalDataElementsQICore4 version '3.0.000' called SDE
include MATGlobalCommonFunctionsQICore4 version '7.0.000' called Global
include QICoreCommon version '1.0.000' called QICoreCommon

codesystem "LOINC": 'http://loinc.org'
codesystem "SNOMEDCT": 'http://snomed.info/sct'
codesystem "ICD10CM": 'http://hl7.org/fhir/sid/icd-10-cm'

valueset "Bipolar Disorder": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.67.1.101.1.128'
valueset "Care Services in Long-Term Residential Facility": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1014'
valueset "Contact or Office Visit": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1080.5'
valueset "Dysthymia": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.67.1.101.1.254'
valueset "Encounter Inpatient": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307'
valueset "Hospice Care Ambulatory": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1584'
valueset "Hospice Encounter": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1003'
valueset "Major Depression Including Remission": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.113883.3.67.1.101.3.2444'
valueset "Palliative Care Encounter": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1090'
valueset "Palliative Care Intervention": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.198.12.1135'
valueset "Palliative or Hospice Care": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.600.1.1579'
valueset "Personality Disorder Emotionally Labile": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.67.1.101.1.246'
valueset "Pervasive Developmental Disorder": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.105.12.1152'
valueset "PHQ 9 and PHQ 9M Tools": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.67.1.101.1.263'
valueset "Schizophrenia or Psychotic Disorder": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.105.12.1104'

code "Birth date": '21112-8' from "LOINC" display 'Birth date'
code "Dead (finding)": '419099009' from "SNOMEDCT" display 'Dead (finding)'
code "Discharge to healthcare facility for hospice care (procedure)": '428371000124100' from "SNOMEDCT" display 'Discharge to healthcare facility for hospice care (procedure)'
code "Discharge to home for hospice care (procedure)": '428361000124107' from "SNOMEDCT" display 'Discharge to home for hospice care (procedure)'
code "Encounter for palliative care": 'Z51.5' from "ICD10CM" display 'Encounter for palliative care'
code "Functional Assessment of Chronic Illness Therapy - Palliative Care Questionnaire (FACIT-Pal)": '71007-9' from "LOINC" display 'Functional Assessment of Chronic Illness Therapy - Palliative Care Questionnaire (FACIT-Pal)'
code "Hospice care [Minimum Data Set]": '45755-6' from "LOINC" display 'Hospice care [Minimum Data Set]'
code "Yes (qualifier value)": '373066001' from "SNOMEDCT" display 'Yes (qualifier value)'

parameter "Measurement Period" Interval<DateTime>

context Patient

define "Denominator Identification Period":
Interval[start of "Measurement Period" - 14 months, start of "Measurement Period" - 2 months )

define "Depression Diagnoses":
["Condition": "Major Depression Including Remission"]
union ["Condition": "Dysthymia"]

define "Has Long Term Care Encounter":
exists ( ["Encounter": "Care Services in Long-Term Residential Facility"] EncounterLongTermCare
where ToDate(start of EncounterLongTermCare.period)on or before
end of "Measure Assessment Period"
)

define "SDE Ethnicity":
SDE."SDE Ethnicity"

define "SDE Payer":
SDE."SDE Payer"

define "SDE Race":
SDE."SDE Race"

define "SDE Sex":
SDE."SDE Sex"

define "test1":
exists ( ["Encounter": "Palliative or Hospice Care"] HospiceEncounter
where HospiceEncounter.period starts during Interval[start of "Denominator Identification Period",
end of "Measure Assessment Period"]
)

define "Denominator Exclusions":
"Has Hospice Services"
or "Palliative Care in the Measure Assessment Period"
or "Has Long Term Care Encounter"
or "Patient Expired"
or "Has Mental Health Disorder Diagnoses"

define "Depression Assessments Greater than 9":
["Observation": "PHQ 9 and PHQ 9M Tools"] DepressionAssessment
where DepressionAssessment.value > 9

define "Depression Encounter":
["Encounter": "Contact or Office Visit"] ValidEncounter
with "Depression Diagnoses" Depression
such that ValidEncounter.period overlaps Depression.onset
and ValidEncounter.period ends during "Denominator Identification Period"

define "Denominator":
"Initial Population"

define "Index Depression Assessment":
First("Depression Assessments Greater than 9" DepressionAssessment
with "Depression Encounter" DepressionEncounter
such that QICoreCommon.ToInterval(DepressionAssessment.effective)is not null
and QICoreCommon.ToInterval(DepressionAssessment.effective)during Interval[ToDate((start of DepressionEncounter.period)- 7 days),
end of DepressionEncounter.period]
sort by start of QICoreCommon.ToInterval(effective)
)

define "Initial Population":
AgeInYearsAt(start of QICoreCommon.ToInterval("Index Depression Assessment".effective))>= 12

define "Measure Assessment Period":
"Index Depression Assessment" FirstIndexAssessment
let YearAfterIndexAssessment: date from start of QICoreCommon.ToInterval ( FirstIndexAssessment.effective ) + 12 months
return Interval[YearAfterIndexAssessment - 60 days, YearAfterIndexAssessment + 60 days]

define "Has Hospice Services":
exists ( ["Encounter": "Encounter Inpatient"] InpatientEncounter
where ( InpatientEncounter.hospitalization.dischargeDisposition ~ "Discharge to home for hospice care (procedure)"
or InpatientEncounter.hospitalization.dischargeDisposition ~ "Discharge to healthcare facility for hospice care (procedure)"
)
and InpatientEncounter.period ends during day of Interval[start of "Denominator Identification Period",
end of "Measure Assessment Period"]
)
or exists ( ["Encounter": "Hospice Encounter"] HospiceEncounter
where HospiceEncounter.period overlaps Interval[start of "Denominator Identification Period",
end of "Measure Assessment Period"]
)
or exists ( ["Observation": "Hospice care [Minimum Data Set]"] HospiceAssessment
where HospiceAssessment.value ~ "Yes (qualifier value)"
and QICoreCommon.ToInterval ( HospiceAssessment.effective ) overlaps Interval[start of "Denominator Identification Period",
end of "Measure Assessment Period"]
)
or exists ( ["ServiceRequest": "Hospice Care Ambulatory"] HospiceOrder
where HospiceOrder.authoredOn during day of Interval[start of "Denominator Identification Period",
end of "Measure Assessment Period"]
)
or exists ( ["Procedure": "Hospice Care Ambulatory"] HospicePerformed
where QICoreCommon.ToInterval ( HospicePerformed.performed ) overlaps Interval[start of "Denominator Identification Period",
end of "Measure Assessment Period"]
)

define "Numerator":
Last(["Observation": "PHQ 9 and PHQ 9M Tools"] DepressionAssessment
where ToDate(start of QICoreCommon.ToInterval(DepressionAssessment.effective))during "Measure Assessment Period"
sort by start of QICoreCommon.ToInterval(effective)
).value < 5

define "Has Mental Health Disorder Diagnoses":
exists ( ( ["Condition": "Bipolar Disorder"]
union ["Condition": "Personality Disorder Emotionally Labile"]
union ["Condition": "Schizophrenia or Psychotic Disorder"]
union ["Condition": "Pervasive Developmental Disorder"] ) MentalHealthDisorderDiagnoses
where MentalHealthDisorderDiagnoses.onset on or before
end of "Measure Assessment Period"
)

define "Patient Expired":
Patient.deceased on or before
end of "Measure Assessment Period"

define "Palliative Care in the Measure Assessment Period":
exists ( ["Observation": "Functional Assessment of Chronic Illness Therapy - Palliative Care Questionnaire (FACIT-Pal)"] PalliativeAssessment
where QICoreCommon.ToInterval ( PalliativeAssessment.effective ) overlaps Interval[start of "Denominator Identification Period",
end of "Measure Assessment Period"]
)
or exists ( ["Condition": "Encounter for palliative care"] PalliativeDiagnosis
where PalliativeDiagnosis.onset overlaps Interval[start of "Denominator Identification Period",
end of "Measure Assessment Period"]
)
or exists ( ["Encounter": "Palliative Care Encounter"] PalliativeEncounter
where PalliativeEncounter.period overlaps Interval[start of "Denominator Identification Period",
end of "Measure Assessment Period"]
)
or exists ( ["Procedure": "Palliative Care Intervention"] PalliativeIntervention
where QICoreCommon.ToInterval ( PalliativeIntervention.performed ) overlaps Interval[start of "Denominator Identification Period",
end of "Measure Assessment Period"]
)

define "Stratification 1":
"Index Depression Assessment" IndexAssessment
where AgeInYearsAt(date from start of QICoreCommon.ToInterval(IndexAssessment.effective))in Interval[12, 17]

define "Stratification 2":
"Index Depression Assessment" IndexAssessment
where AgeInYearsAt(date from start of QICoreCommon.ToInterval(IndexAssessment.effective))>= 18

define function "test"():
exists ( ["Observation": "Functional Assessment of Chronic Illness Therapy - Palliative Care Questionnaire (FACIT-Pal)"] PalliativeAssessment
where QICoreCommon.ToInterval ( PalliativeAssessment.effective ) overlaps "Measurement Period"
)
or exists ( ["Condition": "Encounter for palliative care"] PalliativeDiagnosis
where PalliativeDiagnosis.onset overlaps "Measure Assessment Period"
)
or exists ( ["Encounter": "Palliative Care Encounter"] PalliativeEncounter
where PalliativeEncounter.period overlaps "Measurement Period"
)
or exists ( ["Procedure": "Palliative Care Intervention"] PalliativeIntervention
where QICoreCommon.ToInterval ( PalliativeIntervention.performed ) overlaps "Measurement Period"
)

102 changes: 102 additions & 0 deletions input/cql/POAGOpticNerveEvaluationQICore4.cql
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
library POAGOpticNerveEvaluationQICore4 version '0.0.003'

using QICore version '4.1.1'

include FHIRHelpers version '4.0.013' called FHIRHelpers
include SupplementalDataElementsQICore4 version '3.0.000' called SDE
include MATGlobalCommonFunctionsQICore4 version '7.0.000' called Global
include QICoreCommon version '1.0.000' called QICoreCommon

codesystem "ActCode": 'http://terminology.hl7.org/CodeSystem/v3-ActCode'

valueset "Care Services in Long-Term Residential Facility": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1014'
valueset "Cup to Disc Ratio": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1333'
valueset "Face-to-Face Interaction": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1048'
valueset "Medical Reason": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1007'
valueset "Nursing Facility Visit": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1012'
valueset "Office Visit": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1001'
valueset "Ophthalmological Services": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1285'
valueset "Optic Disc Exam for Structural Abnormalities": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1334'
valueset "Outpatient Consultation": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1008'
valueset "Primary Open-Angle Glaucoma": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.326'

code "virtual": 'VR' from "ActCode" display 'virtual'

parameter "Measurement Period" Interval<DateTime>

context Patient

define "SDE Ethnicity":
SDE."SDE Ethnicity"

define "SDE Payer":
SDE."SDE Payer"

define "SDE Race":
SDE."SDE Race"

define "SDE Sex":
SDE."SDE Sex"

define "Denominator":
"Initial Population"

define "Denominator Exceptions":
exists "Medical Reason for Not Performing Cup to Disc Ratio"
or exists "Medical Reason for Not Performing Optic Disc Exam"

define "Qualifying Encounter During Measurement Period":
( ["Encounter": "Office Visit"]
union ["Encounter": "Ophthalmological Services"]
union ["Encounter": "Outpatient Consultation"]
union ["Encounter": "Nursing Facility Visit"]
union ["Encounter": "Care Services in Long-Term Residential Facility"] ) QualifyingEncounter
where QualifyingEncounter.period during "Measurement Period"
and QualifyingEncounter.class !~ "virtual"

define "Initial Population":
AgeInYearsAt(date from start of "Measurement Period")>= 18
and exists "Primary Open Angle Glaucoma Encounter"

define "Primary Open Angle Glaucoma Encounter":
"Qualifying Encounter During Measurement Period" ValidQualifyingEncounter
with ["Condition": "Primary Open-Angle Glaucoma"] PrimaryOpenAngleGlaucoma
such that QICoreCommon.ToPrevalenceInterval( PrimaryOpenAngleGlaucoma ) overlaps ValidQualifyingEncounter.period //Encounterperiod

define "Cup to Disc Ratio Performed with Result":
["Observation": "Cup to Disc Ratio"] CupToDiscExamPerformed
with "Primary Open Angle Glaucoma Encounter" EncounterWithPOAG
such that QICoreCommon.ToInterval( CupToDiscExamPerformed.effective ) during EncounterWithPOAG.period
where CupToDiscExamPerformed.value is not null

define "Optic Disc Exam Performed with Result":
["Observation": "Optic Disc Exam for Structural Abnormalities"] OpticDiscExamPerformed
with "Primary Open Angle Glaucoma Encounter" EncounterWithPOAG
such that QICoreCommon.ToInterval( OpticDiscExamPerformed.effective ) during EncounterWithPOAG.period
where OpticDiscExamPerformed.value is not null

define "Numerator":
exists "Cup to Disc Ratio Performed with Result"
and exists "Optic Disc Exam Performed with Result"

define "Medical Reason for Not Performing Cup to Disc Ratio":
["ObservationNotDone": "Cup to Disc Ratio"] CupToDiscExamNotPerformed
with "Primary Open Angle Glaucoma Encounter" EncounterWithPOAG
such that CupToDiscExamNotPerformed.issued during EncounterWithPOAG.period
where CupToDiscExamNotPerformed.notDoneReason in "Medical Reason"

/*
define "Medical Reason for Not Performing Optic Disc Exam":
["Observation": "Optic Disc Exam for Structural Abnormalities"] OpticDiscExamNotPerformed
with "Primary Open Angle Glaucoma Encounter" EncounterWithPOAG
such that OpticDiscExamNotPerformed.issued during EncounterWithPOAG.period
where OpticDiscExamNotPerformed.status = 'cancelled'
and FHIRCommon."Extension" ( OpticDiscExamNotPerformed, 'http://hl7.org/fhir/us/qicore/StructureDefinition-qicore-notDone' ).value = true
and FHIRCommon."Extension" ( OpticDiscExamNotPerformed, 'http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-notDoneReason' ).value in "Medical Reason"
*/

define "Medical Reason for Not Performing Optic Disc Exam":
["ObservationNotDone": "Optic Disc Exam for Structural Abnormalities"] OpticDiscExamNotPerformed
with "Primary Open Angle Glaucoma Encounter" EncounterWithPOAG
such that OpticDiscExamNotPerformed.issued during EncounterWithPOAG.period
where OpticDiscExamNotPerformed.notDoneReason in "Medical Reason"

0 comments on commit 9b62860

Please sign in to comment.