EHR Integration Studio
Interactive architecture designer, US Core FHIR payload builder, and Model Context Protocol (MCP) AI agent connector for Epic, Cerner, and TEFCA.
Integration Architecture
The modern EHR landscape: standards vs. production reality
Medical device developers, SaMD teams, and AI architects building clinical integrations face an industry in transition. Under the 21st Century Cures Act, the ONC (ASTP) Health IT Certification criteria, and the Information Blocking regulations (45 CFR Part 171), hospitals and health systems are legally required to provide standardized, vendor-neutral electronic access to health data without unreasonable delay or expense.
In practice, modern hospital electronic health record (EHR) environments are dominated by four major software platforms:
- Epic Systems (Hyperspace / MyChart / Cosmos): Holding the majority of US acute-care hospital beds. Integrations operate via the Epic Connection Hub, supporting SMART on FHIR v2, CDS Hooks, and backend system services, wrapped in stringent security reviews and app approval gates.
- Oracle Health (Cerner Millennium): Enterprise clinical foundation across community, academic, and government hospital networks (including the VA EHRM program). Accessible via Oracle Health Developer Program with FHIR R4 standard conformance.
- Athenahealth (athenaOne): Dominant in ambulatory practices and specialty clinics, offering robust RESTful FHIR R4 endpoints alongside legacy JSON APIs.
- MEDITECH (Expanse): Expanding presence in regional hospital networks, exposing standard US Core FHIR APIs under ONC HTI-1 compliance mandates.
Base HL7 FHIR R4 specifies what is syntactically valid. Production EHR integrations are governed by US Core Implementation Guides, vendor data dictionaries, and institutional deployment configurations.
The most common architectural pitfall is building against the base HL7 FHIR specification without accounting for implementation profiles. Every production EHR instance enforces the US Core Implementation Guide (US Core 3.1.1 through 6.1.0), which mandates specific bindings, cardinality rules, search parameters, and provenance records. An integration that passes general FHIR schema validation will fail production EHR ingress if required US Core elements (such as Device.distinctIdentifier, Device.patient, or explicit coding systems) are omitted.
SMART on FHIR v2: authentication & session authorization
SMART on FHIR (Substitutable Medical Applications, Reusable Technologies) provides the universal security and session orchestration layer for modern health applications. Built on OAuth 2.0 (RFC 6749) and OpenID Connect Core 1.0, SMART v2 standardizes how external apps authenticate users, obtain access tokens, and establish clinical context.
| Launch Pattern | Trigger Workflow | Security Mechanism | Primary Use Case |
|---|---|---|---|
| EHR In-Workflow Launch | Clinician launches app inside EHR patient chart or flowsheeting interface | EHR-provided launch token exchanged via OAuth2 Authorization Code + PKCE | Point-of-care clinical decision support, device telemetry dashboards, surgical checklists |
| Standalone App Launch | App launched independently outside the EHR (web, mobile, or workstation) | Direct OAuth2 authorization request with interactive user login & chart selection | Patient portal apps, outpatient remote patient monitoring (RPM), field engineering consoles |
| Backend Services | Automated scheduled service, ingestion daemon, or device hub | Asymmetric JWT assertion signed with pre-registered private key (no interactive user) | Continuous medical device telemetry ingestion, nightly batch reconciliation, inventory audit sync |
The OAuth 2.0 + PKCE Handshake Sequence
SMART on FHIR mandates Proof Key for Code Exchange (PKCE) for all client types to neutralize authorization code interception vulnerabilities. The protocol handshake executes across four discrete stages:
- Capability Discovery: The client reads the EHR's public
/.well-known/smart-configurationmetadata endpoint to dynamically resolve authorization endpoints, token issuance endpoints, supported cryptographic signing algorithms, and capability statements. - Authorization Code Request: The client creates a cryptographically random
code_verifier(43–128 characters), computes the SHA-256 hashcode_challenge, and redirects the browser or embedded webview to the EHR authorization endpoint with requested scopes, client identifier, and launch context. - User Consent & Context Binding: The EHR authenticates the clinician or patient, checks role-based access permissions, binds the session to the current encounter and patient ID, and returns an authorization code to the redirect URI.
- Token Exchange: The client executes a POST request to the token endpoint presenting the authorization code and original plaintext
code_verifier. Upon cryptographic validation, the EHR returns an access token, token expiration, refresh token (if scoped), and the resolved launch context JSON.
{
"access_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6IjEweC1laHItdmsifQ...",
"token_type": "Bearer",
"expires_in": 3600,
"scope": "openid fhirUser launch/patient patient/Device.read patient/Observation.read",
"patient": "PT-9482103",
"encounter": "ENC-881204",
"need_patient_banner": false,
"smart_style_url": "https://ehr.example-health.org/theme/compact.json"
} National health data networks: TEFCA & QHINs
Historically, medical device and software vendors faced the prohibitive overhead of negotiating point-to-point Business Associate Agreements (BAAs) and custom VPN tunnels with every individual hospital system. The Trusted Exchange Framework and Common Agreement (TEFCA), established under the 21st Century Cures Act and overseen by the ONC and The Sequoia Project (the Recognized Coordinating Entity), establishes a standardized nationwide interoperability governance framework.
Under TEFCA, nationwide data exchange flows through certified Qualified Health Information Networks (QHINs). Participating healthcare organizations, clinical registries, and software systems connect to a single QHIN rather than establishing hundreds of bilateral interfaces:
- Facilitated FHIR Roadmap: While early nationwide queries relied on document-based IHE XCA/XDS.b (Cross-Enterprise Document Sharing) profiles exchanging C-CDA XML documents, TEFCA is actively transitioning to Facilitated FHIR. This enables direct, fine-grained RESTful queries for specific FHIR resources (such as
Device,Condition, andObservation) across organizational boundaries using directory-mediated endpoints. - Uniform Permitted Purposes: TEFCA establishes standardized legal and operational exchange purposes, including Treatment, Payment, Healthcare Operations, Public Health, and Individual Access Services (IAS).
- Significance for Medical Technology: Implantable device registries, post-market surveillance programs, and remote monitoring platforms can query historical records and correlate device performance across disparate health systems through a single QHIN gateway.
Medical device identifiers: UDI, GS1, & FHIR mapping
FDA 21 CFR Part 830 requires every medical device distributed in the United States to carry a Unique Device Identifier (UDI) in both human-readable interpretation (HRI) and automatic identification and data capture (AIDC) machine-readable formats. In hospital workflows, this barcode is scanned at receiving, surgical suite preparation, bedside administration, and inventory management.
A compliant UDI barcode integrates two fundamental segments:
- Device Identifier (DI): A mandatory, fixed numerical identifier for the specific device model and labeler, standardly formatted as a GS1 Global Trade Item Number (GTIN-14) or HIBCC primary data structure. The DI must be validated with an algorithmically computed Modulo 10 check digit.
- Production Identifier (PI): Variable operational data reflecting manufacturing execution: expiration date (AI 17), lot or batch number (AI 10), unique serial number (AI 21), and date of manufacture (AI 11).
When ingested into the electronic health record, the raw barcode must be parsed and mapped to the standard HL7 FHIR R4 Device resource conforming to the US Core Implantable Device Profile:
{
"resourceType": "Device",
"id": "dev-ortho-tibial-01",
"meta": {
"profile": [
"http://hl7.org/fhir/us/core/StructureDefinition/us-core-implantable-device"
]
},
"status": "active",
"udiCarrier": [
{
"deviceIdentifier": "00850012345678",
"carrierHRF": "(01)00850012345678(17)281231(10)LOT-24901(21)SN-98421",
"entryType": "barcode"
}
],
"distinctIdentifier": "00850012345678",
"manufacturer": "10x MedTech BioMaterials LLC",
"manufactureDate": "2024-06-15",
"expirationDate": "2028-12-31",
"lotNumber": "LOT-24901",
"serialNumber": "SN-98421",
"modelNumber": "NX-TIBIA-70",
"type": {
"coding": [
{
"system": "http://snomed.info/sct",
"code": "720555008",
"display": "Prosthesis, internal, joint, knee, tibial component"
}
],
"text": "Anatomic Tibial Baseplate Prosthesis"
},
"patient": {
"reference": "Patient/PT-9482103",
"display": "Patient PT-9482103"
}
} Furthermore, production integration pipelines enrich the device record by executing live queries against the FDA Global Unique Device Identification Database (GUDID) via openFDA or AccessGUDID APIs. This retrieves critical safety metadata that the physical barcode does not hold directly:
- MRI Safety Status: MR Safe, MR Conditional (with specific field strength and SAR parameters), or MR Unsafe.
- Biocompatibility & Sterile Status: Natural rubber latex warning declarations, sterile barrier validation, and single-use vs. reusable reprocessing designations.
- Regulatory Classification: FDA product codes (e.g., JWH, OVE), 510(k) or PMA clearance tracking numbers, and Global Medical Device Nomenclature (GMDN) preferred terms.
High-frequency telemetry & biomedical waveforms
Physiological monitoring hardware (such as multi-lead electrocardiographs, arterial pressure transducers, capnography sensors, and bedside ventilators) generates hundreds or thousands of telemetry data points every second. Attempting to ingest each reading as an individual scalar FHIR Observation creates immediate write-amplification failures:
| Ingestion Strategy | Network & Database Impact | Waveform Fidelity | EHR Conformance |
|---|---|---|---|
| Individual Scalar Observations (1 HTTP POST per sample) | Severe database contention; 500 writes/sec per lead quickly overwhelms database indices and triggers rate limits. | High network latency causes dropped frames, jitter, and broken morphological timing. | Anti-pattern: explicitly rejected by health IT integration teams. |
| FHIR SampledData Structures (Periodic buffered arrays) | Optimal efficiency: 1 write every 2 to 5 seconds packaging hundreds of continuous points in a single compact payload. | Exact millisecond-level morphological fidelity with explicit sampling frequency, scale factor, and calibration offsets. | Industry standard: fully conformant with HL7 FHIR Point-of-Care Devices (PoCD) profile. |
The FHIR SampledData element condenses an entire waveform sequence into a single, compact, space-delimited string of analog-to-digital converter (ADC) counts or calibrated values:
{
"resourceType": "Observation",
"id": "obs-telemetry-ecg-lead-ii",
"status": "final",
"category": [
{
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/observation-category",
"code": "vital-signs"
}
]
}
],
"code": {
"coding": [
{
"system": "http://loinc.org",
"code": "131328",
"display": "MDC_ECG_LEAD_II"
}
],
"text": "ECG Lead II Telemetry Waveform"
},
"subject": {
"reference": "Patient/PT-9482103"
},
"device": {
"reference": "Device/dev-telemetry-monitor-04"
},
"valueSampledData": {
"origin": {
"value": 0,
"unit": "mV",
"system": "http://unitsofmeasure.org",
"code": "mV"
},
"period": 4,
"factor": 0.001,
"lowerLimit": -2048,
"upperLimit": 2047,
"dimensions": 1,
"data": "12 18 24 32 45 80 140 280 620 1050 1420 1100 450 110 35 22 18"
}
}
In this architecture, period: 4.0 indicates a 250 Hz sampling frequency (1000 ms / 250 = 4.0 ms interval). factor: 0.001 scales raw integer values by 0.001 to reconstitute calibrated millivolt readings. Terminology binding uses IEEE 11073-10101 (MDC) nomenclature mapped to LOINC codes, establishing unambiguous semantics for clinical alarm generation and cardiac monitoring algorithms.
AI agents & LLMs in clinical workflows: the MCP bridge
As healthcare organizations explore autonomous AI agents, clinical copilots, and LLM-assisted analysis, the interface between the AI reasoning engine and the EHR represents a critical safety boundary.
Directly exposing production EHR databases or unconstrained FHIR write endpoints to an LLM introduces severe risks: hallucinated clinical values, inadvertent data leakage, unauthorized write operations, and lack of reproducible audit trails.
An AI agent must never be granted direct database credentials. The agent should interact solely with an intermediary tool server via Model Context Protocol (MCP), where every read is downscoped and every write requires named human approval.
The Model Context Protocol (MCP) Integration Pattern
The Model Context Protocol (MCP) standardizes how language models communicate with external tools, databases, and APIs. In healthcare architectures, an EHR MCP Server acts as an air-gapped proxy that sits between the agent and the hospital FHIR gateway:
- Strictly Scoped Tool Definitions: Instead of executing arbitrary HTTP calls, the agent invokes discrete, validated MCP tools with rigid JSON schema contracts (e.g.,
query_patient_vitals,inspect_implantable_devices,stage_observation_draft). - Ephemeral Token Isolation: The MCP server authenticates to the EHR using short-lived SMART on FHIR tokens bound to the specific clinician session. The agent receives only filtered, de-identified or minimally necessary context. No patient data is retained or used for model training.
- Deterministic Human-in-the-Loop (HITL) Gate: The MCP bridge strictly segregates read tools from state-mutating tools. An agent may draft an observation, summarize telemetry, or formulate an encounter note, but the EHR transaction is staged in a holding buffer. The write endpoint remains physically locked until a named human clinician reviews and cryptographically signs the record.
- Auditable FHIR AuditEvent Generation: Every tool call, agent deliberation step, and human disposition triggers an immutable FHIR
AuditEventresource, satisfying 21 CFR Part 11 electronic records regulations and the HIPAA Security Rule.
{
"name": "stage_device_observation",
"description": "Stages a calibrated medical device telemetry observation for human clinical review before EHR ingestion.",
"inputSchema": {
"type": "object",
"properties": {
"patient_id": {
"type": "string",
"description": "EHR Patient Identifier"
},
"device_udi": {
"type": "string",
"description": "Device GTIN-14 Identifier"
},
"metric_loinc": {
"type": "string",
"description": "LOINC terminology code"
},
"observed_value": {
"type": "number",
"description": "Calibrated numeric measurement"
},
"unit": {
"type": "string",
"description": "UCUM measurement unit"
},
"clinical_rationale": {
"type": "string",
"description": "Agent analysis and confidence score"
}
},
"required": [
"patient_id",
"device_udi",
"metric_loinc",
"observed_value",
"unit",
"clinical_rationale"
]
}
} The 10xAnd interoperability and device tool suite
We build free, ungated tools to help device engineers, regulatory leads, and healthtech architects inspect and test interoperability workflows without waiting weeks for vendor sandbox access.
| Tool | What It Does | Standards & Datasets | Action |
|---|---|---|---|
| FHIRBridge MD | Convert medical device barcodes to HL7 FHIR R4 Device resources, simulate SMART on FHIR app launches, and inspect telemetry waveforms. | HL7 FHIR R4 · FDA GUDID · SMART on FHIR · IEEE 11073 | Launch FHIRBridge MD → |
| UDIScope | Reverse-engineer medical device barcodes, verify GTIN-14 check digits, and inspect public FDA GUDID registration records. | GS1-128 · HIBCC · openFDA GUDID | Open UDIScope → |
| MedLabel Studio | Generate GS1 DataMatrix symbols, place ISO 15223-1 symbols, and lint device labels against 21 CFR Part 801 requirements. | GS1 General Specs · 21 CFR 801 · ISO 15223-1 | Open MedLabel Studio → |
| Cadence MD | Model medical device and SaMD milestone schedules using Monte Carlo simulation and reference-class forecasting. Plan stays local. | Local engine · Reference-class priors · MCP Server | Open Cadence MD → |
| PredicateScope | Search every 510(k) under an FDA product code, with clearance durations computed directly from public records. | openFDA 510(k) database · Live query | Open PredicateScope → |
| Clearance Timeline Estimator | Empirical review duration distributions (P50, P80, P90) from receipt to decision for cleared 510(k) submissions. | openFDA snapshot · Historical distributions | Open Timeline Estimator → |
Engineering and regulatory notice
The architectures, code payloads, and data formats described on this page are provided for educational and engineering planning purposes. Integration with commercial EHR platforms requires authorized access agreements, production security reviews, and vendor-specific developer enrollment.
This page provides educational technical engineering specifications. It is not clinical decision support, not medical consultation, and not legal counsel. Interoperability architectures must be verified and validated under a 21 CFR § 820.30 Quality Management System.
Questions we get
What is the primary difference between SMART on FHIR v1 and SMART on FHIR v2?
SMART on FHIR v2 introduces granular resource-level scopes (e.g., patient/Observation.rs?category=vital-signs), mandatory PKCE (RFC 7636) for all confidential and public clients, asymmetric client authentication via signed JSON Web Tokens (private_key_jwt), and standardized user identity context via OpenID Connect. SMART v2 also aligns with ONC HTI-1 certification criteria for US Core 6.1.
Why can high-frequency physiological waveforms not be stored as individual FHIR Observation resources?
Continuous physiological monitors sample at 250 Hz to 1000 Hz. Ingesting 500 individual FHIR Observation resources per second per patient would saturate EHR database write throughput, overwhelm indexing pipelines, and incur massive storage overhead. FHIR addresses this using the Observation.valueSampledData datatype, which compresses continuous timeseries points into space-delimited text arrays representing calibrated millivolt increments.
How does TEFCA exchange differ from direct SMART on FHIR EHR integration?
Direct SMART on FHIR integrations require bilateral registration, approval, and Business Associate Agreements (BAAs) with each individual health system or EHR vendor developer portal. The Trusted Exchange Framework and Common Agreement (TEFCA) enables nationwide federated exchange through certified Qualified Health Information Networks (QHINs) governed by a single Common Agreement, allowing cross-organizational query and response without individual vendor connections.
What is the architectural purpose of Model Context Protocol (MCP) in clinical AI systems?
Model Context Protocol (MCP) provides an open, sandboxed protocol for connecting large language model (LLM) agents to external EHR tools and datasets. In medical device environments, MCP ensures that autonomous agent actions are mediated through typed schemas and deterministic Human-in-the-Loop review gates—preventing unauthorized or unreviewed direct write calls to production electronic health records.
What distinguishes an EHR In-Workflow Launch from a Standalone App Launch?
An EHR In-Workflow Launch occurs directly inside the clinician charting interface (e.g., Epic Hyperspace or Cerner PowerChart). The EHR supplies an opaque launch identifier that binds the session to the currently active patient and encounter. A Standalone App Launch is initiated externally by a clinician or patient portal, requiring an explicit patient authorization picker during the OAuth2 handshake.
How are FDA Global UDI Database (GUDID) records linked to FHIR R4 Device resources?
A medical device barcode contains the Device Identifier (DI) and Production Identifiers (PI: lot, serial, expiration). In FHIR R4, the DI (GTIN-14) is mapped to Device.udiCarrier.deviceIdentifier and Device.distinctIdentifier. EHR systems query the FDA AccessGUDID API using this DI to populate brand name, MRI safety status, latex warnings, and premarket submission numbers directly into the electronic patient chart.
Limited intake