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

# Medication Request

## Overview

An order or request for both supply of the medication and the instructions for administration of the medication to a patient. The resource is called "MedicationRequest" rather than "MedicationPrescription" or "MedicationOrder" to generalize the use across inpatient and outpatient settings, including care plans, etc., and to harmonize with workflow patterns.

**Each MedicationRequest has next elements:**

* a status
* an intent code
* a medication
* a patient

**Each MedicationRequest supports next elements:**

* the category (e.g., Discharge Medication)
* the reported flag or reference signaling that information is from a secondary source such as a patient
* the encounters
* a prescriber
* a date for when written
* the prescription Sig
* the amount dispensed and number of refills
* the dose and rate

**Profile specific implementation guidance:**

* See the [Medication List](https://www.hl7.org/fhir/us/core/medication-list.html) section for guidance on accessing a patient medications including over the counter (OTC) medication and other substances taken for medical and recreational use.
* \*The MedicationRequest resources can represent a medication using either a code, or reference a [Medication](http://hl7.org/fhir/R4/medication.html) resource.
  * When referencing a Medication resource, the resource may be [contained](http://hl7.org/fhir/R4/references.html#contained) or an external resource.
  * The server application MAY choose any combination of these methods, but if an external reference to Medication is used, the server SHALL support the \_include parameter for searching this element.
  * The client application SHALL support both elements.
* Source EHR identifiers SHOULD be included to support deduplication across MedicationRequest resources. Exposing the EHR identifiers helps client applications identify duplicates.

This resource conforms to [USCDI V3 profile](https://www.healthit.gov/isa/uscdi-data-class/medications#uscdi-v3) for MedicationRequest - refer to [StructureDefinition US Core MedicationRequest](http://hl7.org/fhir/us/core/STU6.1/StructureDefinition-us-core-medicationrequest.html). MedicationRequest response will be provided in JSON (refers to Capability Statement) format as per [FHIR](https://hl7.org/fhir) standard R4 version.

| USCore Data Element | FHIR Resource Field          |
| ------------------- | ---------------------------- |
| status              | medicationRequest.status     |
| intent code         | medicationRequest.intent     |
| medication          | medicationRequest.medication |
| patient             | medicationRequest.subject    |
| date when written   | medicationRequest.authoredOn |
| prescriber          | medicationRequest.requester  |

### Must support elements, mandatory and optional search parameters

*MedicationRequest**must support** these elements:*

* `status`
* `intent`
* `category`
  * `category:us-core`
* `reported[x]`
* `medication[x]`
* `subject`
* `encounter`
* `authoredOn`
* `requester`
* `dosageInstruction`
  * `text`
  * `timing`
* `doseAndRate`
  * `dose[x]`
* `dispenseRequest`
  * `numberOfRepeatsAllowed`
  * `quantity`

*The following search parameters and search parameter combinations SHALL be supported:*
**SHALL** support searching using the combination of the `patient` and `intent` search parameters:

* including support for OR search on intent (e.g.intent=\{system|}\[code],\{system|}\[code],...)

`GET [base url]/MedicationRequest?patient={Type/}[id]&intent=order,plan`

**SHALL** support searching using the combination of the `patient` and `intent` and `status` search parameters:

* including support for OR search on intent (e.g.intent=\{system|}\[code],\{system|}\[code],...)
* including support for OR search on status (e.g.status=\{system|}\[code],\{system|}\[code],...)

`GET [base url]/MedicationRequest?patient={Type/}[id]&intent=order,plan&status={system|}[code]`

*The following search parameter combinations **SHOULD**  be supported (**optional**):*

**SHOULD** support searching using the combination of the patient and intent and encounter search parameters:

* including support for OR search on intent (e.g.intent=\{system|}\[code],\{system|}\[code],...)

`GET [base url]/MedicationRequest?patient={Type/}[id]&intent=order,plan&encounter={Type/}[encounter_id]`

**SHOULD** support searching using the combination of the `patient` and `intent` and `authoredon` search parameters:

* including support for OR search on intent (e.g.intent=\{system|}\[code],\{system|}\[code],...)
* including support for these authoredon comparators: gt,lt,ge,le
* including optional support for AND search on authoredon (e.g.authoredon=\[date]\&authoredon=\[date]&...)

`GET [base url]/MedicationRequest?patient={Type/}[id]&intent=order,plan&authoredon={gt|lt|ge|le}[date]&authoredon={gt|lt|ge|le}[date]`

The response to any search operation is always a list of resources in a Bundle or an Operation Outcome.

## MedicationRequest By Patient Id

Search for MedicationRequest by patient.

**METHOD** *GET*

```
[base url]/MedicationRequest?patient={Type/}[id]
```

**PARAMS**
\[base url] - [FHIR base url](/articles/fhir/service-base-urls)
\[id] - Id for the Patient

**HEADERS**

The Authorization token SHALL be obtained during the Authentication and Authorization process. Go to [Authentication and Authorization](/articles/fhir/authentication-authorization) for further details.

| Header        | Type       | Required/Optional | Value            |
| ------------- | ---------- | ----------------- | ---------------- |
| Authorization | **string** | required          | `Bearer <token>` |

**RESPONSES**

| Code | Description                        | Comment                                                                                                                                         |
| ---- | ---------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| 200  | OK                                 | The request was processed successfully                                                                                                          |
| 400  | Bad request                        | Invalid request parameters or FHIR operation outcome resource returned                                                                          |
| 401  | Unauthorized                       | This code indicates that the client request has not been completed because it lacks valid authentication credentials for the requested resource |
| 404  | No route matched with those values | The request was able to communicate with a given server, but the server could not find what was requested                                       |
| 500  | Internal Server Error              | The server has encountered a situation it doesn't know how to handle                                                                            |

**EXAMPLE:**

```
curl --location --request GET 'https://sandbox.fhir.elationemr.com/fhir/MedicationRequest?patient=Patient/c5137fa5-3216-b12a-cbbc-a0c6bef361g7' \
--header 'Authorization: Bearer fe1cd986-1ac7-4c26-b8b3-d632a48408fd'
```

## MedicationRequest By Id

Get MedicationRequest by ID.

**METHOD** *GET*

```
[base url]/MedicationRequest/{id}
```

or

```
[base url]/MedicationRequest?_id={id}
```

**PARAMS**
\[base url] - [FHIR base url](/articles/fhir/service-base-urls)
\{id} - Id for MedicationRequest resource

**HEADERS**

The Authorization token SHALL be obtained during the Authentication and Authorization process. Go to [Authentication and Authorization](/articles/fhir/authentication-authorization) for further details.

| Header        | Type       | Required/Optional | Value            |
| ------------- | ---------- | ----------------- | ---------------- |
| Authorization | **string** | required          | `Bearer <token>` |

**RESPONSES**

| Code | Description                        | Comment                                                                                                                                         |
| ---- | ---------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| 200  | OK                                 | The request was processed successfully                                                                                                          |
| 400  | Bad request                        | Invalid request parameters or FHIR operation outcome resource returned                                                                          |
| 401  | Unauthorized                       | This code indicates that the client request has not been completed because it lacks valid authentication credentials for the requested resource |
| 404  | No route matched with those values | The request was able to communicate with a given server, but the server could not find what was requested                                       |
| 500  | Internal Server Error              | The server has encountered a situation it doesn't know how to handle                                                                            |

**EXAMPLE:**

```
curl --location --request GET 'https://sandbox.fhir.elationemr.com/fhir/MedicationRequest/c5137fa5-3216-b12a-cbbc-a0c6bef361g7' \
--header 'Authorization: Bearer fe1cd986-1ac7-4c26-b8b3-d632a48408fd'
```

## MedicationRequest by patient and intent search parameters

Get MedicationRequests  using the combination of the patient and intent search parameters

**METHOD** *GET*

```
GET [base url]/MedicationRequest?patient={Type/}[id]&intent=order,plan&status={system|}[code]
```

**PARAMS**
\[base url] - [FHIR base url](/articles/fhir/service-base-urls)
\{Type/} - Type for the Reference. *Example:* `Patient`
\[id] - patient id
\{system|} - terminology system used to identify medication request status
\[code] - status of the medication request

**HEADERS**

The Authorization token SHALL be obtained during the Authentication and Authorization process. Go to [Authentication and Authorization](/articles/fhir/authentication-authorization) for further details.

| Header        | Type       | Required/Optional | Value            |
| ------------- | ---------- | ----------------- | ---------------- |
| Authorization | **string** | required          | `Bearer <token>` |

**RESPONSES**

| Code | Description                        | Comment                                                                                                                                         |
| ---- | ---------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| 200  | OK                                 | The request was processed successfully                                                                                                          |
| 400  | Bad request                        | Invalid request parameters or FHIR operation outcome resource returned                                                                          |
| 401  | Unauthorized                       | This code indicates that the client request has not been completed because it lacks valid authentication credentials for the requested resource |
| 404  | No route matched with those values | The request was able to communicate with a given server, but the server could not find what was requested                                       |
| 500  | Internal Server Error              | The server has encountered a situation it doesn't know how to handle                                                                            |

**EXAMPLE:**

```
curl --location --request GET 'https://sandbox.fhir.elationemr.com/fhir/MedicationRequest?patient=Patient/fe1cd986-1ac7-4c26-b8b3-d632a48408fd&intent=order,plan&status=active' \
--header 'Authorization: Bearer 1239b275-909e-4754-8f73-1e411fd6769e'
```

## MedicationRequest by patient and intent and encounter search parameters:

Get MedicationRequests  using the combination of the patient and intent and encounter search parameters

**METHOD** *GET*

```
GET [base url]/MedicationRequest?patient=Patient/[id]&intent=order,plan&encounter=[reference]
```

**PARAMS**
\[base url] - [FHIR base url](/articles/fhir/service-base-urls)
\[id] - patient id
\[reference] - reference to Encounter

**HEADERS**

The Authorization token SHALL be obtained during the Authentication and Authorization process. Go to [Authentication and Authorization](/articles/fhir/authentication-authorization) for further details.

| Header        | Type       | Required/Optional | Value            |
| ------------- | ---------- | ----------------- | ---------------- |
| Authorization | **string** | required          | `Bearer <token>` |

**RESPONSES**

| Code | Description                        | Comment                                                                                                                                         |
| ---- | ---------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| 200  | OK                                 | The request was processed successfully                                                                                                          |
| 400  | Bad request                        | Invalid request parameters or FHIR operation outcome resource returned                                                                          |
| 401  | Unauthorized                       | This code indicates that the client request has not been completed because it lacks valid authentication credentials for the requested resource |
| 404  | No route matched with those values | The request was able to communicate with a given server, but the server could not find what was requested                                       |
| 500  | Internal Server Error              | The server has encountered a situation it doesn't know how to handle                                                                            |

**EXAMPLE:**

```
curl --location --request GET 'https://sandbox.fhir.elationemr.com/fhir/MedicationRequest?patient=Patient/fe1cd986-1ac7-4c26-b8b3-d632a48408fd&intent=order,plan&encounter=Encounter/example123' \
--header 'Authorization: Bearer 1239b275-909e-4754-8f73-1e411fd6769e'
```

## MedicationRequest by patient and intent and authoredon search parameters

Get MedicationRequests using the combination of the patient and intent and authoredon search parameters
**METHOD** *GET*

```
GET [base url]/MedicationRequest?patient=Patient/[id]&intent=order,plan&authoredon={gt|lt|ge|le}[date]
```

**PARAMS**
\[base url] - [FHIR base url](/articles/fhir/service-base-urls)
\{Type/} - Type for the Reference. *Example:* `Patient`
\[id] - patient id
\[date] -date when medication request was authored on

**HEADERS**

The Authorization token SHALL be obtained during the Authentication and Authorization process. Go to [Authentication and Authorization](/articles/fhir/authentication-authorization) for further details.

| Header        | Type       | Required/Optional | Value            |
| ------------- | ---------- | ----------------- | ---------------- |
| Authorization | **string** | required          | `Bearer <token>` |

**RESPONSES**

| Code | Description                        | Comment                                                                                                                                         |
| ---- | ---------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| 200  | OK                                 | The request was processed successfully                                                                                                          |
| 400  | Bad request                        | Invalid request parameters or FHIR operation outcome resource returned                                                                          |
| 401  | Unauthorized                       | This code indicates that the client request has not been completed because it lacks valid authentication credentials for the requested resource |
| 404  | No route matched with those values | The request was able to communicate with a given server, but the server could not find what was requested                                       |
| 500  | Internal Server Error              | The server has encountered a situation it doesn't know how to handle                                                                            |

**EXAMPLE:**

```
curl --location --request GET 'https://sandbox.fhir.elationemr.com/fhir/MedicationRequest?patient=Patient/fe1cd986-1ac7-4c26-b8b3-d632a48408fd&intent=order,plan&authoredon=ge2019-01-01T00:00:00Z' \
--header 'Authorization: Bearer 1239b275-909e-4754-8f73-1e411fd6769e'
```
