Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor to separate gaps and data requirements #293

Merged
merged 5 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/calculation/Calculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import * as MeasureBundleHelpers from '../helpers/MeasureBundleHelpers';
import * as ResultsHelpers from './ClauseResultsBuilder';
import * as DataRequirementHelpers from '../helpers/DataRequirementHelpers';
import MeasureReportBuilder from './MeasureReportBuilder';
import * as GapsInCareHelpers from '../gaps/GapsReportBuilder';
import * as GapsReportBuilder from './GapsReportBuilder';
import { generateHTML, generateClauseCoverageHTML } from './HTMLBuilder';
import { parseQueryInfo } from '../gaps/QueryFilterParser';
import * as RetrievesHelper from '../gaps/RetrievesFinder';
import { parseQueryInfo } from '../helpers/elm/QueryFilterParser';
import * as RetrievesHelper from '../helpers/elm/RetrievesHelper';
import { GracefulError } from '../types/errors/GracefulError';
import {
ErrorWithDebugInfo,
Expand All @@ -40,7 +40,7 @@ import { pruneDetailedResults } from '../helpers/DetailedResultsHelpers';
import { clearElmInfoCache } from '../helpers/elm/ELMInfoCache';
import _, { omit } from 'lodash';
import { ELM } from '../types/ELMTypes';
import { getReportBuilder } from '../helpers/reportBuilderFactory';
import { getReportBuilder } from '../helpers/ReportBuilderFactory';

/**
* Calculate measure against a set of patients. Returning detailed results for each patient and population group.
Expand Down Expand Up @@ -536,7 +536,7 @@ export async function calculateGapsInCare<T extends OneOrMultiPatient>(
errorLog.push(...retrievesErrors);

// Add detailed info to queries based on clause results
const gapsRetrieves = GapsInCareHelpers.processQueriesForGaps(baseRetrieves, dr);
const gapsRetrieves = GapsReportBuilder.processQueriesForGaps(baseRetrieves, dr);

const grPromises = gapsRetrieves.map(async retrieve => {
// If the retrieves have a localId for the query and a known library name, we can get more info
Expand All @@ -558,19 +558,19 @@ export async function calculateGapsInCare<T extends OneOrMultiPatient>(
await Promise.all(grPromises);

const { results: detailedGapsRetrieves, withErrors: reasonDetailErrors } =
GapsInCareHelpers.calculateReasonDetail(gapsRetrieves, improvementNotation, dr);
GapsReportBuilder.calculateReasonDetail(gapsRetrieves, improvementNotation, dr);

errorLog.push(...reasonDetailErrors);

const { detectedIssues, withErrors: detectedIssueErrors } = GapsInCareHelpers.generateDetectedIssueResources(
const { detectedIssues, withErrors: detectedIssueErrors } = GapsReportBuilder.generateDetectedIssueResources(
detailedGapsRetrieves,
matchingMeasureReport,
improvementNotation
);
errorLog.push(...detectedIssueErrors);

const patient = res.patientObject?._json as fhir4.Patient;
const gapsBundle = GapsInCareHelpers.generateGapsInCareBundle(detectedIssues, matchingMeasureReport, patient);
const gapsBundle = GapsReportBuilder.generateGapsInCareBundle(detectedIssues, matchingMeasureReport, patient);
result.push(gapsBundle);
if (debugOutput && options.enableDebugOutput) {
debugOutput.gaps = {
Expand Down Expand Up @@ -636,7 +636,7 @@ export async function calculateLibraryDataRequirements(
*
* @returns FHIR Library of data requirements
*/
export async function calculateDataRequirements(
export async function calculateMeasureDataRequirements(
measureBundle: fhir4.Bundle,
options: CalculationOptions = {}
): Promise<DRCalculationOutput> {
Expand Down
2 changes: 1 addition & 1 deletion src/calculation/ClauseResultsBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as ClauseResultsHelpers from './ClauseResultsHelpers';
import * as ClauseResultsHelpers from '../helpers/ClauseResultsHelpers';
import * as MeasureBundleHelpers from '../helpers/MeasureBundleHelpers';
import * as ELMDependencyHelper from '../helpers/elm/ELMDependencyHelpers';
import { ELM, LibraryDependencyInfo } from '../types/ELMTypes';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ import {
ReasonDetailData
} from '../types/Calculator';
import { FinalResult, ImprovementNotation, CareGapReasonCode, CareGapReasonCodeDisplay } from '../types/Enums';
import {
flattenFilters,
generateDetailedCodeFilter,
generateDetailedDateFilter,
generateDetailedValueFilter
} from '../helpers/DataRequirementHelpers';
import {
EqualsFilter,
InFilter,
Expand All @@ -26,6 +20,12 @@ import {
} from '../types/QueryFilterTypes';
import { GracefulError, isOfTypeGracefulError } from '../types/errors/GracefulError';
import { compareValues } from '../helpers/ValueComparisonHelpers';
import {
flattenFilters,
generateDetailedCodeFilter,
generateDetailedDateFilter,
generateDetailedValueFilter
} from '../helpers/elm/QueryFilterParser';

/**
* Iterate through base queries and add clause results for parent query and retrieve
Expand Down Expand Up @@ -249,7 +249,7 @@ export function generateGuidanceResponses(
codeFilter: [{ ...dataTypeCodeFilter }]
};

addFiltersToDataRequirement(q, dataRequirement, withErrors);
addGapFiltersToDataRequirement(q, dataRequirement, withErrors);

const guidanceResponse: fhir4.GuidanceResponse = {
resourceType: 'GuidanceResponse',
Expand Down Expand Up @@ -608,8 +608,8 @@ function getGapReasonCode(filter: AnyFilter): CareGapReasonCode | GracefulError
* @param withErrors Errors object which will eventually be returned to the user if populated
* @returns void, but populated the dataRequirement filters
*/
export function addFiltersToDataRequirement(
q: GapsDataTypeQuery | DataTypeQuery,
export function addGapFiltersToDataRequirement(
q: GapsDataTypeQuery,
dataRequirement: fhir4.DataRequirement,
withErrors: GracefulError[]
) {
Expand Down
4 changes: 2 additions & 2 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
calculateMeasureReports,
calculateGapsInCare,
calculateRaw,
calculateDataRequirements,
calculateMeasureDataRequirements,
elsaperelli marked this conversation as resolved.
Show resolved Hide resolved
calculateQueryInfo,
calculateLibraryDataRequirements
} from './calculation/Calculator';
Expand Down Expand Up @@ -121,7 +121,7 @@ async function calc(
} else if (program.outputType === 'gaps') {
result = await calculateGapsInCare(measureBundle, patientBundles, calcOptions, valueSetCache);
} else if (program.outputType === 'dataRequirements') {
result = calculateDataRequirements(measureBundle, calcOptions);
result = calculateMeasureDataRequirements(measureBundle, calcOptions);
} else if (program.outputType === 'libraryDataRequirements') {
// in this case, measureBundle should be a library bundle
result = calculateLibraryDataRequirements(measureBundle, calcOptions);
Expand Down
Loading
Loading