Info |
---|
/wiki/spaces/EN/pages/17591304241 (remove the link block before publishing the document) |
Table of Contents |
---|
Properties of a REST API method document
Page Properties | ||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||||||||||||||||||||
|
Purpose
This WS is designed to create a new procedure separately from encounter pckg.
Logic
Procedure can be registered in eHealth as a part of encounter pckg or just by itself with reference on Service Request. Procedure should be registered in the system after it was performed for a patient.
Реєстрація запису про проведену процедуру в ЦК
Configuration parameters
Description of the configuration parameters that are used when processing a request in the system
Dictionaries
Provides a list of links to dictionaries that are available in Confluence
Input parameters
Input parameter | Mandatory | Type | Description | Example | |
---|---|---|---|---|---|
1 | patient_id |
| String | Unique patient identifier |
|
Request structure
See on Apiary
See on API-specification
Expand | ||
---|---|---|
| ||
|
Headers
Key | Value | Mandatory | Description | Example | |
---|---|---|---|---|---|
1 | Content-Type | application/json | M | Тип контенту | Content-Type:application/json |
2 | Authorization | Bearer {{access_token}} | Authorization:Bearer {{access_token}} | ||
3 | API-key | {{secret}} | API-key:{{secret}} |
Request data validation
Authorize
Verify the validity of access token
return 401 ('Unauthorized') in case of validation fails
Verify that token is not expired
in case of error - return 401 ('Unauthorized')
Check user scopes in order to perform this action (scope = 'procedure:write')
Return 403 ('Invalid scopes') in case of invalid scope(s)
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")
Validate digital signature
Decode content that is encrypted in an electronic digital signature.
Use Digital signature WS. Method checks digital signature and returns result.
See service specification
...
Code Block |
---|
SELECT p.tax_id FROM employees e, parties p WHERE e.party_id = p.id AND e.id = :recorded_by; |
Validate request using JSON Schema
Return 422 with the list of validation errors in case validation fails
Validate procedure
Validate id
ID is unique for MongoDB.procedures
ID is UUID
Validate referrals
As a referral it can be referenced electronic (registered in the system) OR paper service request
Validate $.procedure.based_on OR $.procedure.paper_referral is in request
Validate based_on as Reference(Referencevalidation)
Validate paper referral as Object (paper_referral)
Validate that service_request is
in status is active
in case of error return 409 "Invalid service request status"
if used_by_legal_entity != NULL:
check used_by_legal_entity.identifier.value == token.client_id
in case of error return 409 "Service request is used by another legal_entity"
service_request.expiration date should be >= now
in case error return 422, "Service request expiration date must be a datetime greater than or equal"
check that service_request contains based_on parameter
in case based_on present in service_request
verify care_plan:
It should be in active status
Care plan's period end (if exist) should be greater than current date or equal.
verify activity:
It has activity.detail.kind=service_request; activity.detail.product_reference=service_id.
It has scheduled, in_progress status
For an old activities (has no units in quantity) validate remaining_quantity as described at Submit Encounter Data Package: Related care plan validation
in case based_on not present in request skip previous validations.
Check if service request quantity is not exhausted as described at Submit Encounter Data Package: Related service request validation
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
Note. For procedure.code pass only "service", and the "service_group" does not passValidate code as Reference(Referencevalidation)
If service_requests.code.identifier.value is service, validate $procedure.code.identifier.value = service_requests.code.identifier.value
in case error return 409, "Service in procedure differ from service in service request"
if service_requests.code.identifier.value is service_group, validate $procedure.code.identifier.value in (SELECT service_id from service_inclusions where service_group_id='service_requests.code.identifier.value')
in case error return 409, "Service in procedure differ from services in service request's service_group"
Validate procedure.service.is_active = true
in case error return 409, "Service should be active"
Validate performed_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, entry: "$.performed_period", rules[0].description: "can't be blank"
Validate recorded_by
Validate recorded_by as Reference(Referencevalidation)
$..recorded_by.identifier.value is an ID of existing employee in PRM.employee
in case of error return 422, "Employee with such id is not found"
Validate recorded_by is employee with status='APPROVED' and is_active= true and end_date is null or more than today and PRM.employees.employee_type in ('DOCTOR','SPECIALIST','ASSISTANT')
in case error return 409, "This action is prohibited for current employee"
Validate employees.legal_entity_id=$managing_organization.identifier.value
in case error return 409, "Employee should be from current legal entity"
Performer(asserter) validation
case $..primary_source==true
$..performer(or $..asserter) must be filled
in case of error "Performer (asserter) must be filled"
$..report_origin must be absent
in case of error "Report_origin can not be submitted in case primary_source is true"
validate performer(asserter) is a valid value from corresponding dictionary
$..performer.identifier.type.coding[*].system == "eHealth/resources"
in case of error "Submitted system is not allowed for this field"
$..performer.identifier.type.coding[*].code=="employee"
in case of error "Submitted code is not allowed for this field"
validate performer(asserter) is an active medical staff from current legal_entity
$..performer.identifier.value is an ID of existing employee in PRM.employee
in case of error "Employee with such id is not found"
$..performer.identifier.value == PRM.employees.id where (PRM.employees.status == "APPROVED" and PRM.employees.employee_type in ('DOCTOR','SPECIALIST','ASSISTANT'))
case primary_source=false
error 422. (Procedure with primary_source=false could be send only with encounter package)
Validate division
Validate division as Reference(Referencevalidation)
$division is an ID in PRM.divisions
in case return 422, "Division with such id is not found"
division.status=ACTIVE and is_active=true
in case error return 409, "Division is not active"
division.legal_entity_id = $client_id
in case error return 409, "Division is not in current legal_entity"
Validate managing_organization is a current active legal_entity with proper type
as Reference(Referencevalidation)
$managing_organization is an ID in PRM.legal_entities
in case return 422, "Legal entity with such id is not found"
validate managing_organization status is 'ACTIVE' and is_active=true
in case error return 422 ('Legal entity is not active')
validate legal_entity type is in ('PRIMARY_CARE','MSP','MSP_PHARMACY','MSP_PHARMACY') (use `ME_ALLOWED_TRANSACTIONS_LE_TYPES` from charts)
in case error return 422, "Legal entity with type $legal_entity.type cannot perform procedures"
validate $managing_organization.identifier.value = $client_id
in case of error 409 "Managing organization does not correspond to user's legal entity."
Validate reason_references
Validate reason_reference as a Reference (Referencevalidation)
Validate reason_refernce.identifier.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, "<Medical event resource> in "entered_in_error" status can not be referenced"
Validate outcome
validate outcome as a Reference (Referencevalidation)
validate outcome.coding.object.system is in dictionary eHealth/procedure_outcomes
in case error return 422, "outcome not in dictionary eHealth/procedure_outcomes"
Validate category
according to the dictionary 'eHealth/procedure_categories' - by schemata
Validate that procedure category corresponds to service category, that is references as code in procedure
$.procedure.category=PRM.services.category where PRM.services.id=$.procedure.code.identifier.value
in case of error return 422 "Procedure category does not match with the service category"
If patient is person - validate verification status:
If procedure has based_on with service request, then skip this validation.
Else check patient verification_status is not equal to NOT_VERIFIED.
in case NOT_VERIFIED - return error 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"
Processing
A list of processes related to receiving, changing or transmitting data according to the logic defined in the REST API
Response structure examples
See on Apiary
See on API-specification
Expand | ||
---|---|---|
| ||
|
HTTP status codes
Response code | HTTP Status code | Message | Internal name | Description | |
---|---|---|---|---|---|
1 | Базові | ||||
2 | 202 |
|
| ||
3 | 401 | Access denied |
| ||
4 | 403 | Access denied. Party is not verified | |||
5 | 403 | Invalid scopes |
| ||
6 | 404 | Patient not found |
| ||
7 | 409 | Division is not active | |||
8 | 409 | Division is not in current legal_entity | |||
9 | 409 | Employee should be from current legal entity | |||
10 | 409 | Invalid service request status | |||
11 | 409 | Managing organization does not correspond to user's legal entity. | |||
12 | 409 | Patient is not verified | |||
13 | 409 | Service request is used by another legal_entity | |||
14 | 409 | Service in procedure differ from service in service request | |||
15 | 409 | Service should be active | |||
16 | 409 | This action is prohibited for current employee | |||
17 | 409 | Value is not active | |||
18 | 422 |
| Validation error | ||
19 | 422 | Division with such id is not found | |||
20 | 422 | End date must be greater than start date | |||
21 | 422 | Employee with such id is not found | |||
22 | 422 | Legal entity with such id is not found | |||
23 | 422 | Legal entity is not active | |||
24 | 422 | Legal entity with type $legal_entity.type cannot perform procedures | |||
25 | 422 | <Medical event resource> in "entered_in_error" status can not be referenced | |||
26 | 422 | Only one of the parameters must be present | |||
27 | 422 | outcome not in dictionary eHealth/procedure_outcomes | |||
28 | 422 | Performed_date_time in invalid | |||
29 | 422 | Procedure category does not match with the service category | |||
30 | 422 | Procedure with primary_source=false could be send only with encounter package | |||
31 | 422 | Procedure cannot be registered in future | |||
32 | 422 | $.performed_period", rules[0].description: "can't be blank | |||
33 | 422 | $.performed_period" (or "$.performed_date_time"), rules[0].description: "Must not be present in procedure with status <$.status> | |||
34 | 422 | Service request expiration date must be a datetime greater than or equal | |||
35 | 422 | value is not allowed in enum | |||
36 | Специфічні | ||||
37 |
Post-processing processes
Save signed_content to Media Storage
Save data to corresponding collection in DB
In case procedures.based_on was filled set $.procedures.id to related to $.service_request $.activity[].outcome_reference
Update $ .activity.status to in_progress if previous activity status was scheduled
Update the $ .activity.remaining_quantity parameter by the value achieved at Submit Encounter Data Package: Related care plan validation (for an old activities only that has no quantity units)
Update remaining_quantity in the service request with a value that was calculated in the Submit Encounter Data Package: Related care plan validation
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
Technical modules where the method is used
List of pages describing technical modules where the method is used
Page Properties Report | ||||
---|---|---|---|---|
|
...