---
# System prepended metadata

title: FHIR Architecture Comparison Diagrams

---

# FHIR Architecture Comparison Diagrams

## For EmpowerHealth Platform - SFMC Integration Discussion

## 1. Current SFMC Proposed Architecture (Problems Highlighted)

```mermaid
%%{init: {'theme':'base', 'themeVariables': { 'primaryColor':'#ff6b6b', 'primaryTextColor':'#fff', 'primaryBorderColor':'#ff4757', 'lineColor':'#5f27cd', 'secondaryColor':'#feca57', 'tertiaryColor':'#ff9ff3', 'background':'#dfe6e9', 'mainBkg':'#ffffff', 'secondBkg':'#f5f3f0', 'tertiaryBkg':'#ffeaa7'}}}%%

graph TB
    subgraph "PROBLEMS"
        P1["24+ Hour Latency"]:::problem
        P2["Multiple Data Hops"]:::problem
        P3["High Maintenance"]:::problem
        P4["No Real-time Support"]:::problem
    end

    subgraph "SFMC Proposed Architecture"
        Epic[("Epic Production System")]:::epic
        Clarity[("Clarity Reporting DB T-1 Day Batch")]:::clarity
        RPT1[("RPT-1 Database")]:::rpt

        Databasin["Databasin"]:::processing
        FHIR_API["FHIR_API"]:::processing

        subgraph "Snowflake Layers"
            SF1[("Snowflake_Clarity")]:::snowflake
            SF2[("Snowflake_FHIR_Stage")]:::snowflake
            SF3[("Snowflake_SaintFrancis")]:::snowflake
            SF4[("Snowflake_Empower")]:::snowflake
            SF1 --> SF2 --> SF3 --> SF4
        end

        EH["EmpowerHealth Platform"]:::empower

        Epic -->|"Nightly Batch"| Clarity
        Epic -->|"Reports"| RPT1
        Clarity --> Databasin
        RPT1 --> Databasin
        Databasin --> FHIR_API
        FHIR_API -->|"Data Pull"| SF1
        SF4 --> EH
    end

    classDef problem fill:#ff6b6b,stroke:#ee5a24,stroke-width:3px,color:#fff
    classDef epic fill:#3498db,stroke:#2980b9,stroke-width:2px,color:#fff
    classDef clarity fill:#95a5a6,stroke:#7f8c8d,stroke-width:2px,color:#fff
    classDef rpt fill:#95a5a6,stroke:#7f8c8d,stroke-width:2px,color:#fff
    classDef processing fill:#f39c12,stroke:#e67e22,stroke-width:2px,color:#fff
    classDef snowflake fill:#74b9ff,stroke:#0984e3,stroke-width:2px,color:#fff
    classDef cache fill:#fd79a8,stroke:#e84393,stroke-width:2px,color:#fff
    classDef empower fill:#6c5ce7,stroke:#5f3dc4,stroke-width:3px,color:#fff
```

### Key Issues with This Approach

- **Multiple Data Hops** from Epic to your application through Databasin and multiple Snowflake layers
- **T-1 Day minimum latency** from Clarity batch processing
- **Recreating what Epic already provides** (FHIR APIs) through custom Databasin layer
- **Complex data pipeline** with multiple transformation stages increases maintenance burden

---

## 2. Recommended Architecture: Smart FHIR with Event-Driven Model

```mermaid
%%{init: {'theme':'base', 'themeVariables': { 'primaryColor':'#00b894', 'primaryTextColor':'#fff', 'primaryBorderColor':'#00cec9', 'lineColor':'#0984e3', 'secondaryColor':'#fdcb6e', 'tertiaryColor':'#6c5ce7'}}}%%

graph TB
    subgraph "BENEFITS"
        B1["Real-time Data"]:::benefit
        B2["Standard FHIR"]:::benefit
        B3["Simplified Architecture"]:::benefit
        B4["Lower Maintenance"]:::benefit
    end

    subgraph "Recommended: Smart Event-Driven Architecture"
        Epic2[("EpicProduction")]:::epic

        subgraph "Epic Native Services"
            FHIR["Epic FHIR R4 Server Real-time"]:::fhir
            SUB["FHIR Subscriptions Webhooks"]:::fhir
        end

        subgraph "EmpowerHealth API Gateway"
            GW["Smart Gateway"]:::gateway
            CACHE["Intelligent Cache• User-triggered fetch• Smart TTL• ETag validation"]:::smartcache
            RL["Rate Limiter"]:::gateway
            CB["Circuit Breaker"]:::gateway

            GW --> CACHE
            GW --> RL
            GW --> CB
        end

        subgraph "Data Pipeline"
            Stream["Event Stream Processor"]:::stream
            SF_RT[("Snowflake Real-time Tables")]:::snowflake
            SF_AN[("Snowflake Analytics")]:::snowflake

            Stream --> SF_RT
            SF_RT --> SF_AN
        end

        subgraph "EmpowerHealth Modules"
            CDI["CDI Module"]:::module
            AIC["AI Coding"]:::module
            PT["Patient Type"]:::module
        end

        Epic2 --> FHIR
        Epic2 --> SUB
        FHIR -->|"On-demand"| GW
        SUB -->|"Events"| Stream
        CACHE --> Stream
        SF_AN --> CDI
        SF_AN --> AIC
        SF_AN --> PT
    end

    classDef benefit fill:#00b894,stroke:#00cec9,stroke-width:3px,color:#fff
    classDef epic fill:#3498db,stroke:#2980b9,stroke-width:2px,color:#fff
    classDef fhir fill:#2ecc71,stroke:#27ae60,stroke-width:2px,color:#fff
    classDef gateway fill:#9b59b6,stroke:#8e44ad,stroke-width:2px,color:#fff
    classDef smartcache fill:#f39c12,stroke:#e67e22,stroke-width:2px,color:#fff
    classDef stream fill:#e74c3c,stroke:#c0392b,stroke-width:2px,color:#fff
    classDef snowflake fill:#74b9ff,stroke:#0984e3,stroke-width:2px,color:#fff
    classDef module fill:#6c5ce7,stroke:#5f3dc4,stroke-width:3px,color:#fff
```

