fhir-integration-architecture

Use this skill when architecting how Health Cloud connects to external EHR/EMR systems via FHIR R4 — covering integration pattern selection, transformation layer design, MuleSoft Accelerator usage, and EMR bidirectional sync topology. NOT for individual FHIR REST API call implementation, NOT for FHIR object-level data mapping or Apex code that reads/writes specific Health Cloud objects, and NOT for HL7 v2 message parsing internals.

Best use case

fhir-integration-architecture is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Use this skill when architecting how Health Cloud connects to external EHR/EMR systems via FHIR R4 — covering integration pattern selection, transformation layer design, MuleSoft Accelerator usage, and EMR bidirectional sync topology. NOT for individual FHIR REST API call implementation, NOT for FHIR object-level data mapping or Apex code that reads/writes specific Health Cloud objects, and NOT for HL7 v2 message parsing internals.

Teams using fhir-integration-architecture should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/fhir-integration-architecture/SKILL.md --create-dirs "https://raw.githubusercontent.com/PranavNagrecha/AwesomeSalesforceSkills/main/skills/architect/fhir-integration-architecture/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/fhir-integration-architecture/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How fhir-integration-architecture Compares

Feature / Agentfhir-integration-architectureStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Use this skill when architecting how Health Cloud connects to external EHR/EMR systems via FHIR R4 — covering integration pattern selection, transformation layer design, MuleSoft Accelerator usage, and EMR bidirectional sync topology. NOT for individual FHIR REST API call implementation, NOT for FHIR object-level data mapping or Apex code that reads/writes specific Health Cloud objects, and NOT for HL7 v2 message parsing internals.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# FHIR Integration Architecture

This skill activates when an architect must decide how Health Cloud will connect to an external EHR or EMR system using FHIR R4. It covers the four canonical sync patterns, the mandatory transformation layer, and how MuleSoft Accelerator for Healthcare fits into the topology. It does not cover low-level Apex coding, individual object mappings, or HL7 v2 parsing internals.

---

## Before Starting

Gather this context before working on anything in this domain:

- **Confirm Health Cloud is enabled** and that the FHIR R4 feature is licensed. The Generic FHIR Client and FHIR ingestion features require Health Cloud, not just core Salesforce.
- **Clarify data freshness requirements.** Real-time clinician-facing use cases require a different pattern than overnight batch reconciliation. Mismatched pattern selection is the most common architectural error.
- **Identify whether HL7 v2 legacy feeds exist** alongside FHIR R4 endpoints. Many EMRs (Epic, Cerner) emit both. HL7 v2 ADT/ORU messages cannot be ingested directly into Health Cloud and require MuleSoft conversion to FHIR R4 first.
- **Confirm whether integration is inbound only or bidirectional.** Bidirectional sync introduces write-back conflict resolution complexity that must be designed explicitly.
- **Check the 26-resource limit.** Salesforce's FHIR R4 implementation maps approximately 26 FHIR R4 resource types. Resources outside this set cannot be stored in Health Cloud's clinical data model without custom extension objects.

---

## Core Concepts

### Health Cloud is NOT a Conformant FHIR Server

Salesforce Health Cloud is a FHIR-aware CRM platform, not a fully conformant FHIR server. It supports approximately 26 FHIR R4 resource types mapped to its clinical data model. Data is stored in a denormalized relational structure across child objects — not in the one-to-many FHIR resource graph model. Raw FHIR bundles cannot be persisted directly. Every inbound FHIR payload must pass through a transformation layer that maps FHIR elements to Health Cloud object fields before storage. Architects who treat Health Cloud as a FHIR endpoint will design the wrong data flow.

### The Four Canonical Sync Patterns

Health Cloud FHIR R4 supports four documented integration patterns. Pattern selection drives every downstream architectural decision.

**Pattern 1 — Real-Time REST Query (Generic FHIR Client):** Health Cloud queries an external FHIR server on demand, typically triggered by a user opening a patient record. Data is fetched at query time and displayed or stored transiently. No persistent copy is written to Health Cloud objects unless a separate write step is implemented. Best for supplemental reference data that does not need to live in Salesforce long-term.

