ЕСОЗ - публічна документація
IL.Create/Update Legal Entity
Lucidchart link
Authorize user
- Validate MIS API Token
- Check MIS scopes legal_entity:write in order to perform this action
- In case error - generate 401 response
Digital signature
- Validate signature
- Extract signer Certificate details
- Save Signed Content
Validate Tax ID
- Check that EDRPOU in Certificate details exists and not empty
- Check that EDRPOU in Certificate details is valid according to ^[0-9]{8,10}$
- Check that EDRPOU in Certificate details is equal to EDRPOU in Legal Entity payload
- In case validation fails - generate 422 error
- If EDRPOU in Certificate details is empty check that DRFO exists and not empty
- Check that DRFO in Certificate details is valid according to ^[0-9]{9,10}$
- Check that DRFO in Certificate details is equal to EDRPOU in Legal Entity payload
- In case validation fails - generate 422 error
- In case EDRPOU and DRFO is empty return error 422, msg "EDRPOU and DRFO is empty in digital sign"
Validate Legal Entity request
- Validate request using JSON schema
- In case validation fails - generate 422 error
- Validate request using JSON schema
Validate KVEDS
Validate KVEDs allowed for registration according to Legal Entity type
- If Request:
$.type = MSP
, check that at least one KVED Request:$.kveds
is in KVEDS_ALLOWED_MSP list - If Request:
$.type = PHARMACY
, check that at least one KVED Request:$.kveds
is in KVEDS_ALLOWED_PHARMACY list
Validate owners position
owners positions should be one of the list - env. configuration OWNER_POSITIONS.
At the moment it is - "P1, P2, P3, P32, P4, P6, P5, P18, P19, P22, P23, P24, P25, P26, P229, P230, P231, P232, P233, P234, P235, P236, P240"
At the moment it is - "P1, P2, P3, P32, P4, P6, P5, P18, P19, P22, P23, P24, P25, P26, P229, P230, P231, P232, P233, P234, P235, P236, P240, P257"
EDR Validation
The data provided by MIS during LE registration must matches with the data stored in EDR
General rules
- LE must be registered in EDR
- LE must be active in EDR
- If new LE type is created then no active or suspended LE type should exist in e-Health with same EDRPOU and different edr_id as active record in EDR
Implementation
TBC
Save signed content
Generate RESOURCE_NAME for signed content
Generate RESOURCE_ID for Legal Entity
Invoke Media Content Storage to get upload URL for the document
Parameter | Source |
---|---|
action | 'PUT' |
bucket | 'LEGAL_ENTITIES' |
resource_id | :RESOURCE_NAME |
resource_name | :RESOURCE_ID |
Upload file via Google Cloud API
Refresh EDR Data
- Get detailed data from EDR for active EDR record: call EDR data validation#Getdetailedinformation using id, received on step EDR Validation.
- Create or Update record in prm.edr_data for active EDR record data.
Mapping
eHealth | EDR |
---|---|
edr_id | $.id |
name | $.names.name |
short_name | $.names.short |
public_name | $.names.display |
legal_form | $.olf_code |
kveds | $.activity_kinds |
registration_address | $.address |
state | $.state |
Search Legal Entity using EDRPOU from Signer Certificate
Search Legal Entity in prm.legal_entities using EDRPOU from Signer Certificate where (legal_entities.type = $.type or legal_entities.type = 'PRIMARY_CARE' if $.type ='MSP') and status = active or suspended
- In case record found go to Update Client in Auth
- In case record not found go to Generate client and legal entity identifier
Request parameters:
Parameter | Source | Description |
---|---|---|
EDRPOU | Signer certificate | Extracted from public signer certificate |
curl -X GET http://private.domain/api/legal_entities?edrpou=34108665
Update Client in Auth
Update Redirect URI
Update Legal Entity
Update legal_entities (see Table specs)
- Change the record according to received request
- Some of the fields must not be changed. This fields must be excluded from PATCH request: EDRPOU, TYPE
- set accreditations = Request: $.medical_services_providers.accreditations
- save residence address into legal_entities.residence_address
- If nhs_reviewed = true reset it to false
Update licenses (see Table specs)
- Search for a record in prm.licenses for current legal entity
- Check if any attribute has changed comparing request and prm data. If yes, then:
- For each record in prm.legal_entities related to the license:
- If nhs_reviewed = true reset it to false
- If nhs_verified = true
- reset it to false
- set `nhs_unverified_at` to current date
- For each record in prm.legal_entities related to the license:
- Update license data according to the request
- Check if any attribute has changed comparing request and prm data. If yes, then:
Update LE official name
Extract official name from Digital signature.
- Update `legal_entities.public_name` in prm with official name from Digital signature
- Update `clients.name` in mithril with official name from Digital signature
Update Contract Request
- Find contract requests related to current legal entity in status = NEW, APPROVED, PENDING_NHS_SIGN, NHS_SIGNED, set status = 'TERMINATED', status_reason "Legal Entity Data has changed"
Reset flags
Update Contract
In case Legal Entity already exists in DB we need to check whether next fields weren't changed:
nameaddresses (any field in array)status
Compare fields in prm.legal_entities and in request. In case any of the fields above were changed
find contracts by contractor_legal_entity_id=$legal_entities.id and status='VERIFIED'. Set ops.contracts.is_suspended=true
Generate client and legal entity identifier
Generate UUID as client identifier and legal entity identifier
Create client and connection in Auth
- Invoke Auth API (idempotent PUT) to register new client and generate client secret key
- Determine MIS_ID (consumer_id) using api-key
- Invoke Put client connection in order to UpSet connection in Mithril for this client and consumer
Create new Legal Entity
Populate licenses table (see Table specs)
- select licenses.id from prm.licenses where type = $.type and id in (select license_id from legal_entities where edr_data_id in (select id from edr_data where edr_id = active edr id))
- If record found then
- check if any attribute has changed comparing request and prm data. If yes, then:
- For each record in prm.legal_entities related to the license:
- If nhs_reviewed = true reset it to false
- If nhs_verified = true
- reset it to false
- set `nhs_unverified_at` to current date
- For each record in prm.legal_entities related to the license:
- Update license data according to the request
- check if any attribute has changed comparing request and prm data. If yes, then:
- if record not found then create new record:
- set 'licenses.type' = MSP if Request: $.type = MSP
- set 'licenses.type' = PHARMACY if Request: $.type = PHARMACY
- set 'licenses.is_active' = true and populate inserted_by, inserted_at, updated_by, updated_at fields
- set issued_by, issued_date, expiry_date, active_from_date, what_licensed, order_no according to Request: $.medical_services_providers.licenses data
- Link created record and edr_data record
- If record found then
Populate legal_entities table (see Table specs)
- Create new record according to received request
- Link created record and edr_data record
- Link created record and license
- set accreditations = Request: $.medical_services_providers.accreditations
- save registration_address separately
- set nhs_verified, nhs_reviewed to false
- set `nhs_unverified_at` to current date
- set status =
activesuspended
Save LE official name
Extract official name from Digital signature.
- Save LE official name to prm DB = legal_entities.public_name
- Save LE official name to mithril DB = clients.name
Check UKR_MED_REGISTRY
Manual verification is not required if Legal Entity is in Registry
Search EDRPOU in UKR_MED_REGISTRY with corresponding type
Set Legal Entity mis_verified to VERIFIED
Set mis_verified to VERIFIED for PRM.legal_entity if Legal Entity is in Registry
Request parameters:
|
Set Legal Entity mis_verified to NOT_VERIFIED
Set mis_verified to NOT_VERIFIED for PRM.legal_entity if Legal Entity is not in Registry
Request parameters:
Register new employee
Init IL.Create employee request
Determine employee_type
If legal_entity_types.type == MSP: Employee_type = OWNER If legal_entity_types.type == PHARMACY: Employee_type = PHARMACY_OWNER
Mapping
Parameter | Source |
---|---|
legal_entity_id | Generated previously legal_entities.id |
employee_type | Variable: Employee_type |
position | Request: $.owner.position |
status | Const: PENDING_VERIFICATION |
start_date | now() |
party | Request: $.owner Except: $.owner.position |
ЕСОЗ - публічна документація