### Why This Architecture Wins

- **2-3 Hops** only (Epic → Gateway → Snowflake → App)
- **Real-time data** when users need it
- **Respects Epic's built-in protections**
- **Event-driven** reduces unnecessary calls
- **Simplified maintenance** with standard FHIR implementation

---

## 3. Hybrid Approach: Best of Both Worlds

```mermaid
%%{init: {'theme':'base', 'themeVariables': { 'primaryColor':'#6c5ce7', 'primaryTextColor':'#fff', 'primaryBorderColor':'#5f3dc4', 'lineColor':'#74b9ff', 'secondaryColor':'#55efc4', 'tertiaryColor':'#ff7675'}}}%%

graph TB
    subgraph "Hybrid Benefits"
        HB1["Real-time Clinical"]:::benefit
        HB2["Batch Analytics"]:::benefit
        HB3["Cost Optimized"]:::benefit
    end

    subgraph "Hybrid Architecture: Optimized for Use Cases"
        Epic3[("EpicProduction")]:::epic

        subgraph "Real-time Path"
            FHIR3["FHIR APIs"]:::fhirrt
            ADT["ADT Feed"]:::fhirrt
            RTG["Real-time Gateway"]:::gatewayrt

            FHIR3 --> RTG
            ADT --> RTG
        end

        subgraph "Batch Path"
            Clarity3[("Clarity DB Nightly")]:::clarity
            CDC["CDC Tool (Fivetran)"]:::cdc
        end

        subgraph "Unified Data Lake"
            RT_Table[("Snowflake Hot Data Active Patients")]:::hot
            BATCH_Table[("Snowflake Warm Data Population")]:::warm
            UNIFIED[("Unified View")]:::unified

            RT_Table --> UNIFIED
            BATCH_Table --> UNIFIED
        end

        subgraph "Smart Router"
            Router{"Smart Router: Active → Real-time, Analytics → Batch"}:::router
        end

        EH3["EmpowerHealthPlatform"]:::empower

        Epic3 --> FHIR3
        Epic3 -->|"Events"| ADT
        Epic3 -->|"Nightly"| Clarity3

        RTG -->|"<5 min"| RT_Table
        Clarity3 --> CDC
        CDC -->|"Incremental"| BATCH_Table

        UNIFIED --> Router
        Router --> EH3
    end

    classDef benefit fill:#2ecc71,stroke:#27ae60,stroke-width:3px,color:#fff
    classDef epic fill:#3498db,stroke:#2980b9,stroke-width:2px,color:#fff
    classDef fhirrt fill:#e74c3c,stroke:#c0392b,stroke-width:2px,color:#fff
    classDef gatewayrt fill:#e67e22,stroke:#d68910,stroke-width:2px,color:#fff
    classDef clarity fill:#95a5a6,stroke:#7f8c8d,stroke-width:2px,color:#fff
    classDef cdc fill:#9b59b6,stroke:#8e44ad,stroke-width:2px,color:#fff
    classDef hot fill:#ff7675,stroke:#ff6348,stroke-width:2px,color:#fff
    classDef warm fill:#74b9ff,stroke:#0984e3,stroke-width:2px,color:#fff
    classDef unified fill:#00b894,stroke:#00cec9,stroke-width:3px,color:#fff
    classDef router fill:#fdcb6e,stroke:#f39c12,stroke-width:2px,color:#fff
    classDef empower fill:#6c5ce7,stroke:#5f3dc4,stroke-width:3px,color:#fff
```

