Purpose
This WS is designed to sign Request for Medication request (patch). If successfully signed - automatically create Medication request.
Specification
Logic
Method receives signed message (pkcs7) including signed content, digital signature and signer public key in signed_content
property. All signature fields will be validated (including signer certificate authority).
This service will store signed copy of Medication request Request in Media Content Storage and create Medication request if signature is all checks is passed.
Signed content MUST consists of JSON object with Medication request Request data. Object that need to be signed is returned by Get medication request requests details response, JSON.Path: $.data
.
Important: Invoke Get Medication request Request by ID to obtain seed - Hash of previous block in Medication request Request chain or other random component that should be signed with Medication request Request.
Look at Dummy Sign Medication Request Requests for more details.
Preconditions
API paragraph not found
Global and configurable parameters
No
Input parameters
Input parameter | Values | Type | Description | Example |
---|---|---|---|---|
id | String | Required | 6a8a83a4 |
Filters
No
Request structure
See on Apiary
Example:
Authorize
Verify the validity of access token
Check user scope (scope = 'medication_request_request:sign') in order to perform this action
In case error - generate 401 response
Headers
Content-Type:application/json
Authorization:Bearer c2778f3064753ea70de870a53795f5c9
api-key:uXhEczJ56adsfh3Ri9SUkc4en
msp_drfo:2534157686
Validate request
Validate request using JSON schema
In case validation fails - generate 422 error
Request data validation
Validate request status
Purpose validation: Valid ability transition.
For info - status charts: Medication request Request Status Chart
Get Medication request Request status by $.id
Check status == NEW
if invalid - return 409 error (message: "Invalid status Medication request Request for sign transition!")'
Check signed content
Purpose validation: Check equality decoded signed content with previously created on IL.db.
Get data
SELECT data FROM medication_request_requests WHERE id = $.id
If they are not equal with decoded signed content - generate 422 error (message: "Signed content does not match the previously created content!")
Parameters that are used when processing the request
Configuration parameters
API paragraph not found
Dictionaries
API paragraph not found
Processing
Digital signature
Decode content that is encrypted in an electronic digital signature.
Use Digital signature WS. Method checks digital signature and returns result.
See service specification.
Save signed medication request to media storage
Get url for medication request upload. Use Request a Secret WS (need check actuality !!!)
ParameterSourceaction 'GET' bucket 'medication-request-requests' resource_id : MEDICATION_REQUEST_ID resource_name : MEDICATION_REQUEST_NAME Upload signed medication request request to media storage
Create medication request
Create new record in medication_requests with status ACTIVE
if there is existing record in the medication_requests table with the same id and medication_request_request_id, return ok to IL
Mapping (where <rd> = medication_request_request.data )
Destination | Source |
---|---|
id | |
request_number | <rd>.request_number |
verification_code | <rd>.verification_code |
created_at | <rd>.created_at |
started_at | <rd>.started_at |
ended_at | <rd>.ended_at |
dispense_valid_from | <rd>.dispense_valid_from |
dispense_valid_to | <rd>.dispense_valid_to |
person_id | <rd>.person_id |
employee_id | <rd>.employee_id |
division_id | <rd>.division_id |
medication_id | <rd>.medication_id |
medication_qty | <rd>.medication_qty |
medical_program_id | <rd>.medical_program_id |
status | ACTIVE |
is_active | true |
recall_at | NULL |
recalled_by | NULL |
recall_reason | NULL |
request_for_medication_request_id | $.id |
inserted_at | :timestamp |
inserted_by | user_id |
updated_at | :timestamp |
updated_by | user_id |
intent | <rd>.intent |
category | <rd>.category |
context | <rd>.context |
dosage_instructions | <rd>.dosage_instructions |
Generate printout form
Invoke ael.api in order to render MEDICATION_REQUEST_TEMPLATE
Template parameters
Parameter | Source |
---|---|
request_number | |
created_at | |
dispense_valid_to | |
program_name | |
person_short_name | |
person_age | |
medication_name | |
medication_qty | |
started_at | |
ended_at | |
dosage_instructions_text | |
employee_short_name | |
employee_phone_number | |
legal_entity_name | |
division_name | |
legal_entity_address | |
legal_entity_edrpou | |
legal_entity_license_number | |
legal_entity_license_what_licensed | |
legal_entity_license_issued_date | |
legal_entity_license_issued_by | |
legal_entity_license_active_from_date | |
legal_entity_license_expiry_date | |
legal_entity_license_order_no | |
person_authentication_method |
Medication request form example: medication_request_form.docx
Update Medication Request Request status
Update Medication Request Request:
UPDATE medication_request_requests SET status = 'SIGNED' WHERE id = {:id}
Send SMS for person
Get authentication_method of MPI
If authentication_method == OTP - send SMS:
Generate text SMS (call Manmethod- templates rendering service with template "TEMPLATE_SMS_FOR_SIGN_MEDICATION_REQUEST" (!!! TBD).
Sending SMS for MPI via service .... (!!! TBD)
Response structure
See on Apiary
Example:
Post-processing processes
No
HTTP status codes
HTTP status code | Message | What caused the error |
---|---|---|
200 | Response |
|
401 | Unauthorized Error |
|
409 | Error | |
422 | Error |
Backward compatibility
API paragraph not found