> ## Documentation Index
> Fetch the complete documentation index at: https://docs.connectivehealth.io/llms.txt
> Use this file to discover all available pages before exploring further.

# MedicationRequest

> The FHIR MedicationRequest resource as produced by Connective Health

[FHIR R4 MedicationRequest](https://www.hl7.org/fhir/R4/medicationrequest.html) ·
[US Core MedicationRequest](https://hl7.org/fhir/us/core/STU9/StructureDefinition-us-core-medicationrequest.html)

<Info>
  `MedicationRequest` is produced for all three FHIR outputs, from different source data. The
  [Patient Everything](/fhir/patient-everything-bundle) and [Patient Summary](/fhir/patient-summary-bundle) bundles
  populate it identically to one another; [Bulk Medication History](/fhir/bulk-medication-history-bundle) is built
  from pharmacy claim data and differs in several places. The **Stable ID** and **Fields** sections below cover
  both, with a column per output.
</Info>

# Stable ID

| Output                       | Recipe                                                                                                                                                                                                                                              |
| ---------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Patient Everything / Summary | Derived from the patient, the prescribed date, the medication code, the drug name code, the directions (sig), the strength value and unit, the refills allowed, and the initial fill quantity.                                                      |
| Bulk Med History             | Derived from the patient, written date, product code, drug description, directions, strength, refills, and quantity prescribed. If a subsequent request contains a record with all of the same values, it resolves to the same `MedicationRequest`. |

# Fields

| Field                                    | Patient Everything / Summary | Bulk Med History | Notes                                                                                                                                                                                                                                                                                                                                             |
| ---------------------------------------- | ---------------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `meta.profile`                           | 1..1                         | 1..1             | Always set to the US Core MedicationRequest profile URL.                                                                                                                                                                                                                                                                                          |
| `status`                                 | 1..1                         | 1..1             | Bundles: `active` when the source medication is flagged as still active, otherwise `completed`. Bulk Med History: `completed` when the source record has a sold/fill date, otherwise `active`.                                                                                                                                                    |
| `intent`                                 | 1..1                         | 1..1             | Always `order`.                                                                                                                                                                                                                                                                                                                                   |
| `subject`                                | 1..1                         | 1..1             | Reference to the [Patient](/fhir/resources/patient).                                                                                                                                                                                                                                                                                              |
| `category`                               | 1..1                         | 1..1             | Currently, always coded as `outpatient` using the [medicationrequest-category](http://terminology.hl7.org/CodeSystem/medicationrequest-category) system.                                                                                                                                                                                          |
| `medication[x]`                          | 1..1                         | 1..1             | Bundles: either a reference to a contained [Medication](/fhir/resources/medication) resource or an inline `medicationCodeableConcept` -- see [Medication representation](#medication-representation). Bulk Med History: **always** a reference to a full [Medication](/fhir/resources/medication) resource, regardless of customer configuration. |
| `requester`                              | 0..1                         | 1..1             | Reference to the prescriber's [PractitionerRole](/fhir/resources/practitioner-role). Omitted in the bundles when no prescriber is known; always populated in Bulk Med History.                                                                                                                                                                    |
| `authoredOn`                             | 0..1                         | 0..1             | The prescribed/written date, when present.                                                                                                                                                                                                                                                                                                        |
| `dosageInstruction.text`                 | 0..1                         | 0..1             | The source free-text directions (sig).                                                                                                                                                                                                                                                                                                            |
| `dosageInstruction.doseAndRate.dose`     | 0..1                         | 0..1             | Bundles: the strength value and unit, normalized to [UCUM](http://unitsofmeasure.org), when the strength value is numeric. Bulk Med History: parsed from the source free-text strength field (e.g. `"10 MG"`) -- only populated when that text matches a simple "number followed by unit" pattern; other formats are silently skipped.            |
| `dispenseRequest.quantity`               | 0..1                         | 0..1             | Bundles: the initial fill quantity, when present. Bulk Med History: the quantity prescribed, when it is a valid number, with `code` set to the source potency unit code using the [NCI Thesaurus](https://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl) system.                                                                                    |
| `dispenseRequest.numberOfRepeatsAllowed` | 0..1                         | 0..0             | Bundles only: the source refill count **plus one**, reflecting that FHIR counts repeats after the initial fill differently from how the source counts authorized fills. Not populated in Bulk Med History.                                                                                                                                        |

<Warning>
  In the bundles, a medication with no usable drug code -- neither a coded product nor a drug name with a
  description -- is **excluded** entirely rather than published without a medication.
</Warning>

<Note>
  `encounter`, `reasonCode`, `priority`, `substitution`, and `dispenseRequest.validityPeriod` are not populated in
  either output.
</Note>

## Medication representation

FHIR allows the drug to be given either inline as a code or as a separate `Medication` resource. In the
Patient Everything and Patient Summary bundles, which one is used depends on customer configuration:

| Customer configuration                         | `medication[x]`                                                                                                                   |
| ---------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| Full `Medication` resources enabled            | `medicationReference`, pointing at a [Medication](/fhir/resources/medication) resource contained inside this `MedicationRequest`. |
| Full `Medication` resources disabled (default) | `medicationCodeableConcept`, carrying the drug coding inline.                                                                     |

In both cases the coding published is the same "effective" code: the source's coded product where it carries both a
code and a description, otherwise the drug name code. If neither is fully populated, whichever of the two has a
description is used.

<Note>
  Bulk Medication History does not have this configuration switch -- it always uses `medicationReference` against a
  full [Medication](/fhir/resources/medication) resource, regardless of customer configuration.
</Note>