### Use Case Optimization

- **Real-time Path**: Active patient documentation, CDI alerts, coding suggestions
- **Batch Path**: Population health, risk stratification, quality metrics
- **Smart Router**: Automatically chooses optimal path based on use case

---

## 4. Data Flow Timing Comparison

```mermaid
%%{init: {'theme':'default', 'themeVariables': { 'crit0':'#d63031', 'crit1':'#e17055', 'done0':'#00b894', 'done1':'#00cec9', 'active0':'#0984e3', 'active1':'#74b9ff', 'gridColor':'#2d3436', 'textColor':'#2d3436', 'fontSize':'14px'}}}%%

gantt
    title Data Latency Comparison: Patient Documentation to CDI Alert
    dateFormat HH:mm
    axisFormat %H:%M

    section SFMC Proposed
    Patient Documentation  :done, doc1, 08:00, 1m
    Wait for Clarity Batch :crit, wait1, after doc1, 16h
    Databasin Processing   :active, db1, after wait1, 2h
    Snowflake Pipeline    :active, sf1, after db1, 1h
    CDI Alert Generated   :milestone, alert1, after sf1, 0m
    Total Time ~19-20 hours :crit, after doc1, 20h

    section Recommended
    Patient Documentation  :done, doc2, 08:00, 1m
    FHIR Webhook Fired    :done, webhook2, after doc2, 10s
    Gateway Processing    :done, gw2, after webhook2, 30s
    Snowflake Update     :done, sf2, after gw2, 1m
    CDI Alert Generated  :milestone, alert2, after sf2, 0m
    Total Time ~2-5 minutes :done, after doc2, 5m

    section Hybrid Approach
    Patient Documentation  :done, doc3, 08:00, 1m
    Real-time (Active)   :done, rt3, after doc3, 2m
    Batch (Population)   :active, batch3, 00:00, 24h
    Both Available       :milestone, both3, 08:03, 0m
```

---

## 5. API Call Volume Comparison (Based on 1,000 Active Patients)

```mermaid
%%{init: {'theme':'base', 'themeVariables': { 'primaryColor':'#e74c3c', 'primaryTextColor':'#fff', 'lineColor':'#3498db'}}}%%

graph TB
    subgraph one["SFMC Batch Processing"]
        direction TB
        BATCH["Daily Clarity batch + Databasin processing<br/>Limited real-time capability"]:::bad
    end

    subgraph two["Event-Driven"]
        direction TB
        EVENT["~50 events/day × 1,000 patients × 2 resources<br/>100,000 calls - All meaningful, real-time"]:::good
        CACHE["Intelligent Cache• User-triggered fetch• Smart TTL• ETag validation"]:::smartcache
        EVENT --> CACHE
    end

    subgraph three["Comparison"]
        direction TB
        COMPARE["SFMC: 24+ hour delay, batch only<br/>Recommended: Real-time + lower API volume"]:::compare
    end

    classDef bad fill:#e74c3c,stroke:#c0392b,stroke-width:3px,color:#fff
    classDef good fill:#2ecc71,stroke:#27ae60,stroke-width:3px,color:#fff
    classDef compare fill:#3498db,stroke:#2980b9,stroke-width:2px,color:#fff
```

---

## Key Takeaways for SFMC Discussion

### Problems with Their Approach

1. **Latency**: 24+ hour delay unacceptable for clinical decisions
2. **Complexity**: Maintaining custom Databasin FHIR layer and multiple Snowflake transformations = technical debt
3. **Limited Real-time**: Batch-based architecture cannot support real-time clinical workflows
4. **Maintenance Burden**: Multiple transformation layers increase operational complexity

### Benefits of Recommended Approach

1. **Real-time**: 2-5 minute latency for critical workflows vs 24+ hours
2. **Standards**: Use Epic's native FHIR = less maintenance, no custom Databasin layer needed
3. **Simplified**: Direct Epic FHIR connection reduces complexity
4. **Efficient**: Event-driven architecture eliminates unnecessary batch processing delays

### Compromise Position

If they insist on some caching/protection:

- Implement smart caching at YOUR gateway (not custom FHIR)
- Use Epic's built-in throttling and ETags
- Start with hybrid approach (real-time + batch)
- Let Epic handle the FHIR complexity

### Cost Comparison (Annual Estimate)

| Architecture  | Infrastructure        | Maintenance     | API Costs | Total          |
| ------------- | --------------------- | --------------- | --------- | -------------- |
| SFMC Proposed | $80K (Databasin + SF) | $150K (Custom)  | $30K      | **$260K**      |
| Recommended   | $30K (Gateway)        | $50K (Standard) | $10K      | **$90K**       |
| **Savings**   |                       |                 |           | **$170K/year** |
