---
title: "Extract Medications"
canonical: "https://wiki.patientsknowbest.com/space/api/4495245313/Extract%20Medications"
format: markdown
---
> Macro (toc)

## What

> Macro (excerpt)
> 
> Enables you to pull out all medications sent from any source.  See the [Validation and Business rules](https://wiki.patientsknowbest.com/space/api/3364388935/Aggregated#Validation-and-business-rules) section for further details on what is included in the Aggregated endpoint.

## Prerequisites

> Macro (excerpt-include)



## How to

> Macro (excerpt)
> 
> - With a valid token, call the base URL with the MedicationStatement resource, using the patient’s national id or PKB public id (with the corresponding system) in the subject search parameter.
>   - *National ID Example: *[https://aggregated-fhir.sandbox.patientsknowbest.com/fhir/MedicationStatement?subject:Patient.identifier=https://fhir.nhs.uk/Id/nhs-number%7C9996650251](https://aggregated-fhir.sandbox.patientsknowbest.com/fhir/MedicationStatement?subject:Patient.identifier=https://fhir.nhs.uk/Id/nhs-number%7C9996650251)
>   - *Public ID Example:* [https://aggregated-fhir.sandbox.patientsknowbest.com/fhir/MedicationStatement?subject:Patient.identifier=http://fhir.patientsknowbest.com/id/public-id%7C8cfd31f2-b027-4aa5-ae27-0df7489434eb](https://aggregated-fhir.sandbox.patientsknowbest.com/fhir/MedicationStatement?subject:Patient.identifier=http://fhir.patientsknowbest.com/id/public-id%7C8cfd31f2-b027-4aa5-ae27-0df7489434eb)
> - You can add other supported search parameters onto that request to meet your specific use case.  See the [FHIR R4 Search](https://hl7.org/fhir/R4/search.html#3.1.1) page for further information.
>   - Example pulling back all of a patient’s medications that were started on or more recently than 14th Sept 2022: [https://aggregated-fhir.sandbox.patientsknowbest.com/fhir/MedicationStatement?subject:Patient.identifier=https://fhir.nhs.uk/Id/nhs-number%7C9996650251&effective=ge2022-09-14](https://aggregated-fhir.sandbox.patientsknowbest.com/fhir/MedicationStatement?subject:Patient.identifier=https://fhir.nhs.uk/Id/nhs-number%7C9996650251&effective=ge2022-09-14)
> - A FHIR bundle is returned to you in json format with all of the patient’s medications that are in their PKB record.

> Macro (excerpt)
> 
> ## Useful links
> 
> - Further information on [connectivity and endpoints](https://wiki.patientsknowbest.com/space/api/4348444939/FHIR+API+-+Network+Connectivity).
> - PKB uses the [MedicationStatement](https://hl7.org/fhir/R4/medicationstatement.html) FHIR resource.  [You can read the full capability statement here.](https://wiki.patientsknowbest.com/space/api/3364389010/Capabilities:+Aggregated+Endpoint#MedicationStatement)
> - Read more about how [PKB maps any non-FHIR medication data (HL7 or UI entered) to FHIR](https://wiki.patientsknowbest.com/space/api/3583082497/Aggregated+MedicationStatement).

## Example

Here is a test patient’s Medications in the PKB UI:

> Macro (excerpt)
> 
> ![image-20250219-165542.png](media://4a8c7bb9-2c16-46e1-abf5-f4dfa38fd277)

> Macro (excerpt)
> 
> Here’s an example response for pulling all of this patient’s medications.
> 
> <span style="color: #36b37e">**GET**</span> [https://aggregated-fhir.sandbox.patientsknowbest.com/fhir/MedicationStatement?subject:Patient.identifier=https://fhir.nhs.uk/Id/nhs-number%7C9996650251](https://aggregated-fhir.sandbox.patientsknowbest.com/fhir/MedicationStatement?subject:Patient.identifier=https://fhir.nhs.uk/Id/nhs-number%7C9996650251)
> 
> ```json
> {
>     "resourceType": "Bundle",
>     "meta": {
>         "lastUpdated": "2025-02-19T16:58:43.105+00:00"
>     },
>     "type": "searchset",
>     "total": 14,
>     "link": [
>         {
>             "relation": "self",
>             "url": "/fhir/MedicationStatement?subject%3APatient.identifier=https%3A%2F%2Ffhir.nhs.uk%2FId%2Fnhs-number%7C9996650251"
>         }
>     ],
>     "entry": [
>         {
>             "link": [
>                 {
>                     "relation": "self",
>                     "url": "https://sandboxaggregated.fhir-api.sandbox.patientsknowbest.com/MedicationStatement/3a8e1549-467e-3e7f-9fc0-0ac57f9fb5c2"
>                 }
>             ],
>             "fullUrl": "https://sandboxaggregated.fhir-api.sandbox.patientsknowbest.com/MedicationStatement/3a8e1549-467e-3e7f-9fc0-0ac57f9fb5c2",
>             "resource": {
>                 "resourceType": "MedicationStatement",
>                 "id": "3a8e1549-467e-3e7f-9fc0-0ac57f9fb5c2",
>                 "meta": {
>                     "extension": [
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/access-route",
>                             "valueCoding": {
>                                 "system": "http://fhir.patientsknowbest.com/codesystem/access-route",
>                                 "code": "WEBAPP",
>                                 "display": "PKB website"
>                             }
>                         },
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/version-persisted",
>                             "valueDateTime": "2023-05-16T13:21:49+00:00"
>                         },
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/recorded-date",
>                             "valueDateTime": "2023-05-16T13:21:49+00:00"
>                         },
>                         {
>                             "url": "ex:createdAt",
>                             "valueInstant": "2023-05-16T13:21:50.664085Z"
>                         }
>                     ],
>                     "versionId": "2757064",
>                     "lastUpdated": "2023-05-16T13:21:50.664085Z",
>                     "security": [
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/source-organization",
>                             "code": "29c26058-3253-38a8-8f84-0b28f488db2f",
>                             "display": "Royal Dermatology Hospital"
>                         },
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/source-team",
>                             "code": "78cb6b3b-9eca-3cf5-8638-4c222bdefb87",
>                             "display": "Dermatology"
>                         },
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/source-practitioner",
>                             "code": "1befd114-3753-38cf-805d-f0837ebbc59e",
>                             "display": "Dr Jake Professional"
>                         },
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/connecting-org",
>                             "code": "29c26058-3253-38a8-8f84-0b28f488db2f",
>                             "display": "Royal Dermatology Hospital"
>                         },
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/privacy-label",
>                             "code": "GENERAL_HEALTH"
>                         }
>                     ]
>                 },
>                 "extension": [
>                     {
>                         "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream",
>                         "extension": [
>                             {
>                                 "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream-source-id",
>                                 "valueString": "ehrmigrated"
>                             },
>                             {
>                                 "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream-resource-id",
>                                 "valueString": "MedicationStatement/aa4bac6d-9310-4d5e-8ccd-048421027f13"
>                             }
>                         ]
>                     },
>                     {
>                         "url": "http://fhir.patientsknowbest.com/structuredefinition/source-organization-time-zone-id",
>                         "valueString": "Europe/London"
>                     }
>                 ],
>                 "identifier": [
>                     {
>                         "system": "http://fhir.patientsknowbest.com/id/menudata-legacy-identifier",
>                         "value": "126095743"
>                     }
>                 ],
>                 "status": "active",
>                 "medicationCodeableConcept": {
>                     "text": "Hydrocortisone Cream"
>                 },
>                 "subject": {
>                     "reference": "Patient/85fcb223-a1ab-3efb-9d5b-376cca520781"
>                 },
>                 "effectivePeriod": {
>                     "start": "2023-01-09T00:00:00+00:00"
>                 },
>                 "dosage": [
>                     {
>                         "timing": {
>                             "code": {
>                                 "text": "As directed"
>                             }
>                         },
>                         "doseAndRate": [
>                             {
>                                 "doseQuantity": {
>                                     "value": 1.0,
>                                     "code": "APPLICATIONS"
>                                 }
>                             }
>                         ]
>                     }
>                 ]
>             },
>             "search": {
>                 "mode": "match"
>             }
>         },
>         {
>             "link": [
>                 {
>                     "relation": "self",
>                     "url": "https://sandboxaggregated.fhir-api.sandbox.patientsknowbest.com/MedicationStatement/cea5cf2e-6c7b-3d4d-952b-e733268b8b62"
>                 }
>             ],
>             "fullUrl": "https://sandboxaggregated.fhir-api.sandbox.patientsknowbest.com/MedicationStatement/cea5cf2e-6c7b-3d4d-952b-e733268b8b62",
>             "resource": {
>                 "resourceType": "MedicationStatement",
>                 "id": "cea5cf2e-6c7b-3d4d-952b-e733268b8b62",
>                 "meta": {
>                     "extension": [
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/access-route",
>                             "valueCoding": {
>                                 "system": "http://fhir.patientsknowbest.com/codesystem/access-route",
>                                 "code": "WEBAPP",
>                                 "display": "PKB website"
>                             }
>                         },
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/version-persisted",
>                             "valueDateTime": "2023-05-16T13:22:34+00:00"
>                         },
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/recorded-date",
>                             "valueDateTime": "2023-05-16T13:18:32+00:00"
>                         },
>                         {
>                             "url": "ex:createdAt",
>                             "valueInstant": "2023-05-16T13:18:33.821370Z"
>                         }
>                     ],
>                     "versionId": "2757074",
>                     "lastUpdated": "2023-05-16T13:22:35.172490Z",
>                     "security": [
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/source-organization",
>                             "code": "29c26058-3253-38a8-8f84-0b28f488db2f",
>                             "display": "Royal Dermatology Hospital"
>                         },
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/source-team",
>                             "code": "78cb6b3b-9eca-3cf5-8638-4c222bdefb87",
>                             "display": "Dermatology"
>                         },
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/source-practitioner",
>                             "code": "1befd114-3753-38cf-805d-f0837ebbc59e",
>                             "display": "Dr Jake Professional"
>                         },
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/connecting-org",
>                             "code": "29c26058-3253-38a8-8f84-0b28f488db2f",
>                             "display": "Royal Dermatology Hospital"
>                         },
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/privacy-label",
>                             "code": "GENERAL_HEALTH"
>                         }
>                     ]
>                 },
>                 "extension": [
>                     {
>                         "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream",
>                         "extension": [
>                             {
>                                 "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream-source-id",
>                                 "valueString": "ehrmigrated"
>                             },
>                             {
>                                 "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream-resource-id",
>                                 "valueString": "MedicationStatement/0616f9ff-0fa3-4ffc-8680-e995675dc460"
>                             }
>                         ]
>                     },
>                     {
>                         "url": "http://fhir.patientsknowbest.com/structuredefinition/source-organization-time-zone-id",
>                         "valueString": "Europe/London"
>                     }
>                 ],
>                 "identifier": [
>                     {
>                         "system": "http://fhir.patientsknowbest.com/id/menudata-legacy-identifier",
>                         "value": "126095745"
>                     }
>                 ],
>                 "status": "active",
>                 "medicationCodeableConcept": {
>                     "text": "Hydromol cream"
>                 },
>                 "subject": {
>                     "reference": "Patient/85fcb223-a1ab-3efb-9d5b-376cca520781"
>                 },
>                 "effectivePeriod": {
>                     "start": "2023-01-09T00:00:00+00:00"
>                 },
>                 "dosage": [
>                     {
>                         "text": "Take as needed",
>                         "asNeededBoolean": true,
>                         "doseAndRate": [
>                             {
>                                 "doseQuantity": {
>                                     "value": 1.0,
>                                     "code": "APPLICATIONS"
>                                 }
>                             }
>                         ]
>                     }
>                 ]
>             },
>             "search": {
>                 "mode": "match"
>             }
>         },
>         {
>             "link": [
>                 {
>                     "relation": "self",
>                     "url": "https://sandboxaggregated.fhir-api.sandbox.patientsknowbest.com/MedicationStatement/5f933c6d-24b2-33d3-9b1d-3bb40bc6fdf4"
>                 }
>             ],
>             "fullUrl": "https://sandboxaggregated.fhir-api.sandbox.patientsknowbest.com/MedicationStatement/5f933c6d-24b2-33d3-9b1d-3bb40bc6fdf4",
>             "resource": {
>                 "resourceType": "MedicationStatement",
>                 "id": "5f933c6d-24b2-33d3-9b1d-3bb40bc6fdf4",
>                 "meta": {
>                     "extension": [
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/access-route",
>                             "valueCoding": {
>                                 "system": "http://fhir.patientsknowbest.com/codesystem/access-route",
>                                 "code": "WEBAPP",
>                                 "display": "PKB website"
>                             }
>                         },
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/version-persisted",
>                             "valueDateTime": "2023-05-16T13:29:50+00:00"
>                         },
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/recorded-date",
>                             "valueDateTime": "2023-05-16T13:29:50+00:00"
>                         },
>                         {
>                             "url": "ex:createdAt",
>                             "valueInstant": "2023-05-16T13:29:53.592139Z"
>                         }
>                     ],
>                     "versionId": "2757077",
>                     "lastUpdated": "2023-05-16T13:29:53.592139Z",
>                     "security": [
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/source-patient",
>                             "code": "85fcb223-a1ab-3efb-9d5b-376cca520781",
>                             "display": "Mr Charlie Derma"
>                         },
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/privacy-label",
>                             "code": "GENERAL_HEALTH"
>                         }
>                     ]
>                 },
>                 "extension": [
>                     {
>                         "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream",
>                         "extension": [
>                             {
>                                 "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream-source-id",
>                                 "valueString": "ehrmigrated"
>                             },
>                             {
>                                 "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream-resource-id",
>                                 "valueString": "MedicationStatement/bfdfd17b-64ca-4dfb-98a5-5313a239c400"
>                             }
>                         ]
>                     }
>                 ],
>                 "identifier": [
>                     {
>                         "system": "http://fhir.patientsknowbest.com/id/menudata-legacy-identifier",
>                         "value": "126095752"
>                     }
>                 ],
>                 "status": "active",
>                 "medicationCodeableConcept": {
>                     "text": "Cetirizine"
>                 },
>                 "subject": {
>                     "reference": "Patient/85fcb223-a1ab-3efb-9d5b-376cca520781"
>                 },
>                 "effectivePeriod": {
>                     "start": "2023-01-09T00:00:00+00:00"
>                 },
>                 "dosage": [
>                     {
>                         "timing": {
>                             "repeat": {
>                                 "frequency": 1,
>                                 "period": 24,
>                                 "periodUnit": "h"
>                             }
>                         },
>                         "doseAndRate": [
>                             {
>                                 "doseQuantity": {
>                                     "value": 1.0,
>                                     "code": "TABLETS"
>                                 }
>                             }
>                         ]
>                     }
>                 ]
>             },
>             "search": {
>                 "mode": "match"
>             }
>         },
>         {
>             "link": [
>                 {
>                     "relation": "self",
>                     "url": "https://sandboxaggregated.fhir-api.sandbox.patientsknowbest.com/MedicationStatement/d03d233d-1004-3857-9062-419d9afbfa85"
>                 }
>             ],
>             "fullUrl": "https://sandboxaggregated.fhir-api.sandbox.patientsknowbest.com/MedicationStatement/d03d233d-1004-3857-9062-419d9afbfa85",
>             "resource": {
>                 "resourceType": "MedicationStatement",
>                 "id": "d03d233d-1004-3857-9062-419d9afbfa85",
>                 "meta": {
>                     "extension": [
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/access-route",
>                             "valueCoding": {
>                                 "system": "http://fhir.patientsknowbest.com/codesystem/access-route",
>                                 "code": "WEBAPP",
>                                 "display": "PKB website"
>                             }
>                         },
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/version-persisted",
>                             "valueDateTime": "2023-05-16T12:49:49+00:00"
>                         },
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/recorded-date",
>                             "valueDateTime": "2023-05-16T12:49:03+00:00"
>                         },
>                         {
>                             "url": "ex:createdAt",
>                             "valueInstant": "2023-05-16T12:50:04.504784Z"
>                         }
>                     ],
>                     "versionId": "2757040",
>                     "lastUpdated": "2023-05-16T12:50:04.504784Z",
>                     "security": [
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/source-organization",
>                             "code": "29c26058-3253-38a8-8f84-0b28f488db2f",
>                             "display": "Royal Dermatology Hospital"
>                         },
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/source-team",
>                             "code": "78cb6b3b-9eca-3cf5-8638-4c222bdefb87",
>                             "display": "Dermatology"
>                         },
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/source-practitioner",
>                             "code": "1befd114-3753-38cf-805d-f0837ebbc59e",
>                             "display": "Dr Jake Professional"
>                         },
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/connecting-org",
>                             "code": "29c26058-3253-38a8-8f84-0b28f488db2f",
>                             "display": "Royal Dermatology Hospital"
>                         },
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/privacy-label",
>                             "code": "GENERAL_HEALTH"
>                         }
>                     ]
>                 },
>                 "extension": [
>                     {
>                         "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream",
>                         "extension": [
>                             {
>                                 "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream-source-id",
>                                 "valueString": "ehrmigrated"
>                             },
>                             {
>                                 "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream-resource-id",
>                                 "valueString": "MedicationStatement/23865b01-fbc2-4e3b-b8fb-171d4d41efaa"
>                             }
>                         ]
>                     },
>                     {
>                         "url": "http://fhir.patientsknowbest.com/structuredefinition/source-organization-time-zone-id",
>                         "valueString": "Europe/London"
>                     }
>                 ],
>                 "identifier": [
>                     {
>                         "system": "http://fhir.patientsknowbest.com/id/menudata-legacy-identifier",
>                         "value": "126095736"
>                     }
>                 ],
>                 "status": "active",
>                 "medicationCodeableConcept": {
>                     "text": "Salbutamol inhaler"
>                 },
>                 "subject": {
>                     "reference": "Patient/85fcb223-a1ab-3efb-9d5b-376cca520781"
>                 },
>                 "effectivePeriod": {
>                     "start": "2023-01-09T00:00:00+00:00"
>                 },
>                 "dosage": [
>                     {
>                         "patientInstruction": "Reliever Inhaler",
>                         "asNeededBoolean": true,
>                         "doseAndRate": [
>                             {
>                                 "doseQuantity": {
>                                     "value": 1.0,
>                                     "code": "PUFFS"
>                                 }
>                             }
>                         ]
>                     }
>                 ]
>             },
>             "search": {
>                 "mode": "match"
>             }
>         },
>         {
>             "link": [
>                 {
>                     "relation": "self",
>                     "url": "https://sandboxaggregated.fhir-api.sandbox.patientsknowbest.com/MedicationStatement/9610e86f-f945-3fcd-ad46-ce93a783685b"
>                 }
>             ],
>             "fullUrl": "https://sandboxaggregated.fhir-api.sandbox.patientsknowbest.com/MedicationStatement/9610e86f-f945-3fcd-ad46-ce93a783685b",
>             "resource": {
>                 "resourceType": "MedicationStatement",
>                 "id": "9610e86f-f945-3fcd-ad46-ce93a783685b",
>                 "meta": {
>                     "extension": [
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/access-route",
>                             "valueCoding": {
>                                 "system": "http://fhir.patientsknowbest.com/codesystem/access-route",
>                                 "code": "WEBAPP",
>                                 "display": "PKB website"
>                             }
>                         },
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/version-persisted",
>                             "valueDateTime": "2023-05-16T12:49:03+00:00"
>                         },
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/recorded-date",
>                             "valueDateTime": "2023-05-16T12:49:03+00:00"
>                         },
>                         {
>                             "url": "ex:createdAt",
>                             "valueInstant": "2023-05-16T12:50:04.521233Z"
>                         }
>                     ],
>                     "versionId": "2757041",
>                     "lastUpdated": "2023-05-16T12:50:04.521233Z",
>                     "security": [
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/source-organization",
>                             "code": "29c26058-3253-38a8-8f84-0b28f488db2f",
>                             "display": "Royal Dermatology Hospital"
>                         },
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/source-team",
>                             "code": "78cb6b3b-9eca-3cf5-8638-4c222bdefb87",
>                             "display": "Dermatology"
>                         },
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/source-practitioner",
>                             "code": "1befd114-3753-38cf-805d-f0837ebbc59e",
>                             "display": "Dr Jake Professional"
>                         },
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/connecting-org",
>                             "code": "29c26058-3253-38a8-8f84-0b28f488db2f",
>                             "display": "Royal Dermatology Hospital"
>                         },
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/privacy-label",
>                             "code": "GENERAL_HEALTH"
>                         }
>                     ]
>                 },
>                 "extension": [
>                     {
>                         "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream",
>                         "extension": [
>                             {
>                                 "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream-source-id",
>                                 "valueString": "ehrmigrated"
>                             },
>                             {
>                                 "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream-resource-id",
>                                 "valueString": "MedicationStatement/a0beacf3-9656-4de3-959f-0a53ab7bf20b"
>                             }
>                         ]
>                     },
>                     {
>                         "url": "http://fhir.patientsknowbest.com/structuredefinition/source-organization-time-zone-id",
>                         "valueString": "Europe/London"
>                     }
>                 ],
>                 "identifier": [
>                     {
>                         "system": "http://fhir.patientsknowbest.com/id/menudata-legacy-identifier",
>                         "value": "126095733"
>                     }
>                 ],
>                 "status": "active",
>                 "medicationCodeableConcept": {
>                     "text": "Beclometasone inhaler"
>                 },
>                 "subject": {
>                     "reference": "Patient/85fcb223-a1ab-3efb-9d5b-376cca520781"
>                 },
>                 "effectivePeriod": {
>                     "start": "2023-01-09T00:00:00+00:00"
>                 },
>                 "dosage": [
>                     {
>                         "patientInstruction": "Take 1 puff daily.",
>                         "timing": {
>                             "repeat": {
>                                 "frequency": 1,
>                                 "period": 24,
>                                 "periodUnit": "h"
>                             }
>                         },
>                         "doseAndRate": [
>                             {
>                                 "doseQuantity": {
>                                     "value": 1.0,
>                                     "code": "PUFFS"
>                                 }
>                             }
>                         ]
>                     }
>                 ]
>             },
>             "search": {
>                 "mode": "match"
>             }
>         },
>         {
>             "link": [
>                 {
>                     "relation": "self",
>                     "url": "https://sandboxaggregated.fhir-api.sandbox.patientsknowbest.com/MedicationStatement/a8eeffef-bdc3-34c2-8943-8f730d32bd40"
>                 }
>             ],
>             "fullUrl": "https://sandboxaggregated.fhir-api.sandbox.patientsknowbest.com/MedicationStatement/a8eeffef-bdc3-34c2-8943-8f730d32bd40",
>             "resource": {
>                 "resourceType": "MedicationStatement",
>                 "id": "a8eeffef-bdc3-34c2-8943-8f730d32bd40",
>                 "meta": {
>                     "extension": [
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/access-route",
>                             "valueCoding": {
>                                 "system": "http://fhir.patientsknowbest.com/codesystem/access-route",
>                                 "code": "WEBAPP",
>                                 "display": "PKB website"
>                             }
>                         },
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/version-persisted",
>                             "valueDateTime": "2024-08-16T11:02:38.445+00:00"
>                         },
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/recorded-date",
>                             "valueDateTime": "2024-08-16T11:02:38.432+00:00"
>                         },
>                         {
>                             "url": "ex:createdAt",
>                             "valueInstant": "2024-08-16T11:02:40.736454Z"
>                         }
>                     ],
>                     "versionId": "7336888",
>                     "lastUpdated": "2024-08-16T11:02:40.736454Z",
>                     "security": [
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/source-patient",
>                             "code": "85fcb223-a1ab-3efb-9d5b-376cca520781",
>                             "display": "Mr Charlie Derma"
>                         },
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/privacy-label",
>                             "code": "GENERAL_HEALTH"
>                         }
>                     ]
>                 },
>                 "extension": [
>                     {
>                         "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream",
>                         "extension": [
>                             {
>                                 "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream-source-id",
>                                 "valueString": "ehrmigrated"
>                             },
>                             {
>                                 "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream-resource-id",
>                                 "valueString": "MedicationStatement/c059f2c0-a743-477e-883e-1ddb3908c5ca"
>                             }
>                         ]
>                     }
>                 ],
>                 "identifier": [
>                     {
>                         "system": "http://fhir.patientsknowbest.com/id/menudata-legacy-identifier",
>                         "value": "134611813"
>                     }
>                 ],
>                 "status": "active",
>                 "medicationCodeableConcept": {
>                     "text": "Ventolin 100micrograms/dose Evohaler (GlaxoSmithKline UK Ltd)"
>                 },
>                 "subject": {
>                     "reference": "Patient/85fcb223-a1ab-3efb-9d5b-376cca520781"
>                 },
>                 "effectivePeriod": {
>                     "start": "2022-09-13T23:00:00.000+00:00",
>                     "end": "2022-10-08T23:00:00.000+00:00"
>                 },
>                 "dosage": [
>                     {
>                         "patientInstruction": "1 x 200 dose",
>                         "timing": {
>                             "repeat": {
>                                 "frequency": 1,
>                                 "period": 6,
>                                 "periodUnit": "h"
>                             }
>                         },
>                         "doseAndRate": [
>                             {
>                                 "doseQuantity": {
>                                     "value": 1.0,
>                                     "code": "PUFFS"
>                                 }
>                             }
>                         ]
>                     }
>                 ]
>             },
>             "search": {
>                 "mode": "match"
>             }
>         },
>         {
>             "link": [
>                 {
>                     "relation": "self",
>                     "url": "https://sandboxaggregated.fhir-api.sandbox.patientsknowbest.com/MedicationStatement/41ab989d-17e8-321b-9ea5-f3166525fd98"
>                 }
>             ],
>             "fullUrl": "https://sandboxaggregated.fhir-api.sandbox.patientsknowbest.com/MedicationStatement/41ab989d-17e8-321b-9ea5-f3166525fd98",
>             "resource": {
>                 "resourceType": "MedicationStatement",
>                 "id": "41ab989d-17e8-321b-9ea5-f3166525fd98",
>                 "meta": {
>                     "extension": [
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/access-route",
>                             "valueCoding": {
>                                 "system": "http://fhir.patientsknowbest.com/codesystem/access-route",
>                                 "code": "WEBAPP",
>                                 "display": "PKB website"
>                             }
>                         },
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/version-persisted",
>                             "valueDateTime": "2024-08-16T11:03:48.184+00:00"
>                         },
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/recorded-date",
>                             "valueDateTime": "2024-08-16T11:03:48.155+00:00"
>                         },
>                         {
>                             "url": "ex:createdAt",
>                             "valueInstant": "2024-08-16T11:03:48.735938Z"
>                         }
>                     ],
>                     "versionId": "7336889",
>                     "lastUpdated": "2024-08-16T11:03:48.735938Z",
>                     "security": [
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/source-patient",
>                             "code": "85fcb223-a1ab-3efb-9d5b-376cca520781",
>                             "display": "Mr Charlie Derma"
>                         },
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/privacy-label",
>                             "code": "GENERAL_HEALTH"
>                         }
>                     ]
>                 },
>                 "extension": [
>                     {
>                         "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream",
>                         "extension": [
>                             {
>                                 "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream-source-id",
>                                 "valueString": "ehrmigrated"
>                             },
>                             {
>                                 "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream-resource-id",
>                                 "valueString": "MedicationStatement/db1a41c8-6c5d-41f0-b81e-b6d9ab83e595"
>                             }
>                         ]
>                     }
>                 ],
>                 "identifier": [
>                     {
>                         "system": "http://fhir.patientsknowbest.com/id/menudata-legacy-identifier",
>                         "value": "134611814"
>                     }
>                 ],
>                 "status": "active",
>                 "medicationCodeableConcept": {
>                     "text": "Aspirin 75mg tablets"
>                 },
>                 "subject": {
>                     "reference": "Patient/85fcb223-a1ab-3efb-9d5b-376cca520781"
>                 },
>                 "effectivePeriod": {
>                     "start": "2022-09-11T23:00:00.000+00:00",
>                     "end": "2022-09-13T23:00:00.000+00:00"
>                 },
>                 "dosage": [
>                     {
>                         "timing": {
>                             "repeat": {
>                                 "frequency": 1,
>                                 "period": 24,
>                                 "periodUnit": "h"
>                             }
>                         },
>                         "doseAndRate": [
>                             {
>                                 "doseQuantity": {
>                                     "value": 1.0,
>                                     "code": "TABLETS"
>                                 }
>                             }
>                         ]
>                     }
>                 ]
>             },
>             "search": {
>                 "mode": "match"
>             }
>         },
>         {
>             "link": [
>                 {
>                     "relation": "self",
>                     "url": "https://sandboxaggregated.fhir-api.sandbox.patientsknowbest.com/MedicationStatement/5e1a99d9-259d-3ede-9046-d26b320894eb"
>                 }
>             ],
>             "fullUrl": "https://sandboxaggregated.fhir-api.sandbox.patientsknowbest.com/MedicationStatement/5e1a99d9-259d-3ede-9046-d26b320894eb",
>             "resource": {
>                 "resourceType": "MedicationStatement",
>                 "id": "5e1a99d9-259d-3ede-9046-d26b320894eb",
>                 "meta": {
>                     "extension": [
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/access-route",
>                             "valueCoding": {
>                                 "system": "http://fhir.patientsknowbest.com/codesystem/access-route",
>                                 "code": "WEBAPP",
>                                 "display": "PKB website"
>                             }
>                         },
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/version-persisted",
>                             "valueDateTime": "2024-08-16T11:06:03.809+00:00"
>                         },
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/recorded-date",
>                             "valueDateTime": "2024-08-16T11:06:03.799+00:00"
>                         },
>                         {
>                             "url": "ex:createdAt",
>                             "valueInstant": "2024-08-16T11:06:05.103923Z"
>                         }
>                     ],
>                     "versionId": "7336890",
>                     "lastUpdated": "2024-08-16T11:06:05.103923Z",
>                     "security": [
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/source-patient",
>                             "code": "85fcb223-a1ab-3efb-9d5b-376cca520781",
>                             "display": "Mr Charlie Derma"
>                         },
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/privacy-label",
>                             "code": "GENERAL_HEALTH"
>                         }
>                     ]
>                 },
>                 "extension": [
>                     {
>                         "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream",
>                         "extension": [
>                             {
>                                 "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream-source-id",
>                                 "valueString": "ehrmigrated"
>                             },
>                             {
>                                 "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream-resource-id",
>                                 "valueString": "MedicationStatement/e8ed65dd-088a-46ce-b4d7-690ab7c9d2e0"
>                             }
>                         ]
>                     }
>                 ],
>                 "identifier": [
>                     {
>                         "system": "http://fhir.patientsknowbest.com/id/menudata-legacy-identifier",
>                         "value": "134611815"
>                     }
>                 ],
>                 "status": "active",
>                 "medicationCodeableConcept": {
>                     "text": "Liquid paraffin light 63.4% bath additive"
>                 },
>                 "subject": {
>                     "reference": "Patient/85fcb223-a1ab-3efb-9d5b-376cca520781"
>                 },
>                 "effectivePeriod": {
>                     "start": "2021-11-30T00:00:00.000+00:00",
>                     "end": "2021-12-20T00:00:00.000+00:00"
>                 },
>                 "dosage": [
>                     {
>                         "patientInstruction": "Add One To Three Capfuls To Bath Water, Or Apply To Wet Skin And Rinse, 10 ml",
>                         "timing": {
>                             "code": {
>                                 "text": "As directed"
>                             }
>                         },
>                         "doseAndRate": [
>                             {
>                                 "doseQuantity": {
>                                     "value": 10.0,
>                                     "code": "ML"
>                                 }
>                             }
>                         ]
>                     }
>                 ]
>             },
>             "search": {
>                 "mode": "match"
>             }
>         },
>         {
>             "link": [
>                 {
>                     "relation": "self",
>                     "url": "https://sandboxaggregated.fhir-api.sandbox.patientsknowbest.com/MedicationStatement/b008cb3f-7292-3cae-9893-3c975f2a3857"
>                 }
>             ],
>             "fullUrl": "https://sandboxaggregated.fhir-api.sandbox.patientsknowbest.com/MedicationStatement/b008cb3f-7292-3cae-9893-3c975f2a3857",
>             "resource": {
>                 "resourceType": "MedicationStatement",
>                 "id": "b008cb3f-7292-3cae-9893-3c975f2a3857",
>                 "meta": {
>                     "extension": [
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/access-route",
>                             "valueCoding": {
>                                 "system": "http://fhir.patientsknowbest.com/codesystem/access-route",
>                                 "code": "HL7_API",
>                                 "display": "Integration (HL7)"
>                             }
>                         },
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/uploaded-data-id",
>                             "valueString": "14253778"
>                         },
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/version-persisted",
>                             "valueDateTime": "2024-08-19T14:57:36.271+00:00"
>                         },
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/recorded-date",
>                             "valueDateTime": "2024-08-19T14:08:48.000+00:00"
>                         },
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/source-text",
>                             "valueString": "Mrs Zoe Hernandez"
>                         },
>                         {
>                             "url": "ex:createdAt",
>                             "valueInstant": "2024-08-19T14:57:37.416197Z"
>                         }
>                     ],
>                     "versionId": "7337235",
>                     "lastUpdated": "2024-08-19T14:57:37.416197Z",
>                     "security": [
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/source-organization",
>                             "code": "e8ce8a2b-6b08-3e03-8feb-eb32dc389ab4",
>                             "display": "Housewold NHS Trust"
>                         },
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/connecting-org",
>                             "code": "e8ce8a2b-6b08-3e03-8feb-eb32dc389ab4",
>                             "display": "Housewold NHS Trust"
>                         },
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/privacy-label",
>                             "code": "GENERAL_HEALTH"
>                         }
>                     ]
>                 },
>                 "extension": [
>                     {
>                         "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream",
>                         "extension": [
>                             {
>                                 "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream-source-id",
>                                 "valueString": "ehrmigrated"
>                             },
>                             {
>                                 "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream-resource-id",
>                                 "valueString": "MedicationStatement/5f0cfd8a-e74e-4140-8d91-d6f346c29894"
>                             }
>                         ]
>                     },
>                     {
>                         "url": "http://fhir.patientsknowbest.com/structuredefinition/source-organization-time-zone-id",
>                         "valueString": "Europe/London"
>                     }
>                 ],
>                 "identifier": [
>                     {
>                         "system": "http://fhir.patientsknowbest.com/id/menudata-legacy-identifier",
>                         "value": "134612396"
>                     }
>                 ],
>                 "status": "active",
>                 "medicationCodeableConcept": {
>                     "coding": [
>                         {
>                             "display": "Liquid paraffin light 70% gel"
>                         }
>                     ]
>                 },
>                 "subject": {
>                     "reference": "Patient/85fcb223-a1ab-3efb-9d5b-376cca520781"
>                 },
>                 "effectivePeriod": {
>                     "start": "2021-11-23T00:00:00.000+00:00",
>                     "end": "2019-07-02T23:00:00.000+00:00"
>                 },
>                 "dosage": [
>                     {
>                         "patientInstruction": "Apply to wet skin and rinse twice a day.",
>                         "doseAndRate": [
>                             {
>                                 "doseQuantity": {
>                                     "extension": [
>                                         {
>                                             "url": "http://fhir.patientsknowbest.com/structuredefinition/dose-units",
>                                             "valueCodeableConcept": {
>                                                 "coding": [
>                                                     {
>                                                         "display": "gram"
>                                                     }
>                                                 ]
>                                             }
>                                         }
>                                     ],
>                                     "value": 500.0,
>                                     "unit": "gram"
>                                 }
>                             }
>                         ]
>                     }
>                 ]
>             },
>             "search": {
>                 "mode": "match"
>             }
>         },
>         {
>             "link": [
>                 {
>                     "relation": "self",
>                     "url": "https://sandboxaggregated.fhir-api.sandbox.patientsknowbest.com/MedicationStatement/3c57b0a2-18b7-347a-a4c3-3d73b264730c"
>                 }
>             ],
>             "fullUrl": "https://sandboxaggregated.fhir-api.sandbox.patientsknowbest.com/MedicationStatement/3c57b0a2-18b7-347a-a4c3-3d73b264730c",
>             "resource": {
>                 "resourceType": "MedicationStatement",
>                 "id": "3c57b0a2-18b7-347a-a4c3-3d73b264730c",
>                 "meta": {
>                     "extension": [
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/access-route",
>                             "valueCoding": {
>                                 "system": "http://fhir.patientsknowbest.com/codesystem/access-route",
>                                 "code": "WEBAPP",
>                                 "display": "PKB website"
>                             }
>                         },
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/version-persisted",
>                             "valueDateTime": "2023-06-14T15:15:37+00:00"
>                         },
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/recorded-date",
>                             "valueDateTime": "2023-06-14T15:15:37+00:00"
>                         },
>                         {
>                             "url": "ex:createdAt",
>                             "valueInstant": "2023-06-14T15:15:39.482999Z"
>                         }
>                     ],
>                     "versionId": "5660535",
>                     "lastUpdated": "2023-06-14T15:15:39.482999Z",
>                     "security": [
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/source-patient",
>                             "code": "85fcb223-a1ab-3efb-9d5b-376cca520781",
>                             "display": "Mr Charlie Derma"
>                         },
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/privacy-label",
>                             "code": "GENERAL_HEALTH"
>                         }
>                     ]
>                 },
>                 "extension": [
>                     {
>                         "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream",
>                         "extension": [
>                             {
>                                 "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream-source-id",
>                                 "valueString": "ehrmigrated"
>                             },
>                             {
>                                 "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream-resource-id",
>                                 "valueString": "MedicationStatement/26de2cd0-f2b4-47f9-86b7-5cb08913054e"
>                             }
>                         ]
>                     }
>                 ],
>                 "identifier": [
>                     {
>                         "system": "http://fhir.patientsknowbest.com/id/menudata-legacy-identifier",
>                         "value": "133661154"
>                     }
>                 ],
>                 "status": "active",
>                 "medicationCodeableConcept": {
>                     "text": "Amoxicillin"
>                 },
>                 "subject": {
>                     "reference": "Patient/85fcb223-a1ab-3efb-9d5b-376cca520781"
>                 },
>                 "effectivePeriod": {
>                     "start": "2021-06-12T23:00:00+00:00",
>                     "end": "2021-06-26T23:00:00+00:00"
>                 },
>                 "dosage": [
>                     {
>                         "patientInstruction": "Swallow amoxicillin capsules whole with a drink of water. Do not chew or break them. ",
>                         "timing": {
>                             "repeat": {
>                                 "frequency": 1,
>                                 "period": 8,
>                                 "periodUnit": "h"
>                             }
>                         },
>                         "doseAndRate": [
>                             {
>                                 "doseQuantity": {
>                                     "value": 1.0,
>                                     "code": "TABLETS"
>                                 }
>                             }
>                         ]
>                     }
>                 ]
>             },
>             "search": {
>                 "mode": "match"
>             }
>         },
>         {
>             "link": [
>                 {
>                     "relation": "self",
>                     "url": "https://sandboxaggregated.fhir-api.sandbox.patientsknowbest.com/MedicationStatement/49f7ecfb-ba34-390e-ba84-03aa7b63173e"
>                 }
>             ],
>             "fullUrl": "https://sandboxaggregated.fhir-api.sandbox.patientsknowbest.com/MedicationStatement/49f7ecfb-ba34-390e-ba84-03aa7b63173e",
>             "resource": {
>                 "resourceType": "MedicationStatement",
>                 "id": "49f7ecfb-ba34-390e-ba84-03aa7b63173e",
>                 "meta": {
>                     "extension": [
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/access-route",
>                             "valueCoding": {
>                                 "system": "http://fhir.patientsknowbest.com/codesystem/access-route",
>                                 "code": "HL7_API",
>                                 "display": "Integration (HL7)"
>                             }
>                         },
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/uploaded-data-id",
>                             "valueString": "14253778"
>                         },
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/version-persisted",
>                             "valueDateTime": "2024-08-19T14:57:36.272+00:00"
>                         },
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/recorded-date",
>                             "valueDateTime": "2024-08-19T14:08:48.000+00:00"
>                         },
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/source-text",
>                             "valueString": "Mr Knox Isaac Khan"
>                         },
>                         {
>                             "url": "ex:createdAt",
>                             "valueInstant": "2024-08-19T14:57:37.397229Z"
>                         }
>                     ],
>                     "versionId": "7337232",
>                     "lastUpdated": "2024-08-19T14:57:37.397229Z",
>                     "security": [
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/source-organization",
>                             "code": "e8ce8a2b-6b08-3e03-8feb-eb32dc389ab4",
>                             "display": "Housewold NHS Trust"
>                         },
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/connecting-org",
>                             "code": "e8ce8a2b-6b08-3e03-8feb-eb32dc389ab4",
>                             "display": "Housewold NHS Trust"
>                         },
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/privacy-label",
>                             "code": "GENERAL_HEALTH"
>                         }
>                     ]
>                 },
>                 "extension": [
>                     {
>                         "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream",
>                         "extension": [
>                             {
>                                 "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream-source-id",
>                                 "valueString": "ehrmigrated"
>                             },
>                             {
>                                 "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream-resource-id",
>                                 "valueString": "MedicationStatement/e91ac267-523c-43d8-9030-fe5278aa649a"
>                             }
>                         ]
>                     },
>                     {
>                         "url": "http://fhir.patientsknowbest.com/structuredefinition/source-organization-time-zone-id",
>                         "valueString": "Europe/London"
>                     }
>                 ],
>                 "identifier": [
>                     {
>                         "system": "http://fhir.patientsknowbest.com/id/menudata-legacy-identifier",
>                         "value": "134612397"
>                     }
>                 ],
>                 "status": "active",
>                 "medicationCodeableConcept": {
>                     "coding": [
>                         {
>                             "display": "Aspirin 75mg tablets"
>                         }
>                     ]
>                 },
>                 "subject": {
>                     "reference": "Patient/85fcb223-a1ab-3efb-9d5b-376cca520781"
>                 },
>                 "effectivePeriod": {
>                     "start": "2021-02-12T00:00:00.000+00:00"
>                 },
>                 "dosage": [
>                     {
>                         "patientInstruction": "Take 1 tablet daily.",
>                         "doseAndRate": [
>                             {
>                                 "doseQuantity": {
>                                     "extension": [
>                                         {
>                                             "url": "http://fhir.patientsknowbest.com/structuredefinition/dose-units",
>                                             "valueCodeableConcept": {
>                                                 "coding": [
>                                                     {
>                                                         "display": "mg"
>                                                     }
>                                                 ]
>                                             }
>                                         }
>                                     ],
>                                     "value": 75.0,
>                                     "unit": "mg"
>                                 }
>                             }
>                         ]
>                     }
>                 ]
>             },
>             "search": {
>                 "mode": "match"
>             }
>         },
>         {
>             "link": [
>                 {
>                     "relation": "self",
>                     "url": "https://sandboxaggregated.fhir-api.sandbox.patientsknowbest.com/MedicationStatement/37524e64-42d8-365a-8ec5-5d7ccf719629"
>                 }
>             ],
>             "fullUrl": "https://sandboxaggregated.fhir-api.sandbox.patientsknowbest.com/MedicationStatement/37524e64-42d8-365a-8ec5-5d7ccf719629",
>             "resource": {
>                 "resourceType": "MedicationStatement",
>                 "id": "37524e64-42d8-365a-8ec5-5d7ccf719629",
>                 "meta": {
>                     "extension": [
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/access-route",
>                             "valueCoding": {
>                                 "system": "http://fhir.patientsknowbest.com/codesystem/access-route",
>                                 "code": "HL7_API",
>                                 "display": "Integration (HL7)"
>                             }
>                         },
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/uploaded-data-id",
>                             "valueString": "14253778"
>                         },
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/version-persisted",
>                             "valueDateTime": "2024-08-19T14:57:36.272+00:00"
>                         },
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/recorded-date",
>                             "valueDateTime": "2024-08-19T14:08:48.000+00:00"
>                         },
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/source-text",
>                             "valueString": "Prof Emmaline Summer Clark"
>                         },
>                         {
>                             "url": "ex:createdAt",
>                             "valueInstant": "2024-08-19T14:57:37.407723Z"
>                         }
>                     ],
>                     "versionId": "7337234",
>                     "lastUpdated": "2024-08-19T14:57:37.407723Z",
>                     "security": [
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/source-organization",
>                             "code": "e8ce8a2b-6b08-3e03-8feb-eb32dc389ab4",
>                             "display": "Housewold NHS Trust"
>                         },
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/connecting-org",
>                             "code": "e8ce8a2b-6b08-3e03-8feb-eb32dc389ab4",
>                             "display": "Housewold NHS Trust"
>                         },
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/privacy-label",
>                             "code": "GENERAL_HEALTH"
>                         }
>                     ]
>                 },
>                 "extension": [
>                     {
>                         "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream",
>                         "extension": [
>                             {
>                                 "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream-source-id",
>                                 "valueString": "ehrmigrated"
>                             },
>                             {
>                                 "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream-resource-id",
>                                 "valueString": "MedicationStatement/3ff90f58-fa66-4b55-bad7-a8f47a89afc5"
>                             }
>                         ]
>                     },
>                     {
>                         "url": "http://fhir.patientsknowbest.com/structuredefinition/source-organization-time-zone-id",
>                         "valueString": "Europe/London"
>                     }
>                 ],
>                 "identifier": [
>                     {
>                         "system": "http://fhir.patientsknowbest.com/id/menudata-legacy-identifier",
>                         "value": "134612398"
>                     }
>                 ],
>                 "status": "active",
>                 "medicationCodeableConcept": {
>                     "coding": [
>                         {
>                             "display": "Paracetamol 500mg tablets"
>                         }
>                     ]
>                 },
>                 "subject": {
>                     "reference": "Patient/85fcb223-a1ab-3efb-9d5b-376cca520781"
>                 },
>                 "effectivePeriod": {
>                     "start": "2021-01-15T00:00:00.000+00:00"
>                 },
>                 "dosage": [
>                     {
>                         "patientInstruction": "Take 1 tablet every 4-6 hours as needed for pain.  Do not take more than 4 doses a day.",
>                         "doseAndRate": [
>                             {
>                                 "doseQuantity": {
>                                     "extension": [
>                                         {
>                                             "url": "http://fhir.patientsknowbest.com/structuredefinition/dose-units",
>                                             "valueCodeableConcept": {
>                                                 "coding": [
>                                                     {
>                                                         "display": "mg"
>                                                     }
>                                                 ]
>                                             }
>                                         }
>                                     ],
>                                     "value": 500.0,
>                                     "unit": "mg"
>                                 }
>                             }
>                         ]
>                     }
>                 ]
>             },
>             "search": {
>                 "mode": "match"
>             }
>         },
>         {
>             "link": [
>                 {
>                     "relation": "self",
>                     "url": "https://sandboxaggregated.fhir-api.sandbox.patientsknowbest.com/MedicationStatement/7a602f71-7233-3db6-b377-9e76e94d46e7"
>                 }
>             ],
>             "fullUrl": "https://sandboxaggregated.fhir-api.sandbox.patientsknowbest.com/MedicationStatement/7a602f71-7233-3db6-b377-9e76e94d46e7",
>             "resource": {
>                 "resourceType": "MedicationStatement",
>                 "id": "7a602f71-7233-3db6-b377-9e76e94d46e7",
>                 "meta": {
>                     "extension": [
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/access-route",
>                             "valueCoding": {
>                                 "system": "http://fhir.patientsknowbest.com/codesystem/access-route",
>                                 "code": "WEBAPP",
>                                 "display": "PKB website"
>                             }
>                         },
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/version-persisted",
>                             "valueDateTime": "2023-06-19T08:50:20+00:00"
>                         },
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/recorded-date",
>                             "valueDateTime": "2023-06-19T08:50:20+00:00"
>                         },
>                         {
>                             "url": "ex:createdAt",
>                             "valueInstant": "2023-06-19T08:50:21.529027Z"
>                         }
>                     ],
>                     "versionId": "5665127",
>                     "lastUpdated": "2023-06-19T08:50:21.529027Z",
>                     "security": [
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/source-practitioner",
>                             "code": "347fbdd4-1efa-37f3-b216-83c14e19e0ba",
>                             "display": "Dr Paul GP"
>                         },
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/privacy-label",
>                             "code": "SEXUAL_HEALTH"
>                         }
>                     ]
>                 },
>                 "extension": [
>                     {
>                         "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream",
>                         "extension": [
>                             {
>                                 "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream-source-id",
>                                 "valueString": "ehrmigrated"
>                             },
>                             {
>                                 "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream-resource-id",
>                                 "valueString": "MedicationStatement/11012086-1f5e-4436-bca6-1212f6e0a93c"
>                             }
>                         ]
>                     }
>                 ],
>                 "identifier": [
>                     {
>                         "system": "http://fhir.patientsknowbest.com/id/menudata-legacy-identifier",
>                         "value": "133671382"
>                     }
>                 ],
>                 "status": "active",
>                 "medicationCodeableConcept": {
>                     "text": "clindamycin"
>                 },
>                 "subject": {
>                     "reference": "Patient/85fcb223-a1ab-3efb-9d5b-376cca520781"
>                 },
>                 "effectivePeriod": {
>                     "start": "2017-04-19T23:00:00+00:00",
>                     "end": "2017-08-19T23:00:00+00:00"
>                 },
>                 "dosage": [
>                     {
>                         "timing": {
>                             "repeat": {
>                                 "frequency": 1,
>                                 "period": 8,
>                                 "periodUnit": "h"
>                             }
>                         },
>                         "doseAndRate": [
>                             {
>                                 "doseQuantity": {
>                                     "value": 1.0,
>                                     "code": "CAPSULES"
>                                 }
>                             }
>                         ]
>                     }
>                 ]
>             },
>             "search": {
>                 "mode": "match"
>             }
>         },
>         {
>             "link": [
>                 {
>                     "relation": "self",
>                     "url": "https://sandboxaggregated.fhir-api.sandbox.patientsknowbest.com/MedicationStatement/55b60937-9fe1-3b0d-ba02-c112f6a16677"
>                 }
>             ],
>             "fullUrl": "https://sandboxaggregated.fhir-api.sandbox.patientsknowbest.com/MedicationStatement/55b60937-9fe1-3b0d-ba02-c112f6a16677",
>             "resource": {
>                 "resourceType": "MedicationStatement",
>                 "id": "55b60937-9fe1-3b0d-ba02-c112f6a16677",
>                 "meta": {
>                     "extension": [
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/access-route",
>                             "valueCoding": {
>                                 "system": "http://fhir.patientsknowbest.com/codesystem/access-route",
>                                 "code": "HL7_API",
>                                 "display": "Integration (HL7)"
>                             }
>                         },
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/uploaded-data-id",
>                             "valueString": "14253778"
>                         },
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/version-persisted",
>                             "valueDateTime": "2024-08-19T14:57:36.270+00:00"
>                         },
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/recorded-date",
>                             "valueDateTime": "2024-08-19T14:08:48.000+00:00"
>                         },
>                         {
>                             "url": "http://fhir.patientsknowbest.com/structuredefinition/source-text",
>                             "valueString": "Dr Shepherd Leon Smith"
>                         },
>                         {
>                             "url": "ex:createdAt",
>                             "valueInstant": "2024-08-19T14:57:37.403789Z"
>                         }
>                     ],
>                     "versionId": "7337233",
>                     "lastUpdated": "2024-08-19T14:57:37.403789Z",
>                     "security": [
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/source-organization",
>                             "code": "e8ce8a2b-6b08-3e03-8feb-eb32dc389ab4",
>                             "display": "Housewold NHS Trust"
>                         },
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/connecting-org",
>                             "code": "e8ce8a2b-6b08-3e03-8feb-eb32dc389ab4",
>                             "display": "Housewold NHS Trust"
>                         },
>                         {
>                             "system": "http://fhir.patientsknowbest.com/codesystem/privacy-label",
>                             "code": "GENERAL_HEALTH"
>                         }
>                     ]
>                 },
>                 "extension": [
>                     {
>                         "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream",
>                         "extension": [
>                             {
>                                 "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream-source-id",
>                                 "valueString": "ehrmigrated"
>                             },
>                             {
>                                 "url": "https://fhir.patientsknowbest.com/structuredefinition/upstream-resource-id",
>                                 "valueString": "MedicationStatement/71fdafaa-9da2-422d-8a2a-97ee357cc275"
>                             }
>                         ]
>                     },
>                     {
>                         "url": "http://fhir.patientsknowbest.com/structuredefinition/source-organization-time-zone-id",
>                         "valueString": "Europe/London"
>                     }
>                 ],
>                 "identifier": [
>                     {
>                         "system": "http://fhir.patientsknowbest.com/id/menudata-legacy-identifier",
>                         "value": "134612395"
>                     }
>                 ],
>                 "status": "active",
>                 "medicationCodeableConcept": {
>                     "coding": [
>                         {
>                             "display": "Sertrolin 100mg tablets"
>                         }
>                     ]
>                 },
>                 "subject": {
>                     "reference": "Patient/85fcb223-a1ab-3efb-9d5b-376cca520781"
>                 },
>                 "effectivePeriod": {
>                     "start": "2016-05-29T23:00:00.000+00:00"
>                 },
>                 "dosage": [
>                     {
>                         "patientInstruction": "Take 1 tablet daily.",
>                         "doseAndRate": [
>                             {
>                                 "doseQuantity": {
>                                     "extension": [
>                                         {
>                                             "url": "http://fhir.patientsknowbest.com/structuredefinition/dose-units",
>                                             "valueCodeableConcept": {
>                                                 "coding": [
>                                                     {
>                                                         "display": "mg"
>                                                     }
>                                                 ]
>                                             }
>                                         }
>                                     ],
>                                     "value": 100.0,
>                                     "unit": "mg"
>                                 }
>                             }
>                         ]
>                     }
>                 ]
>             },
>             "search": {
>                 "mode": "match"
>             }
>         }
>     ]
> }
> ```

> Macro (excerpt)
> 
> ## Aggregated MedicationStatement supported search parameters
> 
> ```
> {
>                             "name": "code",
>                             "definition": "/SearchParameter/MedicationStatement.code",
>                             "type": "token"
>                         },
>                         {
>                             "name": "identifier",
>                             "definition": "/SearchParameter/MedicationStatement.identifier",
>                             "type": "token"
>                         },
>                         {
>                             "name": "category",
>                             "definition": "/SearchParameter/MedicationStatement.category",
>                             "type": "token"
>                         },
>                         {
>                             "name": "medication",
>                             "definition": "/SearchParameter/MedicationStatement.medication",
>                             "type": "reference"
>                         },
>                         {
>                             "name": "part-of",
>                             "definition": "/SearchParameter/MedicationStatement.part-of",
>                             "type": "reference"
>                         },
>                         {
>                             "name": "source",
>                             "definition": "/SearchParameter/MedicationStatement.source",
>                             "type": "reference"
>                         },
>                         {
>                             "name": "subject",
>                             "definition": "/SearchParameter/MedicationStatement.subject",
>                             "type": "reference"
>                         },
>                         {
>                             "name": "effective",
>                             "definition": "/SearchParameter/MedicationStatement.effective",
>                             "type": "date"
>                         },
>                         {
>                             "name": "context",
>                             "definition": "/SearchParameter/MedicationStatement.context",
>                             "type": "reference"
>                         },
>                         {
>                             "name": "status",
>                             "definition": "/SearchParameter/MedicationStatement.status",
>                             "type": "token"
>                         },
>                         {
>                             "name": "patient",
>                             "definition": "/SearchParameter/MedicationStatement.patient",
>                             "type": "reference"
>                         }
> ```