import type { CalculatedExpression } from '../interfaces'; import type { QuestionnaireItem } from 'fhir/r4'; import type { ValidateCodeResponse } from '../interfaces/valueSet.interface'; /** * Validates if a value represents a quantity with a unit enclosed in single quotes, * supporting escaped single quotes within the unit. * * @param input - The value to validate. * @returns {boolean} Returns true if the input matches the pattern: a number followed by a space and a unit enclosed in single quotes, (allowing escaped single quotes); otherwise, false. */ export declare function isQuantityString(input: unknown): input is string; interface UcumQuantityPromise { numericValueString: string; promise: Promise; } /** * Validates a UCUM unit code from a FHIR Quantity string using a terminology server. * Based on https://hl7.org/fhirpath/N1/#toquantityunit-string-quantity. * * @param rawValue - Quantity string (e.g. "10 'mg'"). * @param qItem - The QuestionnaireItem metadata. * @param itemPreferredTerminologyServers - Map of item-specific terminology servers. * @param defaultTerminologyServerUrl - Fallback terminology server URL. * @returns Promise resolving to a ValidateCodeResponse or null. */ export declare function validateQuantityUcumCode(rawValue: string, qItem: Omit, itemPreferredTerminologyServers: Record, defaultTerminologyServerUrl: string): UcumQuantityPromise; /** * Parse and convert calculatedExpression values of type `quantity` into valid UCUM-coded `Quantity` objects. * * This function: * - Iterates over calculatedExpressions grouped by `linkId` * - Identifies expressions with `from: "item"` and valid quantity strings (e.g. `"10 'mg'"`) * - Validates the UCUM unit code against a terminology server * - Converts validated expressions into FHIR `Quantity` objects with `value`, `system`, `code`, and `unit` * - Leaves non-quantity or invalid expressions unchanged * * @param diffCalculatedExpressions - Map of `linkId` → calculatedExpressions to process * @param questionnaireItemMap - Map of `linkId` → QuestionnaireItem metadata * @param itemPreferredTerminologyServers - Map of `linkId` → preferred terminology server URL * @param defaultTerminologyServerUrl - Default terminology server URL if no item-specific server is defined * @returns A promise resolving to the same structure as `diffCalculatedExpressions`, with quantity expressions converted to FHIR `Quantity` objects where possible */ export declare function parseAndConvertUcumQuantities(diffCalculatedExpressions: Record, questionnaireItemMap: Record>, itemPreferredTerminologyServers: Record, defaultTerminologyServerUrl: string): Promise>; export {};