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

@onkarsabale15/fhir-r4

v1.0.1

Published

TypeScript type definitions for FHIR R4 resources

Readme

@onkarsabale15/fhir-r4

npm version License: ISC

TypeScript type definitions and enums for FHIR R4 resources

A comprehensive, type-safe TypeScript library providing complete type definitions for FHIR R4 (Fast Healthcare Interoperability Resources) standard. This package enables developers to build healthcare applications with full IntelliSense support and compile-time type checking.


📦 Installation

npm install @onkarsabale15/fhir-r4

🚀 Quick Start

import { IPatient, EResourceType, EGender } from '@onkarsabale15/fhir-r4';

const patient: IPatient = {
  resourceType: EResourceType.PATIENT,
  id: 'patient-123',
  name: [{ given: ['John'], family: 'Doe' }],
  gender: EGender.MALE,
  birthDate: '1990-01-01'
};

📖 Usage

Working with Resource Types

This package exports TypeScript interfaces (prefixed with I) and enums (prefixed with E) for FHIR R4 resources.

Patient Resource Example

import { 
  IPatient, 
  IHumanName, 
  IContactPoint,
  EResourceType, 
  EGender 
} from '@onkarsabale15/fhir-r4';

const patientName: IHumanName = {
  use: 'official',
  given: ['John', 'Michael'],
  family: 'Doe',
  prefix: ['Mr.']
};

const contactPoint: IContactPoint = {
  system: 'phone',
  value: '+1-555-0123',
  use: 'home'
};

const patient: IPatient = {
  resourceType: EResourceType.PATIENT,
  id: 'patient-123',
  active: true,
  name: [patientName],
  telecom: [contactPoint],
  gender: EGender.MALE,
  birthDate: '1990-01-01'
};

Observation Resource Example

import { 
  IObservation, 
  ICodeableConcept,
  IQuantity,
  IReference,
  EResourceType,
  EObservationStatus 
} from '@onkarsabale15/fhir-r4';

const observation: IObservation = {
  resourceType: EResourceType.OBSERVATION,
  id: 'obs-001',
  status: EObservationStatus.FINAL,
  code: {
    coding: [{
      system: 'http://loinc.org',
      code: '85354-9',
      display: 'Blood pressure panel'
    }],
    text: 'Blood Pressure'
  },
  subject: {
    reference: 'Patient/patient-123',
    display: 'John Doe'
  },
  effectiveDateTime: '2024-01-15T10:30:00Z',
  valueQuantity: {
    value: 120,
    unit: 'mmHg',
    system: 'http://unitsofmeasure.org',
    code: 'mm[Hg]'
  }
};

Bundle Resource Example

import { 
  IBundle, 
  IBundleEntry,
  EResourceType,
  EBundleType 
} from '@onkarsabale15/fhir-r4';

const bundle: IBundle = {
  resourceType: EResourceType.BUNDLE,
  type: EBundleType.COLLECTION,
  timestamp: '2024-01-15T12:00:00Z',
  entry: [
    {
      fullUrl: 'Patient/patient-123',
      resource: patient
    },
    {
      fullUrl: 'Observation/obs-001',
      resource: observation
    }
  ]
};

Using Enums

The package provides enums for common FHIR value sets:

import { 
  EResourceType,
  EGender,
  EObservationStatus,
  EBundleType,
  EEncounterStatus,
  EConditionStatus
} from '@onkarsabale15/fhir-r4';

// Resource types
const patientType = EResourceType.PATIENT; // "Patient"
const observationType = EResourceType.OBSERVATION; // "Observation"

// Gender values
const male = EGender.MALE; // "male"
const female = EGender.FEMALE; // "female"

// Status values
const final = EObservationStatus.FINAL; // "final"
const preliminary = EObservationStatus.PRELIMINARY; // "preliminary"

🎯 Features

  • Full FHIR R4 Compliance - Implements FHIR R4 specification
  • Type Safety - Complete TypeScript interfaces with strict typing
  • IntelliSense Support - Rich IDE autocomplete and documentation
  • Zero Runtime Dependencies - Pure TypeScript type definitions
  • Tree-Shakeable - Import only what you need
  • Comprehensive Coverage - 34+ resource types and primitives

📚 Available Resources

Clinical Resources (34 total)

Core Resources:

  • Patient, Practitioner, PractitionerRole, Organization, RelatedPerson, Person

Clinical:

  • Encounter, Observation, Condition, Procedure, DiagnosticReport, Specimen

Medications:

  • Medication, MedicationRequest, MedicationStatement, MedicationAdministration, Immunization

Care Provision:

  • CarePlan, CareTeam, Goal, ServiceRequest, Task

Documents & Communication:

  • DocumentReference, Appointment, Flag

Administrative:

  • Location, Device, Account, Coverage, EpisodeOfCare

Grouping:

  • Bundle, List, Group

Allergies:

  • AllergyIntolerance

Primitive Types

All FHIR primitive data types are included:

  • IIdentifier, IReference, ICodeableConcept, ICoding
  • IHumanName, IAddress, IContactPoint
  • IPeriod, IQuantity, IRange, IRatio
  • IAttachment, IAnnotation, ITiming, ISignature
  • IAge, IDuration, IMeta, IDosage

Type Aliases

Convenient type aliases for common patterns:

  • TResourceType, TBundleType, TGender
  • TObservationStatus, TEncounterStatus, TConditionStatus
  • TDate, TDateTime, TInstant

🔧 TypeScript Configuration

For best results, use strict TypeScript settings:

{
  "compilerOptions": {
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "moduleResolution": "node"
  }
}

🤝 Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.

Development Setup

# Clone the repository
git clone https://github.com/onkarsabale15/fhir-r4.git

# Install dependencies
npm install

# Build the package
npm run build

📄 License

ISC License - see LICENSE file for details


🔗 Related Resources


📝 Notes

This package provides type definitions only. For runtime validation and builder classes with method chaining, consider creating a separate companion package or using existing FHIR validation libraries.


Made with ❤️ for the healthcare developer community