---
title: "Aggregated MedicationStatement"
canonical: "https://wiki.patientsknowbest.com/space/api/3583082497/Aggregated%20MedicationStatement"
format: markdown
---
[http://fhir.patientsknowbest.com/structuredefinition/aggregated-medicationstatement](http://fhir.patientsknowbest.com/structuredefinition/aggregated-medicationstatement)

[https://www.hl7.org/fhir/R4/medicationstatement.html](https://www.hl7.org/fhir/R4/medicationstatement.html)

## Description

This profile is…

- a description of how non-FHIR medication data will be mapped to FHIR in the [Aggregated FHIR endpoint](https://wiki.hub.patientsknowbest.com/wiki/spaces/api/pages/3364388935) by PKB

This profile is not…

- a spec for all Medication and MedicationStatement resources returned from the Aggregated FHIR endpoint; resources sent to a Customer FHIR endpoint are not guaranteed to conform to this profile
- a spec describing how Medication and MedicationStatement resources must be sent to a Customer FHIR endpoint; some of the elements used in this profile might only be meaningful for migrated data and cannot be provided to a Customer FHIR endpoint

## Relevant PKB entities

- [[[Medication]]](https://wiki.patientsknowbest.com/space/api/3738402817/Entity%3A+Medication)

| **FHIR** | **PKB** | **Notes** |
| --- | --- | --- |
| Resource id | [[Medication.Aggregated Data Point ID]] |  |
| Resource meta | - meta: Meta
  - lastUpdated = time of most recent update, automatically maintained by the FHIR server. It is normal for this to be slightly later than any value returned in the [http://fhir.patientsknowbest.com/structuredefinition/version-persisted](http://fhir.patientsknowbest.com/structuredefinition/version-persisted) extension.
  - security[x]: Coding
    - system = <span style="color: #0747a6">"</span>[http://fhir.patientsknowbest.com/codesystem/privacy-label](http://fhir.patientsknowbest.com/codesystem/privacy-label)<span style="color: #0747a6">"</span>
    - code = [[Data Point.Privacy Label]]
  - security[x]: Coding
    - system =<span style="color: #0747a6"> “</span>[http://fhir.patientsknowbest.com/codesystem/source-organization](http://fhir.patientsknowbest.com/codesystem/source-organization)”
    - code = the resource ID of the Organization representing the [[Data Point.Source Organisation]]
  - security[x]: Coding
    - system = <span style="color: #0747a6">“</span>[http://fhir.patientsknowbest.com/codesystem/source-team](http://fhir.patientsknowbest.com/codesystem/source-team)”
    - code = the resource ID of the Organization representing the [[Data Point.Source Team]]
  - <span style="color: #ff991f"><conditional></span>
  - <span style="color: #ff991f">If Source Person is a Professional:</span>
  - security[x]: Coding
    - system = <span style="color: #0747a6">“</span>[http://fhir.patientsknowbest.com/codesystem/source-practitioner](http://fhir.patientsknowbest.com/codesystem/source-practitioner)”
    - code = the resource ID of the Practitioner
  - <span style="color: #ff991f">Else if Source Person is a Patient:</span>
  - security[x]: Coding
    - system = <span style="color: #0747a6">“</span>[http://fhir.patientsknowbest.com/codesystem/source-patient](http://fhir.patientsknowbest.com/codesystem/source-patient)”
    - code = the resource ID of the Patient
  - security[x]: Coding
    - system =<span style="color: #0747a6"> “</span>[http://fhir.patientsknowbest.com/codesystem/connecting-org](http://fhir.patientsknowbest.com/codesystem/connecting-org)”
    - code = the resource ID of the Organization representing the [[Data Point.Connecting Organisation]]<br>[[Data Point.Privacy Label]] code mappings (PKB → FHIR):<br>- GENERAL_HEALTH → GENERAL_HEALTH
- MENTAL_HEALTH → MENTAL_HEALTH
- SEXUAL_HEALTH → SEXUAL_HEALTH
- SOCIAL_CARE → SOCIAL_CARE |  |
|  | - extension[x]: Extension
  - url = “[http://fhir.patientsknowbest.com/structuredefinition/uploaded-data-id](http://fhir.patientsknowbest.com/structuredefinition/uploaded-data-id)”
  - valueString = [[Data Point.Uploaded Data ID]] | A single uploadeddata entry can result in multiple data points, so this ID does not necessarily uniquely identify a data point. |
|  | - extension[x]: Extension
  - url = “[http://fhir.patientsknowbest.com/structuredefinition/access-route](http://fhir.patientsknowbest.com/structuredefinition/access-route)”
  - valueCoding: Coding
    - system = “[http://fhir.patientsknowbest.com/codesystem/access-route](http://fhir.patientsknowbest.com/codesystem/access-route)”
    - code = [[Data Point.Access Route]] |  |
|  | - extension[x]: Extension
  - url = <span style="color: #0747a6">"</span>[http://fhir.patientsknowbest.com/structuredefinition/source-text](http://fhir.patientsknowbest.com/structuredefinition/source-text)<span style="color: #0747a6">"</span>
  - valueString = [[Data Point.Source Text]] |  |
|  | - extension[x]: Extension
  - url = <span style="color: #0747a6">“</span>[http://fhir.patientsknowbest.com/structuredefinition/responsible-organization](http://fhir.patientsknowbest.com/structuredefinition/responsible-organization)<span style="color: #0747a6">”</span>
  - valueString = [[Data Point.Responsible Organisation Identifier]] |  |
|  | - extension[x]: Extension
  - url = <span style="color: #0747a6">“</span>[http://fhir.patientsknowbest.com/structuredefinition/partner-identifier](http://fhir.patientsknowbest.com/structuredefinition/partner-identifier)<span style="color: #0747a6">”</span>
  - valueReference: Reference
    - identifier: Identifier
      - system = <span style="color: #0747a6">“urn:uuid:cd97da65-0aa4-43a6-b695-cfd0c6f3267d</span>”
      - value = [[Data Point.HL7 Partner]] |  |
|  | - extension[x]: Extension
  - url = <span style="color: #0747a6">“</span>[http://fhir.patientsknowbest.com/structuredefinition/privacy-override-source-organization](http://fhir.patientsknowbest.com/structuredefinition/privacy-override-source-organization)<span style="color: #0747a6">”</span>
  - valueReference: Reference
    - reference = the relative URL of the Organization resource for the source organisation of the most recent privacy override | Note that this is a reference, unlike the meta.security which contains a code. |
|  | - extension[x]: Extension
  - url = <span style="color: #0747a6">"</span>[http://fhir.patientsknowbest.com/structuredefinition/privacy-override-source-team](http://fhir.patientsknowbest.com/structuredefinition/privacy-override-source-team)<span style="color: #0747a6">”</span>
  - valueReference: Reference
    - reference = the relative URL of the Organization resource for the source team of the most recent privacy override | Note that this is a reference, unlike the meta.security which contains a code. |
|  | - extension[x]: Extension
  - url = <span style="color: #0747a6">"</span>[http://fhir.patientsknowbest.com/structuredefinition/privacy-override-source-person](http://fhir.patientsknowbest.com/structuredefinition/privacy-override-source-person)<span style="color: #0747a6">”</span>
  - valueReference: Reference
    - reference = the relative URL of the Patient or Practitioner resource of the source person of the most recent privacy override | Note that this is a reference, unlike the meta.security which contains a code. |
|  | - extension[x]: Extension
  - url = <span style="color: #0747a6">"</span>[http://fhir.patientsknowbest.com/structuredefinition/privacy-override-access-route](http://fhir.patientsknowbest.com/structuredefinition/privacy-override-access-route)<span style="color: #0747a6">”</span>
  - valueCoding: Coding
    - system = <span style="color: #0747a6">“</span>[http://fhir.patientsknowbest.com/codesystem/access-route](http://fhir.patientsknowbest.com/codesystem/access-route)<span style="color: #0747a6">”</span>
    - code = the access route which added the most recent privacy override |  |
|  | - extension[x]: Extension
  - url = <span style="color: #0747a6">"</span>[http://fhir.patientsknowbest.com/structuredefinition/privacy-override-change-date](http://fhir.patientsknowbest.com/structuredefinition/privacy-override-change-date)<span style="color: #0747a6">“</span>
  - valueDateTime = the timestamp of the most recent privacy override |  |
|  | - extension[x]: Extension
  - url = “[http://fhir.patientsknowbest.com/structuredefinition/recorded-date](http://fhir.patientsknowbest.com/structuredefinition/recorded-date)”
  - valueDateTime = [[Data Point.Entered Timestamp]] |  |
|  | - extension[x]: Extension
  - url = “[http://fhir.patientsknowbest.com/structuredefinition/version-persisted](http://fhir.patientsknowbest.com/structuredefinition/version-persisted)”
  - valueDateTime = [[Data Point.Persisted Timestamp]] |  |
|  | - extension[x]: Extension
  - url = “[https://fhir.patientsknowbest.com/structuredefinition/upstream-last-updated](https://fhir.patientsknowbest.com/structuredefinition/upstream-last-updated)”
  - valueDateTime = as per extension definition |  |
| MedicationStatement.extension | For each [[Medication.Attachment]]:<br>- extension[x]: Extension
  - url = "[http://fhir.patientsknowbest.com/structuredefinition/attachment](http://fhir.patientsknowbest.com/structuredefinition/attachment)"
  - valueAttachment: Attachment
    - contentType = [[Attachment.Media Type]]
    - title = [[Attachment.Filename]] |  |
|  | - extension[x]: Extension
  - url = "[http://fhir.patientsknowbest.com/structuredefinition/specialty](http://fhir.patientsknowbest.com/structuredefinition/specialty)"
  - valueCoding: Coding
    - code = [[Data Point.Specialty]]
    - display = Resolve( [[Data Point.Specialty]] ) | The “Resolve()” notation indicates that the display value for the corresponding specialty code will be determined at the time of retrieval, based [on the (optional) code set for the source organisation](https://pkbdev.atlassian.net/wiki/spaces/api/pages/3365012136/Code+sets#Hospital-Service-(Specialty)). |
|  | - extension[x]: Extension
  - url = “[https://fhir.patientsknowbest.com/structuredefinition/upstream](https://fhir.patientsknowbest.com/structuredefinition/upstream)”
  - extension[x]: Extension
    - url = “[https://fhir.patientsknowbest.com/structuredefinition/upstream-source-id](https://fhir.patientsknowbest.com/structuredefinition/upstream-source-id)”
    - valueString = “<span style="color: #0747a6">ehrmigrated</span>”
  - extension[x]: Extension
    - url = “[https://fhir.patientsknowbest.com/structuredefinition/upstream-resource-id](https://fhir.patientsknowbest.com/structuredefinition/upstream-resource-id)”
    - valueString = MedicationStatement/[[Data Point ID]] |  |
| MedicationStatement.identifier | - identifier[x]: Identifier
  - system = “[http://fhir.patientsknowbest.com/id/menudata-legacy-identifier](http://fhir.patientsknowbest.com/id/menudata-legacy-identifier)”
  - value = [[Data Point.Legacy Data Point ID]] |  |
|  | - identifier[x]: Identifier
  - value = [[Data Point.External Data Point ID]]
  - assigner: Reference
    - reference = the relative URL of the Organization representing the [[Data Point.Source Organisation]] |  |
| MedicationStatement.status | - <span style="color: #ff991f"><conditional></span>
- <span style="color: #ff991f">If [[Medication.Status]] == INACTIVE:</span>
  - <span style="color: #0747a6">“completed“</span>
- <span style="color: #ff991f">Else</span>
  - <span style="color: #0747a6">“active“</span> |  |
| MedicationStatement.medicationCodeableConcept | [[Medication.Substance]] |  |
| MedicationStatement.effectivePeriod | - effectivePeriod: Period
  - start = [[Medication.Start Timestamp]]
  - end = [[Medication.End Timestamp]] |  |
| MedicationStatement.subject | - subject: Reference
  - reference = the relative URL of the Patient resource
  - display = [[User.Title]] [[User.Given Name]] [[User.Family Name]] |  |
| MedicationStatement.dosage | - dosage[0]: Dosage
  - text = [[Medication.Frequency Text]]
  - patientInstruction = [[Medication.Instructions]]
  - timing: Timing
    - <conditional>
    - If [[Medication.Frequency Priority]] != AS_DIRECTED AND != AS_NEEDED:
      - repeat: Element
        - frequency = 1
        - period = [[Medication.Frequency Value]]
        - periodUnit = [[Medication.Frequency Units]]
    - Else if [[Medication.Frequency Priority]] == AS_DIRECTED:
      - code: CodeableConcept
        - text = "As directed"
    - Else:
      - Omit the "code" element
  - <conditional>
  - If [[Medication.Frequency Priority]] == AS_NEEDED:
    - asNeededBoolean = true
  - Else:
    - Omit the "asNeededBoolean" element
  - doseAndRate: Element
    - doseQuantity: SimpleQuantity
      - extension[x]: Extension
        - url = <span style="color: #0747a6">“</span><span style="color: #0747a6">[http://fhir.patientsknowbest.com/structuredefinition/dose-units](http://fhir.patientsknowbest.com/structuredefinition/dose-units)</span><span style="color: #0747a6">”</span>
        - valueCodeableConcept = [[Medication.Dose Units]]
      - value = [[Medication.Dose Value]]
      - <span style="color: #ff5630"><conditional></span>
      - <span style="color: #ff5630">If </span>[[Medication.Medication Unit]]<span style="color: #ff5630"> NOT NULL:</span>
        - code = [[Medication.Medication Unit]]
      - <span style="color: #ff5630">Else if </span>[[Medication.Dose Units.Display Text]]<span style="color: #ff5630"> NOT BLANK:</span>
        - unit = [[Medication.Dose Units.Display Text]]
      - <span style="color: #ff5630">Else:</span>
        - unit = [[Medication.Dose Units]] {coding[0] - display}
        - system = [[Medication.Dose Units]] {coding[0] - system}
        - code = [[Medication.Dose Units]] {coding[0] - code}<br>[[Medication.Frequency Units]] code mappings (PKB → FHIR):<br>- HOUR → h | Note #1: PKB supports more than one for dose units, but Quantity can represent only one. To ensure data is not lost, an extension is returned with the full CodeableConcept.<br>Note #2: Frequency instructions of “as directed” are discouraged, but if they have been provided then “As directed” will be set into the timing.code.text element. |