# Truepill MCP

> Truepill is an MCP Server for managing patient records and pharmacy operations. It lets your AI agent interact with core healthcare functions—creating new patients, finding existing ones by demographics, updating profiles, and pulling complete prescription histories (Rx). Use it to pull specific metadata like NDC codes or monitor real-time system events directly from conversation.

## Overview
- **Category:** data-management
- **Price:** Free
- **Tags:** pharmacy-api, patient-records, prescription-management, healthcare-it, telehealth

## Description

**Truepill** lets your AI agent handle all the grunt work of patient records and pharmacy operations. You connect it to any AI client, and instead of jumping between a bunch of dashboards, your agent just calls what's needed. It’s built for people who need fast, structured access to critical health data—period.

### **Managing Patient Profiles**

You can start by building an entirely new patient file using `create_patient`; the system returns that unique token you need right away. Need to find a person first? You don't have to guess; your agent uses `find_patient` to search the database just by name, date of birth, or zip code to locate their existing record. Once you get that patient token, `get_patient` pulls all core profile details—everything from demographics to contact info—for that specific person.

Keep the file current with **modifications**: if a client changes their phone number or email address, your agent uses `update_patient` to change those non-critical fields on an existing record. You never gotta manually type anything; it just gets updated right there.

### **Rx History and Drug Details**

The server gives you full visibility into a patient's medication history. To pull every single prescription ever filled or ordered for any given person, your agent calls `get_patient_prescriptions` using their token. You get a complete list of everything associated with that file.

If you need to drill down on just one drug—say, figuring out the NDC code or checking how many refills are left—you use `get_prescription`. This tool fetches detailed metadata for one specific medication, including exactly who prescribed it and its current refill count. It’s like having a deep dive into the drug file itself.

### **System Monitoring**

The system keeps you in the loop on everything happening at the pharmacy. When orders ship or records transfer status, your agent calls `get_webhook_events`. This grabs recent system status changes directly from the pharmacy lifecycle, letting you know about major events like shipment confirmations without having to refresh any screens.

### **How It Works**

The whole process works by giving your AI client access to specific tools. You never write API calls; you just tell your agent what you need—like "Find the record for Jane Smith born 01/01/1985"—and it handles calling `find_patient`. If that's successful, and you want her full profile, it immediately uses that token to call `get_patient`, keeping everything fast. It’s all about chaining those operations together without human intervention.

## Tools

### create_patient
Builds an entirely new patient record and returns the unique token for that profile.

### find_patient
Searches the database using demographic criteria (like name or DOB) to locate a patient's existing record.

### get_patient_prescriptions
Pulls a complete list of every prescription ever filled or ordered for a given patient's token.

### get_patient
Retrieves all core profile details for a patient when you provide their unique token.

### get_prescription
Fetches detailed metadata for one specific medication, including prescriber details and refill counts.

### get_webhook_events
Grabs recent system status changes from the pharmacy, like order shipments or transfers.

### update_patient
Modifies non-critical information on an existing patient record, such as their phone number or email address.

## Prompt Examples

**Prompt:** 
```
Find a patient named Alice Smith born on 19880425.
```

**Response:** 
```
I've searched the records. I found one match for Alice Smith (DOB: 1988-04-25) with patient token 'pt_987654321'. Would you like to see her full profile?
```

**Prompt:** 
```
Get all prescriptions for patient pt_987654321.
```

**Response:** 
```
Retrieving prescription history... Alice has 2 active prescriptions: Amoxicillin (Status: Filled) and Lisinopril (Status: Pending). Do you need the details for either of these?
```

**Prompt:** 
```
Create a new patient record for Bob Jones, male, born 19751212, living in New York 10001.
```

**Response:** 
```
I've successfully created the record for Bob Jones. His new patient token is 'pt_112233445'. You can now add prescriptions to this profile.
```

## Capabilities

### Create and modify patient profiles
The server creates new patient records using `create_patient` and allows updates to non-critical fields with `update_patient`.

### Find patients by demographics
You can locate a patient's record token simply by giving the agent name, date of birth, or zip code using `find_patient`.

### Retrieve full patient records
Once you have a token, `get_patient` pulls all demographic and contact information for that specific person.

### Fetch comprehensive Rx history
The agent calls `get_patient_prescriptions` to pull every prescription associated with a patient's token.

### Get detailed drug metadata
Using `get_prescription`, you can drill down into specific details about one medication, like the NDC or how many refills are left.

