Function: toFhirCodeableConceptVia()
toFhirCodeableConceptVia(
cwe,map,ctx?):ConvertResult<FhirComplex>
Value-translate a coded v2 element to a FHIR CodeableConcept via a license-clean
CodedValueMap, additively and fail-safe - never mutating or discarding what the message
said:
- Primary code recognized as a bound-table code (translateBound - CWE.3 absent or names
the bound table, and the code is in the IG map's mapped group) → the primary coding is emitted
in the recognized source-table system (
map.sourceSystem, carryingCWE.7version) and the derived target coding is appended when it differs (a remap such asSC→SQ); the alternate triplet (CWE.4/5/6, via buildCoding, with its own system resolution + flags) and the originalCWE.9text are preserved. No primary unmapped flag - the value was faithfully recognized. - Otherwise - the primary declares a foreign coding system (not the bound table), the code is
empty, or it is in the IG's
(unmapped)group → this defers entirely to the structural toFhirCodeableConcept, which preserves the raw coding (and itsCWE.4/5/6alternate andCWE.7version) and flags it (ISSUE_CODES.TRANSFORM_CODE_UNMAPPED /TRANSFORM_CODE_SYSTEM_UNRESOLVED). A target is never fabricated, and a code that declares a foreign system is never asserted to be the standard concept.
Parameters
cwe
The parsed @cosyte/hl7 coded element (its identifier is the candidate table code).
map
The license-clean value map to apply (e.g. ROUTE_VALUE_MAP).
ctx?
TransformContext = {}
The transform context (threaded to the structural path + the alternate-triplet resolver).
Returns
ConvertResult<FhirComplex>
Example
import { toFhirCodeableConceptVia, ROUTE_VALUE_MAP } from "@cosyte/transform";
const { value } = toFhirCodeableConceptVia({ identifier: "IM" }, ROUTE_VALUE_MAP);
// coding === [{ system: ".../v2-0162", code: "IM" },
// { system: ".../v3-RouteOfAdministration", code: "IM", display: "Injection, intramuscular" }]
void value;