ΠΠ‘ΠΠ - ΠΏΡΠ±Π»ΡΡΠ½Π° Π΄ΠΎΠΊΡΠΌΠ΅Π½ΡΠ°ΡΡΡ
RC_[UPD]_Submit Encounter Package
- 1 Purpose
- 2 Specification
- 3 Logic
- 4 Global and configurable parameters
- 5 Dictionaries
- 6 Request structure
- 7 Authorize
- 8 Headers
- 9 Request data validation
- 9.1 Validate Legal Entity Type
- 9.2 Validate Encounter
- 9.2.1 Global validations
- 9.2.2 Important
- 9.2.3 Encounter class validations
- 9.2.4 Validate Conditions
- 9.3 Validate Observations
- 9.3.1 Basic validation and REHAB
- 9.3.2 Validate observations for encounter.type == "patient_identity"Β
- 9.3.3 Validate observations using configuration set
- 9.3.3.1 Category
- 9.3.3.2 Components
- 9.3.3.3 Value
- 9.4 Validate Immunizations
- 9.5 Validate Allergy Intolerances
- 9.6 Validate Risk Assessments
- 9.7 Validate Devices
- 9.8 Validate Medication Statement
- 9.9 Validate Medication Administration
- 9.10 Validate Diagnostic Report
- 9.11 Validate Procedures
- 9.12 Validate Clinical impression
- 9.13 Validate Specimen
- 9.14 Validate Device Dispense
- 10 Primary key validation
- 11 Reference validation
- 12 Performer(asserter) validation
- 13 Period Validation
- 14 Employee validation
- 15 Related service request validation
- 16 Related care plan validation
- 17 Processing
- 18 Response structure
- 19 Post-processing processes
- 20 HTTP status codes
Purpose
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
Link | |
Resource | /api/patients/{{id}}/encounter_package |
Scope | encounter:write |
Components | Episode of Care |
Microservices | API paragraph not found |
Protocol type | REST |
Request type | POST |
Sync/Async | Async |
Public/Private/Internal | Public |
Β
Logic
Using this web service you can submit:
Object | Required | Part of Signed content |
---|---|---|
Visit | 0-1 | false |
Encounter | 1-1 | true |
Condition | 0-* | true |
Observation | 0-* | true |
Allergy intolerance | 0-* | true |
Immunization | 0-* | true |
Risk assessment | 0-* | true |
Device | 0-* | true |
Medication statement | 0-* | true |
Medication administration | 0-* | true |
Diagnostic report | 0-* | true |
Procedure | 0-* | true |
Clinical impression | 0-* | true |
You can send the same request (with the same body) multiple times, but a new job will not be created before previous is not performed.
Β
Global and configurable parameters
Medical Events Dictionaries and configurations | employee_encounter_classes
Medical Events Dictionaries and configurations | employee_encounter_types
Medical Events Dictionaries and configurations | legal_entity_episode_types
Medical Events Dictionaries and configurations | episode_type_encounter_classes
Medical Events Dictionaries and configurations | eHealth/encounter_classes
Medical Events Dictionaries and configurations | encounter_class_encounter_types
Medical Events Dictionaries and configurations | PSYCHIATRY_ICPC2_DIAGNOSES_EVIDENCE_CHECK
Medical Events Dictionaries and configurations | PSYCHIATRY_ICD10_AM_CONDITION_EVIDENCE_ALLOWED
Medical Events Dictionaries and configurations | <system>_ASSISTANT_EMPLOYEE_CONDITIONS_ALLOWED
Β
Dictionaries
Β
Request structure
See on Apiary
Example:
Β
Authorize
Verify the validity of access token
in case of error - return 401Β ('Invalid access token')
Verify that token is not expired
in case of error - return 401 ('Invalid access token')
Check user scopeΒ encounter: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")
Β
Headers
Content-Type:application/json
Authorization:Bearer {{access_token}}
API-key:{{secret}}
Β
Request data 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"
Validate request according to JSON Schema
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.period.start <= current_dateTime
in case of error return 422- "Start date must be in past"
$.visit.period.end <= current_dateTime
in case of error return 422- "End date must be in past"
$.visit.period.end > visit.period.start
in case of error return 422 - "End date must be greater than the start date"
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 encoded signed content according to JSON Schema
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
Validate that the date is within acceptable limits
$.encounter.date<= current_date
$.encounter.date>=current_date-encounter_max_days_passed
$.encounter.date>=episode.period.start where episode.id=$encounter.episode.identifier.value
in case of error return 422 "Encounterβs date must be equal to or greater than start date ofΒ episode"
Validate that the period is within acceptable limits
$.encounter.period.start<= current_date
in case of error return 422 "Date must be in past"
$.encounter.period.start>=current_date-encounter_max_days_passed
in case of error return 422 "Date must be greater than {{current_date-encounter_max_days_passed}}"
$.encounter.period.start>=episode.period.start where episode.id=$encounter.episode.identifier.value
in case of error return 422 "Encounterβs date must be equal to or greater than start date ofΒ episode"
$.encounter.period.end>=Β $.encounter.period.start
in case of error return 422 "End date must be greater than start date"
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
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.
Check if service request quantity is not exhausted as described at Submit Encounter Package | Related service request validation
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
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
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 that action_referencesΒ is service with service.category==βcounsellingβ in case encounter.class=βAMBβ
in case error return β422', msgΒ 'Invalid service category for AMB encounter class'
Β ValidateΒ diagnosesΒ
Validate conditions asΒ References
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 http://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: Nebo #15 API Manifest Β· Apiary .', 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
If encounter.type.code = "discharge" than encounter.hospitalization.admit_source is required, encounter.hospitalization.discharge_disposition is required, encounter.hospitalization.discharge_department is required
in case error return 422, msg "<parameter> is required for encounter.type.code = "discharge"
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"
Validations for encounter classes
Β
Important
This validations is applicable for all encounter types except covid. Specific validations for covid encounter type described in separate page
Encounter class validations
Validation | PHC | AMB | INPATIENT |
---|---|---|---|
employees.type | as stated in config file employee_encounter_types | as stated in config file employee_encounter_types | as stated in config file employee_encounter_types |
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
Validate conditions ids asΒ primary keys
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[*]
ORΒ $.conditions[*].evidences[*].detail[*].identifier.value is an ID of existing condition in MedicalEvents.Conditionsin case of error 422Β "<medical_event> 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Β $.conditions[*].evidences[*].detail[*].identifier.value
for eachΒ $.conditions[*].evidences
check:MedicalEvents.<MedicalEvent>.Patient == patient_id (from url)
Error 422 "<medical_event> with such id is not found"
MedicalEvents.<MedicalEvent>.StatusΒ != "entered_in_error"
Error 422 "<medical_event> inΒ "entered_in_error" status can not be used as an evidence"
in case ifΒ PSYCHIATRY_ICPC2_DIAGNOSES_EVIDENCE_CHECKΒ chart parameterΒ containsΒ $.conditions[*].code.coding.code
check if at least one item from $.conditions[*].evidencesΒ meets requirements:Βcheck if $.conditions[*].evidences[*].detail[*].identifier.type.coding.code == "condition"Β
Error 422 "Condition must be entered as an evidence to set condition code <$.conditions[*].code.coding.code>"
MedicalEvents.Condition.Code.CodingΒ array contains at least one of codes fromΒ PSYCHIATRY_ICD10_AM_CONDITION_EVIDENCE_ALLOWEDΒ chart parameter.
Error 422 "Condition can not be used as an evidence to set condition code <$.conditions[*].code.coding.code>"
Validate asserter.
$.conditions.asserter.identifier.value is an ID of one of users employeeΒ
in case of error return "Employee is not performer of encounter"
according to logicΒ Submit Encounter Data Package#Performer(asserter)validation
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>')
checkΒ if asserter's employee_type == "MED_COORDINATOR" then define allowedΒ conditions fromΒ ICD10_AM_MED_COORDINATOR_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>')
Validate primary_source:
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 <code>')
if primary_source = false - skip this check
Validate Observations
Several approaches are used for validating observations. This is driven by the natural growth of the system, which implies increased complexity and the different requirements for various groups, categories of observations and even the contexts in which they (observations) were created.
Currently, the following approaches are used:
Basic validations for all observations
Validation of observations for the encounter type "patient_identity".
A set of validations for rehabilitation observations based on ICF (International Classification of Functioning, Disability, and Health) dictionaries.
Validation of observations based on a configuration set defined for a specific observation code (new).
Basic validation and REHAB
Validate observations ids asΒ primary keys
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
Β if $.observations[*].code.coding[*].system is "eHealth/ICF/classifiers":
Check number of component items withΒ $.observations[*].components[*].code.coding[*].system =Β "eHealth/ICF/qualifiers":Β
ifΒ $.observations[*].code.coding[*].codeΒ starts from "b" letter, thenΒ components must contain exact 1 item with:
$.observations[*].components[*].code.coding[*].code = "extent_or_magnitude_of_impairment"Β
in case of missing qualifier - return 422 "Missing components with qualifiers <list of missing qualifiers>"
in case of incorrect number of qualifiers - return 422 "Required 1 component, but got <number of items>"
in case value is not active in dictionary - return 422 "Value is not active"
if $.observations[*].code.coding[*].codeΒ starts from "s" letter, thenΒ components must contain exactΒ 3 items with:
$.observations[*].components[*].code.coding[*].code = "extent_or_magnitude_of_impairment"
$.observations[*].components[*].code.coding[*].code = "nature_of_change_in_body_structure"
$.observations[*].components[*].code.coding[*].code = "anatomical_localization"
in case of missing qualifier - returnΒ 422 "Missing components with qualifiers <list of missing qualifiers>"
in case of incorrect number of qualifiers - return 422 "Required 3 components, but got <number of items>"
in case value is not active in dictionary - return 422 "Value is not active"
if $.observations[*].code.coding[*].codeΒ starts from "d" letter, thenΒ components must contain exactΒ 2 items with:
$.observations[*].components[*].code.coding[*].code = "performance"
$.observations[*].components[*].code.coding[*].code = "capacity"
in case of missing qualifier - returnΒ 422 "Missing components with qualifiers <list of missing qualifiers>"
in case of incorrect number of qualifiers - return 422 "Required 2 components, but got <number of items>"
in case value is not active in dictionary - return 422 "Value is not active"
if $.observations[*].code.coding[*].codeΒ starts from "e" letter, thenΒ components must contain exactΒ 1 item with:
$.observations[*].components[*].code.coding[*].code = "barrier_or_facilitator"
in case of missing qualifier - returnΒ 422 "Missing components with qualifiers <list of missing qualifiers>"
in case of incorrect number of qualifiers - return 422 "Required 1 component, but got <number of items>"
in case value is not active in dictionary - return 422 "Value is not active"
CheckΒ $.observations[*].components[*].value_codeable_conceptΒ is present in each item withΒ $.observations[*].components[*].code.coding[*].system =Β "eHealth/ICF/qualifiers" andΒ Β $.observations[*].components[*].value_codeable_concept.coding[*].system corresponds toΒ $.observations[*].components[*].code.coding[*].code
in case not present or doesn't correspond -Β return 422 "Doesn't correspond to $.observations[i].components[i].code"
in case code value is not active in dictionary - return 422 "Value is not active"
if observations[*].categories[0].coding[0].system == "eHealth/ICF/observation_categories" - skip validation of observations[*].value and make this fields optional
else - check that one off this fields present:
Validate$.observations[*].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Β $.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}"
if observations[*].code.coding[*].system is "eHealth/ICF/classifiers", then:
CheckΒ observations[*].categories[*].coding[*].system should contain "eHealth/ICF/observation_categories"
in case of error return 422 βCode doesn't match observation categoryβ
CheckΒ observations[*].components are presented
in case of error return 422 βComponents requiredβ
Validate $.observations.code.coding[*].code is active in corresponding dictionary
in case of error return 409, βValue is not activeβ
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[*].categories[*].coding[*].system is "eHealth/observation_categories" or "eHealth/ICF/observation_categories"Β
in case of error return 422 "Value is not allowed in enum"
$.observations[*].categories[*].coding[*].code corresponds to the system
in case of error return 422 "Value is not allowed in enum"
Validate $.observations.categories[*].coding[*].code is active in corresponding dictionary
in case of error return 409, βValue is not activeβ
If $.observations[*].categories[*].coding[*].system = "eHealth/ICF/observation_categories",Β then $.observations[*].code should be filled from "eHealth/ICF/classifiers" dictionary.
in case of error return 422 βCode doesn't match observation categoryβ
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 specimen,Β if submitted:
Check the fieldΒ is aΒ ReferenceΒ on a specimen resource
in case of error return 422 βnot allowed in enumβ
Check it exists in DB or within current package, and belongs to the sameΒ patient:
in case of error return 422 "Specimen not found"
Check status:
is available if the specimen was found in the DB
in case of error return 422 "Specimen created beforeΒ the current package should be available"
is unavailableΒ if the specimen not found in the DB, but in the package
in case of error return 422 "Specimen created in the current package should be unavailable"
Validate observations for encounter.type == "patient_identity"Β
EDP with type == "patient_identity" should have list of special observations.Β
Such list can contain limited set of codes, some of them are mandatory
code | M/O |
---|---|
height | M |
weight | M |
sex | M |
stature | O |
eye_colour | O |
hair_ color | O |
hair_length | O |
beard | O |
mustache | O |
clothes | O |
peculiarity | O |
Validate observations using configuration set
This validations must be done on top of Basic validations and only in case there is defined configuration set for such observation
Search for active configuration set (is_active = true) using observation code (code + system) and perform additional validation. If there is no configuration for such code then this additional validations must be skipped
Category
Check that
observation.categories.coding.system
andobservation.categories.coding.code
matches with one of the options in CATEGORY configuration parameter
Components
Check that all components in
observation.components
are unique and not duplicated if COMPONENTS_UNIQUE is set to true. Otherwise skip this stepin case of error return 422 βObservation components must be uniqueβ
Check that all required components are present in
observation.components
(declared in COMPONENTS_REQUIRED)values in COMPONENTS_REQUIRED.check means all required and observation components must include all of them
if COMPONENTS_REQUIRED is missing or is empty then skip this validation
in case of error return 422 βNot all required components provided for this observation codeβ
Check that there are no items in
observation.components
other than those allowed, which are defined by the COMPONENTS_ALLOWEDvalues in COMPONENTS_ALLOWED.check means all allowed (except COMPONENTS_REQUIRED) observation components that could be used for this observation code
if COMPONENTS_ALLOWED.check is empty then no additional components are allowed
if COMPONENTS_ALLOWED is missing then skip this validation
in case of error return 422 βComponent code is not allowed for this observation codeβ
Check that component value type matches with COMPONENTS_TYPE configuration parameter
search for related configuration in COMPONENTS_TYPE.condition using
observation.component.code.coding.system
andobservation.component.code.coding.code
check that
observation.component.value[x]
type matches with the type declared in COMPONENTS_TYPE.checkif COMPONENTS_TYPE is missing or is empty or there is no matched configuration then skip this validation
in case of error return 422 βtype mismatch. ExpectedΒ {COMPONENTS_TYPE.check} but got {entered type}β
Check that dictionary used to represent component with value type
codeable_concept
matches with declared in COMPONENTS_BINDING configuration parameterMust be done only in case when component value type is codeable_concept (
observation.component.value[x]
type is codeable_concept)search for related configuration in COMPONENTS_BINDING.condition using
observation.component.code.coding.system
andobservation.component.code.coding.code
check that
observation.component.value_codeable_concept.coding.system
matches with the system (dictionary) declared in COMPONENTS_BINDING.checkif COMPONENTS_BINDING is missing or is empty or there is no matched configuration then skip this validation
in case of error return 422 βIncorrect dictionary. ExpectedΒ {COMPONENTS_TYPE.check}β
Check that code system and value used to represent quantity in component are allowed according to COMPONENTS_QUANTITY_CODES configuration parameter
Must be done only in case when component value type is quantity (
observation.component.value[x]
type is quantity)search for related configuration in COMPONENTS_QUANTITY_CODES.condition using
observation.component.code.coding.system
andobservation.component.code.coding.code
check that
observation.component.value_quantity.coding.system
andobservation.component.value_quantity.coding.code
matches respectively with one of configurations in COMPONENTS_QUANTITY_CODES.checkif COMPONENTS_QUANTITY_CODES is missing or is empty or there is no matched configuration then skip this validation
in case of error return 422 βSuch quantity system and quantity code are not allowed in this componentβ
Check that component value is within the declared in COMPONENTS_QUANTITY_BOUNDARIES configuration parameter boundaries
Must be done only in case when component value type is quantity (
observation.component.value[x]
type is quantity)search for related configuration in COMPONENTS_QUANTITY_BOUNDARIES.condition using (
observation.component.code.coding.system
andobservation.component.code.coding.code
for COMPONENTS_QUANTITY_BOUNDARIES.condition.component_code) and (observation.component.value_quantity.system
andobservation.component.value_quantity.code
for COMPONENTS_QUANTITY_BOUNDARIES.condition.quantity_code)check that configuration.check.min <=
observation.component.value_quantity.value
>= configuration.check.maxif COMPONENTS_QUANTITY_BOUNDARIES is missing or is empty or there is no matched configuration then skip this validation
in case of error return 422 βIncorrect value. Expected value to be in rangeΒ {configuration.check.min} and {configuration.check.max}β
Check that only allowed extensions are used in components (declared in COMPONENTS_ALLOWED_EXTENSIONS)
values not declared in COMPONENTS_ALLOWED_EXTENSIONS.check is prohibited and is not allowed in
observation.components
if COMPONENTS_ALLOWED_EXTENSIONS.check is empty then no extension allowed
if COMPONENTS_ALLOWED_EXTENSIONS is missing then no extension allowed
check that
observation.component.value_codeable_concept.coding.extension
contains only extensions declared in COMPONENTS_ALLOWED_EXTENSIONS.checkin case of error return 422 βExtension {
observation.component.value_codeable_concept.coding.extension
} is not allowedβ
check that there are no duplicated extensions in
observation.component.value_codeable_concept.coding.extension
in case of error return 422 βDuplicated extensionβ
check that extension is valid according to https://e-health-ua.atlassian.net/wiki/spaces/REHABILIT/pages/18431246564/UPD+Medical+Events+MongoDB+Data+Model#Predefined-extensions
in case of error return 422 βInvalid extensionβ
Check that extension value is correct according to COMPONENT_SCORE configuration parameter
Must be done only in case when component value type is codeable_concept (
observation.component.value[x]
type is codeable_concept)search for the score associated with provided value (declared in COMPONENT_SCORE configuration parameter) using component value (
observation.component.value_codeable_concept.coding.system
andobservation.component.value_codeable_concept.coding.code
) and component code (observation.component.code.coding.system
andobservation.component.code.coding.code
).check that extension value (
observation.component.value_codeable_concept.coding.extension(code = item_weight).value_decimal
) is equal value declared in COMPONENT_SCORE.check for such componentin case of error return 422 βIncorrect component scoreβ
Value
Check that observation value type matches with RESULT_TYPE configuration parameter
check that
observation.value[x]
type matches with the type declared in RESULT_TYPE.checkif RESULT_TYPE is missing or is empty then skip this validation
in case of error return 422 βtype mismatch. ExpectedΒ {RESULT_TYPE.check} but got {entered type}β
Check that dictionary used to represent observation value matches with declared in RESULT_BINDING configuration parameter
Must be done only in case when observation value type is codeable_concept (
observation.value[x]
type is codeable_concept)check that
observation.value_codeable_concept.coding.system
matches with the system (dictionary) declared in RESULT_BINDING.checkif RESULT_BINDING is missing or is empty then skip this validation
in case of error return 422 βIncorrect dictionary. ExpectedΒ {RESULT_BINDING.check}β
Check that code system and value used to represent quantity in observation are allowed according to RESULT_QUANTITY_CODES configuration parameter
Must be done only in case when component value type is quantity (
observation.value[x]
type is quantity)check that
observation.value_quantity.coding.system
andobservation.value_quantity.coding.code
matches respectively with one of configurations in RESULT_QUANTITY_CODES.checkif RESULT_QUANTITY_CODES is missing or is empty or there is no matched configuration then skip this validation
in case of error return 422 βSuch quantity system and quantity code are not allowed in observation resultβ
Check that observation value is within the declared in RESULT_BOUNDARIES configuration parameter boundaries
Must be done only in case when observation value type is quantity (
observation.value[x]
type is quantity)search for related configuration in RESULT_BOUNDARIES.condition using
observation.value_quantity.coding.system
andobservation.value_quantity.coding.code
check that configuration.check.min <=
observation.value_quantity.value
>= configuration.check.maxif RESULT_BOUNDARIES is missing or is empty or there is no matched configuration then skip this validation
in case of error return 422 βIncorrect value. Expected value to be in rangeΒ {RESULT_BOUNDARIES.check.min} and {RESULT_BOUNDARIES.check.max}β
Check that observation value calculated correctly according to the method declared in RESULT_SCORE_CALCULATION configuration parameter
There are different supported methods to calculate and control result (βSUMβ)
If `SUM` specified
go through all
observation.components
sum all scores provided in item_weight extension
observation.component.value_codeable_concept.coding.extension(code = item_weight).value_decimal
and all components where component value type is quantity and quantity system =eHealth/ucum/units
and quantity code =ScoreOf
ensure that this result is equal to
observation.component.value_quantity.value
if RESULT_SCORE_CALCULATION is missing or is empty then skip this validation
in case of error return 422 βIncorrect observation resultβ
Validate Immunizations
Validate immunizations ids asΒ primary keys
Validate primary_source
in case primary_source == true
$..performer must be filled
in case of error return 422 with msg "performer must be present if primary_source is true"
$..report_origin must beΒ absent
in case of error return 422 with msg "Only one of the parameters must be present"
check not_given parameter
in case not_given == false
$..explanation.reasons, $..manufacturer, $..lot_number, $..expiration_date, $..dose_quantity.value, $..dose_quantity.unit, $..dose_quantity.code, $..site, $..route, $..vaccination_protocols.dose_sequence, $..vaccination_protocols.authority, $..vaccination_protocols.series, $..vaccination_protocols.series_doses, $..vaccination_protocols.target_diseases must be filled (inclusive with those that are mandatory according to the apiary)
in case of error return 422 with msg "<reasons|manufacturer|lot_number|expiration_date|value|unit|code|site|route|dose_sequence|authority|series|series_doses|target_diseases> must be present if primary_source is true and not_given is false"
$..explanation.reasons_not_given must beΒ absent
in case of error return 422 with msg "Only one of the parameters must be present"
in case not_given == true
$..explanation.reasons_not_given, $..vaccination_protocols.dose_sequence, $..vaccination_protocols.authority, $..vaccination_protocols.series, $..vaccination_protocols.series_doses, $..vaccination_protocols.target_diseases must be filled (inclusive with those that are mandatory according to the apiary)
in case of error return 422 with msg "<reasons_not_given|dose_sequence|authority|series|series_doses|target_diseases> must be present if primary_source and not_given is true"
$..explanation.reasons must beΒ absent
in case of error return 422 with msg "Only one of the parameters must be present"
in case primary_source == false
$..report_origin must be filled
in case of error return 422 with msg "report_origin must be present if primary_source is false"
$..performer must beΒ absent
in case of error return 422 with msg "Only one of the parameters must be present"
check not_given parameter
in case not_given == true return error 422 with msg "Only completed immunizations can be filled if primary_source is false and not_given is true"
in case not_given == false
$..explanation.reasons, $..dose_quantity.value, $..dose_quantity.unit, $..vaccination_protocols.authority, $..vaccination_protocols.target_diseases must be filled (inclusive with those that are mandatory according to the apiary)
in case of error return 422 with msg "<reasons|value|unit|authority|target_diseases> must be present if primary_source and not_given is false"
if vaccination_protocols.authority == MoH $..vaccination_protocols.dose_sequence, vaccination_protocols.series, vaccination_protocols.series_doses must be filled
in case of error return 422 with msg "<dose_sequence|series|series_doses> must be present if primary_source and not_given is false"
$..explanation.reasons_not_given must beΒ absent
in case of error return 422 with msg "Only one of the parameters must be present"
$..manufacturer must be optional
Validate that context of immunizations is a current encounter
$.immunizations[*].context.identifier.value == $.encounter.id
in case of errorΒ "Submitted context is not allowed for the immunization"
Validate that the date is within acceptable limits
$.immunizations[*].date <= current_time
in case of error "Date must be in past"
$.immunizations[*].date>=current_date-immunization_max_days_passed
in case of error "Date must be greater thanΒ {{current_date-immunization_max_days_passed}}"
Validate performer according to the RuleΒ
Validate that observation submitted as a detail of reaction is an existing observation that belongs to the current patient
$.immunizations[*].reactions[*].detail.identifier.value is an ID of existing observation in ME.observations where (ME.observations.patient_id==patient_id from url)Β OR one of $.observations[*].id
in case of error return 422 "There is no observation with such id"
Validate Allergy Intolerances
Validate allergy intolerances ids asΒ primary keys
Validate that context ofΒ allergy_intolerances is a current encounter
$.allergy_intolerances[*].context.identifier.value == $.encounter.id
in case of errorΒ "Submitted context is not allowed for the allergy_intolerances"
Validate asserter according to the Rule
Validate that the date is within acceptable limits
$.allergy_intolerances[*].onset_date_time<= current date_time
in case of error "Onset date time must be in past"
$.allergy_intolerances[*].onset_date_time>=current_date-allergy_intolerance_max_days_passed
in case of error "Onset date time must be greater thanΒ {{current_date-allergy_intolerance_max_days_passed}}"
Validate that asserted_date is in past
$.allergy_intolerances[*].asserted_date<= current date_time
in case of error "Asserted date must be in past"
Validate that last_occurrence is in past
$.allergy_intolerances[*].last_occurrence<= current date_time
in case of error "Last occurrence must be in past"
Validate Risk Assessments
Validate risk assessment id as a primary key
Validate that context ofΒ risk_assessments is a current encounter
$.risk_assessments[*].context.identifier.value == $.encounter.id
in case of errorΒ "Submitted context is not allowed for the risk_assessments"
Validate that asserted_dateΒ is within acceptable limits
$.risk_assessments [*].asserted_date<= current date_time
in case of error "Asserted dateΒ must be in past"
$.risk_assessments [*].asserted_date>=current_date-risk_assessment_max_days_passed
in case of error "Asserted date must be greater thanΒ {{current_date-risk_assessment_max_days_passed}}"
Validate performerΒ according to the Rule
validateΒ performer is an active doctor 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")
in case of error return 422 "Invalid employee type"
Validate only one of these fields are filled: reason_reference , reason_codeable_concept
Validate reason_referenceΒ as a Reference
Validate basis as a Reference
Validate when_period as a Period
Validate only one of the fields is filled: prediction.when_period or prediction.when_range
Validate only one of the fields is filled: prediction.probability_decimal or prediction.probability_range
Validate Devices
Validate device id as a primary key
Validate that context of devices is a current encounter
$.devices[*].context.identifier.value == $.encounter.id
in case of errorΒ "Submitted context is not allowed for the device"
Validate that asserted_dateΒ is within acceptable limits
$.devices[*].asserted_date<= current date_time
in case of error "Asserted dateΒ must be in past"
$.devices[*].asserted_date>=current_date-device_max_days_passed
in case of error "Asserted date must be greater thanΒ {{current_date-device_max_days_passed}}"
Validate asserter according to the Rule
Validate usage_period as a period
Validate Medication Statement
Validate medication statement id as primary key
Validate that context ofΒ medication statement is a current encounter
$.medication_statements[*].context.identifier.value == $.encounter.id
in case of errorΒ "Submitted context is not allowed for the medication statement"
Validate that asserted_dateΒ is within acceptable limits
$.medication statements[*].asserted_date<= current date_time
in case of error "Asserted dateΒ must be in past"
$.medication statements[*].asserted_date>=current_date-medication statement_max_days_passed
in case of error "Asserted date must be greater thanΒ {{current_date-medication statement_max_days_passed}}"
Validate asserter according to the Rule
Validate based_on as aΒ Reference to OPS.medication_request
Validate Medication Administration
Validate medication statement id as primary key
Validate part_ofΒ
validate procedure or medication_administration is made for the same patient
procedure.patient_id=@person_id
medication_administration.patient_id=@person_id
in case error returnΒ 409 "Procedure/Medication administration was made for another person"
validate procedure or medication_administration is not in status `entered_in_error`
in case error return 409, "Procedure/Medication administration is not active"
if part_of.identifier.value is a procedure validate it is a procedure in DB or in payload
in case error return 422, "Procedure with such id is not found"
ValidateΒ medication
validate that medication is of type 'BRAND'
in case error return 422, "Medication should be of type brand"
medication corresponds to the INNM_DOSAGE medication from request.medicationΒ
"select count(*) from ingredients where parent_id=βmedication_administration.medication.idβ and medication_child_id = βmedication_request.medication_idβ " >=1
in case error return 422,Β "Medication should correspond to the one in request"
Validate that context ofΒ medication administration is a current encounter
$.medication_administration[*].context.identifier.value == $.encounter.id
in case of errorΒ "Submitted context is not allowed for the medication administration"
validateΒ performed_date_time <= now()
in case error return 422, "performed_date_time should be in the past"
Validate performerΒ according to the Rule
validateΒ performer is an active doctor 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"))
"Employee is not an active doctor"
validateΒ reason_references
validateΒ Β Condition|Observation|DiagnosticReportΒ asΒ Reference
validate Condition|Observation|DiagnosticReport is not in status "entered_in_error"
in case error return 409, "Reason reference should be active"
validate Condition|Observation|DiagnosticReport is made for the same person
in case error return 409, "Reason reference was made for another person"
validate Condition|Observation|DiagnosticReport exist in DB or in payload
in case error return 422, "Condition|Observation|DiagnosticReport with such id is not found"
ValidateΒ request
Β validate medication_request as a reference
validate medication_request is in active status. medication_request.status='ACTIVE' and is_active=true
in case error return 409, "medication request is not active"
validate medication request is made for the same person
in case error return 409, "medication requestΒ was made for another person"
Validate medication_request.started_atΒ < now()
in case error return 409, "Medication request started at should be in the past"
ValidateΒ dosage
Validate Diagnostic Report
Validate diagnostic reports ids as primary keys
Validate based_on asΒ Reference
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"
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.
Check if service request quantity is not exhausted as described atΒ related service request validation
category
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 $.diagnostic_report[*].categories
is an array with only one item
in case of error return 422 "Expected a maximum of 1 items but got <number of elements>"
Validate that $.diagnostic_report[*].category.coding.code is
eHealth/diagnostic_report_categories
dictionary, requiredin case of error return 422 "value is not allowed in enum"
Validate that diagnostic reports category 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 "Diagnostic report category does not match with the service category"
ValidateΒ code
Validate code asΒ Reference
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 diagnostic_report.service.is_active = true
in case error return 409, "Service should be active"
Validate effective_periodΒ as a period
Validate that issued is within acceptable limits
$.diagnostic_reports[*].issued<= current date_time
in case of error 422 "Asserted 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 conclusion_code:
$.diagnostic_reports[*].conclusion_code.coding[*].code validate that the code belongs to the dictionary system 'eHealth/ICD10_AM/condition_codes'
in case of error return "Value is not allowed in enum"
Check that there is only one code in conclusion_code.coding array
if more - return error "Only one code from one dictionary is allowed"
Validate recorded_by as Employee
Validate encounter
$.diagnostic_reports[*].encounter.identifier.value == $.encounter.id
in case of error 409 "Invalid reference"
Validate performer:
as Employee
according to logic Performer(asserter) validation
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
Validate result_interpreter.identifier is an employee with employee_type = DOCTOR or SPECIALIST
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Β primary_source
If primary_source==true, then
Managing organization MUST be filled
performer.referenceΒ MUST be filled
If primary_source==false, then
report_origin must be filled
performer.reference must NOT be filled
results_enterpreter.reference must NOT be filled
Validate patient verification status:
If diagnostic report has based_on 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 specimens, if submitted:
Check field has array with elements ofΒ ReferenceΒ type on specimen resource
in case of error return 422 βnot allowed in enumβ
For each specimen check:
Check it exists in DB or within current package, and belongs to the sameΒ patient:
in case of error return 422 "Specimen not found"
Check it is present in the only one diagnostic report within the package.
in case of error return 422 "Specimen is already used in another diagnostic report"
Check status:
is available if the specimen found in the DB
in case of error return 422 "Specimen created beforeΒ the current package should be available"
is unavailable if the specimen not found in the DB, but in the package
Validate Procedures
Validate by json schema
Validate procedure id as primary key
Validate status
On createΒ procedure status could be completed or not_done.Β `entered_in_error` could be set on update procedure.
error 422 by json schema
ValidateΒ code
Validate code asΒ Reference
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
ValidateΒ performed_period/performed_date_time:
if $.status == "not_done" check that Β performed_period/performed_date_timeΒ fields are not present in request
in case error return 422Β entry:Β "$.performed_period" (or "$.performed_date_time"), rules[0].description: "Must not be present in procedure with status <$.status>"
else,Β if $.status == "completed":
Check that only one of this parameters present
in case error return 422 "Only one of the parameters must be present"
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Β performed_period
$.performed_period.start<= now
in case of error return 422 "Procedure cannot be registered in future"
$.performed_period.end>=Β $.performed_period.start
in case of error return 422 "End date must be greater than start date"
performed_period.end <= now
in case error return 422 "Procedure cannot be registered in future"
Validate $.performed_periodΒ as required field in case if procedure based on service request with quantity that has code=MINUTE (system=SERVICE_UNIT)
in case of error return 422 "can't be blank"
ValidateΒ recorded_by
ValidateΒ recorded_by asΒ Reference
$..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
$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
$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Β (Reference)
ValidateΒ reason_refernce.identifier.type.coding.[0].codeΒ is condition or observation
in caseΒ error return 422 "value is not allowed in enum"
ValidateΒ reason_refernce.identifier.value isΒ condition or observation not in statusΒ ENTERED_IN_ERROR
in case error return 422, "Observation in "entered_in_error" status can not be referenced" if observation, else - "Condition is canceled"
ValidateΒ outcome
validate outcomeΒ as a ReferenceΒ
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Β
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"
Validate used_codes
CheckΒ that the $.used_codes[*].coding[*].codeΒ belongs to the dictionary in $.used_codes[*].coding[*].system
in case of error - return 422Β "Value is not allowed in enum"
Validate 'used_codes.coding.code'Β is_active = true
in case error return 409, "Value is not active"
Validate Clinical impression
Validate by json schema
Validate clinical impression id as primary key (Primarykeyvalidation)
Validate status
Check that the code belongs to the dictionary systemΒ (eHealth/clinical_impression_statuses)
in case of error - return 422 ('value is not allowed in enum')
Check it has value = completed
in case of error - return 422 ('value is not allowed in enum')
ValidateΒ code
CheckΒ that the code belongs to the dictionary system (eHealth/clinical_impression_patient_categories)
in case of error - return 422 ('value is not allowed in enum')
Validate code.coding depending on the qty of codes. Maximum one code is allowed
in case of error - return 422 ('Only one code is allowed')
Check by code.coding[0].code and code.coding[0].system active rulesΒ inΒ rule_engine_rules collection
in case any active rules present - check request only with following validations
in case rule present in collection -Β check request with following validationsΒ and with additional from rule engine rule
Validate description
Check thatΒ value withΒ string type
in case of error - return 422 ('type mismatch. Expected string but gotΒ {entered type}')
Validate encounter
Check the value is valid reference onΒ encounter resource
Check that value is an object with references of type encounter
in case of error - return 422 ('value is not allowed in enum')
Check the value is valid reference on encounter resource
Check that $.clinical_impressions[*].encounter.identifier.value == $.encounter.id
in case error - return 422 ('Invalid reference')
Validate effective_period andΒ effective_date_time:
Validate that at least one of the parameters are present
in case of error - return 422 ('At least one of the parameters must be present')
Validate effective_periodΒ as a period (PeriodValidation)
Validate value in the field $.effective_period
Check that $.effective_period.start <= encounter.date
in case of error - return 422 ('Start date must be in the past')
Check that $.effective_period.end >= $.effective_period.start
in case of error - return 422 ('End date must be greater than or equal the start date')
Validate that $.effective_period.end is within acceptible limits
Check that $.effective_period.end <= current_time
in case of error - return 422 ('Date must be in past')
Check that $.effective_period.end >= current_date-clinical_impression_max_days_passed
in case of error - return 422 ('Date must be greater than {{current_date-clinical_impression_max_days_passed}}')
ValidateΒ effective_date_time
CheckΒ that field $.effective_date_timeΒ withΒ string type
in case of error - return 422 ('type mismatch. Expected string but gotΒ {entered type}')
Check that field $.effective_date_time <= current_time
in case of error - return 422 ('Date must be in past')
Check that field $.effective_date_time >= current_date-clinical_impression_max_days_passed
in case of error - return 422 ('Date must be greater than {{current_date-clinical_impression_max_days_passed}}')
ValidateΒ assessor
ValidateΒ assessor asΒ Reference (Referencevalidation)
$.assessor.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Β assessor is employee with status='APPROVED' and is_active= true and end_date is null or more than today
in case of error - return 422 ('Invalid employee status')
ValidateΒ previous
Check the value is valid reference onΒ clinical impression resource
Check that value is an object with references of type clinical_impression
in case of error - return 422 ('value is not allowed in enum')
Check thatΒ clinical impression is active (status is not entered_in_error)
in case of error - return 422 ('Clinical impression in "entered_in_error" status can not be referenced')
Check thatΒ clinical impression belongs to patient ($.subject)
in case of error - return 422 ('Clinical impression with such id is not found')
ValidateΒ problems
Check that value is an array with references of type condition
in case of error - return 422 ('value is not allowed in enum')
Check that each condition is active (verification_status is not entered_in_error)
in case of error - return 422 ('Condition in "entered_in_error" status can not be referenced')
Check that condition belongs to the patient ($.subject)
in case of error - return 422 ('Condition with such id is not found')
Validate finding
Check that value is an array with objects
ValidateΒ item_reference
Check that value is an object with reference of resource condition, observation (furtherΒ <Medical event resource>)
in case of error - return 422 ('value is not allowed in enum')
Check thatΒ <Medical event resource>Β is active (status is not entered_in_error)
in case of error - return 422 ('<Medical event resource> in "entered_in_error" status can not be referenced')
Check that each reference:
is valid ME of defined type above
belongs to the patient ($.subject)
in case of error - return 422 (<Medical event resource> with such ID is not found')
In case some resources present in active rule, check that they correspond to configured rule
Check that value is an object with reference of resource condition, observation (further <Medical event resource>)
in case of error - return 422 'entry': '$.clinical_impressions[0].code', 'entry_type': 'json_data_property', 'rules': [{'description': '<description_text of the failed rule>, rule: <number of failed rule>', β¦
ValidateΒ basis
Check thatΒ value withΒ string type
in case of error - return 422 ('type mismatch. Expected string but gotΒ {entered type}')
ValidateΒ supporting_info
Check that value is an array with references of type episode_of_care, procedure, diagnostic report, encounter (furtherΒ <Medical event resource>)
in case of error - return 422 ('value is not allowed in enum')
Check thatΒ <Medical event resource>Β is active (status is not entered_in_error)
in case of error - return 422 ('<Medical event resource> in "entered_in_error" status can not be referenced')
Check that each reference:
is valid ME of defined type above
belongs to the patient ($.subject)
in case of error - return 422 (<Medical event resource> with such ID is not found')
In case some resources present in active rule, check that they correspond to configured rule
in case of error - return 422 'entry': '$.clinical_impressions[0].code', 'entry_type': 'json_data_property', 'rules': [{'description': '<description_text of the failed rule>, rule: <number of failed rule>', β¦
Validate note
Check thatΒ value withΒ string type
in case of error - return 422 ('type mismatch. Expected string but gotΒ {entered type}')
Validate patient
In case patient params present in active rule, get them through subject and check that they correspond to configured rule
in case of error - return 422 'entry': '$.clinical_impressions[0].code', 'entry_type': 'json_data_property', 'rules': [{'description': '<description_text of the failed rule>, rule: <number of failed rule>', β¦
In case medication dispense data presents in active rule, get medication dispense data in patient context (through subject) and check that it correspond to configured rule
in case of error - return 422 'entry': '$.clinical_impressions[0].code', 'entry_type': 'json_data_property', 'rules': [{'description': '<description_text of the failed rule>, rule: <number of failed rule>', β¦
Validate Specimen
Validate by json schema
Validate specimens ids asΒ primary keys (Submit Encounter Data Package#Primarykeyvalidation)
Validate that context of specimen is a current encounter
$.specimens[*].context.identifier.value==$.encounter.id
in case of error return 422 "Submitted context is not allowed for the specimen"
Validate specimen's root attributes:
ValidateΒ requests, type, condition, registered_by, managing_organizationΒ as described at Create Specimen: Validate specimen
Validate parentΒ as described atΒ Create Specimen: Validate specimen,Β but also check it within current package
Validate status:
Check the value is available or unavailable, according to theΒ
specimen_statuses
Β dictionaryΒin case of error return 422 "value is not allowed in enum"
Specimen is unavailable if there is at least one entity thatΒ references specimen (Observations where ($.observations[*].specimen.reference == specimen.id) or Diagnostic Reports whereΒ ($.diagnostic_reports[*].specimen.reference == specimen.id))
in case of error return 422 "Specimen that is not referenced in Observation or Diagnostic Report must be in 'available' status"
Validate collection attributes:
Validate collector, collected, quantity, duration, method, body_site, fasting statusΒ as described at Create Specimen: Validate collection
Validate procedure in the field $.collection.procedure, Reference type, optional
Check it references to procedure resource
in case of error - return 422 ('value is not allowed in enum')
Check that procedure exists in the DB and belongs to the patient, or it is within current package
in case of error - return 422 ('Procedure not found')
Validate that entity is not in status "entered_in_error"
in case of error - return 422 ("Entity in status "entered_in_error" can not be referenced")
Validate container attributes as described at Create specimen: Validate container
ValidateΒ received_time as described at Process Specimen: Validate received datetime
received_time must be emptyΒ if there are no other entities that reference specimen (NOΒ Observations where ($.observations[*].specimen.reference == specimen.id) and NO Diagnostic Reports whereΒ ($.diagnostic_reports[*].specimen.reference == specimen.id))
in case of error return 422 "
Received time must not be set for available specimen
"
Validate status_reason:
is set to codeable concept with system = specimen_invalidate_reasons and code = used, if the specimen status is unavailable (i.e. at least one entity thatΒ references specimen).
in case of error return 422 ('value is not allowed in enum')
is empty, if the specimen status is available.
in case of error return 422 ('Status reason must not be set for available specimen')
Validate Device Dispense
Validate by json schema
Return 422 with list of validation errors in case validation failsΒ
Validate device dispenses ids asΒ primary keys (https://e-health-ua.atlassian.net/wiki/spaces/EH/pages/edit-v2/18492261105#Primary-key-validation )
Validate device dispenses's root attributes:
Validate performer, location as described at https://e-health-ua.atlassian.net/wiki/spaces/EH/pages/18493276353/RC_+UPD+Create+Device+dispense#Validate-dispense
Validate $.status is COMPLETED or DECLIEND
else - return 422 ("value is not allowed in enum")
If based_on is present, validate:
Check it references to device_request resource
in case of error - return 422 ('value is not allowed in enum')
Check that device request exists and belongs to the same patient
in case of error - return 422 ('Device request not found')
Π‘heck that device request is in status 'active'
in case of error - return 409 error ('Device request is not active')
Check that intent specified in Device request is
order
in case of error - return 409 error ('Only device request with intent = 'order' can be dispensed')
Check that program in device request is empty (device_requests.program = null)
in case of error - return 409 ('Device request with program can not be referenced')
Verify care plan Activity as described in https://e-health-ua.atlassian.net/wiki/spaces/EH/pages/18493276302/RC_+UPD+Qualify+Device+Request+by+ID#Validate-related-Care-plan
validate when_handed_over
If based_on is present check that when_handed_over is equal or greater then device_request.authored_on
1. in case of error - return 409 error ('when_handed_over date can not be lesser then the authored_onΒ date of the related Device request')
Validate encounter:
Validate encounter references the current encounter, submitted within the same package
$.device_dispenses[*].encounter.identifier.value==$.encounter.id
in case of error return 422 "Device dispense can only reference encounter from the same package"
Validate encounter period fully contains when_handed_over date
$.encounter.period.start<$.device_dispenses[*].when_handed_over and $.encounter.period.end_date>$.device_dispenses[*].when_handed_over
in case of error return 422 "Device dispense when_handed_over date doesnβt match with encounter periodβ
Validate part_of:
Check it references to procedure resource
in case of error - return 422 ('value is not allowed in enum')
Validate that procedure reference one of procedures, submitted within the same package
in case of error return 422 "Device dispense can only reference procedure from the same package"
Validate that procedure is not in status "entered_in_error" or βnot_doneβ
in case of error - return 422 ("Procedure in status "entered_in_error" or βnot_doneβ can not be referenced")
Validate supporting_info:
Check it references condition, observation, diagnostic_report, procedure, encounter, episode, device or device_association resource
in case of error - return 422 ('value is not allowed in enum')
Check that {resource} exists and belongs to the same patient, or it is within current package
in case of error - return 422 ('{resource} not found')
Validate that {resource} is not in status "entered_in_error"
in case of error - return 422 ("{resource} in status "entered_in_error" can not be referenced")
Validate $.details.device_code if present:
if based_on is present validate Dispense details as described at https://e-health-ua.atlassian.net/wiki/spaces/EH/pages/18493276353/RC_+UPD+Create+Device+dispense#Validate-device_code
if based_on is NOT present:
Check system($.details.device_code.coding.system) = device_definition_classification_type
in case of error - return 422 ('value is not allowed in enum')
Get device_code from the dictionary
device_definition_classification_type
($.details.device_code.coding.code) and check parameter is_active = truein case of error - return 422 ('Device code not found')
Check that $.device_code.coding[] array contains only 1 element
in case of error - return 422 ('Exceeded max count of elements in the array')
Check that $.device_code.coding[].code is an active value from the dictionary specified in $.device_code.coding[].system
in case of error - return 422 ('Value <code> not found in the dictionary <system>')
Validate $.details.device If reference on Device definition is present there:
if based_on is present: https://e-health-ua.atlassian.net/wiki/spaces/EH/pages/18493276353/RC_+UPD+Create+Device+dispense#Validate-device_code
if based_on is NOT present
Check code ($.details.device.identifier.type.coding.code) =
device_definition
in case of error - return 422 ('value is not allowed in enum')
Get device definition by id ($.details.device.identifier.value)
device_definition.is_active = true
in case of error - return 422 ('Device definition not found')
Check the remainder of the division ($.details.quantity.value/device_definition.packaging_count) is equal to 0
in case of error - return reject_reason = οΏ½οΏ½οΏ½The quantity must be divisible to packaging_count of prescribed Device Definitionβ
Validate $.details.device If reference on Device is present there:
Check that device exists and belongs to the same patient, or it is within current package
in case of error - return 422 ('Device not found')
Validate that device status is not in status "entered_in_error"
in case of error - return 422 ("Device in 'entered_in_error' status can not be referenced")
If based_on is present, validate:
if referenced Device request($.based_on) contains code (device_request.code)
Check that the type in the Device($.details.device) is equal to the code in the Device request($.based_on)
in case of error - return 422 ("Dispensed device doesnβt match with prescribed device")
if referenced Device request($.based_on) contains code_reference (device_request.code_reference)
Check that the definition in the Device($.details.device) is equal to the code_reference in the Device request($.based_on)
in case of error - return 422 ("Dispensed device doesnβt match with prescribed device")
Validate quantity
if based_on is present validate quantity as described at https://e-health-ua.atlassian.net/wiki/spaces/EH/pages/18493276353/RC_+UPD+Create+Device+dispense#Valdate-quantity ,but also include Device dispenses from the current package in remaining_quantity calculation
else validate quantity.value is an integer bigger than 0
Validate related Care plan
Verify care plan Activity as described in Qualify Device request | Validate related Care plan
Validate primary_source
if $.primary_source = true, then check $.report_origin isΒ absent
in case of error - return 422 ("Report_origin can not be submitted in caseΒ primary_source is true")
if $.primary_source = false, then check $.report_origin isΒ present
in case of error - return 422 (βcan't be blankβ)
Validate report_origin
Check $.report_origin.coding[].system is
eHealth/report_origins
dictionaryin case of error - return 422Β ("value is not allowed in enum")
Check that $.report_origin.coding[].code is an active value from the dictionary specified in code.coding[].system
in case of error - return 422 ('value is not allowed in enum')
Primary key validation
Validate that IDs of all submitted entities in the array are unique
validate that $.{collection}[*].id from the payload are all unique among themselves
in case of error return 409 "All primary keys must be unique"Β Β
validate there is no entity with such id in the corresponding Medical events collection
in case of error return 422 "{Entity} with such id already exists"
Reference validation
This validation is used to validate references to medical events data from patient's collection.Β
Validate that $..identifier.value is an existing value from $..identifier.type.coding[0].code collection in DB and it belongs to the patient OR it is a value from corresponding collection in the current requestΒ
in case of errror return 422 "There is noΒ {$..identifier.type.coding[0].code} with such id"
Validate that this entity is not in status entered_in error
in case of errror return 422 "Could not reference entity in status entered_in_error"
Example:
"identifier": {
"type": {
"coding": [
{
"system": "eHealth/resources",
"code": "observation"
}
]
},
"value": "9183a36b-4d45-4244-9339-63d81cd08d9c"
}
}
In this case validate thatΒ "9183a36b-4d45-4244-9339-63d81cd08d9c" is an existing observation from patients collection and it is not entered_in_error.
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 a active doctor 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=="DOCTOR" or "SPECIALIST") (in case of observation also ASSISTANT)
case primary_source==false
$..report_origin must be filledΒ
in case of error "Report_origin must be filled"
if $..primary_source==false then $..performer(asserter) must be absent
in case of errorΒ "Performer(asserter) can not be submitted in caseΒ primary_source is false"Β
validate report_origin
$..report_origin.coding[*].system == "eHealth/report_origins"
in case of errorΒ "Submitted system is not allowed for this field"
Period Validation
$..period.start <= current_dateTime
in case of error return 422- "Start date must be in past"
if $..period.end is filled:
$..period.end > visit.period.start
in case of error return 422 - "End date must be greater than the start date"
Employee validation
Users can not reference employees between different legal entities. Employee that is not in status `approved` can not be referenced as well.
Β $...identifier.value exists inΒ PRM.employees
in case of error 409 "Employee not found"
$...identifier.value == PRM.employees.id where (PRM.employees.status == "APPROVED" andΒ PRM.employees.legal_entity==token.client_id)
in case of error 409 "Submitted employee is not an active employee from current legal entity"
Related service request validation
If service request referenced as based on in ME:
if it has quantity:
Check allowed quantity units for ME:
if ME is Procedure, then service_request.quantity.code can have values MINUTE or PIECE (system=SERVICE_UNIT)
if ME is Encounter or Diagnostic report, then service_request.quantity.code can have PIECE only
in case of error return error 409 ("<ME type> cannot be measured in <quantity.code's value>")
Check service_request remaining quantity parameter:
if quantity.code = PIECE:
count number of related MEs to the service request as used quantity.
calculate remaining quantity by subtracting used quantity and number of current MEs that are related to theΒ service request from service request's quantity
Validate remaining quantity is greater then or equal to zero
in case of error return 409 "The total amount of medical events exceeds quantity in related service request with <id>"
if quantity.code = MINUTE:
select related Procedures to the service request.
for each selected Procedure calculate duration as performedPeriod.end - performedPeriod.start without considering seconds. Result should be in minutes.
calculate used quantity as sum of procedure durations
calculate remaining quantity by subtracting used quantity and durations of current ProceduresΒ that are related to theΒ service requestΒ from service request's quantity
Validate remaining quantity is greater then or equal to zero
in case of error return 409 "The total amount of medical events exceeds quantity in related service request with <id>"
Related care plan validation
As for old care plan activities (has quantity w/o units) the amount of service request was no controlled, we should ensure that number of created medical events are not exceed its quantity:
Validate remaining_quantity in activitiesΒ referenced by service requests in the EDP using the algorithm described for a quantity without units (code=null) inΒ PreQualify Service Request#Validate-service-requestΒ . But also, addΒ theΒ reserved at the moment quantity,Β that includes the number of medical events in the EDP related to the activity, to the used_quantity.
Β
Processing
API paragraph not found
Β
Response structure
See on Apiary
Example:
Β
Β
Post-processing processes
Save signed_content to Media Storage
Save data to corresponding collections in DBs
Save link to the signed content to the encounter
Enrich encounter.diagnoses:
select condition.code from Medical Events DB(or from request body)Β where condition.id==diagnoses[@].condition.identifier.valueΒ
set diagnoses[@].code = select 1
Save diagnoses from encounter to episodes.current_diagnoses
ME.patients.episodes.diagnoses = $.encounter.diagnosesΒ
Add a record to the ME.patient.episodes{episode_id}.diagnoses_hstr
date = current_date
evidence = reference to encounterΒ ($.encounter.id)
diagnoses = $.encounter.diagnosesΒ
Generate accession_identifier number:
Generate requisition number (seeΒ Human readable requisition number) based on the specimen id. Note: requisition number should be unique for each specimen and should not match with number of another entities. So, if generated number match to existing in DB - it should be regenerated
Encode and set it into $.accession_identifier attributeΒ
Set display_value to employees for all submitted objects
Select PRM.parties.first_name, PRM.parties.second_name, PRM.parties.last_name from PRM.parties where (PRM.parties.id == (Select PRM.employees.party_id fromΒ PRM.employeesΒ whereΒ PRM.employees.id==Β $.care_manager.identifier.value))
ME.patients.encounters{encounter_id}.performer.display== Select 1
ME.conditions{condition_id}.asserter.displayΒ == Select 1
ME.observations{observation_id}.performer.display == Select 1
ME.patients.immunizations{immunization_id}.performer.display == Select 1
ME.patients.allergy_intolerance{ai_id}.asserter.display == Select 1
ME.patients.devices{device_id}.asserter.display == Select 1
ME.patients.medication_statements{ms_id}.asserter.display == Select 1
ME.patients.risk_assessment{rs_id}.asserter.display == Select 1
ME.patients.diagnostic_reports{dr_id}.performer.reference.display == Select 1
ME.patients.diagnostic_reports{dr_id}.recorded_by.reference.display == Select 1
ME.patients.diagnostic_reports{dr_id}.results_interpreter.reference.display == Select 1
ME.specimens{specimen_id}.registered_by.reference.display == Select 1
ME.specimens{specimen_id}.collector.reference.display == Select 1, if collector type is employeeΒ
In case there are reactions ($.observations[?].reaction_on) in the request, update corresponding immunizations with the reactions:
Set in ME.patient.immunization.reaction.detail $.observation.id as a reference
note:Β $.observations[?].reaction_on should not be saved in observation, only in corresponding immunization
SetΒ display_value for legal_entities
ME.patients.diagnostic_reports{dr_id}.managing_organization.display
ME.specimens{specimen_id}.managing_organization.display_value
Set managing_organization for submitted observations, conditions, encounter
ME.conditions{cond_id}.managing_organization=token.client_id
ME.observations{observ_id}.managing_organization=token.client_id
ME.encounters{encounter_id}.managing_organization=token.client_id
In case encounter.incoming_referral was filled, set episode_origin to encounter
Select episode where id== (select ME.encounter.episode.identifier.value where encounter.id==(select ME.service_requests.context.identifier.value where id==$.encounter.incoming_referral.identifier.value))
In case diagnostic_reports.based_on was filled, setΒ episode_origin to diagnostic report
Select episode where id== (select ME.encounter.episode.identifier.value where encounter.id==(select ME.service_requests.context.identifier.value where id==$.diagnostic_reports.based_on.identifier.value))
in case service request has reference on care plan and encounter.incoming_referralΒ was filled set $.encounter.id to related to $.service_request activity[].outcome_reference
in case service request has reference on care plan and procedures.based_on was filled set $.procedures.id to related to $.service_request $.activity[].outcome_reference
in case service request has reference on care plan and diagnostic_reports.based_onΒ was filled set $.diagnostic_reports.id to related to $.service_request activity[].outcome_reference
in case reference on service request has reference on care plan updateΒ $ .activity.status to in_progress if previous activity status was scheduled
in case reference on service request has reference on care plan update $ .activity.remaining_quantity parameter by subtracting the quantity of artifacts that have a reference on service request that contains an $.based_on.[]activity
If there are at least one record for speciality where speciality_officio = true:
Enrich encounter data with performer speciality:
SELECTΒ speciality -> 'speciality' FROM employees WHEREΒ speciality ->> 'speciality_officio' = 'true' AND id =Β $.encounter.performer.identifier.value
Β SetΒ encounter.performer_speciality as CodeableConcept type with system =Β SPECIALITY_TYPE
In case encounter.clinical_impression was filled set $.context_episode_id to clinical_impressions data model (encounters.context.[].episode.value=clinical_impression.context_episode_id)
If any available specimen, that has already stored in DB, is referenced in Observation or Diagnostic Report - change its (Specimen) status to unavailable in DB according to RC.__Specimen status model_EN . Also, set status_reason for a specimen: system = specimen_invalidate_reasons, code = used.
Set origin_episode (if $.based_on in request and $.based_on.service_request.context != null) for Diagnostic Report:
origin_episode is an object from the $.service_request.context.episode
Set origin_episode (if $.based_on in request and $.based_on.service_request.context != null) for Procedure:
origin_episode is an object from the $.service_request.context.episode d.
Set following fields for device dispense:
performer_legal_entity= client_id from token
details.quantity.unit = description according to quantity code and system
origin_episode_id= context_episode_id from device request referenced in based_on
context_episode_id = episode referenced by current encounter
If the Package contains Device Dispense in status completed, and related Device request has reference on an Activity as a device_request.based_on, then
add reference on the device dispense resource to theΒ outcome_reference attribute of the activity
if Activity.status is
scheduled
change it toin_progress
If the Package contains Device Dispense with related Device request that has a quantity but no medical program:
calculate remaining quantity of the related Device request (same as on https://e-health-ua.atlassian.net/wiki/spaces/EH/pages/17782015159#Service-logic):
Select all Device dispenses in status completed related to the Device request, including Device dispenses from the current package
Sum
quantity
in the filtered Device dispenses as dispensed_qtyCalculate remaining_quantity = requested_quantity-Β dispensed_quantity
If remaining_quantity is 0, change status of the related Device request($.based_on) to completed
Β
HTTP status codes
HTTP status code | Message | What caused the error |
---|---|---|
202 | Response | Β |
401 | Access denied | Β |
403 | Invalid scopes | Β |
404 | Patient not found | Β |
409 | Β | Validation error |
422 | Β | Validation error |
Β
ΠΠ‘ΠΠ - ΠΏΡΠ±Π»ΡΡΠ½Π° Π΄ΠΎΠΊΡΠΌΠ΅Π½ΡΠ°ΡΡΡ