Function: translate()
translate(
sourceCoding,map):TranslateResult
Translate a source Coding through a loaded ConceptMap.
Matches the coding's code against each applicable group's element.code (the source side -
never targets, so the map is never inverted) and returns every declared target for it. A target
with an unmatched equivalence, or with no code, is treated as "no target" - the FHIR way of
asserting a non-mapping - and does not count as a match. When nothing matches, the map author's
group.unmapped directive (if any) is reported via the result's UnmappedMode but never
silently applied.
Parameters
sourceCoding
The source concept to translate.
map
A ConceptMap from loadConceptMap.
Returns
A TranslateResult - matched targets, or a typed unmapped outcome.
Example
import { loadConceptMap, translate } from "@cosyte/terminology";
const map = loadConceptMap({
resourceType: "ConceptMap",
group: [
{
source: "http://hl7.org/fhir/administrative-gender",
target: "http://terminology.hl7.org/CodeSystem/v2-0001",
element: [{ code: "male", target: [{ code: "M", equivalence: "equivalent" }] }],
},
],
});
const r = translate(
{ system: "http://hl7.org/fhir/administrative-gender", code: "male" },
map,
);
r.unmapped; // => false