0.0.0 • Published 2 years ago
@useplugged/models v0.0.0
Plugged FHIR Model Definitions
This library contains TypeScript type definitions for all R4 types.
Installation
Add as a dependency:
npm install --save-dev @useplugged/models
Basic Usage
Consider the following untyped code:
const myPatient = {
resourceType: 'Patient',
name: 'George Washington',
};
Keen observers will note that Patient.name
should not be a string. Instead, it should be an array of HumanName
objects.
Let's add the type definition and see what happens:
import { Patient } from '@useplugged/models';
const myPatient: Patient = {
resourceType: 'Patient',
name: 'George Wasington',
};
Now "name" is a compile error. Developer tools with TypeScript support should provide feedback. For example, VS Code adds red squigglies and a helpful error message:
So we can build a well-formed example:
import { Patient } from '@useplugged/models';
const myPatient: Patient = {
resourceType: 'Patient',
name: [
{
given: ['George'],
family: 'Washington',
},
],
};
License
Apache 2.0. Copyright © Plugged 2023
0.0.0
2 years ago