@drug-database/hl7v2
v0.1.0
Published
HL7v2 RXE segment helper for the Drug Database Swiss drug master — precompiled Pharmacode → RxNorm + ATC + UCUM mapping.
Maintainers
Readme
@drug-database/hl7v2
HL7v2 RXE segment helper for the Drug Database Swiss drug master. The headline value is the **precompiled Pharmacode → RxNorm + ATC
- UCUM mapping** — point at a Swiss Pharmacode, get back a CH-EPR-compatible RXE segment.
Install
npm i @drug-database/hl7v2(Marketing snippet — same as on the docs page.)
Node 18+. Zero runtime dependencies. ESM only.
Quickstart
import { rxe } from '@drug-database/hl7v2'
const seg = rxe({
pharmacode: '7680123456789',
dose: '500mg',
frequency: 'qid',
})
// "RXE|qid|...|500|mg|...|..."Without the data package
The published @drug-database/hl7v2 ships with an empty Pharmacode map. The
real lookup data lives in a separate package, @drug-database/hl7v2-data, which
is regenerated from BAG-SL + WHO ATC/DDD + RxNorm exports on every watchtower
promotion. Install both for the full experience:
npm i @drug-database/hl7v2 @drug-database/hl7v2-data@drug-database/hl7v2-data calls registerPharmacodeMapping(...) on import to
populate the lookup table at module-load time. Without it, callers can still
pass explicit dose, unit, giveCode, etc. and bypass the lookup:
rxe({
giveCode: { identifier: 'M01AE01', text: 'Ibuprofen', codingSystem: 'ATC' },
doseAmount: 400,
unit: 'mg',
frequency: 'tid',
})API
rxe(input: RxeInput): string
Render a single RXE segment. Returns a |-delimited HL7v2 string suitable for
inclusion in an OMP^O09 or RDE^O11 message.
| Field | RxeInput key | Notes |
| --- | --- | --- |
| RXE-1 | frequency | qd, bid, tid, qid, prn, … |
| RXE-2 | pharmacode / giveCode | CWE: identifier ^ text ^ codingSystem (prefers ATC when mapped) |
| RXE-3 | dose / doseAmount | Numeric dose. Parsed from dose if you pass "500mg". |
| RXE-5 | dose / unit | UCUM unit. |
| RXE-7 | instructions | Free-text SIG. |
| RXE-9 | substitution | N / G / T / C. |
| RXE-15 | prescriptionNumber | |
lookupPharmacode(code) / registerPharmacodeMapping(...entries)
Manual access to the precompiled map. Useful when you want to render your own segments or pre-fetch the resolved RxNorm code.
License
MIT
