Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Page Properties
idENT-005-011-006

ID метода

API-005-011-006-0201

Автор

Viacheslav Tybin (SoE eHealth)

Версія документа

1.0

Статус документа

Status
titledraft

Назва метода (укр.)

Оновлення MPI

Назва метода (eng.)

Update MPI

Короткий опис метода

Для зміни пацієнтом персональних даних в кабінеті.

...

Note

Сторінка знаходиться в процесі розробки. Інформація на ній може бути застарілою.

/wiki/spaces/EN/pages/17591304241 (remove the link block before publishing the document)

Properties of a REST API method document

Document type

Метод REST API

Document title

[DRAFT] Update MPI [API-005-010-006-0205]

Guideline ID

GUI-0011

Author

Viacheslav Tybin (SoE eHealth)

Document version

1

Document status

DRAFT

Date of creation

ХХ.ХХ.ХХХХ (дата фінальної версії документа – RC або PROD)

Date of update

ХХ.ХХ.ХХХХ (дата зміни версії)

Method API ID

API-005-010-006-0205

Microservices (namespace)

IL

Component

Patient Cabinet

Component ID

COM-005-010

Link на API-специфікацію

https://ehealthmisapi1.docs.apiary.io/#reference/public.-patient-cabinet/cabinet/update-mpi

Resource

{{host}}/api/cabinet/persons/{{id}}

Scope

person:write

Protocol type

REST

Request type

PATCH

Sync/Async

Sync

Public/Private

Public

Purpose

This WS is designed to change some personal information in cabinet by patient. Method receives signed message (pkcs7) including signed content, digital signature and signer public key. All signature fields will be validated (including signer certificate authority).

Overview

  • patient could change only its own information

  • patient should sign changes to mpi with DS. Signed content should be saved to storage

  • the payload for upload mpi should be the same as for sign-up

  • on get mpi by id we do not show "process_disclosure_data_consent", but sign it with DS and save it to the storage with all data

  • Only patients that made sign-in to cabinet with DS has scope "person:write", otherwise only person:read. 

Logic

9d5390cc-b10d-444e-99ad-66ab3470d982.png

Configuration parameters

Description of the configuration parameters that are used when processing a request in the systemN/A

Dictionaries

  • GENDER

  • DOCUMENT_TYPE

  • ADDRESS_TYPE

  • COUNTRY

  • SETTLEMENT_TYPE

  • STREET_TYPE

  • PHONE_TYPE

  • AUTHENTICATION_METHOD

  • PREFERRED_WAY_COMMUNICATION

Input

...

parameters

Composition object ID

Input parameter

Mandatory

Type

Description

Example

1

composition_id

 M

String ($uuid) (path)

 89678f60-4cdc-4fe3-ae83-e8b3ebd35c59

2

 

 

 

 

 

Request structure

See on API-specification (посилання на сторінку з API-специфікацією)

Description of the REST API request structure, example

