Skip to content
This repository has been archived by the owner on Dec 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #706 from MeasureAuthoringTool/MAT-7725
Browse files Browse the repository at this point in the history
MAT-7725 stratification display issue after STU4 change
  • Loading branch information
adongare authored Sep 26, 2024
2 parents c2da963 + a84113d commit 62642c8
Show file tree
Hide file tree
Showing 5 changed files with 281 additions and 76 deletions.
222 changes: 201 additions & 21 deletions src/api/CalculationService.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import {
CalculationService,
ExecutionStatusType,
PopulationEpisodeResult,
} from "./CalculationService";
import { CalculationService, ExecutionStatusType } from "./CalculationService";
import { officeVisitMeasure } from "./__mocks__/OfficeVisitMeasure";
import { officeVisitValueSet } from "./__mocks__/OfficeVisitValueSet";
import { officeVisitMeasureBundle } from "./__mocks__/OfficeVisitMeasureBundle";
import { testCaseOfficeVisit } from "./__mocks__/TestCaseOfficeVisit";
import { groupResults } from "./__mocks__/GroupExecutionResults";
import {
ContinuousVariable_Encounter_Fail,
ContinuousVariable_Encounter_Pass,
Expand All @@ -18,7 +13,6 @@ import {

import {
DetailedPopulationGroupResult,
EpisodeResults,
ExecutionResult,
} from "fqm-execution/build/types/Calculator";
import {
Expand Down Expand Up @@ -487,6 +481,14 @@ describe("CalculationService Tests", () => {
name: "strata-1 Initial Population",
expected: true,
actual: true,
populationValues: [
{
id: "1",
name: PopulationType.INITIAL_POPULATION,
expected: true,
actual: true,
},
],
},
],
};
Expand Down Expand Up @@ -514,6 +516,14 @@ describe("CalculationService Tests", () => {
name: "strata-1 Initial Population",
expected: true,
actual: false,
populationValues: [
{
id: "1",
name: PopulationType.INITIAL_POPULATION,
expected: true,
actual: false,
},
],
},
],
};
Expand Down Expand Up @@ -773,6 +783,159 @@ describe("CalculationService Tests", () => {
};
expect(output).toEqual(expected);
});

it("should return test case results for episode based cohort stratification", () => {
const popGroupResults: DetailedPopulationGroupResult[] = [
{
groupId: "groupID",
statementResults: [],
episodeResults: [
{
episodeId: "episode-1",
populationResults: [
{
populationType: FqmPopulationType.IPP,
criteriaExpression: "Initial Population",
result: true,
populationId: "1",
},
],
stratifierResults: [
{
strataCode: "strata-1",
result: true,
appliesResult: false,
strataId: "strata-1",
},
],
},
{
episodeId: "episode-2",
populationResults: [
{
populationType: FqmPopulationType.IPP,
criteriaExpression: "Initial Population",
result: true,
populationId: "1",
},
],
stratifierResults: [
{
strataCode: "strata-1",
result: false,
appliesResult: false,
},
],
},
],
populationResults: [
{
populationId: "1",
populationType: FqmPopulationType.IPP,
criteriaExpression: "Initial Population",
result: true,
},
],
stratifierResults: [
{
strataCode: "strata-1",
result: true,
appliesResult: true,
strataId: "strata-1",
},
],
},
];
const testCase = {
id: "TC1",
name: "TestCase1",
title: "TestCase1",
description: "first",
validResource: true,
groupPopulations: [
{
groupId: "groupID",
scoring: MeasureScoring.COHORT,
populationBasis: "boolean",
populationValues: [
{
id: "1",
name: PopulationType.INITIAL_POPULATION,
expected: 2,
actual: 2,
},
],
stratificationValues: [
{
id: "strata-1",
name: "strata-1 Initial Population",
expected: true,
populationValues: [
{
id: "1",
name: PopulationType.INITIAL_POPULATION,
expected: 1,
actual: 1,
},
],
},
],
},
],
createdAt: "",
createdBy: "",
lastModifiedAt: "",
lastModifiedBy: "",
executionStatus: "NA",
series: undefined,
hapiOperationOutcome: undefined,
} as TestCase;

const groups: Group[] = [
{
id: "groupID",
scoring: MeasureScoring.COHORT,
populationBasis: "Encounter",
populations: [
{
id: "1",
name: PopulationType.INITIAL_POPULATION,
definition: "Initial Population",
},
],
stratifications: [
{
id: "strata-1",
cqlDefinition: "Stratification 1",
association: PopulationType.INITIAL_POPULATION,
},
],
measureObservations: [],
measureGroupTypes: [MeasureGroupTypes.OUTCOME],
},
];
const output = calculationService.processTestCaseResults(
testCase,
groups,
popGroupResults
);
expect(output).toBeTruthy();
expect(output.executionStatus).toEqual(ExecutionStatusType.PASS);
const outputGroupPopulations = output.groupPopulations;
expect(outputGroupPopulations).toBeTruthy();
expect(outputGroupPopulations.length).toEqual(1);
const group1PopVals = outputGroupPopulations[0].populationValues;
expect(group1PopVals).toBeTruthy();
expect(group1PopVals.length).toEqual(1);
expect(group1PopVals[0]).toBeTruthy();
expect(group1PopVals[0].expected).toBeTruthy();
expect(group1PopVals[0].actual).toBeTruthy();
const group1StratVals = outputGroupPopulations[0].stratificationValues;
expect(group1StratVals).toBeTruthy();
expect(group1StratVals.length).toEqual(1);
expect(group1StratVals[0].populationValues[0].actual).toEqual(1);
expect(group1StratVals[0].populationValues[0].actual).toEqual(1);
});
});

