Table of Contents |
---|
...
Validate encounter id as a primary key (Primary Key Validation)
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"
Validate "visit" is a visit that belongs to the current patient
$.encounter.visit.identifier.value=$.visit.id OR ID of already existing Visit in ME.patient{patient_id}.visit.id
in case of error return 422 "Visit with such ID is not found"
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
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 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 == PRM.Employees.id where (PRM.Employees.legal_entity== client_id)
"User can not create encounter for this legal_entity"
validate employee type according to encounter.class - use config file (employee_encounter_classes)
in case error return 422, "Employee.type $type is forbidden for your encounter class"
according to employee.type as stated in employee_encounter_types
in case error return 422, msg "Employee.type $type is forbidden for your encounter type"
division
$.encounter.division.identifier.value must meet the following requirements
PRM.division.status = "ACTIVE"
in case of error return 409 "Division is not active "
PRM.division.legal_entity= token.client_id
in case of error return 409 "User is not allowed to create encouners for this division"
Validate supporting_info as References (Reference validation)
Validate encounter.class
according to legal_entity.type - use config file (legal_entity_episode_types)
in case error return 409, msg "Encounter.class $class is forbidden for your legal entity type"
according to episode.type - use config file (episode_type_encounter_classes)
in case error return 409, msg "Encounter.class $class is forbidden for your episode type"
according to employee.type as stated in encounter class validations
in case error return 409, msg "Encounter.class $class is forbidden for your employee type"
Validate encounter.type according to encounter.class - use config file encounter_class_encounter_types
in case error return 409, msg "Encounter.type $type is forbidden for your encounter class"
Validate actions
Validate actions presence according to encounter class validations
in case error return '422', msg 'TBC'
Defined in the system that corresponds to encounter class validations
in case error return '422', msg 'TBC'
Validate action_references
Note. For encounter.action_references pass only "service", and the "service_group" does not passValidate action_references presence according to encounter class validations
in case error return '422', msg 'At least one of action references, diagnostic reports or procedures should exist in encounter package'
Validate code as a Reference(Reference validation)
Validate action_references is in prm.services, has status ACTIVE and is_active = true
in case error return '422', msg 'Service with such ID is not found'
in case error return '422', msg 'Service should be active'
Validate diagnoses
Validate conditions as References (Submit Encounter Data Package#Referencevalidation)
Validate that encounter type= 'intervention'. If not, than:
Validate encounter has exactly one diagnosis where $.encounter.diagnoses[?(@.role.coding[0].code=="primary")]
in case of error return 422 "Encounter must have exactly one primary diagnosis"
Validate condition.id is in DB or in current Encounter package
Validate that each condition is active (verification_status != entered_in_error)
in case of error return 409 "Conditions in diagnoses must be active"
Validate that primary diagnosis defined in the system that corresponds to encounter class validations
in case of error "Primary diagnosis should be defined in {$.encounter.diagnoses[*].role.coding[*].system } system"
Validate that rank
Rank value should be integer and >= 1
in case of error return 422 "expected the value to be >= 1"
Rank value should be integer and <= 10
in case of error return 422 "expected the value to be <= 10"
Validate reasons
Validate reasons presence according to encounter class validations
in case error return '422', msg 'Validation failed. You can find validators description at our API Manifest: http://docs.apimanifest.apiary.io/#introduction/interacting-with-api/errors .', description 'can't be blank.
Validate hospitalization
Validate hospitalization presence according to encounter class validations
in case error return 422, msg "Hospitalization block is forbidden for encounter.class = $encounter.class"
Validate all fields according to schemata
destination
discharge_disposition
pre_admission_identifier
admit_source
re_admission
discharge_department
Validate destination is a valid legal_entity in prm with status is ACTIVE and is_active = true
in case error return 422, "Legal entity is not active"
Validate patient_id for encounter.type == "patient_identity"
$patient_id should exist in mpi.prepersons.id, have status =='ACTIVE' and is_active = true
in case error return 'TBC', msg 'TBC'
If incoming referrals exists and incoming_referral (service request) category not in ('transfer_of_care', 'hospitalization') and encounter.class in ("AMB", "INPATIENT") and encounter.type <> "patient_identity" validate service for encounter.actions OR diagnostic_report.code OR procedure.code
If service_requests.code.identifier.value is service, validate $resourse.code.identifier.value = service_requests.code.identifier.value
in case error return 409, "Service in $resourse differ from service in service request"
if service_requests.code.identifier.value is service_group, validate $resourse.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 $resourse differ from services in service request's service_group"
Validate $resourse.service.is_active = true
in case error return 409, "Service should be active"
Validate patient verification status:
If encounter has incoming referral with valid and active service request, then skip this validation.
Else check patient's verification_status is not equal to NOT_VERIFIED.
in case of error return 409, "Patient is not verified"
Validate priority
Validate priority presence according to eHealth/encounter_priority
in case error return 409, ""
If encounter.class.code = "INPATIENT", priority is required
in case error return 422, "Priority for encounter is required"
...
Info |
---|
ImportantThis validations is applicable for all encounter types except covid. Specific validations for covid encounter type described in separate page |
Validation | PHC | AMB | INPATIENT |
---|---|---|---|
employees.type |
|
|
|
encounter.type | as stated in config file encounter_class_encounter_types | as stated in config file encounter_class_encounter_types | as stated in config file encounter_class_encounter_types |
actions |
| is absent in request | is absent in request |
diagnoses | diagnoses.primary is a condition with code in dictionary "eHealth/ICPC2/condition_codes" | diagnoses.primary is a condition with code in dictionary "eHealth/ICD10_AM/condition_codes" | diagnoses.primary is a condition with code in dictionary "eHealth/ICD10_AM/condition_codes" |
reasons |
|
|
|
hospitalisation | is absent in request | is absent in request | if encounter.type == "discharge" - this block is mandatory
For other encounter types
|
action_references | is absent in request | if encounter.type == "patient_identity"
For other encounter types
| if encounter.type == "patient_identity"
For other encounter types
|
division | Division must be filled |
...
Validate conditions ids as primary keys (Submit Encounter Data Package#Primarykeyvalidation)
Validate that context of conditions is a current encounter
$.conditions[*].context.identifier.value == $.encounter.id
in case of error return "Submitted context is not allowed for the condition"
Validate code depending on encounter class
if $.encounter.class = PHC - allowed both eHealth/ICPC2/condition_codes and eHealth/ICD10_AM/condition_codes
if $.encounter.class in (AMB, INPATIENT) - allowed only eHealth/ICD10_AM/condition_codes
Validate code.coding depending on the qty of codes
Maximum one code from one dictionary (eHealth/ICPC2/condition_codes and eHealth/ICD10_AM/condition_codes) is allowed
in case of error return 422 with msg "Only one code from one dictionary is allowed"
Validate that the date is within acceptable limits
$.conditions[*].onset_date <= current_date
in case of error "Onset date must be in past"
$.condition[*].onset_date>=current_date-condition_max_days_passed
in case of error "Onset date must be greater than {{current_date-condition_max_days_passed}}"
$.conditions[*].onset_date <= current_date
in case of error "Onset date must be in past"
$.conditions[*].asserted_date <= current_date
in case of error "Asserted date must be in past"
$.conditions[*].evidences[*].detail[*].identifier.value is an ID of existing observation in MedicalEvents.Observations or one of $.observations[*]
in case of error 409 "Observation with such id is not found"
$.conditions[*].evidences[*].detail[*].identifier.value meet follownig conditions
MedicalEvents.Observation.Patient == patient_id (from url)
Error 409 "Evidence can not reference another patient"
MedicalEvents.Observation.Status != "entered_in_error"
Error 409 "Observation in "entered_in_error" status can not be used as an evidence"
validate asserter. And additionally check:
check if asserter's employee_type == "ASSISTANT" then define allowed conditions from ASSISTANT_EMPLOYEE_CONDITIONS_ALLOWED
in case condition code is not allowed for the employee_type - return 409 error ('Asserter has no required employee type to set condition code <code>')
if primary_source = true and code has eHealth/ICD10_AM/condition_codes dictionary value:
define allowed specialities for ICD10_AM condition code using a set of chart variables ICD10_AM_<SPECIALITY_TYPE>_SPECIALITY_CONDITIONS_ALLOWED
check if asserter's speciality in allowed specialities defined on previous step
in case speciality not allowed for the condition code - return 409 error ('Asserter has no required speciality to set condition code <ICD10_AM code>')
validate asserterValidate conditions for encounter.type == "intervention"
If $.conditions is present in EDP, than validate:
$.encounter.diagnoses condition.id is in current Encounter package
Validate Observations
Validate observations ids as primary keys (Submit Encounter Data Package#Primarykeyvalidation)
Validate that context of observation is a current encounter
$.observations[*].context.identifier.value==$.encounter.id
in case of error return "Submitted context is not allowed for the observation"
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(asserter)
Validate$.observations[*].components[*].value_period as a Period
Validate $.observations[*].value_quantity
$.observations[*].value must be with number type
in case of error return "type mismatch. Expected number but got {entered type}"
$.observations[*].comparator can take the following values : [">", ">=", "=", "<=", "<"]
in case of error return "value is not allowed in enum"
$.observations[*].unit can take values from dictionary eHealth/ucum/units
in case of error return "value is not allowed in enum"
Validate $.observations[*].value_codeable_concept
$.observations[*].code validate that the code belongs to the dictionary system
in case of error return "Value is not allowed in enum"
Validate $.observations[*].value_boolean
$.observations[*].value_boolean must be boolean type
in case of error return "type mismatch. Expected boolean but got {entered type}"
Validate $.observations[*].value_string
$.observations[*].value_string must be string type
in case of error return "type mismatch. Expected string but got {entered type}"
Validate $.observations[*].value_sampled_data
$.observations[*].data must be string type
in case of error return "type mismatch. Expected string but got {entered type}"
$.observations[*].origin must be with number type
in case of error return "type mismatch. Expected number but got {entered type}"
$.observations[*].period must be with number type
in case of error return "type mismatch. Expected number but got {entered type}"
$.observations[*].factor must be with number type
in case of error return "type mismatch. Expected number but got {entered type}"
$.observations[*].lower_limit must be with number type
in case of error return "type mismatch. Expected number but got {entered type}"
$.observations[*].upper_limit must be with number type
in case of error return "type mismatch. Expected number but got {entered type}"
$.observations[*].dimensions must be with number type
in case of error return "type mismatch. Expected number but got {entered type}"
Validate $.observations[*].value_range
$.observations[*].low must be with object type
in case of error return "type mismatch. Expected object but got {entered type}"
$.observations[*].high must be with object type
in case of error return "type mismatch. Expected object but got {entered type}"
Validate $.observations[*].value_ratio
$.observations[*].numerator must be with object type
in case of error return "type mismatch. Expected object but got {entered type}"
$.observations[*].denominator must be with object type
in case of error return "type mismatch. Expected object but got {entered type}"
Validate $.observations[*].value_time
$.observations[*].value_time must be with string type
in case of error return "type mismatch. Expected string but got {entered type}"
Validate $.observations[*].value_date_time
$.observations[*].value_date_time must be with string type
in case of error return "type mismatch. Expected string but got {entered type}"
Validate diagnostic report is one of reports in the current package
$.observations[*].diagnostic_report.identifier.value == one of $.diagnostic_report[*].identifier.value
in case of error "Invalid reference"
Validate $.observations[*].reaction_on
check that the appropriate immunizations.status != "entered_in_error"
in case of error return 409 "Immunization with status ‘entered_in_error’ can not be use"
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>“
...
Validate by json schema
Validate procedure id as primary key (Submit Encounter Data Package#Primarykeyvalidation)
Validate that service_request, referenced as based_on, is
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 code
Validate code as Reference(Referencevalidation)
Validate procedure.service.is_active = true
in case error return 409, "Service is not active"
Validate encounter
$.procedure[*].encounter.identifier.value == $.encounter.id
in case error return 409, "Submitted encounter is not allowed for procedure"
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
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"
Validate asserter
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 or division.legal_entity_id=$managing_organization.identifier.value
in case error return 409, "Division is not in current legal_entity"
Validate managing_organization is a current active legal_entity with proper type
as Reference(Referencevalidation/wiki/spaces/EBT/pages/1044873249)
$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 complication_details
validate complication_details as a Reference (Referencevalidation)
validate complication_details.identifier.value refer to condition in the same encounter package
in case error return 422, "complication_details does not correspond to condition in this encounter package"
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"
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"
...