Skip to main content

Search for Patients with the patients Query

Welcome to the Semble GraphQL API how-to guide. In this guide, we'll walk you through the steps to find a patient using the patients query.

The patients query allows you to search for patients based on certain built in criteria such as first name, last name, email, date of birth. This query is paginated, meaning you can request a specific number of records at a time and also navigate through the records.

The patients query looks like this:

search: String
pagination: Pagination
options: QueryOptions
): PatientData

Where PatientData is:

type PatientData {
data: [Patient]
pageInfo: PageInfo

And Patient is:

type Patient {
id: ID
title: String
status: String
firstName: String
lastName: String
fullName: String
dob: Date
gender: String
sex: String
email: String
googleClientId: String
paymentReference: String
phones: [Phone]
occupation: String
address: Address
membershipName: String
membershipStartDate: String
sharingToken: SharingToken
numbers: [PatientNumber]
customAttributes: [CustomAttribute]
communicationPreferences: CommunicationPreferences
relatedAccounts: [PatientRelationship]
bookings(start: Date!, end: Date!): [Booking]
invoices(start: Date!, end: Date!): [Invoice]
letters: [Letter]
labs: [Lab]
labels: [PatientLabel]
prescriptions(page: Int, pageSize: Int): PrescriptionData
records(page: Int, pageSize: Int): RecordData
patientDocuments(page: Int, pageSize: Int): PatientDocumentData
createdAt: Date
updatedAt: Date
accessGroups: [PatientAccessGroup]
comments: String

Step 1: Authenticate

Before making any requests, make sure you have a valid token. Refer to the Authentication section for more details.

Step 2: Construct Your Query

Construct a query to fetch patient data. Here's an example where we fetch the first 10 patients with the first name "John":

curl -X POST \
-H "Content-Type: application/json" \
-H "x-token: yourtoken" \
-d '{
"query": "query findPatients($search: String, $pagination: Pagination) { patients(search: $search, pagination: $pagination) { data { id firstName lastName dob email } pageInfo { currentPage totalItems totalPages } } }",
"variables": {"search": "John", "pagination": {"limit": 10, "page": 1}}

In the query, we've specified that we want the id, firstName, lastName, dob, and email for each patient. You can modify this to include any other fields you need from the Patient type.


That's it! You've successfully used the patients query to fetch patient data. Remember, you can refine your search using the search argument, and control the amount of data you fetch at a time using pagination. Happy querying!