Table of Contents |
---|
...
Specification
Purpose
This WS is designed to create Request fo Medication request
There are two types of medication request:
plan - The request represents an intention to ensure something occurs without providing an authorization for others to act. Medication request with type plan can't be dispensed and only provide the instruction to administer the medicine.
order - The request represents a request/demand and authorization for action. Medication request with type order can be dispensed
Authorize
Verify the validity of access token
Check user scope (scope = 'medication_request_request:write') in order to perform this action
In case error - generate 401 response
Validate request (JSON schema)
Validate request using JSON schema.
in case of error return 422 error with msg ("required property %{property} was not present")
Validate employee
Purpose validation: Validation of an employee for the possibility of creating a medication request.
...
Invoke employee_id from request
Validate employee
...
Validate that exists
in case invalid return 422 error with msg ("Employee not found")
...
Validate that $.employees.status == APPROVED
in case invalid return 409 error with msg ("Employee is not active")
...
Validate that $.employees.legal_entity_id == client_id from token
in case invalid return 422 error with msg ("Employee does not belong to legal entity from token")
Validate that $.employees.employee_type == <employee_type>
in case medical_program_id present in request validate medical_program_settings.skip_employee_validation == false (or absent)
validate <employee_type>
get $.medical_programs.medical_program_setting by medical_program_id from request
validate that employee_type present in employee_types_for_create_medication_request variable
...
in case invalid return 422 error with msg ("Employee type can't create medication request with medical program from request")
in case employee_type = DOCTOR
...
Table of Contents |
---|
...
Specification
Purpose
This WS is designed to create Request fo Medication request
There are two types of medication request:
plan - The request represents an intention to ensure something occurs without providing an authorization for others to act. Medication request with type plan can't be dispensed and only provide the instruction to administer the medicine.
order - The request represents a request/demand and authorization for action. Medication request with type order can be dispensed
Authorize
Verify the validity of access token
Check user scope (scope = 'medication_request_request:write') in order to perform this action
In case error - generate 401 response
Validate request (JSON schema)
Validate request using JSON schema.
in case of error return 422 error with msg ("required property %{property} was not present")
Validate employee
Purpose validation: Validation of an employee for the possibility of creating a medication request.
Invoke employee_id from request
Validate employee
Validate that exists
in case invalid return 422 error with msg ("Employee not found")
Validate that $.employees.status == APPROVED
in case invalid return 409 error with msg ("Employee is not active")
Validate that $.employees.legal_entity_id == client_id from token
in case invalid return 422 error with msg ("Employee does not belong to legal entity from token")
Validate that $.employees.employee_type == <employee_type>
in case medical_program_id present in request validate medical_program_settings.skip_employee_validation == false (or absent)
validate <employee_type>
get $.medical_programs.medical_program_setting by medical_program_id from request
validate that employee_type present in employee_types_for_create_medication_request variable
in case invalid return 422 error with msg ("Employee type can't create medication request with medical program from request")
in case employee_type = DOCTOR
get $.declarations by employee_id, person_id, status=ACTIVE or check MEDICATION_REQUEST_DECLARATION_VERIFY param (which allow to create medication request for any doctor from LE where person have declaration)
if not found - return 422 error (message: "Employee must have an active declaration with the patient to create medication request!")
2. in case employee_type = DOCTOR
a. if variable skip_medication_request_employee_declaration_verify = false or null/absent
i. then: get $.declarations by employee_id, person_id, status=ACTIVE
if not found - return 422 error "Only doctors with an active declaration with the patient can create medication request!"
ii. else skip declaration verification on employee level (if true)
b. if variable skip_medication_request_legal_entity_declaration_verify = false or null/absent
i. then: get $.declarations by employee's legal_entity_id, person_id, status=ACTIVE
or check MEDICATION_REQUEST_DECLARATION_VERIFY param (which allow to create medication request for any doctor from LE where person have declaration)if not found - return 422
error (message: "Employee must haveerror "Only legal entity with an active declaration with the patient
to create medication request!")can create medication request!"
ii. else skip declaration verification on legal entity level (if true)
c. else if both are true - skip declaration verification at all
in case employee_type = SPECIALIST
get $.employees.speciality.speciality(speciality_officio == true)
validate that speciality present in$.medical_programs.medical_program_setting.speciality_types_allowed variable
in case invalid return 422 error with msg ("Employee's specialty doesn't allow create medication request with medical program from request")
in case employee_type = <XXX>
in case invalid return 422 error with msg ("Employee type can't create medication request with medical program from request")
in case medical_program_settings.skip_employee_validation == true or there is no medical_program_id in the request, any user who has a scope can create medication request
...
Validate that created_at, started_at, ended_at in date format
in case invalid return 422 with msg ("expected \"%{actual}\" to be a valid ISO 8601 date")
Validate ended_at >= started_at
if invalid - return 422 error (message: "Ended date must be >= Started date!")
Validate started_at` >= created_at
if invalid - return 422 error (message: "Started date must be >= Created date!")
Validate started_at >= current_date()
if invalid - return 422 error (message: "Started date must be >= current date!")
Validate created_at >= current_date() - mrr_delay_input
if invalid - return 422 error (message: "Create date must be = current date!")
Validate started_at regarding frequency of receiving drugs
get $.medical_programs.medical_program_setting by medical_program_id from request
validate skip_mnn_in_treatment_period variable
in case skip_mnn_in_treatment_period == FALSE (or absent)
validate request according to logic: PreQualify Medication request#2.Checkabsencethesamemedicationsfortheprograms
in case skip_mnn_in_treatment_period == TRUE
skip validating frequency of receiving drugs
Validate created_at regarding frequency of receiving drugs
get $.medical_programs.medical_program_setting by medical_program_id from request
validate skip_mnn_in_treatment_period variable
in case skip_mnn_in_treatment_period == FALSE (or absent)
validate request according to logic: PreQualify Medication request#2.Checkabsencethesamemedicationsfortheprograms
in case skip_mnn_in_treatment_period == TRUE
skip validating frequency of receiving drugs
Validate period length (ended_at - started_at):
If medical program has been submitted:
validate request according to logic: PreQualify Medication request: 7. Validate period
else:
Check that medication request period less than or equal to MEDICATION_REQUEST_MAX_PERIOD_DAY parameter from charts
in case of error - return 409 “Period length exceeds default maximum value“
...
Validate medical_program_id is present in the request
in case of error return 422 ("required property medical_program_id was not present")
Validate medical_program_id - medical_program_id existsprogram_id exists
in case of error return 422 ("Medical program not found")
Validate context with encounter is present in the request
in case of error return 422 ("Context with encounter is required as medical program is present in the request")
encounter diagnosis is not empty in $.encounter.diagnosis
in case of error return
422 ("
Encounter without diagnosis can not be referenced")
Validate context with encounter is present in the requestmedical_programs.medical_program_setting parameters
check if care_plan_required == true then the request should contain a based_on with care plan and activity that contains the same medical program
in case of error return 422 with msg ("
Care plan and activity with the same medical program should be present in request")
encounter diagnosis is not empty in $.encounter.diagnosisIf there is CONDITIONS_ICD10_AM_ALLOWED parameter, then:
check if care_plan_required == true then the request should contain a based_on with care plan and activity that contains the same medical programCheck if primary diagnosis from the encounter in context has code from eHealth/ICD10_AM/condition_codes dictionary
Check diagnosis code in CONDITIONS_ICD10_AM_ALLOWED
in case of error - return 422
Validate medical_programs.medical_program_setting parameters
“Encounter in context has no primary diagnosis allowed for the medical program“
If there is CONDITIONS_ICPC2_ALLOWED parameter, then:
Check if primary diagnosis from the encounter in context has code from eHealth/ICPC2/condition_codes dictionary
Check diagnosis code in CONDITIONS_ICPC2_ALLOWED
in case of error
If there is CONDITIONS_ICD10_AM_ALLOWED parameter, then:
Check if primary diagnosis from the encounter in context has code from eHealth/ICD10_AM/condition_codes dictionary
Check diagnosis code in CONDITIONS_ICD10_AM_ALLOWED
in case of error - return 422 “Encounter in context has no primary diagnosis allowed for the medical program“
If there is CONDITIONS_ICPC2_ALLOWED parameter, then:
Check if primary diagnosis from the encounter in context has code from eHealth/ICPC2/condition_codes dictionary
Check diagnosis code in CONDITIONS_ICPC2_ALLOWED
in case of error - return 422 “Encounter in context has no primary diagnosis allowed for the medical program“- return 422 “Encounter in context has no primary diagnosis allowed for the medical program“
if skip_medication_request_employee_declaration_verify = false or null/absent
then: get $.declarations by employee_id, person_id, status=ACTIVE
if not found - return 422 error "Only doctors with an active declaration with the patient can create medication request!"
else skip declaration verification on employee level (if true)
if skip_medication_request_legal_entity_declaration_verify = false or null/absent
then: get $.declarations by employee's legal_entity_id, person_id, status=ACTIVE
if not found - return 422 error "Only legal entity with an active declaration with the patient can create medication request!"
else skip declaration verification on legal entity level (if true)
Validate multiplicity & medication request allowed for participants
...
Generate human readable number for receipt (See specs)
Code Block Structure number XXXX-1234-5678-9012-345-C , where: - XXXX - series: numbers + only some letters (A, E, H, K, M, P, T, X) - 1234-5678-9012-345 - randomly generated numbers - C - checksum: Should be calculated using the Damn algorithm or Verhoeff algorithm After new Request number was generated we should check that it is unique in the DB (entity: medication_request + medication_request_request
Generate verification_code for MPI.person_authentication_methods == OTP or OFFLINE
Code Block Structure code 1234, where: - 1234 - randomly generated numbers
...