From 63adf3ec5b5973fbc75e924bf8d43d1b4aec83b8 Mon Sep 17 00:00:00 2001 From: Prateek Keerthi Date: Sun, 3 Dec 2023 13:40:00 -0500 Subject: [PATCH 1/5] MAT-6006,6007,6008 added Used, Unused and Functions to QDM Highlighting Tab --- src/api/useCqlParsingService.ts | 41 +++++ .../groupCoverage/QdmGroupCoverage.tsx | 171 ++++++++++++++++-- .../groupCoverage/QiCoreGroupCoverage.tsx | 5 +- .../calculationResults/CalculationResults.tsx | 29 ++- src/util/GroupCoverageHelpers.ts | 63 ++++++- 5 files changed, 287 insertions(+), 22 deletions(-) create mode 100644 src/api/useCqlParsingService.ts diff --git a/src/api/useCqlParsingService.ts b/src/api/useCqlParsingService.ts new file mode 100644 index 000000000..fd70189dd --- /dev/null +++ b/src/api/useCqlParsingService.ts @@ -0,0 +1,41 @@ +import axios from "axios"; +import useServiceConfig from "./useServiceConfig"; +import { ServiceConfig } from "./ServiceContext"; +import { useOktaTokens } from "@madie/madie-util"; +import { CqlDefinitionExpression } from "../util/GroupCoverageHelpers"; + +export class CqlParsingService { + constructor(private baseUrl: string, private getAccessToken: () => string) {} + + async getAllDefinitionsAndFunctions( + cql: string + ): Promise { + try { + const response = await axios.put( + `${this.baseUrl}/cql/definitions`, + cql, + { + headers: { + Authorization: `Bearer ${this.getAccessToken()}`, + "Content-Type": "text/plain", + }, + } + ); + return response.data as unknown as CqlDefinitionExpression[]; + } catch (err) { + const message = `Unable to retrieve definition and function references`; + throw new Error(message); + } + } +} + +const useCqlParsingService = () => { + const serviceConfig: ServiceConfig = useServiceConfig(); + const { getAccessToken } = useOktaTokens(); + return new CqlParsingService( + serviceConfig?.elmTranslationService.baseUrl, + getAccessToken + ); +}; + +export default useCqlParsingService; diff --git a/src/components/editTestCase/groupCoverage/QdmGroupCoverage.tsx b/src/components/editTestCase/groupCoverage/QdmGroupCoverage.tsx index ee138ca54..c4b6ad8d1 100644 --- a/src/components/editTestCase/groupCoverage/QdmGroupCoverage.tsx +++ b/src/components/editTestCase/groupCoverage/QdmGroupCoverage.tsx @@ -6,8 +6,10 @@ import _, { isEmpty } from "lodash"; import { MappedCql, Population, + QDMPopulationDefinition, getFirstPopulation, getPopulationAbbreviation, + isPopulation, } from "../../../util/GroupCoverageHelpers"; import "twin.macro"; import "styled-components/macro"; @@ -18,16 +20,24 @@ interface Props { testCaseGroups: GroupPopulation[]; cqlPopulationDefinitions: MappedCql; measureGroups: Group[]; + calculationResults; } type PopulationResult = Record; +const allDefinitions = [ + { name: "Definitions" }, + { name: "Functions" }, + { name: "Unused" }, +]; + const populationCriteriaLabel = "Population Criteria"; const QdmGroupCoverage = ({ testCaseGroups, cqlPopulationDefinitions, measureGroups, + calculationResults, }: Props) => { const [selectedHighlightingTab, setSelectedHighlightingTab] = useState(getFirstPopulation(testCaseGroups[0])); @@ -39,6 +49,8 @@ const QdmGroupCoverage = ({ selectedPopulationDefinitionResults, setSelectedPopulationDefinitionResults, ] = useState(); + const [selectedAllDefinitions, setSelectedAllDefinitions] = + useState(); useEffect(() => { if (!isEmpty(testCaseGroups)) { @@ -90,8 +102,111 @@ const QdmGroupCoverage = ({ } }; + const getDefintionCategoryFilteringCondition = ( + statementResults, + definitionName, + definitionCategory + ) => { + if (definitionCategory === "Definitions") { + return statementResults[definitionName]?.relevance !== "NA"; + } + if (definitionCategory === "Unused") { + return statementResults[definitionName]?.relevance === "NA"; + } + }; + + const filterBasedOnDefinitionCategories = ( + statementResults, + definitionCategory + ) => { + return Object.keys(statementResults) + .filter((definitionName) => + getDefintionCategoryFilteringCondition( + statementResults, + definitionName, + definitionCategory + ) + ) + .reduce((result, definitionName) => { + result[definitionName] = statementResults[definitionName]; + return result; + }, {}); + }; + + const filterDefinitions = ( + cqlPopulationDefinitions, + calculationResults, + definitionCategory + ): QDMPopulationDefinition => { + const statementResults = + calculationResults[Object.keys(calculationResults)[0]][selectedCriteria]; + + if (Object.keys(statementResults?.statement_results)) { + const filteredDefinitions = Object.keys( + statementResults?.statement_results + ) + .map((definitionName) => + filterBasedOnDefinitionCategories( + statementResults?.statement_results[definitionName], + definitionCategory + ) + ) + .reduce((result, statementResult) => { + Object.assign(result, statementResult); + return result; + }, {}); + + return Object.keys( + cqlPopulationDefinitions[selectedCriteria]?.definitions + ) + .filter((definitionName) => filteredDefinitions[definitionName]) + .reduce((result, definitionName) => { + result[definitionName] = + cqlPopulationDefinitions[selectedCriteria]?.definitions[ + definitionName + ]; + return result; + }, {}); + } + }; + + const changeDefinitions = (population) => { + setSelectedHighlightingTab(population); + let resultDefinitions: QDMPopulationDefinition; + + if (cqlPopulationDefinitions && calculationResults) { + if (population.name === "Functions") { + if (cqlPopulationDefinitions[selectedCriteria]?.functions) { + resultDefinitions = + cqlPopulationDefinitions[selectedCriteria].functions; + } + } + if (population.name === "Definitions") { + resultDefinitions = filterDefinitions( + cqlPopulationDefinitions, + calculationResults, + population.name + ); + } + if (population.name === "Unused") { + resultDefinitions = filterDefinitions( + cqlPopulationDefinitions, + calculationResults, + population.name + ); + } + setSelectedAllDefinitions(resultDefinitions); + } + }; + const onHighlightingNavTabClick = (selectedTab) => { - changePopulation(selectedTab); + if (isPopulation(selectedTab.name)) { + setSelectedAllDefinitions(null); + changePopulation(selectedTab); + } else { + setSelectedPopulationDefinitionResults(null); + changeDefinitions(selectedTab); + } }; const getPopulationResults = (groupId: string) => { @@ -199,22 +314,52 @@ const QdmGroupCoverage = ({ id={selectedCriteria} populations={getRelevantPopulations()} // used for definitions, functions and unused - allDefinitions={[]} + allDefinitions={allDefinitions} selectedHighlightingTab={selectedHighlightingTab} onClick={onHighlightingNavTabClick} /> -
- {selectedPopulationDefinitionResults - ? parse( - `
${selectedPopulationDefinitionResults}
` - ) - : "No results available"} -
+ + {!selectedAllDefinitions ? ( +
+ {selectedPopulationDefinitionResults + ? parse( + `
${selectedPopulationDefinitionResults}
` + ) + : "No results available"} +
+ ) : ( +
+ {calculationResults && + Object.keys(selectedAllDefinitions).length > 0 ? ( + Object.values(selectedAllDefinitions) + .filter((definition: any) => !!definition.definitionLogic) + .map((definition: any, index) => { + return ( +
+ {parse( + `
${definition?.definitionLogic}
` + )} +
+ ); + }) + ) : ( +
No results available
+ )} +
+ )} ); diff --git a/src/components/editTestCase/groupCoverage/QiCoreGroupCoverage.tsx b/src/components/editTestCase/groupCoverage/QiCoreGroupCoverage.tsx index e7f84cb0c..35850e420 100644 --- a/src/components/editTestCase/groupCoverage/QiCoreGroupCoverage.tsx +++ b/src/components/editTestCase/groupCoverage/QiCoreGroupCoverage.tsx @@ -16,6 +16,7 @@ import GroupCoverageResultsSection from "./GroupCoverageResultsSection"; import { getFirstPopulation, getPopulationAbbreviation, + isPopulation, } from "../../../util/GroupCoverageHelpers"; interface Props { @@ -211,10 +212,6 @@ const QiCoreGroupCoverage = ({ ); }; - const isPopulation = (name: string) => { - return name !== "Functions" && name !== "Definitions" && name !== "Unused"; - }; - const onHighlightingNavTabClick = (selectedTab) => { if (isPopulation(selectedTab.name)) { changePopulation(selectedTab); diff --git a/src/components/editTestCase/qdm/RightPanel/calculationResults/CalculationResults.tsx b/src/components/editTestCase/qdm/RightPanel/calculationResults/CalculationResults.tsx index 5e06866e3..281c4e4ec 100644 --- a/src/components/editTestCase/qdm/RightPanel/calculationResults/CalculationResults.tsx +++ b/src/components/editTestCase/qdm/RightPanel/calculationResults/CalculationResults.tsx @@ -1,10 +1,14 @@ -import React from "react"; +import React, { useEffect, useRef, useState } from "react"; import QdmGroupCoverage from "../../../groupCoverage/QdmGroupCoverage"; import { isEmpty } from "lodash"; import { MadieAlert } from "@madie/madie-design-system/dist/react"; -import { mapCql } from "../../../../../util/GroupCoverageHelpers"; +import { + CqlDefinitionExpression, + mapCql, +} from "../../../../../util/GroupCoverageHelpers"; import "twin.macro"; import "styled-components/macro"; +import useCqlParsingService from "../../../../../api/useCqlParsingService"; const CalculationResults = ({ calculationResults, @@ -13,6 +17,20 @@ const CalculationResults = ({ measureGroups, calculationErrors, }) => { + const cqlParsingService = useRef(useCqlParsingService()); + const [allDefinitions, setAllDefinitions] = + useState(); + + useEffect(() => { + if (measureCql) { + cqlParsingService.current + .getAllDefinitionsAndFunctions(measureCql) + .then((allDefinitionsAndFunctions: CqlDefinitionExpression[]) => { + setAllDefinitions(allDefinitionsAndFunctions); + }); + } + }, [measureCql]); + return (
{!calculationResults && isEmpty(calculationErrors) && ( @@ -28,8 +46,13 @@ const CalculationResults = ({ {!isEmpty(testCaseGroups) && ( )}
diff --git a/src/util/GroupCoverageHelpers.ts b/src/util/GroupCoverageHelpers.ts index 0ddb2ed74..731f622ab 100644 --- a/src/util/GroupCoverageHelpers.ts +++ b/src/util/GroupCoverageHelpers.ts @@ -8,14 +8,40 @@ export interface Population { criteriaReference?: string; name: PopulationType; } + +export interface QDMPopulationDefinition { + [definitionName: string]: { + definitionLogic: string; + parentLibrary: string; + }; +} export interface MappedCql { [groupId: string]: { populationDefinitions: { [populationName: string]: string; }; + functions: QDMPopulationDefinition; + definitions: QDMPopulationDefinition; }; } +export interface CqlDefinitionExpression { + id?: string; + definitionName: string; + definitionLogic: string; + context: string; + supplDataElement: boolean; + popDefinition: boolean; + commentString: string; + returnType: string | null; + parentLibrary: string | null; + libraryDisplayName: string | null; + libraryVersion: string | null; + function: boolean; + name: string; + logic: string; +} + export const abbreviatedPopulations = { initialPopulation: "IP", denominator: "DENOM", @@ -46,7 +72,15 @@ export const getFirstPopulation = (group) => { }; }; -export const mapCql = (measureCql: string, measureGroups): MappedCql => { +export const isPopulation = (name: string) => { + return name !== "Functions" && name !== "Definitions" && name !== "Unused"; +}; + +export const mapCql = ( + measureCql: string, + measureGroups, + allDefinitions +): MappedCql => { if (measureCql && measureGroups) { const definitions = new CqlAntlr(measureCql).parse().expressionDefinitions; return measureGroups.reduce((acc, group) => { @@ -64,7 +98,32 @@ export const mapCql = (measureCql: string, measureGroups): MappedCql => { }, {} ); - acc[group.id] = { populationDefinitions: populationDetails }; + + const functionDetails = allDefinitions + ?.filter((definition) => definition.function) + .reduce((result, definition) => { + result[definition.definitionName] = { + definitionLogic: definition.definitionLogic, + parentLibrary: definition.parentLibrary, + }; + return result; + }, {}); + + const allDefinitionDetails = allDefinitions + ?.filter((definition) => !definition.function) + .reduce((result, definition) => { + result[definition.definitionName] = { + definitionLogic: definition.definitionLogic, + parentLibrary: definition.parentLibrary, + }; + return result; + }, {}); + + acc[group.id] = { + populationDefinitions: populationDetails, + functions: functionDetails, + definitions: allDefinitionDetails, + }; return acc; }, {}); } From 86e96f72a281154d5705b768c4204ce80377cae7 Mon Sep 17 00:00:00 2001 From: Prateek Keerthi Date: Sun, 3 Dec 2023 15:15:25 -0500 Subject: [PATCH 2/5] MAT-6006,6007,6008 fixed test cases --- .../_mocks_/QdmCalculationResults.ts | 522 ++++++++++++++ .../groupCoverage/_mocks_/QdmCallStack.ts | 642 ++++++++++++++++++ .../_mocks_/QdmCovergaeMeasureCql.ts | 77 +++ .../groupCoverage/_mocks_/QdmMeasureCql.ts | 153 +++-- .../editTestCase/qdm/EditTestCase.test.tsx | 6 +- .../CalculationResults.test.tsx | 47 +- .../testCaseLanding/qdm/TestCaseList.test.tsx | 2 +- 7 files changed, 1389 insertions(+), 60 deletions(-) create mode 100644 src/components/editTestCase/groupCoverage/_mocks_/QdmCalculationResults.ts create mode 100644 src/components/editTestCase/groupCoverage/_mocks_/QdmCallStack.ts create mode 100644 src/components/editTestCase/groupCoverage/_mocks_/QdmCovergaeMeasureCql.ts diff --git a/src/components/editTestCase/groupCoverage/_mocks_/QdmCalculationResults.ts b/src/components/editTestCase/groupCoverage/_mocks_/QdmCalculationResults.ts new file mode 100644 index 000000000..e77f3eeb5 --- /dev/null +++ b/src/components/editTestCase/groupCoverage/_mocks_/QdmCalculationResults.ts @@ -0,0 +1,522 @@ +export const qdmCalculationResults = { + "655e12db1069370e9cde2f80": { + IPP: 0, + DENOM: 0, + DENEX: 0, + NUMER: 0, + NUMEX: 0, + DENEXCEP: 0, + episode_results: {}, + statement_relevance: { + MATGlobalCommonFunctionsQDM: { + HospitalizationWithObservationLengthofStay: "TRUE", + LengthInDays: "TRUE", + HospitalizationWithObservation: "TRUE", + EarliestOf: "NA", + Earliest: "NA", + HasStart: "NA", + NormalizeInterval: "NA", + }, + TestQDM: { + Patient: "TRUE", + "Inpatient Encounters": "TRUE", + "Initial Population": "TRUE", + Denominator: "FALSE", + Numerator: "FALSE", + "SDE Ethnicity": "NA", + "SDE Payer": "NA", + "SDE Race": "NA", + "SDE Sex": "NA", + FirstPhysicalExamWithEncounterId: "NA", + FirstPhysicalExamWithEncounterIdUsingLabTiming: "NA", + FirstLabTestWithEncounterId: "NA", + "SDE Results": "NA", + LengthOfStay: "NA", + }, + }, + population_relevance: { + IPP: true, + DENOM: false, + DENEX: false, + NUMER: false, + NUMEX: false, + DENEXCEP: false, + }, + statement_results: { + MATGlobalCommonFunctionsQDM: { + HospitalizationWithObservationLengthofStay: { + library_name: "MATGlobalCommonFunctionsQDM", + statement_name: "HospitalizationWithObservationLengthofStay", + relevance: "TRUE", + final: "UNHIT", + }, + LengthInDays: { + library_name: "MATGlobalCommonFunctionsQDM", + statement_name: "LengthInDays", + relevance: "TRUE", + final: "UNHIT", + }, + HospitalizationWithObservation: { + library_name: "MATGlobalCommonFunctionsQDM", + statement_name: "HospitalizationWithObservation", + relevance: "TRUE", + final: "UNHIT", + }, + EarliestOf: { + library_name: "MATGlobalCommonFunctionsQDM", + statement_name: "EarliestOf", + relevance: "NA", + final: "NA", + }, + Earliest: { + library_name: "MATGlobalCommonFunctionsQDM", + statement_name: "Earliest", + relevance: "NA", + final: "NA", + }, + HasStart: { + library_name: "MATGlobalCommonFunctionsQDM", + statement_name: "HasStart", + relevance: "NA", + final: "NA", + }, + NormalizeInterval: { + library_name: "MATGlobalCommonFunctionsQDM", + statement_name: "NormalizeInterval", + relevance: "NA", + final: "NA", + }, + }, + TestQDM: { + Patient: { + library_name: "TestQDM", + statement_name: "Patient", + relevance: "TRUE", + final: "FALSE", + }, + "Inpatient Encounters": { + raw: [], + library_name: "TestQDM", + statement_name: "Inpatient Encounters", + relevance: "TRUE", + final: "FALSE", + }, + "Initial Population": { + raw: [], + library_name: "TestQDM", + statement_name: "Initial Population", + relevance: "TRUE", + final: "FALSE", + }, + Denominator: { + raw: [], + library_name: "TestQDM", + statement_name: "Denominator", + relevance: "FALSE", + final: "UNHIT", + }, + Numerator: { + raw: [], + library_name: "TestQDM", + statement_name: "Numerator", + relevance: "FALSE", + final: "UNHIT", + }, + "SDE Ethnicity": { + raw: [ + { + dataElementCodes: [ + { + code: "2135-2", + system: "2.16.840.1.113883.6.238", + version: "1.2", + display: "Hispanic or Latino", + }, + ], + _id: "656a0995c2da020000043b76", + qdmTitle: "Patient Characteristic Ethnicity", + hqmfOid: "2.16.840.1.113883.10.20.28.4.56", + qdmCategory: "patient_characteristic", + qdmStatus: "ethnicity", + qdmVersion: "5.6", + _type: "QDM::PatientCharacteristicEthnicity", + id: "656a0995c2da020000043b76", + }, + ], + library_name: "TestQDM", + statement_name: "SDE Ethnicity", + relevance: "NA", + final: "NA", + }, + "SDE Payer": { + raw: [], + library_name: "TestQDM", + statement_name: "SDE Payer", + relevance: "NA", + final: "NA", + }, + "SDE Race": { + raw: [ + { + dataElementCodes: [ + { + code: "2028-9", + system: "2.16.840.1.113883.6.238", + version: "1.2", + display: "Asian", + }, + ], + _id: "656a0992c2da020000043b72", + qdmTitle: "Patient Characteristic Race", + hqmfOid: "2.16.840.1.113883.10.20.28.4.59", + qdmCategory: "patient_characteristic", + qdmStatus: "race", + qdmVersion: "5.6", + _type: "QDM::PatientCharacteristicRace", + id: "656a0992c2da020000043b72", + }, + ], + library_name: "TestQDM", + statement_name: "SDE Race", + relevance: "NA", + final: "NA", + }, + "SDE Sex": { + raw: [ + { + dataElementCodes: [ + { + code: "M", + system: "2.16.840.1.113883.5.1", + version: "2022-11", + display: "Male", + }, + ], + _id: "656a0993c2da020000043b74", + qdmTitle: "Patient Characteristic Sex", + hqmfOid: "2.16.840.1.113883.10.20.28.4.55", + qdmCategory: "patient_characteristic", + qdmStatus: "gender", + qdmVersion: "5.6", + _type: "QDM::PatientCharacteristicSex", + id: "656a0993c2da020000043b74", + }, + ], + library_name: "TestQDM", + statement_name: "SDE Sex", + relevance: "NA", + final: "NA", + }, + FirstPhysicalExamWithEncounterId: { + library_name: "TestQDM", + statement_name: "FirstPhysicalExamWithEncounterId", + relevance: "NA", + final: "NA", + }, + FirstPhysicalExamWithEncounterIdUsingLabTiming: { + library_name: "TestQDM", + statement_name: "FirstPhysicalExamWithEncounterIdUsingLabTiming", + relevance: "NA", + final: "NA", + }, + FirstLabTestWithEncounterId: { + library_name: "TestQDM", + statement_name: "FirstLabTestWithEncounterId", + relevance: "NA", + final: "NA", + }, + "SDE Results": { + raw: { + FirstHeartRate: [], + FirstSystolicBloodPressure: [], + FirstRespiratoryRate: [], + FirstBodyTemperature: [], + FirstOxygenSaturation: [], + FirstBodyWeight: [], + FirstHematocritLab: [], + FirstWhiteBloodCellCount: [], + FirstPotassiumLab: [], + FirstSodiumLab: [], + FirstBicarbonateLab: [], + FirstCreatinineLab: [], + FirstGlucoseLab: [], + }, + library_name: "TestQDM", + statement_name: "SDE Results", + relevance: "NA", + final: "NA", + }, + LengthOfStay: { + library_name: "TestQDM", + statement_name: "LengthOfStay", + relevance: "NA", + final: "NA", + }, + }, + }, + clause_results: null, + patient: "656a098cc2da020000043b67", + measure: "656cd2e13761fb000092d358", + state: "complete", + }, + "656a08a29803a260d239a924": { + IPP: 0, + DENOM: 0, + DENEX: 0, + NUMER: 0, + NUMEX: 0, + DENEXCEP: 0, + episode_results: {}, + statement_relevance: { + MATGlobalCommonFunctionsQDM: { + HospitalizationWithObservationLengthofStay: "TRUE", + LengthInDays: "TRUE", + HospitalizationWithObservation: "TRUE", + EarliestOf: "NA", + Earliest: "NA", + HasStart: "NA", + NormalizeInterval: "NA", + }, + TestQDM: { + Patient: "TRUE", + "Inpatient Encounters": "TRUE", + "Initial Population": "TRUE", + Denominator: "TRUE", + Numerator: "FALSE", + "SDE Ethnicity": "NA", + "SDE Payer": "NA", + "SDE Race": "NA", + "SDE Sex": "NA", + FirstPhysicalExamWithEncounterId: "NA", + FirstPhysicalExamWithEncounterIdUsingLabTiming: "NA", + FirstLabTestWithEncounterId: "NA", + "SDE Results": "NA", + LengthOfStay: "NA", + }, + }, + population_relevance: { + IPP: true, + DENOM: false, + DENEX: false, + NUMER: false, + NUMEX: false, + DENEXCEP: false, + }, + statement_results: { + MATGlobalCommonFunctionsQDM: { + HospitalizationWithObservationLengthofStay: { + library_name: "MATGlobalCommonFunctionsQDM", + statement_name: "HospitalizationWithObservationLengthofStay", + relevance: "TRUE", + final: "UNHIT", + }, + LengthInDays: { + library_name: "MATGlobalCommonFunctionsQDM", + statement_name: "LengthInDays", + relevance: "TRUE", + final: "UNHIT", + }, + HospitalizationWithObservation: { + library_name: "MATGlobalCommonFunctionsQDM", + statement_name: "HospitalizationWithObservation", + relevance: "TRUE", + final: "UNHIT", + }, + EarliestOf: { + library_name: "MATGlobalCommonFunctionsQDM", + statement_name: "EarliestOf", + relevance: "NA", + final: "NA", + }, + Earliest: { + library_name: "MATGlobalCommonFunctionsQDM", + statement_name: "Earliest", + relevance: "NA", + final: "NA", + }, + HasStart: { + library_name: "MATGlobalCommonFunctionsQDM", + statement_name: "HasStart", + relevance: "NA", + final: "NA", + }, + NormalizeInterval: { + library_name: "MATGlobalCommonFunctionsQDM", + statement_name: "NormalizeInterval", + relevance: "NA", + final: "NA", + }, + }, + TestQDM: { + Patient: { + library_name: "TestQDM", + statement_name: "Patient", + relevance: "TRUE", + final: "FALSE", + }, + "Inpatient Encounters": { + raw: [], + library_name: "TestQDM", + statement_name: "Inpatient Encounters", + relevance: "TRUE", + final: "FALSE", + }, + "Initial Population": { + raw: [], + library_name: "TestQDM", + statement_name: "Initial Population", + relevance: "TRUE", + final: "FALSE", + }, + Denominator: { + raw: [], + library_name: "TestQDM", + statement_name: "Denominator", + relevance: "TRUE", + final: "FALSE", + }, + Numerator: { + raw: [], + library_name: "TestQDM", + statement_name: "Numerator", + relevance: "FALSE", + final: "UNHIT", + }, + "SDE Ethnicity": { + raw: [ + { + dataElementCodes: [ + { + code: "2135-2", + system: "2.16.840.1.113883.6.238", + version: "1.2", + display: "Hispanic or Latino", + }, + ], + _id: "656a0995c2da020000043b76", + qdmTitle: "Patient Characteristic Ethnicity", + hqmfOid: "2.16.840.1.113883.10.20.28.4.56", + qdmCategory: "patient_characteristic", + qdmStatus: "ethnicity", + qdmVersion: "5.6", + _type: "QDM::PatientCharacteristicEthnicity", + id: "656a0995c2da020000043b76", + }, + ], + library_name: "TestQDM", + statement_name: "SDE Ethnicity", + relevance: "NA", + final: "NA", + }, + "SDE Payer": { + raw: [], + library_name: "TestQDM", + statement_name: "SDE Payer", + relevance: "NA", + final: "NA", + }, + "SDE Race": { + raw: [ + { + dataElementCodes: [ + { + code: "2028-9", + system: "2.16.840.1.113883.6.238", + version: "1.2", + display: "Asian", + }, + ], + _id: "656a0992c2da020000043b72", + qdmTitle: "Patient Characteristic Race", + hqmfOid: "2.16.840.1.113883.10.20.28.4.59", + qdmCategory: "patient_characteristic", + qdmStatus: "race", + qdmVersion: "5.6", + _type: "QDM::PatientCharacteristicRace", + id: "656a0992c2da020000043b72", + }, + ], + library_name: "TestQDM", + statement_name: "SDE Race", + relevance: "NA", + final: "NA", + }, + "SDE Sex": { + raw: [ + { + dataElementCodes: [ + { + code: "M", + system: "2.16.840.1.113883.5.1", + version: "2022-11", + display: "Male", + }, + ], + _id: "656a0993c2da020000043b74", + qdmTitle: "Patient Characteristic Sex", + hqmfOid: "2.16.840.1.113883.10.20.28.4.55", + qdmCategory: "patient_characteristic", + qdmStatus: "gender", + qdmVersion: "5.6", + _type: "QDM::PatientCharacteristicSex", + id: "656a0993c2da020000043b74", + }, + ], + library_name: "TestQDM", + statement_name: "SDE Sex", + relevance: "NA", + final: "NA", + }, + FirstPhysicalExamWithEncounterId: { + library_name: "TestQDM", + statement_name: "FirstPhysicalExamWithEncounterId", + relevance: "NA", + final: "NA", + }, + FirstPhysicalExamWithEncounterIdUsingLabTiming: { + library_name: "TestQDM", + statement_name: "FirstPhysicalExamWithEncounterIdUsingLabTiming", + relevance: "NA", + final: "NA", + }, + FirstLabTestWithEncounterId: { + library_name: "TestQDM", + statement_name: "FirstLabTestWithEncounterId", + relevance: "NA", + final: "NA", + }, + "SDE Results": { + raw: { + FirstHeartRate: [], + FirstSystolicBloodPressure: [], + FirstRespiratoryRate: [], + FirstBodyTemperature: [], + FirstOxygenSaturation: [], + FirstBodyWeight: [], + FirstHematocritLab: [], + FirstWhiteBloodCellCount: [], + FirstPotassiumLab: [], + FirstSodiumLab: [], + FirstBicarbonateLab: [], + FirstCreatinineLab: [], + FirstGlucoseLab: [], + }, + library_name: "TestQDM", + statement_name: "SDE Results", + relevance: "NA", + final: "NA", + }, + LengthOfStay: { + library_name: "TestQDM", + statement_name: "LengthOfStay", + relevance: "NA", + final: "NA", + }, + }, + }, + clause_results: null, + patient: "656a098cc2da020000043b67", + measure: "656cd2e13761fb000092d358", + state: "complete", + }, +}; diff --git a/src/components/editTestCase/groupCoverage/_mocks_/QdmCallStack.ts b/src/components/editTestCase/groupCoverage/_mocks_/QdmCallStack.ts new file mode 100644 index 000000000..7c7a8c7dd --- /dev/null +++ b/src/components/editTestCase/groupCoverage/_mocks_/QdmCallStack.ts @@ -0,0 +1,642 @@ +export const qdmCallStack = [ + { + id: "MATGlobalCommonFunctionsQDM-1.0.000|Global|ED Encounter", + definitionName: "ED Encounter", + definitionLogic: + 'define "ED Encounter":\n ["Encounter, Performed": "Emergency Department Visit"]', + context: "Patient", + supplDataElement: false, + popDefinition: false, + commentString: "", + returnType: null, + parentLibrary: "MATGlobalCommonFunctionsQDM", + libraryDisplayName: "Global", + libraryVersion: "1.0.000", + name: "ED Encounter", + function: false, + logic: + 'define "ED Encounter":\n ["Encounter, Performed": "Emergency Department Visit"]', + }, + { + id: "MATGlobalCommonFunctionsQDM-1.0.000|Global|EarliestOf", + definitionName: "EarliestOf", + definitionLogic: + 'define function "EarliestOf"(pointInTime DateTime, period Interval ):\n Earliest(NormalizeInterval(pointInTime, period))', + context: "Patient", + supplDataElement: false, + popDefinition: false, + commentString: "", + returnType: null, + parentLibrary: "MATGlobalCommonFunctionsQDM", + libraryDisplayName: "Global", + libraryVersion: "1.0.000", + name: "EarliestOf", + function: true, + logic: + 'define function "EarliestOf"(pointInTime DateTime, period Interval ):\n Earliest(NormalizeInterval(pointInTime, period))', + }, + { + id: "MATGlobalCommonFunctionsQDM-1.0.000|Global|HospitalizationLengthofStay", + definitionName: "HospitalizationLengthofStay", + definitionLogic: + 'define function "HospitalizationLengthofStay"(Encounter "Encounter, Performed" ):\n LengthInDays("Hospitalization"(Encounter))', + context: "Patient", + supplDataElement: false, + popDefinition: false, + commentString: "", + returnType: null, + parentLibrary: "MATGlobalCommonFunctionsQDM", + libraryDisplayName: "Global", + libraryVersion: "1.0.000", + name: "HospitalizationLengthofStay", + function: true, + logic: + 'define function "HospitalizationLengthofStay"(Encounter "Encounter, Performed" ):\n LengthInDays("Hospitalization"(Encounter))', + }, + { + id: "SDE Race", + definitionName: "SDE Race", + definitionLogic: + 'define "SDE Race":\n ["Patient Characteristic Race": "Race"]', + context: "Patient", + supplDataElement: false, + popDefinition: false, + commentString: "", + returnType: null, + parentLibrary: null, + libraryDisplayName: null, + libraryVersion: null, + name: "SDE Race", + function: false, + logic: 'define "SDE Race":\n ["Patient Characteristic Race": "Race"]', + }, + { + id: "MATGlobalCommonFunctionsQDM-1.0.000|Global|Inpatient Encounter", + definitionName: "Inpatient Encounter", + definitionLogic: + 'define "Inpatient Encounter":\n ["Encounter, Performed": "Encounter Inpatient"] EncounterInpatient\n where "LengthInDays"(EncounterInpatient.relevantPeriod)<= 120\n and EncounterInpatient.relevantPeriod ends during day of "Measurement Period"', + context: "Patient", + supplDataElement: false, + popDefinition: false, + commentString: "", + returnType: null, + parentLibrary: "MATGlobalCommonFunctionsQDM", + libraryDisplayName: "Global", + libraryVersion: "1.0.000", + name: "Inpatient Encounter", + function: false, + logic: + 'define "Inpatient Encounter":\n ["Encounter, Performed": "Encounter Inpatient"] EncounterInpatient\n where "LengthInDays"(EncounterInpatient.relevantPeriod)<= 120\n and EncounterInpatient.relevantPeriod ends during day of "Measurement Period"', + }, + { + id: "MATGlobalCommonFunctionsQDM-1.0.000|Global|HospitalizationLocations", + definitionName: "HospitalizationLocations", + definitionLogic: + 'define function "HospitalizationLocations"(Encounter "Encounter, Performed" ):\n Encounter Visit\n \tlet EDVisit: Last(["Encounter, Performed": "Emergency Department Visit"] LastED\n \t\t\twhere LastED.relevantPeriod ends 1 hour or less on or before start of Visit.relevantPeriod\n \t\t\tsort by \n \t\t\tend of relevantPeriod\n \t)\n \treturn if EDVisit is null then Visit.facilityLocations \n \t\telse flatten { EDVisit.facilityLocations, Visit.facilityLocations }', + context: "Patient", + supplDataElement: false, + popDefinition: false, + commentString: "", + returnType: null, + parentLibrary: "MATGlobalCommonFunctionsQDM", + libraryDisplayName: "Global", + libraryVersion: "1.0.000", + name: "HospitalizationLocations", + function: true, + logic: + 'define function "HospitalizationLocations"(Encounter "Encounter, Performed" ):\n Encounter Visit\n \tlet EDVisit: Last(["Encounter, Performed": "Emergency Department Visit"] LastED\n \t\t\twhere LastED.relevantPeriod ends 1 hour or less on or before start of Visit.relevantPeriod\n \t\t\tsort by \n \t\t\tend of relevantPeriod\n \t)\n \treturn if EDVisit is null then Visit.facilityLocations \n \t\telse flatten { EDVisit.facilityLocations, Visit.facilityLocations }', + }, + { + id: "Inpatient Encounters", + definitionName: "Inpatient Encounters", + definitionLogic: + 'define "Inpatient Encounters":\n ["Encounter, Performed": "Encounter Inpatient"] InpatientEncounter\n with ( ["Patient Characteristic Payer": "Medicare FFS payer"]\n union ["Patient Characteristic Payer": "Medicare Advantage payer"] ) Payer\n such that Global."HospitalizationWithObservationLengthofStay" ( InpatientEncounter ) < 365\n and InpatientEncounter.relevantPeriod ends during day of "Measurement Period"\n and AgeInYearsAt(date from start of InpatientEncounter.relevantPeriod)>= 65', + context: "Patient", + supplDataElement: false, + popDefinition: false, + commentString: "", + returnType: null, + parentLibrary: null, + libraryDisplayName: null, + libraryVersion: null, + name: "Inpatient Encounters", + function: false, + logic: + 'define "Inpatient Encounters":\n ["Encounter, Performed": "Encounter Inpatient"] InpatientEncounter\n with ( ["Patient Characteristic Payer": "Medicare FFS payer"]\n union ["Patient Characteristic Payer": "Medicare Advantage payer"] ) Payer\n such that Global."HospitalizationWithObservationLengthofStay" ( InpatientEncounter ) < 365\n and InpatientEncounter.relevantPeriod ends during day of "Measurement Period"\n and AgeInYearsAt(date from start of InpatientEncounter.relevantPeriod)>= 65', + }, + { + id: "SDE Results", + definitionName: "SDE Results", + definitionLogic: + 'define "SDE Results":\n {\n // First physical exams\n FirstHeartRate: "FirstPhysicalExamWithEncounterId"(["Physical Exam, Performed": "Heart Rate"]),\n FirstSystolicBloodPressure: "FirstPhysicalExamWithEncounterId"(["Physical Exam, Performed": "Systolic Blood Pressure"]),\n FirstRespiratoryRate: "FirstPhysicalExamWithEncounterId"(["Physical Exam, Performed": "Respiratory Rate"]),\n FirstBodyTemperature: "FirstPhysicalExamWithEncounterId"(["Physical Exam, Performed": "Body temperature"]),\n FirstOxygenSaturation: "FirstPhysicalExamWithEncounterId"(["Physical Exam, Performed": "Oxygen Saturation by Pulse Oximetry"]),\n // Weight uses lab test timing\n FirstBodyWeight: "FirstPhysicalExamWithEncounterIdUsingLabTiming"(["Physical Exam, Performed": "Body weight"]),\n \n // First lab tests\n FirstHematocritLab: "FirstLabTestWithEncounterId"(["Laboratory Test, Performed": "Hematocrit lab test"]),\n FirstWhiteBloodCellCount: "FirstLabTestWithEncounterId"(["Laboratory Test, Performed": "White blood cells count lab test"]),\n FirstPotassiumLab: "FirstLabTestWithEncounterId"(["Laboratory Test, Performed": "Potassium lab test"]),\n FirstSodiumLab: "FirstLabTestWithEncounterId"(["Laboratory Test, Performed": "Sodium lab test"]),\n FirstBicarbonateLab: "FirstLabTestWithEncounterId"(["Laboratory Test, Performed": "Bicarbonate lab test"]),\n FirstCreatinineLab: "FirstLabTestWithEncounterId"(["Laboratory Test, Performed": "Creatinine lab test"]),\n FirstGlucoseLab: "FirstLabTestWithEncounterId"(["Laboratory Test, Performed": "Glucose lab test"])\n }', + context: "Patient", + supplDataElement: false, + popDefinition: false, + commentString: "", + returnType: null, + parentLibrary: null, + libraryDisplayName: null, + libraryVersion: null, + name: "SDE Results", + function: false, + logic: + 'define "SDE Results":\n {\n // First physical exams\n FirstHeartRate: "FirstPhysicalExamWithEncounterId"(["Physical Exam, Performed": "Heart Rate"]),\n FirstSystolicBloodPressure: "FirstPhysicalExamWithEncounterId"(["Physical Exam, Performed": "Systolic Blood Pressure"]),\n FirstRespiratoryRate: "FirstPhysicalExamWithEncounterId"(["Physical Exam, Performed": "Respiratory Rate"]),\n FirstBodyTemperature: "FirstPhysicalExamWithEncounterId"(["Physical Exam, Performed": "Body temperature"]),\n FirstOxygenSaturation: "FirstPhysicalExamWithEncounterId"(["Physical Exam, Performed": "Oxygen Saturation by Pulse Oximetry"]),\n // Weight uses lab test timing\n FirstBodyWeight: "FirstPhysicalExamWithEncounterIdUsingLabTiming"(["Physical Exam, Performed": "Body weight"]),\n \n // First lab tests\n FirstHematocritLab: "FirstLabTestWithEncounterId"(["Laboratory Test, Performed": "Hematocrit lab test"]),\n FirstWhiteBloodCellCount: "FirstLabTestWithEncounterId"(["Laboratory Test, Performed": "White blood cells count lab test"]),\n FirstPotassiumLab: "FirstLabTestWithEncounterId"(["Laboratory Test, Performed": "Potassium lab test"]),\n FirstSodiumLab: "FirstLabTestWithEncounterId"(["Laboratory Test, Performed": "Sodium lab test"]),\n FirstBicarbonateLab: "FirstLabTestWithEncounterId"(["Laboratory Test, Performed": "Bicarbonate lab test"]),\n FirstCreatinineLab: "FirstLabTestWithEncounterId"(["Laboratory Test, Performed": "Creatinine lab test"]),\n FirstGlucoseLab: "FirstLabTestWithEncounterId"(["Laboratory Test, Performed": "Glucose lab test"])\n }', + }, + { + id: "Denominator", + definitionName: "Denominator", + definitionLogic: 'define "Denominator":\n "Initial Population"', + context: "Patient", + supplDataElement: false, + popDefinition: false, + commentString: "", + returnType: null, + parentLibrary: null, + libraryDisplayName: null, + libraryVersion: null, + name: "Denominator", + function: false, + logic: 'define "Denominator":\n "Initial Population"', + }, + { + id: "MATGlobalCommonFunctionsQDM-1.0.000|Global|HospitalDepartureTime", + definitionName: "HospitalDepartureTime", + definitionLogic: + 'define function "HospitalDepartureTime"(Encounter "Encounter, Performed" ):\n end of Last(("HospitalizationLocations"(Encounter))HospitalLocation\n \t\tsort by start of locationPeriod\n ).locationPeriod', + context: "Patient", + supplDataElement: false, + popDefinition: false, + commentString: "", + returnType: null, + parentLibrary: "MATGlobalCommonFunctionsQDM", + libraryDisplayName: "Global", + libraryVersion: "1.0.000", + name: "HospitalDepartureTime", + function: true, + logic: + 'define function "HospitalDepartureTime"(Encounter "Encounter, Performed" ):\n end of Last(("HospitalizationLocations"(Encounter))HospitalLocation\n \t\tsort by start of locationPeriod\n ).locationPeriod', + }, + { + id: "MATGlobalCommonFunctionsQDM-1.0.000|Global|HospitalArrivalTime", + definitionName: "HospitalArrivalTime", + definitionLogic: + 'define function "HospitalArrivalTime"(Encounter "Encounter, Performed" ):\n start of First(("HospitalizationLocations"(Encounter))HospitalLocation\n \t\tsort by start of locationPeriod\n ).locationPeriod', + context: "Patient", + supplDataElement: false, + popDefinition: false, + commentString: "", + returnType: null, + parentLibrary: "MATGlobalCommonFunctionsQDM", + libraryDisplayName: "Global", + libraryVersion: "1.0.000", + name: "HospitalArrivalTime", + function: true, + logic: + 'define function "HospitalArrivalTime"(Encounter "Encounter, Performed" ):\n start of First(("HospitalizationLocations"(Encounter))HospitalLocation\n \t\tsort by start of locationPeriod\n ).locationPeriod', + }, + { + id: "MATGlobalCommonFunctionsQDM-1.0.000|Global|FirstInpatientIntensiveCareUnit", + definitionName: "FirstInpatientIntensiveCareUnit", + definitionLogic: + 'define function "FirstInpatientIntensiveCareUnit"(Encounter "Encounter, Performed" ):\n First((Encounter.facilityLocations)HospitalLocation\n where HospitalLocation.code in "Intensive Care Unit"\n and HospitalLocation.locationPeriod during Encounter.relevantPeriod\n sort by start of locationPeriod\n )', + context: "Patient", + supplDataElement: false, + popDefinition: false, + commentString: "", + returnType: null, + parentLibrary: "MATGlobalCommonFunctionsQDM", + libraryDisplayName: "Global", + libraryVersion: "1.0.000", + name: "FirstInpatientIntensiveCareUnit", + function: true, + logic: + 'define function "FirstInpatientIntensiveCareUnit"(Encounter "Encounter, Performed" ):\n First((Encounter.facilityLocations)HospitalLocation\n where HospitalLocation.code in "Intensive Care Unit"\n and HospitalLocation.locationPeriod during Encounter.relevantPeriod\n sort by start of locationPeriod\n )', + }, + { + id: "MATGlobalCommonFunctionsQDM-1.0.000|Global|HospitalAdmissionTime", + definitionName: "HospitalAdmissionTime", + definitionLogic: + 'define function "HospitalAdmissionTime"(Encounter "Encounter, Performed" ):\n start of "Hospitalization"(Encounter)', + context: "Patient", + supplDataElement: false, + popDefinition: false, + commentString: "", + returnType: null, + parentLibrary: "MATGlobalCommonFunctionsQDM", + libraryDisplayName: "Global", + libraryVersion: "1.0.000", + name: "HospitalAdmissionTime", + function: true, + logic: + 'define function "HospitalAdmissionTime"(Encounter "Encounter, Performed" ):\n start of "Hospitalization"(Encounter)', + }, + { + id: "Numerator", + definitionName: "Numerator", + definitionLogic: 'define "Numerator":\n "Initial Population"', + context: "Patient", + supplDataElement: false, + popDefinition: false, + commentString: "", + returnType: null, + parentLibrary: null, + libraryDisplayName: null, + libraryVersion: null, + name: "Numerator", + function: false, + logic: 'define "Numerator":\n "Initial Population"', + }, + { + id: "MATGlobalCommonFunctionsQDM-1.0.000|Global|EmergencyDepartmentArrivalTime", + definitionName: "EmergencyDepartmentArrivalTime", + definitionLogic: + 'define function "EmergencyDepartmentArrivalTime"(Encounter "Encounter, Performed" ):\n start of First(("HospitalizationLocations"(Encounter))HospitalLocation\n \t\twhere HospitalLocation.code in "Emergency Department Visit"\n \t\tsort by start of locationPeriod\n ).locationPeriod', + context: "Patient", + supplDataElement: false, + popDefinition: false, + commentString: "", + returnType: null, + parentLibrary: "MATGlobalCommonFunctionsQDM", + libraryDisplayName: "Global", + libraryVersion: "1.0.000", + name: "EmergencyDepartmentArrivalTime", + function: true, + logic: + 'define function "EmergencyDepartmentArrivalTime"(Encounter "Encounter, Performed" ):\n start of First(("HospitalizationLocations"(Encounter))HospitalLocation\n \t\twhere HospitalLocation.code in "Emergency Department Visit"\n \t\tsort by start of locationPeriod\n ).locationPeriod', + }, + { + id: "MATGlobalCommonFunctionsQDM-1.0.000|Global|HospitalizationWithObservationAndOutpatientSurgeryService", + definitionName: "HospitalizationWithObservationAndOutpatientSurgeryService", + definitionLogic: + 'define function "HospitalizationWithObservationAndOutpatientSurgeryService"(Encounter "Encounter, Performed" ):\n Encounter Visit\n \tlet ObsVisit: Last(["Encounter, Performed": "Observation Services"] LastObs\n \t\t\twhere LastObs.relevantPeriod ends 1 hour or less on or before start of Visit.relevantPeriod\n \t\t\tsort by \n \t\t\tend of relevantPeriod\n \t),\n \tVisitStart: Coalesce(start of ObsVisit.relevantPeriod, start of Visit.relevantPeriod),\n \tEDVisit: Last(["Encounter, Performed": "Emergency Department Visit"] LastED\n \t\t\twhere LastED.relevantPeriod ends 1 hour or less on or before VisitStart\n \t\t\tsort by \n \t\t\tend of relevantPeriod\n \t),\n \tVisitStartWithED: Coalesce(start of EDVisit.relevantPeriod, VisitStart),\n \tOutpatientSurgeryVisit: Last(["Encounter, Performed": "Outpatient Surgery Service"] LastSurgeryOP\n \t\t\twhere LastSurgeryOP.relevantPeriod ends 1 hour or less on or before VisitStartWithED\n \t\t\tsort by \n \t\t\tend of relevantPeriod\n \t)\n \treturn Interval[Coalesce(start of OutpatientSurgeryVisit.relevantPeriod, VisitStartWithED), \n \tend of Visit.relevantPeriod]', + context: "Patient", + supplDataElement: false, + popDefinition: false, + commentString: "", + returnType: null, + parentLibrary: "MATGlobalCommonFunctionsQDM", + libraryDisplayName: "Global", + libraryVersion: "1.0.000", + name: "HospitalizationWithObservationAndOutpatientSurgeryService", + function: true, + logic: + 'define function "HospitalizationWithObservationAndOutpatientSurgeryService"(Encounter "Encounter, Performed" ):\n Encounter Visit\n \tlet ObsVisit: Last(["Encounter, Performed": "Observation Services"] LastObs\n \t\t\twhere LastObs.relevantPeriod ends 1 hour or less on or before start of Visit.relevantPeriod\n \t\t\tsort by \n \t\t\tend of relevantPeriod\n \t),\n \tVisitStart: Coalesce(start of ObsVisit.relevantPeriod, start of Visit.relevantPeriod),\n \tEDVisit: Last(["Encounter, Performed": "Emergency Department Visit"] LastED\n \t\t\twhere LastED.relevantPeriod ends 1 hour or less on or before VisitStart\n \t\t\tsort by \n \t\t\tend of relevantPeriod\n \t),\n \tVisitStartWithED: Coalesce(start of EDVisit.relevantPeriod, VisitStart),\n \tOutpatientSurgeryVisit: Last(["Encounter, Performed": "Outpatient Surgery Service"] LastSurgeryOP\n \t\t\twhere LastSurgeryOP.relevantPeriod ends 1 hour or less on or before VisitStartWithED\n \t\t\tsort by \n \t\t\tend of relevantPeriod\n \t)\n \treturn Interval[Coalesce(start of OutpatientSurgeryVisit.relevantPeriod, VisitStartWithED), \n \tend of Visit.relevantPeriod]', + }, + { + id: "MATGlobalCommonFunctionsQDM-1.0.000|Global|Earliest", + definitionName: "Earliest", + definitionLogic: + 'define function "Earliest"(period Interval ):\n if ( HasStart(period)) then start of period \n else \n end of period', + context: "Patient", + supplDataElement: false, + popDefinition: false, + commentString: "", + returnType: null, + parentLibrary: "MATGlobalCommonFunctionsQDM", + libraryDisplayName: "Global", + libraryVersion: "1.0.000", + name: "Earliest", + function: true, + logic: + 'define function "Earliest"(period Interval ):\n if ( HasStart(period)) then start of period \n else \n end of period', + }, + { + id: "MATGlobalCommonFunctionsQDM-1.0.000|Global|HospitalizationWithObservationLengthofStay", + definitionName: "HospitalizationWithObservationLengthofStay", + definitionLogic: + 'define function "HospitalizationWithObservationLengthofStay"(Encounter "Encounter, Performed" ):\n "LengthInDays"("HospitalizationWithObservation"(Encounter))', + context: "Patient", + supplDataElement: false, + popDefinition: false, + commentString: "", + returnType: null, + parentLibrary: "MATGlobalCommonFunctionsQDM", + libraryDisplayName: "Global", + libraryVersion: "1.0.000", + name: "HospitalizationWithObservationLengthofStay", + function: true, + logic: + 'define function "HospitalizationWithObservationLengthofStay"(Encounter "Encounter, Performed" ):\n "LengthInDays"("HospitalizationWithObservation"(Encounter))', + }, + { + id: "FirstPhysicalExamWithEncounterIdUsingLabTiming", + definitionName: "FirstPhysicalExamWithEncounterIdUsingLabTiming", + definitionLogic: + 'define function "FirstPhysicalExamWithEncounterIdUsingLabTiming"(ExamList List ):\n "Inpatient Encounters" Encounter\n let FirstExamWithLabTiming: First(ExamList Exam\n where Global."EarliestOf"(Exam.relevantDatetime, Exam.relevantPeriod)during Interval[start of Encounter.relevantPeriod - 1440 minutes, start of Encounter.relevantPeriod + 1440 minutes]\n sort by Global."EarliestOf"(relevantDatetime, relevantPeriod)\n )\n return {\n EncounterId: Encounter.id,\n FirstResult: FirstExamWithLabTiming.result as Quantity,\n Timing: Global."EarliestOf" ( FirstExamWithLabTiming.relevantDatetime, FirstExamWithLabTiming.relevantPeriod )\n }', + context: "Patient", + supplDataElement: false, + popDefinition: false, + commentString: "", + returnType: null, + parentLibrary: null, + libraryDisplayName: null, + libraryVersion: null, + name: "FirstPhysicalExamWithEncounterIdUsingLabTiming", + function: true, + logic: + 'define function "FirstPhysicalExamWithEncounterIdUsingLabTiming"(ExamList List ):\n "Inpatient Encounters" Encounter\n let FirstExamWithLabTiming: First(ExamList Exam\n where Global."EarliestOf"(Exam.relevantDatetime, Exam.relevantPeriod)during Interval[start of Encounter.relevantPeriod - 1440 minutes, start of Encounter.relevantPeriod + 1440 minutes]\n sort by Global."EarliestOf"(relevantDatetime, relevantPeriod)\n )\n return {\n EncounterId: Encounter.id,\n FirstResult: FirstExamWithLabTiming.result as Quantity,\n Timing: Global."EarliestOf" ( FirstExamWithLabTiming.relevantDatetime, FirstExamWithLabTiming.relevantPeriod )\n }', + }, + { + id: "MATGlobalCommonFunctionsQDM-1.0.000|Global|HospitalDischargeTime", + definitionName: "HospitalDischargeTime", + definitionLogic: + 'define function "HospitalDischargeTime"(Encounter "Encounter, Performed" ):\n end of Encounter.relevantPeriod', + context: "Patient", + supplDataElement: false, + popDefinition: false, + commentString: "", + returnType: null, + parentLibrary: "MATGlobalCommonFunctionsQDM", + libraryDisplayName: "Global", + libraryVersion: "1.0.000", + name: "HospitalDischargeTime", + function: true, + logic: + 'define function "HospitalDischargeTime"(Encounter "Encounter, Performed" ):\n end of Encounter.relevantPeriod', + }, + { + id: "SDE Sex", + definitionName: "SDE Sex", + definitionLogic: + 'define "SDE Sex":\n ["Patient Characteristic Sex": "ONC Administrative Sex"]', + context: "Patient", + supplDataElement: false, + popDefinition: false, + commentString: "", + returnType: null, + parentLibrary: null, + libraryDisplayName: null, + libraryVersion: null, + name: "SDE Sex", + function: false, + logic: + 'define "SDE Sex":\n ["Patient Characteristic Sex": "ONC Administrative Sex"]', + }, + { + id: "MATGlobalCommonFunctionsQDM-1.0.000|Global|HasEnd", + definitionName: "HasEnd", + definitionLogic: + 'define function "HasEnd"(period Interval ):\n not ( \n end of period is null\n or \n end of period = maximum DateTime\n )', + context: "Patient", + supplDataElement: false, + popDefinition: false, + commentString: "", + returnType: null, + parentLibrary: "MATGlobalCommonFunctionsQDM", + libraryDisplayName: "Global", + libraryVersion: "1.0.000", + name: "HasEnd", + function: true, + logic: + 'define function "HasEnd"(period Interval ):\n not ( \n end of period is null\n or \n end of period = maximum DateTime\n )', + }, + { + id: "LengthOfStay", + definitionName: "LengthOfStay", + definitionLogic: + 'define function "LengthOfStay"(Stay Interval ):\n difference in days between start of Stay and \n end of Stay', + context: "Patient", + supplDataElement: false, + popDefinition: false, + commentString: "", + returnType: null, + parentLibrary: null, + libraryDisplayName: null, + libraryVersion: null, + name: "LengthOfStay", + function: true, + logic: + 'define function "LengthOfStay"(Stay Interval ):\n difference in days between start of Stay and \n end of Stay', + }, + { + id: "MATGlobalCommonFunctionsQDM-1.0.000|Global|ToDateInterval", + definitionName: "ToDateInterval", + definitionLogic: + 'define function "ToDateInterval"(period Interval ):\n Interval[date from start of period, date from end of period]', + context: "Patient", + supplDataElement: false, + popDefinition: false, + commentString: "", + returnType: null, + parentLibrary: "MATGlobalCommonFunctionsQDM", + libraryDisplayName: "Global", + libraryVersion: "1.0.000", + name: "ToDateInterval", + function: true, + logic: + 'define function "ToDateInterval"(period Interval ):\n Interval[date from start of period, date from end of period]', + }, + { + id: "MATGlobalCommonFunctionsQDM-1.0.000|Global|HasStart", + definitionName: "HasStart", + definitionLogic: + 'define function "HasStart"(period Interval ):\n not ( start of period is null\n or start of period = minimum DateTime\n )', + context: "Patient", + supplDataElement: false, + popDefinition: false, + commentString: "", + returnType: null, + parentLibrary: "MATGlobalCommonFunctionsQDM", + libraryDisplayName: "Global", + libraryVersion: "1.0.000", + name: "HasStart", + function: true, + logic: + 'define function "HasStart"(period Interval ):\n not ( start of period is null\n or start of period = minimum DateTime\n )', + }, + { + id: "MATGlobalCommonFunctionsQDM-1.0.000|Global|LengthInDays", + definitionName: "LengthInDays", + definitionLogic: + 'define function "LengthInDays"(Value Interval ):\n difference in days between start of Value and end of Value', + context: "Patient", + supplDataElement: false, + popDefinition: false, + commentString: "", + returnType: null, + parentLibrary: "MATGlobalCommonFunctionsQDM", + libraryDisplayName: "Global", + libraryVersion: "1.0.000", + name: "LengthInDays", + function: true, + logic: + 'define function "LengthInDays"(Value Interval ):\n difference in days between start of Value and end of Value', + }, + { + id: "Initial Population", + definitionName: "Initial Population", + definitionLogic: 'define "Initial Population":\n "Inpatient Encounters"', + context: "Patient", + supplDataElement: false, + popDefinition: false, + commentString: "", + returnType: null, + parentLibrary: null, + libraryDisplayName: null, + libraryVersion: null, + name: "Initial Population", + function: false, + logic: 'define "Initial Population":\n "Inpatient Encounters"', + }, + { + id: "FirstPhysicalExamWithEncounterId", + definitionName: "FirstPhysicalExamWithEncounterId", + definitionLogic: + 'define function "FirstPhysicalExamWithEncounterId"(ExamList List ):\n "Inpatient Encounters" Encounter\n let FirstExam: First(ExamList Exam\n where Global."EarliestOf"(Exam.relevantDatetime, Exam.relevantPeriod)during Interval[start of Encounter.relevantPeriod - 1440 minutes, start of Encounter.relevantPeriod + 120 minutes]\n sort by Global."EarliestOf"(relevantDatetime, relevantPeriod)\n )\n return {\n EncounterId: Encounter.id,\n FirstResult: FirstExam.result as Quantity,\n Timing: Global."EarliestOf" ( FirstExam.relevantDatetime, FirstExam.relevantPeriod )\n }', + context: "Patient", + supplDataElement: false, + popDefinition: false, + commentString: "", + returnType: null, + parentLibrary: null, + libraryDisplayName: null, + libraryVersion: null, + name: "FirstPhysicalExamWithEncounterId", + function: true, + logic: + 'define function "FirstPhysicalExamWithEncounterId"(ExamList List ):\n "Inpatient Encounters" Encounter\n let FirstExam: First(ExamList Exam\n where Global."EarliestOf"(Exam.relevantDatetime, Exam.relevantPeriod)during Interval[start of Encounter.relevantPeriod - 1440 minutes, start of Encounter.relevantPeriod + 120 minutes]\n sort by Global."EarliestOf"(relevantDatetime, relevantPeriod)\n )\n return {\n EncounterId: Encounter.id,\n FirstResult: FirstExam.result as Quantity,\n Timing: Global."EarliestOf" ( FirstExam.relevantDatetime, FirstExam.relevantPeriod )\n }', + }, + { + id: "FirstLabTestWithEncounterId", + definitionName: "FirstLabTestWithEncounterId", + definitionLogic: + 'define function "FirstLabTestWithEncounterId"(LabList List ):\n "Inpatient Encounters" Encounter\n let FirstLab: First(LabList Lab\n where Lab.resultDatetime during Interval[start of Encounter.relevantPeriod - 1440 minutes, start of Encounter.relevantPeriod + 1440 minutes]\n sort by resultDatetime\n )\n return {\n EncounterId: Encounter.id,\n FirstResult: FirstLab.result as Quantity,\n Timing: FirstLab.resultDatetime\n }', + context: "Patient", + supplDataElement: false, + popDefinition: false, + commentString: "", + returnType: null, + parentLibrary: null, + libraryDisplayName: null, + libraryVersion: null, + name: "FirstLabTestWithEncounterId", + function: true, + logic: + 'define function "FirstLabTestWithEncounterId"(LabList List ):\n "Inpatient Encounters" Encounter\n let FirstLab: First(LabList Lab\n where Lab.resultDatetime during Interval[start of Encounter.relevantPeriod - 1440 minutes, start of Encounter.relevantPeriod + 1440 minutes]\n sort by resultDatetime\n )\n return {\n EncounterId: Encounter.id,\n FirstResult: FirstLab.result as Quantity,\n Timing: FirstLab.resultDatetime\n }', + }, + { + id: "MATGlobalCommonFunctionsQDM-1.0.000|Global|Hospitalization", + definitionName: "Hospitalization", + definitionLogic: + 'define function "Hospitalization"(Encounter "Encounter, Performed" ):\n Encounter Visit\n \tlet EDVisit: Last(["Encounter, Performed": "Emergency Department Visit"] LastED\n \t\t\twhere LastED.relevantPeriod ends 1 hour or less on or before start of Visit.relevantPeriod\n \t\t\tsort by \n \t\t\tend of relevantPeriod\n \t)\n \treturn Interval[Coalesce(start of EDVisit.relevantPeriod, start of Visit.relevantPeriod), \n \tend of Visit.relevantPeriod]', + context: "Patient", + supplDataElement: false, + popDefinition: false, + commentString: "", + returnType: null, + parentLibrary: "MATGlobalCommonFunctionsQDM", + libraryDisplayName: "Global", + libraryVersion: "1.0.000", + name: "Hospitalization", + function: true, + logic: + 'define function "Hospitalization"(Encounter "Encounter, Performed" ):\n Encounter Visit\n \tlet EDVisit: Last(["Encounter, Performed": "Emergency Department Visit"] LastED\n \t\t\twhere LastED.relevantPeriod ends 1 hour or less on or before start of Visit.relevantPeriod\n \t\t\tsort by \n \t\t\tend of relevantPeriod\n \t)\n \treturn Interval[Coalesce(start of EDVisit.relevantPeriod, start of Visit.relevantPeriod), \n \tend of Visit.relevantPeriod]', + }, + { + id: "MATGlobalCommonFunctionsQDM-1.0.000|Global|Latest", + definitionName: "Latest", + definitionLogic: + 'define function "Latest"(period Interval ):\n if ( HasEnd(period)) then \n end of period \n else start of period', + context: "Patient", + supplDataElement: false, + popDefinition: false, + commentString: "", + returnType: null, + parentLibrary: "MATGlobalCommonFunctionsQDM", + libraryDisplayName: "Global", + libraryVersion: "1.0.000", + name: "Latest", + function: true, + logic: + 'define function "Latest"(period Interval ):\n if ( HasEnd(period)) then \n end of period \n else start of period', + }, + { + id: "MATGlobalCommonFunctionsQDM-1.0.000|Global|HospitalizationWithObservation", + definitionName: "HospitalizationWithObservation", + definitionLogic: + 'define function "HospitalizationWithObservation"(Encounter "Encounter, Performed" ):\n Encounter Visit\n \tlet ObsVisit: Last(["Encounter, Performed": "Observation Services"] LastObs\n \t\t\twhere LastObs.relevantPeriod ends 1 hour or less on or before start of Visit.relevantPeriod\n \t\t\tsort by \n \t\t\tend of relevantPeriod\n \t),\n \tVisitStart: Coalesce(start of ObsVisit.relevantPeriod, start of Visit.relevantPeriod),\n \tEDVisit: Last(["Encounter, Performed": "Emergency Department Visit"] LastED\n \t\t\twhere LastED.relevantPeriod ends 1 hour or less on or before VisitStart\n \t\t\tsort by \n \t\t\tend of relevantPeriod\n \t)\n \treturn Interval[Coalesce(start of EDVisit.relevantPeriod, VisitStart), \n \tend of Visit.relevantPeriod]', + context: "Patient", + supplDataElement: false, + popDefinition: false, + commentString: "", + returnType: null, + parentLibrary: "MATGlobalCommonFunctionsQDM", + libraryDisplayName: "Global", + libraryVersion: "1.0.000", + name: "HospitalizationWithObservation", + function: true, + logic: + 'define function "HospitalizationWithObservation"(Encounter "Encounter, Performed" ):\n Encounter Visit\n \tlet ObsVisit: Last(["Encounter, Performed": "Observation Services"] LastObs\n \t\t\twhere LastObs.relevantPeriod ends 1 hour or less on or before start of Visit.relevantPeriod\n \t\t\tsort by \n \t\t\tend of relevantPeriod\n \t),\n \tVisitStart: Coalesce(start of ObsVisit.relevantPeriod, start of Visit.relevantPeriod),\n \tEDVisit: Last(["Encounter, Performed": "Emergency Department Visit"] LastED\n \t\t\twhere LastED.relevantPeriod ends 1 hour or less on or before VisitStart\n \t\t\tsort by \n \t\t\tend of relevantPeriod\n \t)\n \treturn Interval[Coalesce(start of EDVisit.relevantPeriod, VisitStart), \n \tend of Visit.relevantPeriod]', + }, + { + id: "MATGlobalCommonFunctionsQDM-1.0.000|Global|NormalizeInterval", + definitionName: "NormalizeInterval", + definitionLogic: + 'define function "NormalizeInterval"(pointInTime DateTime, period Interval ):\n if pointInTime is not null then Interval[pointInTime, pointInTime]\n else if period is not null then period \n else null as Interval', + context: "Patient", + supplDataElement: false, + popDefinition: false, + commentString: "", + returnType: null, + parentLibrary: "MATGlobalCommonFunctionsQDM", + libraryDisplayName: "Global", + libraryVersion: "1.0.000", + name: "NormalizeInterval", + function: true, + logic: + 'define function "NormalizeInterval"(pointInTime DateTime, period Interval ):\n if pointInTime is not null then Interval[pointInTime, pointInTime]\n else if period is not null then period \n else null as Interval', + }, + { + id: "SDE Ethnicity", + definitionName: "SDE Ethnicity", + definitionLogic: + 'define "SDE Ethnicity":\n ["Patient Characteristic Ethnicity": "Ethnicity"]', + context: "Patient", + supplDataElement: false, + popDefinition: false, + commentString: "", + returnType: null, + parentLibrary: null, + libraryDisplayName: null, + libraryVersion: null, + name: "SDE Ethnicity", + function: false, + logic: + 'define "SDE Ethnicity":\n ["Patient Characteristic Ethnicity": "Ethnicity"]', + }, + { + id: "SDE Payer", + definitionName: "SDE Payer", + definitionLogic: + 'define "SDE Payer":\n ["Patient Characteristic Payer": "Payer"]', + context: "Patient", + supplDataElement: false, + popDefinition: false, + commentString: "", + returnType: null, + parentLibrary: null, + libraryDisplayName: null, + libraryVersion: null, + name: "SDE Payer", + function: false, + logic: 'define "SDE Payer":\n ["Patient Characteristic Payer": "Payer"]', + }, + { + id: "MATGlobalCommonFunctionsQDM-1.0.000|Global|LatestOf", + definitionName: "LatestOf", + definitionLogic: + 'define function "LatestOf"(pointInTime DateTime, period Interval ):\n Latest(NormalizeInterval(pointInTime, period))', + context: "Patient", + supplDataElement: false, + popDefinition: false, + commentString: "", + returnType: null, + parentLibrary: "MATGlobalCommonFunctionsQDM", + libraryDisplayName: "Global", + libraryVersion: "1.0.000", + name: "LatestOf", + function: true, + logic: + 'define function "LatestOf"(pointInTime DateTime, period Interval ):\n Latest(NormalizeInterval(pointInTime, period))', + }, +]; diff --git a/src/components/editTestCase/groupCoverage/_mocks_/QdmCovergaeMeasureCql.ts b/src/components/editTestCase/groupCoverage/_mocks_/QdmCovergaeMeasureCql.ts new file mode 100644 index 000000000..87a1f4742 --- /dev/null +++ b/src/components/editTestCase/groupCoverage/_mocks_/QdmCovergaeMeasureCql.ts @@ -0,0 +1,77 @@ +export const measureCql = `library HighlightingQDM version '0.0.000' + +using QDM version '5.6' + +codesystem "Test": 'urn:oid:2.16.840.1.113883.6.1' +codesystem "LOINC": 'urn:oid:2.16.840.1.113883.6.1' + +valueset "Emergency Department Visit": 'urn:oid:2.16.840.1.113883.3.117.1.7.1.292' +valueset "Encounter Inpatient": 'urn:oid:2.16.840.1.113883.3.666.5.307' +valueset "Ethnicity": 'urn:oid:2.16.840.1.114222.4.11.837' +valueset "Observation Services": 'urn:oid:2.16.840.1.113762.1.4.1111.143' +valueset "ONC Administrative Sex": 'urn:oid:2.16.840.1.113762.1.4.1' +valueset "Payer": 'urn:oid:2.16.840.1.114222.4.11.3591' +valueset "Race": 'urn:oid:2.16.840.1.114222.4.11.836' +valueset "Active Bleeding or Bleeding Diathesis (Excluding Menses)": 'urn:oid:2.16.840.1.113883.3.3157.4036' +valueset "Active Peptic Ulcer": 'urn:oid:2.16.840.1.113883.3.3157.4031' +valueset "Adverse reaction to thrombolytics": 'urn:oid:2.16.840.1.113762.1.4.1170.6' +valueset "Allergy to thrombolytics": 'urn:oid:2.16.840.1.113762.1.4.1170.5' +valueset "Anticoagulant Medications, Oral": 'urn:oid:2.16.840.1.113883.3.3157.4045' +valueset "Aortic Dissection and Rupture": 'urn:oid:2.16.840.1.113883.3.3157.4028' +valueset "birth date": 'urn:oid:2.16.840.1.113883.3.560.100.4' +valueset "Cardiopulmonary Arrest": 'urn:oid:2.16.840.1.113883.3.3157.4048' +valueset "Cerebral Vascular Lesion": 'urn:oid:2.16.840.1.113883.3.3157.4025' +valueset "Closed Head and Facial Trauma": 'urn:oid:2.16.840.1.113883.3.3157.4026' +valueset "Dementia": 'urn:oid:2.16.840.1.113883.3.3157.4043' +valueset "Discharge To Acute Care Facility": 'urn:oid:2.16.840.1.113883.3.117.1.7.1.87' + +code "Birth date": '21112-8' from "LOINC" display 'Birth date' + +parameter "Measurement Period" Interval + +context Patient + +define "SDE Ethnicity": + ["Patient Characteristic Ethnicity": "Ethnicity"] + +define "SDE Payer": + ["Patient Characteristic Payer": "Payer"] + +define "SDE Race": + ["Patient Characteristic Race": "Race"] + +define "SDE Sex": + ["Patient Characteristic Sex": "ONC Administrative Sex"] + + +define "Initial Population": + ["Encounter, Performed": "Emergency Department Visit"] //Encounter + union ["Encounter, Performed": "Closed Head and Facial Trauma"] //Encounter + union ["Encounter, Performed": "Dementia"] //Encounter + +define "Denominator": + "Initial Population" + +define "Denoninator Exclusion": + ["Encounter, Performed"] E where (duration in days of E.relevantPeriod) > 10 + +define "Numerator": + ["Encounter, Performed"] E where E.relevantPeriod starts during day of "Measurement Period" + +define function denomObs(Encounter "Encounter, Performed"): + duration in seconds of Encounter.relevantPeriod + +define function numerObs(Encounter "Encounter, Performed"): + duration in days of Encounter.relevantPeriod + +define "ipp": + exists ["Encounter, Performed"] E + +define "denom": + exists ["Encounter, Performed"] E + +define "num": + exists ["Encounter, Performed"] E + +define "IP2": + exists ["Encounter, Performed"] E`; diff --git a/src/components/editTestCase/groupCoverage/_mocks_/QdmMeasureCql.ts b/src/components/editTestCase/groupCoverage/_mocks_/QdmMeasureCql.ts index 87a1f4742..d8990546f 100644 --- a/src/components/editTestCase/groupCoverage/_mocks_/QdmMeasureCql.ts +++ b/src/components/editTestCase/groupCoverage/_mocks_/QdmMeasureCql.ts @@ -1,29 +1,34 @@ -export const measureCql = `library HighlightingQDM version '0.0.000' +export const measureCql = `library TestQDM version '0.0.000' using QDM version '5.6' -codesystem "Test": 'urn:oid:2.16.840.1.113883.6.1' -codesystem "LOINC": 'urn:oid:2.16.840.1.113883.6.1' - -valueset "Emergency Department Visit": 'urn:oid:2.16.840.1.113883.3.117.1.7.1.292' -valueset "Encounter Inpatient": 'urn:oid:2.16.840.1.113883.3.666.5.307' -valueset "Ethnicity": 'urn:oid:2.16.840.1.114222.4.11.837' -valueset "Observation Services": 'urn:oid:2.16.840.1.113762.1.4.1111.143' -valueset "ONC Administrative Sex": 'urn:oid:2.16.840.1.113762.1.4.1' -valueset "Payer": 'urn:oid:2.16.840.1.114222.4.11.3591' -valueset "Race": 'urn:oid:2.16.840.1.114222.4.11.836' -valueset "Active Bleeding or Bleeding Diathesis (Excluding Menses)": 'urn:oid:2.16.840.1.113883.3.3157.4036' -valueset "Active Peptic Ulcer": 'urn:oid:2.16.840.1.113883.3.3157.4031' -valueset "Adverse reaction to thrombolytics": 'urn:oid:2.16.840.1.113762.1.4.1170.6' -valueset "Allergy to thrombolytics": 'urn:oid:2.16.840.1.113762.1.4.1170.5' -valueset "Anticoagulant Medications, Oral": 'urn:oid:2.16.840.1.113883.3.3157.4045' -valueset "Aortic Dissection and Rupture": 'urn:oid:2.16.840.1.113883.3.3157.4028' -valueset "birth date": 'urn:oid:2.16.840.1.113883.3.560.100.4' -valueset "Cardiopulmonary Arrest": 'urn:oid:2.16.840.1.113883.3.3157.4048' -valueset "Cerebral Vascular Lesion": 'urn:oid:2.16.840.1.113883.3.3157.4025' -valueset "Closed Head and Facial Trauma": 'urn:oid:2.16.840.1.113883.3.3157.4026' -valueset "Dementia": 'urn:oid:2.16.840.1.113883.3.3157.4043' -valueset "Discharge To Acute Care Facility": 'urn:oid:2.16.840.1.113883.3.117.1.7.1.87' +include MATGlobalCommonFunctionsQDM version '1.0.000' called Global +codesystem "LOINC": 'urn:oid:2.16.840.1.113883.6.1' + +valueset "Acute care hospital Inpatient Encounter": 'urn:oid:2.16.840.1.113883.3.666.5.2289' +valueset "Bicarbonate lab test": 'urn:oid:2.16.840.1.113762.1.4.1045.139' +valueset "Body temperature": 'urn:oid:2.16.840.1.113762.1.4.1045.152' +valueset "Body weight": 'urn:oid:2.16.840.1.113762.1.4.1045.159' +valueset "Creatinine lab test": 'urn:oid:2.16.840.1.113883.3.666.5.2363' +valueset "Emergency Department Visit": 'urn:oid:2.16.840.1.113883.3.117.1.7.1.292' +valueset "Encounter Inpatient": 'urn:oid:2.16.840.1.113883.3.666.5.307' +valueset "Ethnicity": 'urn:oid:2.16.840.1.114222.4.11.837' +valueset "Glucose lab test": 'urn:oid:2.16.840.1.113762.1.4.1045.134' +valueset "Heart Rate": 'urn:oid:2.16.840.1.113762.1.4.1045.149' +valueset "Hematocrit lab test": 'urn:oid:2.16.840.1.113762.1.4.1045.114' +valueset "Medicare Advantage payer": 'urn:oid:2.16.840.1.113762.1.4.1104.12' +valueset "Medicare FFS payer": 'urn:oid:2.16.840.1.113762.1.4.1104.10' +valueset "Observation Services": 'urn:oid:2.16.840.1.113762.1.4.1111.143' +valueset "ONC Administrative Sex": 'urn:oid:2.16.840.1.113762.1.4.1' +valueset "Oxygen Saturation by Pulse Oximetry": 'urn:oid:2.16.840.1.113762.1.4.1045.151' +valueset "Payer": 'urn:oid:2.16.840.1.114222.4.11.3591' + +valueset "Potassium lab test": 'urn:oid:2.16.840.1.113762.1.4.1045.117' +valueset "Race": 'urn:oid:2.16.840.1.114222.4.11.836' +valueset "Respiratory Rate": 'urn:oid:2.16.840.1.113762.1.4.1045.130' +valueset "Sodium lab test": 'urn:oid:2.16.840.1.113762.1.4.1045.119' +valueset "Systolic Blood Pressure": 'urn:oid:2.16.840.1.113762.1.4.1045.163' +valueset "White blood cells count lab test": 'urn:oid:2.16.840.1.113762.1.4.1045.129' code "Birth date": '21112-8' from "LOINC" display 'Birth date' @@ -31,6 +36,16 @@ parameter "Measurement Period" Interval context Patient +define "Denominator": + "Initial Population" + +define "Initial Population": + "Inpatient Encounters" + + +define "Numerator": + "Initial Population" + define "SDE Ethnicity": ["Patient Characteristic Ethnicity": "Ethnicity"] @@ -43,35 +58,71 @@ define "SDE Race": define "SDE Sex": ["Patient Characteristic Sex": "ONC Administrative Sex"] - -define "Initial Population": - ["Encounter, Performed": "Emergency Department Visit"] //Encounter - union ["Encounter, Performed": "Closed Head and Facial Trauma"] //Encounter - union ["Encounter, Performed": "Dementia"] //Encounter - -define "Denominator": - "Initial Population" - -define "Denoninator Exclusion": - ["Encounter, Performed"] E where (duration in days of E.relevantPeriod) > 10 +define "SDE Results": + { + // First physical exams + FirstHeartRate: "FirstPhysicalExamWithEncounterId"(["Physical Exam, Performed": "Heart Rate"]), + FirstSystolicBloodPressure: "FirstPhysicalExamWithEncounterId"(["Physical Exam, Performed": "Systolic Blood Pressure"]), + FirstRespiratoryRate: "FirstPhysicalExamWithEncounterId"(["Physical Exam, Performed": "Respiratory Rate"]), + FirstBodyTemperature: "FirstPhysicalExamWithEncounterId"(["Physical Exam, Performed": "Body temperature"]), + FirstOxygenSaturation: "FirstPhysicalExamWithEncounterId"(["Physical Exam, Performed": "Oxygen Saturation by Pulse Oximetry"]), + // Weight uses lab test timing + FirstBodyWeight: "FirstPhysicalExamWithEncounterIdUsingLabTiming"(["Physical Exam, Performed": "Body weight"]), -define "Numerator": - ["Encounter, Performed"] E where E.relevantPeriod starts during day of "Measurement Period" + // First lab tests + FirstHematocritLab: "FirstLabTestWithEncounterId"(["Laboratory Test, Performed": "Hematocrit lab test"]), + FirstWhiteBloodCellCount: "FirstLabTestWithEncounterId"(["Laboratory Test, Performed": "White blood cells count lab test"]), + FirstPotassiumLab: "FirstLabTestWithEncounterId"(["Laboratory Test, Performed": "Potassium lab test"]), + FirstSodiumLab: "FirstLabTestWithEncounterId"(["Laboratory Test, Performed": "Sodium lab test"]), + FirstBicarbonateLab: "FirstLabTestWithEncounterId"(["Laboratory Test, Performed": "Bicarbonate lab test"]), + FirstCreatinineLab: "FirstLabTestWithEncounterId"(["Laboratory Test, Performed": "Creatinine lab test"]), + FirstGlucoseLab: "FirstLabTestWithEncounterId"(["Laboratory Test, Performed": "Glucose lab test"]) + } -define function denomObs(Encounter "Encounter, Performed"): - duration in seconds of Encounter.relevantPeriod - -define function numerObs(Encounter "Encounter, Performed"): - duration in days of Encounter.relevantPeriod - -define "ipp": - exists ["Encounter, Performed"] E +define "Inpatient Encounters": + ["Encounter, Performed": "Encounter Inpatient"] InpatientEncounter + with ( ["Patient Characteristic Payer": "Medicare FFS payer"] + union ["Patient Characteristic Payer": "Medicare Advantage payer"] ) Payer + such that Global."HospitalizationWithObservationLengthofStay" ( InpatientEncounter ) < 365 + and InpatientEncounter.relevantPeriod ends during day of "Measurement Period" + and AgeInYearsAt(date from start of InpatientEncounter.relevantPeriod)>= 65 + +define function "LengthOfStay"(Stay Interval ): + difference in days between start of Stay and + end of Stay + +define function "FirstPhysicalExamWithEncounterId"(ExamList List ): + "Inpatient Encounters" Encounter + let FirstExam: First(ExamList Exam + where Global."EarliestOf"(Exam.relevantDatetime, Exam.relevantPeriod)during Interval[start of Encounter.relevantPeriod - 1440 minutes, start of Encounter.relevantPeriod + 120 minutes] + sort by Global."EarliestOf"(relevantDatetime, relevantPeriod) + ) + return { + EncounterId: Encounter.id, + FirstResult: FirstExam.result as Quantity, + Timing: Global."EarliestOf" ( FirstExam.relevantDatetime, FirstExam.relevantPeriod ) + } -define "denom": - exists ["Encounter, Performed"] E - -define "num": - exists ["Encounter, Performed"] E +define function "FirstPhysicalExamWithEncounterIdUsingLabTiming"(ExamList List ): + "Inpatient Encounters" Encounter + let FirstExamWithLabTiming: First(ExamList Exam + where Global."EarliestOf"(Exam.relevantDatetime, Exam.relevantPeriod)during Interval[start of Encounter.relevantPeriod - 1440 minutes, start of Encounter.relevantPeriod + 1440 minutes] + sort by Global."EarliestOf"(relevantDatetime, relevantPeriod) + ) + return { + EncounterId: Encounter.id, + FirstResult: FirstExamWithLabTiming.result as Quantity, + Timing: Global."EarliestOf" ( FirstExamWithLabTiming.relevantDatetime, FirstExamWithLabTiming.relevantPeriod ) + } -define "IP2": - exists ["Encounter, Performed"] E`; +define function "FirstLabTestWithEncounterId"(LabList List ): + "Inpatient Encounters" Encounter + let FirstLab: First(LabList Lab + where Lab.resultDatetime during Interval[start of Encounter.relevantPeriod - 1440 minutes, start of Encounter.relevantPeriod + 1440 minutes] + sort by resultDatetime + ) + return { + EncounterId: Encounter.id, + FirstResult: FirstLab.result as Quantity, + Timing: FirstLab.resultDatetime + }`; diff --git a/src/components/editTestCase/qdm/EditTestCase.test.tsx b/src/components/editTestCase/qdm/EditTestCase.test.tsx index 805525586..9e5e6b334 100644 --- a/src/components/editTestCase/qdm/EditTestCase.test.tsx +++ b/src/components/editTestCase/qdm/EditTestCase.test.tsx @@ -412,7 +412,7 @@ const renderEditTestCaseComponent = () => { ); }; -describe("ElementsTab", () => { +describe.skip("ElementsTab", () => { useTestCaseServiceMock.mockImplementation(() => { return useTestCaseServiceMockResolved; }); @@ -458,7 +458,7 @@ describe("ElementsTab", () => { }); }); -test("LeftPanel navigation works as expected.", async () => { +test.skip("LeftPanel navigation works as expected.", async () => { CQMConversionMock.mockImplementation(() => { return useCqmConversionServiceMockResolved; }); @@ -487,7 +487,7 @@ test("LeftPanel navigation works as expected.", async () => { }); }); -describe("EditTestCase QDM Component", () => { +describe.skip("EditTestCase QDM Component", () => { const { getByRole, findByTestId, findByText } = screen; beforeEach(() => { diff --git a/src/components/editTestCase/qdm/RightPanel/calculationResults/CalculationResults.test.tsx b/src/components/editTestCase/qdm/RightPanel/calculationResults/CalculationResults.test.tsx index 4e823ca57..56394c8f1 100644 --- a/src/components/editTestCase/qdm/RightPanel/calculationResults/CalculationResults.test.tsx +++ b/src/components/editTestCase/qdm/RightPanel/calculationResults/CalculationResults.test.tsx @@ -4,6 +4,25 @@ import CalculationResults from "./CalculationResults"; import { GroupPopulation } from "@madie/madie-models"; import userEvent from "@testing-library/user-event"; import { measureCql } from "../../../groupCoverage/_mocks_/QdmMeasureCql"; +import { qdmCallStack } from "../../../groupCoverage/_mocks_/QdmCallStack"; +import { qdmCalculationResults } from "../../../groupCoverage/_mocks_/QdmCalculationResults"; +import useCqlParsingService, { + CqlParsingService, +} from "../../../../../api/useCqlParsingService"; + +jest.mock("@madie/madie-util", () => ({ + useOktaTokens: () => ({ + getAccessToken: () => "test.jwt", + }), +})); + +jest.mock("../../../../../api/useCqlParsingService"); +const useCqlParsingServiceMock = + useCqlParsingService as jest.Mock; + +const useCqlParsingServiceMockResolved = { + getAllDefinitionsAndFunctions: jest.fn().mockResolvedValue(qdmCallStack), +} as unknown as CqlParsingService; const groups = [ { @@ -151,7 +170,7 @@ const assertPopulationTabs = async () => { }; const renderCoverageComponent = ( - calculationResults = undefined, + calculationResults = { qdmCalculationResults }, calculationErrors = undefined ) => { render( @@ -166,8 +185,21 @@ const renderCoverageComponent = ( }; describe("CalculationResults with tabbed highlighting layout off", () => { + beforeEach(() => { + useCqlParsingServiceMock.mockImplementation(() => { + return useCqlParsingServiceMockResolved; + }); + }); test("display info message when test case has not been ran yet", () => { - renderCoverageComponent(); + render( + + ); expect( screen.getByText("To see the logic highlights, click 'Run Test'") ).toBeInTheDocument(); @@ -180,12 +212,17 @@ describe("CalculationResults with tabbed highlighting layout off", () => { }); describe("CalculationResults with new tabbed highlighting layout on", () => { + beforeEach(() => { + useCqlParsingServiceMock.mockImplementation(() => { + return useCqlParsingServiceMockResolved; + }); + }); test("highlighting tab if no groups available", () => { render( @@ -224,14 +261,14 @@ describe("CalculationResults with new tabbed highlighting layout on", () => { const denom = await getByRole("DENOM"); userEvent.click(denom); expect(screen.getByTestId("DENOM-highlighting")).toHaveTextContent( - `define "Initial Population": ["Encounter, Performed": "Emergency Department Visit"] //Encounter union ["Encounter, Performed": "Closed Head and Facial Trauma"] //Encounter union ["Encounter, Performed": "Dementia"]` + `Initial Population": "Inpatient Encounters` ); // switch to numerator tab const numer = await getByRole("NUMER"); userEvent.click(numer); expect(screen.getByTestId("NUMER-highlighting")).toHaveTextContent( - `define "Numerator": ["Encounter, Performed"] E where E.relevantPeriod starts during day of "Measurement Period"` + `define "Numerator": "Initial Population"` ); // select population criteria 2 diff --git a/src/components/testCaseLanding/qdm/TestCaseList.test.tsx b/src/components/testCaseLanding/qdm/TestCaseList.test.tsx index 002f4ab84..a23a115f1 100644 --- a/src/components/testCaseLanding/qdm/TestCaseList.test.tsx +++ b/src/components/testCaseLanding/qdm/TestCaseList.test.tsx @@ -44,7 +44,7 @@ import { ValueSet } from "cqm-models"; import qdmCalculationService, { QdmCalculationService, } from "../../../api/QdmCalculationService"; -import { measureCql } from "../../editTestCase/groupCoverage/_mocks_/QdmMeasureCql"; +import { measureCql } from "../../editTestCase/groupCoverage/_mocks_/QdmCovergaeMeasureCql"; const mockScanResult: ScanValidationDto = { fileName: "testcaseExample.json", From 4339e0da7c8c85e963884ef49e2f83d600342ef1 Mon Sep 17 00:00:00 2001 From: Prateek Keerthi Date: Sun, 3 Dec 2023 16:20:31 -0500 Subject: [PATCH 3/5] MAT-6006,6007,6008 added test cases --- .../groupCoverage/QdmGroupCoverage.tsx | 1 + .../editTestCase/qdm/EditTestCase.test.tsx | 28 +++++++++++++++++-- .../CalculationResults.test.tsx | 7 +++++ 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/components/editTestCase/groupCoverage/QdmGroupCoverage.tsx b/src/components/editTestCase/groupCoverage/QdmGroupCoverage.tsx index c4b6ad8d1..9bbf4ce93 100644 --- a/src/components/editTestCase/groupCoverage/QdmGroupCoverage.tsx +++ b/src/components/editTestCase/groupCoverage/QdmGroupCoverage.tsx @@ -223,6 +223,7 @@ const QdmGroupCoverage = ({ const changeCriteria = (criteriaId: string) => { setSelectedCriteria(criteriaId); + setSelectedAllDefinitions(null); const populationResults = getPopulationResults(criteriaId); setPopulationResults(populationResults); const group = testCaseGroups.find((gp) => gp.groupId === criteriaId); diff --git a/src/components/editTestCase/qdm/EditTestCase.test.tsx b/src/components/editTestCase/qdm/EditTestCase.test.tsx index 9e5e6b334..70726b310 100644 --- a/src/components/editTestCase/qdm/EditTestCase.test.tsx +++ b/src/components/editTestCase/qdm/EditTestCase.test.tsx @@ -36,6 +36,10 @@ import { MadieError } from "../../../util/Utils"; import qdmCalculationService, { QdmCalculationService, } from "../../../api/QdmCalculationService"; +import useCqlParsingService, { + CqlParsingService, +} from "../../../api/useCqlParsingService"; +import { qdmCallStack } from "../groupCoverage/_mocks_/QdmCallStack"; const serviceConfig = { testCaseService: { @@ -320,6 +324,14 @@ const qdmExecutionResults = { }, }; +jest.mock("../../../api/useCqlParsingService"); +const useCqlParsingServiceMock = + useCqlParsingService as jest.Mock; + +const useCqlParsingServiceMockResolved = { + getAllDefinitionsAndFunctions: jest.fn().mockResolvedValue(qdmCallStack), +} as unknown as CqlParsingService; + const mockProcessTestCaseResults = jest.fn().mockImplementation(() => { return { ...testCase, @@ -412,10 +424,13 @@ const renderEditTestCaseComponent = () => { ); }; -describe.skip("ElementsTab", () => { +describe("ElementsTab", () => { useTestCaseServiceMock.mockImplementation(() => { return useTestCaseServiceMockResolved; }); + useCqlParsingServiceMock.mockImplementation(() => { + return useCqlParsingServiceMockResolved; + }); test("Icons present and navigate correctly.", async () => { CQMConversionMock.mockImplementation(() => { @@ -458,10 +473,13 @@ describe.skip("ElementsTab", () => { }); }); -test.skip("LeftPanel navigation works as expected.", async () => { +test("LeftPanel navigation works as expected.", async () => { CQMConversionMock.mockImplementation(() => { return useCqmConversionServiceMockResolved; }); + useCqlParsingServiceMock.mockImplementation(() => { + return useCqlParsingServiceMockResolved; + }); await waitFor(() => renderEditTestCaseComponent()); const symptom = await findByTestId("elements-tab-symptom"); await waitFor(() => { @@ -487,7 +505,7 @@ test.skip("LeftPanel navigation works as expected.", async () => { }); }); -describe.skip("EditTestCase QDM Component", () => { +describe("EditTestCase QDM Component", () => { const { getByRole, findByTestId, findByText } = screen; beforeEach(() => { @@ -500,6 +518,10 @@ describe.skip("EditTestCase QDM Component", () => { CQMConversionMock.mockImplementation(() => { return useCqmConversionServiceMockResolved; }); + useCqlParsingServiceMock.mockImplementation(() => { + return useCqlParsingServiceMockResolved; + }); + (useFeatureFlags as jest.Mock).mockClear().mockImplementation(() => { return { applyDefaults: mockApplyDefaults, diff --git a/src/components/editTestCase/qdm/RightPanel/calculationResults/CalculationResults.test.tsx b/src/components/editTestCase/qdm/RightPanel/calculationResults/CalculationResults.test.tsx index 56394c8f1..b3fb59d8e 100644 --- a/src/components/editTestCase/qdm/RightPanel/calculationResults/CalculationResults.test.tsx +++ b/src/components/editTestCase/qdm/RightPanel/calculationResults/CalculationResults.test.tsx @@ -248,6 +248,9 @@ describe("CalculationResults with new tabbed highlighting layout on", () => { expect(await getByRole("IP 2")).toBeInTheDocument(); expect(await getByRole("DENOM")).toBeInTheDocument(); expect(await getByRole("NUMER")).toBeInTheDocument(); + expect(screen.getByText("Definitions")).toBeInTheDocument(); + expect(screen.getByText("Unused")).toBeInTheDocument(); + expect(screen.getByText("Functions")).toBeInTheDocument(); }); test("render highlighting view with coverage results for 2 groups", async () => { @@ -271,6 +274,10 @@ describe("CalculationResults with new tabbed highlighting layout on", () => { `define "Numerator": "Initial Population"` ); + const functions = await getByRole("Functions"); + userEvent.click(functions); + expect(screen.getAllByTestId("functions-highlighting")).toHaveLength(25); + // select population criteria 2 const criteriaOptions = await getCriteriaOptions(); userEvent.click(criteriaOptions[1]); From 05409c5d3cebab76fccbe4c1aee4bcde77f3ad84 Mon Sep 17 00:00:00 2001 From: Prateek Keerthi Date: Sun, 3 Dec 2023 17:13:32 -0500 Subject: [PATCH 4/5] MAT-6006,6007,6008 added scroll bars --- .../editTestCase/groupCoverage/QdmGroupCoverage.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/editTestCase/groupCoverage/QdmGroupCoverage.tsx b/src/components/editTestCase/groupCoverage/QdmGroupCoverage.tsx index 9bbf4ce93..f54f28579 100644 --- a/src/components/editTestCase/groupCoverage/QdmGroupCoverage.tsx +++ b/src/components/editTestCase/groupCoverage/QdmGroupCoverage.tsx @@ -309,7 +309,11 @@ const QdmGroupCoverage = ({ onChange={(e) => changeCriteria(e.target.value)} /> -
+
From 407cc78829cc1a997d2e5174b0877cb3025a48e9 Mon Sep 17 00:00:00 2001 From: Prateek Keerthi Date: Mon, 4 Dec 2023 12:03:09 -0500 Subject: [PATCH 5/5] MAT-6006,6007,6008 added test cases --- .../_mocks_/QDMCqlPopulationDefinitions.ts | 191 +++++ .../_mocks_/QdmCalculationResults.ts | 762 ++++++------------ .../CalculationResults.test.tsx | 34 + 3 files changed, 477 insertions(+), 510 deletions(-) create mode 100644 src/components/editTestCase/groupCoverage/_mocks_/QDMCqlPopulationDefinitions.ts diff --git a/src/components/editTestCase/groupCoverage/_mocks_/QDMCqlPopulationDefinitions.ts b/src/components/editTestCase/groupCoverage/_mocks_/QDMCqlPopulationDefinitions.ts new file mode 100644 index 000000000..097f12be6 --- /dev/null +++ b/src/components/editTestCase/groupCoverage/_mocks_/QDMCqlPopulationDefinitions.ts @@ -0,0 +1,191 @@ +export const qdmCqlPopulationsDefinitions = { + "64ef": { + populationDefinitions: { + initialPopulation: 'define "Denominator":\n "Initial Population"', + denominator: 'define "Denominator":\n "Initial Population"', + numerator: 'define "Numerator":\n "Initial Population"', + }, + functions: { + Latest: { + definitionLogic: + 'define function "Latest"(period Interval ):\n if ( HasEnd(period)) then \n end of period \n else start of period', + parentLibrary: "MATGlobalCommonFunctionsQDM", + }, + HospitalizationWithObservation: { + definitionLogic: + 'define function "HospitalizationWithObservation"(Encounter "Encounter, Performed" ):\n Encounter Visit\n \tlet ObsVisit: Last(["Encounter, Performed": "Observation Services"] LastObs\n \t\t\twhere LastObs.relevantPeriod ends 1 hour or less on or before start of Visit.relevantPeriod\n \t\t\tsort by \n \t\t\tend of relevantPeriod\n \t),\n \tVisitStart: Coalesce(start of ObsVisit.relevantPeriod, start of Visit.relevantPeriod),\n \tEDVisit: Last(["Encounter, Performed": "Emergency Department Visit"] LastED\n \t\t\twhere LastED.relevantPeriod ends 1 hour or less on or before VisitStart\n \t\t\tsort by \n \t\t\tend of relevantPeriod\n \t)\n \treturn Interval[Coalesce(start of EDVisit.relevantPeriod, VisitStart), \n \tend of Visit.relevantPeriod]', + parentLibrary: "MATGlobalCommonFunctionsQDM", + }, + ToDateInterval: { + definitionLogic: + 'define function "ToDateInterval"(period Interval ):\n Interval[date from start of period, date from end of period]', + parentLibrary: "MATGlobalCommonFunctionsQDM", + }, + HasEnd: { + definitionLogic: + 'define function "HasEnd"(period Interval ):\n not ( \n end of period is null\n or \n end of period = maximum DateTime\n )', + parentLibrary: "MATGlobalCommonFunctionsQDM", + }, + HospitalArrivalTime: { + definitionLogic: + 'define function "HospitalArrivalTime"(Encounter "Encounter, Performed" ):\n start of First(("HospitalizationLocations"(Encounter))HospitalLocation\n \t\tsort by start of locationPeriod\n ).locationPeriod', + parentLibrary: "MATGlobalCommonFunctionsQDM", + }, + HospitalAdmissionTime: { + definitionLogic: + 'define function "HospitalAdmissionTime"(Encounter "Encounter, Performed" ):\n start of "Hospitalization"(Encounter)', + parentLibrary: "MATGlobalCommonFunctionsQDM", + }, + HospitalDischargeTime: { + definitionLogic: + 'define function "HospitalDischargeTime"(Encounter "Encounter, Performed" ):\n end of Encounter.relevantPeriod', + parentLibrary: "MATGlobalCommonFunctionsQDM", + }, + HospitalizationWithObservationAndOutpatientSurgeryService: { + definitionLogic: + 'define function "HospitalizationWithObservationAndOutpatientSurgeryService"(Encounter "Encounter, Performed" ):\n Encounter Visit\n \tlet ObsVisit: Last(["Encounter, Performed": "Observation Services"] LastObs\n \t\t\twhere LastObs.relevantPeriod ends 1 hour or less on or before start of Visit.relevantPeriod\n \t\t\tsort by \n \t\t\tend of relevantPeriod\n \t),\n \tVisitStart: Coalesce(start of ObsVisit.relevantPeriod, start of Visit.relevantPeriod),\n \tEDVisit: Last(["Encounter, Performed": "Emergency Department Visit"] LastED\n \t\t\twhere LastED.relevantPeriod ends 1 hour or less on or before VisitStart\n \t\t\tsort by \n \t\t\tend of relevantPeriod\n \t),\n \tVisitStartWithED: Coalesce(start of EDVisit.relevantPeriod, VisitStart),\n \tOutpatientSurgeryVisit: Last(["Encounter, Performed": "Outpatient Surgery Service"] LastSurgeryOP\n \t\t\twhere LastSurgeryOP.relevantPeriod ends 1 hour or less on or before VisitStartWithED\n \t\t\tsort by \n \t\t\tend of relevantPeriod\n \t)\n \treturn Interval[Coalesce(start of OutpatientSurgeryVisit.relevantPeriod, VisitStartWithED), \n \tend of Visit.relevantPeriod]', + parentLibrary: "MATGlobalCommonFunctionsQDM", + }, + HospitalizationWithObservationLengthofStay: { + definitionLogic: + 'define function "HospitalizationWithObservationLengthofStay"(Encounter "Encounter, Performed" ):\n "LengthInDays"("HospitalizationWithObservation"(Encounter))', + parentLibrary: "MATGlobalCommonFunctionsQDM", + }, + HospitalDepartureTime: { + definitionLogic: + 'define function "HospitalDepartureTime"(Encounter "Encounter, Performed" ):\n end of Last(("HospitalizationLocations"(Encounter))HospitalLocation\n \t\tsort by start of locationPeriod\n ).locationPeriod', + parentLibrary: "MATGlobalCommonFunctionsQDM", + }, + EarliestOf: { + definitionLogic: + 'define function "EarliestOf"(pointInTime DateTime, period Interval ):\n Earliest(NormalizeInterval(pointInTime, period))', + parentLibrary: "MATGlobalCommonFunctionsQDM", + }, + Earliest: { + definitionLogic: + 'define function "Earliest"(period Interval ):\n if ( HasStart(period)) then start of period \n else \n end of period', + parentLibrary: "MATGlobalCommonFunctionsQDM", + }, + LengthOfStay: { + definitionLogic: + 'define function "LengthOfStay"(Stay Interval ):\n difference in days between start of Stay and \n end of Stay', + parentLibrary: null, + }, + LengthInDays: { + definitionLogic: + 'define function "LengthInDays"(Value Interval ):\n difference in days between start of Value and end of Value', + parentLibrary: "MATGlobalCommonFunctionsQDM", + }, + NormalizeInterval: { + definitionLogic: + 'define function "NormalizeInterval"(pointInTime DateTime, period Interval ):\n if pointInTime is not null then Interval[pointInTime, pointInTime]\n else if period is not null then period \n else null as Interval', + parentLibrary: "MATGlobalCommonFunctionsQDM", + }, + FirstInpatientIntensiveCareUnit: { + definitionLogic: + 'define function "FirstInpatientIntensiveCareUnit"(Encounter "Encounter, Performed" ):\n First((Encounter.facilityLocations)HospitalLocation\n where HospitalLocation.code in "Intensive Care Unit"\n and HospitalLocation.locationPeriod during Encounter.relevantPeriod\n sort by start of locationPeriod\n )', + parentLibrary: "MATGlobalCommonFunctionsQDM", + }, + Hospitalization: { + definitionLogic: + 'define function "Hospitalization"(Encounter "Encounter, Performed" ):\n Encounter Visit\n \tlet EDVisit: Last(["Encounter, Performed": "Emergency Department Visit"] LastED\n \t\t\twhere LastED.relevantPeriod ends 1 hour or less on or before start of Visit.relevantPeriod\n \t\t\tsort by \n \t\t\tend of relevantPeriod\n \t)\n \treturn Interval[Coalesce(start of EDVisit.relevantPeriod, start of Visit.relevantPeriod), \n \tend of Visit.relevantPeriod]', + parentLibrary: "MATGlobalCommonFunctionsQDM", + }, + HospitalizationLengthofStay: { + definitionLogic: + 'define function "HospitalizationLengthofStay"(Encounter "Encounter, Performed" ):\n LengthInDays("Hospitalization"(Encounter))', + parentLibrary: "MATGlobalCommonFunctionsQDM", + }, + HasStart: { + definitionLogic: + 'define function "HasStart"(period Interval ):\n not ( start of period is null\n or start of period = minimum DateTime\n )', + parentLibrary: "MATGlobalCommonFunctionsQDM", + }, + LatestOf: { + definitionLogic: + 'define function "LatestOf"(pointInTime DateTime, period Interval ):\n Latest(NormalizeInterval(pointInTime, period))', + parentLibrary: "MATGlobalCommonFunctionsQDM", + }, + FirstPhysicalExamWithEncounterId: { + definitionLogic: + 'define function "FirstPhysicalExamWithEncounterId"(ExamList List ):\n "Inpatient Encounters" Encounter\n let FirstExam: First(ExamList Exam\n where Global."EarliestOf"(Exam.relevantDatetime, Exam.relevantPeriod)during Interval[start of Encounter.relevantPeriod - 1440 minutes, start of Encounter.relevantPeriod + 120 minutes]\n sort by Global."EarliestOf"(relevantDatetime, relevantPeriod)\n )\n return {\n EncounterId: Encounter.id,\n FirstResult: FirstExam.result as Quantity,\n Timing: Global."EarliestOf" ( FirstExam.relevantDatetime, FirstExam.relevantPeriod )\n }', + parentLibrary: null, + }, + FirstLabTestWithEncounterId: { + definitionLogic: + 'define function "FirstLabTestWithEncounterId"(LabList List ):\n "Inpatient Encounters" Encounter\n let FirstLab: First(LabList Lab\n where Lab.resultDatetime during Interval[start of Encounter.relevantPeriod - 1440 minutes, start of Encounter.relevantPeriod + 1440 minutes]\n sort by resultDatetime\n )\n return {\n EncounterId: Encounter.id,\n FirstResult: FirstLab.result as Quantity,\n Timing: FirstLab.resultDatetime\n }', + parentLibrary: null, + }, + HospitalizationLocations: { + definitionLogic: + 'define function "HospitalizationLocations"(Encounter "Encounter, Performed" ):\n Encounter Visit\n \tlet EDVisit: Last(["Encounter, Performed": "Emergency Department Visit"] LastED\n \t\t\twhere LastED.relevantPeriod ends 1 hour or less on or before start of Visit.relevantPeriod\n \t\t\tsort by \n \t\t\tend of relevantPeriod\n \t)\n \treturn if EDVisit is null then Visit.facilityLocations \n \t\telse flatten { EDVisit.facilityLocations, Visit.facilityLocations }', + parentLibrary: "MATGlobalCommonFunctionsQDM", + }, + EmergencyDepartmentArrivalTime: { + definitionLogic: + 'define function "EmergencyDepartmentArrivalTime"(Encounter "Encounter, Performed" ):\n start of First(("HospitalizationLocations"(Encounter))HospitalLocation\n \t\twhere HospitalLocation.code in "Emergency Department Visit"\n \t\tsort by start of locationPeriod\n ).locationPeriod', + parentLibrary: "MATGlobalCommonFunctionsQDM", + }, + FirstPhysicalExamWithEncounterIdUsingLabTiming: { + definitionLogic: + 'define function "FirstPhysicalExamWithEncounterIdUsingLabTiming"(ExamList List ):\n "Inpatient Encounters" Encounter\n let FirstExamWithLabTiming: First(ExamList Exam\n where Global."EarliestOf"(Exam.relevantDatetime, Exam.relevantPeriod)during Interval[start of Encounter.relevantPeriod - 1440 minutes, start of Encounter.relevantPeriod + 1440 minutes]\n sort by Global."EarliestOf"(relevantDatetime, relevantPeriod)\n )\n return {\n EncounterId: Encounter.id,\n FirstResult: FirstExamWithLabTiming.result as Quantity,\n Timing: Global."EarliestOf" ( FirstExamWithLabTiming.relevantDatetime, FirstExamWithLabTiming.relevantPeriod )\n }', + parentLibrary: null, + }, + }, + definitions: { + Denominator: { + definitionLogic: 'define "Denominator":\n "Initial Population"', + parentLibrary: null, + }, + "Inpatient Encounters": { + definitionLogic: + 'define "Inpatient Encounters":\n ["Encounter, Performed": "Encounter Inpatient"] InpatientEncounter\n with ( ["Patient Characteristic Payer": "Medicare FFS payer"]\n union ["Patient Characteristic Payer": "Medicare Advantage payer"] ) Payer\n such that Global."HospitalizationWithObservationLengthofStay" ( InpatientEncounter ) < 365\n and InpatientEncounter.relevantPeriod ends during day of "Measurement Period"\n and AgeInYearsAt(date from start of InpatientEncounter.relevantPeriod)>= 65', + parentLibrary: null, + }, + "SDE Results": { + definitionLogic: + 'define "SDE Results":\n {\n // First physical exams\n FirstHeartRate: "FirstPhysicalExamWithEncounterId"(["Physical Exam, Performed": "Heart Rate"]),\n FirstSystolicBloodPressure: "FirstPhysicalExamWithEncounterId"(["Physical Exam, Performed": "Systolic Blood Pressure"]),\n FirstRespiratoryRate: "FirstPhysicalExamWithEncounterId"(["Physical Exam, Performed": "Respiratory Rate"]),\n FirstBodyTemperature: "FirstPhysicalExamWithEncounterId"(["Physical Exam, Performed": "Body temperature"]),\n FirstOxygenSaturation: "FirstPhysicalExamWithEncounterId"(["Physical Exam, Performed": "Oxygen Saturation by Pulse Oximetry"]),\n // Weight uses lab test timing\n FirstBodyWeight: "FirstPhysicalExamWithEncounterIdUsingLabTiming"(["Physical Exam, Performed": "Body weight"]),\n \n // First lab tests\n FirstHematocritLab: "FirstLabTestWithEncounterId"(["Laboratory Test, Performed": "Hematocrit lab test"]),\n FirstWhiteBloodCellCount: "FirstLabTestWithEncounterId"(["Laboratory Test, Performed": "White blood cells count lab test"]),\n FirstPotassiumLab: "FirstLabTestWithEncounterId"(["Laboratory Test, Performed": "Potassium lab test"]),\n FirstSodiumLab: "FirstLabTestWithEncounterId"(["Laboratory Test, Performed": "Sodium lab test"]),\n FirstBicarbonateLab: "FirstLabTestWithEncounterId"(["Laboratory Test, Performed": "Bicarbonate lab test"]),\n FirstCreatinineLab: "FirstLabTestWithEncounterId"(["Laboratory Test, Performed": "Creatinine lab test"]),\n FirstGlucoseLab: "FirstLabTestWithEncounterId"(["Laboratory Test, Performed": "Glucose lab test"])\n }', + parentLibrary: null, + }, + "SDE Ethnicity": { + definitionLogic: + 'define "SDE Ethnicity":\n ["Patient Characteristic Ethnicity": "Ethnicity"]', + parentLibrary: null, + }, + "SDE Sex": { + definitionLogic: + 'define "SDE Sex":\n ["Patient Characteristic Sex": "ONC Administrative Sex"]', + parentLibrary: null, + }, + "SDE Race": { + definitionLogic: + 'define "SDE Race":\n ["Patient Characteristic Race": "Race"]', + parentLibrary: null, + }, + "ED Encounter": { + definitionLogic: + 'define "ED Encounter":\n ["Encounter, Performed": "Emergency Department Visit"]', + parentLibrary: "MATGlobalCommonFunctionsQDM", + }, + "Inpatient Encounter": { + definitionLogic: + 'define "Inpatient Encounter":\n ["Encounter, Performed": "Encounter Inpatient"] EncounterInpatient\n where "LengthInDays"(EncounterInpatient.relevantPeriod)<= 120\n and EncounterInpatient.relevantPeriod ends during day of "Measurement Period"', + parentLibrary: "MATGlobalCommonFunctionsQDM", + }, + "Initial Population": { + definitionLogic: + 'define "Initial Population":\n "Inpatient Encounters"', + parentLibrary: null, + }, + "SDE Payer": { + definitionLogic: + 'define "SDE Payer":\n ["Patient Characteristic Payer": "Payer"]', + parentLibrary: null, + }, + Numerator: { + definitionLogic: 'define "Numerator":\n "Initial Population"', + parentLibrary: null, + }, + }, + }, +}; diff --git a/src/components/editTestCase/groupCoverage/_mocks_/QdmCalculationResults.ts b/src/components/editTestCase/groupCoverage/_mocks_/QdmCalculationResults.ts index e77f3eeb5..98d29de79 100644 --- a/src/components/editTestCase/groupCoverage/_mocks_/QdmCalculationResults.ts +++ b/src/components/editTestCase/groupCoverage/_mocks_/QdmCalculationResults.ts @@ -1,522 +1,264 @@ export const qdmCalculationResults = { - "655e12db1069370e9cde2f80": { - IPP: 0, - DENOM: 0, - DENEX: 0, - NUMER: 0, - NUMEX: 0, - DENEXCEP: 0, - episode_results: {}, - statement_relevance: { - MATGlobalCommonFunctionsQDM: { - HospitalizationWithObservationLengthofStay: "TRUE", - LengthInDays: "TRUE", - HospitalizationWithObservation: "TRUE", - EarliestOf: "NA", - Earliest: "NA", - HasStart: "NA", - NormalizeInterval: "NA", - }, - TestQDM: { - Patient: "TRUE", - "Inpatient Encounters": "TRUE", - "Initial Population": "TRUE", - Denominator: "FALSE", - Numerator: "FALSE", - "SDE Ethnicity": "NA", - "SDE Payer": "NA", - "SDE Race": "NA", - "SDE Sex": "NA", - FirstPhysicalExamWithEncounterId: "NA", - FirstPhysicalExamWithEncounterIdUsingLabTiming: "NA", - FirstLabTestWithEncounterId: "NA", - "SDE Results": "NA", - LengthOfStay: "NA", - }, - }, - population_relevance: { - IPP: true, - DENOM: false, - DENEX: false, - NUMER: false, - NUMEX: false, - DENEXCEP: false, - }, - statement_results: { - MATGlobalCommonFunctionsQDM: { - HospitalizationWithObservationLengthofStay: { - library_name: "MATGlobalCommonFunctionsQDM", - statement_name: "HospitalizationWithObservationLengthofStay", - relevance: "TRUE", - final: "UNHIT", - }, - LengthInDays: { - library_name: "MATGlobalCommonFunctionsQDM", - statement_name: "LengthInDays", - relevance: "TRUE", - final: "UNHIT", - }, - HospitalizationWithObservation: { - library_name: "MATGlobalCommonFunctionsQDM", - statement_name: "HospitalizationWithObservation", - relevance: "TRUE", - final: "UNHIT", - }, - EarliestOf: { - library_name: "MATGlobalCommonFunctionsQDM", - statement_name: "EarliestOf", - relevance: "NA", - final: "NA", - }, - Earliest: { - library_name: "MATGlobalCommonFunctionsQDM", - statement_name: "Earliest", - relevance: "NA", - final: "NA", - }, - HasStart: { - library_name: "MATGlobalCommonFunctionsQDM", - statement_name: "HasStart", - relevance: "NA", - final: "NA", - }, - NormalizeInterval: { - library_name: "MATGlobalCommonFunctionsQDM", - statement_name: "NormalizeInterval", - relevance: "NA", - final: "NA", - }, - }, - TestQDM: { - Patient: { - library_name: "TestQDM", - statement_name: "Patient", - relevance: "TRUE", - final: "FALSE", - }, - "Inpatient Encounters": { - raw: [], - library_name: "TestQDM", - statement_name: "Inpatient Encounters", - relevance: "TRUE", - final: "FALSE", - }, - "Initial Population": { - raw: [], - library_name: "TestQDM", - statement_name: "Initial Population", - relevance: "TRUE", - final: "FALSE", - }, - Denominator: { - raw: [], - library_name: "TestQDM", - statement_name: "Denominator", - relevance: "FALSE", - final: "UNHIT", - }, - Numerator: { - raw: [], - library_name: "TestQDM", - statement_name: "Numerator", - relevance: "FALSE", - final: "UNHIT", - }, - "SDE Ethnicity": { - raw: [ - { - dataElementCodes: [ - { - code: "2135-2", - system: "2.16.840.1.113883.6.238", - version: "1.2", - display: "Hispanic or Latino", - }, - ], - _id: "656a0995c2da020000043b76", - qdmTitle: "Patient Characteristic Ethnicity", - hqmfOid: "2.16.840.1.113883.10.20.28.4.56", - qdmCategory: "patient_characteristic", - qdmStatus: "ethnicity", - qdmVersion: "5.6", - _type: "QDM::PatientCharacteristicEthnicity", - id: "656a0995c2da020000043b76", - }, - ], - library_name: "TestQDM", - statement_name: "SDE Ethnicity", - relevance: "NA", - final: "NA", - }, - "SDE Payer": { - raw: [], - library_name: "TestQDM", - statement_name: "SDE Payer", - relevance: "NA", - final: "NA", - }, - "SDE Race": { - raw: [ - { - dataElementCodes: [ - { - code: "2028-9", - system: "2.16.840.1.113883.6.238", - version: "1.2", - display: "Asian", - }, - ], - _id: "656a0992c2da020000043b72", - qdmTitle: "Patient Characteristic Race", - hqmfOid: "2.16.840.1.113883.10.20.28.4.59", - qdmCategory: "patient_characteristic", - qdmStatus: "race", - qdmVersion: "5.6", - _type: "QDM::PatientCharacteristicRace", - id: "656a0992c2da020000043b72", - }, - ], - library_name: "TestQDM", - statement_name: "SDE Race", - relevance: "NA", - final: "NA", - }, - "SDE Sex": { - raw: [ - { - dataElementCodes: [ - { - code: "M", - system: "2.16.840.1.113883.5.1", - version: "2022-11", - display: "Male", - }, - ], - _id: "656a0993c2da020000043b74", - qdmTitle: "Patient Characteristic Sex", - hqmfOid: "2.16.840.1.113883.10.20.28.4.55", - qdmCategory: "patient_characteristic", - qdmStatus: "gender", - qdmVersion: "5.6", - _type: "QDM::PatientCharacteristicSex", - id: "656a0993c2da020000043b74", - }, - ], - library_name: "TestQDM", - statement_name: "SDE Sex", - relevance: "NA", - final: "NA", - }, - FirstPhysicalExamWithEncounterId: { - library_name: "TestQDM", - statement_name: "FirstPhysicalExamWithEncounterId", - relevance: "NA", - final: "NA", - }, - FirstPhysicalExamWithEncounterIdUsingLabTiming: { - library_name: "TestQDM", - statement_name: "FirstPhysicalExamWithEncounterIdUsingLabTiming", - relevance: "NA", - final: "NA", - }, - FirstLabTestWithEncounterId: { - library_name: "TestQDM", - statement_name: "FirstLabTestWithEncounterId", - relevance: "NA", - final: "NA", - }, - "SDE Results": { - raw: { - FirstHeartRate: [], - FirstSystolicBloodPressure: [], - FirstRespiratoryRate: [], - FirstBodyTemperature: [], - FirstOxygenSaturation: [], - FirstBodyWeight: [], - FirstHematocritLab: [], - FirstWhiteBloodCellCount: [], - FirstPotassiumLab: [], - FirstSodiumLab: [], - FirstBicarbonateLab: [], - FirstCreatinineLab: [], - FirstGlucoseLab: [], - }, - library_name: "TestQDM", - statement_name: "SDE Results", - relevance: "NA", - final: "NA", - }, - LengthOfStay: { - library_name: "TestQDM", - statement_name: "LengthOfStay", - relevance: "NA", - final: "NA", + "656a098cc2da020000043b67": { + "64ef": { + IPP: 0, + DENOM: 0, + DENEX: 0, + NUMER: 0, + NUMEX: 0, + DENEXCEP: 0, + episode_results: {}, + statement_relevance: { + MATGlobalCommonFunctionsQDM: { + HospitalizationWithObservationLengthofStay: "TRUE", + LengthInDays: "TRUE", + HospitalizationWithObservation: "TRUE", + EarliestOf: "NA", + Earliest: "NA", + HasStart: "NA", + NormalizeInterval: "NA", + }, + TestQDM: { + Patient: "TRUE", + "Inpatient Encounters": "TRUE", + "Initial Population": "TRUE", + Denominator: "TRUE", + Numerator: "FALSE", + "SDE Ethnicity": "NA", + "SDE Payer": "NA", + "SDE Race": "NA", + "SDE Sex": "NA", + FirstPhysicalExamWithEncounterId: "NA", + FirstPhysicalExamWithEncounterIdUsingLabTiming: "NA", + FirstLabTestWithEncounterId: "NA", + "SDE Results": "NA", + LengthOfStay: "NA", }, }, - }, - clause_results: null, - patient: "656a098cc2da020000043b67", - measure: "656cd2e13761fb000092d358", - state: "complete", - }, - "656a08a29803a260d239a924": { - IPP: 0, - DENOM: 0, - DENEX: 0, - NUMER: 0, - NUMEX: 0, - DENEXCEP: 0, - episode_results: {}, - statement_relevance: { - MATGlobalCommonFunctionsQDM: { - HospitalizationWithObservationLengthofStay: "TRUE", - LengthInDays: "TRUE", - HospitalizationWithObservation: "TRUE", - EarliestOf: "NA", - Earliest: "NA", - HasStart: "NA", - NormalizeInterval: "NA", - }, - TestQDM: { - Patient: "TRUE", - "Inpatient Encounters": "TRUE", - "Initial Population": "TRUE", - Denominator: "TRUE", - Numerator: "FALSE", - "SDE Ethnicity": "NA", - "SDE Payer": "NA", - "SDE Race": "NA", - "SDE Sex": "NA", - FirstPhysicalExamWithEncounterId: "NA", - FirstPhysicalExamWithEncounterIdUsingLabTiming: "NA", - FirstLabTestWithEncounterId: "NA", - "SDE Results": "NA", - LengthOfStay: "NA", - }, - }, - population_relevance: { - IPP: true, - DENOM: false, - DENEX: false, - NUMER: false, - NUMEX: false, - DENEXCEP: false, - }, - statement_results: { - MATGlobalCommonFunctionsQDM: { - HospitalizationWithObservationLengthofStay: { - library_name: "MATGlobalCommonFunctionsQDM", - statement_name: "HospitalizationWithObservationLengthofStay", - relevance: "TRUE", - final: "UNHIT", - }, - LengthInDays: { - library_name: "MATGlobalCommonFunctionsQDM", - statement_name: "LengthInDays", - relevance: "TRUE", - final: "UNHIT", - }, - HospitalizationWithObservation: { - library_name: "MATGlobalCommonFunctionsQDM", - statement_name: "HospitalizationWithObservation", - relevance: "TRUE", - final: "UNHIT", - }, - EarliestOf: { - library_name: "MATGlobalCommonFunctionsQDM", - statement_name: "EarliestOf", - relevance: "NA", - final: "NA", - }, - Earliest: { - library_name: "MATGlobalCommonFunctionsQDM", - statement_name: "Earliest", - relevance: "NA", - final: "NA", - }, - HasStart: { - library_name: "MATGlobalCommonFunctionsQDM", - statement_name: "HasStart", - relevance: "NA", - final: "NA", - }, - NormalizeInterval: { - library_name: "MATGlobalCommonFunctionsQDM", - statement_name: "NormalizeInterval", - relevance: "NA", - final: "NA", - }, + population_relevance: { + IPP: true, + DENOM: false, + DENEX: false, + NUMER: false, + NUMEX: false, + DENEXCEP: false, }, - TestQDM: { - Patient: { - library_name: "TestQDM", - statement_name: "Patient", - relevance: "TRUE", - final: "FALSE", - }, - "Inpatient Encounters": { - raw: [], - library_name: "TestQDM", - statement_name: "Inpatient Encounters", - relevance: "TRUE", - final: "FALSE", - }, - "Initial Population": { - raw: [], - library_name: "TestQDM", - statement_name: "Initial Population", - relevance: "TRUE", - final: "FALSE", - }, - Denominator: { - raw: [], - library_name: "TestQDM", - statement_name: "Denominator", - relevance: "TRUE", - final: "FALSE", - }, - Numerator: { - raw: [], - library_name: "TestQDM", - statement_name: "Numerator", - relevance: "FALSE", - final: "UNHIT", - }, - "SDE Ethnicity": { - raw: [ - { - dataElementCodes: [ - { - code: "2135-2", - system: "2.16.840.1.113883.6.238", - version: "1.2", - display: "Hispanic or Latino", - }, - ], - _id: "656a0995c2da020000043b76", - qdmTitle: "Patient Characteristic Ethnicity", - hqmfOid: "2.16.840.1.113883.10.20.28.4.56", - qdmCategory: "patient_characteristic", - qdmStatus: "ethnicity", - qdmVersion: "5.6", - _type: "QDM::PatientCharacteristicEthnicity", - id: "656a0995c2da020000043b76", - }, - ], - library_name: "TestQDM", - statement_name: "SDE Ethnicity", - relevance: "NA", - final: "NA", - }, - "SDE Payer": { - raw: [], - library_name: "TestQDM", - statement_name: "SDE Payer", - relevance: "NA", - final: "NA", - }, - "SDE Race": { - raw: [ - { - dataElementCodes: [ - { - code: "2028-9", - system: "2.16.840.1.113883.6.238", - version: "1.2", - display: "Asian", - }, - ], - _id: "656a0992c2da020000043b72", - qdmTitle: "Patient Characteristic Race", - hqmfOid: "2.16.840.1.113883.10.20.28.4.59", - qdmCategory: "patient_characteristic", - qdmStatus: "race", - qdmVersion: "5.6", - _type: "QDM::PatientCharacteristicRace", - id: "656a0992c2da020000043b72", - }, - ], - library_name: "TestQDM", - statement_name: "SDE Race", - relevance: "NA", - final: "NA", + statement_results: { + MATGlobalCommonFunctionsQDM: { + HospitalizationWithObservationLengthofStay: { + library_name: "MATGlobalCommonFunctionsQDM", + statement_name: "HospitalizationWithObservationLengthofStay", + relevance: "TRUE", + final: "UNHIT", + }, + LengthInDays: { + library_name: "MATGlobalCommonFunctionsQDM", + statement_name: "LengthInDays", + relevance: "TRUE", + final: "UNHIT", + }, + HospitalizationWithObservation: { + library_name: "MATGlobalCommonFunctionsQDM", + statement_name: "HospitalizationWithObservation", + relevance: "TRUE", + final: "UNHIT", + }, + EarliestOf: { + library_name: "MATGlobalCommonFunctionsQDM", + statement_name: "EarliestOf", + relevance: "NA", + final: "NA", + }, + Earliest: { + library_name: "MATGlobalCommonFunctionsQDM", + statement_name: "Earliest", + relevance: "NA", + final: "NA", + }, + HasStart: { + library_name: "MATGlobalCommonFunctionsQDM", + statement_name: "HasStart", + relevance: "NA", + final: "NA", + }, + NormalizeInterval: { + library_name: "MATGlobalCommonFunctionsQDM", + statement_name: "NormalizeInterval", + relevance: "NA", + final: "NA", + }, }, - "SDE Sex": { - raw: [ - { - dataElementCodes: [ - { - code: "M", - system: "2.16.840.1.113883.5.1", - version: "2022-11", - display: "Male", - }, - ], - _id: "656a0993c2da020000043b74", - qdmTitle: "Patient Characteristic Sex", - hqmfOid: "2.16.840.1.113883.10.20.28.4.55", - qdmCategory: "patient_characteristic", - qdmStatus: "gender", - qdmVersion: "5.6", - _type: "QDM::PatientCharacteristicSex", - id: "656a0993c2da020000043b74", + TestQDM: { + Patient: { + library_name: "TestQDM", + statement_name: "Patient", + relevance: "TRUE", + final: "FALSE", + }, + "Inpatient Encounters": { + raw: [], + library_name: "TestQDM", + statement_name: "Inpatient Encounters", + relevance: "TRUE", + final: "FALSE", + }, + "Initial Population": { + raw: [], + library_name: "TestQDM", + statement_name: "Initial Population", + relevance: "TRUE", + final: "FALSE", + }, + Denominator: { + raw: [], + library_name: "TestQDM", + statement_name: "Denominator", + relevance: "TRUE", + final: "FALSE", + }, + Numerator: { + raw: [], + library_name: "TestQDM", + statement_name: "Numerator", + relevance: "FALSE", + final: "UNHIT", + }, + "SDE Ethnicity": { + raw: [ + { + dataElementCodes: [ + { + code: "2135-2", + system: "2.16.840.1.113883.6.238", + version: "1.2", + display: "Hispanic or Latino", + }, + ], + _id: "656a0995c2da020000043b76", + qdmTitle: "Patient Characteristic Ethnicity", + hqmfOid: "2.16.840.1.113883.10.20.28.4.56", + qdmCategory: "patient_characteristic", + qdmStatus: "ethnicity", + qdmVersion: "5.6", + _type: "QDM::PatientCharacteristicEthnicity", + id: "656a0995c2da020000043b76", + }, + ], + library_name: "TestQDM", + statement_name: "SDE Ethnicity", + relevance: "NA", + final: "NA", + }, + "SDE Payer": { + raw: [], + library_name: "TestQDM", + statement_name: "SDE Payer", + relevance: "NA", + final: "NA", + }, + "SDE Race": { + raw: [ + { + dataElementCodes: [ + { + code: "2028-9", + system: "2.16.840.1.113883.6.238", + version: "1.2", + display: "Asian", + }, + ], + _id: "656a0992c2da020000043b72", + qdmTitle: "Patient Characteristic Race", + hqmfOid: "2.16.840.1.113883.10.20.28.4.59", + qdmCategory: "patient_characteristic", + qdmStatus: "race", + qdmVersion: "5.6", + _type: "QDM::PatientCharacteristicRace", + id: "656a0992c2da020000043b72", + }, + ], + library_name: "TestQDM", + statement_name: "SDE Race", + relevance: "NA", + final: "NA", + }, + "SDE Sex": { + raw: [ + { + dataElementCodes: [ + { + code: "M", + system: "2.16.840.1.113883.5.1", + version: "2022-11", + display: "Male", + }, + ], + _id: "656a0993c2da020000043b74", + qdmTitle: "Patient Characteristic Sex", + hqmfOid: "2.16.840.1.113883.10.20.28.4.55", + qdmCategory: "patient_characteristic", + qdmStatus: "gender", + qdmVersion: "5.6", + _type: "QDM::PatientCharacteristicSex", + id: "656a0993c2da020000043b74", + }, + ], + library_name: "TestQDM", + statement_name: "SDE Sex", + relevance: "NA", + final: "NA", + }, + FirstPhysicalExamWithEncounterId: { + library_name: "TestQDM", + statement_name: "FirstPhysicalExamWithEncounterId", + relevance: "NA", + final: "NA", + }, + FirstPhysicalExamWithEncounterIdUsingLabTiming: { + library_name: "TestQDM", + statement_name: "FirstPhysicalExamWithEncounterIdUsingLabTiming", + relevance: "NA", + final: "NA", + }, + FirstLabTestWithEncounterId: { + library_name: "TestQDM", + statement_name: "FirstLabTestWithEncounterId", + relevance: "NA", + final: "NA", + }, + "SDE Results": { + raw: { + FirstHeartRate: [], + FirstSystolicBloodPressure: [], + FirstRespiratoryRate: [], + FirstBodyTemperature: [], + FirstOxygenSaturation: [], + FirstBodyWeight: [], + FirstHematocritLab: [], + FirstWhiteBloodCellCount: [], + FirstPotassiumLab: [], + FirstSodiumLab: [], + FirstBicarbonateLab: [], + FirstCreatinineLab: [], + FirstGlucoseLab: [], }, - ], - library_name: "TestQDM", - statement_name: "SDE Sex", - relevance: "NA", - final: "NA", - }, - FirstPhysicalExamWithEncounterId: { - library_name: "TestQDM", - statement_name: "FirstPhysicalExamWithEncounterId", - relevance: "NA", - final: "NA", - }, - FirstPhysicalExamWithEncounterIdUsingLabTiming: { - library_name: "TestQDM", - statement_name: "FirstPhysicalExamWithEncounterIdUsingLabTiming", - relevance: "NA", - final: "NA", - }, - FirstLabTestWithEncounterId: { - library_name: "TestQDM", - statement_name: "FirstLabTestWithEncounterId", - relevance: "NA", - final: "NA", - }, - "SDE Results": { - raw: { - FirstHeartRate: [], - FirstSystolicBloodPressure: [], - FirstRespiratoryRate: [], - FirstBodyTemperature: [], - FirstOxygenSaturation: [], - FirstBodyWeight: [], - FirstHematocritLab: [], - FirstWhiteBloodCellCount: [], - FirstPotassiumLab: [], - FirstSodiumLab: [], - FirstBicarbonateLab: [], - FirstCreatinineLab: [], - FirstGlucoseLab: [], + library_name: "TestQDM", + statement_name: "SDE Results", + relevance: "NA", + final: "NA", + }, + LengthOfStay: { + library_name: "TestQDM", + statement_name: "LengthOfStay", + relevance: "NA", + final: "NA", }, - library_name: "TestQDM", - statement_name: "SDE Results", - relevance: "NA", - final: "NA", - }, - LengthOfStay: { - library_name: "TestQDM", - statement_name: "LengthOfStay", - relevance: "NA", - final: "NA", }, }, + clause_results: null, + patient: "656a098cc2da020000043b67", + measure: "656e01841900d50000aa439a", + state: "complete", }, - clause_results: null, - patient: "656a098cc2da020000043b67", - measure: "656cd2e13761fb000092d358", - state: "complete", }, }; diff --git a/src/components/editTestCase/qdm/RightPanel/calculationResults/CalculationResults.test.tsx b/src/components/editTestCase/qdm/RightPanel/calculationResults/CalculationResults.test.tsx index b3fb59d8e..c581501a8 100644 --- a/src/components/editTestCase/qdm/RightPanel/calculationResults/CalculationResults.test.tsx +++ b/src/components/editTestCase/qdm/RightPanel/calculationResults/CalculationResults.test.tsx @@ -6,9 +6,11 @@ import userEvent from "@testing-library/user-event"; import { measureCql } from "../../../groupCoverage/_mocks_/QdmMeasureCql"; import { qdmCallStack } from "../../../groupCoverage/_mocks_/QdmCallStack"; import { qdmCalculationResults } from "../../../groupCoverage/_mocks_/QdmCalculationResults"; +import { qdmCqlPopulationsDefinitions } from "../../../groupCoverage/_mocks_/QDMCqlPopulationDefinitions"; import useCqlParsingService, { CqlParsingService, } from "../../../../../api/useCqlParsingService"; +import QdmGroupCoverage from "../../../groupCoverage/QdmGroupCoverage"; jest.mock("@madie/madie-util", () => ({ useOktaTokens: () => ({ @@ -288,4 +290,36 @@ describe("CalculationResults with new tabbed highlighting layout on", () => { `define "Denominator": "Initial Population"` ); }); + + test("render highlighting view with coverage results for definitions, used and functions", async () => { + render( + + ); + + expect(screen.getByText("Population Criteria 1")).toBeInTheDocument(); + + await assertPopulationTabs(); + + const criteriaOptions = await getCriteriaOptions(); + expect(criteriaOptions).toHaveLength(2); + userEvent.click(criteriaOptions[0]); + + expect(await getByRole("IP")).toBeInTheDocument(); + expect(screen.getByText("Definitions")).toBeInTheDocument(); + expect(screen.getByText("Unused")).toBeInTheDocument(); + expect(screen.getByText("Functions")).toBeInTheDocument(); + + const definitions = await getByRole("Definitions"); + userEvent.click(definitions); + expect(screen.getAllByTestId("definitions-highlighting")).toHaveLength(4); + + const unused = await getByRole("Unused"); + userEvent.click(unused); + expect(screen.getAllByTestId("unused-highlighting")).toHaveLength(5); + }); });