Customer: Examples

Create a new Patient

See also: FHIR interaction: create

  1. Make sure you know the following pieces of information, which will have been issued to you by the Integration Team:

    1. Your client ID

    2. Your client secret

    3. The URL for your endpoint on the sandbox environment

      1. The example below assumes you have a server host of: acme.fhir-api.sandbox.patientsknowbest.com

  2. Generate an access token by following the OAuth 2.0 Client credentials walkthrough

    1. The example below assumes you have been granted an access token of: abcdef

  3. Create the new Patient resource by POST-ing the Patient resource to the Patient type service on your own endpoint (replacing the values with your own as required)

Request

curl -X POST --header "Accept: application/fhir+json" --header "Content-Type: application/fhir+json" --header "Authorization: Bearer abcdef" "https://acme.fhir-api.sandbox.patientsknowbest.com/fhir/Patient" --data "{ \"resourceType\": \"Patient\", \"name\": [ { \"family\": \"Bloggs\", \"given\": [ \"Joe\" ] } ] }"

Response

Success

A successful request will respond with the resource that was created, along with any server-assigned identification. You can see in this example that a resource ID of f7fffd5c-122f-4b15-bdb5-c87b9dc1850a has been assigned to the newly created resource.

{ "name":[{"given":["Joe"],"family":"Bloggs"}], "id":"f7fffd5c-122f-4b15-bdb5-c87b9dc1850a", "resourceType":"Patient", "meta":{ "lastUpdated":"2022-07-28T11:46:13.182779Z", "versionId":"6", "extension":[{"url":"ex:createdAt","valueInstant":"2022-07-28T11:46:13.182779Z"}] } }

Error

Where possible, a helpful OperationOutcome will be returned.

Search for all Appointments

See also: FHIR interaction: search

  1. Make sure you know the following pieces of information, which will have been issued to you by the Integration Team:

    1. Your client ID

    2. Your client secret

    3. The URL for your endpoint on the sandbox environment

      1. The example below assumes you have a server host of: acme.fhir-api.sandbox.patientsknowbest.com

  2. Generate an access token by following the OAuth 2.0 Client credentials walkthrough

    1. The example below assumes you have been granted an access token of: abcdef

  3. Search for all Appointment resources by executing the following query

Request

curl -X GET --header "Accept: application/fhir+json" --header "Content-Type: application/fhir+json" --header "Authorization: Bearer abcdef" "https://acme.fhir-api.sandbox.patientsknowbest.com/fhir/Appointment"

Response

The server will return a searchset Bundle containing the results of your search. For example, this shows a single Appointment.

{ "resourceType":"Bundle", "type":"searchset", "meta":{"versionId":"7"}, "total":1, "link":[{"relation":"first","url":"/fhir/Appointment?page=1"},{"relation":"self","url":"/fhir/Appointment?page=1"}], "entry":[{ "resource":{ "end":"2022-07-28T14:38:32", "start":"2022-07-28T13:38:32", "status":"booked", "participant":[{"actor":{"reference":"Patient/f7fffd5c-122f-4b15-bdb5-c87b9dc1850a"},"status":"accepted"}], "id":"f4efe66d-4cea-4199-9182-9d2113dd3108", "resourceType":"Appointment", "meta":{"lastUpdated":"2022-07-28T13:00:33.483304Z","versionId":"7","extension":[{"url":"ex:createdAt","valueInstant":"2022-07-28T13:00:33.483304Z"}]}}, "fullUrl":"https://acme.fhir-api.sandbox.patientsknowbest.com/Appointment/f4efe66d-4cea-4199-9182-9d2113dd3108", "link":[{"relation":"self","url":"https://acme.fhir-api.sandbox.patientsknowbest.com/Appointment/f4efe66d-4cea-4199-9182-9d2113dd3108"}] } ] }

Create a new Appointment

