ЕСОЗ - публічна документація

Update Preperson

Purpose

Method enables to modify all the preperson fields except note and status.

Specification

Link

https://ehealthmisapi1.docs.apiary.io/#reference/public.-medical-service-provider-integration-layer/preperson/update-preperson

Посилання на Apiary або Swagger

Resource

/api/prepersons/{{id}}

Посилання на ресурс, наприклад: /api/persons/create

Scope

preperson:write

Scope для доступу

Components

Patient registry

Зазначається перелік бізнес компонентів, які використовують цей метод, наприклад: ePrescription

Microservices

mpi/api

il/api (rpc)

fe/admin-web

Перелік мікросервісів, які використовує метод API, наприклад: Auth, ABAC

Protocol type

REST

Тип протоколу, який використовується запитом, наприклад: SOAP | REST

Request type

PATCH

Тип запиту API, наприклад: GET, POST, PATCH…

Sync/Async

Sync

Метод є синхронним чи асинхронним?

Public/Private/Internal

Public

Потрібно зазначити тип методу за ступенем доступності

Logic

  1. Only authenticated and authorized SPECIALIST, ASSISTANT, RECEPTIONIST employees can update external_id of preperson.

  2. Preperson can be updated only in OUTPATIENT or EMERGENCY legal entity type, if identifier of preperson is being known (returns after Create preperson).

  3. Only note and status fields can not be updated.

  4. Update allowed for prepersons with status = active.

Input parameters

Input parameter

Values

Type

Description

Example

Input parameter

Values

Type

Description

Example

id

 

String

MPI identifier of the preperson. Required

7c3da506-804d-4550-8993-bf17f9ee0402

Request structure

See on Apiary

Example:

{ "external_id": "#1234-FDS-ab", "first_name": "Петро", "last_name": "Іванов", "second_name": "Миколайович", "gender": "MALE", "birth_date": "1980-01-01", "emergency_contact": { "first_name": "Петро", "last_name": "Іванов", "second_name": "Миколайович", "phones": [ { "type": "MOBILE", "number": "+380503410870" } ] }, "death_date": "2018-11-11", "note": "Registered in SmartMed clinic at 01.01.2019 16:40. Male, 40 years old approximately, tatoo with sport motorcycle on the right forearm" }

Dictionaries

  • GENDER

  • PHONE_TYPE

Authorize

  1. Verify the validity of access token

    • return 401 in case validation fails

  2. Check user scopes in order to perform this action (scope = 'preperson:write')

    • return 403 in case invalid scope(s)

Headers

Content-Type:application/json

Authorization:Bearer {{access_token}}

Api-key:{{secret}}

Request data validation

Validate legal entity

Check that legal entity is active (status = ACTIVE) and belongs to the user

  1. Extract client_id from token

  2. Check legal entity status (status = ACTIVE)

    1. In case of error - return 409 (Legal entity must be ACTIVE)

Validate ID

Check ID exists and belongs to preperson

  1. Check ID exists in MPI.prepersons

    1. In case error - 404

  2. Check preperson has status=active

    1. In case error - return 422 (Preperson is not active)

Validate request

Validate request using schema (TBD)

  1. Check at least one of allowed field is submitted and has value:

    • first_name

    • last_name

    • second_name

    • gender

    • external_id

    • birth_date

    • emergency_contact

    • death_date

      • In case of error - return 422 (Schema validation failed)

    • note

  2. Check if any forbidden field is submitted:

  • status

    1. In case of error - return 422 (Schema validation failed)

Validate fields

  • Validate external_id according to regexp - 8-10.8-10.1-10 [0-9

  • Validate birth_date - must be <= today()

    • else error 422 "Birth date can't be in the future"Validate death_date < now():

    • In case of error - return 422 - “Death date can not be in future”

  • Validate death_date > = birth_date:

    • else error 422 "Death date should equal or greater than birth_date"

  • If death_date submitted, set mpi.preperson.status = inactive

Processing

Update object in DB

prepersons table

Parameter

Source

Description

Parameter

Source

Description

external_id

Request: external_id

Identifier from external system. Get from request body

first_name

Request: first_name

 

second_name

Request: second_name

 

last_name

Request: last_name

 

gender

Request: gender

 

birth_date

Request: birth_date

 If submitted, set status = inactive

emergency_contact

Request: emergency_contact

 

death_date

Request: death_date

 

note

Request: note

 

updated_at

timestamp: now()

Get current date-time

updated_by

uuid

Extract user from token

Response structure

See on Apiary

Example:

{ "meta": { "code": 200, "url": "https://example.com/resource", "type": "object", "request_id": "6617aeec-15e2-4d6f-b9bd-53559c358f97#17810" }, "data": { "id": "7c3da506-804d-4550-8993-bf17f9ee0402", "external_id": "#1234-FDS-aa", "first_name": "Петро", "last_name": "Іванов", "second_name": "Миколайович", "gender": "MALE", "birth_date": "1980-01-01", "emergency_contact": { "first_name": "Петро", "last_name": "Іванов", "second_name": "Миколайович", "phones": [ { "type": "MOBILE", "number": "+380503410870" } ] }, "note": "Registered in SmartMed clinic at 01.01.2019 16:40. Male, 40 years old approximately, tatoo with sport motorcycle on the right forearm", "status": "ACTIVE", "death_date": "2018-11-11", "inserted_at": "2017-04-20T19:14:13Z", "inserted_by": "e1453f4c-1077-4e85-8c98-c13ffca0063e", "updated_at": "2017-04-20T19:14:13Z", "updated_by": "2922a240-63db-404e-b730-09222bfeb2dd" } }

HTTP status codes

HTTP status code

Message

What caused the error

HTTP status code

Message

What caused the error

200

 Response

 

401

 

Access token validation failed

403

 

Invalid scope(s)

404

 

Validation failed

409

Legal entity must be ACTIVE

Validation failed

422

Preperson is not active

Schema validation failed

Birth date can't be in the future

Death date can not be in future

Death date should equal or greater than birth_date

Validation failed

 

 

 

 

ЕСОЗ - публічна документація