> ## Documentation Index
> Fetch the complete documentation index at: https://docs.usecrew.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# EMR / EHR Integration

> Connect Crew to electronic medical record systems

# EMR / EHR Integration

Crew can integrate with Electronic Medical Record (EMR) and Electronic Health Record (EHR) systems to access patient data, schedule appointments, and update records. This guide covers integration patterns and data handling considerations.

<Warning>
  Healthcare integrations require careful attention to data handling and privacy. Crew is designed with healthcare workflows in mind, but the overall compliance posture depends on your specific deployment and configuration. See [Healthcare Readiness](/security/healthcare-readiness) for details.
</Warning>

## Integration Approaches

### FHIR API Integration

FHIR (Fast Healthcare Interoperability Resources) is the modern standard for healthcare data exchange.

```json theme={null}
{
  "emr_integration": {
    "type": "fhir",
    "base_url": "https://your-ehr.com/fhir/r4",
    "auth": {
      "type": "oauth2",
      "token_url": "https://your-ehr.com/oauth/token",
      "client_id": "crew_client",
      "client_secret": "..."
    }
  }
}
```

#### Supported FHIR Resources

| Resource       | Use Case                         |
| -------------- | -------------------------------- |
| `Patient`      | Look up patient demographics     |
| `Appointment`  | Schedule and manage appointments |
| `Schedule`     | Check provider availability      |
| `Slot`         | Find available time slots        |
| `Practitioner` | Provider information             |
| `Location`     | Office/facility details          |

### Custom API Integration

For EMRs without FHIR support, use custom API integrations:

```json theme={null}
{
  "emr_integration": {
    "type": "custom",
    "endpoints": {
      "patient_lookup": "https://your-emr.com/api/patients/search",
      "schedule_appointment": "https://your-emr.com/api/appointments",
      "check_availability": "https://your-emr.com/api/slots"
    },
    "auth": {
      "type": "api_key",
      "header": "X-API-Key",
      "key": "..."
    }
  }
}
```

### Webhook-Based Integration

Receive notifications from your EMR:

```json theme={null}
{
  "emr_webhooks": {
    "appointment_created": "https://api.usecrew.ai/v1/emr/webhook/{crew_id}",
    "appointment_updated": "https://api.usecrew.ai/v1/emr/webhook/{crew_id}",
    "patient_updated": "https://api.usecrew.ai/v1/emr/webhook/{crew_id}"
  }
}
```

## Common Workflows

### Patient Verification

Verify caller identity before accessing information:

```javascript theme={null}
// During call, Crew collects patient identifiers
const patientData = {
  date_of_birth: "1985-03-15",
  last_name: "Smith",
  phone: "+14155551234"
};

// Crew queries EMR to verify
const patient = await emr.searchPatient(patientData);

if (patient && patient.verified) {
  // Proceed with authenticated context
}
```

### Appointment Scheduling

<Steps>
  <Step title="Identify Patient">
    Verify caller identity through date of birth and name
  </Step>

  <Step title="Determine Appointment Type">
    Agent asks about the reason for the visit
  </Step>

  <Step title="Check Availability">
    Query EMR for available slots matching criteria
  </Step>

  <Step title="Present Options">
    Offer available times to the caller
  </Step>

  <Step title="Book Appointment">
    Create appointment in EMR
  </Step>

  <Step title="Confirm">
    Read back confirmation details
  </Step>
</Steps>

### Appointment Lookup

```javascript theme={null}
// Caller asks about existing appointment
const appointments = await emr.getAppointments({
  patient_id: patient.id,
  status: "booked",
  date_from: today
});

// Agent: "I see you have an appointment with Dr. Johnson 
// on January 20th at 2pm. Would you like to keep, 
// reschedule, or cancel that?"
```

### Prescription Refills

```javascript theme={null}
// Validate patient has active prescription
const prescription = await emr.getPrescription({
  patient_id: patient.id,
  medication: requested_medication,
  status: "active"
});

if (prescription && prescription.refills_remaining > 0) {
  // Create refill request in EMR
  await emr.createRefillRequest({
    prescription_id: prescription.id,
    requested_via: "phone",
    call_id: call.id
  });
}
```

