Introduction
Web service "Submit Activity Type Package" allows to transmit new or update existing activity type, its related data and legal entity licenses in e-Health system in one call. Activity types are created/updated one by one.
Specification
TBC
Validation
Authorization
- Verify the validity of access token
- in case of error return 401 ('Access denied')
- Check user scope activity_type:write in order to perform this action
- in case of error generate 403 response ('Invalid scopes')
Request validation
Note: All IDs, submitted as PK, should be unique for eHealth.
Validate digital signature
- Validate signature
- Extract signer Certificate details
Validate encoded signed content according to JSON Schema
- Return 422 with list of validation errors in case validation fails
Validate Legal Entity
- Check that legal_entities.is_active = true and legal_entities.status = active for current legal entity
- in case of error return 409 - "legal entity is not active"
- token.Client_id must match current legal entity
- in case of error return 422
- EDRPOU for token.client_id must match EDRPOU $.legal_entity.edrpou
- in case of error return 422
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 $.legal_entity.edrpou
- 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 $.legal_entity.edrpou
- 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 Owner
- Check that one of token.user_id employees is OWNER of current legal_entity
- in case validation fails - generate ???
Validate Activity Type
- Validate $.activity_type.id as unique
- Check $.activity_type.activity_type license obligation and license type needed (via configuration)
- If license is a must:
- check that $.activity_type.license_id is not empty
- in case validation fails - generate ???
- check that license with $.activity_type.license_id exists in payload and $.license.type is of needed type OR (license with $.activity_type.license_id exists in prm.licenses for current legal entity and prm.licenses.expiry_date is empty or more than today AND prm.licenses.type is of needed type)
- in case validation fails - generate ???
- check that $.activity_type.license_id is not empty
- If license is a must:
- Search for current legal entity activity type in prm.activity_types where is_active=true and type = $.activity_type.type
- If record is found then check that its id is equal to $.activity_type.id
- in case validation fails - generate ???
- If record is found then check that its id is equal to $.activity_type.id
Validate Licenses
- Validate $.license.id as unique
- Search for current legal entity license in prm.licenses where is_active = true and type = $.license.type
- If record is found then check that its id is equal to $.license.id
Request Processing
- Save signed_content to Media Storage
- Save data to corresponding collections in DBs
- Save link to the signed content to the activity type