Back to Openemr

OpenEMR FHIR API Documentation

FHIR_README.md

latest13.8 KB
Original Source

OpenEMR FHIR API Documentation

๐Ÿ“š Complete FHIR documentation has moved to Documentation/api/FHIR_API.md

OpenEMR provides a comprehensive FHIR R4 implementation compliant with US Core 8.0 and SMART on FHIR v2.2.0.

๐Ÿš€ Quick Start

1. Enable FHIR API

Administration โ†’ Config โ†’ Connectors

  • โ˜‘ Enable OpenEMR Standard FHIR REST API

2. FHIR Base URL

Replace default with your multi-site tenant if applicable see (Multi-Tenancy Guide):

https://localhost:9300/apis/default/fhir

3. Get Capability Statement

bash
curl -X GET 'https://localhost:9300/apis/default/fhir/metadata'

No authentication required for capability statement

4. Authenticate & Access Data

bash
# Get access token (see Authentication Guide)
# Then make FHIR requests:
curl -X GET 'https://localhost:9300/apis/default/fhir/Patient' \
  -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  -H 'Accept: application/fhir+json'

๐Ÿ“– Documentation

FHIR-Specific Documentation

Complete API Documentation

โœจ FHIR Standards Compliance

StandardVersionStatus
FHIRR4 (4.0.1)โœ… Full Support
US Core8.0โœ… Compliant
SMART on FHIRv2.2.0โœ… Certified
Bulk Datav1.0โœ… Implemented
USCDIv1โœ… Supported

๐ŸŽฏ Common FHIR Tasks

Get Patient Demographics

bash
curl -X GET 'https://localhost:9300/apis/default/fhir/Patient/123' \
  -H 'Authorization: Bearer TOKEN'

โ†’ Patient Resource Docs

Search for Observations

bash
curl -X GET 'https://localhost:9300/apis/default/fhir/Observation?patient=123&category=vital-signs' \
  -H 'Authorization: Bearer TOKEN'

โ†’ Observation Resource Docs

Generate Clinical Summary (CCD)

bash
curl -X POST 'https://localhost:9300/apis/default/fhir/DocumentReference/$docref' \
  -H 'Authorization: Bearer TOKEN' \
  -H 'Content-Type: application/fhir+json' \
  --data '{"resourceType":"Parameters","parameter":[{"name":"patient","valueId":"123"}]}'

โ†’ $docref Documentation

Request Bulk Data Export

bash
curl -X GET 'https://localhost:9300/apis/default/fhir/Patient/$export' \
  -H 'Authorization: Bearer TOKEN' \
  -H 'Prefer: respond-async'

โ†’ Bulk Export Guide

Register SMART App

bash
curl -X POST 'https://localhost:9300/oauth2/default/registration' \
  -H 'Content-Type: application/json' \
  --data '{"client_name":"My SMART App","scope":"openid launch patient/Patient.rs"}'

โ†’ SMART Registration

๐Ÿ“ฆ Supported FHIR Resources

Patient-Level Resources (30+)

AllergyIntolerance, Appointment, Binary, CarePlan, CareTeam, Condition, Coverage, Device, DiagnosticReport, DocumentReference, Encounter, Goal, Immunization, Location, Medication, MedicationRequest, MedicationDispense โœจ, Observation, Organization, Patient, Person, Practitioner, PractitionerRole, Procedure, Provenance, RelatedPerson โœจ, ServiceRequest โœจ, Specimen โœจ

System-Level Resources

All patient resources plus: Group, Bulk Export operations

โœจ New in SMART v2.2.0

  • ServiceRequest - Lab orders, imaging requests, referrals
  • Specimen - Laboratory specimen tracking
  • MedicationDispense - Pharmacy dispensing records
  • RelatedPerson - Patient relationships and emergency contacts

โ†’ Complete Resource List

๐Ÿ” FHIR Search Examples

Search by Patient

bash
# All medications for a patient
GET /fhir/MedicationRequest?patient=123

# Active problems
GET /fhir/Condition?patient=123&clinical-status=active

# Recent encounters
GET /fhir/Encounter?patient=123&date=ge2024-01-01

Search by Category

bash
# Vital signs only
GET /fhir/Observation?patient=123&category=vital-signs

# Lab results only
GET /fhir/Observation?patient=123&category=laboratory

# Problem list items
GET /fhir/Condition?patient=123&category=problem-list-item

Search by Date Range

bash
# Observations since January 2024
GET /fhir/Observation?patient=123&date=ge2024-01-01

# Encounters in Q1 2024
GET /fhir/Encounter?patient=123&date=ge2024-01-01&date=le2024-03-31

โ†’ Search Parameter Guide

๐Ÿ” FHIR Authentication & Scopes

Required Scopes Format

<context>/<Resource>.<permissions>

Examples:
patient/Patient.rs              # Patient: read + search
user/Observation.cruds          # User: full access
system/Patient.$export          # System: bulk export

Permission Flags

  • c - Create
  • r - Read
  • u - Update
  • d - Delete
  • s - Search

Context Types

  • patient/ - Single patient's data
  • user/ - User's authorized data (multiple patients)
  • system/ - Unrestricted access (backend services)

โ†’ Complete Scope Reference

Granular Scopes (SMART v2.2.0) โœจ

Filter resources by category:

bash
# Vital signs only
patient/Observation.rs?category=http://terminology.hl7.org/CodeSystem/observation-category|vital-signs

# Health concerns only
patient/Condition.rs?category=http://hl7.org/fhir/us/core/CodeSystem/condition-category|health-concern

