import type { CalculatedExpression } from '../interfaces/calculatedExpression.interface'; import type { Quantity, Questionnaire, QuestionnaireItem, QuestionnaireResponse, QuestionnaireResponseItem } from 'fhir/r4'; import type { Variables } from '../interfaces'; import type { ComputedNewAnswers } from '../interfaces/computedUpdates.interface'; interface EvaluateInitialCalculatedExpressionsParams { initialResponse: QuestionnaireResponse; initialResponseItemMap: Record; calculatedExpressions: Record; variables: Variables; existingFhirPathContext: Record; fhirPathTerminologyCache: Record; terminologyServerUrl: string; } export declare function evaluateInitialCalculatedExpressions(params: EvaluateInitialCalculatedExpressionsParams): Promise<{ initialCalculatedExpressions: Record; updatedFhirPathContext: Record; fhirPathTerminologyCache: Record; }>; export declare function evaluateCalculatedExpressionsFhirPath(fhirPathContext: Record, fhirPathTerminologyCache: Record, calculatedExpressions: Record, terminologyServerUrl: string): Promise<{ calculatedExpsIsUpdated: boolean; updatedCalculatedExpressions: Record; computedNewAnswers: ComputedNewAnswers; }>; /** * Applies evaluated calculated expression values into a QuestionnaireResponse. * Filters out calculated expressions that has value=undefined because in our prior processing step, items without values are set to null. * Uses the generic updateQuestionnaireResponse function to recursively apply the values. * * @param questionnaire - The Questionnaire definition object. * @param initialResponse - The target QuestionnaireResponse to be updated. * @param questionnaireItemMap - A mapping from linkId to QuestionnaireItem (without 'item' children) for easy lookup. * @param previousCalculatedExpressions - A mapping from linkId to array of CalculatedExpression objects that were previously applied. * @param updatedCalculatedExpressions - A mapping from linkId to array of CalculatedExpression objects to be applied. * @param itemPreferredTerminologyServers - A mapping of `linkId` to preferred terminology server URLs for that item. * @param defaultTerminologyServerUrl - The fallback terminology server URL to use if none is specified for an item. * @returns The updated QuestionnaireResponse with calculated expression values applied. */ export declare function applyCalculatedExpressionValuesToResponse(questionnaire: Questionnaire, initialResponse: QuestionnaireResponse, questionnaireItemMap: Record>, previousCalculatedExpressions: Record, updatedCalculatedExpressions: Record, itemPreferredTerminologyServers: Record, defaultTerminologyServerUrl: string): Promise; /** * Check if an answer is a datetime in the format YYYY, YYYY-MM, YYYY-MM-DD, YYYY-MM-DDThh:mm:ss+zz:zz * * @author Sean Fong */ export declare function checkIsDateTime(value: string): boolean; /** * Check if an answer is in a time format - Regex: ([01][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)(\.[0-9]+)? * * @author Sean Fong */ export declare function checkIsTime(value: string): boolean; /** * Check if an object is a FHIR Quantity. For our use case, `value` must be present (number). `unit`, `system`, and `code` are optional. * If a code for the unit is present, the system SHALL also be present. See https://www.hl7.org/fhir/R4/datatypes.html#Quantity constraints. * * @author Sean Fong */ export declare function checkIsQuantity(obj: unknown): obj is Quantity; /** * Evaluate calculated expressions with chaining support. * Iteratively evaluates calculated expressions until no more changes occur, ensuring that chained expressions are properly resolved. */ export declare function processCalculatedExpressions(questionnaire: Questionnaire, questionnaireResponse: QuestionnaireResponse, questionnaireItemMap: Record>, calculatedExpressions: Record, variables: Variables, existingFhirPathContext: Record, existingFhirPathTerminologyCache: Record, itemPreferredTerminologyServers: Record, defaultTerminologyServerUrl: string): Promise<{ updatedResponse: QuestionnaireResponse; updatedCalculatedExpressions: Record; }>; /** * Generates a unique repeat ID for a calculated expression answer. * * @param linkId - The item's linkId. * @returns A unique calculatedExpression ID. */ export declare function generateCalculatedExpressionsAnswerKey(linkId: string): string; export {};