Overview
Procedure can be registered in eHealth as a part of encounter pckg or just by itself with reference on Service Request. This WS is designed to create a new procedure separately from encounter pckg.
...
Validate id
ID is unique for MongoDB.procedures
ID is UUID
Validate referrals
As a referral it can be referenced electronic (registered in the system) OR paper service request
Validate $.procedure.based_on OR $.procedure.paper_referral is in request
Validate based_on as Reference(Referencevalidation)
Validate paper referral as Object (paper_referral)
Validate that service_request is
in status is active or in progress
in case of error return 409 "Invalid service request status"
used_by_legal_entity==token.client_id
in case of error return 409 "Service request is used by another legal_entity"
service_request.expiration date should be <= now
in case error return 422, "Service request expiration date must be a datetime greater than or equal"
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 status
On create procedure status could be only `completed`. There is no necessity to publish another procedure to e-Health. `entered_in_error` could be set on update procedure.
error 422 by json schema
Validate code
Note. For procedure.code pass only "service", and the "service_group" does not passValidate code as Reference(Referencevalidation)
If service_requests.code.identifier.value is service, validate $procedure.code.identifier.value = service_requests.code.identifier.value
in case error return 409, "Service in procedure differ from service in service request"
if service_requests.code.identifier.value is service_group, validate $procedure.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 procedure differ from services in service request's service_group"
Validate procedure.service.is_active = true
in case error return 409, "Service should be active"
Validate performed_date_time
performed_date_time is real
in case error return 422, "Performed_date_time in invalid"
performed_date_time <= now
in case error return 422 "Procedure cannot be registered in future"
Validate recorded_by
Validate recorded_by as Reference(Referencevalidation)
$..recorded_by.identifier.value is an ID of existing employee in PRM.employee
in case of error return 422, "Employee with such id is not found"
Validate recorded_by is employee with status='APPROVED' and is_active= true and end_date is null or more than today and PRM.employees.employee_type in ('DOCTOR','SPECIALIST','ASSISTANT')
in case error return 409, "This action is prohibited for current employee"
Validate employees.legal_entity_id=$managing_organization.identifier.value
in case error return 409, "Employee should be from current legal entity"
Performer(asserter) validation
case $..primary_source==true
$..performer(or $..asserter) must be filled
in case of error "Performer (asserter) must be filled"
$..report_origin must be absent
in case of error "Report_origin can not be submitted in case primary_source is true"
validate performer(asserter) is a valid value from corresponding dictionary
$..performer.identifier.type.coding[*].system == "eHealth/resources"
in case of error "Submitted system is not allowed for this field"
$..performer.identifier.type.coding[*].code=="employee"
in case of error "Submitted code is not allowed for this field"
validate performer(asserter) is an active medical staff from current legal_entity
$..performer.identifier.value is an ID of existing employee in PRM.employee
in case of error "Employee with such id is not found"
$..performer.identifier.value == PRM.employees.id where (PRM.employees.status == "APPROVED" and PRM.employees.employee_type in ('DOCTOR','SPECIALIST','ASSISTANT'))
case primary_source=false
error 422. (Procedure with primary_source=false could be send only with encounter package)
Validate division
Validate division as Reference(Referencevalidation)
$division is an 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"
Validate patient status
Medical_data status for this patient must be in "active" status
in case of error return 409 - "Patient is not active"
Validate managing_organization is a current active legal_entity with proper type
as Reference(Referencevalidation)
$managing_organization is an ID in PRM.legal_entities
in case return 422, "Legal entity with such id is not found"
validate managing_organization status is 'ACTIVE' and is_active=true
in case error return 422 ('Legal entity is not active')
validate legal_entity type is in ('PRIMARY_CARE','MSP','MSP_PHARMACY','MSP_PHARMACY') (use `ME_ALLOWED_TRANSACTIONS_LE_TYPES` from charts)
in case error return 422, "Legal entity with type $legal_entity.type cannot perform procedures"
validate $managing_organization.identifier.value = $client_id
in case of error 409 "Managing organization does not correspond to user's legal entity."
Validate reason_references
Validate reason_reference as a Reference (Referencevalidation)
Validate reason_refernce.identifier.value is condition not in status ENTERED_IN_ERROR
in case error return 422, "Condition is canceled"
Validate outcome
validate outcome as a Reference (Referencevalidation)
validate outcome.coding.object.system is in dictionary eHealth/procedure_outcomes
in case error return 422, "outcome not in dictionary eHealth/procedure_outcomes"
Validate category
according to the dictionary 'eHealth/procedure_categories' - by schemata
Validate that procedure category corresponds to service category, that is references as code in procedure
$.procedure.category=PRM.services.category where PRM.services.id=$.procedure.code.identifier.value
in case of error return 422 "Procedure category does not match with the service category"
Related care plan validation in case service request has reference on care plan and procedure has reference on service request check possibility to create procedure depending on service_request[].activity remaining quantity
calculate the quantity of artifacts that are contained in the request and have a link to the service request. Compare remaining_quantity from activity with the quantity of artifacts. 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 patient verification status:
If procedure has based_on with valid and active service request, then skip this validation.
Else check patient verification_status is not equal to NOT_VERIFIED.
in case of error return 409, "Patient is not verified"
Postprocessing
Save signed_content to Media Storage
Save data to corresponding collection in DB