Expand
titleExample
Code Block
{
  "signed_request": "`MIIUKAYJKoZIhvcNAQcCoIIUGTCCFBUCAQExDjAMBgoqhiQCAQEBAQIBMIIGRgYJKoZIhvcNAQcBoIIGNwSCBjN7CiAgICAiZmlyc3RfbmFtZSI6ICLQn9C10YLRgNC+IiwKICAgICJsYXN0X25hbWUiOiAi0IbQstCw0L3QvtCyIiwKICAgICJzZWNvbmRfbmFtZSI6ICLQnNC40LrQvtC70LDQudC+0LLQuNGHIiwKICAgICJiaXJ0aF9kYXRlIjogIjE5OTEtMDgtMTkiLAogICAgImJpcnRoX2NvdW50cnkiOiAi0KPQutGA0LDRl9C90LAiLAogICAgImJpcnRoX3NldHRsZW1lbnQiOiAi0JLRltC90L3QuNGG0Y8iLAogICAgImdlbmRlciI6ICJNQUxFIiwKICAgICJlbWFpbCI6ICJlbWFpbEBleGFtcGxlLmNvbSIsCiAgICAidGF4X2lkIjogIjMxMjY1MDk4MTYiLAogICAgInNlY3JldCI6ICJzZWNyZXQiLAogICAgImRvY3VtZW50cyI6IFsKICAgICAgewogICAgICAgICJ0eXBlIjogIlBBU1NQT1JUIiwKICAgICAgICAibnVtYmVyIjogIjEyMDUxOCIsCiAgICAgICAgImlzc3VlZF9ieSI6ICLQoNC+0LrQuNGC0L3Rj9C90YHRjNC60LjQvCDQoNCSINCT0KMg0JzQktChINCa0LjRl9Cy0YHRjNC60L7RlyDQvtCx0LvQsNGB0YLRliIsCiAgICAgICAgImlzc3VlZF9hdCI6ICIyMDE3LTAyLTI4IgogICAgICB9CiAgICBdLAogICAgImFkZHJlc3NlcyI6IFsKICAgICAgewogICAgICAgICJ0eXBlIjogIlJFU0lERU5DRSIsCiAgICAgICAgImNvdW50cnkiOiAiVUEiLAogICAgICAgICJhcmVhIjogItCW0LjRgtC+0LzQuNGA0YHRjNC60LAiLAogICAgICAgICJyZWdpb24iOiAi0JHQtdGA0LTQuNGH0ZbQstGB0YzQutC40LkiLAogICAgICAgICJzZXR0bGVtZW50IjogItCa0LjRl9CyIiwKICAgICAgICAic2V0dGxlbWVudF90eXBlIjogIkNJVFkiLAogICAgICAgICJzZXR0bGVtZW50X2lkIjogIjQzNDMyNDMyIiwKICAgICAgICAic3RyZWV0X3R5cGUiOiAiU1RSRUVUIiwKICAgICAgICAic3RyZWV0IjogItCy0YPQuy4g0J3RltC20LjQvdGB0YzQutCwIiwKICAgICAgICAiYnVpbGRpbmciOiAiMTUiLAogICAgICAgICJhcGFydG1lbnQiOiAiMjMiLAogICAgICAgICJ6aXAiOiAiMDIwOTAiCiAgICAgIH0KICAgIF0sCiAgICAicGhvbmVzIjogWwogICAgICB7CiAgICAgICAgInR5cGUiOiAiTU9CSUxFIiwKICAgICAgICAibnVtYmVyIjogIiszODA1MDM0MTA4NzAiCiAgICAgIH0KICAgIF0sCiAgICAiYXV0aGVudGljYXRpb25fbWV0aG9kcyI6IFsKICAgICAgewogICAgICAgICJ0eXBlIjogIk9UUCIsCiAgICAgICAgInBob25lX251bWJlciI6ICIrMzgwNTA4ODg3NzAwIgogICAgICB9CiAgICBdLAogICAgInByZWZlcnJlZF93YXlfY29tbXVuaWNhdGlvbiI6ICJlbWFpbCIsCiAgICAiZW1lcmdlbmN5X2NvbnRhY3QiOiB7CiAgICAgICJmaXJzdF9uYW1lIjogItCf0LXRgtGA0L4iLAogICAgICAibGFzdF9uYW1lIjogItCG0LLQsNC90L7QsiIsCiAgICAgICJzZWNvbmRfbmFtZSI6ICLQnNC40LrQvtC70LDQudC+0LLQuNGHIiwKICAgICAgInBob25lcyI6IFsKICAgICAgICB7CiAgICAgICAgICAidHlwZSI6ICJNT0JJTEUiLAogICAgICAgICAgIm51bWJlciI6ICIrMzgwNT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vdGW0YHRgtC10YDRgdGC0LLQviDRjtGB0YLQuNGG0ZbRlyDQo9C60YDQsNGX0L3QuDExMC8GA1UECwwo0JDQtNC80ZbQvdGW0YHRgtGA0LDRgtC+0YAg0IbQotChINCm0JfQnjFJMEcGA1UEAwxA0KbQtdC90YLRgNCw0LvRjNC90LjQuSDQt9Cw0YHQstGW0LTRh9GD0LLQsNC70YzQvdC40Lkg0L7RgNCz0LDQvTEZMBcGA1UEBQwQVUEtMDAwMTU2MjItMjAxMjELMAkGA1UEBhMCVUExETAPBgNVBAcMCNCa0LjRl9CyAhQwBHUd7yx4rgIAAAABAAAASgAAADANBgsqhiQCAQEBAQMBAQRAHzpSvoXA50haDgvvHvYN/umJ1WUaZgVtKsTJ2AfICAaQlVPrO+v1nIeX6/KpgtOAu2SN4AWe6dzCfB/09aedYDANBgsqhiQCAQEBAQMBAQRAA4cSEkGh+nTfIz27J2BxCNTO+Jm44SVy+plack1vXjlgGCqYNFu6NVMglvkClreOes6+yEojxb/xaOkX6AgfQQ=="
}

Headers

...

Headers

...

Request data validation

...

Mandatory

...

Description

...

Example

...

Content-Type

...

application/json

...

M

...

Тип контенту

...

Content-Type:application/json

...

 

...

 

...

 

...

 

...

 

...

Authorize

  • Verify the validity of access token

    • Return 401 in case validation fails

Validate client type

  • Check client_type = cabimet

    • in case error return 403 forbidden

Validate token

Only patients that made sign-in to cabinet with DS has scope "person:write", othewise only person:read. 

  • Extract user_id from token.

  • Check if users.person_id=$.persons.id

    • in case error return 403

  • Check scopes person:write

    • in case error return 403 - "Your scope does not allow to access this resource. Missing allowances: person:write"

Validate MPI

  • Check mpi.persons.status = 'active'

    • in case error return 409

Sign MPI 

All mpi that are saved to DB should be signed by digital signature. Signed fields for update person should be the same as signed fields for create person.

...

name

type

o/m

last_name

varchar

M

first_name

varchar

M

second_name

varchar

O

birth_date

date

M

birth_country

varchar

M

birth_settlement

varchar

M

gender

varchar

M

email

varchar

O

tax_id

varchar

O

