Facade: Examples (REST)

Search for a Patient by NHS number

This example demonstrates how to search for a Patient resource based on their known NHS number.

  1. Generate an access token by following the OAuth 2.0 walkthrough

    1. The example below assumes you have been granted an access token of: aaaaa-bbbbb

  2. Confirm the NHS number of the patient you want to search for

    1. The example below assumes an NHS number of: 9999999999

  3. Make the call as detailed below, replacing the access token and NHS number with your own values

  4. The Patient resource will be returned in the search results

You might like to navigate to the patient's record in the web UI, in order to compare the data you can see with the data returned from the FHIR API.

Example request

This example is written for http://sandbox.patientsknowbest.com; replace the URL as needed if you are connecting to a different environment.

curl -X GET --header "Accept: application/fhir+json" --header "Authorization: Bearer aaaaa-bbbbb" "https://sandbox.patientsknowbest.com/fhir/Patient?identifier=https://fhir.nhs.uk/Id/nhs-number%7C9999999999"

Retrieve a specific Patient

This example demonstrates how to retrieve the Patient resource for a specific ID.

  1. Generate an access token by following the OAuth 2.0 walkthrough

    1. The example below assumes you have been granted an access token of: aaaaa-bbbbb

  2. Confirm the patient's ID. For example, by searching by NHS number as in the example above.

    1. The example assumes a Patient ID of: 3d8afd18-0844-459a-b3c2-355d02e54c0a

  3. Make the call as detailed below, replacing the patient ID with your own value.

  4. The Patient resource will be returned

Example request

This example is written for http://sandbox.patientsknowbest.com; replace the URL as needed if you are connecting to a different environment.

curl -X GET --header "Accept: application/fhir+json" --header "Authorization: Bearer aaaaa-bbbbb" "https://sandbox.patientsknowbest.com/fhir/Patient/3d8afd18-0844-459a-b3c2-355d02e54c0a"

Example response

Note: whilst every effort has been made to ensure that the examples are correct and useful, they do not form part of the official specification.

{ "resourceType": "Patient", "id": "3d8afd18-0844-459a-b3c2-355d02e54c0a", "extension": [ { "url": "http://fhir.patientsknowbest.com/structuredefinition/sharing-disabled", "valueBoolean": false } ], "identifier": [ { "system": "https://fhir.nhs.uk/Id/nhs-number", "value": "9999999999" } ], "name": [ { "family": "Clark", "given": [ "Louie" ], "prefix": [ "Dr" ] } ], "telecom": [ { "system": "email", "value": "louie.clark@example.com" }, { "system": "phone", "value": "07123456789" } ], "gender": "male", "birthDate": "2000-01-01", "deceasedBoolean": false, "address": [ { "line": [ "1 Main Street" ], "city": "London", "state": "London", "postalCode": "W1A 1AA", "country": "GB-ENG" } ] }

Retrieve the OperationDefinition for the Purview operation

This example demonstrates how to retrieve the OperationDefinition for the Purview operation.

Note: there is no need to provide an access token; the OperationDefinition is public.

Example request

This example is written for http://sandbox.patientsknowbest.com; replace the URL as needed if you are connecting to a different environment.

curl -X GET --header "Accept: application/fhir+json" "https://sandbox.patientsknowbest.com/fhir/OperationDefinition/Consent--purview"

Search for a patient's appointments, starting on or after a given date, including their source information

This example demonstrates how to retrieve a patient's upcoming appointments.

  1. Generate an access token by following the OAuth 2.0 walkthrough

    1. The example below assumes you have been granted an access token of: aaaaa-bbbbb

  2. Confirm the Patient reference of the patient

    1. The example below assumes a reference of: Patient/3d8afd18-0844-459a-b3c2-355d02e54c0a

  3. Confirm the date of interest

    1. The example below assumes a date of: 2018-08-01

  4. Make the call as detailed below, replacing the access token and search parameters with your own values

  5. The matching Appointment resources will be returned in the search results

Example request

This example is written for http://sandbox.patientsknowbest.com; replace the URL as needed if you are connecting to a different environment.

