ЕСОЗ - публічна документація
[DRAFT] PIS. Terminate declaration [API-013-001-001-0470]
https://e-health-ua.atlassian.net/wiki/spaces/EN/pages/17591304241 (remove the link block before publishing the document)
- 1 Properties of a REST API method document
- 2 Purpose
- 3 Logic
- 3.1 Service logic
- 4 Configuration parameters
- 5 Dictionaries
- 6 Input parameters
- 7 Request structure
- 8 Headers
- 9 Request data validation
- 10 Processing
- 11 Response structure examples
- 12 HTTP status codes
- 13 Post-processing processes
- 14 Technical modules where the method is used
Properties of a REST API method document
Document type | Метод REST API |
---|---|
Document title | [DRAFT] PIS. Terminate declaration [API-013-001-001-0470] |
Guideline ID | GUI-0011 |
Author | @ |
Document version | 1 |
Document status | DRAFT |
Date of creation | ХХ.ХХ.ХХХХ (дата фінальної версії документа – RC або PROD) |
Date of update | ХХ.ХХ.ХХХХ (дата зміни версії) |
Method API ID | API-013-001-001-0470 |
Microservices (namespace) | OPS |
Component | Declaration |
Component ID | COM-013-001 |
Link на API-специфікацію | |
Resource | {{host}}/api/pis/declarations/{{id}}/actions/terminate |
Scope | declaration:terminate_pis |
Protocol type | REST |
Request type | PATCH |
Sync/Async | Sync |
Public/Private | Public |
Purpose
This WS is designed to terminate active declaration by Patient.
Logic
Service logic
Update declaration in ops.declarations table:
set status = 'TERMINATED'
set reason_description = $.reason_description from request
set declarations.reason to `manual_person`
Add new status to event manager
field | value |
---|---|
|
|
|
|
| $.id |
| $.status |
| $.update_at |
| $.changed_by |
Configuration parameters
N/A
Dictionaries
N/A
Input parameters
Input parameter | Mandatory | Type | Description | Example | |
---|---|---|---|---|---|
1 |
|
|
|
|
|
2 |
|
|
|
|
|
Request structure
See on API-specification
Headers
Request data validation
Authorization
Verify the validity of access token
in case of error - return 401 (“Invalid access token”) in case of validation fails
Verify that token is not expired
in case of error - return 401 (“Invalid access token”)
Check user scopes in order to perform this action (scope = 'declaration:terminate_pis')
return 403 (“Your scope does not allow to access this resource. Missing allowances: ‘declaration:terminate_pis’) in case of invalid scope(s)
Validation
Validate Person
Get person_id from token (x-person-id header)
Validate patient status is active (status = ‘active' & is_active = 'true’)
in case of error - return 404 ('not found')
Validate verification status of person not NOT_VERIFIED
in case of error - return return 403 ("Access denied. Person is not verified")
Validate confidant person and relationship (optional)
If person is not legally capable - system must ensure that declaration is terminated by confidant person and there is registered and verified their relationship
Get applicant_person_id
from token, compare it to person_id
from token:
If equals - check that person must not be authorized by confidant person, so it doesn’t correspond to following rules:
persons age < no_self_registration_age global parameter;
persons age between no_self_registration_age and person_full_legal_capacity_age global parameters and person does not have document with type from PIS_PERSON_LEGAL_CAPACITY_DOCUMENT_TYPES config parameter;
persons age > person_full_legal_capacity_age global parameter and exists at least one active and approved confidant person relationship for person (using following process https://e-health-ua.atlassian.net/wiki/spaces/PCAB/pages/17415995422 with person_id = person from request - expected
:ok, :approved
response)In case of error - return 409 (‘Request must be authorized by confidant person’)
If not equal - validate relationship with following steps:
Check that there is registered relationship between
person_id
andapplicant_person_id
(MPI.confidant_person_relationships)Check that relationship is VERIFIED
In case of error - return 409 (‘Can’t confirm relationship’)
Check that
applicant_person_id
exists (status = 'active' & is_active = 'true') and has verification_status any butNOT_VERIFIED
In case of error - return 409 (‘Confidant person not found or is not verified’)
Validate Declaration
Check that declaration with such ID:
exists in the system (ops DB)
belongs to patient
in case of error - return 404 ('not found')
Check declaration status = active
in case of error return 403. Message: ‘Declaration is not active’
Processing
N/A
Response structure examples
See on API-specification
HTTP status codes
Response code | HTTP Status code | Message | Internal name | Description | |
---|---|---|---|---|---|
1 | Базові | ||||
2 |
|
|
|
|
|
3 |
|
|
|
|
|
4 | Специфічні | ||||
5 |
|
|
|
|
|
Post-processing processes
N/A
Technical modules where the method is used
Название |
---|
|
Related content
ЕСОЗ - публічна документація