Versions Compared

Key

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

...

Page Properties

Link

https://ehealthmisapi1.docs.apiary.io/#reference/public.-medical-service-provider-integration-layer/legal-entities/create/update-legal-entity-v2

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

Resource

/api/v2/legal_entities

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

Scope

legal_entity:write

Scope для доступу

Components

Legal Entities

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

Microservices

API paragraph not found

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

Protocol type

REST

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

Request type

PUT

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

Sync/Async

Sync

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

Public/Private/Internal

Public

...

  1. Save signed content to media storage.

  2. Get detailed data from EDR for active EDR record of legal entity (described at EDR data validation )

  3. Create or update edr_data record based on logic:

    1. If active EDR record of legal entity exists in edr_data table in PRM DB (edr_data.edr_id = $.id of EDR response), update record in edr_data table with following fields from EDR response:

      1. name = names.display

      2. short_name = names.short

      3. public_name = names.name

      4. legal_form = olf_code

      5. kveds = activity_kinds

      6. registration_address = address

      7. updated_by = consumer_id from MIS API token

      8. updated_at = now()

    2. If active EDR record of legal entity does not exist in edr_data table in PRM DB (edr_data.edr_id = $.id of EDR response), create new record in edr_data table with following fields from EDR response:

      1. id = generate (uuid)

      2. edr_id = id

      3. name = names.display

      4. short_name = names.short

      5. public_name = names.name

      6. legal_form = olf_code

      7. kveds = activity_kinds

      8. registration_address = address

      9. is_active = true

      10. inserted_by = consumer_id from MIS API token

      11. updated_by = consumer_id from MIS API token

      12. inserted_at = now()

      13. updated_at = now()

  4. Generate legal_entity_id that will be used also as client_id

  5. Create new record in legal_entities table in PRM DB according to received request, also add following fields:

    1. id = legal_entity_id

    2. name = edr_data.name from created EDR data record

    3. public_name = edr_data.public_name from created EDR data record

    4. short_name = edr_data.short_name from created EDR data record

    5. status = value according to LEGAL_ENTITY_CREATE_STATUS chart parameter (described at Legal Entities configurable parameters )

    6. is_active = true

    7. inserted_by = consumer_id from MIS API token

    8. updated_by = consumer_id from MIS API token

    9. inserted_at = now()

    10. updated_at = now()

    11. created_by_mis_client_id = client_id from MIS API token

    12. nhs_unverified_at = now()

    13. nhs_verified = false

    14. nhs_reviewed = false

    15. edr_data_id = edr_data.id from created EDR data record

  6. Create new record in licenses table in PRM DB according to received request, also add following fields:

    1. is_primary = true

    2. legal_entity_id = legal_entities.id

    3. is_active = true

    4. inserted_by = consumer_id from MIS API token

    5. updated_by = consumer_id from MIS API token

    6. inserted_at = now()

    7. updated_at = now()

  7. Create employee request for owner according to Create employee request v2

  8. Create client details and connection in MITHRIL DB:

    1. Generate client record using legal_entities.id in MITHRIL DB.

    2. Get consumer_id from MIS API token

    3. Create client connection in MITHRIL DB for client and consumer

  9. Create response with following data

    1. Legal entity, primary license and edr data details

    2. Created employee request id

    3. Client connection details

...

  • Validate decoded input data is signed

    • in case of error - return 422 (“document must contain 1 signature and 0 stamps but contains 0 signatures and 0 stamps”)

  • Check DS is valid and not expired

  • Check that Last Name from DS and Owner last_name from request matches

    • in case of error - return 422 (“Does not match the signer last name“)

  • If EDRPOU in Certificate details exists and not empty

    • Check that EDRPOU in Certificate details is valid according to ([0-9]{8,10}|[А-ЯЁЇIЄҐ]{2}\d{6}) regular expression

      • in case of error - return 422 (“string does not match pattern")

    • Check that EDRPOU in Certificate details is equal to $.edrpou in payload

      • in case of error - return 422 (“EDRPOU does not match legal_entity edrpou“)

  • If EDRPOU in Certificate details is empty and if DRFO in Certificate detailsexists and not empty

    • Check that DRFO in Certificate details is valid according to ([0-9]{9,10}|[А-ЯЁЇIЄҐ]{2}\d{6}) regular expression

      • in case of error - return 422 (“string does not match pattern")

    • Check that DRFO in Certificate details is equal to $.edrpou in payload

      • in case of error - return 422 (“DRFO does not match signer drfo“)

  • If EDRPOU and DRFO in Certificate details are empty - return 422 (“EDRPOU and DRFO is empty in digital sign“)

...

Validate owner

Validate tax_id

  • If $.owner.no_tax_id does not exists in request or exists and equals false, check that $.owner.tax_id is valid according to ^[0-9]{10}$ regular expression

    • in case of error - return 422 (“invalid tax_id value“)

  • If $.owner.no_tax_id equals true, check that $.owner.tax_id is valid according to ([0-9]{9}|[А-ЯЁЇIЄҐ]{2}\d{6}) regular expression

    • in case of error - return 422 (“invalid tax_id value”)

Validate birth date

  • Check that $.owner.birth_date is greater than MIN_BIRTH_DATE chart parameter

    • in case of error - return 422 (“invalid birth_date value”)

  • Check that owners age is greater than MIN_AGE chart parameter

    • in case of error - return 422 (“invalid birth_date value”)

...

Check license according to the schema below.

License from request must be validated with related primary license (licenses.is_primary=true where licenses.legal_entity_id=legal_entities.id).

...

Check if license is needed for legal entity type is performed based on LEGAL_ENTITY_<LEGAL_ENTITY_TYPE>_PRIMARY_LICENSE_TYPES chart parameter (described at Legal Entities configurable parameters )

Processing

Save signed content

...