curl -X GET --header "Accept: application/fhir+json" --header "Authorization: Bearer aaaaa-bbbbb" "https://sandbox.patientsknowbest.com/fhir/Appointment?patient=Patient/3d8afd18-0844-459a-b3c2-355d02e54c0a&date=ge2018-08-01&_revinclude=Provenance:target"

Search for messages for a specific Patient

This example demonstrates how to search for Communication resources for a specific Patient.

  1. Generate an access token by following the OAuth 2.0 walkthrough

    1. The example below assumes you have been granted an access token of: aaaaa-bbbbb

  2. Confirm the Patient reference of the Patient you are interested in

    1. The example below assumes a reference of: Patient/3d8afd18-0844-459a-b3c2-355d02e54c0a

  3. Make the call as detailed below, replacing the access token and search parameters with your own values

  4. The matching Communication resources will be returned in the search results

Example request

This example is written for http://sandbox.patientsknowbest.com; replace the URL as needed if you are connecting to a different environment.

curl -X GET --header "Accept: application/fhir+json" --header "Authorization: Bearer aaaaa-bbbbb" "https://sandbox.patientsknowbest.com/fhir/Communication?patient=Patient/3d8afd18-0844-459a-b3c2-355d02e54c0a"

This example demonstrates how to search for Consent resources for a specific Patient.

  1. Generate an access token by following the OAuth 2.0 walkthrough

    1. The example below assumes you have been granted an access token of: aaaaa-bbbbb

  2. Confirm the Patient reference of the Patient you are interested in

    1. The example below assumes a reference of: Patient/3d8afd18-0844-459a-b3c2-355d02e54c0a

  3. Make the call as detailed below, replacing the access token and search parameters with your own values

  4. The matching Consent resources will be returned in the search results

Example request

This example is written for http://sandbox.patientsknowbest.com; replace the URL as needed if you are connecting to a different environment.

curl -X GET --header "Accept: application/fhir+json" --header "Authorization: Bearer aaaaa-bbbbb" "https://sandbox.patientsknowbest.com/fhir/Consent?patient=Patient/3d8afd18-0844-459a-b3c2-355d02e54c0a"

Search for radiology reports for a specific Patient

This example demonstrates how search for radiology reports for a specific Patient.

Since radiology reports are mapped to DiagnosticReport resources with a PKB category of RADIOLOGY, this can be achieved by searching the DiagnosticReport type.

  1. Generate an access token by following the OAuth 2.0 walkthrough

    1. The example below assumes you have been granted an access token of: aaaaa-bbbbb

  2. Confirm the Patient reference of the desired Patient

    1. The example below assumes a reference of: Patient/3d8afd18-0844-459a-b3c2-355d02e54c0a

  3. Make the call as detailed below, replacing the access token and search parameters with your own values

  4. The matching DiagnosticReport resources will be returned in the search results

Example request

This example is written for http://sandbox.patientsknowbest.com; replace the URL as needed if you are connecting to a different environment.

curl -X GET --header "Accept: application/fhir+json" --header "Authorization: Bearer aaaaa-bbbbb" "https://sandbox.patientsknowbest.com/fhir/DiagnosticReport?category=http://fhir.patientsknowbest.com/codesystem/diagnosticreport-category|RADIOLOGY&patient=Patient/3d8afd18-0844-459a-b3c2-355d02e54c0a"

Read Receipts: Search for DocumentReference resources sent by your organisation, on a given date, which have been read by the patient

This example demonstrates how to determine which of your documents have been read by the patient.

This can be achieved by providing your organisation reference, the date of interest, and a status of "READ" as input parameters to the DocumentReference type search.

  1. Generate an access token by following the OAuth 2.0 walkthrough

    1. The example below assumes you have been granted an access token of: aaaaa-bbbbb

  2. Confirm the Organization reference of your own organisation

    1. The example below assumes a reference of: Organization/235a397b-1ae8-4755-9c77-1a0e2fbc5314

  3. Confirm the date of interest

    1. The example below assumes a date of: 2018-08-01

  4. Make the call as detailed below, replacing the access token and search parameters with your own values

  5. The matching DocumentReference resources will be returned in the search results

Example request

