# @ahryman40k/ts-fhir-types

> Typescript / Javascript object model for FHIR standard Model follows FHIR R4 specifications.

Latest version **4.0.39** (published 2022-02-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install @ahryman40k/ts-fhir-types
pnpm add @ahryman40k/ts-fhir-types
yarn add @ahryman40k/ts-fhir-types
bun add @ahryman40k/ts-fhir-types
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.39 |
| Published | 2022-02-11 |
| First published | 2019-02-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 3.8 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 132 |
| Maintainers | ahryman40k |

## Links

- npm: https://www.npmjs.com/package/@ahryman40k/ts-fhir-types
- Repository: https://github.com/Ahryman40k/typescript-fhir-types
- Homepage: https://github.com/Ahryman40k/typescript-fhir-types#readme
- Issues: https://github.com/Ahryman40k/typescript-fhir-types/issues
- npm.io page: https://npm.io/package/@ahryman40k/ts-fhir-types

## Dependencies (3)

- [fp-ts](https://npm.io/package/fp-ts.md) ^2.11.8
- [io-ts](https://npm.io/package/io-ts.md) ^2.2.16
- [reflect-metadata](https://npm.io/package/reflect-metadata.md) ^0.1.13

## Recent versions

- 4.0.39 (latest) — 2022-02-11
- 4.0.38 — 2022-02-11
- 4.0.36 — 2021-05-26
- 4.0.34 — 2020-10-09
- 4.0.32 — 2020-06-29
- 4.0.29 — 2020-06-16
- 4.0.25 — 2020-01-28
- 4.0.24 — 2020-01-28
- 4.0.23 — 2019-06-26
- 4.0.22 — 2019-06-26
- 4.0.21 — 2019-06-15
- 4.0.20 — 2019-06-15
- 4.0.19 — 2019-06-15
- 4.0.18 — 2019-06-15
- 4.0.17 — 2019-06-15
- … 12 more at https://npm.io/package/@ahryman40k/ts-fhir-types/versions

## README

# typescript-fhir-types
Typescript / Javascript object model for FHIR standard
Model follows FHIR R4 specifications.

[![npm version](https://badge.fury.io/js/%40ahryman40k%2Fts-fhir-types.svg)](https://badge.fury.io/js/%40ahryman40k%2Fts-fhir-types)
[![Build Status](https://travis-ci.com/Ahryman40k/typescript-fhir-types.svg?branch=4.0.0)](https://travis-ci.com/Ahryman40k/typescript-fhir-types)
[![codecov](https://codecov.io/gh/Ahryman40k/typescript-fhir-types/branch/4.0.0/graph/badge.svg)](https://codecov.io/gh/Ahryman40k/typescript-fhir-types)
[![Known Vulnerabilities](https://snyk.io/test/github/Ahryman40k/typescript-fhir-types/badge.svg)](https://snyk.io/test/github/Ahryman40k/typescript-fhir-types) 
[![Project dependencies overview(Beta)](https://david-dm.org/ahryman40k/typescript-fhir-types.svg)]() 
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)

Definitions are io-ts based interfaces. See [io-ts github project](https://github.com/gcanti/io-ts) for further details. This means you can check your types at runtime.
  
## Installation
```
npm i -S @ahryman40k/ts-fhir-types
```
or
```
yarn install @ahryman40k/ts-fhir-types
```

## articles
[A medium article: Handle FHIR objects with Typescript](https://medium.com/@ahryman40k.gb/handle-fhir-objects-in-typescript-and-javascript-7110f5a0686f)

## Examples

let's imagine your server or your application is receiving a FHIR Resource like an observation from a server or any external system

```typescript
import { R4 } from '@ahryman40k/ts-fhir-types'
import { either as E } from 'fp-ts'

const json = {
    "resourceType":"Patient"   
 };

const  validationResult = R4.RTTI_Patient.decode(json)

if ( E.isLeft( validationResult) ) {
    console.log(validationResult.left);
}

if ( E.isRight( validationResult) ) {
    console.log(validationResult.right);
}
```

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
  

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 !

---
_Source: https://npm.io/package/@ahryman40k/ts-fhir-types · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
