Function: applyComplexMap()
applyComplexMap(
map,source,context?):ComplexMapApplyResult
Apply a loaded SNOMED→ICD-10-CM complex map to a source concept and patient context.
Resolves each map group independently (groups are an AND - a source needing multiple ICD-10-CM
codes has multiple groups) by running its rules in priority order against context. A group whose
decision needs IFA context the caller did not supply is a typed
ComplexMapContextRequired; a 447638001 row is a typed No-Map; every result carries the
steward's advice verbatim. Never fabricates a target, never inverts the map.
Parameters
map
A ComplexMap from loadComplexMap.
source
string
The SNOMED CT source concept id.
context?
PatientContext = {}
The caller-supplied PatientContext (age / gender). Optional; a missing
field that a rule needs yields a context-required group, never a guessed branch.
Returns
A ComplexMapApplyResult - per-group resolutions, or a typed absence.
Example
import { loadComplexMap, applyComplexMap } from "@cosyte/terminology";
const map = loadComplexMap({
format: "rows",
rows: [
{ source: "72098002", group: 1, priority: 1, rule: "IFA 248152002 | Female (finding) |", advice: "MAP IS CONTEXT DEPENDENT FOR GENDER", target: "O00.9", category: "447639009" },
{ source: "72098002", group: 1, priority: 2, rule: "OTHERWISE TRUE", advice: "CANNOT BE CLASSIFIED", category: "447638001" },
],
});
const r = applyComplexMap(map, "72098002", { gender: "female" });
r.mapped; // => true