Function: loadCodeSystem()
loadCodeSystem(
source):CodeSystem
Load a consumer-supplied code-system release into an immutable, queryable CodeSystem.
Dispatches on source.format:
"rrf"- pipe-delimited RxNorm/UMLS release (one parameterized reader for both)."csv"- RFC-4180 CSV (e.g. LOINCLoinc.csv), with real quote handling."fixed-width"- slice-by-column order files (e.g. ICD-10-CM; seeICD10CM_ORDER_FILE_FIELDS)."fhir"- a native FHIR R4CodeSystemJSON resource.
Liberal on load: a malformed row is skipped and surfaced in warnings (never a crash, never a
partial concept). Conservative on structure: an unusable source (wrong FHIR resourceType, or
a CSV whose configured columns are absent from the header) throws a typed TerminologyError
carrying TERM_CODESYSTEM_MALFORMED.
Parameters
source
The release descriptor (a discriminated CodeSystemSource).
Returns
The immutable, deep-frozen CodeSystem.
Throws
TERM_CODESYSTEM_MALFORMED when the source is structurally unusable.
Example
import { loadCodeSystem } from "@cosyte/terminology";
const cs = loadCodeSystem({
format: "fhir",
resource: {
resourceType: "CodeSystem",
url: "http://example.org/cs",
concept: [{ code: "A", display: "Alpha" }],
},
});
cs.count; // => 1