This example is written for http://sandbox.patientsknowbest.com; replace the URL as needed if you are connecting to a different environment.

curl -X GET --header "Accept: application/fhir+json" --header "Authorization: Bearer aaaaa-bbbbb" "https://sandbox.patientsknowbest.com/fhir/DocumentReference?source-organisation=Organization/235a397b-1ae8-4755-9c77-1a0e2fbc5314&indexed=2018-08-01&document-status=http://fhir.patientsknowbest.com/codesystem/document-status|READ"

Search for encounters for a specific Patient

This example demonstrates how to search for Encounter resources for a specific Patient.

  1. Generate an access token by following the OAuth 2.0 walkthrough

    1. The example below assumes you have been granted an access token of: aaaaa-bbbbb

  2. Confirm the Patient reference of the Patient you are interested in

    1. The example below assumes a reference of: Patient/3d8afd18-0844-459a-b3c2-355d02e54c0a

  3. Make the call as detailed below, replacing the access token and search parameters with your own values

  4. The matching Encounter resources will be returned in the search results

Example request

This example is written for http://sandbox.patientsknowbest.com; replace the URL as needed if you are connecting to a different environment.

curl -X GET --header "Accept: application/fhir+json" --header "Authorization: Bearer aaaaa-bbbbb" "https://sandbox.patientsknowbest.com/fhir/Encounter?patient=Patient/3d8afd18-0844-459a-b3c2-355d02e54c0a"

Search for NamingSystem resources for a specific system value

This example demonstrates how to search for NamingSystem resources for a specific system value.

  1. Generate an access token by following the OAuth 2.0 walkthrough

    1. The example below assumes you have been granted an access token of: aaaaa-bbbbb

  2. Confirm the system of the NamingSystem you are interested in (for example, as returned in the identifier element from a query to the Patient resource)

    1. The example below assumes a system of: urn:uuid:8978a687-cf0f-4cd9-b7e9-f29e76eb5f8d

  3. Make the call as detailed below, replacing the access token and search parameters with your own values

  4. The matching NamingSystem resource will be returned in the search results

Example request

This example is written for http://sandbox.patientsknowbest.com; replace the URL as needed if you are connecting to a different environment.

curl -X GET --header "Accept: application/fhir+json" --header "Authorization: Bearer aaaaa-bbbbb" "https://sandbox.patientsknowbest.com/fhir/NamingSystem?value:exact=urn:uuid:8978a687-cf0f-4cd9-b7e9-f29e76eb5f8d"

Search for laboratory results for a specific Patient

This example demonstrates how search for laboratory results for a specific Patient.

Since laboratory results are mapped to Observation resources with a PKB category of LABORATORY, this can be achieved by searching the Observation type.

  1. Generate an access token by following the OAuth 2.0 walkthrough

    1. The example below assumes you have been granted an access token of: aaaaa-bbbbb

  2. Confirm the Patient reference of the desired Patient

    1. The example below assumes a reference of: Patient/3d8afd18-0844-459a-b3c2-355d02e54c0a

  3. Make the call as detailed below, replacing the access token and search parameters with your own values

  4. The matching Observation resources will be returned in the search results

Example request

This example is written for http://sandbox.patientsknowbest.com; replace the URL as needed if you are connecting to a different environment.

curl -X GET --header "Accept: application/fhir+json" --header "Authorization: Bearer aaaaa-bbbbb" "https://sandbox.patientsknowbest.com/fhir/Observation?category=http://fhir.patientsknowbest.com/codesystem/observation-category|LABORATORY&patient=Patient/3d8afd18-0844-459a-b3c2-355d02e54c0a"

Retrieve a specific Organization

This example demonstrates how to retrieve the Organization resource for a specific ID.

  1. Generate an access token by following the OAuth 2.0 walkthrough

    1. The example below assumes you have been granted an access token of: aaaaa-bbbbb

  2. Confirm the ID of the Organization

    1. The example below assumes an ID of: 235a397b-1ae8-4755-9c77-1a0e2fbc5314

  3. Make the call as detailed below, replacing the access token and ID with your own values

  4. The Organization resource will be returned

Example request

This example is written for http://sandbox.patientsknowbest.com; replace the URL as needed if you are connecting to a different environment.

