Messaging: Examples
Create a new patient record
This example demonstrates how to create a new patient record.
Generate an access token by following the OAuth 2.0 walkthrough
The example below assumes you have been granted an access token of: eyJhbGxxxx
Confirm the ID of the Organization
The example below assumes you have an ID of: 235a397b-1ae8-4755-9c77-1a0e2fbc5314
Confirm the contents of the Patient resource
Make the call as detailed below, replacing the access token, organisation ID and Patient resource with your own values
Success
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: whilst every effort has been made to ensure that the examples are correct and useful, they do not form part of the official specification.
curl -X POST --header "Accept: application/fhir+json" --header "Content-Type: application/fhir+json" --header "Authorization: Bearer eyJhbGxxxx" --header "X-Org-Public-Id: 235a397b-1ae8-4755-9c77-1a0e2fbc5314" "https://sandbox.patientsknowbest.com/phr-fhir/Patient/$process-message" --data "{ \"resourceType\": \"Patient\", \"identifier\": [{ \"system\": \"https://fhir.nhs.uk/Id/nhs-number\\", \"value\": \"9999999999\" }], \"name\": [{ \"family\": \"Doe\", \"given\": [\"John\"], \"prefix\": [\"Mr\"] }], \"telecom\": [ { \"system\": \"phone\", \"value\": \"07123456789\" }, { \"system\": \"email\", \"value\": \"john.smith@example.com\" } ], \"gender\": \"male\", \"birthDate\": \"1990-01-02\", \"address\": [{ \"line\": [\"1 Main Street\", \"The Place\"], \"city\": \"London\", \"postalCode\": \"CB11BC\" }], \"extension\": [{\"url\": \"http://fhir.patientsknowbest.com/structuredefinition/team-alias\\", \"valueString\": \"team_alias_a\"}, {\"url\": \"http://fhir.patientsknowbest.com/structuredefinition/team-alias\\", \"valueString\": \"team_alias_b\"}] }"
Pretty-printed request body
{
"resourceType": "Patient",
"identifier": [{
"system": "https://fhir.nhs.uk/Id/nhs-number",
"value": "9999999999"
}],
"name": [{
"family": "Doe",
"given": ["John"],
"prefix": ["Mr"]
}],
"telecom": [
{
"system": "phone",
"value": "07123456789"
},
{
"system": "email",
"value": "john.smith@example.com"
}
],
"gender": "male",
"birthDate": "1990-01-02",
"address": [{
"line": ["1 Main Street", "The Place"],
"city": "London",
"postalCode": "CB11BC"
}],
"extension": [
{
"url": "http://fhir.patientsknowbest.com/structuredefinition/team-alias",
"valueString": "team_alias_a"
},
{
"url": "http://fhir.patientsknowbest.com/structuredefinition/team-alias",
"valueString": "team_alias_b"
}
]
}
Example response
Status: 200 OK
Body: Empty
Failure
Example request
{
"resourceType": "Patient",
"identifier": [{
"system": "https://fhir.nhs.uk/Id/nhs-number",
"value": ""
}],
"name": [{
"family": "Doe",
"given": ["John"],
"prefix": ["Mr"]
}],
"telecom": [
{
"system": "phone",
"value": "07123456789"
},
{
"system": "email",
"value": "john.smith@example.com"
}
],
"gender": "male",
"birthDate": "1990-01-02",
"address": [{
"line": ["1 Main Street", "The Place"],
"city": "London",
"postalCode": "CB11BC"
}]
}
Example response
{
"resourceType": "OperationOutcome",
"id": "a7b93683-c9fd-467a-9d4f-4cdb9534eef7",
"issue": [{
"severity": "error",
"code": "invalid",
"diagnostics": "NHS number identifier must be valid"
}]
}