Purpose
This method is designed to create reimbursement report which is based on Medication request and Medication dispense data for NHS admin.
WS logic
Authorize user
- Verify the validity of access token
- Return 401 in case validation fails
- Check user scopes in order to perform this action (scope = 'reimbursement_report:download')
- Return 403 in case invalid scope(s)
Validate request
Validate input dates
- There is 2 available dates for the filtering: date_from_dispense and date_to_dispense. Both of them must be filled.
In case of error show 422 error with message must be shown ( "Input dates must be filled")
- Validate input date_from and date_to
- if date_from_request is not null then: date_from_dispense<=date_to_dispense and date_to_dispense must be filled
in case of error - return 422 error:
{:error, [{
%{
description:
"Input dates are not valid"
,
params: [],
rule: :invalid
},
"$.date_from_dispense"
}]}
Input dates filter the field:
- date_from_dispense/date_to_dispense comparing to field medication_dispenses.dispensed_at
- if date_from_request is not null then: date_from_dispense<=date_to_dispense and date_to_dispense must be filled
If there is no data available for the requested period of time in response must be sent empty file, no error is shown.
Prepare response
Output format - text/csv
- Prepare response with fields described below and conditions described below:
- first row is for headers (REQUESTED_FIELD which is below)
- NHS admin will receive all Medication Dispenses and corresponding Medication Requests.
- in case there is no Medication Dispenses for Medication Requests, Medication Requests won't be shown in the report
- for Medication Dispense: status='PROCESSED'
REQUESTED_FIELD | REPORT_FIELD | SOURCE | COMMENT |
---|---|---|---|
Назва суб’єкту господарювання (аптека) | pharmacy_name | medication_dispense.legal_entity.name | |
Код ЄДРПОУ суб'єкту господарювання (аптека) | pharmacy_edrpou | medication_dispense.legal_entity.edrpou | |
Назва закладу охорони здоров’я | msp_name | medication_request.legal_entity.name | |
Код ЄДРПОУ закладу охорони здоров’я | msp_edrpou | medication_request.legal_entity.edrpou | |
Лікар, що виписав рецепт (ПІБ) | doctor_name | medication_request.employee.party.last_name&first_name&second_name | |
Лікар, що виписав рецепт (ID) | doctor_id | medication_request.employee.id | |
№ Номер рецепта | request_number | medication_request.request_number | |
Дата створення рецепта | created_at | medication_request.created_at | |
Дата відпуску рецепта | dispensed_at | medication_dispense.dispensed_at | |
Міжнародна непатентована назва лікарського засобу (словник реєстру) | innm_name | select i.name | |
Лікарська форма | innm_dosage_name | medication_request.medication.name | innm_dosage |
Торгова назва лікарського засобу | medication_name | medication_dispense.details.medication.name | |
Сила дії (дозування) | ----- | do not show | |
Форма випуску (словник реєстру) | form | medication_dispense.details.medication.form | |
Кількість одиниць лікарської форми відповідної дози в упаковці, од. | package_qty | medication_dispense.details.medication.package_qty | |
Кількість відпущених упаковок, упак /Кількість відпущених ліків, одиниць | medication_qty | medication_dispense_details.medication_qty | units, not packages |
Фактична роздрібна ціна реалізації упаковки, грн | sell_amount | medication_dispense_details.sell_amount | |
Розмір відшкодування вартості лікарського засобу за упаковку, грн | reimbursement_amount | medication_dispense_details.reimbursement_amount | |
Сума відшкодування, грн | discount_amount | medication_dispense_details.discount_amount | |
Сума доплати за упаковку ЛЗ, грн / Фактична роздрібна ціна за одиницю, грн | sell_price | medication_dispense_details.sell_price | instead we show all fields to be able to calculate this value |
Номер фіксального чеку | payment_id | medication_dispense.payment_id | |
Сума транзакції | payment_amount | medication_dispense.payment_amount |