Introduction
Web service "Submit Encounter Package" allows to transmit all the data collected during the encounter into eHealth DB using one single endpoint. I.e. all the data such as conditions, observations, allergy intolerances should be aggregated in one single data package in order to be registered in eHealth.
Specification
Validation
Authorization
- Verify the validity of access token
- in case of error return 401 ('Access denied')
- Check user scope encounter:write in order to perform this action
- in case of error generate 403 response ('Invalid scopes')
Request validation
Note: No update operations are allowed. All IDs, submitted as PK, should be unique for eHealth.
- Validate patient status
- db.patients.status for this patient must "active"
- in case of error return 409 - "Patient is not active"
- db.patients.status for this patient must "active"
- Validate request according to JSON Schema (link)
- Return 422 with list of validation errors in case validation fails
- Validate Visit
- $.visit.id is unique
- in case of error return 422 - "Visit with such id already exists"
- $.visit.end is filled
- in case of error return - "End date of visit must be filled"
- Period Validation
- $.visit.id is unique
- Validate DS
- Validate that DS belongs to the performer of encounter
- validate that drfo from DS and party.drfo of performer matches
- Validate that performer of encounter is a current user
- validate that one of users employee is a performer of encouner
- validate that client_id from token == PRM.performer.legal_entity
- Validate that DS belongs to the performer of encounter
- Validate encoded signed content according to JSON Schema (link)
- Return 422 with list of validation errors in case validation fails
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'
Validate Encounter
Global validations
- Validate encounter id as a primary key (Submit Encounter Data Package#Primarykeyvalidation)
- Validate that the date is within acceptable limits
- $.encounter.date<= current_date
- $.encounter.date>=current_date-encounter_max_days_passed
- Validate "episode" is an active episode that belongs to the current patient
- $.encounter.episode.identifier.value is one of ME.patinet{patient_id}.episodes{*}.id
- in case of error return 422 "Episode with such ID is not found"
- $.encounter.episode.identifier.value is an ID of an Episode that meets the requirements:
- ME.patient{patinet_id}.episodes{episode_id}.status = 'active'
- in case of error return 422 "Episode is not active"
- ME.patient{patinet_id}.episodes{episode_id}.managing_organization==token.client_id
- in case of error return 422 "Managing_organization in the episode does not correspond to user`s legal_entity"
- ME.patient{patinet_id}.episodes{episode_id}.status = 'active'
- $.encounter.episode.identifier.value is one of ME.patinet{patient_id}.episodes{*}.id
- Validate "visit" is a visit that belongs to the current patient
- Validate referrals
- As a referral it can be referenced electronic (registered in the system) OR paper service request
- Validate ($.encounter.incoming_referrals OR $.encounter.paper_referral) or none in request
- Validate incoming referrals as References (Submit Encounter Data Package#Referencevalidation)
- Validate paper referral as Object (paper_referral)
- Validate incoming referrals that corresponds to $.encounter.incoming_referrals[*].identifier.value have:
- ..used_by_legal_entity.identifier.value==token.client_id OR null
- in case of error return 409 "Service request is used by another legal_entity"
- ..status==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"
- ..if program is defined program_processing_status=new, in_queue or in_progress
- ..used_by_legal_entity.identifier.value==token.client_id OR null
- Validate performer
- $.encounter.performer.identifier.value is an ID of existing employee in PRM.Employees
- in case of error return "There is no Employee with such id"
- $.encounter.performer.identifier.value == PRM.Employees.id where (PRM.Employees.status==`active`)
- in case of error return "Employee is not active"
- $.encounter.performer.identifier.value is an ID of existing employee in PRM.Employees