Skip to main content
Version: v0.2.0

Warning and error codes

Every code the package reports, in one place. A warning is a CcdaWarning on doc.warnings (and on onWarning); a fatal is a CcdaParseError that parseCcda throws; an edit error is a CcdaEditError that editCcda throws. Each meaning below restates the warning's own message, which comes whole from a fixed registry and never carries text from the document.

The Safety-critical column says whether the code is in SAFETY_CRITICAL_CODES. A vendor profile can never tolerate a safety-critical code: defineCcdaProfile throws if one is listed. Every other warning can be downgraded to CCDA_PROFILE_QUIRK_APPLIED by a profile that expects it. Under { strict: true }, parseCcda throws the first warning that no profile expected as a CcdaParseError carrying that warning's code.

The sample below holds this page to the code: it fails when a code is added to CCDA_WARNING_CODES or CCDA_FATAL_CODES, or when SAFETY_CRITICAL_CODES changes, until the page is brought up to date.

import { CCDA_FATAL_CODES, SAFETY_CRITICAL_CODES, CCDA_WARNING_CODES } from "@cosyte/ccda";

Object.keys(CCDA_WARNING_CODES).length; // => 54
Object.keys(CCDA_FATAL_CODES).length; // => 7
SAFETY_CRITICAL_CODES.size; // => 28

Object.keys(CCDA_FATAL_CODES).join(","); // => "CCDA_XXE_OR_DTD_PRESENT,CCDA_ENTITY_EXPANSION_LIMIT,CCDA_INPUT_SIZE_LIMIT_EXCEEDED,CCDA_ELEMENT_DEPTH_LIMIT_EXCEEDED,CCDA_NODE_COUNT_LIMIT_EXCEEDED,CCDA_NOT_WELL_FORMED_XML,CCDA_NOT_A_CLINICAL_DOCUMENT"

Fatal codes​

parseCcda throws a CcdaParseError with one of these codes. The first five are the defenses against hostile XML; their caps default to DEFAULT_LIMITS and are set with the limits parse option.

CodeMeaning
CCDA_XXE_OR_DTD_PRESENTThe input declares a DTD, a DOCTYPE or a custom entity, and is refused to prevent external-entity attacks.
CCDA_ENTITY_EXPANSION_LIMITThe input has more custom entity references than the cap allows.
CCDA_INPUT_SIZE_LIMIT_EXCEEDEDThe input is larger than the byte cap.
CCDA_ELEMENT_DEPTH_LIMIT_EXCEEDEDElements are nested deeper than the depth cap.
CCDA_NODE_COUNT_LIMIT_EXCEEDEDThe input has more elements than the node cap.
CCDA_NOT_WELL_FORMED_XMLThe input is not well-formed XML, or holds a character XML 1.0 forbids, written as it is or as a character reference, or an element with one attribute name under two prefixes of one namespace, or a character outside ASCII that is neither XML white space nor a name character (NEL, U+2028, U+2029, a no-break space, U+0080 and the rest) inside a tag or outside the root.
CCDA_NOT_A_CLINICAL_DOCUMENTThe XML is well-formed, but the root element is not a ClinicalDocument in the HL7 v3 namespace.

Warning codes​

Document and template recognition​

CodeMeaningSafety-critical
CCDA_UNKNOWN_DOCUMENT_TEMPLATEThe root templateId set names no recognized C-CDA R2.1 document type; the document is read as a generic ClinicalDocument.No
CCDA_MISSING_TEMPLATE_IDThe element carries no templateId. On a document or a section, recognition fell back to other signals; on an entry's clinical statement, the entry is not read and survives only in the re-serialized XML.No
CCDA_TEMPLATE_EXTENSION_ABSENTThe recognized templateId has no @extension version stamp, so it was matched by its root alone (the document may predate R2.1).No
CCDA_TEMPLATE_EXTENSION_UNMODELED_RELEASEThe recognized templateId carries a version stamp for a C-CDA release this package does not model; the document is read leniently.No
CCDA_REQUIRED_SECTIONS_NOT_EVALUATEDThe document type's required (SHALL) sections were not checked, because its templateId names a release the tables do not reach. No CCDA_REQUIRED_SECTION_MISSING is reported for the document.No
CCDA_UNKNOWN_NAMESPACE_PREFIXAn element outside the v3, xsi and sdtc namespaces, or in no namespace, was found. The node is kept and reported once per namespace.No
CCDA_ENCODING_BOM_STRIPPEDA UTF-8 byte-order mark was removed from the start of the input.No

