A demonstration of how to bridge CARIN Digital Insurance Card (DIC) Coverage resources with Real-Time Pharmacy Benefit Check (RTPBC) requirements, enabling real-world adoption of pharmacy benefit checking at the point of prescribing.
graph TB
subgraph "Health Plan"
DIC["CARIN DIC Coverage<br/>Resource includes<br/>RxBIN RxPCN<br/>RxGroup RxID"]
end
DIC -->|"Embedded in"| CBB
subgraph "CARIN Blue Button API"
CBB["Coverage Endpoint<br/>/Coverage/{id}<br/>Returns DIC-profiled<br/>Coverage Resource"]
end
CBB -->|"GET request"| CLIENT
subgraph "Client Application"
CLIENT["Retrieve Coverage<br/>from CARIN BB API"]
CLIENT --> TRANSFORM
TRANSFORM["Extract Pharmacy IDs<br/>from DIC Coverage"]
TRANSFORM --> RTPBC
RTPBC["Use with RTPBC<br/>for benefit checks"]
end
style DIC fill:#81c784
style CBB fill:#e1f5fe
style CLIENT fill:#fff9c4
style TRANSFORM fill:#fff9c4
style RTPBC fill:#ffb74d
This implementation demonstrates how CARIN DIC Coverage Resources are embedded within CARIN Blue Button APIs, then retrieved and used to enable Real-Time Pharmacy Benefit Check workflows, helping patients get real-time benefits information about their prescriptions.
Implementing RTPBC in the context of a CARIN Blue Button Patient Access API creates a powerful synergy that solves multiple challenges simultaneously:
1. Authentication is Already Solved
- CARIN BB APIs require OAuth 2.0 patient authentication
- Patients have already consented and authenticated to access their data
- The same authenticated session can be used for RTPBC requests
- No need for separate authentication workflows or credentials
2. Patient-Centered Architecture
- Both APIs are designed for patient empowerment
- Patients control access to their own benefit information
- Aligns with CMS interoperability rules requiring patient access
- Supports patient choice and transparency in healthcare costs
3. Single Integration Point
- Developers integrate once with the payer's CARIN BB API
- Same API provides claims history AND real-time benefit checks
- Reduces implementation complexity and maintenance burden
- Leverages existing SMART on FHIR infrastructure
4. Trust and Security
- Patient has established trust relationship with their health plan
- OAuth flow ensures only authorized applications access data
- Audit trails show patient-initiated benefit checks
- Reduces risk of unauthorized pharmacy benefit inquiries
This prototype addresses a critical gap preventing widespread adoption of real-time pharmacy benefit checking in the United States healthcare system.
The CARIN Real-Time Pharmacy Benefit Check (RTPBC) Implementation Guide enables a transformative capability: allowing prescribers to check medication coverage and patient out-of-pocket costs at the point of prescribing. This means:
- Patients know their copay before leaving the doctor's office
- Physicians can discuss affordable alternatives during the visit
- Prior authorization requirements are identified immediately
- Pharmacy surprises and medication abandonment are reduced
RTPBC requires specific pharmacy benefit identifiers to route requests to the correct Pharmacy Benefit Manager (PBM) systems. These identifiers, familiar from physical insurance cards, include:
rxid
- The member's unique identifier for pharmacy benefits (often different from medical ID)rxgroup
- Identifies the specific benefit design/formularyrxbin
- Bank Identification Number that routes to the correct PBM processorrxpcn
- Processor Control Number for additional routing specificity
Without these identifiers, RTPBC requests cannot be processed - they literally cannot reach the systems that know the patient's drug coverage.
Most health plans have implemented the CARIN Consumer Directed Payer Data Exchange (CARIN Blue Buttonยฎ) Implementation Guide, which enables patients to access their claims data via FHIR APIs. However, the Coverage resource in CARIN BB was designed for medical claims and doesn't profile these pharmacy-specific elements.
This creates a chicken-and-egg problem:
- Prescriber systems need these identifiers to check drug prices
- Payer systems have the data but don't expose it via their FHIR APIs
- Adding new fields to existing implementations is a significant undertaking
The CARIN Digital Insurance Card Implementation Guide was designed to digitize insurance cards for mobile wallets and apps. Critically, it includes ALL the pharmacy identifiers needed for RTPBC:
Coverage.class[rxbin] โ Maps to โ RTPBC Coverage.class:bin
Coverage.class[rxpcn] โ Maps to โ RTPBC Coverage.class:pcn
Coverage.class[rxgroup] โ Maps to โ RTPBC Coverage.class:rxgroup-id
Coverage.class[rxid] โ Maps to โ RTPBC Coverage.class:pbm-member-id
Many payers are already implementing or planning to implement digital insurance cards for member convenience. This creates an opportunity: systems that expose CARIN DIC Coverage resources already have the data needed for RTPBC.
- For Patients: Medication costs become transparent at the point of care, reducing abandonment and improving adherence
- For Providers: Enables informed prescribing decisions during the visit by helping patients get real-time benefit information
- For Payers: Existing digital insurance card implementations can enable RTPBC without major rework
- For the Ecosystem: Demonstrates how FHIR IGs can work together to solve real-world problems
This demo implements a complete end-to-end flow:
- SMART on FHIR Authorization - Simulated OAuth2 flow with popup-based authentication
- FHIR API Integration - Retrieves Coverage resources with the CARIN DIC profile
- Data Transformation - Maps DIC Coverage elements to RTPBC-required format
- Visual Demonstration - Side-by-side comparison showing the transformation
- Bun runtime installed
- Modern web browser (Chrome, Firefox, Safari, or Edge)
- Port 3000 and 3001 available
-
Clone the repository
git clone <repository-url> cd rtpbc-demo
-
Start the Mock FHIR Server
cd server bun install bun run dev
The server will start on http://localhost:3001
-
Start the Client Application (in a new terminal)
cd client bun serve.js
The client will be available at http://localhost:3000
- Navigate to http://localhost:3000 in your browser
- Click "Start SMART Launch" to begin the authorization flow
- Sign in using the pre-filled demo credentials (or any values)
- View the transformation as the app:
- Fetches the CARIN DIC Coverage resource
- Transforms it to RTPBC format
- Displays both versions side-by-side
- Shows the field mappings
rtpbc-demo/
โโโ server/ # Mock FHIR server
โ โโโ index.js # Express server with SMART auth
โ โโโ mockData.js # FHIR resource examples
โ โโโ auth.html # OAuth authorization page
โโโ client/ # Browser-based demo app
โ โโโ index.html # Main application UI
โ โโโ app.js # SMART client & transformation logic
โ โโโ styles.css # Application styling
โโโ README.md # This file
- Mock FHIR Server: Implements SMART on FHIR authorization and FHIR API endpoints
- Coverage Transformation: Maps CARIN DIC fields to RTPBC requirements
- Visual Interface: Shows the complete data flow and transformations
The transformation preserves critical pharmacy routing information:
CARIN DIC Field | Example Value | RTPBC Field | Purpose |
---|---|---|---|
Coverage.class[rxbin] | "100045" | Coverage.class:bin | PBM routing |
Coverage.class[rxpcn] | "1234000" | Coverage.class:pcn | Processor routing |
Coverage.class[rxgroup] | "GOLD2024" | Coverage.class:rxgroup-id | Group benefits |
Coverage.class[rxid] | "102345672-01" | Coverage.class:pbm-member-id | Member identification |
This is a demonstration application with simplified security:
- Mock authentication (no real credentials required)
- No data persistence
- CORS enabled for local development
For production implementations:
- Implement real SMART on FHIR security
- Follow OAuth2 best practices
- Validate all FHIR resources
- Implement proper error handling
- Add audit logging
This reference implementation follows these HL7 FHIR Implementation Guides:
- CARIN Digital Insurance Card IG - Source of pharmacy benefit identifiers
- CARIN RTPBC IG - Target format for pharmacy benefit checking
- SMART App Launch - Authorization framework
- US Core - Base FHIR profiles for US Realm
- CARIN Alliance - Advancing consumer-directed exchange
- RTPBC Project Page - Overview and use cases
- Digital Insurance Card Project - Background and adoption
- NCPDP RTPBC Standard - Underlying pharmacy industry standard
- Da Vinci Payer Data Exchange - Complementary payer-to-payer exchange
- CMS Interoperability Rules - Regulatory context
This is a reference implementation intended to demonstrate the concept. For questions or suggestions:
- Open an issue in the repository
- Contact the CARIN Alliance working groups
- Participate in HL7 FHIR connectathons
โน๏ธ Sponsored by Flexpa
Flexpa is committed to advancing healthcare interoperability and supporting real-world adoption of FHIR standards. We believe that patients deserve transparency in healthcare costs, and this reference implementation demonstrates one path toward that goal.