See also: FHIR interaction: create

  1. Make sure you know the following pieces of information, which will have been issued to you by the Integration Team:

    1. Your client ID

    2. Your client secret

    3. The URL for your endpoint on the sandbox environment

      1. The example below assumes you have a server host of: acme.fhir-api.sandbox.patientsknowbest.com

  2. Make sure you know the following pieces of information, which will depend on the data you have sent to PKB:

    1. The id of the Patient for whom the Appointment is scheduled

      1. The example below assumes the relevant patient is: Patient/f7fffd5c-122f-4b15-bdb5-c87b9dc1850a

  3. Generate an access token by following the OAuth 2.0 Client credentials walkthrough

    1. The example below assumes you have been granted an access token of: abcdef

  4. Create the new Appointment resource by POST-ing the Appointment resource to the Appointment type service on your own endpoint (replacing the values with your own as required)

Request

curl -X POST --header "Accept: application/fhir+json" --header "Content-Type: application/fhir+json" --header "Authorization: Bearer abcdef" "https://acme.fhir-api.sandbox.patientsknowbest.com/fhir/Appointment" --data "{ \"resourceType\": \"Appointment\", \"status\": \"booked\", \"start\": \"2022-07-28T13:38:32\", \"end\": \"2022-07-28T14:38:32\", \"participant\": [ { \"actor\": { \"reference\": \"Patient/f7fffd5c-122f-4b15-bdb5-c87b9dc1850a\" }, \"status\": \"accepted\" } ] }"

Response

Success

A successful request will respond with the resource that was created, along with any server-assigned identification. You can see in this example that a resource ID of f4efe66d-4cea-4199-9182-9d2113dd3108 has been assigned to the newly created resource.

{ "end":"2022-07-28T14:38:32", "start":"2022-07-28T13:38:32", "status":"booked", "participant":[{"actor":{"reference":"Patient/f7fffd5c-122f-4b15-bdb5-c87b9dc1850a"},"status":"accepted"}], "id":"f4efe66d-4cea-4199-9182-9d2113dd3108", "resourceType":"Appointment", "meta":{ "lastUpdated":"2022-07-28T13:00:33.483304Z", "versionId":"7", "extension":[{"url":"ex:createdAt","valueInstant":"2022-07-28T13:00:33.483304Z"}] } }

Error

Where possible, a helpful OperationOutcome will be returned.

Read a specific Appointment

See also: FHIR interaction: read

  1. Make sure you know the following pieces of information, which will have been issued to you by the Integration Team:

    1. Your client ID

    2. Your client secret

    3. The URL for your endpoint on the sandbox environment

      1. The example below assumes you have a server host of: acme.fhir-api.sandbox.patientsknowbest.com

  2. Make sure you know the following pieces of information, which will depend on the data you have sent to PKB:

    1. The id of the Appointment that you wish to read

      1. The example below assumes the relevant appointment is: Appointment/f4efe66d-4cea-4199-9182-9d2113dd3108

  3. Generate an access token by following the OAuth 2.0 Client credentials walkthrough

    1. The example below assumes you have been granted an access token of: abcdef

  4. Read the Appointment by executing the following query.

Request

curl -X GET --header "Accept: application/fhir+json" --header "Content-Type: application/fhir+json" --header "Authorization: Bearer abcdef" "https://acme.fhir-api.sandbox.patientsknowbest.com/fhir/Appointment/f4efe66d-4cea-4199-9182-9d2113dd3108"

Response

Success

A successful request will respond with the resource that has the corresponding ID.

{ "end":"2022-07-28T14:38:32", "start":"2022-07-28T13:38:32", "status":"booked", "participant":[{"actor":{"reference":"Patient/f7fffd5c-122f-4b15-bdb5-c87b9dc1850a"},"status":"accepted"}], "id":"f4efe66d-4cea-4199-9182-9d2113dd3108", "resourceType":"Appointment", "meta":{ "lastUpdated":"2022-07-28T13:00:33.483304Z", "versionId":"7", "extension":[{"url":"ex:createdAt","valueInstant":"2022-07-28T13:00:33.483304Z"}] } }

Error

Where possible, a helpful OperationOutcome will be returned.

Update a specific Appointment

