import { ELM, LibraryDependencyInfo } from '../types/ELMTypes'; import * as cql from '../types/CQLTypes'; import { FinalResult, PopulationType, Relevance } from '../types/Enums'; import { ClauseResult, DetailedPopulationGroupResult, EpisodeResults, PopulationResult, SDEResult, StatementResult } from '../types/Calculator'; /** * Contains helpers that generate useful data for coverage and highlighting. */ /** * Builds the initial list of StatementResult objects. This initializes the objects with ith statement relevance info. * This list gets added to the DetailedPopulationGroupResult for the given population group. * * The statement relevance indicates which define statements were actually relevant to a population inclusion * consideration. This makes use of the 'population relevance' info. The values for statement relevance differ from the * `population relevance` because we also need to track statements that are not used for any population calculation. * Therefore the values are a string/enum that is one of the following: 'NA', 'TRUE', 'FALSE'. Here is what they mean: * * 'NA' - Not applicable. This statement is not relevant to any population calculation in this population_set. Common * for unused library statements or statements only used for other population sets. * * 'FALSE' - This statement is not relevant to any of this patient's population inclusion calculations. * * 'TRUE' - This statement is relevant for one or more of the population inclusion calculations. * * This function relies heavily on the statement dependency map built in ELMDependencyHelper to recursively determine * which statements are used in the relevant population statements. It also uses the 'population_relevance' map to * determine the relevance of the population defining statement and its dependent statements. * * @public * @param {fhir4.Measure} measure - The measure. * @param {PopulationResult[]} populationRelevanceSet - The population relevance results, used at the starting point. * @param {string} mainLibraryId - The identifier of the main library. * @param {ELM[]} elmLibraries - All ELM libraries for the measure. * @param {fhir4.MeasureGroup} populationGroup - The population group being calculated. * @param {boolean} calculateSDEs - Whether or not to treat SDEs as calculated/relevant or not. * @param {boolean} calculateRAVs - Whether or not to treat RAVs as calculated/relevant or not. * @returns {StatementResult[]} The StatementResults list for each statement with its relevance status populated. */ export declare function buildStatementRelevanceMap(measure: fhir4.Measure, populationRelevanceSet: PopulationResult[], mainLibraryId: string, elmLibraries: ELM[], populationGroup: fhir4.MeasureGroup, calculateSDEs: boolean, calculateRAVs: boolean): StatementResult[]; /** * Recursive helper function for the buildStatementRelevanceMap function. This marks a statement as relevant (or not * relevant but applicable) in the StatementResults list. It recurses and marks dependent statements also relevant * unless they have already been marked as 'TRUE' for their relevance status. This function will never be called on * statements that are 'NA'. * * @private * @param {ELM[]} elmLibraries * @param {LibraryDependencyInfo[]} statementDependencies - dependency map from the measure object. The thing we recurse * over to find dependent statements even though it is flat, it represents a tree. * @param {StatementResult[]} statementResults - The list of StatementResults to mark relevance in. * @param {string} libraryName - The library name of the statement we are marking. * @param {string} statementName - The name of the statement we are marking. * @param {boolean} relevant - true if the statement should be marked 'TRUE', false if it should be marked 'FALSE'. */ export declare function markStatementRelevant(elmLibraries: ELM[], statementDependencies: LibraryDependencyInfo[], statementResults: StatementResult[], libraryName: string, statementName: string, relevant: boolean): void; /** * Helper function to find the StatementResult object for a given statement. * * @param {string} libraryName - Name of libary. * @param {string} statementName - Name of statement. * @param {StatementResult[]} statementResults - List of statement results to find the result in. * @returns {StatementResult|undefined} The statement results if found. */ export declare function getStatementResult(libraryName: string, statementName: string, statementResults: StatementResult[]): StatementResult | undefined; /** * Fills out the results attributes for the statements and builds clause results. * * The StatementResult `final` field indicates the result for the statement taking into account the statement * relevance in determining the result. The StatementResult also has the properties, 'raw', 'final' and 'pretty'. 'raw' * is the raw result from the execution engine for that statement. 'final' is the final result that takes into account * the relevance in this calculation. 'pretty' is a human readable description of the result that is only generated if * doPretty is true. The value of 'final' will be one of the following strings/enums: 'NA', 'UNHIT', 'TRUE', 'FALSE'. * * Here's what they mean: * * 'NA' - Not applicable. This statement is not relevant to any population calculation in this population_set. Common * for unused library statements or statements only used for other population sets. * !!!IMPORTANT NOTE!!! All define function statements are marked 'NA' since we don't have a strategy for * highlighting or coverage when it comes to functions. * * 'UNHIT' - This statement wasn't hit. This is most likely because the statement was not relevant to population * calculation for this patient. i.e. 'FALSE' in the the `statement_relevance` map. * * 'TRUE' - This statement is relevant and has a truthy result. * * 'FALSE' - This statement is relevant and has a falsey result. * * The ClauseResult list is similar to the StatementResult list but it indicates the results for each clause. * The same 'raw' and 'final' fields are set, but for the the clause itself. * * This function relies very heavily on the StatementResult `relevance` field to determine the final results. * * @public * @param {fhir4.Measure} measure - The measure. * @param {ELM[]} elmLibraries - List of all ELM Library JSONs. * @param {any} rawClauseResults - The raw clause results from the calculation engine. * @param {StatementResult[]} statementResults - The `statement_relevance` map. Used to determine if they were hit or not. * @param {boolean} doPretty - If true, also generate pretty versions of result. * @returns {object} Object with the statement_results and clause_results structures, keyed as such. */ export declare function buildStatementAndClauseResults(measure: fhir4.Measure, elmLibraries: ELM[], rawClauseResults: cql.LocalIdResults, statementResults: StatementResult[], doPretty: boolean, includeClauseResults: boolean): ClauseResult[]; /** * Generates a pretty human readable representation of a result. * * @param {(Array|object|boolean|???)} result - The result from the calculation engine. * @param {boolean} includeType - true if certain types should be labeled in the pretty output, like 'CODE' * @param {number|undefined} indentLevel - For nested objects, the indentLevel indicates how far to indent. * Note that 1 is the base because Array(1).join ' ' returns ''. * @param {number|undefined} keyIndent - Indent count used for key indentation. * @returns {String} a pretty version of the given result */ export declare function prettyResult(result: any | null, includeType?: boolean, indentLevel?: number, keyIndent?: number): string; /** * Uses the pieces of a code object to show code, system, and display in a pretty way * for whichever properties are available. */ export declare function prettyCode(code: string, system: string | undefined, display: string | undefined, includeType: boolean): string; /** * Uses the pieces of a codeable concept object to show concept display text (if available) * and the contained codings that belong to the concept in a pretty way */ export declare function prettyConcept(conceptTxt: string | undefined, conceptCodings: any[] | undefined, includeType: boolean, indentLevel?: number, keyIndent?: number): string; /** * Function to help prettyResult handle FHIRObject(s) specifically, handling similar types, but * in a FHIRObject structure rather than a CQL object structure. Uses similar inputs put expects * a FHIRObject result to be passed in. */ export declare function prettyFHIRObject(result: FHIRObject, includeType?: boolean, indentLevel?: number, keyIndent?: number): string; /** * Determines the final result (for coloring and coverage) for a clause. The result fills the 'final' property for the * clause result. Look at the comments for buildStatementAndClauseResults to get a description of what each of the * string results of this function are. * @private * @param {object} rawClauseResults - The raw clause results from the calculation engine. * @param {object} statementRelevance - The statement relevance map. * @param {object} statement_name - The name of the statement the clause is in * @param {object} library_name - The name of the libarary the clause is in * @param {object} localId - The localId of the current clause * @param {object} clause - The clause we are getting the final result of * @param {Array|Object|Interval|??} rawResult - The raw result from the calculation engine. * @returns {string} The final result for the clause. */ export declare function setFinalResults(params: { rawClauseResults: any; statementRelevance: Relevance; libraryName: string; clause: any; rawResult: any; }): FinalResult; /** * Finds the clause localId for a statement and gets the raw result for it from the raw clause results. * @private * @param {ELM} library - The library * @param {string} statement - The statement * @param {cql.LocalIdResults} rawClauseResults - The raw clause results from the engine. * @returns {(Array|object|Interval|??)} The raw result from the calculation engine for the given statement. */ export declare function findResultForStatementClause(elm: ELM, statementName: string, rawClauseResults: cql.LocalIdResults): any; /** * Determines if a result (for a statement or clause) from the execution engine is a pass or fail. * @private * @param {(Array|object|boolean|???)} result - The result from the calculation engine. * @returns {boolean} true or false */ export declare function doesResultPass(result: any | null): boolean; /** * Iterate over episode results, call _buildPopulationRelevanceMap for each result then OR population relevances * together so that a patient level population relevance set can be made. * * @private * @param {EpisodeResults[]} episodeResultsSet - Results for each episode * @param {fhir4.MeasureGroup} populationGroup - The population group from the measure * @param {string} measureScoringCode - The scoring code for the measure (used if scoring code not provided at the group level) * @returns {PopulationResult[]} List denoting if population calculation was considered/relevant in any episode */ export declare function buildPopulationRelevanceForAllEpisodes(episodeResultsSet: EpisodeResults[], populationGroup: fhir4.MeasureGroup, measureScoringCode?: string): PopulationResult[]; /** * Builds the relevance results for each population. This creates the `populationRelevance` list that is put on * DetailedPopulationGroupResult * * For each population in the group it is set to true if the population was relevant/considered, false if * NOT relevant/considered. This is used later to determine which define statements are relevant in the calculation. * * For example: If they aren't in the IPP then they are not going to be considered for any other population and all other * populations will be marked NOT relevant. * * This function is extremely verbose because this is an important and confusing calculation to make. The verbosity * was kept to make it more maintainable. * * @param {PopulationResult[]} results - The population results list for the population results. * @param {fhir4.MeasureGroup} group - The full group of the Measure, which is useful for resolving references between different populations * @param {string} measureScoringCode - The scoring code for measure (used if scoring code not provided at the group level) * @returns {PopulationResult[]} The population relevance set. */ export declare function buildPopulationRelevanceMap(results: PopulationResult[], group?: fhir4.MeasureGroup, measureScoringCode?: string): PopulationResult[]; /** * Wrapper function that builds population relevance either for all episodes (if the measure is episode-based) or for each * population (if patient-based). * @param results - The detailed results (used to pull off episode results for episode of care measure, or population results for * patient-based measure) * @param group - The full group of the Measure * @param measureScoringCode - The scoring code for measure (used if scoring code not provided at the group level) * @returns The population relevance set. */ export declare function buildPopulationGroupRelevanceMap(results: DetailedPopulationGroupResult, group: fhir4.MeasureGroup, measureScoringCode?: string): PopulationResult[]; export declare function findResult(populationType: PopulationType, results: PopulationResult[], criteriaExpression?: string, criteriaReferenceId?: string): PopulationResult | undefined; export declare function hasResult(populationType: PopulationType, results: PopulationResult[], criteriaExpression?: string): boolean; export declare function getResult(populationType: PopulationType, results: PopulationResult[], criteriaExpression?: string): boolean; export declare function setResult(populationType: PopulationType, newResult: boolean, results: PopulationResult[], criteriaExpression?: string, criteriaReferenceId?: string): void; export declare function createOrSetResult(populationType: PopulationType, newResult: boolean, results: PopulationResult[], criteriaExpression?: string, populationId?: string, criteriaReferenceId?: string, observations?: string[]): void; export declare function getSDEValues(measure: fhir4.Measure, statementResults: cql.StatementResults): SDEResult[];