Sections​

CodeMeaningSafety-critical
CCDA_UNKNOWN_SECTION_CODEThe section's LOINC code names no recognized C-CDA section; the section is kept as narrative only.No
CCDA_SECTION_MATCHED_BY_LOINC_FALLBACKThe section was recognized by its LOINC code, since it carries no recognized templateId.No
CCDA_SECTION_PLACEMENT_SUSPECTAn entry template was found in a section it does not belong to; the entry is read and flagged.No
CCDA_REQUIRED_SECTION_MISSINGThe document type requires a section (SHALL) that is not there; the document is read without it, and missingRequiredSections() names the full set.Yes
CCDA_SUBJECT_CONTEXT_OVERRIDEA <subject> declaration governs this content, so it is not the record target's own: the entry is withheld from every read path for the patient's data.Yes

Patient and author​

CodeMeaningSafety-critical
CCDA_MULTIPLE_RECORD_TARGETSThe document has more than one recordTarget; getPatient() reads the first, and header.recordTargets holds them all.Yes
CCDA_MISSING_ASSIGNING_AUTHORITYA patient identifier has a root OID but no assigningAuthorityName.Yes
CCDA_UNIDENTIFIED_AUTHORAn author carries neither an assignedPerson nor an assignedAuthoringDevice; it is kept and marked unidentified, and no identity is inferred for it.No

Datatypes and null flavors​

CodeMeaningSafety-critical
CCDA_INVALID_NULL_FLAVORThe nullFlavor is not a code of the HL7 v3 NullFlavor code system; it is kept as written.No
CCDA_CONTRADICTORY_NULL_FLAVORThe element declares a nullFlavor and a value at once; the value is kept as written but is never read as the field's value.Yes
CCDA_MALFORMED_DATETIMEThe value does not have the shape of an HL7 v3 TS datetime; the raw text is kept and the parsed date is undefined.Yes
CCDA_NEGATION_VS_NULLFLAVOR_AMBIGUOUSThe act carries both negationInd="true" and a nullFlavor; the two are kept as separate fields, never merged.Yes

Coded values and terminology​

CodeMeaningSafety-critical
CCDA_UNEXPECTED_CODE_SYSTEMThe code system OID is not one expected at this coded slot; the value is kept.Yes
CCDA_DEPRECATED_CODE_SYSTEMThe code system OID is deprecated at this slot, and a modern successor exists; the value is kept.No
CCDA_MISSING_CODE_SYSTEMThe coded value has a @code but no @codeSystem, so it names no terminology; no system is inferred, and it is never handed to a terminology adapter.Yes
CCDA_MISSING_CODE_VALUEThe coded value has neither a @code nor a @nullFlavor, so an absent concept cannot be told from a lost one; no code is inferred.Yes
CCDA_CODE_NARRATIVE_MISMATCHA coded value and the narrative it references disagree; both are kept and neither is chosen.Yes
CCDA_NARRATIVE_REFERENCE_BROKENThe narrative reference points at no ID in the section narrative.Yes
CCDA_DEPRECATED_LOINCThe observation's LOINC code is deprecated, and a current successor exists; the code is kept.No
CCDA_SEMANTIC_CODE_INVALIDThe terminology adapter you supplied says the code is not a valid member of its system; the code is kept as written.No
CCDA_VALUE_SET_BINDING_VIOLATEDThe value-set source you supplied says the code is not in the value set C-CDA R2.1 binds this slot to with a Required binding. valueSet and valueSetRelease say which.No
CCDA_VALUE_SET_BINDING_NOT_EVALUATEDThe value-set source you supplied holds no expansion of the bound value set, so membership was not checked; the silence says nothing about membership.No