**Pattern 2 — Event-Driven Inbound Ingestion:** An external system pushes FHIR resources into Salesforce via Platform Events or a REST inbound endpoint. MuleSoft or another middleware layer receives the EMR event, transforms the payload, and writes to Health Cloud. Appropriate for real-time notifications such as ADT events (admissions, discharges, transfers) that need to create or update records immediately.

**Pattern 3 — Bulk FHIR Batch Retrieval:** Uses the FHIR `$export` operation to retrieve large volumes of FHIR resources from an EMR in bulk, typically on a schedule. Payloads are NDJSON files that must be transformed before loading into Health Cloud. Appropriate for initial data migration or nightly reconciliation of large patient populations.

**Pattern 4 — Scheduled EMR Bidirectional Sync:** A scheduled integration job reads changes from both the EMR and Health Cloud, reconciles differences, and writes updates in both directions. This is the most complex pattern and requires explicit conflict resolution rules. Appropriate when Health Cloud is a system of record for certain data (e.g., care plans) that must flow back to the EMR.

### Transformation Layer is Mandatory

Every FHIR integration pattern requires a transformation layer between the FHIR resource representation and Health Cloud's object model. MuleSoft Accelerator for Healthcare provides pre-built DataWeave transformations for Epic and Cerner that map common FHIR R4 resources (Patient, Encounter, Observation, Condition, MedicationRequest) to Health Cloud objects. For custom EMRs or resources not covered by the Accelerator, custom DataWeave or Apex-based transformation must be built. The transformation layer must handle FHIR Bundle unwrapping, resource type routing, and identifier cross-referencing.

### HL7 v2 Requires Conversion Before Ingestion

Many production EMR environments emit both FHIR R4 and HL7 v2 messages (lab results as ORU^R01, ADT events as ADT^A01/A08). HL7 v2 is a pipe-delimited message format that Health Cloud has no native parser for. MuleSoft Accelerator for Healthcare includes HL7 v2 to FHIR R4 conversion assets. Any architecture that receives HL7 v2 feeds must route them through MuleSoft (or an equivalent middleware) for conversion before the FHIR ingestion pipeline begins.

---

## Common Patterns

### Real-Time Clinical Data Supplementation (Generic FHIR Client)

**When to use:** A clinician or care coordinator opens a patient record in Health Cloud and needs to see the latest vitals, lab results, or medications from an external EHR in real time. Data does not need to persist in Salesforce between sessions.

**How it works:**
1. Configure a Named Credential pointing to the external FHIR server endpoint.
2. Enable the Generic FHIR Client in Health Cloud setup and associate it with the Named Credential.
3. A Lightning Web Component or Flow on the patient record page triggers a FHIR query (e.g., `GET /Patient/{id}/Observation`) when the record loads.
4. Results are displayed inline. Optionally, a subset of critical values can be written back to Health Cloud object fields for audit or alerting purposes.

**Why not the alternative:** Storing every real-time query result as persistent Health Cloud records creates record bloat and stale data problems. The Generic FHIR Client pattern avoids this by keeping Health Cloud as the system of engagement without duplicating the EHR's source-of-truth data.

### Event-Driven ADT Ingestion via MuleSoft

**When to use:** The EMR fires admission, discharge, and transfer events that must immediately create or update Health Cloud episode records, trigger care gap alerts, or enroll patients in care programs.

**How it works:**
1. EMR publishes ADT events (HL7 v2 ADT^A01 or FHIR Encounter resource) to a message bus or webhook.
2. MuleSoft Accelerator for Healthcare receives the event, converts HL7 v2 to FHIR R4 if necessary, and executes the DataWeave transformation to Health Cloud object format.
3. MuleSoft calls the Health Cloud REST API or Composite API to create/update the Patient, EpisodeOfCare, or related objects.
4. A Platform Event is optionally published to trigger downstream Flows or Apex for care plan enrollment or task creation.

**Why not the alternative:** Polling the EMR on a schedule for new encounters introduces minutes-to-hours of latency for time-sensitive workflows like care gap closure at point of admission.

---

## Decision Guidance

