GraphQL API
Aidbox supports default GraphQL implementation without any extensions (spec located here) Queries are supported, but mutations are not (yet)
In Aidbox UI there is GraphiQL interface, you can try your queries there. GraphQL console sends all your requests to $graphql endpoint which you can use from your application too
post
/$graphql
GraphQL endpoint
Aidbox generates different GraphQL scalars, objects, queries with args and unions from FHIR metadata.

Queries

For each ResourceType two queries are generated:
    <resourceType> e.g.: Patient. Receives a single parameter id and returns a resource with the requested id. For example: Patient (id: "pat-1")
    <resourceType>Liste.g.: PatientList. Receives FHIR search parameters for that resourceType. SearchParameters have underscores instead of dashes and referenced later in this doc as search_parameter. For each SearchParameter there are two args generated:
      <search_parameter> e.g.: PatientList(address_state: "CA") Accepts a string. Is an equivalent of using FHIR search parameter
      <search_parameter>_list e.g.: PatientList(language_list: ["en", "de"]) Accepts a list of strings. It is an equivalent of repeating search parameters in FHIR search. <search_parameter>_list arg is needed because args can't be repeated in the GraphQL query.

Examples

    PatientList(language_list: ["en", "de"]) will return a set of Patients the same as GET /Patient?language=en&language=de and those will be patients with en AND de as their communication language specified
    PatientList(language: "en,de") will return a set of Patients the same as GET /Patient?language=en,de and those will be patients with en OR de as their communication language specified
    PatientList(language_list: ["en", "de,fr"]) will return a set of Patients the same as GET /Patient?language=en&language=de,fr and those will be patients with en AND (de OR fr) as their communication language specified
    PatientList(language: "en", language: "de") is an error, it will ignore all language arg repetitions except of the last and will return a set of Patients the same as
    GET /Patient?language=de

Objects

For each ResourceType object with fields is generated. For every FHIR resource attribute field is created. Also for attributes with Reference type unions are created for direct and reverse includes Reverse include fields have such format: <revIncludeResourceType>s_as_<includedResourceReferenceSearchParameter> e.g.: observations_as_subject for Patient will be equivalent of _revinclude=Observation:subject

Example

Request
Response
POST /$graphql
1
{
2
"query" : "
3
fragment PractitionerRoleWithPractitioner on PractitionerRole {
4
id
5
code {
6
coding {
7
code
8
system
9
display
10
}
11
}
12
practitioner {
13
resource {
14
... on Practitioner {
15
id
16
name {
17
given
18
}
19
}
20
}
21
}
22
}
23
{
24
PatientList(active: true, identifier_list: [\"tenantId|org1\", \"mrn|5678\"]) {
25
id
26
name {
27
given
28
}
29
generalPractitioner {
30
resource {
31
...PractitionerRoleWithPractitioner
32
}
33
}
34
observations_as_subject {
35
id
36
code {
37
coding {
38
code
39
system
40
display
41
}
42
}
43
performer {
44
resource {
45
...PractitionerRoleWithPractitioner
46
}
47
}
48
}
49
}
50
}
51
"}
Copied!
1
{
2
"data" : {
3
"PatientList" : [ {
4
"id" : "51f507b5-8723-4dda-bee6-d3cbd86da28f",
5
"name" : [ {
6
"given" : [ "Tom" ]
7
} ],
8
"generalPractitioner" : [ {
9
"resource" : {
10
"id" : "54513486-7b9c-4baf-84b6-8d1bdb279ba3",
11
"code" : [ {
12
"coding" : [ {
13
"code" : "therapist",
14
"system" : "sys",
15
"display" : "Therapist"
16
} ]
17
} ],
18
"practitioner" : {
19
"resource" : {
20
"id" : "0091e1ee-8a5b-45a1-a1be-c2638e6ed482",
21
"name" : [ {
22
"given" : [ "Doc" ]
23
} ]
24
}
25
}
26
}
27
} ],
28
"observations_as_subject" : [ {
29
"id" : "68100e43-4d1c-4fb7-b4d9-2f14d359fe90",
30
"code" : {
31
"coding" : [ {
32
"code" : "15074-8",
33
"system" : "http://loinc.org",
34
"display" : "Glucose"
35
} ]
36
},
37
"performer" : [ {
38
"resource" : {
39
"id" : "54513486-7b9c-4baf-84b6-8d1bdb279ba3",
40
"code" : [ {
41
"coding" : [ {
42
"code" : "therapist",
43
"system" : "sys",
44
"display" : "Therapist"
45
} ]
46
} ],
47
"practitioner" : {
48
"resource" : {
49
"id" : "0091e1ee-8a5b-45a1-a1be-c2638e6ed482",
50
"name" : [ {
51
"given" : [ "Doc" ]
52
} ]
53
}
54
}
55
}
56
} ]
57
} ]
58
} ]
59
}
60
}
Copied!
If you have any questions feel free to reach us at Aidbox users chat.
Last modified 4mo ago