Awell Health Developer Hub
Developer Hub

Query

  • graphql
01query GetPatients(
02 $search: String
03 $name_contains: String
04 $name_equals: String
05 $patient_code: String
06 $national_registry_number: String
07 $profile_id: [String!]
08 $count: Float!
09 $offset: Float!
10 $sort_field: String!
11 $sort_direction: String!
12) {
13 patients(
14 filters: {
15 search: { contains: $search }
16 name: { contains: $name_contains, eq: $name_equals }
17 patient_code: { eq: $patient_code }
18 national_registry_number: { eq: $national_registry_number }
19 profile_id: { in: $profile_id }
20 }
21 pagination: { count: $count, offset: $offset }
22 sorting: { field: $sort_field, direction: $sort_direction }
23 ) {
24 pagination {
25 offset
26 count
27 total_count
28 }
29 sorting {
30 field
31 direction
32 }
33 patients {
34 id
35 profile {
36 email
37 sex
38 birth_date
39 first_name
40 last_name
41 name
42 phone
43 mobile_phone
44 preferred_language
45 patient_code
46 national_registry_number
47 address {
48 street
49 city
50 zip
51 state
52 country
53 }
54 }
55 }
56 }
57}

Variables

Required parameters

There are no required parameters for this query. However, you should provide pagination and sorting parameters. See Pagination and Sorting below.

Filters

The filter is optional: if you don't provide one, an unfiltered list of patients will be returned.

  • graphql
01query GetPatients(
02 $count: Float!
03 $offset: Float!
04 $sort_field: String!
05 $sort_direction: String!
06) {
07 patients(
08 pagination: { count: $count, offset: $offset }
09 sorting: { field: $sort_field, direction: $sort_direction }
10 ) {
11 pagination {
12 offset
13 count
14 total_count
15 }
16 sorting {
17 field
18 direction
19 }
20 patients {
21 ...Patient
22 }
23 }
24}

All in filters accept a list of values and result in an is any of search criteria. The eq filter accepts a single string and results in is exact match search criteria. The contains filter accepts a single string and returns any results that partially match (case-insensitively) a set of fields. For this query, the fields searched against are name, patient_code and email. name is a user's full name, if you wish to partial match on first or last name, then use the search filter rather than the name contains or equals filters.

When specifying multiple filters, the resulting criteria is the conjuction of all filters.

  • json
01{
02 "search": "Henriet",
03 "name_contains": "Henriet",
04 "name_equals": "Henrietta Lacks",
05 "national_registry_number": "{{ NRNN }}",
06 "patient_code": "{{ PATIENT_CODE }}",
07 "profile_id": ["AWELL_PATIENT_ID_1", "AWELL_PATIENT_ID_2"],
08 "offset": 0,
09 "count": 20,
10 "sort_field": "last_name",
11 "sort_direction": "DESC"
12 }

Pagination and sorting

Pagination and sorting are required for this query. If no pagination values are supplied, the API will return only the first 10 patients, or 10 patients from the specified offset. There is also an upper limit of 100 records per query. Please be aware that setting count greater than 100 will successfully execute but return only 100 records.

Default sorting is based on the last_name field, sorted ascending. Only top-level patient profile fields can be used for sorting (e.g. birth_date, sex, patient_code). Sorting by nested fields (e.g. address.city) is not supported.

  • json
01{
02 "count": 100, // max 100
03 "offset": 0,
04 "sort_field": "last_name",
05 "sort_direction": "ASC"
06}

How to use