Skip to content

Commit

Permalink
chore(elation): docs for AI actions
Browse files Browse the repository at this point in the history
  • Loading branch information
nckhell committed Feb 4, 2025
1 parent 745d48d commit 429411b
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 4 deletions.
48 changes: 48 additions & 0 deletions extensions/elation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,51 @@ Search a physician based on a set of parameters. The ID of the physician matchin

Note that this action can only support finding one physician so if your search criteria match multiple physicians the action will throw an error.

### 🪄 Find future appointment

Tries to find a **single future appointment** for a patient based on a prompt in natural language. These are the steps executed by the action:

1. All future appointments with status `Scheduled` or `Confirmed` for the patient are retrieved from Elation.
2. Based on the provided prompt, an LLM tries to find a single appointment from the list of future appointments that matches the prompt.
3. If multiple appointments exist that match the instructions, only the first one is returned.

If a matching appointment is found, the action returns the full appointment resource and an explanation of why the LLM chose this appointment.

### 🪄 Find appointments by prompt

Tries to find **all appointments** for a patient based on a prompt in natural language. These are the steps executed by the action:

1. All appointments, independent their date or status, for the patient are retrieved from Elation.
2. Based on the provided prompt, an LLM tries to find all appointments from the list appointments that matches the prompt.

The action returns the full appointment resources of all appointments matching the prompt and an explanation of why the LLM chose these appointments. Additionally, the action returns a count of appointments by status.

Example data points output below.

Appointments (note: only displaying a partial appointment resource)
```json
[
{
"id": 456,
"scheduled_date": "2023-07-12T20:44:22Z",
"status": {
"status": "Scheduled",
},
},
{
"id": 456,
"scheduled_date": "2023-08-12T20:44:22Z",
"status": {
"status": "Confirmed",
},
}
]
```

Appointment counts by status
```json
{
"Scheduled": 1,
"Confirmed": 1,
}
```
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ChatPromptTemplate } from '@langchain/core/prompts'

export const systemPrompt = ChatPromptTemplate.fromTemplate(`You are a helpful medical assistant. You will receive a list (array) of appointments for a single patient and instructions about which types of appointments to find. You're supposed to use the information in the list to find appointments that match, if any exist. If no appointments exists that obviously match the instructions, that's a perfectly acceptable outcome. If multiple appointments exist that match the instructions, you should return all of them.
export const systemPrompt =
ChatPromptTemplate.fromTemplate(`You are a helpful medical assistant. You will receive a list (array) of appointments for a single patient and instructions about which types of appointments to find. You're supposed to use the information in the list to find appointments that match, if any exist. If no appointments exists that obviously match the instructions, that's a perfectly acceptable outcome. If multiple appointments exist that match the instructions, you should return all of them.
Important instructions:
- The appointment "reason" is the appointment type.
Expand All @@ -18,5 +19,4 @@ Instruction:
Output a JSON object with the following keys:
1. appointmentIds: array of numbers representing appointment IDs that match the instructions (or an empty array if no appointments exist that match the instructions).
2. explanation: A readable explanation of how the appointments were found and why. Or, if no appointments exist that match the instructions, an explanation of why.`
)
2. explanation: A readable explanation of how the appointments were found and why. Or, if no appointments exist that match the instructions, an explanation of why.`)
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ export const findFutureAppointment: Action<
},
events: [
addActivityEventLog({
message: `Number of future scheduled or confirmed appointments for patient ${patientId}: ${appointments.length}\nFound appointment: ${isNil(foundAppointment) ? 'none' : foundAppointment?.id}\nExplanation: ${explanation}`,
message: `Number of future scheduled or confirmed appointments: ${appointments.length}\n
Appointments data: ${JSON.stringify(appointments, null, 2)}\n
Found appointment: ${isNil(foundAppointment) ? 'none' : foundAppointment?.id}\n
Explanation: ${explanation}`,
}),
],
})
Expand Down

0 comments on commit 429411b

Please sign in to comment.