Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents

Purpose

...

Table of Contents

Purpose

The method is used to register new employee or to update an existing one. There are two different flows of registration depending on whether the employee has tax_id or doesn't have one.

...

Page Properties

Link

 https://ehealthmisapi1.docs.apiary.io/#reference/public.-medical-service-provider-integration-layer/employee-requests/create-employee-request-v2

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

Resource

 /api/v2/employee_requests

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

Scope

 employee_request:write

Scope для доступу

Components

Employees

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

Microservices

il/api

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

Protocol type

 REST

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

Request type

 POST

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

Sync/Async

 Sync

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

Public/Private/Internal

 Public

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

Dummy for employee request

https://ehealthmisapi1.docs.apiary.io/#reference/dummy-methods/dummy-for-employee-request/create-employee-request-v2

Посилання на приклад запиту перед підписанням КЕП

Logic

...

Dictionaries

  • POSITION

  • EMPLOYEE_TYPE

  • GENDER

  • +DOCUMENT_TYPE

  • COUNTRY

  • EDUCATION_DEGREE

  • QUALIFICATION_TYPE

  • PHONE_TYPE

  • SPECIALITY_TYPE

  • SPECIALITY_LEVEL

  • SPEC_QUALIFICATION_TYPE

...

There is an object “<employee_type>” (“doctor”, “assistant”, “specialist”…) in the body of the “employee_request”; <employee_type> is the same as employee to be created (DOCTOR, ASSISTANT, SPECIALIST, etc). Required for the employees with mandatory medical education (“doctor”, “assistant”, “specialist”, “laborant”, “med_coordinator”, ”med_admin”, ”pharmasist”).

  1. if employee_type == PHARMACY_EMPLOYEE_TYPES check division_id

    1. if division_id is absent - return error 422 "division_id should be specified"

Validate request (Logic)

  1. Check employee_type: Employee configurable validation rules and dictionaries

  2. If employee_id is passed in the payload:

    1. search employees by employee_id

      1. if not found - return error 404else check *

    2. check that employee_type not in (OWNER, PHARMACY_OWNER)

      1. in case of error - return 409 “Forbidden to create <employee_type>“

    3. check employee_type and

      (*

      tax_id (or passport

      _id

      _id, if no_tax_id: true)

      1. If dosn't match, return error 409

        If match,

        “<field> doesn't match"

    4. check that employee is active

      for

      (

      employee_type = OWNER or PHARMACY_OWNER),

      status = APPROVED and is_active =

      false

      for (employee_type not OWNER and not PHARMACY_OWNER), status = DISMISSED and is_active = true

    5. if employee is active - create employee request

    6. if employee is not active - return error 409

      true)

      1. in case of error - return 409 “employee is <status>“

  3. Check allowed employee types for legal_entity type: Legal_Entity_Type vs Employee_Type validation rules

    1. if not found - return error 404

  4. Validate legal entity type status for current legal entity: status should be active or suspended

  5. Validate party

    1. first_name, last_name, second_name have the same validation pattern - `^(?!.*[ЫЪЭЁыъэё@%&$^#])[А-ЯҐЇІЄа-яґїіє’\\'\\- ]+$` 

      1. if doesn't match, return error 422 "string does not match pattern ..."

    2. validate birth_date

      1. birth_date > 1900-01-01 and birth_date < current date

        1. otherwise return error 422 "invalid birth_date value"

      2. birth_date has validation pattern - `^(\\d{4}(?!\\d{2}\\b))((-?)((0[1-9]|1[0-2])(\\3([12]\\d|0[1-9]|3[01]))?|W([0-4]\\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\\d|[12]\\d{2}|3([0-5]\\d|6[1-6])))?)?$`

        1. if doesn't match, return error 422 "expected 'birth_date' to be a valid ISO 8601 date"

    3. gender has one of the following values - "FEMALE", "MALE"

      1. otherwise return error 422 "value is not allowed in enum"

    4. validate tax_id

      1. tax_id has validation pattern - `^([0-9]{9,10}|[А-ЯЁЇIЄҐ]{2}\\d{6})$`

        1. if doesn't match, return error 422 "string does not match pattern ..."

    5. email has validation pattern - `^[\\w!#$%&'*+/=?`{|}~^-]+(?:\\.[\\w!#$%&'*+/=?`{|}~^-]+)*@(?:[A-Z0-9-]+\\.)+[A-Z]{2,6}$`

      1. if doesn't match, return error 422 "expected 'email' to be an email address"

    6. validate documents

      1. documents.type has one of the following values:

        1. "BIRTH_CERTIFICATE"

        2. "BIRTH_CERTIFICATE_FOREIGN"

        3. "COMPLEMENTARY_PROTECTION_CERTIFICATE"

        4. "NATIONAL_ID"

        5. "PASSPORT"

        6. "PERMANENT_RESIDENCE_PERMIT"

        7. "REFUGEE_CERTIFICATE"

        8. "TEMPORARY_CERTIFICATE"

        9. "TEMPORARY_PASSPORT"

          1. otherwise return error 422 "value is not allowed in enum"

      2. documents.number has validation pattern according to documents.type

        1. BIRTH_CERTIFICATE - `^((?![ЫЪЭЁыъэё@%&$^#`~:,.*|}{?!])[A-ZА-ЯҐЇІЄ0-9№\\/()-]){2,25}$`

        2. COMPLEMENTARY_PROTECTION_CERTIFICATE - `^((?![ЫЪЭЁ])([А-ЯҐЇІЄ])){2}[0-9]{6}$`

        3. NATIONAL_ID - `^[0-9]{9}$`

        4. PASSPORT - `^((?![ЫЪЭЁ])([А-ЯҐЇІЄ])){2}[0-9]{6}$`

        5. PERMANENT_RESIDENCE_PERMIT - `^(((?![ЫЪЭЁ])([А-ЯҐЇІЄ])){2}[0-9]{4,6}|[0-9]{9}|((?![ЫЪЭЁ])([А-ЯҐЇІЄ])){2}[0-9]{5}\\/[0-9]{5})$`

        6. REFUGEE_CERTIFICATE - `^((?![ЫЪЭЁ])([А-ЯҐЇІЄ])){2}[0-9]{6}$`

        7. TEMPORARY_CERTIFICATE - `^(((?![ЫЪЭЁ])([А-ЯҐЇІЄ])){2}[0-9]{4,6}|[0-9]{9}|((?![ЫЪЭЁ])([А-ЯҐЇІЄ])){2}[0-9]{5}\\/[0-9]{5})$`

        8. TEMPORARY_PASSPORT - `^((?![ЫЪЭЁыъэё@%&$^#`~:,.*|}{?!])[A-ZА-ЯҐЇІЄ0-9№\\/()-]){2,25}$`

      3. validate documents.issued_at 

        1. documents.issued_at has validation pattern - `^(\\d{4}(?!\\d{2}\\b))((-?)((0[1-9]|1[0-2])(\\3([12]\\d|0[1-9]|3[01]))?|W([0-4]\\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\\d|[12]\\d{2}|3([0-5]\\d|6[1-6])))?)?$`

          1. if doesn't match, return error 422 "expected 'issued_at' to be a valid ISO 8601 date"

    7. validate phones

      1. phones.type has one of the following values - "LAND_LINE", "MOBILE"

        1. otherwise return error 422 "value is not allowed in enum"

      2. phones.number has validation pattern - `^\\+38[0-9]{10}$`

        1. if doesn't match, return error 422 "string does not match pattern ..."

...