ЕСОЗ - публічна документація
ARCHIVE_Submit Diagnostic Report Package_EN (DRACS, DRFO)
Specification
Validation
Authorization
Verify the validity of access token
in case of error return 401 ('Access denied')
Check user scope diagnostic_report:write in order to perform this action
in case of error generate 403 response ('Invalid scopes')
If BLOCK_UNVERIFIED_PARTY_USERS is true, then check party's data match following condition: verification_status != NOT_VERIFIED or (verification_status = NOT_VERIFIED and updated_at <= current_date - UNVERIFIED_PARTY_PERIOD_DAYS_ALLOWED):
in case not match - return 403 ("Access denied. Party is not verified")
Request validation
DS validation
DS must be valid
The document must be signed by recorder
Select PRM.parties.tax_id from PRM where PRM.parties.id ==( Select PRM.employees.party_id where PRM.employees.id==$.diagnostic_report.recorded_by.identifier.value)
ds.drfo == select a
in case of error retuert 409 "Document must be signed by the recorder of the diagnostic_report"
Recorder must be a current user
$.diagnostic_report.recorded_by.identifier.value is one of current user's employee
in case of error return 409 "Document must be sent by the recorder of the diagnostic_report"
Validate Legal Entity Type
Validate legal entity from token: legal_entities.type should be in me_allowed_transactions_le_types and legal_entities.status =='active'
Diagnostic report validation
Validate diagnostic_report _id is unique for MongoDB.Diagnostic_reports
Validate that one of diagnostic reports categories corresponds to service category, that is references as code in DR
$.diagnostic_report.category[?]=PRM.services.category where PRM.services.id=$.diagnostic_report.code.identifier.value
in case of error return 422 "None of the diagnostic report categories matches with the service category"
Validate that service, referenced as a code in DR, is active
Note. For diagnostic_report.code pass only "service", and the "service_group" does not passPRM.services.is_active = true where PRM.services.id=$.diagnostic_report.code.identifier.value
in case of errror return 422 "Service is not active"
If service_requests.code.identifier.value is service, validate $diagnostic_report.code.identifier.value = service_requests.code.identifier.value
in case error return 409, "Service in diagnostic_report differ from service in service request"
if service_requests.code.identifier.value is service_group, validate $diagnostic_report.code.identifier.value in (SELECT service_id from service_inclusions where service_group_id='service_requests.code.identifier.value')
in case error return 409, "Service in diagnostic_report differ from services in service request's service_group"
Validate referrals
As a referral it can be referenced electronic (registered in the system) OR paper service request
Validate ($.diagnostic_report.based_on OR $.diagnostic_report.paper_referral) or none in request
Validate based on as Reference(Referencevalidation)
Validate paper referral as Object (paper_referral)
Validate that service_request, referenced as based_on, is
in status is
active
or program_processing_status=in_progress (any status is valid in case program_processing_status= in_progress)in case of error return 409 "Invalid service request status"
used_by_legal_entity==token.client_id OR null
in case of error return 409 "Service request is used by another legal_entity"
if program is defined than used_by_legal_entity==token.client_id or NULL
in case of error return 409 "Service request is used by another legal_entity"
if program is defined than program_processing_status == new, in_queue or in_progress
check that service_request contains based_on parameter
in case based_on present in service_request
verify care_plan:
It should be in active status
Care plan's period end (if exist) should be greater than current date or equal.
verify activity:
It has activity.detail.kind=service_request; activity.detail.product_reference=service_id.
It has scheduled, in_progress status
in case based_on not present in request skip previous validations.
Validate effective_period as a period (PeriodValidation)
Validate that issued is within acceptable limits
$.diagnostic_reports[*].issued<= current date_time
in case of error 422 "Issued date must be in past"
$.diagnostic_reports[*].issued>=current_date-diagnostic_report_max_days_passed
in case of error 422 "Issued must be greater than {{current_date-diagnostic_report_max_days_passed}}"
Validate recorded_by as Employee (Employeevalidation)
Validate performer.identifier as Employee (Employeevalidation)
Validate managing_organization is a current legal_entity
$.managing_organization.identifier.value==token.client_id
in case of error 409 "Managing organization does not correspond to user's legal entity."
Validate result_interpreter.identifier as Employee (Employeevalidation)
Validate result_interpreter.identifier:
if the category.coding.code is in (
diagnostic_curative
,imaging
,diagnostic_procedure
) check that result_interpreter.identifier is an employee with employee_type = DOCTOR or SPECIALISTin case of error 409 "Employee does not match results_interpreter field"
if the category.coding.code is laboratory_procedure check that result_interpreter.identifier is an employee with employee_type = DOCTOR, SPECIALIST, ASSISTANT, LABORANT
in case of error 409 "Employee does not match results_interpreter field"
Validate only One of the fields is filled:
$.diagnostic_report[*].results_interpreter.reference OR $.diagnostic_report[*].results_interpreter.text
$.diagnostic_report[*].performer.reference OR $.diagnostic_report[*].performer.text
Validate division
Validate division as Reference(Referencevalidation)
$division is an existing ID in PRM.divisions
in case return 422, "Division with such id is not found"
division.status=ACTIVE and is_active=true
in case error return 409, "Division is not active"
division.legal_entity_id = $client_id
in case error return 409, "Division is not in current legal_entity"
Patient must be active
check that patients.status == active
in case patients.status == inactive
check mpi.persons(or mpi.prepersons if patients.preperson == true).updated_at and validate that now() - updated_at<=SUBMIT_DIAGNOSTIC_REPORT_PACKAGE_ALLOWED_PERIOD configuration (in minutes)
in case of error return 409 (Person is not active more that the allowed time for data submitting)
If patient is person - validate verification status:
If diagnostic report has based_on with service request, then skip this validation.
Else check patient's verification_status is not equal to NOT_VERIFIED.
in case NOT_VERIFIED - return error 409, "Patient is not verified"
Observation validation
Validate observations ids as primary keys (Primarykeyvalidation)
Validate that diagnostic_report of ALL observation is a current DR
$.observations[*].diagnostic_report.identifier.value==$.diagnostic_report.id
in case of error return "Submitted diagnostic report is not allowed for the observation"
$.observations[*].effective_period validate as Period PeriodValidation
Validate that the date is within acceptable limits
$.observations[*].issued <= current_time
in case of error return "Issued date must be in past"
$.observations[*].issued>=current_date-observation_max_days_passed
in case of error "Issued must be greater than {{current_date-observation_max_days_passed}}"
Validate performer as Employeevalidation
Validate $.observations[*].value_period as a Period
Validate component
$.observations[*].components[*].value_period as a Period
Related care plan validation
If diagnostic report has reference on service request and service_request[].activity.detail.quantity was set - check possibility to create diagnostic report depending on service_request[].activity remaining quantity
calculate the quantity of artifacts that are contained in the $.activity.outcome_reference by service_request.based_on[].activity[].id
calculate the quantity of artifacts that are contained in the request and have a link to the service request
compare quantity from outcome_reference with the artifact quantity
check that difference is greater then or equal to zero
in case of error return 409 "The total amount of the prescribed service quantity exceeds quantity in care plan activity"
Validate $.observations.code
if observations.code.coding[*].code value is included in chart variables 'OBSERVATION_CODES_WITH_<VALUE_TYPE>_REQUIRED', <value_type> field is mandatory
in case of error return 422 “This field is required for code = <code>“
Postprocessing
Set managing_organization for submitted observations
ME.conditions{cond_id}.managing_organization=token.client_id
In case diagnostic report.based_on was filled set $.diagnostic_report.id to related to $.service_request $.activity[].outcome_reference
Update $ .activity.status to in_progress if previous activity status was scheduled
Update the $ .activity.remaining_quantity parameter by subtracting the quantity of artifacts that have a reference on service request that contains an $.based_on.[]activity
ЕСОЗ - публічна документація