T0014 — Functions: conversion
Part of the roadmap. Phase 1 · wave 4 · size M.
Goal
iif(lazy: only the selected branch is evaluated)toBooleanandconvertsToBooleantoIntegerandconvertsToIntegertoDecimalandconvertsToDecimaltoDateandconvertsToDatetoDateTimeandconvertsToDateTimetoTimeandconvertsToTimetoStringandconvertsToStringtoQuantity([unit])andconvertsToQuantity([unit])
Scope
- With a model, the functions read the System value that T0018 gives a typed FHIR primitive, the same for every provider (FHIR versions). The R6 draft adds a FHIR note on
toString()that limits it to FHIR primitives with a value (§2.1.9.4.1); check a typed FHIRQuantityagainst it and record any difference indocs/spec-notes.md.
Acceptance criteria
- Each conversion table in N1 §5.5 is fully covered, including the string formats it accepts and rejects.
-
toString()formats are tested:1.0 → '1.0',1 'wk',1 week, dates without@. - Conformance groups:
testIif,testCollectionBoolean(with T0010 for|and/),testToInteger,testToDecimal,testToString, and the conversion parts oftestLiteralsandtestTypes.
Implementation notes
functions/conversion.tsdefines every function of N1 §5.5 on the System value of the single input item (T0018), with the string formats of N1 and the 3.0.0 clarifications. Unit tests are infunctions/conversion.test.ts, the R4/R5/R6 cases inpackages/core/test/conversion-models.test.tsand the UCUMtoQuantity(unit)examples inpackages/ucum/test/conversion-integration.test.ts.iif()needs the 3.0.0 scoping: the input is$thisof its arguments, also when it is empty, and$indexstays that of the enclosing function. The existing lambda helpers could not express that, soLambdaArggainsforInput(input)(functions/define.ts,compiler/lambda.ts, botharea:core). The decisions are in spec notes.- The R6
toString()note differs for a typed FHIRQuantity; Callis keeps one behaviour for every provider (spec notes). - Long values (
System.Long, frominteger64) are not converted yet; T0028 adds them (#182). The optionalformatargument oftoDate()andtoDateTime()in 3.0.0 is not part of this task (#183). - Conformance-group residuals are due to other tasks:
empty()anddistinct()(T0041),select()(T0042),today()andnow()(T0017), and the strict-mode semantic error oftestIif6(T0024). Exact case names are in the generated reports.