Skip to main content
Version: v0.0.3

Installation

@cosyte/ncpdp is a TypeScript NCPDP toolkit for Node.js. It ships dual ESM + CJS builds with per-condition type declarations, so it works from either module system without configuration, and it exposes its two standards as separate subpaths so a Telecom-only or SCRIPT-only consumer never pays for the other.

Status: pre-alpha, published to npm (public, on the 0.0.x ladder until first alpha). The install command below is live.

Prerequisites

  • Node.js >= 22. The whole @cosyte/* suite targets ES2023 / Node 22+.
  • A package manager: pnpm, npm, or yarn.
  • One runtime dependency. The Telecom side (fixed-field text) is Node stdlib only. The SCRIPT side (XML) uses a single vetted parser, fast-xml-parser: namespace-aware, and configured XXE-safe (entity resolution disabled). No further runtime dependency is added without the same review.

Install

npm install @cosyte/ncpdp

Smoke test

Confirm the package resolves and a real entry point is callable. Parse the smallest valid SCRIPT message and read its version back:

import { parseScript } from "@cosyte/ncpdp/script";

const msg = parseScript('<Message version="2017071"><Header /><Body /></Message>');

msg.header.version; // => "2017071"
Array.isArray(msg.warnings); // => true

If that resolves and returns, the install is good. Head to the Quickstart.

Module systems and subpaths

@cosyte/ncpdp is "type": "module" and exposes both conditions, so both of these resolve to the right build without extra configuration:

// ESM / TypeScript
import { parseScript } from "@cosyte/ncpdp/script";
import { parseTelecom } from "@cosyte/ncpdp/telecom";
// CommonJS
const { parseScript } = require("@cosyte/ncpdp/script");
const { parseTelecom } = require("@cosyte/ncpdp/telecom");

The four subpaths (the root @cosyte/ncpdp, @cosyte/ncpdp/script, @cosyte/ncpdp/telecom, @cosyte/ncpdp/common, and @cosyte/ncpdp/profiles) each publish per-condition types (.d.ts for import, .d.cts for require), gated by attw on every release, and resolve under both node16 and legacy node10 module resolution. Editor IntelliSense matches the build you actually load.

PHI discipline

Every example in this documentation uses synthetic fixtures: no real patient names, member IDs, prescriber NPIs, or NDCs. Do the same in your own tests: NCPDP messages carry PHI, and a fixture committed to a repository is a leak the moment it publishes. See Troubleshooting for how the parser keeps field content out of its warnings and logs.