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

# EHR integration

> Embed knowledge resolution in EHR workflows

RCI integrates with EHR and practice management systems to provide billing knowledge at the point of care.

## Integration patterns

### REST API (server-side)

The most common pattern. Your EHR backend calls RCI's API during scheduling, check-in, or charge capture:

```
Patient schedules visit → EHR triggers knowledge resolution
                         → RCI returns billing context
                         → EHR displays expected payment, coding guidance
```

### Python SDK

```python theme={null}
import httpx

class RCIClient:
    def __init__(self, api_key: str, base_url: str = "https://api-dev.rcintell.com"):
        self.client = httpx.AsyncClient(
            base_url=base_url,
            headers={"X-API-Key": api_key, "Content-Type": "application/json"},
            timeout=30.0,
        )

    async def resolve(self, ccn: str, cpt: str, payer: str = "Medicare", care_setting: str = "outpatient"):
        resp = await self.client.post("/v1/knowledge/resolve", json={
            "ccn": ccn, "cpt": cpt, "payer": payer, "care_setting": care_setting,
        })
        resp.raise_for_status()
        return resp.json()

    async def calculate_payment(self, ccn: str, cpt: str):
        resp = await self.client.post("/v1/knowledge/payment-calc", json={"ccn": ccn, "cpt": cpt})
        resp.raise_for_status()
        return resp.json()

    async def billing_guide(self, ccn: str, cpt: str, payer: str = None):
        body = {"ccn": ccn, "cpt": cpt}
        if payer:
            body["payer"] = payer
        resp = await self.client.post("/v1/knowledge/billing-guide", json=body)
        resp.raise_for_status()
        return resp.json()
```

### TypeScript SDK

```typescript theme={null}
interface RCIConfig {
  apiKey: string;
  baseUrl?: string;
}

class RCIClient {
  private baseUrl: string;
  private headers: Record<string, string>;

  constructor(config: RCIConfig) {
    this.baseUrl = config.baseUrl ?? "https://api-dev.rcintell.com";
    this.headers = {
      "X-API-Key": config.apiKey,
      "Content-Type": "application/json",
    };
  }

  async resolve(params: {
    ccn: string;
    cpt?: string;
    payer?: string;
    careSetting?: string;
  }) {
    const res = await fetch(`${this.baseUrl}/v1/knowledge/resolve`, {
      method: "POST",
      headers: this.headers,
      body: JSON.stringify({
        ccn: params.ccn,
        cpt: params.cpt,
        payer: params.payer,
        care_setting: params.careSetting,
      }),
    });
    if (!res.ok) throw new Error(`RCI API error: ${res.status}`);
    return res.json();
  }

  async calculatePayment(ccn: string, cpt: string) {
    const res = await fetch(`${this.baseUrl}/v1/knowledge/payment-calc`, {
      method: "POST",
      headers: this.headers,
      body: JSON.stringify({ ccn, cpt }),
    });
    if (!res.ok) throw new Error(`RCI API error: ${res.status}`);
    return res.json();
  }
}
```

## Workflow integration points

| Workflow Step         | RCI Endpoint                        | Value                                   |
| --------------------- | ----------------------------------- | --------------------------------------- |
| **Scheduling**        | `POST /v1/knowledge/resolve`        | Verify billing context before the visit |
| **Check-in**          | `POST /v1/knowledge/payment-calc`   | Show expected payment for transparency  |
| **Coding**            | `POST /v1/agents/code-research`     | Assist coders with CPT selection        |
| **Charge capture**    | `POST /v1/knowledge/billing-guide`  | Correct billing form and TOB codes      |
| **Claim review**      | `POST /v1/agents/medical-necessity` | Pre-submission necessity validation     |
| **Denial management** | `POST /v1/agents/denial-resolution` | Resolve denials with appeal strategies  |

## Agent callbacks for EHR systems

Agent jobs are async. Pass `callback_url` on submit (see [Agent callbacks](/docs/webhooks)) or poll `GET /v1/agents/jobs/{job_id}`.

```bash theme={null}
curl -X POST https://api-dev.rcintell.com/v1/agents/code-research \
  -H "X-API-Key: kp_test_..." \
  -H "Content-Type: application/json" \
  -d '{
    "query": "CPT for this procedure?",
    "ccn": "170001",
    "callback_url": "https://your-ehr.com/webhooks/rci-agent",
    "callback_secret": "whsec_your_shared_secret"
  }'
```
