@cosyte/fhir
A developer-focused FHIR toolkit for Node.js and TypeScript: an R4-first resource model, a
JSON and XML codec, and layered validation, with the same one-line ergonomics as the rest of the
@cosyte/* parser suite. It is the FHIR member of that suite and mirrors the API shape of
@cosyte/hl7, the reference parser.
@cosyte/fhir is pre-alpha and not yet published to npm. It is registered in the docs site but
disabled until it cuts its first release.
The full documentation spine (Installation, Quickstart, Core Concepts, Guides, and Troubleshooting)
is not written yet. Until then, the repository README
and its CHANGELOG.md are the authoritative, always-current account of what the parser does.
What exists today
The library is further along than this stub documents. As of the current pre-alpha it can already,
against FHIR R4 (4.0.1):
- Read and round-trip a resource through a precision-preserving JSON codec and a
zero-dependency XML codec that share one schema-free model:
decimal/integer64values are kept as their exact lexical strings and are never routed through a JavaScriptnumber(no silent dose or identifier corruption). The XML reader is XXE- and billion-laughs-proof by refusal: it rejects any<!DOCTYPEor non-predefined entity rather than resolving it. - Validate a resource across structural, cardinality, and primitive/enumerated value-domain
layers, emitting a value-free
OperationOutcome: a finding carries a coded reason and a FHIRPath location, never the value it was raised over, and the location is bounded to the published form of a FHIR name rather than echoing whatever the document put there. - Preserve the safety-critical status & negation model: it fails closed on an unknown
modifierExtensionand never drops a status, modifier, or negation. - Surface measured values by their true
value[x]type with UCUMcodeunit fidelity (never the display string, never converted), validate codesystems and binding strength without vendoring any SNOMED / CPT / LOINC content, validate against caller-supplied US Core / vendorStructureDefinitions (snapshot generation, slicing,fixed[x]/pattern[x], must-support as an obligation), and evaluate their FHIRPath invariants through a bounded, in-repo FHIRPath subset, reporting anything outside that subset asINVARIANT_UNCHECKEDrather than passing it.
What is not here yet
Honestly, and by design for a pre-alpha:
- No published package: it is not yet installable from npm, and the docs site keeps it disabled until the first release.
- No bundled terminology or profile content: there is no code-validity / value-set-membership
guarantee beyond
system+ binding strength unless you supply a terminology service, and no US Core IG corpus is bundled (US Core / vendor profiles are caller-supplied). - No typed per-resource models, no
type·profileslicing-discriminator or reslicing validation (PROFILE_SLICE_UNCHECKED), and novalidator_cli.jardifferential yet. - No narrative or full-guide documentation: see the status note above.
For the precise record of what is in the package and what is deferred, read the
repository README and CHANGELOG.md.