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

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 36 Next »

Purpose

This WS gives the opportunity to create an unidentified person in eHealth. It means that person can be created w/o any information about it

Specification

Link

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

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

Resource

/api/prepersons

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

Scope

preperson:write

Scope для доступу

Components

Patient registry

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

Microservices

API paragraph not found

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

Protocol type

REST

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

Request type

POST

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

Sync/Async

Sync

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

Public/Private/Internal

Public

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

Logic

  1. Only authenticated and authorized SPECIALIST, ASSISTANT, RECEPTIONIST employees can register prepersons.

  2. Prepersons can be registered in OUTPATIENT and EMERGENCY legal entities.

  3. Prepersons shoul be registered only with external_id as a required field. Other are optional

  4. Preperson registers as separate record in MPI.prepersons table. On create ID of preperson sholdn’t match with ID of existent person.

  5. Service should return preperson_id.

Request structure

See on Apiary

Example:

 Request example
{
  "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"
}

Authorize

  1. Verify the validity of access token

    1. Return 401 in case validation fails

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

    1. Return 403 in case invalid scope(s)

Headers

Наприклад:

Content-Type:application/json

Authorization:Bearer c2778f3064753ea70de870a53795f5c9

api-key:uXhEczJ56adsfh3Ri9SUkc4en

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)

  3. Check legal entity has at least one healthcare service with status = ACTIVE and providing_condition = INPATIENT and speciality_type in PREPERSON_HEALTHCARE_SERVICES_SPECIALITY_TYPES variable (value should exist in SPECIALITY_TYPE dict)

    1. if no such healthcare services - return 409 (Legal entity does not have appropriate healthcare services)

Validate request

  • Validate request using schema (TBD)

  • Validate birth_date - must be <= today()

    • else error 422 "Birth date can't be in the future"

Validate external_id

  1. Check external_id is not empty.

    1. In case of error - return 422 (external_id should not be empty)

  2. Validate according to regexp - ^[0-9]{8,10}\.[0-9]{8,10}\.[0-9]{1,10}$

Processing

Generate preperson_id

  1. Generate preperson_id (will be returned in response). Ensure there is no such person_id in MPI.persons

  2. Generate patient_id to save it in patients collection (separate job).

Save object to DB

Insert preperson to MPI

prepersons table

Parameter

Source

Description

id

string

Autogenerated.

first_name

Request: first_name

second_name

Request: second_name

last_name

Request: last_name

gender

Request: gender

Gender, required. The values correspond to GENDER dictionary

birth_date

Request: birth_date

emergency_contact

Request: emergency_contact

death_date

date

By default is null on create

note

Request: note

status

string

Status, required. By default is “active”

external_id

Request: external_id

Identifier from external system. Required

is_active

bool

Technical flag. By default is true.

inserted_by

uuid

Extract user from token

inserted_at

timestamp

Get current date-time

updated_by

uuid

Extract user from token

updated_at

timestamp

Get current date-time

Response structure

See on Apiary

Example:

 Response example
{
  "meta": {
    "code": 201,
    "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"
  }
}

Post-processing processes

API paragraph not found

HTTP status codes

HTTP status code

Message

What caused the error

201

 Response

 

401

 

Access token validation failed

403

Invalid scope(s)

409

Validation failed

422

Validation failed

  • No labels