## Supported EMR Systems

Crew has pre-built connectors for:

| EMR            | Integration Type | Features                        |
| -------------- | ---------------- | ------------------------------- |
| Epic           | FHIR R4          | Full scheduling, patient lookup |
| Cerner         | FHIR R4          | Scheduling, patient lookup      |
| athenahealth   | REST API         | Scheduling, patient lookup      |
| DrChrono       | REST API         | Scheduling, patient lookup      |
| eClinicalWorks | Custom           | Scheduling (limited)            |

<Note>
  Contact [sales@usecrew.ai](mailto:sales@usecrew.ai) for EMR integrations not listed above.
</Note>

## Data Handling

### Minimum Necessary Principle

Crew only accesses the data required for the specific task:

| Task                   | Data Accessed                                    |
| ---------------------- | ------------------------------------------------ |
| Appointment scheduling | Name, DOB, contact info, appointment preferences |
| Appointment lookup     | Name, DOB, upcoming appointments                 |
| Prescription refill    | Name, DOB, active prescriptions                  |

### Data in Transit

All data between Crew and EMR systems is encrypted:

* TLS 1.2+ for all connections
* Certificate validation enforced
* No data cached in transit

### Data at Rest

Crew can be configured to minimize data storage:

```json theme={null}
{
  "data_handling": {
    "store_patient_data": false,
    "store_transcripts": true,
    "redact_phi_from_transcripts": true,
    "retention_days": 30
  }
}
```

## Authentication Patterns

### OAuth 2.0

For FHIR and modern APIs:

```json theme={null}
{
  "auth": {
    "type": "oauth2",
    "grant_type": "client_credentials",
    "token_url": "https://emr.com/oauth/token",
    "client_id": "...",
    "client_secret": "...",
    "scope": "patient/*.read appointment/*.write"
  }
}
```

### SMART on FHIR

For clinical contexts requiring user authorization:

```json theme={null}
{
  "auth": {
    "type": "smart_on_fhir",
    "iss": "https://emr.com/fhir",
    "scopes": ["launch", "patient/Appointment.write"]
  }
}
```

### API Keys

For simpler integrations:

```json theme={null}
{
  "auth": {
    "type": "api_key",
    "header": "Authorization",
    "prefix": "Bearer",
    "key": "your_api_key"
  }
}
```

## Error Handling

Handle EMR connectivity issues gracefully:

```javascript theme={null}
try {
  const slots = await emr.getAvailableSlots(criteria);
  // Present options to caller
} catch (error) {
  if (error.type === "emr_unavailable") {
    // Agent: "I'm having trouble accessing our scheduling system. 
    // Can I take your information and have someone call you back?"
    await collectCallbackInfo();
  }
}
```

## Responsibility Boundaries

<Info>
  Integration with EMR systems involves shared responsibilities between Crew and your organization.
</Info>

### Crew Responsibilities

* Secure transmission of data
* Proper authentication to your EMR
* Logging of all EMR interactions
* Error handling and graceful degradation

### Customer Responsibilities

* EMR access credentials management
* Data access policies and permissions
* Audit log review
* User training on data handling
* Regulatory compliance oversight

## Best Practices

<AccordionGroup>
  <Accordion title="Use minimal permissions">
    Grant Crew only the EMR permissions needed for specific workflows.
  </Accordion>

  <Accordion title="Audit regularly">
    Review Crew's EMR access logs for unexpected patterns.
  </Accordion>

  <Accordion title="Test in sandbox first">
    Use EMR sandbox/test environments before production.
  </Accordion>

  <Accordion title="Plan for failures">
    Design call flows that gracefully handle EMR unavailability.
  </Accordion>

  <Accordion title="Train staff">
    Ensure staff understand how Crew accesses and uses EMR data.
  </Accordion>
</AccordionGroup>

## Next Steps

* [Healthcare Readiness](/security/healthcare-readiness) — Security and compliance considerations
* [Data Handling](/security/data-handling) — How Crew handles sensitive data
* [Webhooks](/integrations/webhooks) — Sync data between systems