| Situation | Recommended Pattern | Reason |
|---|---|---|
| Clinician needs latest EHR data on record open; data need not persist in Salesforce | Real-Time REST Query (Generic FHIR Client) | Avoids data duplication and stale record issues; data is always fetched live from source of truth |
| ADT events (admit/discharge/transfer) must trigger immediate Salesforce record updates or workflows | Event-Driven Inbound Ingestion | Lowest latency; EMR push model avoids polling overhead |
| Initial load or nightly reconciliation of large patient populations (10k+ records) | Bulk FHIR Batch ($export) | Purpose-built for high-volume extraction; NDJSON format is efficient for batch transform pipelines |
| Health Cloud care plans or clinical notes must flow back to the EMR | Scheduled EMR Bidirectional Sync | Only pattern that handles write-back; requires explicit conflict resolution design |
| EMR exposes only HL7 v2 (no FHIR R4 endpoint) | Event-Driven Inbound via MuleSoft with HL7 v2 conversion | MuleSoft Accelerator provides HL7 v2 to FHIR R4 conversion; output feeds the standard ingestion pipeline |
| Multiple patterns are needed simultaneously (e.g., real-time view + nightly sync) | Hybrid: Generic FHIR Client for on-demand reads + Bulk for baseline population | Common production topology; ensure named credentials and transformation configs are shared |

---

## Recommended Workflow

Step-by-step instructions for an architect working on FHIR integration design:

1. **Gather requirements against the four pattern dimensions.** Confirm data freshness SLA, volume profile, directionality, and whether HL7 v2 feeds exist. Document findings before any design work begins.

2. **Map each data domain to a pattern.** Not all clinical data domains require the same pattern. Vitals and labs may be real-time reads; ADT events may be event-driven; medication history may be bulk. Create a data domain-to-pattern matrix.

3. **Confirm the transformation layer scope.** For each pattern, identify which FHIR R4 resources are involved and whether they fall within Health Cloud's supported 26-resource set. For unsupported resources, design custom extension objects or determine whether they can be stored as external data references.

4. **Design the middleware topology.** If MuleSoft is in scope, confirm whether MuleSoft Accelerator for Healthcare assets cover the EMR (Epic, Cerner have pre-built assets; custom EMRs require custom DataWeave). Document where HL7 v2 conversion occurs in the pipeline.

5. **Design error handling and retry logic for each pattern.** Real-time queries need circuit breaker patterns. Event-driven ingestion needs dead-letter queues. Bulk jobs need idempotent upsert logic (use the EMR patient identifier as the external ID in Health Cloud).

6. **Validate the architecture against the review checklist** (see below) before presenting to stakeholders or handing off to implementation teams.

7. **Document integration pattern decisions in the ADR template** (`templates/fhir-integration-architecture-template.md`) so the rationale is traceable during implementation and future reviews.

---

## Review Checklist

Run through these before marking FHIR integration architecture work complete:

- [ ] Each data domain has been explicitly assigned to one of the four canonical sync patterns with written rationale
- [ ] The transformation layer is designed for every pattern — no pattern assumes raw FHIR bundles are persisted directly into Health Cloud
- [ ] HL7 v2 feeds have been identified and routed through a conversion step before the FHIR ingestion pipeline
- [ ] The 26-resource limit has been verified — FHIR resources outside Health Cloud's supported set have a design decision documented
- [ ] Error handling strategy is defined for each pattern (circuit breaker, dead-letter queue, idempotent upsert)
- [ ] Bidirectional sync conflict resolution rules are documented if write-back to the EMR is required
- [ ] Named Credentials and Connected App configuration for external FHIR endpoints are included in the design
- [ ] MuleSoft Accelerator asset coverage confirmed — custom DataWeave identified for any gaps

---

## Salesforce-Specific Gotchas

Non-obvious platform behaviors that cause real production problems:

1. **Health Cloud is not a conformant FHIR server** — Salesforce's FHIR R4 support covers only ~26 resource types mapped to its internal data model. Architects who assume Health Cloud can receive and store any arbitrary FHIR resource will discover at implementation time that resources like CareTeam, ServiceRequest, or custom profiles with extensions not in the supported set have no target object. This forces late-stage redesign. Verify the supported resource list against the Health Cloud Developer Guide before finalizing scope.

