Skip to main content
Version: v0.0.3

Function: checkCodeSlot()

checkCodeSlot(code, slot, position, ctx): void

Validate a coded value's @codeSystem against the terminologies expected for its CodeSlot. Emits DEPRECATED_CODE_SYSTEM for a known-deprecated system (ICD-9) and UNEXPECTED_CODE_SYSTEM for any other unexpected OID.

A CD that asserts a @code with no @codeSystem emits MISSING_CODE_SYSTEM: the symbol names no terminology, so it can be neither read nor checked. No system is ever inferred for it (not from the slot's expected list, not from a @codeSystemName label), and it is therefore never handed to a TerminologyAdapter, which validates a system + code pair.

The mirror shape emits MISSING_CODE_VALUE: a CD that is present but asserts no usable @code (absent, empty, or whitespace) and declares no @nullFlavor, e.g. a system-only <value codeSystem="…6.96"/>. A code system without a symbol identifies a concept no better than a symbol without a system does. The nullFlavor is what separates the two cases: a nullFlavor-only CD is a complete statement ("this concept is unknown") and stays silent, while a CD that says nothing at all leaves a reader unable to tell an absent concept from one lost in transformation. An absent value stays silent too, there is no element to judge.

The value is preserved verbatim in every case, and no code, system, or nullFlavor is ever inferred.

Parameters

code

CD | undefined

slot

CodeSlot

position

column?

number

line?

number

path?

string

ctx

ParseCtx

Returns

void

Example

import { checkCodeSlot } from "@cosyte/ccda";
checkCodeSlot(problemValue, "problem", { path: "value" }, ctx);