@onkarsabale15/fhir-r4
v1.0.1
Published
TypeScript type definitions for FHIR R4 resources
Maintainers
Readme
@onkarsabale15/fhir-r4
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,ICodingIHumanName,IAddress,IContactPointIPeriod,IQuantity,IRange,IRatioIAttachment,IAnnotation,ITiming,ISignatureIAge,IDuration,IMeta,IDosage
Type Aliases
Convenient type aliases for common patterns:
TResourceType,TBundleType,TGenderTObservationStatus,TEncounterStatus,TConditionStatusTDate,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