Medications and immunizations​

CodeMeaningSafety-critical
CCDA_MISSING_DOSE_QUANTITYThe medication activity has no doseQuantity; the dose is absent, never defaulted.Yes
CCDA_MISSING_ROUTE_CODEThe medication activity has no routeCode; the route is absent, never defaulted.Yes
CCDA_MISSING_PRODUCT_CODENo manufacturedProduct arm carries a coded product; the product is absent, never inferred from the narrative or the entry's other fields.Yes
CCDA_MEDICATION_PRODUCT_ARM_UNEXPECTEDThe product is on the manufacturedLabeledDrug arm, which the C-CDA medication templates are not written around. Read alone, the product was read as usual.No
CCDA_MEDICATION_PRODUCT_ARM_CONFLICTThe product arms name different products; no product code is selected, and every arm survives in the re-serialized XML.Yes
CCDA_MEDICATION_PRODUCT_ARM_REPEATEDMore than one arm of the same kind is present, where CDA R2 allows one; whether they agree is answered by CCDA_MEDICATION_PRODUCT_ARM_CONFLICT.No
CCDA_MEDICATION_PRODUCT_CODE_REPEATEDOne product arm carries more than one <code>; every one is compared, and only the first is ever selected.Yes
CCDA_MEDICATION_PRODUCT_CODE_TRANSLATION_ONLYNo arm's first <code> asserts a primary @code, and the product is named only in a <translation>; no product code is selected.Yes
CCDA_MULTIPLE_EFFECTIVE_TIMES_UNRESOLVEDThe medication has effectiveTime siblings that could not be told apart as duration and frequency; all are kept.Yes
CCDA_IMMUNIZATION_REFUSEDThe immunization activity carries negationInd="true": the vaccine was not given or was refused, and it is read as refused, never as given.No

Results, vital signs and units​

CodeMeaningSafety-critical
CCDA_NON_UCUM_UNITThe @unit is not a well-formed UCUM unit; the unit and the value are kept as written.Yes
CCDA_UCUM_CASE_SUSPECTThe @unit looks like a letter-case slip of a UCUM unit; the value is kept.Yes
CCDA_MISSING_UNIT_ON_PQA physical quantity has a number but no @unit; it is kept as dimensionless, never defaulted.Yes
CCDA_FREE_TEXT_REFERENCE_RANGEThe reference range is free text, not a low and high interval; it is kept as text and cannot be compared as numbers.No
CCDA_RESULT_VALUE_TYPE_UNHANDLEDThe observation value's xsi:type is not one the model reads; it is read as unsupported, keeping the type name and any text.Yes

Problems, procedures, plans and status​

CodeMeaningSafety-critical
CCDA_PROBLEM_STATUS_INDETERMINATEThe problem concern's statusCode is missing or not recognized, so whether it is active or resolved cannot be said.Yes
CCDA_ALLERGEN_GRANULARITY_SUSPECTThe allergen looks coded at product level where an ingredient-level concept is expected.Yes
CCDA_PROCEDURE_MOOD_UNEXPECTEDThe procedure's moodCode is neither performed (EVN) nor a recognized planned mood; the procedure is read and left unclassified.Yes
CCDA_PLANNED_VS_PERFORMED_AMBIGUOUSThe procedure has no moodCode, so performed and planned cannot be told apart; it is left unclassified.Yes
CCDA_PLAN_ENTRY_NOT_MODELEDAn entry template is recognized but not modeled (an Instruction, a Handoff Communication, a Nutrition Recommendation, a Goal Observation); it survives only in the re-serialized XML.No
CCDA_SMOKING_STATUS_UNKNOWNSmoking status is recorded as unknown, by a nullFlavor or an "unknown" SNOMED CT concept.No
CCDA_SMOKING_STATUS_CODE_UNRECOGNIZEDThe smoking status code is not in the Smoking Status value set; it is kept as written.No

Building and editing​

buildCcda and editCcda report these on the document they return, about content the call itself wrote.

