fqm-execution
Advanced tools
Comparing version 1.4.1 to 1.5.0
@@ -36,2 +36,3 @@ import { DetailedPopulationGroupResult, EpisodeResults, PopulationResult, StratifierResult } from '../types/Calculator'; | ||
}; | ||
export declare function handleStratificationValues(populationGroup: fhir4.MeasureGroup, populationResults: PopulationResult[], stratifierResults: StratifierResult[]): StratifierResult[]; | ||
/** | ||
@@ -38,0 +39,0 @@ * Create population results for all episodes using the results from the calculator. This is |
@@ -26,3 +26,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.generateBooleanELMJSONFunction = exports.generateEpisodeELMJSONFunction = exports.setValueSetVersionsToUndefined = exports.createEpisodePopulationValues = exports.createPatientPopulationValues = exports.handlePopulationValues = exports.createPopulationValues = void 0; | ||
exports.generateBooleanELMJSONFunction = exports.generateEpisodeELMJSONFunction = exports.setValueSetVersionsToUndefined = exports.createEpisodePopulationValues = exports.handleStratificationValues = exports.createPatientPopulationValues = exports.handlePopulationValues = exports.createPopulationValues = void 0; | ||
const MeasureBundleHelpers = __importStar(require("../helpers/MeasureBundleHelpers")); | ||
@@ -54,2 +54,5 @@ const DetailedResultsHelpers = __importStar(require("../helpers/DetailedResultsHelpers")); | ||
populationResults = handlePopulationValues(populationResults, populationGroup, measureScoringCode); | ||
if (stratifierResults) { | ||
stratifierResults = handleStratificationValues(populationGroup, populationResults, stratifierResults); | ||
} | ||
} | ||
@@ -67,2 +70,5 @@ else { | ||
stratifierResults = popAndStratResults.stratifierResults; | ||
if (stratifierResults) { | ||
stratifierResults = handleStratificationValues(populationGroup, populationResults, stratifierResults); | ||
} | ||
} | ||
@@ -99,6 +105,9 @@ else { | ||
else { | ||
stratifierResults === null || stratifierResults === void 0 ? void 0 : stratifierResults.push(Object.assign({ result: strat.result, strataCode: strat.strataCode }, (strat.strataId ? { strataId: strat.strataId } : {}))); | ||
stratifierResults === null || stratifierResults === void 0 ? void 0 : stratifierResults.push(Object.assign({ result: strat.result, strataCode: strat.strataCode, appliesResult: strat.result }, (strat.strataId ? { strataId: strat.strataId } : {}))); | ||
} | ||
}); | ||
}); | ||
if (stratifierResults) { | ||
stratifierResults = handleStratificationValues(populationGroup, populationResults, stratifierResults); | ||
} | ||
} | ||
@@ -283,7 +292,7 @@ } | ||
populationGroup.stratifier.forEach(strata => { | ||
var _a, _b, _c, _d; | ||
var _a, _b, _c, _d, _e; | ||
if ((_a = strata.criteria) === null || _a === void 0 ? void 0 : _a.expression) { | ||
const value = patientResults[(_b = strata.criteria) === null || _b === void 0 ? void 0 : _b.expression]; | ||
const result = isStatementValueTruthy(value); | ||
stratifierResults === null || stratifierResults === void 0 ? void 0 : stratifierResults.push(Object.assign({ strataCode: (_d = (_c = strata.code) === null || _c === void 0 ? void 0 : _c.text) !== null && _d !== void 0 ? _d : `strata-${strataIndex++}`, result }, (strata.id ? { strataId: strata.id } : {}))); | ||
stratifierResults === null || stratifierResults === void 0 ? void 0 : stratifierResults.push(Object.assign({ strataCode: (_e = (_d = (_c = strata.code) === null || _c === void 0 ? void 0 : _c.text) !== null && _d !== void 0 ? _d : strata.id) !== null && _e !== void 0 ? _e : `strata-${strataIndex++}`, result, appliesResult: result }, (strata.id ? { strataId: strata.id } : {}))); | ||
} | ||
@@ -298,2 +307,26 @@ }); | ||
exports.createPatientPopulationValues = createPatientPopulationValues; | ||
function handleStratificationValues(populationGroup, populationResults, stratifierResults) { | ||
if (populationGroup.stratifier) { | ||
stratifierResults.forEach(stratRes => { | ||
var _a, _b, _c, _d, _e, _f, _g; | ||
const strata = ((_a = populationGroup.stratifier) === null || _a === void 0 ? void 0 : _a.find(s => s.id === stratRes.strataCode)) || | ||
((_b = populationGroup.stratifier) === null || _b === void 0 ? void 0 : _b.find(s => s.code && s.code.text === stratRes.strataCode)); | ||
if (strata) { | ||
// if the cqfm-appliesTo extension is present, then we want to consider the result of that | ||
// population in our stratifier result | ||
const appliesToExtension = (_c = strata.extension) === null || _c === void 0 ? void 0 : _c.find(e => e.url === 'http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-appliesTo'); | ||
let popValue = true; | ||
if (appliesToExtension) { | ||
const popCode = (_e = (_d = appliesToExtension.valueCodeableConcept) === null || _d === void 0 ? void 0 : _d.coding) === null || _e === void 0 ? void 0 : _e[0].code; | ||
if (popCode) { | ||
popValue = (_g = (_f = populationResults.find(pr => pr.populationType === popCode)) === null || _f === void 0 ? void 0 : _f.result) !== null && _g !== void 0 ? _g : true; | ||
} | ||
} | ||
stratRes.appliesResult = popValue && stratRes.result; | ||
} | ||
}); | ||
} | ||
return stratifierResults; | ||
} | ||
exports.handleStratificationValues = handleStratificationValues; | ||
function isStatementValueTruthy(value) { | ||
@@ -401,2 +434,5 @@ if (Array.isArray(value) && value.length > 0) { | ||
episodeResults.populationResults = handlePopulationValues(episodeResults.populationResults, populationGroup, measureScoringCode); | ||
if (episodeResults.stratifierResults) { | ||
handleStratificationValues(populationGroup, episodeResults.populationResults, episodeResults.stratifierResults); | ||
} | ||
}); | ||
@@ -468,3 +504,3 @@ // TODO: Remove any episode that don't fall in any populations or stratifications after the above code | ||
const newStrataCode = (_b = (_a = strata.code) === null || _a === void 0 ? void 0 : _a.text) !== null && _b !== void 0 ? _b : `strata-${strataIndex++}`; | ||
(_c = newEpisodeResults.stratifierResults) === null || _c === void 0 ? void 0 : _c.push(Object.assign(Object.assign({}, (strataId ? { strataId } : {})), { strataCode: newStrataCode, result: newStrataCode === strataCode ? true : false })); | ||
(_c = newEpisodeResults.stratifierResults) === null || _c === void 0 ? void 0 : _c.push(Object.assign(Object.assign({}, (strataId ? { strataId } : {})), { strataCode: newStrataCode, result: newStrataCode === strataCode ? true : false, appliesResult: newStrataCode === strataCode ? true : false })); | ||
}); | ||
@@ -471,0 +507,0 @@ } |
@@ -109,3 +109,8 @@ "use strict"; | ||
const reportStratifier = {}; | ||
reportStratifier.code = s.code ? [s.code] : []; | ||
if (s.code) { | ||
reportStratifier.code = [s.code]; | ||
} | ||
if (s.id) { | ||
reportStratifier.id = s.id; | ||
} | ||
const strat = {}; | ||
@@ -183,9 +188,12 @@ // use existing populations, but reduce count as appropriate | ||
(_b = er.stratifierResults) === null || _b === void 0 ? void 0 : _b.forEach(stratResults => { | ||
var _a, _b, _c; | ||
var _a, _b, _c, _d; | ||
// only add to results if this episode is in the strata | ||
if (stratResults.result) { | ||
const strata = (_a = group.stratifier) === null || _a === void 0 ? void 0 : _a.find(s => s.code && s.code[0].text === stratResults.strataCode); | ||
const stratum = (_b = strata === null || strata === void 0 ? void 0 : strata.stratum) === null || _b === void 0 ? void 0 : _b[0]; | ||
// the strataCode has the potential to be a couple of things, either s.code[0].text (previous measures) | ||
// or s.id (newer measures) | ||
const strata = ((_a = group.stratifier) === null || _a === void 0 ? void 0 : _a.find(s => { var _a; return s.code && ((_a = s.code[0]) === null || _a === void 0 ? void 0 : _a.text) === stratResults.strataCode; })) || | ||
((_b = group.stratifier) === null || _b === void 0 ? void 0 : _b.find(s => s.id === stratResults.strataCode)); | ||
const stratum = (_c = strata === null || strata === void 0 ? void 0 : strata.stratum) === null || _c === void 0 ? void 0 : _c[0]; | ||
if (stratum) { | ||
(_c = er.populationResults) === null || _c === void 0 ? void 0 : _c.forEach(pr => { | ||
(_d = er.populationResults) === null || _d === void 0 ? void 0 : _d.forEach(pr => { | ||
this.incrementPopulationInStratum(stratum, pr, groupScoringCode); | ||
@@ -218,9 +226,12 @@ }); | ||
(_f = groupResults.stratifierResults) === null || _f === void 0 ? void 0 : _f.forEach(stratResults => { | ||
var _a, _b, _c; | ||
var _a, _b, _c, _d; | ||
// only add to results if this patient is in the strata | ||
if (stratResults.result) { | ||
const strata = (_a = group.stratifier) === null || _a === void 0 ? void 0 : _a.find(s => s.code && s.code[0].text === stratResults.strataCode); | ||
const stratum = (_b = strata === null || strata === void 0 ? void 0 : strata.stratum) === null || _b === void 0 ? void 0 : _b[0]; | ||
if (stratResults.appliesResult) { | ||
// the strataCode has the potential to be a couple of things, either s.code[0].text (previous measures) | ||
// or s.id (newer measures) | ||
const strata = ((_a = group.stratifier) === null || _a === void 0 ? void 0 : _a.find(s => { var _a; return s.code && ((_a = s.code[0]) === null || _a === void 0 ? void 0 : _a.text) === stratResults.strataCode; })) || | ||
((_b = group.stratifier) === null || _b === void 0 ? void 0 : _b.find(s => s.id === stratResults.strataCode)); | ||
const stratum = (_c = strata === null || strata === void 0 ? void 0 : strata.stratum) === null || _c === void 0 ? void 0 : _c[0]; | ||
if (stratum) { | ||
(_c = groupResults.populationResults) === null || _c === void 0 ? void 0 : _c.forEach(pr => { | ||
(_d = groupResults.populationResults) === null || _d === void 0 ? void 0 : _d.forEach(pr => { | ||
this.incrementPopulationInStratum(stratum, pr, groupScoringCode); | ||
@@ -279,5 +290,2 @@ }); | ||
} | ||
else { | ||
throw new CustomErrors_1.UnexpectedProperty(`Population ${pr.populationType} in stratum ${stratum.id} not found in measure report.`); | ||
} | ||
} | ||
@@ -284,0 +292,0 @@ } |
@@ -158,3 +158,6 @@ "use strict"; | ||
const sources = []; | ||
const querySources = [...query.source, ...query.relationship]; | ||
const querySources = [...query.source]; | ||
if (query.relationship) { | ||
querySources.push(...query.relationship); | ||
} | ||
querySources.forEach(source => { | ||
@@ -161,0 +164,0 @@ if (source.expression.type == 'Retrieve') { |
@@ -217,2 +217,8 @@ import { PopulationType, FinalResult, Relevance, CareGapReasonCode } from './Enums'; | ||
result: boolean; | ||
/** | ||
* True if patient or episode is in stratifier AND the population | ||
* result it appliesTo is true. False if not. Only implemented for | ||
* patient based measures currently. | ||
*/ | ||
appliesResult: boolean; | ||
strataId?: string; | ||
@@ -219,0 +225,0 @@ } |
@@ -187,3 +187,3 @@ import { AnyTypeSpecifier } from 'cql-execution'; | ||
let?: ELMLetClause[]; | ||
relationship: ELMRelationshipClause[]; | ||
relationship?: ELMRelationshipClause[]; | ||
where?: AnyELMExpression; | ||
@@ -190,0 +190,0 @@ return?: ELMReturnClause; |
{ | ||
"name": "fqm-execution", | ||
"version": "1.4.1", | ||
"version": "1.5.0", | ||
"description": "FHIR Quality Measure Execution", | ||
@@ -18,3 +18,3 @@ "main": "build/index.js", | ||
"cql-exec-fhir": "^2.1.3", | ||
"cql-execution": "^3.0.1", | ||
"cql-execution": "^3.1.0", | ||
"handlebars": "^4.7.7", | ||
@@ -91,2 +91,6 @@ "lodash": "^4.17.21", | ||
"email": "laurend@mitre.org" | ||
}, | ||
{ | ||
"name": "Elsa Perelli", | ||
"email": "eperelli@mitre.org" | ||
} | ||
@@ -93,0 +97,0 @@ ], |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
1263013
17695
1369
Updatedcql-execution@^3.1.0