REST API method / Метод REST API (настанова) (remove the link block before publishing the REST API method / Метод REST API (настанова) (remove the link block before publishing the document)
Properties of a REST API method document
Document type | Метод REST API |
---|---|
Document title | [Document status] REST API [Назва методу] [ID методу] |
Guideline ID | GUI-0011 |
Author | @ |
Document version | 1 |
Document status | DRAFT |
Date of creation | ХХ.ХХ.ХХХХ (дата фінальної версії документа – RC або PROD) |
Date of update | ХХ.ХХ.ХХХХ (дата зміни версії) |
Method API ID | API-007-001-001-0218 |
Microservices (namespace) | ME |
Component | Care plan |
Component ID | COM-007-001 |
Link на API-специфікацію | |
Resource | {{host}}/api/patients/{{patient_id}}/care_plans |
Scope | care_plan:write |
Protocol type | REST |
Request type | POST |
Sync/Async | Async(def)/Sync |
Public/Private | Public |
...
Only authenticated and authorized user with employee_type from the list ofCARE_PLAN_AUTHOR_EMPLOYEE_TYPES_ALLOWED
config with appropriate speciality pointed in CARE_PLAN_<category>_SPECIALITIES_ALLOWEDconfig can create a Care plan.Care plan can be created from MSP, PRIMARY_CARE or OUTPATIENT legal entity.
Care plan can be created for persons and prepersons.
Care plan should be signed with DS.
Care plan creates in async way as all MEs.
Activities are added to a Care plan using Create Care Plan activity method. Thus, Care plan is being initially created without activities.
...
PROVIDING_CONDITION
Input parameters
Description of input parameters
Input parameter | Mandatory | Type | Description | Example | |
---|---|---|---|---|---|
1 | patient_id |
| String | MPI identifier of the person |
|
Request structure
See on API-specification (посилання на сторінку з API-специфікацією)
Description of the REST API request structure, example
Expand | ||
---|---|---|
| ||
|
...
Extract user_id from token. Check that author belongs to one of the user’s employee.
in case of error - return 422 ('User is not allowed to create care plan for the employee')
Check that author is an active and approved employee and related to the legal entity (client_id from token).
in case of error - return 403 ('Access denied')
Check author’s employee type:
for employees with employee_type from CARE_PLAN_AUTHOR_ROLE_CHECK_EMPLOYEE_TYPESconfig:
Сheck it has at least one employee role that:
is active and has active status
refers to healthcare service with providing_conditions=$.terms_of_service value
in case of error - return 422 ('Employee does not have active role that correspond to the submitted terms of service')
If DOCTOR, then no additional validations needed
Check author’s speciality (speciality_officio == true) pointed in config for a corresponding care plan category.
in case of error - return 409 (“Invalid employee speciality”)
...
Check the value is valid reference on encounter resource
Check encounter is active (status is not entered_in_error)
in case of error - return 422 ('Encounter in "entered_in_error" status can not be referenced')
Check encounter belongs to patient ($.subject)
in case of error - return 422 ('Encounter with such id is not found')
Check that encounter diagnosis is not empty in $.encounter.diagnosis
in case of error - return 422 ('Encounter without diagnosis can not be referenced')
Validate primary diagnosis Condition in the Encounter:
Check condition codes is in allowed condition code list for the care plan’s category (chart variables in config: for employee types: SPECIALIST, DOCTOR and MED_COORDINATOR)
in case of error - return 422 ('Primary diagnosis condition code and care plan category mismatch')
Check the condition system/codes has strict match with the value in the Addresses field
in case of error - return 422 ('Primary diagnosis condition codes do not match with codes in addresses') in case condition code in addresses is not the same as in the encounter diagnosis.
Validate Episode related to the Encounter:
exists
in case of error - return 422 ('Encounter refers to episode that does not exist')
is active
in case of error - return 422 ('Encounter refers to episode that is not active')
it’s managing organization matches with author’s legal entity (client_id)
in case of error - return 422 ('Encounter is from another legal entity')
...
Check that there is values from a dictionary
PROVIDING_CONDITION
.in case of error - return 422 ('value is not allowed in enum')
Check submitted value:
define allowed terms_of_service for employee_type using a set of chart variables CARE_PLAN_<employee_type>_TERMS_OF_SERVICE_ALLOWED
in case terms_of_service not allowed for the employee_type - return 422 ('Not allowed for <employee type>')
...
Check that $.period.start >= encounter.date (OR encounter.period.start)
in case of error and encounter.period.start - return 422 ('Care plan start date must be greater or equal than Encounter period start')
in case of error and encounter.date - return 422 ('Care plan start date must be greater or equal than Encounter start date')
Check that $.period.end >= $.period.start
in case of error - return 422 ('End date must be greater than or equal the start date')
...
Response structure examples
See on API-specification (посилання на сторінку з API-специфікацією)
Description of the REST API response structure, example
Expand | ||
---|---|---|
| ||
|
Expand | ||
---|---|---|
| ||
|
HTTP status codes
...
Response code
...
HTTP Status code
...
Message
...
Internal name
...
Description
...
Базові
...
codes
Response code | HTTP Status code | Message | Internal name | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | Базові | |||||||||||||||||||
2 | 201 | Response |
| |||||||||||||||||
3 | 202 | Response payload will be returned in the job details |
| |||||||||||||||||
4 | 202 | Use Get job details to get processing result. | ||||||||||||||||||
5 | 401 | Invalid access token |
| |||||||||||||||||
6 | 401 | Unauthorized |
| Помилка підтвердження | ||||||||||||||||
7 | 403 | Access denied | invalid scope(s) | |||||||||||||||||
8 | 403 | Access denied. Party is not verified | ||||||||||||||||||
9 | 403 | Your scope does not allow to access this resource. Missing allowances: care_plan:write | ||||||||||||||||||
10 | 1000 | 404 | Composition not found | COMPOSITION_NOT_FOUND_404 | Не знайдено медичний висновок | |||||||||||||||
311 | 201 | Response |
| 4 | 202 | Use Get job details to get processing result. Response payload will be returned in the job details |
| 5 | 401 | Invalid access token |
| 6 | 403 |
|
| 7 | 409 | client_id refers to legal entity that is not active | Validation failed | |
12 | 409 | client_id refers to legal entity with type that is not allowed to create medical events transactions | ||||||||||||||||||
13 | 409 | Care plan with such id already exists | ||||||||||||||||||
14 | 409 | Invalid employee speciality | ||||||||||||||||||
15 | 409 | Patient is not verified | ||||||||||||||||||
16 | 409 | Person is not active | ||||||||||||||||||
17 | 409 | Signer DRFO doesn't match with requester tax_id client_id refers to legal entity that is not active client_id refers to legal entity with type that is not allowed to create medical events transactions Person is not active Patient is not verified | ||||||||||||||||||
18 | 422 | Authentication method doesn't exist, is inactive or does not belong to this person | ||||||||||||||||||
19 | 422 | Care plan with such id already exists | Validation failed | 8is not found | ||||||||||||||||
20 | 422 | type mismatch or schema validation error list of validation errors in case validation failsCare plan start date must be greater or equal than Encounter period start | ||||||||||||||||||
21 | 422 | Care plan in status "<care_plan.status>" can not be referenced | ||||||||||||||||||
22 | 422 | Document must be signed by 1 signer but contains 0 signatures User is not allowed to create care plan for the employee | ||||||||||||||||||
23 | 422 | Employee does not have active role that correspond to the submitted terms of service Value is not allowed in enum | ||||||||||||||||||
24 | 422 | Encounter without diagnosis can not be referenced | ||||||||||||||||||
25 | 422 | Encounter refers to episode that does not exist | ||||||||||||||||||
26 | 422 | Encounter with such id is not found | ||||||||||||||||||
27 | 422 | Encounter without diagnosisin "entered_in_error" status can not be referenced Primary diagnosis condition code and care plan category mismatch Primary diagnosis condition codes do not match with codes in addresses | ||||||||||||||||||
28 | 422 | End date must be greater than or equal the start date | ||||||||||||||||||
29 | 422 | Encounter refers to episode that is not active | ||||||||||||||||||
30 | 422 | 14Encounter is from another legal entity
| 9 | 10 | 11 | |||||||||||||||
12 |
| 401 | Unauthorized |
| Помилка підтвердження | |||||||||||||||
13 | Специфічні | |||||||||||||||||||
31 | 422 | Invalid employee status | ||||||||||||||||||
32 | 422 | list of validation errors in case validation fails | ||||||||||||||||||
33 | 422 | <medical event type> with such ID is not found | ||||||||||||||||||
34 | 422 | Not allowed for <employee type> | ||||||||||||||||||
35 | 422 | Primary diagnosis condition codes do not match with codes in addresses | ||||||||||||||||||
36 | 422 | Primary diagnosis condition code and care plan category mismatch | ||||||||||||||||||
37 | 422 | type mismatch or schema validation error | ||||||||||||||||||
38 |
| 422 | Value is not allowed in enum | |||||||||||||||||
39 | 422 | User is not allowed to create care plan for the employee | ||||||||||||||||||
40 | Специфічні | |||||||||||||||||||
41 |
| 422 | Only for active MPI record can be created medication request! |
|
|
Post-processing processes
Description of actions performed on data after processing
Technical modules where the method is used
List of pages describing technical modules where the method is used
Название | ID ТМ | Статус |
---|---|---|
TM0112 | ||