Build E-Prescribing Transaction (NCPDP SCRIPT)
Skill: Convert a prescription into an NCPDP SCRIPT e-prescribing transaction
Region: United States Category: Health Care EDI Does: Takes a prescriber's medication order and assembles an NCPDP SCRIPT transaction — the national standard for electronic prescribing between prescribers, pharmacies, and intermediaries (Surescripts), including new prescriptions, renewals, changes, cancellations, electronic prior authorization, and controlled-substance prescribing. Spec: NCPDP SCRIPT Standard (XML; e.g. v2023011 / current adopted version)
SCRIPT is maintained by the National Council for Prescription Drug Programs. CMS adopted specific SCRIPT versions for Medicare Part D e-prescribing, and EPCS (Electronic Prescribing of Controlled Substances) carries additional DEA identity-proofing, two-factor signing, and audit requirements. Transactions almost always route through the Surescripts network. Confirm the CMS-adopted SCRIPT version and Surescripts companion requirements before building.
Transaction types
| Transaction | Purpose |
|---|---|
| NewRx | Prescriber → pharmacy: a new prescription |
| RxRenewalRequest / Response | Pharmacy ↔ prescriber: refill authorization |
| RxChangeRequest / Response | Pharmacy ↔ prescriber: therapeutic/prior-auth/clarification change |
| CancelRx / CancelRxResponse | Cancel a previously sent prescription |
| RxFill | Pharmacy → prescriber: fill/dispense status |
| NewRx (EPCS) | New prescription for a controlled substance (Schedule II–V) with DEA two-factor signature |
| ePA (PAInitiationRequest/Response, etc.) | Electronic prior-authorization exchange |
Message structure (XML)
<Message>
<Header>
<To Qualifier="..."> / <From Qualifier="..."> (routing IDs)
<MessageID>, <SentTime>, <PrescriberOrderNumber>
</Header>
<Body>
<NewRx>
<Patient> name, DOB, gender, address, contact
<Pharmacy> NCPDP Provider ID, NPI, name, address
<Prescriber> NPI, DEA (controlled), SPI, name, address, contact
<MedicationPrescribed>
DrugDescription, <DrugCoded> (NDC / RxNorm), Quantity (+ unit code),
DaysSupply, Directions (Sig), Refills, Substitutions,
WrittenDate, <DEASchedule> (controlled)
<Observation> (height/weight, situational)
</NewRx>
</Body>
</Message>
Key identifiers & code sets
| Element | Carries |
|---|---|
| NPI | prescriber and pharmacy National Provider Identifier |
| DEA number | required for controlled substances (EPCS) |
| SPI | Surescripts Prescriber Identifier (network routing) |
| NCPDP Provider ID | pharmacy identifier |
| DrugCoded | NDC (National Drug Code) and/or RxNorm RXCUI; potency/form qualifiers |
| Quantity | value + NCPDP quantity unit of measure code + dosage-form description |
| DEASchedule | controlled-substance schedule (CII–CV) for EPCS |
Data rules
- NewRx must be a complete, fillable order: patient identity, prescriber (with NPI; DEA for controlled), pharmacy, the coded drug (NDC/RxNorm), structured Sig (directions), quantity + unit, days supply, refills, and substitution permission.
- EPCS (controlled substances) requires DEA-compliant identity proofing, a two-factor electronic signature applied by the prescriber, the
DEASchedule, and a tamper-evident audit trail — these are process/security requirements layered on the message. - Response transactions must echo the linking IDs (PrescriberOrderNumber / MessageID / original transaction reference) so the renewal/change/cancel pairs to the original prescription.
- Quantity uses coded units (NCPDP UOM) — free-text quantities are non-conforming; structured Sig is strongly preferred over free-text directions.
- Routing IDs (
To/Fromwith qualifiers, SPI, NCPDP ID) must be valid on the Surescripts directory for delivery.
Worked example (NewRx — outline)
Header: From SPI=1234567 (Dr. Lee) → To NCPDP=5912345 (Acme Pharmacy); PrescriberOrderNumber=RX-1001
Patient: Jane Doe, DOB 1985-01-15, F
Prescriber: NPI 1234567893, Dr. M. Lee
Pharmacy: NCPDP 5912345, NPI 1982634...
MedicationPrescribed:
DrugDescription: Amoxicillin 500 MG Oral Capsule
DrugCoded: NDC 00093-3107-01 / RxNorm 308191
Quantity: 30 (UOM = C48542 capsule)
DaysSupply: 10
Sig: "Take 1 capsule by mouth three times daily for 10 days"
Refills: 0
Substitutions: 0 (allowed)
WrittenDate: 2025-05-31
(Non-controlled, so no DEA/DEASchedule/EPCS signature needed.) Emitted as a SCRIPT <Message><Body><NewRx> and routed via Surescripts.
Validation checklist
- CMS-adopted SCRIPT version + Surescripts companion requirements confirmed; correct transaction type
- Patient, prescriber (NPI), and pharmacy (NCPDP ID) identities complete; SPI routing valid
- Drug coded (NDC and/or RxNorm); quantity uses an NCPDP UOM code; structured Sig; days supply + refills + substitution set
- Controlled substances: DEA number,
DEASchedule, EPCS identity proofing + two-factor signature, audit trail - Response/renewal/change/cancel transactions echo the linking IDs to the original
- Routing
To/Fromqualifiers valid on the Surescripts directory - Message validates against the SCRIPT schema before transmission
Last updated: 2026-05-31 — confirm the CMS-adopted NCPDP SCRIPT version, EPCS/DEA requirements, code sets (NDC/RxNorm/UOM), and Surescripts companion rules against current NCPDP and CMS guidance before use.