See also: FHIR interaction: update

  1. Make sure you know the following pieces of information, which will have been issued to you by the Integration Team:

    1. Your client ID

    2. Your client secret

    3. The URL for your endpoint on the sandbox environment

      1. The example below assumes you have a server host of: acme.fhir-api.sandbox.patientsknowbest.com

  2. Make sure you know the following pieces of information, which will depend on the data you have sent to PKB:

    1. The id of the Appointment you wish to update

      1. The example below assumes the relevant appointment is: Appointment/f4efe66d-4cea-4199-9182-9d2113dd3108

  3. Generate an access token by following the OAuth 2.0 Client credentials walkthrough

    1. The example below assumes you have been granted an access token of: abcdef

  4. Update the existing Appointment resource by PUT-ing the Appointment resource to the Appointment instance service on your own endpoint (replacing the values with your own as required)

Request

curl -X PUT --header "Accept: application/fhir+json" --header "Content-Type: application/fhir+json" --header "Authorization: Bearer abcdef" "https://acme.fhir-api.sandbox.patientsknowbest.com/fhir/Appointment/f4efe66d-4cea-4199-9182-9d2113dd3108" --data "{ \"resourceType\": \"Appointment\", \"status\": \"noshow\", \"start\": \"2022-07-28T13:38:32\", \"end\": \"2022-07-28T14:38:32\", \"participant\": [ { \"actor\": { \"reference\": \"Patient/f7fffd5c-122f-4b15-bdb5-c87b9dc1850a\" }, \"status\": \"accepted\" } ] }"

Response

Success

A successful request will respond with the new content of the resource that was updated.

{ "end":"2022-07-28T14:38:32", "start":"2022-07-28T13:38:32", "status":"noshow", "participant":[{"actor":{"reference":"Patient/f7fffd5c-122f-4b15-bdb5-c87b9dc1850a"},"status":"accepted"}], "id":"f4efe66d-4cea-4199-9182-9d2113dd3108", "resourceType":"Appointment", "meta":{ "lastUpdated":"2022-07-28T13:43:09.425633Z", "versionId":"9", "extension":[{"url":"ex:createdAt","valueInstant":"2022-07-28T13:43:09.425633Z"}] } }

Error

Where possible, a helpful OperationOutcome will be returned.

Delete a specific Appointment

See also: FHIR interaction: delete

  1. Make sure you know the following pieces of information, which will have been issued to you by the Integration Team:

    1. Your client ID

    2. Your client secret

    3. The URL for your endpoint on the sandbox environment

      1. The example below assumes you have a server host of: acme.fhir-api.sandbox.patientsknowbest.com

  2. Make sure you know the following pieces of information, which will depend on the data you have sent to PKB:

    1. The id of the Appointment that you wish to delete

      1. The example below assumes the relevant appointment is: Appointment/f4efe66d-4cea-4199-9182-9d2113dd3108

  3. Generate an access token by following the OAuth 2.0 Client credentials walkthrough

    1. The example below assumes you have been granted an access token of: abcdef

  4. Delete the Appointment by executing the following query.

Request

curl -X DELETE --header "Accept: application/fhir+json" --header "Content-Type: application/fhir+json" --header "Authorization: Bearer abcdef" "https://acme.fhir-api.sandbox.patientsknowbest.com/fhir/Appointment/f4efe66d-4cea-4199-9182-9d2113dd3108"

Response

Success

A successful request will respond with the resource that has been deleted.

{ "end":"2022-07-28T14:38:32", "start":"2022-07-28T13:38:32", "status":"booked", "participant":[{"actor":{"reference":"Patient/f7fffd5c-122f-4b15-bdb5-c87b9dc1850a"},"status":"accepted"}], "id":"f4efe66d-4cea-4199-9182-9d2113dd3108", "resourceType":"Appointment", "meta":{ "lastUpdated":"2022-07-28T13:32:50.830909Z", "versionId":"8", "extension":[{"url":"ex:createdAt","valueInstant":"2022-07-28T13:32:50.830909Z"}] } }

Error

Where possible, a helpful OperationOutcome will be returned.

Related content