GraphQL Query Examples
Here we imagine we wish to book a New Patient Exam Appointment for a patient at a location
Get a location
Imagine we need to get a location - in this case we'll look up Palo Alto
Request
query location {
locations(where: { name: { _eq: "Palo Alto" } }) {
id
name
address {
addressLine1
addressLine2
state
zip
}
}
}Response
{
"data": {
"locations": [
{
"id": "d8f5120e-1dbc-4ca7-bf78-f49680a28201",
"name": "Palo Alto",
"address": {
"addressLine1": "5541 Yundt Knoll",
"addressLine2": null,
"state": "IL",
"zip": "72775"
}
}
]
}
}The correct appointment type for that location
Get the appointment type that we want to use for booking against, in this case we will use a new exam type. This may be something you need to know about in terms of the naming as provided by the organization, as they can name these themselves.
Request
query appointmentTemplates {
appointmentTemplates(
where: {
fullName: { _eq: "New Patient Exam" }
location: { id: { _eq: "d8f5120e-1dbc-4ca7-bf78-f49680a28201" } }
}
) {
appointmentType {
id
}
fullName
}
}Response
{
"data": {
"appointmentTemplates": [
{
"appointmentType": {
"id": "f250d550-b89d-43b5-8dae-4a11c423b749"
},
"fullName": "New Patient Exam"
}
]
}
}Checking appointment slot availability
Let's get appointment slots available for this appointment type and location, in a range
Request
query availablity {
appointmentAvailability(
from: "2024-09-01"
until: "2024-09-30"
appointmentTypeId: "f250d550-b89d-43b5-8dae-4a11c423b749"
locationId: "d8f5120e-1dbc-4ca7-bf78-f49680a28201"
) {
date
slotsAvailability
}
}Response
{
"data": {
"appointmentAvailability": [
{
"date": "2024-09-11",
"slotsAvailability": [
"15:00",
"16:00",
"17:00",
"18:00",
"19:00",
"20:00",
"21:00",
"22:00"
]
},
{
"date": "2024-09-12",
"slotsAvailability": [
"15:00",
"16:00",
"17:00",
"18:00",
"19:00",
"20:00",
"21:00",
"22:00"
]
},
{
"date": "2024-09-13",
"slotsAvailability": [
"15:00",
"16:00",
"17:00",
"18:00",
"19:00",
"20:00",
"21:00",
"22:00"
]
}
]
}
}Get an appointment id to book against
When you have a treatment plan that plan consists of a chain a of appointments. Patients schedule booking against each appointment as it comes up. In this case we're booking an 'out of treatment' booking - a new Patient Exam. So we need an adhoc appointment id to make the booking against.
If you are rescheduling an appointment or scheduling for an existing an appointment, you will get the appointment id from the patient appointments query, skipping the preceding steps.
Request
mutation getAppointmentId {
insertAppointment(
patientId: "1bdc2ba6-f5b1-4a0c-9c9f-618ba23c82ef"
appointmentTypeId: "f250d550-b89d-43b5-8dae-4a11c423b749"
locationId: "d8f5120e-1dbc-4ca7-bf78-f49680a28201"
) {
id
}
}Response
{
"data": {
"insertAppointment": {
"id": "e9d84504-f045-413b-ab58-ad5e5f4c9797"
}
}
}Schedule an appointment booking slot
With a known available slot, and an appointment id, let's schedule the booking.
Request
mutation bookAppointmentSlot {
scheduleAppointmentBooking(
slotLocalDate: "2024-09-11"
slotLocalTime: "16:00"
appointmentId: "e9d84504-f045-413b-ab58-ad5e5f4c9797"
locationId: "d8f5120e-1dbc-4ca7-bf78-f49680a28201"
) {
id
}
}Response
{
"data": {
"scheduleAppointmentBooking": {
"id": "957a28ad-a96d-4e3d-ae2c-0bfa5cf9fa49"
}
}
}