Definitions are io-ts based interfaces. See io-ts github project for further details. This means you can check your types at runtime.
npm i -S @ahryman40k/ts-fhir-types
yarn install @ahryman40k/ts-fhir-types
let imagine you server or your application is receiving a FHIR Resource like an observation from a server or any external system
There is 2 points:
- You would like to have strongly typed types (typescript)
- You would validate data returned from server and test their validity against FHIR standard
// Import requested objects;// validation succeededconst validationResult = R4RTTI_Observation // => Right if good, Left if notThrowReporter;const obs: R4.IObservation = <R4IObservation> schemaValidationResultvalue;
FHIR resources are also provided as interface, so you can inherit and implement your own object implementation.
Please don't hesitate to give me advice and feedback !