curl -X GET --header "Accept: application/fhir+json" --header "Authorization: Bearer aaaaa-bbbbb" "https://sandbox.patientsknowbest.com/fhir/Organization/235a397b-1ae8-4755-9c77-1a0e2fbc5314"

Retrieve a specific Practitioner

This example demonstrates how to retrieve the Practitioner resource for a specific ID.

  1. Generate an access token by following the OAuth 2.0 walkthrough

    1. The example below assumes you have been granted an access token of: aaaaa-bbbbb

  2. Confirm the ID of the Practitioner

    1. The example below assumes an ID of: fe486948-b6e2-4826-9a7a-f78cf671fea9

  3. Make the call as detailed below, replacing the access token and ID with your own values

  4. The Practitioner resource will be returned

Example request

This example is written for http://sandbox.patientsknowbest.com; replace the URL as needed if you are connecting to a different environment.

curl -X GET --header "Accept: application/fhir+json" --header "Authorization: Bearer aaaaa-bbbbb" "https://sandbox.patientsknowbest.com/fhir/Practitioner/fe486948-b6e2-4826-9a7a-f78cf671fea9"

Retrieve a specific ProcedureRequest as a System client

This example demonstrates how to retrieve the ProcedureRequest resource for a specific ID.

  1. Generate an access token by following the OAuth 2.0 walkthrough

    1. The example below assumes you have been granted an access token of: aaaaa-bbbbb

  2. Confirm the ID of the Organisation whose ProcedureRequest you are fetching

    1. The example below assumes you have an ID of: 235a397b-1ae8-4755-9c77-1a0e2fbc5314

  3. Confirm the ID of the ProcedureRequest

    1. The example below assumes you have an ID of: 2f292349-6893-4813-868b-ec00e8318c8c

  4. Make the call as detailed below, replacing the access token and ProcedureRequest ID with your own values

  5. The matching ProcedureRequest resource will be returned

Example request

This example is written for http://sandbox.patientsknowbest.com; replace the URL as needed if you are connecting to a different environment.

curl -X GET --header "Accept: application/fhir+json" --header "Authorization: Bearer aaaaa-bbbbb" --header "X-Org-Public-Id: 235a397b-1ae8-4755-9c77-1a0e2fbc5314" "https://sandbox.patientsknowbest.com/fhir/ProcedureRequest/2f292349-6893-4813-868b-ec00e8318c8c"

Example response

Note: whilst every effort has been made to ensure that the examples are correct and useful, they do not form part of the official specification.

{ "resourceType":"ProcedureRequest", "id":"2f292349-6893-4813-868b-ec00e8318c8c", "meta":{ "lastUpdated":"2022-05-27T07:01:10+00:00" }, "extension":[ { "url":"http://hl7.org/fhir/StructureDefinition/procedurerequest-questionnaireRequest", "valueReference":{ "reference":"Questionnaire/bd17e556-20e3-4f01-8078-30e5f675b0f2", "display": "IBD Control PROM" } } ], "identifier":[ { "system":"org-uuid", "value":"id-value" } ], "status":"active", "intent":"order", "code":{ "text":"Questionnaire" }, "subject":{ "reference":"Patient/ca9db36c-1b77-4d12-9246-d78fa5d13e8c", "display": "Mr Test Patient" }, "authoredOn":"2022-05-27T07:01:10+00:00" }

Search for all questionnaires as a System client

This example demonstrates how to find all the questionnaires for a particular organisation.

  1. Generate an access token by following the OAuth 2.0 walkthrough

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

  2. Confirm the ID of the Organisation whose questionnaires you are fetching

    1. The example below assumes you have an ID of: 235a397b-1ae8-4755-9c77-1a0e2fbc5314

  3. Make the call as detailed below, replacing the access token and organisation ID with your own values

  4. The matching Questionnaire resources will be returned

Example request

This example is written for http://sandbox.patientsknowbest.com; replace the URL as needed if you are connecting to a different environment.

curl -X GET --header "Accept: application/fhir+json" --header "Authorization: Bearer eyJhbGxxxx" --header "X-Org-Public-Id: 235a397b-1ae8-4755-9c77-1a0e2fbc5314" "https://sandbox.patientsknowbest.com/fhir/Questionnaire"