# Clinical notes only
patient/DocumentReference.rs?category=http://hl7.org/fhir/us/core/CodeSystem/us-core-documentreference-category|clinical-note

โ†’ Granular Scopes Guide

๐Ÿ”„ Bulk FHIR Exports

Export large datasets for analytics and population health:

System Export

bash
# Export all data
GET /fhir/$export

Patient Export

bash
# Export all patient compartment data
GET /fhir/Patient/$export

Group Export

bash
# Export data for specific patient group
GET /fhir/Group/1/$export

Required Scopes

system/Patient.$export          # For patient export
system/*.$bulkdata-status       # Check export status
system/Binary.read              # Download files

Workflow

  1. Initiate export โ†’ Receive Content-Location URL
  2. Poll status โ†’ Wait for completion
  3. Download NDJSON files โ†’ Process data

โ†’ Complete Bulk Export Guide

๐Ÿ“„ DocumentReference $docref (CCD Generation)

Generate Continuity of Care Documents on demand:

Generate CCD

bash
POST /fhir/DocumentReference/$docref

Parameters:

  • patient - Patient ID (required)
  • start - Start date for filtering
  • end - End date for filtering

Example Request

json
{
  "resourceType": "Parameters",
  "parameter": [
    {"name": "patient", "valueId": "123"},
    {"name": "start", "valueDate": "2024-01-01"},
    {"name": "end", "valueDate": "2024-12-31"}
  ]
}

Response

Returns DocumentReference with link to download CCD XML file.

โ†’ Complete $docref Guide

โ†’ CCD Tutorial with Screenshots

โšก SMART on FHIR Integration

Launch Types

EHR Launch - App launched from within OpenEMR:

1. User clicks app in OpenEMR
2. App receives launch token
3. App requests authorization with launch token
4. App receives patient + encounter context

Standalone Launch - App launched independently:

1. User opens app
2. App requests authorization
3. User logs in and approves
4. App receives access token

โ†’ SMART Launch Guide

Launch Contexts (SMART v2.2.0) โœจ

Patient Context:

json
{
  "patient": "123"
}

Encounter Context: โœจ NEW

json
{
  "patient": "123",
  "encounter": "456"
}

User Context:

json
{
  "fhirUser": "Practitioner/789"
}

โ†’ Launch Context Guide

๐Ÿงช Testing Your FHIR Integration

Swagger UI

Interactive API testing:

https://your-openemr-install/swagger/

Online Demos

Test against live OpenEMR instances:

Capability Statement

Discover server capabilities:

bash
curl https://localhost:9300/apis/default/fhir/metadata

SMART Configuration

Discover SMART capabilities:

bash
curl https://localhost:9300/apis/default/fhir/.well-known/smart-configuration

๐Ÿ†˜ Support & Resources

Documentation

Community

Standards

๐Ÿ“Š FHIR API Coverage

Clinical Data

โœ… Patients, Practitioners, Organizations โœ… Observations, Vital Signs, Lab Results โœ… Conditions, Problems, Diagnoses โœ… Medications, Prescriptions, Dispensing โœ… Procedures, Immunizations, Allergies

Care Coordination

โœ… Encounters, Appointments โœ… Care Plans, Care Teams, Goals โœ… Service Requests, Specimens โœ… Documents, CCD Generation

Administrative

โœ… Coverage, Related Persons โœ… Locations, Devices โœ… Provenance, Audit

โ†’ Resource Details

๐Ÿ”’ Security & Compliance

Security Features

โœ… OAuth 2.0 / OpenID Connect โœ… Granular scope-based access control โœ… PKCE for public applications โœ… Token introspection โœ… Asymmetric client authentication (JWKS) โœ… TLS/HTTPS required

Compliance

โœ… HIPAA - Protected health information โœ… ONC Cures - Information blocking prevention โœ… US Core 8.0 - US healthcare requirements โœ… FHIR R4 - HL7 standard compliance

โ†’ Security Guide

๐ŸŽ“ Tutorials & Examples

For Developers

  1. Register a SMART App
  2. Implement EHR Launch
  3. Handle Launch Context
  4. Use Granular Scopes

For System Integrators

  1. Bulk Data Export
  2. Client Credentials Auth
  3. Generate CCDs

Code Examples

โ†’ JavaScript Examples โ†’ Python Examples โ†’ cURL Examples

๐Ÿ”— Quick Reference

TopicLink
FHIR ResourcesFHIR_API.md#supported-resources
Search ParametersFHIR_API.md#search-parameters
FHIR ScopesAUTHORIZATION.md#fhir-api-scopes
AuthenticationAUTHENTICATION.md
SMART AppsSMART_ON_FHIR.md
Bulk ExportFHIR_API.md#bulk-fhir-exports
CCD GenerationFHIR_API.md#documentreference-docref-operation

FHIR Version: R4 (4.0.1) SMART Version: v2.2.0 US Core: 8.0


Documentation Attribution

Authorship

This documentation represents the collective knowledge and contributions of the OpenEMR open-source community. The content is based on:

  • Original documentation by OpenEMR developers and contributors
  • Technical specifications from the OpenEMR codebase
  • Community feedback and real-world implementation experience

AI Assistance

The organization, structure, and presentation of this documentation was enhanced using Claude AI (Anthropic) to:

  • Reorganize content into a more accessible modular structure
  • Add comprehensive examples and use cases
  • Improve navigation and cross-referencing
  • Enhance clarity and consistency across documents

All technical accuracy is maintained from the original community-authored documentation.

Contributing

OpenEMR is an open-source project. To contribute to this documentation:

Last Updated: November 2025 License: GPL v3

For complete documentation, see Documentation/api/