Table of Contents |
---|
Specification
...
This WS is design to create relationship for reorganized legal entities by NHS admin using DS. Before the request is created new LE must be created (in case if needed) and employee from old legal entity must be registered in the new one. After that NHS admin must set relationship via signed content. After basic validation
Input parameters
Input is signed data in PKCS7 format. The data must be unpacked and validated using Json Schema.
Fields to sign:
field | type | ||
---|---|---|---|
merged_from_legal_entity | id | uuid | required |
name | string | required | |
edrpou | string | required | |
merged_to_legal_entity | id | id | required |
name | string | required | |
edrpou | string | required | |
reason | sring | required |
...
- Verify the validity of access token
- in case of error return 401 ('Access denied')
- Check user scope legal_entity:merge in order to perform this action
- in case of error generate 401 response ('Invalid scopes')
- Verify the validity of access token
Validate Digital signature
Decode content that is encrypted in an electronic digital signature.
Use Digital signature WS. Method checks digital signature and returns result.
We need to check DS.
- Get client_id from token. Find prm.legal_entities by client_id
- Check EDRPOU matches prm.legal_entities.EDRPOU
- Check if EDRPOU in Certificate details exists and not empty
- Check if Certificate_details.EDRPOU=prm.legal_entities.EDRPOU
- In case validation fails - generate 422 error
- Check if EDRPOU in Certificate details exists and not empty
- Check EDRPOU matches prm.legal_entities.EDRPOU
- Get parties.tax_id using party_users.party_id by user_id.
- Compare DRFO in Certificate with party.tax_id
- Convert DRFO and TAX_ID to uppercase
- Compare DRFO and TAX_ID as Cyrillic letters
- Convert DRFO to Cyrillic and compare as Cyrillic letters
- In case validation fails - generate 422 error
- Compare DRFO in Certificate with party.tax_id
...
- Validate client_id (is_blocked=false)
- in case of error return 403 Error ('Client is blocked')
- Check client_id is active
- in case error return 403 - ('Client is not active')
Validate request
- Validate merged_to legal_entity
- Check legal entity exists and status='active'
- in case of error return 409 error view $merged_to.id ('Merged to legal entity must be active')
- Validate merged_to legal entity is not an active merged_from legal entity (select * from related_legal_entities where merged_from_id=$merged_to_id and is_active=true) returns empty result
- in case of error return 409 error view $merged_to.id ('Merged to legal entity is in the process of reorganisation itself')
- Validate merged_to.name from request=prm.legal_entites.$merged_to.id.name
- in case of error return 422 error view $merged_to.name ('Invalid legal entity name')
- Validate merged_to.edrpou from request=prm.legal_entites.$merged_to.id.edrpou
- in case of error return 422 error view $merged_to.edrpou ('Invalid legal entity edrpou')
- Check legal entity exists and status='active'
- Validate merged_from legal_entity
- Check merged from legal entity exists and status='active' or 'suspended'
- in case of error return 409 error view $merged_from.id ('Merged from legal entity must be active or suspended')
- Validate merged from legal entity is not in the process of reorganization (select * from related_legal_entities where merged_from_id=$merged_from_id and is_active=true) returns empty result
- in case of error return 409 error view $merged_from.id ('Merged from legal entity is already in the process of reorganisation')
- Validate merged from legal_entity.name from request=prm.legal_entites.$merged_from.id.name
- in case of error return 422 error view $merged_from.name ('Invalid legal entity name')
- Validate merged from legal_entity.edrpou from request=prm.legal_entites.$merged_from.id.edrpou
- in case of error return 422 error view $merged_from.edrpou ('Invalid legal entity edrpou')
- Validate merged_to_legal_entity.id<>merged_from_legal_entity.id
- in case of error return 422 error view ('Legator and successor legal entities must be different')
- Check merged from legal entity exists and status='active' or 'suspended'
- Validate merged_to.legal_entity_type and merged_from.legal_entity_type. Valid type transitions see in the table below.
- in case of error return 422 error view ('Invalid legal entity type')
- in case of error return 422 error view ('Reorganisation of legal entity to itself is not allowed')
Valid type transitions for legal entities
...
Get url for request upload.
ParameterSourceaction 'GET' bucket 'RELATED_LEGAL_ENTITIES' resource_id : RELATED_LEGAL_ENTITIES_ID resource_name : CREATE_RELATED_LEGAL_ENTITIES timestamp :TIMESTAMP - Upload signed content to media storage
...
- For each employee with type DOCTOR from merged from legal_entity take employee.speciality_officio and employee.party
select id as merged_from_employee_id, speciality.speciality, party_id from employees where legal_entity_id=$merged_from_id and employee_type='DOCTOR' and status='APPROVED'
and check whether exist at least one employee with same speciality_officio in merged_to_legal_entity
select id from employees where legal_entity_id=$merged_to_id and employee_type='DOCTOR' and status='APPROVED' and party_id=$party_id and speciality.speciality=$speciality.speciality- In case there is no such employee in merged_to_legal_entity change employee's status='DISMISSED' and set `status_reason`='auto_merge_legal_entity' from merged_from legal_entity.
...