Example response

Note: whilst every effort has been made to ensure that the examples are correct and useful, they do not form part of the official specification.

{ "resourceType": "Bundle", "id": "06197768-3adc-4cb6-b64c-7a0f9cd2fbf2", "meta": { "lastUpdated": "2019-08-27T10:48:35.114+00:00" }, "type": "searchset", "total": 1, "link": [ { "relation": "self", "url": "/Questionnaire" } ], "entry": [ { "fullUrl": "https://sandbox.patientsknowbest.com/fhir/Questionnaire/f1a841f1-6f3a-43fc-830f-e1417b4ff13d", "resource": { "resourceType": "Questionnaire", "id": "f1a841f1-6f3a-43fc-830f-e1417b4ff13d", "meta": { "lastUpdated": "2019-06-08T19:21:59.797Z", "security": [ { "system": "http://fhir.patientsknowbest.com/codesystem/privacy-label", "code": "GENERAL_HEALTH" } ] }, "title": "IBD Control PROM", "status": "active", "date": "2019-06-07T19:29:42Z", "item": [ { "linkId": "1", "text": "1. Do you believe that:", "type": "display" }, { "linkId": "2", "text": "a. Your IBD has been well controlled in the past two weeks?", "type": "choice", "option": [ { "valueString": "Yes" }, { "valueString": "No" }, { "valueString": "Not sure" } ] }, { "linkId": "3", "text": "b. Your current treatment is useful in controlling your IBD?", "type": "choice", "option": [ { "valueString": "Yes" }, { "valueString": "No" }, { "valueString": "Not sure" } ] }, { "linkId": "4", "text": "(if you are not taking any treatment, please tick this box)", "type": "choice", "repeats": true, "option": [ { "valueString": "Not taking any treatment" } ] }, { "linkId": "5", "text": "2. Over the past 2 weeks, have your bowel symptoms been getting worse, getting better or not changed?", "type": "choice", "option": [ { "valueString": "Better" }, { "valueString": "No change" }, { "valueString": "Worse" } ] }, { "linkId": "6", "text": "3 In the past 2 weeks, did you:", "type": "display" }, { "linkId": "7", "text": "a. Miss any planned activities because of IBD? (e.g. attending school/college, going to work or a social event)", "type": "choice", "option": [ { "valueString": "Yes" }, { "valueString": "No" }, { "valueString": "Not sure" } ] }, { "linkId": "8", "text": "b. Wake up at night because of symptoms of IBD?", "type": "choice", "option": [ { "valueString": "Yes" }, { "valueString": "No" }, { "valueString": "Not sure" } ] }, { "linkId": "9", "text": "c. Suffer from significant pain or discomfort?", "type": "choice", "option": [ { "valueString": "Yes" }, { "valueString": "No" }, { "valueString": "Not sure" } ] }, { "linkId": "10", "text": "d. Often feel lacking in energy (fatigued) (by ‘often’ we mean more than half of the time)", "type": "choice", "option": [ { "valueString": "Yes" }, { "valueString": "No" }, { "valueString": "Not sure" } ] }, { "linkId": "11", "text": "e. Feel anxious or depressed because of your IBD?", "type": "choice", "option": [ { "valueString": "Yes" }, { "valueString": "No" }, { "valueString": "Not sure" } ] }, { "linkId": "12", "text": "f. Think you needed a change to your treatment?", "type": "choice", "option": [ { "valueString": "Yes" }, { "valueString": "No" }, { "valueString": "Not sure" } ] }, { "linkId": "13", "text": "4 At your next clinic visit, would you like to discuss:", "type": "display" }, { "linkId": "14", "text": "a. Alternative types of drug for controlling IBD", "type": "choice", "option": [ { "valueString": "Yes" }, { "valueString": "No" }, { "valueString": "Not sure" } ] }, { "linkId": "15", "text": "b. Ways to adjust your own treatment", "type": "choice", "option": [ { "valueString": "Yes" }, { "valueString": "No" }, { "valueString": "Not sure" } ] }, { "linkId": "16", "text": "c. Side effects or difficulties with using your medicines", "type": "choice", "option": [ { "valueString": "Yes" }, { "valueString": "No" }, { "valueString": "Not sure" } ] }, { "linkId": "17", "text": "d. New symptoms that have developed since your last visit", "type": "choice", "option": [ { "valueString": "Yes" }, { "valueString": "No" }, { "valueString": "Not sure" } ] }, { "linkId": "18", "text": "5 How would you rate the OVERALL control of your IBD in the past two weeks?", "type": "choice", "option": [ { "valueString": "0- Worst possible control" }, { "valueString": "1" }, { "valueString": "2" }, { "valueString": "3" }, { "valueString": "4" }, { "valueString": "5" }, { "valueString": "6" }, { "valueString": "7" }, { "valueString": "8" }, { "valueString": "9" }, { "valueString": "10- Best possible control" } ] } ] }, "search": { "mode": "match" } } ] }

