GraphQL Query Examples
The following are real-world use cases with the Greyfinch GraphQL API showing query and response.
All appointments for a patient
Get all scheduled and unscheduled appointments for a patient, sorted by bookings (those that have been scheduled) first, then unscheduled.
Request
query docs_patient_appointments {
patients(where: { appointments: { id: { _isNull: false } } }, limit: 1) {
id
person {
firstName
lastName
}
appointments(orderBy: { unplanned: DESC }) {
duration
unplanned
type {
name
}
bookings {
localStartDate
localStartTime
}
}
}
}Response
{
"data": {
"patients": [
{
"id": "a422064d-04c5-453c-8789-5f64b56f4d58",
"person": {
"firstName": "Beth",
"lastName": "Barrows"
},
"appointments": [
{
"type": {
"name": "New Patient Exam"
},
"duration": 45,
"unplanned": false,
"bookings": []
}
]
}
]
}
}All today's agenda
Get the agenda for today, who is due for appointments and what are they in for, showing first and last name of patient with appointment name and scheduled time sorted by appointment time ascending.
Request
query docs_todays_agenda {
appointmentBookings(where: { localStartDate: { _eq: "now()" } }) {
localStartDate
localStartTime
appointment {
patient {
person {
firstName
}
}
}
}
}Response
{
"data": {
"appointmentBookings": [
{
"localStartDate": "2024-05-02",
"localStartTime": "11:30",
"appointment": {
"patient": {
"person": {
"firstName": "John"
}
}
}
}
]
}
}Every image series for a patient's
Get each image series for a patient, grouped by treatment, showing the patient's first name, last name and date of birth along with image series info and treatment which it belongs to.
Request
query docs_patient_image_series {
patients(limit: 1) {
person {
firstName
lastName
birthDate
}
treatments {
name
imageSeries {
name
seriesDate
}
}
}
}Response
{
"data": {
"patients": [
{
"person": {
"firstName": "Casandra",
"lastName": "Ritchie",
"birthDate": "1970-01-01"
},
"treatments": [
{
"name": "New tx",
"imageSeries": [
{
"name": "Initial records",
"seriesDate": "2023-06-05T21:21:52+00:00"
}
]
}
]
}
]
}
}Images in an image series
Gets all images in a given image series
Request
query docs_image_series_images {
imageSeries(limit: 1) {
name
seriesDate
images {
slotKey
urlSigned
}
}
}Response
{
"data": {
"imageSeries": [
{
"name": "Initial records",
"seriesDate": "2023-06-05T21:21:52+00:00",
"images": [
{
"slotKey": "occlusalLower",
"urlSigned": "https://..."
},
{
"slotKey": "facialLateral",
"urlSigned": "https://..."
},
{
"slotKey": "facialLateral",
"urlSigned": "https://..."
},
{
"slotKey": "buccalLeft",
"urlSigned": "https://..."
},
{
"slotKey": "buccalLeft",
"urlSigned": "https://..."
}
]
}
]
}
}A Patient's Documents
Get a list of documents for a patient, showing patient's first name, last name and date of birth along with document metadata.
Request
query docs_patient_documents {
patients(limit: 1) {
person {
firstName
lastName
birthDate
}
documents {
type
name
urlSigned
}
}
}Response
{
"data": {
"patients": [
{
"person": {
"firstName": "Casandra",
"lastName": "Ritchie",
"birthDate": "1970-01-01"
},
"documents": [
{
"type": "FOLDER",
"name": "Contracts"
},
{
"type": "FOLDER",
"name": "Invoices"
},
{
"type": "FILE",
"name": "New Tx ontract.pdf"
},
{
"type": "FILE",
"name": "Extraction Letter.pdf"
}
]
}
]
}
}A clinic's appointment types
Get the list of all appointment types for a clinic.
Request
query docs_all_appointment_types {
appointmentTypes {
id
name
isVirtual
}
}Response
{
"date": {
"appointmentTypes": [
{
"id": "22318744-eefa-4bf5-bff0-e1e136e07b92",
"name": "New Patient Exam",
"isVirtual": false
}
]
}
}