CodeMeaningSafety-critical
CCDA_MISSING_PLANNED_MEDICATION_EFFECTIVE_TIMEA Planned Medication Activity was written with no effectiveTime, which its template requires; no date is invented, so the act is written without it.No
CCDA_MISSING_SELF_CARE_ACTIVITYA Functional Status Organizer was asked for with no self-care activity, which its template requires; its findings were written as standalone observations instead.No

Profiles​

CodeMeaningSafety-critical
CCDA_PROFILE_QUIRK_APPLIEDAn active profile expected this deviation and downgraded it: the original code is on toleratedCode, the profile on profile, and expected is true.Yes

Edit error codes​

editCcda throws a CcdaEditError with one of these codes. CCDA_EDIT_ERROR_CODES holds the set, and CcdaEditErrorCode is its type.

CodeMeaning
CCDA_EDIT_NO_SOURCE_DOCUMENTThe source is not a CcdaDocument from parseCcda or buildCcda, or keeps no XML to edit.
CCDA_EDIT_NO_STRUCTURED_BODYA section edit was asked of a document with no structuredBody, such as an Unstructured Document.
CCDA_EDIT_SECTION_ALREADY_PRESENTAn add edit names a section the document already has; use replace or upsert.
CCDA_EDIT_SECTION_ABSENTA replace edit names a section the document does not have; use add or upsert.
CCDA_EDIT_REQUIRED_SECTION_MISSINGThe edit would leave the document without a section its type requires (SHALL).
CCDA_EDIT_SOURCE_MISSING_IDA revision was asked of a source whose ClinicalDocument.id is absent or carries a nullFlavor, so it names no prior version.

Build error codes​

buildCcda throws a CcdaBuildError with one of these codes, and so does editCcda for the section content it builds. CCDA_BUILD_ERROR_CODES holds the set, and CcdaBuildErrorCode is its type. The message names the field and the rule it broke, never the timestamp, code, or display name you passed.

CodeMeaning
CCDA_BUILD_UNSUPPORTED_DOCUMENT_TYPEdocumentType is not one of the types the builder writes.
CCDA_BUILD_FIELD_NOT_CARRIEDAn input was supplied that the chosen document type does not carry.
CCDA_BUILD_INVALID_TIMESTAMPA date is not a valid HL7 v3 timestamp (TS).
CCDA_BUILD_FORBIDDEN_CHARACTERA string holds a character XML 1.0 does not allow in a document.
CCDA_BUILD_CODE_REQUIREDA required coded value is missing or is not a code.
CCDA_BUILD_DISPLAY_NAME_REQUIREDA coded value has no displayName to write the narrative from.
CCDA_BUILD_RESOLUTION_WITHOUT_RESOLVED_STATUSA problem or allergy has a resolution date and a status other than "resolved".
CCDA_BUILD_ALLERGEN_REQUIREDAn allergy sets neither allergen nor noKnownAllergy: true.
CCDA_BUILD_RESULT_VALUE_FORMA result sets other than exactly one of quantity, codedValue, or stringValue.
CCDA_BUILD_PROCEDURE_VALUE_REQUIREDA procedure of kind "observation" has no value.
CCDA_BUILD_EMPTY_ORGANIZERA functional status, mental status, or family history organizer has no member.

Profile definition error codes​

defineCcdaProfile throws a CcdaProfileDefinitionError with one of these codes. CCDA_PROFILE_ERROR_CODES holds the set, and CcdaProfileErrorCode is its type.

CodeMeaning
CCDA_PROFILE_OPTIONS_REQUIREDNo options object was passed.
CCDA_PROFILE_NAME_REQUIREDname is missing, not a string, or blank.
CCDA_PROFILE_UNKNOWN_OPTIONThe options hold a key the profile engine does not know.
CCDA_PROFILE_UNKNOWN_WARNING_CODEA tolerate entry names a code that is not a warning code.
CCDA_PROFILE_SAFETY_CRITICAL_CODEA tolerate entry names a safety-critical warning code, which no profile may tolerate.
CCDA_PROFILE_RATIONALE_REQUIREDA tolerate entry has no rationale.