2. **Raw FHIR bundles cannot be persisted directly** — There is no "save this Bundle to Health Cloud" API operation. Every FHIR bundle must be unwrapped, each contained resource identified by type, and each mapped individually to Health Cloud object fields before a DML/API write occurs. Architects who do not design an explicit transformation layer end up with ad hoc Apex parsing logic scattered across the codebase that is fragile and untestable.

3. **Generic FHIR Client does not cache results** — Data retrieved via the Generic FHIR Client on a patient record open is not automatically stored in Health Cloud. If a downstream process (Flow, Apex trigger, report) needs the retrieved data, the design must include an explicit write step. Architects who assume the client persists data will create phantom data dependencies.

---

## Output Artifacts

| Artifact | Description |
|---|---|
| Integration Pattern Decision Matrix | Table mapping each clinical data domain to a selected sync pattern with rationale |
| Transformation Layer Design | Document specifying which FHIR resources are transformed, by which middleware component, and to which Health Cloud objects |
| FHIR Resource Coverage Audit | List of FHIR resources in scope vs. Health Cloud's supported 26-resource set, with gap disposition |
| Architecture Decision Record (ADR) | Completed `fhir-integration-architecture-template.md` capturing decisions, tradeoffs, and risks |

---

## Related Skills

- `health-cloud-data-model` — use alongside this skill when designing the Health Cloud object model that will receive the transformed FHIR data
- `health-cloud-apex-extensions` — use when custom Apex is needed to supplement the transformation layer or implement post-ingestion business logic
- `hipaa-compliance-architecture` — use to ensure the chosen integration pattern meets HIPAA PHI data handling requirements
- `compliant-data-sharing-setup` — use when FHIR data sharing across org boundaries or external portals is in scope

Related Skills

scim-provisioning-integration

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when designing or reviewing SCIM-based user lifecycle provisioning into Salesforce from Okta, Azure AD / Entra, or another IdP — create/update/deactivate, group-to-permission-set mapping, attribute mapping, and deprovisioning semantics. Triggers: 'scim provisioning', 'okta scim salesforce', 'entra salesforce provisioning', 'user deactivation automation', 'group to permission set mapping'. NOT for SSO/authentication setup (see single-sign-on skills).

omnistudio-lwc-integration

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when embedding OmniScripts in Lightning Web Components, registering custom LWC elements inside OmniScript screens, or calling OmniScript/Integration Procedures from LWC. Triggers: embed omniscript in LWC, custom LWC element in OmniScript, call OmniScript from Lightning page, omnistudio-omni-script tag, seed data JSON, OmniScript launch from LWC. NOT for standalone LWC development, standard Flow embedding, or OmniScript-to-OmniScript embedding.

integration-procedures

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when building, reviewing, or debugging OmniStudio Integration Procedures. Triggers: 'integration procedure', 'IP', 'HTTP action', 'DataRaptor', 'rollbackOnError', 'failureResponse'. NOT for Apex-only integrations unless the main design choice is whether OmniStudio is still appropriate.

integration-procedure-cacheable-patterns

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when designing Integration Procedures (IPs) with platform cache to cut latency and callout load. Covers cache key design, TTL selection, per-user vs org-wide partitions, invalidation on data changes, and safe fallback on cache miss/stale. Does NOT cover general IP authoring (see omnistudio-error-handling-patterns) or LWC client-side caching.

slack-salesforce-integration-setup

8
from PranavNagrecha/AwesomeSalesforceSkills

Use this skill when setting up or troubleshooting the Salesforce for Slack managed app — including connecting a Salesforce org to a Slack workspace, configuring the three-party admin handshake, linking Slack channels to Salesforce records, enabling record preview sharing, and managing org-level limits. Triggers on: Salesforce for Slack app not connecting, Slack org connection setup, Salesforce record sharing in Slack, Slack workspace admin approval, connecting Salesforce to Slack. NOT for building custom Slack apps or Slack bots (separate development platform), not for Slack Workflow Builder Salesforce connector (use slack-workflow-builder skill), not for Flow-based Slack messaging (use flow-for-slack skill).

sis-integration-patterns

8
from PranavNagrecha/AwesomeSalesforceSkills