### Monitor pharmacy system events
The `get_webhook_events` tool retrieves real-time status changes from the pharmacy lifecycle, such as shipment confirmations.

## Use Cases

### Checking a complex medication history
A nurse needs to check if a patient is allergic or has taken drug X before. They ask their agent: 'Show me all prescriptions for pt_123.' The agent runs `get_patient_prescriptions` and then uses `get_prescription` on key items, pulling the full history in minutes.

### Admitting a new patient
A staff member has basic demographic data for a walk-in. They ask their agent to 'Create a record for Jane Doe.' The agent runs `create_patient`, gets the token, and confirms it's ready for use in other systems.

### Tracking an outgoing order
The pharmacy manager needs to know if today's large transfer shipment was successfully logged. They prompt their agent: 'What are the recent system events?' The agent executes `get_webhook_events` and gives them a list of confirmed status changes.

### Updating contact info for an old record
A patient calls in with a new address, but the records are old. Instead of manually finding the profile, they ask their agent to 'Update John Smith's phone number.' The agent uses `update_patient` and confirms the change.

## Benefits

- Real-time status updates: You don't have to manually check the dashboard for order changes. Running `get_webhook_events` lets your agent pull immediate notifications about shipment or transfer status changes.
- Quick patient identification: Forget tedious searches. Use `find_patient` with just a name and DOB, and the agent returns the needed token instantly. This saves minutes per lookup.
- Deep prescription dives: Need to know if a drug has refills left? Running `get_prescription` provides metadata like NDC codes and refill counts without needing a separate billing tool.
- Full profile access: Once you find the patient, `get_patient_prescriptions` pulls the entire history in one go. You get everything—not just the last thing they filled.
- Efficient data entry: If a patient moves or changes their phone number, you use `update_patient`. It handles changing contact details without requiring manual form submission.

## How It Works

The bottom line is: you talk to your AI agent, and it handles the sequence of API calls needed to build the answer for you.

1. First, subscribe to this server and enter your Truepill API Key into your AI client.
2. Next, prompt your agent with a request (e.g., 'Find the patient for John Doe'). The agent executes `find_patient` to get a token.
3. Finally, use that token in subsequent calls—like running `get_patient_prescriptions` — to pull all required data.

## Frequently Asked Questions

**How do I start using get_patient_prescriptions with Truepill?**
You first need a patient's token. Use `find_patient` to locate the ID, then pass that token directly into the agent's call for `get_patient_prescriptions`. It returns every filled prescription.

**Can I update a patient's address using update_patient?**
Yes. You use `update_patient` and specify the new address details. Just remember that core identifiers like DOB or last name cannot be changed with this tool.

**What is the difference between get_patient and find_patient?**
`find_patient` runs a search using demographics (name, zip). It gives you a token. `get_patient` takes that specific token to pull all the associated profile data.

**Does Truepill help me monitor order shipments?**
Yes. You use the `get_webhook_events` tool. This retrieves recent pharmacy events, including status changes for orders and transfers.

**How do I start with `create_patient` to onboard a new patient record?**
The `create_patient` tool generates a unique patient token. This token is essential because you must use it for all subsequent actions, like retrieving full profiles or adding prescriptions.

**What specific information does the `get_prescription` tool retrieve?**
This tool pulls deep metadata about one single prescription instance. You'll get details on the prescriber, NDC codes, and how many refills are available for that item.

**If I run `get_webhook_events`, what types of pharmacy lifecycle changes can I track?**
You monitor various system events using this tool. It tracks key stages like prescription notifications (NOTIFY_RX), new orders, shipments, or patient record transfers.

**Are there any fields in `update_patient` that are read-only?**
Yes, while you can update contact details like address and phone number, certain required identifiers—specifically the date of birth or last name—cannot be changed using this endpoint.

**Can I search for a patient without having their specific patient token?**
Yes. You can use the `find_patient` tool to search by first name, last name, date of birth, or zip code to locate the correct record.

**How do I check the status of all medications assigned to a patient?**
Use the `get_patient_prescriptions` tool with the patient's token. It will return a list of all prescriptions, their current status, and whether they are fillable.

**Is it possible to update a patient's date of birth if it was entered incorrectly?**
No. The `update_patient` tool only allows modifications to non-required fields like address, phone, and email. Required identity fields like DOB cannot be changed via this tool.