@cosyte/ncpdp
Parse real-world, vendor-quirky NCPDP and pull fields out in one line, without reading the
(paywalled) spec. @cosyte/ncpdp is a TypeScript toolkit following the cosyte parser archetype: a
lenient parser, an immutable model, a spec-clean serializer, and a descriptive profile system for
vendor quirks. It mirrors the API shape of the reference parser, @cosyte/hl7.
Status:
0.1.0, published to npm. The public API is settled: while the version is below1.0.0, a breaking change ships in a new minor version, never a patch, and the changelog says so. The shipped surface is the SCRIPT read + serialize/build side, the Telecom read (request + response) + serialize/build side, the shared value vocabulary, and the trading-partner profile system. This documentation is gated to that surface. Where the parser does not yet do a thing, this site says so rather than promising it. Streaming, SIG generation, and EPCS are explicit non-goals for v1; see Troubleshooting & known limitations.
Two standards, one package
NCPDP is two structurally unrelated standards under one brand. Each ships as its own subpath export, so a Telecom-only or SCRIPT-only consumer stays lean:
@cosyte/ncpdp/script, the SCRIPT ePrescribing standard (XML):parseScript, thenewRxand lifecycle projections, the response spine, the structured-SIG decode, plusserializeScript/buildNewRx/buildScriptResponse.@cosyte/ncpdp/telecom, the Telecommunication claim standard (fixed-field text with FS/GS/RS framing):parseTelecom, theclaimrequest view, theadjudicationresponse view, the compound / COB / DUR / prior-authorization reads, plusserializeTelecom/buildTelecomRequest.@cosyte/ncpdp/common, the shared value vocabulary: NDC, decimal-safe money/quantity, code systems, warning/fatal types.@cosyte/ncpdp/profiles, the descriptive trading-partner profile system.
The package root (@cosyte/ncpdp) re-exports the SCRIPT, Telecom, and common surfaces for
convenience; deep subpath imports are equivalent.
Which version of each standard is decoded, and for how long, is one document. The version, the section of public law that adopts it, the date that adoption ends, and the fact that no third party has tested this package are stated once in the Conformance statement and are not restated on this page.
Install and smoke-test
npm install @cosyte/ncpdp
Confirm the package resolves and its version symbol is present:
import { VERSION } from "@cosyte/ncpdp";
typeof VERSION; // => "string"
If that resolves, the install is good. Head to the Installation page for prerequisites and module-system notes, then the Quickstart for a first useful result.
The archetype in one line
The parser is lenient by default: vendor quirks become stable-coded warnings with positional
context (byte offset for Telecom, XPath for SCRIPT), not failures. The serializer, by contrast, always
emits spec-clean output (Postel's Law). Only unrecoverable structural corruption throws a typed error.
Safety-critical dispositions are fail-safe: a failure is never quietly read as a success, and
money is never a float.
Next
- Installation: prerequisites, the XML-parser dependency, module systems.
- Quickstart: parse a SCRIPT NewRx and a Telecom claim end to end.
- Core Concepts: the implementation notes behind each read.
- Guides: task-oriented recipes for the common reads.
- Serializers and builders: the emit side, the round-trip contract, and the inputs it refuses.
- Trading-partner profiles: documenting a partner's conventions and triaging warnings against them.
- Troubleshooting and known limitations: every diagnostic this library can raise, the fail-safe rules, and the non-goals.
- Conformance: the decoded version per wire format, the section adopting it, the date that adoption ends, and the absence of any third-party conformance record.
- The API Reference documents every export, generated from source.