npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

fhir-models-r4

v1.0.2

Published

TypeScript class models for all FHIR R4 resources, data types, and value set enums. Unlike interface-only libraries, this package provides real instantiable classes decorated with [class-validator](https://github.com/typestack/class-validator) and [class-

Readme

fhir-models-r4

TypeScript class models for all FHIR R4 resources, data types, and value set enums. Unlike interface-only libraries, this package provides real instantiable classes decorated with class-validator and class-transformer, enabling runtime validation and plain-object-to-class transformation out of the box.

Features

  • 146 FHIR R4 resources — every resource from the official specification, from Patient to MedicinalProduct
  • 37 complex data typesHumanName, Address, CodeableConcept, Identifier, Quantity, Timing, Dosage, Money, and more
  • 140 enums — coded value sets like AdministrativeGender, ObservationStatus, BundleType, etc.
  • Proper inheritanceElementBackboneElement, ResourceDomainResource → concrete resources
  • Runtime validation — all properties decorated with class-validator (@IsOptional, @IsString, @ValidateNested, @IsEnum, etc.)
  • Plain-to-class transformation — nested objects decorated with class-transformer @Type() for automatic deserialization
  • Strict TypeScript — compiled with strict: true, full type declarations included

Installation

npm install fhir-models-r4

Quick start

import 'reflect-metadata';
import { plainToInstance } from 'class-transformer';
import { validate } from 'class-validator';
import { Patient, HumanName, AdministrativeGender } from 'fhir-models-r4';

// Create a Patient from a plain FHIR JSON object
const patient = plainToInstance(Patient, {
  resourceType: 'Patient',
  id: '123',
  gender: 'male',
  birthDate: '1990-01-01',
  name: [{ use: 'official', family: 'Jansen', given: ['Pieter'] }],
});

// Validate
const errors = await validate(patient);
if (errors.length > 0) {
  console.error('Validation failed:', errors);
} else {
  console.log('Patient is valid');
}

Construct directly

const name = new HumanName();
name.use = NameUse.Official;
name.family = 'Jansen';
name.given = ['Pieter'];

const patient = new Patient();
patient.gender = AdministrativeGender.Male;
patient.birthDate = '1990-01-01';
patient.name = [name];

Project structure

src/models/
├── base/           # Element, BackboneElement, Resource, DomainResource
├── enums/          # 140 coded value set enums
├── datatypes/      # 37 complex data types
├── resources/      # 146 FHIR R4 resources
└── index.ts

All files use kebab-case naming (e.g. practitioner-role.ts, codeable-concept.ts).

Inheritance hierarchy

Element
├── Extension
├── (all complex data types)
│
BackboneElement (extends Element)
├── (all backbone/nested structures)
│
Resource
├── Bundle
├── Binary
├── Parameters
│
DomainResource (extends Resource)
├── Patient
├── Observation
├── Encounter
└── ... (all other resources)

Scripts

| Script | Description | |--------|-------------| | npm run build | Compile TypeScript to dist/ | | npm run lint | Run ESLint | | npm run clean | Remove dist/ directory |

License

ISC