Search for responses to a specific questionnaire, completed by a specific patient as a System client

This example demonstrates how to find responses to a specific questionnaire, completed by a specific patient.

  1. Generate an access token by following the OAuth 2.0 walkthrough

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

  2. Confirm the ID of the Organisation whose questionnaires you are fetching

    1. The example below assumes you have an ID of: 235a397b-1ae8-4755-9c77-1a0e2fbc5314

  3. Confirm the Questionnaire reference

    1. The example below assumes a reference of: Questionnaire/f1a841f1-6f3a-43fc-830f-e1417b4ff13d

  4. Confirm the Patient reference

    1. The example below assumes a reference of: Patient/3d8afd18-0844-459a-b3c2-355d02e54c0a

  5. Make the call as detailed below, replacing the access token and search parameters with your own values

  6. The matching QuestionnaireResponse resources will be returned

Example request

This example is written for http://sandbox.patientsknowbest.com; replace the URL as needed if you are connecting to a different environment.

curl -X GET --header "Accept: application/fhir+json" --header "Authorization: Bearer eyJhbGxxxx" --header "X-Org-Public-Id: 235a397b-1ae8-4755-9c77-1a0e2fbc5314" "https://sandbox.patientsknowbest.com/fhir/QuestionnaireResponse?questionnaire=Questionnaire/f1a841f1-6f3a-43fc-830f-e1417b4ff13d&patient=Patient/3d8afd18-0844-459a-b3c2-355d02e54c0a"

Example response

Note: whilst every effort has been made to ensure that the examples are correct and useful, they do not form part of the official specification.

Search for questionnaire responses matching a specific procedure request business identifier as a System client

This example demonstrates how to find responses to a specific questionnaire, completed by a specific patient.

  1. Generate an access token by following the OAuth 2.0 walkthrough

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

  2. Confirm the ID of the Organisation whose questionnaires you are fetching

    1. The example below assumes you have an ID of: 235a397b-1ae8-4755-9c77-1a0e2fbc5314

  3. Confirm the Procedure Request business identifier

    1. The example below assumes you have the following business identifier:

      1. system: https://fhir-open.cerner.com/r4/ec2458f2-1e24-41c8-b71b-0e701af7583d/ServiceRequest

      2. value: 294672281

  4. Make the call as detailed below, replacing the access token and search parameters with your own values

  5. The matching QuestionnaireResponse resources will be returned, as well as the ProcedureRequest resources they were based on

Example request

This example is written for http://sandbox.patientsknowbest.com ; replace the URL as needed if you are connecting to a different environment. Note the ‘%7C’ string between the business identifier system and value, it is the html-encoded value of a '|' character.

curl -X GET --header "Accept: application/fhir+json" --header "Authorization: Bearer eyJhbGxxxx" --header "X-Org-Public-Id: 235a397b-1ae8-4755-9c77-1a0e2fbc5314" "https://sandbox.patientsknowbest.com/fhir/QuestionnaireResponse?based-on:ProcedureRequest.identifier=https://fhir-open.cerner.com/r4/ec2458f2-1e24-41c8-b71b-0e701af7583d/ServiceRequest%7C294672281&_include=QuestionnaireResponse:basedOn:ProcedureRequest"