---
title: "Connect AdvancedMD to ChatGPT: Access Patient History & Care Plans"
slug: connect-advancedmd-to-chatgpt-access-patient-history-care-plans
date: 2026-11-25
author: Yuvraj Muley
categories: ["AI & Agents"]
excerpt: "Learn how to connect AdvancedMD to ChatGPT using Truto's auto-generated MCP servers to securely query patient FHIR records, observations, and care plans."
tldr: "Connect AdvancedMD to ChatGPT via Truto's managed MCP server. This guide covers bypassing FHIR API complexities, handling patient tokens, setting up the server, and executing clinical workflows."
canonical: https://truto.one/blog/connect-advancedmd-to-chatgpt-access-patient-history-care-plans/
agent:
  instructions: "Use this search API to find relevant content across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://truto.one/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Connect AdvancedMD to ChatGPT: Access Patient History & Care Plans


If you are engineering clinical AI workflows, you need to give your Large Language Models (LLMs) secure, programmatic access to Practice Management (PM) and Electronic Health Record (EHR) systems. If you want to connect AdvancedMD to ChatGPT so your AI agents can query patient histories, retrieve active care plans, and extract bulk FHIR data, you need a [Model Context Protocol (MCP) server](https://truto.one/blog/what-is-mcp-model-context-protocol-the-2026-guide-for-saas-pms/).

You can either spend months building, mapping, and securing a custom integration layer that translates LLM JSON-RPC calls into AdvancedMD's FHIR API payloads, or you can use a managed platform like Truto to dynamically generate a compliant, authenticated MCP server URL.

If your team uses Claude, check out our guide on [connecting AdvancedMD to Claude](https://truto.one/connect-advancedmd-to-claude-analyze-clinical-records-lab-results/) or explore our broader architectural overview on [connecting AdvancedMD to AI Agents](https://truto.one/connect-advancedmd-to-ai-agents-automate-bulk-patient-data-workflows/).

Giving ChatGPT read-and-write access to a clinical system like AdvancedMD is a massive undertaking. Healthcare APIs are notoriously complex, deeply nested, and heavily guarded. This guide breaks down exactly how to use Truto to generate a secure MCP server for AdvancedMD, connect it to ChatGPT, and execute multi-step clinical queries using natural language.

> Stop writing boilerplate healthcare integrations. Let Truto generate secure, [HIPAA-ready MCP servers](https://truto.one/blog/zero-data-retention-mcp-servers-building-soc-2-gdpr-compliant-ai-agents/) for your clinical AI agents in seconds.
>
> [Talk to us](https://truto.one/book-a-demo/)

## The Engineering Reality of the AdvancedMD API

Building a custom MCP server for AdvancedMD means owning the entire API integration lifecycle. While the MCP standard dictates [how the model discovers your tools](https://truto.one/blog/what-is-mcp-and-mcp-servers-and-how-do-they-work/), translating the model's intent into valid AdvancedMD requests is entirely on your shoulders.

AdvancedMD's modern API surface is built on the FHIR (Fast Healthcare Interoperability Resources) R4 standard. While FHIR is highly standardized, it introduces specific architectural challenges for LLM integrations that break standard CRUD assumptions.

### The Complexity of FHIR Bundles and Pagination
When an LLM asks "Get me all observations for patient X," the AdvancedMD API does not return a simple flat array of records. It returns a FHIR `Bundle`. The actual data is nested inside `entry.*.resource`. 

Furthermore, pagination in FHIR relies on opaque `next` links provided within the Bundle. Your MCP server must intercept the LLM's requests, translate generic query arguments into specific FHIR search parameters (e.g., `patient=123&category=vital-signs`), and then parse the resulting Bundle to extract the cursor for the next page. If you pass the raw FHIR payload directly to the LLM, the model will waste massive amounts of its context window on metadata and structural wrapper elements.

### Contextual Token Scoping
AdvancedMD API requests are deeply tied to the context of the OAuth token making the request. A patient token can only read its own data, while a provider's token operates in the context of the specific patient selected at sign-in. 

This means your MCP server must handle session state securely. When ChatGPT invokes a tool like `get_single_advanced_md_patient_by_id`, the underlying API request will fail if the token context is mismatched. Building an orchestration layer that maps the LLM's intent to the correct active token session requires significant middleware logic.

### Bulk Export Asynchronous Polling
AdvancedMD supports the US Core `$export` operation for bulk data extraction. This is not a synchronous REST call. When you start an export, you must pass a `Prefer: respond-async` header. AdvancedMD returns an HTTP 202 Accepted response containing a `jobId`. 

Your MCP server must provide the LLM with separate tools to initiate the job, poll the job status (looking for "In progress" vs "Done"), and eventually download the resulting NDJSON (application/fhir+ndjson) manifest files. Teaching an LLM to navigate this multi-step asynchronous state machine requires highly descriptive tool schemas and strict parameter validation.

## Step-by-Step: Connecting AdvancedMD to ChatGPT

Instead of building a custom translation layer for FHIR endpoints, you can use Truto to [auto-generate an MCP server](https://truto.one/blog/auto-generated-mcp-tools-for-ai-agents-a-2026-architecture-guide/) that is already mapped to AdvancedMD's resources.

Here is how to deploy the server and connect it to ChatGPT.

### 1. Create the AdvancedMD MCP Server

First, you must connect an AdvancedMD account via OAuth through Truto. Truto will securely manage the token lifecycles and refresh them automatically before they expire. Once the account is connected, you can provision an MCP server scoped specifically to that tenant.

You can create the MCP server using either the Truto Dashboard or the Truto API.

**Method A: Via the Truto UI**
1. Log into your Truto dashboard and navigate to the **Integrated Accounts** page.
2. Click on the connected AdvancedMD account.
3. Navigate to the **MCP Servers** tab.
4. Click **Create MCP Server**.
5. Select your desired configuration (e.g., filter by specific FHIR methods or set an expiration date).
6. Copy the generated MCP Server URL (e.g., `https://api.truto.one/mcp/a1b2c3...`). Keep this secure.

**Method B: Via the Truto API**
You can also [provision servers dynamically](https://truto.one/blog/auto-generated-mcp-tools-for-ai-agents-a-2026-architecture-guide/) using your Truto API key. This is the preferred method for programmatically spinning up agent environments per customer.

```bash
curl -X POST https://api.truto.one/integrated-account/<INTEGRATED_ACCOUNT_ID>/mcp \
  -H "Authorization: Bearer $TRUTO_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "AdvancedMD Clinical Agent",
    "config": {
      "methods": ["read", "custom"],
      "tags": ["patient", "clinical"]
    },
    "expires_at": "2026-12-31T23:59:59Z"
  }'
```

The API returns a payload containing the `url`. This single URL handles all routing, authentication, and schema translation.

### 2. Connect the MCP Server to ChatGPT

Once you have the Truto MCP URL, you need to register it as a tool provider for your ChatGPT instance. You can do this via the ChatGPT desktop UI or via a manual configuration file if you are running a custom agent environment.

**Method A: Via the ChatGPT UI (Custom Connectors)**
1. Open your ChatGPT desktop or web app.
2. Navigate to **Settings -> Apps -> Advanced settings**.
3. Toggle on **Developer mode** (required for MCP support).
4. Under MCP servers / Custom connectors, click **Add new server**.
5. Name the connector (e.g., "AdvancedMD (Truto)").
6. Paste your Truto MCP URL into the Server URL field.
7. Click **Save**.

ChatGPT will immediately ping the endpoint, perform the MCP handshake, and ingest the tool schemas.

**Method B: Via Manual Config File (Custom Agent Environments)**
If you are running a custom AI agent framework that supports MCP (like LangChain, LlamaIndex, or raw Claude Desktop), you can configure the connection manually. Truto provides the tools via Server-Sent Events (SSE).

```json
{
  "mcpServers": {
    "advancedmd_production": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-sse",
        "--url",
        "https://api.truto.one/mcp/<YOUR_TRUTO_TOKEN>"
      ]
    }
  }
}
```

## Hero Tools for AdvancedMD

When the LLM handshakes with the Truto MCP server, it receives a curated list of tools derived directly from AdvancedMD's FHIR schemas. Truto normalizes the inputs (flattening query and body parameters) and standardizes the output structure. 

Here are 6 high-leverage hero tools your AI agent can immediately use to interact with clinical data.

### 1. Read Patient
**Tool Name:** `get_single_advanced_md_patient_by_id`

Fetches a comprehensive patient demographic record using their FHIR resource ID. The response includes structured data such as name, telecom, gender, birth date, and address. This is typically the entry point for any patient-specific workflow.

> "Retrieve the complete patient record for FHIR ID 'pt-98765'. I need their primary contact number and date of birth."

### 2. Search CarePlan
**Tool Name:** `list_all_advanced_md_care_plans`

Searches for active CarePlans based on filter criteria. This returns a paginated list of plans outlining the interventions, goals, and activities prescribed for a patient. 

> "Find all active care plans for patient 'pt-98765'. Let me know what specific interventions have been scheduled for their physical therapy."

### 3. Search Observation
**Tool Name:** `list_all_advanced_md_observations`

Retrieves clinical observations, which encompass lab results, vital signs, and social history. The tool accepts query parameters to filter by `patient` and `category` (e.g., `vital-signs` or `laboratory`). Truto parses the FHIR Bundle and extracts the `next_cursor` so the LLM can easily request subsequent pages.

> "Pull the most recent vital signs observations for patient 'pt-98765'. Specifically, I am looking for their last recorded blood pressure and heart rate."

### 4. Search Condition
**Tool Name:** `list_all_advanced_md_conditions`

Queries the patient's problem list. This returns `Condition` resources indicating clinical diagnoses, the clinical status (active, resolved, inactive), and verification status. This is critical for agents generating clinical summaries.

> "List all active conditions for patient 'pt-98765' documented in the last 12 months. Summarize their current chronic diagnoses."

### 5. Search DocumentReference
**Tool Name:** `list_all_advanced_md_document_references`

Locates clinical documents attached to the patient's record, such as C-CDA files, PDF specialist reports, or imaging narratives. The returned records contain metadata and URLs to fetch the actual document binaries.

> "Search for any document references for patient 'pt-98765' categorized under 'cardiology report'."

### 6. Start Bulk Data Export Job
**Tool Name:** `create_a_advanced_md_bulk_export`

Initiates an asynchronous bulk FHIR export for a specific group of patients. The agent must provide a `group_id`. Truto handles the `Prefer: respond-async` headers natively and returns the `jobId` and `groupId` needed to poll for the results using the `advanced_md_bulk_export_jobs_lookup` tool.

> "Start a bulk FHIR export job for patient group 'grp-1122'. Return the job ID so we can monitor its progress."

To view the complete inventory of available AdvancedMD tools, supported FHIR parameters, and schema structures, visit the [AdvancedMD integration page](https://truto.one/integrations/detail/advancedmd).

## Workflows in Action

Individual tools are useful, but the real power of MCP emerges when ChatGPT chains multiple API calls together to execute complex clinical workflows.

### Scenario 1: Clinical Encounter Prep (Provider Persona)

A physician asks their AI assistant to generate a clinical brief for an upcoming appointment. The LLM must aggregate data across multiple FHIR resources to build a cohesive summary.

> "Generate a pre-encounter summary for patient 'pt-98765'. I need their active conditions, their most recent vital signs, and their current care plan interventions."

**Tool Execution Sequence:**
1. `get_single_advanced_md_patient_by_id` - Fetches demographic context (age, gender).
2. `list_all_advanced_md_conditions` - Queries with `patient=pt-98765&clinical-status=active` to identify ongoing problems.
3. `list_all_advanced_md_observations` - Queries with `patient=pt-98765&category=vital-signs` and sorts by date to get the most recent readings.
4. `list_all_advanced_md_care_plans` - Retrieves active treatment pathways to understand current interventions.

**The Result:** ChatGPT digests the raw FHIR JSON from four separate endpoints and synthesizes a concise, human-readable medical brief, allowing the physician to review the patient's state in seconds without clicking through multiple EHR tabs.

### Scenario 2: Orchestrating Bulk Data Extraction (Admin Persona)

A health informatics admin needs to extract a bulk dataset for a population health analysis. Because the AdvancedMD bulk export API is asynchronous, the LLM must handle state transitions.

> "Initiate a bulk export for the diabetic cohort (Group ID 'grp-4455'). Check the status of the job, and let me know when the export manifest is ready for download."

**Tool Execution Sequence:**
1. `create_a_advanced_md_bulk_export` - The agent passes `group_id: "grp-4455"`. The tool returns a 202 response with a `jobId`.
2. `advanced_md_bulk_export_jobs_lookup` - The agent passes the `jobId` to check the status. It sees `status: "In progress"`.
3. *(Agent pauses or instructs the user to wait)*
4. `advanced_md_bulk_export_jobs_lookup` - The agent polls again later, receiving a 200 OK with the final export manifest, containing the output URLs for the NDJSON files.

```mermaid
sequenceDiagram
  participant Agent as "ChatGPT Agent"
  participant Truto as "Truto MCP Server"
  participant AMD as "AdvancedMD API"
  Agent->>Truto: Call create_a_advanced_md_bulk_export<br>(groupId)
  Truto->>AMD: GET /v1/r4/Group/{id}/$export<br>(Async Header)
  AMD-->>Truto: 202 Accepted (jobId)
  Truto-->>Agent: Return jobId
  Agent->>Truto: Call advanced_md_bulk_export_jobs_lookup<br>(jobId)
  Truto->>AMD: GET /v1/fhir-bulk/status
  AMD-->>Truto: 202 In Progress
  Truto-->>Agent: Status: In Progress
```

## Security and Access Control

Exposing clinical FHIR APIs to a Large Language Model requires strict governance. Truto's MCP servers provide granular controls to limit what ChatGPT can access.

*   **Method Filtering:** You can restrict the MCP server to read-only operations by passing `methods: ["read"]` during creation. This ensures ChatGPT can query patient data but cannot accidentally create or update clinical records.
*   **Tag Filtering:** Limit the server's scope by functional area. Passing `tags: ["clinical"]` will omit administrative or billing endpoints, reducing the tool surface area and protecting irrelevant data.
*   **API Token Authentication:** By setting `require_api_token_auth: true`, you force the MCP client (ChatGPT) to provide an active Truto API token in the `Authorization` header, adding a second layer of identity verification on top of the obscure URL.
*   **Ephemeral Servers:** Set an `expires_at` timestamp. Truto will automatically revoke the URL and destroy the underlying KV mapping when the timestamp is reached, ensuring temporary agent sessions cannot be abused long-term.

### A Note on Rate Limits
AdvancedMD enforces strict API rate limits to protect system stability. Truto's proxy layer is designed for transparency: it does not arbitrarily retry, throttle, or apply backoff logic on rate limit errors. 

If the AdvancedMD API returns an HTTP 429 (Too Many Requests), Truto passes that error directly back to ChatGPT. Truto normalizes the upstream rate limit headers into standardized IETF headers (`ratelimit-limit`, `ratelimit-remaining`, `ratelimit-reset`). The caller (your agent framework) is responsible for reading these headers and orchestrating the appropriate retry and backoff strategy.

## Architecting for Scale

Connecting AdvancedMD to ChatGPT transforms how healthcare providers interact with clinical data. Instead of manually navigating complex PM software, clinicians can query patient histories, orchestrate bulk exports, and summarize care plans using natural language.

By leveraging Truto's auto-generated MCP servers, you eliminate the need to write custom FHIR parsers, manage OAuth token lifecycles, or hardcode LLM tool definitions. Your engineering team can focus on refining the AI agent's prompts and behaviors, while Truto handles the harsh reality of the underlying integration infrastructure.