documents

jsonb[ ] 

M

addresses

jsonb[ ]

M

phones

jsonb[ ] 

O

secret

varchar

O

emergency_contact

jsonb

M

process_disclosure_data_consent

boolean

M

authentication_methods

jsonb

M

preferred_way_communication

varchar

M

Validate request

  • Validate request using JSON schema

    • in case error return - 422

  • Check authentication number in verification DB

    • in case error return 422 - authentication number is not verified

  • Check last_name, first_name, tax_id was not changed

    • in case error return 403 - forbidden "fields last_name, first_name, tax_id could not be changed from cabinet"

  • Check $.gender in dictionaries.GENDER

    • in case error return 422 - value is not allowed in enum

  • Check $.documents.type in dictionaries.DOCUMENT_TYPE

    • in case error return 422 - value is not allowed in enum

  • Check person age < 14 and DOCUMENT_TYPE = BIRTH_CERTIFICATE

    • in case error return 422  - Must contain required item BIRTH_CERTIFICATE.

  • Check $.phones.type in dictionaries.PHONE_TYPE

    • in case error return 422 - value is not allowed in enum

  • Check authentication_methods

    • $.authentication_methods in dictionaries.AUTHENTICATION_METHOD 

      • in case error return 422 - value is not allowed in enum

    • $.authentication_methods=OPT

      • in case error return 422 - OFFLINE method could not be used in cabinet 

  • Check adresses

    • $.addresses.type in dictionaries.ADDRESS_TYPE

    • $.addresses.settlement_type in dictionaries.SETTLEMENT_TYPE

    • $.addresses.street_type in dictionaries.STREET_TYPE

      • in case error return 422 - value is not allowed in enum

    • $.settlement = uaddresses.settlements.name and $.settlement_id = uaddresses.settlements.id

      • in case error return 422- invalid settlement value

Validate DS

Extract party from token

Extract tax_id from DS

  • Check if user.tax_id = DS.tax_id = person.tax_id = $.tax_id

    • in case error return 409 (Person that loged in, person that is changed and person that sign should be the same)

Processing

Update data in DB, save signed content to media storage

Response structure examples

See on API-specification (посилання на сторінку з API-специфікацією)

Description of the REST API response structure, example

Expand
titleExample
Code Block
languagejson
{
  "meta": {
    "code": 200,
    "url": "https://example.com/resource",
    "type": "object",
    "request_id": "6617aeec-15e2-4d6f-b9bd-53559c358f97#17810"
  },
  "data": {
    "first_name": "Петро",
    "last_name": "Іванов",
    "second_name": "Миколайович",
    "birth_date": "1991-08-19",
    "birth_country": "Україна",
    "birth_settlement": "Вінниця",
    "gender": "MALE",
    "email": "email@example.com",
    "tax_id": "3126509816",
    "secret": "secret",
    "documents": [
      {
        "type": "PASSPORT",
        "number": "АА120518",
        "expiration_date": "2021-02-28",
        "issued_by": "Рокитнянським РВ ГУ МВС Київської області",
        "issued_at": "2017-02-28"
      }
    ],
    "addresses": [
      {
        "type": "RESIDENCE",
        "country": "UA",
        "area": "Житомирська",
        "region": "Бердичівський",
        "settlement": "Київ",
        "settlement_type": "CITY",
        "settlement_id": "b075f148",
        "street_type": "STREET",
        "street": "вул. Ніжинська",
        "building": "15",
        "apartment": "23",
        "zip": "02090"
      }
    ],
    "phones": [
      {
        "type": "MOBILE",
        "number": "+380503410870"
      }
    ],
    "authentication_methods": [
      {
        "type": "OTP",
        "phone_number": "+38093*****85"
      }
    ],
    "preferred_way_communication": "email",
    "unzr": "19900101-00099",
    "emergency_contact": {
      "first_name": "Петро",
      "last_name": "Іванов",
      "second_name": "Миколайович",
      "phones": [
        {
          "type": "MOBILE",
          "number": "+380503410870"
        }
      ]
    },
    "process_disclosure_data_consent": true
  }
}

HTTP status codes

Unauthorized

Response code

HTTP Status code

Message

Internal name

Description

1

Базові

2

200

 Response

 

3

401

 

Помилка підтвердження

4

403

Fields last_name, first_name, tax_id could not be changed from cabinet

Validation failed

54

403

Your scope does not allow to access this resource. Missing allowances: person:write

6

1000

404

Composition not found

COMPOSITION_NOT_FOUND_404

Не знайдено медичний висновок

75

409

Person that loged in, person that is changed and person that sign should be the same

Validation failed

86

422

Authentication number is not verified

Validation failed

97

422

Invalid settlement value

108

422

Must contain required item BIRTH_CERTIFICATE

119

422

OFFLINE method could not be used in cabinet

1210

422

Value is not allowed in enum

1311

Специфічні

14

 

422

Only for active MPI record can be created medication request!

 

 

12

 

Post-processing processes

Description of actions performed on data after processing

Technical modules where the method is used

List of pages describing technical N/A

Technical modules where the method is used