@paq-ts-fhir/r5-datamodels
v1.2.0
Published
Generated FHIR R5 data model package
Downloads
201
Maintainers
Readme
FHIR R5 Data Model Library
The TypeScript data models in this package were generated for all FHIR R5 resources and complex types.
TypeScript classes were generated for each FHIR R5 resource and
FHIR R5 complex type as defined by their corresponding
FHIR StructureDefinition.
Background
The HAPI FHIR ecosystem (implemented in Java) includes data model classes representing FHIR resources and data types. These data model classes include a number of getters and setters for the basic properties of that data model along with many convenience methods. These HAPI FHIR data models provided the inspiration for the design of the TypeScript data models generated for this project.
A proof-of-concept (POC) project was undertaken to arrive at a design for TypeScript that could easily be applied to
generated data models.
This POC project resulted in contents for a core library that contains the base data models, implementations of the FHIR
primitive data types, and various utilities required by the data models.
These are implemented in the @paq-ts-fhir/fhir-core library.
This generated data model project takes this library as its sole dependency.
Additionally, a set of implementation patterns were identified to facilitate code generation of data models for
resources and complex data types.
Getting Started
This @paq-ts-fhir/r5-datamodels package is intended to be installed as a dependency in your TypeScript/JavaScript
project for use within a Node.js environment.
The minimum supported version of Node.js is v22.11.0 (LTS).
To install this package, run the following command in your project directory:
> npm install @paq-ts-fhir/r5-datamodels -PThis package's only dependency is the @paq-ts-fhir/fhir-core library whose only dependencies are the
Luxon and Zod libraries.
Data Model Classes
The FHIR data model class hierarchy is based on the FHIR Type Framework.
All FHIR resource data models extend either Resource or DomainResource.
According to the FHIR specification, only DomainResource, Bundle, Parameters, and Binary extend Resource.
All other FHIR resources extend DomainResource.
All FHIR complex data types extend either DataType or BackboneType.
All FHIR primitive data types extend PrimitiveType<T> where T represents the FHIR primitive as defined in the
FHIR Specification and implemented in the @paq-ts-fhir/fhir-core
library.
Additional "component" classes are also generated for each BackboneElement defined in a resource.
While generated as separate classes, these "component" classes have no meaning on their own and should only be used
as a special data type defined within a resource.
Finally, "pseudo-enumeration" classes based on a FHIR CodeSystem were generated for each primitive code element
defined in a resource or complex type.
These are generated when the code element has a binding.strength of required with a binding.valueSet URL.
These classes are used to represent the values of code elements that are defined in the FHIR specification.
Additional Information
Release Notes are available for all published FHIR data model libraries.
For more information on the data models generated by this package, refer to the API Documentation and the User Guide.
For background information on the generation of these data models, refer to content in dev-docs.
