Skip to main content
Version: v0.1.7

Diagnostic codes

Every code below is a stable string exported from the package root in a frozen registry (SCRIPT_FATAL_CODES, SCRIPT_WARNING_CODES, SCRIPT_BUILD_CODES, and the three TELECOM_ registries), each with its fixed message in the matching _MESSAGES registry. Renaming or removing a code is a breaking change. A message never carries any part of the input.

  • A fatal is thrown by a parser as NcpdpScriptParseError or NcpdpTelecomParseError, with the code on .code. Nothing is returned.
  • A warning is collected on the result's .warnings, each with a position: an XPath for SCRIPT, a byte offset (and the field id, when there is one) for Telecom. The read went on.
  • A build code is thrown by a builder or serializer as NcpdpScriptBuildError or NcpdpTelecomBuildError. Nothing is written.

SCRIPT fatals​

CodeThrown when
EMPTY_INPUTThe input was empty or whitespace only.
NCPDP_SCRIPT_NOT_XMLThe input did not parse as XML, or carried a <!DOCTYPE> or <!ENTITY> (the XXE boundary).
NCPDP_SCRIPT_NO_MESSAGE_ROOTThe XML was well formed, but its root element is not <Message>.
NCPDP_SCRIPT_UNSUPPORTED_VERSIONThe declared version predates the XML-era SCRIPT this package decodes (Conformance statement).

Telecom fatals​

CodeThrown when
EMPTY_INPUTThe input was empty.
NCPDP_TELECOM_NO_HEADERThe transmission is too short to hold the fixed Transaction Header.
NCPDP_TELECOM_INVALID_FRAMINGA non-empty body carried no FS, GS, or RS framing bytes. A separator is never guessed.
NCPDP_TELECOM_UNSUPPORTED_VERSIONThe version stamp is not one this package recognizes at the offset it read (Conformance statement, which gives the outcome for each direction).

SCRIPT warnings​

CodeWhat the reader did
NCPDP_SCRIPT_VERSION_ABSENTFound no version declared on the message and parsed it best-effort rather than refusing it.
NCPDP_SCRIPT_UNSUPPORTED_VERSION_TOLERATEDRead a version string it does not model, parsed the document against the same XML-era field model, and surfaced the string verbatim.
NCPDP_SCRIPT_UNSUPPORTED_TRANSACTIONMet a transaction body it does not model and surfaced it as unsupported, naming the transaction only when its element name is one it recognizes.
NCPDP_SCRIPT_MISSING_REQUIRED_ELEMENTLeft a required element of the detected transaction undefined rather than inventing a value to fill it.
NCPDP_SCRIPT_STRENGTH_CODED_AND_EXPLICITFound a coded drug and an explicit Strength together, surfaced both verbatim, and reconciled neither into a single answer.
NCPDP_SCRIPT_RESPONSE_AMBIGUOUS_DISPOSITIONFound more than one response body and reported the most conservative disposition, so a failure is never masked by a success beside it.
NCPDP_SCRIPT_LIFECYCLE_AMBIGUOUS_OUTCOMEFound more than one outcome on a lifecycle response and chose by fail-safe precedence, so a denial is never masked by an approval beside it.
NCPDP_SCRIPT_LIFECYCLE_OUTCOME_UNRECOGNIZEDFound no recognized outcome on a lifecycle response and reported it as unknown rather than assuming an approval.
NCPDP_SCRIPT_SIG_STRUCTURED_LOSSYDecoded a structured <Sig> into an additive, lossy view while the free-text SigText stayed authoritative and verbatim.
NCPDP_SCRIPT_SIG_AMBIGUOUS_DOSERead a dose structure it could not resolve to one quantity and reported the dose as absent rather than guessing a number.

Telecom warnings​

CodeWhat the reader did
NCPDP_TELECOM_VF6_NOT_DECODEDRecognized the F6 stamp on a request, surfaced it on header.versionRelease, and read no positional field rather than read one at offsets it cannot trust.
NCPDP_TELECOM_UNKNOWN_SEGMENTMet a Segment Identification code it does not name, kept the segment and every field verbatim, and left only the paraphrased name absent.
NCPDP_TELECOM_MALFORMED_FIELDMet a field token too short to carry a 2-character identifier and kept it verbatim with an empty id rather than dropping the bytes.
NCPDP_TELECOM_MISSING_SEGMENT_IDMet a segment that did not begin with an AM field, kept its fields, and left the segment id empty because it could not be read where it belongs.
NCPDP_TELECOM_MALFORMED_SEGMENT_IDMet an AM value that is not 2 characters, kept it in segment.fields verbatim, and did not promote it onto segment.segmentId.
NCPDP_TELECOM_TRANSACTION_COUNT_MISMATCHFound that the declared Transaction Count and the number decoded disagree, kept every decoded transaction, and enforced no maximum.
NCPDP_TELECOM_STATUS_CONFLICTFound reject codes beside a status claiming payment and resolved the disposition to rejected, because a reject always wins.
NCPDP_TELECOM_UNKNOWN_REJECT_CODEKept a Reject Code it does not recognize verbatim, in wire order, with known: false, and dropped nothing.
NCPDP_TELECOM_UNKNOWN_RESPONSE_STATUSKept a Transaction Response Status it does not model verbatim and read the disposition as unknown, never as paid.
NCPDP_TELECOM_COMPOUND_COUNT_MISMATCHFound that the declared ingredient count and the number decoded disagree, and kept every decoded ingredient.
NCPDP_TELECOM_COB_COUNT_MISMATCHFound that the declared other-payer count and the number of blocks decoded disagree, and kept every decoded block.
NCPDP_TELECOM_UNKNOWN_DUR_REASONKept a Reason For Service code it does not recognize verbatim and never dropped the interaction it belonged to.

Build codes​

The builders refuse input that is invalid by construction, and the serializers refuse a model they cannot write honestly. Serializers and builders gives each rule in full.

SCRIPT (NcpdpScriptBuildError):

CodeRefused because
NCPDP_SCRIPT_BUILD_MISSING_MEDICATIONA NewRx has no prescribed-medication description.
NCPDP_SCRIPT_BUILD_MISSING_RESPONSE_CODEA Status, Error, or Verify has no <Code>.
NCPDP_SCRIPT_BUILD_INVALID_CHARACTERA supplied value carries a control character that XML 1.0 does not allow.
NCPDP_SCRIPT_BUILD_UNSUPPORTED_TRANSACTIONThe message body is a transaction this library does not model; raised by the serializer and toString().

Telecom (NcpdpTelecomBuildError):

CodeRefused because
NCPDP_TELECOM_BUILD_MISSING_TRANSACTION_CODEThere is no Transaction Code (103-A3), so the request cannot route.
NCPDP_TELECOM_BUILD_MISSING_SEGMENT_IDA segment has no Segment Identification (111-AM) code.
NCPDP_TELECOM_BUILD_INVALID_SEGMENT_IDA Segment Identification code is not exactly 2 characters.
NCPDP_TELECOM_BUILD_INVALID_FIELD_IDA data field's id is not a 2-character identifier.
NCPDP_TELECOM_BUILD_EMBEDDED_CONTROL_CHARACTERA supplied value carries an FS, GS, or RS control character, which would corrupt the framing.
NCPDP_TELECOM_BUILD_FIELD_TOO_LONGA fixed-width header field is longer than its wire width.
NCPDP_TELECOM_BUILD_MULTI_TRANSACTION_EMITThe model carries more than one decoded transaction, and the serializer writes one.

Reference: the registries are in the API reference.

Next​