> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.joincandidhealth.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.joincandidhealth.com/_mcp/server.

# Encounters & Service Lines

> Overview of Encounters & Service Lines tables in Candid Data Share

General metadata is provided at both the `service_line` and `encounter` granularities for easy reporting and summarization.

## Table Relationships

```mermaid
erDiagram
    export_encounter ||--|| export_financial_summary : "encounter_id"
    export_encounter ||--o{ export_service_line : "encounter_id"
    export_encounter ||--o{ export_claim_submission_history : "encounter_id"
    export_service_line ||--|| export_service_line_financial_summary : "service_line_id"
    export_service_line ||--|| export_service_line_projected_financials : "service_line_id"
```

| Table                                      | Primary Key           | Description                                                                                                                                                                         |
| ------------------------------------------ | --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `export_encounter`                         | `encounter_id`        | Core encounter data with patient, provider, and claim information                                                                                                                   |
| `export_financial_summary`                 | `encounter_id`        | Encounter-level financial summary (patient responsibility, copay, deductible, coinsurance)                                                                                          |
| `export_service_line`                      | `service_line_id`     | Individual billable services within an encounter                                                                                                                                    |
| `export_service_line_financial_summary`    | `service_line_id`     | Financial totals (billed, allowed, patient responsibility) per service line                                                                                                         |
| `export_service_line_projected_financials` | `service_line_id`     | Expected allowed amounts and projections                                                                                                                                            |
| `export_claim_submission_history`          | `claim_submission_id` | Claim submission history — one row per submission, with channel (automated/external/crossover), insurance/non-insurance payer destination, and clearinghouse/payer acknowledgements |

## Common Queries

### Join Service Lines to Encounters

```sql
SELECT
  e.encounter_id,
  e.date_of_service,
  sl.service_line_id,
  sl.procedure_code
FROM export_encounter e
JOIN export_service_line sl
  ON e.encounter_id = sl.encounter_id
```

### Service Line Financial Summary

```sql
SELECT
  sl.service_line_id,
  sl.procedure_code,
  slfs.billed_amount_cents,
  slfs.allowed_amount_cents,
  slfs.patient_responsibility_cents
FROM export_service_line sl
JOIN export_service_line_financial_summary slfs
  ON sl.service_line_id = slfs.service_line_id
```