Use this skill when designing or implementing an integration between a Student Information System (SIS) — such as Ellucian Banner, Ellucian Colleague, Anthology Student, Oracle PeopleSoft Campus Solutions, or Workday Student — and Salesforce Education Cloud. Covers the canonical Education Cloud data model objects (AcademicTermEnrollment, CourseOfferingParticipant, CourseOfferingPtcpResult, LearnerProfile, PersonAcademicCredential), external ID / upsert keying strategies using SIS-native identifiers (Banner PIDM, PeopleSoft EMPLID), batch nightly upsert patterns, Change Data Capture (CDC) for enrollment status writeback, and MuleSoft/middleware watermark patterns. Trigger keywords: SIS integration, Banner integration, PeopleSoft integration, Education Cloud data model, enrollment sync, grade writeback, AcademicTermEnrollment, LearnerProfile upsert. NOT for Salesforce Admissions Connect application processing, Financial Aid integration, Learning Management System (LMS) integrations, or general ETL tooling not involving Education Cloud objects.

salesforce-to-salesforce-integration

8
from PranavNagrecha/AwesomeSalesforceSkills

Use this skill to implement Salesforce-to-Salesforce integration patterns — covering the native S2S feature, API-based cross-org sync, Platform Event bridging, and Salesforce Connect Cross-Org adapter. Trigger keywords: Salesforce to Salesforce integration, cross-org data sharing, S2S feature, cross-org Platform Events, Salesforce Connect cross-org. NOT for multi-org strategy or architecture decisions (use architect/multi-org-strategy), single-org data sharing, or external (non-Salesforce) system integration.

real-time-vs-batch-integration

8
from PranavNagrecha/AwesomeSalesforceSkills

When to use this skill: choosing between real-time (synchronous callouts, Platform Events, CDC, Pub/Sub API) and batch (Bulk API 2.0, scheduled ETL) integration patterns. Trigger keywords: should I use real-time or batch, how to sync high-volume data, when to use Platform Events vs Bulk API, integration latency vs volume tradeoff. NOT for Batch Apex internals (use batch-apex-patterns), NOT for MuleSoft middleware design (use middleware-integration-patterns), NOT for CDC field tracking configuration.

platform-events-integration

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when publishing Platform Events from external systems via REST API, subscribing to Platform Events from outside Salesforce via CometD or Pub/Sub API, designing replay ID strategy for durable external consumers, or handling high-volume event delivery guarantees. Trigger keywords: 'external publish platform event', 'CometD subscribe', 'Pub/Sub API', 'replay ID external', 'durable subscription', 'RetainUntilDate'. NOT for Apex-only event publishing or triggering (use platform-events-apex). NOT for Change Data Capture external subscription (use change-data-capture-integration).

middleware-integration-patterns

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when selecting or comparing middleware / iPaaS tools (MuleSoft, Dell Boomi, Workato, Informatica) for Salesforce connectivity, or when determining whether a scenario requires middleware at all versus native Salesforce capabilities. Triggers: 'which iPaaS should I use', 'MuleSoft vs Boomi vs Workato', 'when do I need middleware for Salesforce', 'message transformation orchestration middleware'. NOT for MuleSoft Anypoint Salesforce Connector configuration (use mulesoft-salesforce-connector). NOT for API-led connectivity layer design (use api-led-connectivity). NOT for native Salesforce-to-Salesforce integration, Platform Events, or CDC.

idempotent-integration-patterns

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when designing retry-safe integrations with Salesforce — including external ID upsert strategies, idempotency key management for inbound calls, Platform Event replay safety, and Outbound Message retry handling. NOT for Salesforce duplicate management rules.

heroku-salesforce-integration

8
from PranavNagrecha/AwesomeSalesforceSkills

Heroku ↔ Salesforce integration paths — Heroku Connect (Postgres bidirectional sync), Heroku AppLink (expose Heroku APIs to Flow / Apex / Agentforce), Heroku External Objects (Salesforce Connect oData), Platform Events, REST API in either direction, and Salesforce Canvas for UI embedding. Decision matrix + Heroku Connect deep dive (OAuth integration user, plan-tier row limits, polling cadence, region co-location). NOT for AWS integration (see integration/aws-salesforce-patterns), NOT for generic PaaS, NOT for MuleSoft.