Note |
---|
Сторінка знаходиться в процесі розробки. Інформація на ній може бути застарілою. |
Info |
---|
/wiki/spaces/EN/pages/17591304241 (remove the link block before publishing the document) |
...
Save signed content to media storage.
Get detailed data from EDR for active EDR record of legal entity (described at EDR data validation )
Create or update edr_data record based on logic:
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:
name = names.display
short_name = names.short
public_name = names.name
legal_form = olf_code
kveds = activity_kinds
registration_address = address
updated_by = consumer_id from MIS API token
updated_at = now()
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:
id = generate (uuid)
edr_id = id
name = names.display
short_name = names.short
public_name = names.name
legal_form = olf_code
kveds = activity_kinds
registration_address = address
is_active = true
inserted_by = consumer_id from MIS API token
updated_by = consumer_id from MIS API token
inserted_at = now()
updated_at = now()
Generate legal_entity_id that will be used also as client_id
Create new record in legal_entities table in PRM DB according to received request, also add following fields:
id = legal_entity_id
name = edr_data.name from created EDR data record
public_name = edr_data.public_name from created EDR data record
short_name = edr_data.short_name from created EDR data record
status = value according to LEGAL_ENTITY_CREATE_STATUS chart parameter (described at Legal Entities configurable parameters )
is_active = true
inserted_by = consumer_id from MIS API token
updated_by = consumer_id from MIS API token
inserted_at = now()
updated_at = now()
created_by_mis_client_id = client_id from MIS API token
nhs_unverified_at = now()
nhs_verified = false
nhs_reviewed = false
edr_data_id = edr_data.id from created EDR data record
Create new record in licenses table in PRM DB according to received request, also add following fields:
is_primary = true
legal_entity_id = legal_entities.id
is_active = true
inserted_by = consumer_id from MIS API token
updated_by = consumer_id from MIS API token
inserted_at = now()
updated_at = now()
Create employee request for owner according to 1f1fa-1f1e6Create employee request v2
Create client details and connection in MITHRIL DB:
Generate client record using legal_entities.id in MITHRIL DB.
Get consumer_id from MIS API token
Create client connection in MITHRIL DB for client and consumer
Create response with following data
Legal entity, primary license and edr data details
Created employee request id
Client connection details
...
Save signed content to media storage
Get detailed data from EDR for active EDR record (described at EDR data validation )
Create or update edr_data record based on logic:
If active EDR record of legal entity exists in edr_data table in PRM DB (edr_data.edr_id = $.id of EDR response) and corresponds to legal entity that is being updated (legal_entities.edr_data_id=edr_data.id), update record in edr_data table with following fields from EDR response:
name = names.display
short_name = names.short
public_name = names.name
legal_form = olf_code
kveds = activity_kinds
registration_address = address
updated_by = consumer_id from MIS API token
updated_at = now()
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:
id = generate (uuid)
edr_id = id
name = names.display
short_name = names.short
public_name = names.name
legal_form = olf_code
kveds = activity_kinds
registration_address = address
is_active = true
inserted_by = consumer_id from MIS API token
updated_by = consumer_id from MIS API token
inserted_at = now()
updated_at = now()
If edr_data.state is not in ACTIVE_EDR_STATES chart parameter, update legal entity status in legal_entities table (PRM DB):
status = ‘SUSPENDED’
status_reason = 'MANUAL_LEGAL_ENTITY_STATUS_UPDATE'
If legal entity status was changed to SUSPENDED:
terminate related capitation contract requests
suspend related capitation contracts
Update license with following logic:
If $.license_id is null then
Check if any attribute has changed comparing request and licenses data. If any, then:
Update license data in licenses table (PRM DB) according to received request for is_primary license record, additionally:
updated_by = consumer_id from MIS API token
updated_at = now()
For legal entity record in legal_entities related to the primary license, update following parameters in PRM DB:
set nhs_reviewed = false
set nhs_verified = false
set nhs_unverified_at = now()
If $.license_id is not null then skip license update
Update legal_entities data in PRM DB according to received request, also update following fields:
name = edr_data.name from created EDR data record (if edr_data was updated)
public_name = edr_data.public_name from created EDR data record (if edr_data was updated)
short_name = edr_data.short_name from created EDR data record (if edr_data was updated)
updated_by = consumer_id from MIS API token
updated_at = now()
edr_data_id = edr_data.id from created EDR data record (if edr_data was updated)
Create employee request for owner according to 1f1fa-1f1e6Create employee request v2
Update client details and connection in MITHRIL DB:
Get consumer_id from MIS API token
Create new client connection in MITHRIL DB for client and consumer_id
Create response with following data
Legal entity, primary license and edr data details
Created employee request id
Client connection details
Update accreditation with following logic:
if "category": "NO_ACCREDITATION" than check if only required fields are filled, also update following fields:
“issued_date” set null
“expiry_date" set null
“order_date" set null
if it is another category- update all fields with the values they were filled with
Configuration parameters
N/A
...
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 expressionin 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 expressionin 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 expressionin 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 expressionin 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 that employee with id = $.owner.employee_id exists in PRM DB
in case of error - return 422 (“Employee not found“)
Check that employee with id = $.owner.employee_id corresponds to Legal entity from payload
in case of error - return 409 (“Employee doesn't belong to your legal entity“)
Check that employee with id = $.owner.employee_id is an employee with employee_type = ‘OWNER’ or ‘PHARMACY_OWNER’
in case of error - return 409 (“Invalid employee type”)
Check that employee with id = $.owner.employee_id is an employee with status = ‘APPROVED’ and is_active = true
in case of error - return 409 (“Invalid employee status“)
Check $.owner.tax_id from request is equal to parties.tax_id for $.owner.employee_id
in case of error - return 409 (“tax_id doesn't match“)
Check $.owner.tax_id from request is not empty if parties.tax_id for $.owner.employee_id is not empty:
in case of error - return 422 (“
required property tax_id was not present
“)
Check $.owner.birth_date from request is equal to parties.birth_date of $.owner.employee_id
in case of error - return 409 (“birth_date doesn't match“)
If parties.no_tax_id for $.owner.employee_id is true check $.owner.tax_id from request:
$.owner.tax_id is valid according to
([0-9]{9}|[А-ЯЁЇIЄҐ]{2}\d{6})
regular expressionin case of error - return 422 (“
string does not match pattern \"^([0-9]{9,10}|[А-ЯЁЇIЄҐ]{2}\\d{6})$\"
”)
Validate legal entity with EDR
...
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
...