MediRecords FHIR Implementation Guide
1.4.2 - release


MedicationRequest

The MediRecords FHIR API supports the following MedicationRequest profiles:

MRMedicationRequest Core MedicationRequest
MRMedicationRequestAdmission MedicationRequest Admission
MRMedicationRequestAdmissionIV MedicationRequest Admission Intravenous
MRMedicationRequestDraft Draft MedicationRequest

The MediRecords FHIR API supports the following MedicationRequest operations.

GET {API_URL}/v1/MedicationRequest

This API interface enables the client to search MedicationRequest instances from MediRecords repository. This is in compliance with the following MedicationRequest profiles:

MRMedicationRequest Core MedicationRequest
MRMedicationRequestAdmission MedicationRequest Admission
MRMedicationRequestAdmissionIV MedicationRequest Admission Intravenous
Query Parameters    
_count number Instruct the server regarding how many resources should be returned in a single page
authoredon date The date the medication request was recorded in the format YYYY-MM-DD.
category token The prescription category. If not provided, will default to community which will return MRMedicationRequest resources only.
code token A valid medication code.
patient reference Patient(id) for whom the medication request record is created.
priority token Represents the priority of the prescription. We support only routine and urgent values.
requester reference Practitioner(id) or organization(id) who has ordered for the prescription.
status token Represents the prescription status. We support only draft, active, completed, cancelled, stopped and entered-in-error values.

Response

The server returns matching MedicationRequest instances in a Bundle that the logged-in user has access to. If no search criteria is provided, then all MedicationRequest instances that the logged-in user has access to will be returned.

Only script records that are not draft or deleted will be provided in the search results.

In an error situation, server SHALL return OperationOutcome detailing the error with the appropriate HTTP Error code as follows.

Status Text
200 OK
400 Bad Request
401 Unauthorized
403 Forbidden
404 Not Found
500 Internal Server Error

Read

GET {API_URL}/v1/MedicationRequest/{id}

This API interface enables the client to read an MedicationRequest resource from MediRecords repository which is compliant with the following profiles:

MRMedicationRequest Core MedicationRequest
MRMedicationRequestAdmission MedicationRequest Admission
MRMedicationRequestAdmissionIV MedicationRequest Admission Intravenous
Request Parameters  
id The logical id of the MedicationRequest resource

Response

In an error situation, server SHALL return OperationOutcome detailing the error with the appropriate HTTP Error code as follows.

Status Text
200 OK
400 Bad Request
401 Unauthorized
403 Forbidden
404 Not Found
500 Internal Server Error

Create (Draft)

POST {API_URL}/v1/MedicationRequest

This API interface enables the client to create a draft MedicationRequest resource in MediRecords repository which is compliant with the MediRecords Draft MedicationRequest profile.

Note: The Create MedicationRequest Draft interaction does not validate whether the referenced patient has a recorded address. A patient address is required for a valid prescription. Ensuring that the patient has a valid address prior to prescription submission is the responsibility of the integration partner.

Request Parameters  
_format This parameter allows a client to override the accept header value when it is unable to set it correctly due to internal limitations (e.g. XSLT usage). The values xml, text/xml, application/xml, and application/fhir+xml SHALL be interpreted to mean the XML format, the codes json, application/json and application/fhir+json SHALL be interpreted to mean the JSON format. The _format parameter does not override the Content-Type header for the type of the body of a POST request
Request Headers  
X-Request-Id A unique id for the request/response assigned by either client or server. The expected format is UUID. If the client doesn’t supply this id, it is expected that server SHALL assign one.

Request Body

Request body that creates a new draft MedicationRequest resource

Response

Successful Response

On success, the server returns HTTP 201 Created and includes a Location header pointing to the newly created draft MedicationRequest. No response body is returned.

Important Notes:

  • The draft MedicationRequest id is different from the prescribed (active) MedicationRequest id.
  • Webhook notifications are generated only for the prescribed (active) MedicationRequest, not for the draft.
  • As a result, the draft MedicationRequest id is not included in webhook payloads
Example Success Response

The Location header will have the form:

HTTP/1.1 201 Created
Location: {base_url_path}/MedicationRequest/{id}/_history/1

The draft MedicationRequest id is provided within the {id} portion of the Location header. In the example response below the id is ‘29955051-7b28-4e4f-853b-0f8be62f1372’.

HTTP/1.1 201 Created
Location: /v1/fhir/*/MedicationRequest/29955051-7b28-4e4f-853b-0f8be62f1372/_history/1

When the draft prescription is printed and becomes an active MedicationRequest, the webhook generated for the active resource will contain a different id.
As such, the draft MedicationRequest id cannot be used to correlate the initial request with the subsequent webhook event.

Error Response

In an error situation, server SHALL return OperationOutcome detailing the error with the appropriate HTTP Error code as follows.

Status Text  
400 Bad Request Resource could not be parsed or failed basic FHIR validation rules
401 Unauthorized  
403 Forbidden  
422 Unprocessable Entity The proposed resource violated applicable FHIR profiles or server business rules.
500 Internal Server Error  

Webhook

The following table provides the FHIR Webhook event types generated for the MedicationRequest resource.

Core MedicationRequest Webhooks

Hub Event Application Trigger Event  
medication-request.created Occurs whenever a new prescription record is created Example
medication-request.updated Occurs whenever a prescription record is updated  
Bundle 
  MedicationRequest (1)
  Encounter (0..1)
  Patient (1)
  PractitionerRole (0..1)
  Practitioner (0..3)
  Organization (0..2)
   
medication-request.deleted Occurs whenever a prescription record is deleted
Bundle 
  request (1) 
    url: DELETE MedicationRequest/{id}

MedicationRequest Admission Webhooks

Hub Event Application Trigger Event  
medication-request-admission.created Occurs whenever a new prescription record is created in Admissions Example
  Occurs whenever a new infusion chart record is created in Admissions Example
medication-request-admission.updated Occurs whenever a prescription record is ceased or updated in Admissions  
  Occurs whenever an infusion chart record is ceased in Admissions  
Bundle 
  MedicationRequest (1)
  Encounter (1)
  Patient (1)
  PractitionerRole (0..1)
  Practitioner (0..3)
  Organization (0..4)
  Location (0..1)