describe("CalculationService.processTestCaseResults", () => {
Expand Down Expand Up @@ -859,7 +1022,7 @@ describe("CalculationService Tests", () => {
});

it("should return Pass executionStatus if groupPopulations are null but actual result is false", () => {
const testCase: TestCase = {
const testCase = {
id: "TC1",
name: "TestCase1",
title: "TestCase1",
Expand All @@ -873,7 +1036,7 @@ describe("CalculationService Tests", () => {
executionStatus: "NA",
series: undefined,
hapiOperationOutcome: undefined,
};
} as TestCase;

const groups: Group[] = [
{
Expand Down Expand Up @@ -917,7 +1080,7 @@ describe("CalculationService Tests", () => {
});

it("should return Fail executionStatus if groupPopulations are empty and actual result is true", () => {
const testCase: TestCase = {
const testCase = {
id: "TC1",
name: "TestCase1",
title: "TestCase1",
Expand All @@ -931,7 +1094,7 @@ describe("CalculationService Tests", () => {
executionStatus: "NA",
series: undefined,
hapiOperationOutcome: undefined,
};
} as TestCase;

const groups: Group[] = [
{
Expand Down Expand Up @@ -976,7 +1139,7 @@ describe("CalculationService Tests", () => {
});

it("should return Fail executionStatus for provided measure groups when no matching groups are found and actual result is true", () => {
const testCase: TestCase = {
const testCase = {
id: "TC1",
name: "TestCase1",
title: "TestCase1",
Expand Down Expand Up @@ -1005,7 +1168,7 @@ describe("CalculationService Tests", () => {
executionStatus: "NA",
series: undefined,
hapiOperationOutcome: undefined,
};
} as TestCase;

const groups: Group[] = [
{
Expand Down Expand Up @@ -1076,7 +1239,7 @@ describe("CalculationService Tests", () => {
],
},
];
const testCase: TestCase = {
const testCase = {
id: "TC1",
name: "TestCase1",
title: "TestCase1",
Expand Down Expand Up @@ -1105,7 +1268,7 @@ describe("CalculationService Tests", () => {
executionStatus: "NA",
series: undefined,
hapiOperationOutcome: undefined,
};
} as TestCase;
const groups: Group[] = [
{
id: "groupID",
Expand Down Expand Up @@ -1155,7 +1318,7 @@ describe("CalculationService Tests", () => {
],
},
];
const testCase: TestCase = {
const testCase = {
id: "TC1",
name: "TestCase1",
title: "TestCase1",
Expand Down Expand Up @@ -1184,7 +1347,7 @@ describe("CalculationService Tests", () => {
executionStatus: "NA",
series: undefined,
hapiOperationOutcome: undefined,
};
} as TestCase;
const groups: Group[] = [
{
id: "groupID",
Expand Down Expand Up @@ -1264,7 +1427,7 @@ describe("CalculationService Tests", () => {
],
},
];
const testCase: TestCase = {
const testCase = {
id: "TC1",
name: "TestCase1",
title: "TestCase1",
Expand All @@ -1287,11 +1450,27 @@ describe("CalculationService Tests", () => {
id: "strata1",
name: "strata-1 Initial Population",
expected: true,
populationValues: [
{
id: "pop1",
name: PopulationType.INITIAL_POPULATION,
expected: true,
actual: true,
},
],
},
{
id: "strata2",
name: "strata-2 Initial Population",
expected: true,
populationValues: [
{
id: "pop1",
name: PopulationType.INITIAL_POPULATION,
expected: true,
actual: true,
},
],
},
],
},
Expand All @@ -1303,7 +1482,8 @@ describe("CalculationService Tests", () => {
executionStatus: "NA",
series: undefined,
hapiOperationOutcome: undefined,
};
} as TestCase;

const groups: Group[] = [
{
id: "groupID",
Expand Down Expand Up @@ -1351,8 +1531,8 @@ describe("CalculationService Tests", () => {
const group1StratVals = outputGroupPopulations[0].stratificationValues;
expect(group1StratVals).toBeTruthy();
expect(group1StratVals.length).toEqual(2);
expect(group1StratVals[0].actual).toEqual(true);
expect(group1StratVals[1].actual).toEqual(true);
expect(group1StratVals[0].populationValues[0].actual).toEqual(true);
expect(group1StratVals[1].populationValues[0].actual).toEqual(true);
});

it("should return test case results for continuous variable, boolean popBasis", () => {
Expand Down
Loading

0 comments on commit 62642c8

Please sign in to comment.