Scheduling API Interactions - adamacrown1/schedulingAPI GitHub Wiki
The following document provides a developer an overview of how to interact with the Ignite FHIR APIs, and specifically Scheduling (GET /Slot, POST /Appointment, and GET /Appointment).
- It is assumed access to the API has already been ascertained.
- Developer has downloaded Postman.
For our use case, we have interest as an external application developer to:
- Identify open schedule slots for a specific provider, and slot type
- Book an appointment on behalf of a consumer
- Review that we've successfully booked the appointment
In our test environment, we will use the following variables to interact with the API:
-
Patient Name:
Wilma Smart
-
Patient ID:
4342008
-
Slot Type:
General Medicine
-
Slot Type Coding:
http://snomed.info/sct
-
Slot Type Code:
394581000
-
Practitioner Name:
Carter, Kristen Cerner
-
Practitioner ID:
605926
We must first identify the schedules that are open so that we can book on behalf of our consumer user. We can search by:
- Slot Type
- Schedule Actor
- Location
- Start
As an example API call, structured to search the FHIR endpoint by a specific Slot Type, a Start year, and with a specific Practitioner, I will return all applicable, open slots that can be booked.
https://{{endpoint}}.{{environment}}.com/dstu2/{{tenantId}}/Slot?slot-type={{slotType}}&start={{year}}&_count=20&schedule.actor=Practitioner/{{practitionerId}}
In my example, against the FHIR test environment, this is my resulting API call: https://fhir-ehr.sandboxcerner.com/dstu2/0b8a0111-e8e6-4c26-a91c-5069cbc6b1ca/Slot?slot-type=http%3A%2F%2Fsnomed.info%2Fsct%7C408443003&schedule.actor=Practitioner%2F605926&start=2020&_count=20
The API yields the following result, one of many open slots:
"entry": [{
"fullUrl": "https://fhir-ehr.sandboxcerner.com/dstu2/0b8a0111-e8e6-4c26-a91c-5069cbc6b1ca/Slot/5038373-4048296-7731127-330",
"resource": {
"resourceType": "Slot",
"id": "5038373-4048296-7731127-330",
"meta": {
"versionId": "0",
"lastUpdated": "2019-03-04T22:07:30.000Z"
},
"text": {
"status": "generated",
"div": "<div><p><b>Slot</b></p><p><b>Type</b>: Office Visit - Follow Up</p><p><b>Start</b>: Jan 7, 2020 7:30 P.M. UTC</p><p><b>End</b>: Jan 7, 2020 8:00 P.M. UTC</p><p><b>Status</b>: Free</p></div>"
},
"extension": [{
"url": "https://fhir-ehr.cerner.com/dstu2/StructureDefinition/scheduling-location",
"valueReference": {
"reference": "Location/4048296"
}
}],
"type": {
"coding": [{
"system": "http://snomed.info/sct",
"code": "408443003",
"display": "General medical practice",
"userSelected": false
},
{
"system": "https://fhir.cerner.com/0b8a0111-e8e6-4c26-a91c-5069cbc6b1ca/codeSet/14249",
"code": "5038373",
"display": "Office Visit - Follow Up",
"userSelected": true
}
],
"text": "Office Visit - Follow Up"
},
"schedule": {
"reference": "Schedule/5038373-4048296-7731127-330"
},
"freeBusyType": "free",
"start": "2020-01-07T19:30:00.000Z",
"end": "2020-01-07T20:00:00.000Z"
},
"search": {
"mode": "match"
}
},
The most critical element in this response, is the Slot.id value:
5038373-4048296-7731127-330
. It is the primary identifier used when booking the appointment, against the POST /Appointment resource.
Now that we've identified an open slot, 5038373-4048296-7731127-330
, let's book.
Our API request will look like the following:
- POST
https://{{endpoint}}.{{environment}}.com/dstu2/{{tenantId}}/Appointment/
In this specific example, against the test environment:
- POST
https://fhir-ehr.sandboxcerner.com/dstu2/0b8a0111-e8e6-4c26-a91c-5069cbc6b1ca/Appointment/
Our API request headers will follow what is found at fhir.cerner.com. For posterity:
- Authorization:
- Accept: application/json+fhir
- Content-Type: application/json+fhir
Let's compose our POST /Appointment payload. A few key variables to build:
- Appointment.slot.reference:
Slot/{{slotId}}
- Appointment.participant.actor.reference:
Patient/{{patientId}}
- Appointment.participant.actor.display:
{{patientFamilyName}}, {{patientGivenName}}
Our body of the POST will look as such:
{
"resourceType": "Appointment",
"slot": [
{
"reference": "Slot/5038373-4048296-7731127-330"
}
],
"participant": [
{
"actor": {
"reference": "Patient/4342008",
"display": "Smart, Wilma"
},
"status": "needs-action"
}
],
"status": "proposed"
}