ЕСОЗ - публічна документація
DEPRECATED - Submit Activity Type Package
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
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 when creating new record
Validate Owner
- Check that one of token.user_id employees is an OWNER of current legal_entity
- in case validation fails - generate 409 - "Only owner of legal entity can create or update activity types and(or) licenses for legal entity"
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 Licenses
- Apply current validations which depends on license type
- Check that legal entity has at least one kved which corresponds to license type according to the following table
in case validation fails - generate 409 - "Legal entity does not have any KVED corresponding to license type"
LICENSE_TYPERuleMSP at least one KVED from KVEDS_ALLOWED_MSP PHARMACY at least one KVED from KVEDS_ALLOWED_PHARMACY
- Check that license type is not changed and license is active and is not expired for existing license
- if $.license.id is not null then search for current legal entity license in prm.licenses with id = $.license.id
- If record is found then check that:
- prm.licenses.is_active = true
- in case validation fails - generate 409 - "Inactive license update is not allowed"
- prm.licenses.type = $.license.type
- in case validation fails - generate 409 - "License type update is not allowed"
- If $.licenses data is not provided check that prm.licenses.expiry_date is empty or more than today
- in case validation fails - generate 409 - "Activity type can not be linked to expired license"
- prm.licenses.is_active = true
- if record is not found generate 422
- If record is found then check that:
- if $.license.id is not null then search for current legal entity license in prm.licenses with id = $.license.id
Validate Activity Type
- Check that activity_type type is not changed and activity_type is active for existing activity_type
- If $.activity_type.id is not null then search for current legal entity activity type in prm.activity_types where id = $.activity_type.id
- if record is found then check that
- prm.activity_types.type = $.activity_type.type
- in case validation fails - generate 409 - "Update of type for activity type is not allowed"
- prm.activity_types.is_active = true
- in case validation fails - generate 409 - "Inactive activity type update is not allowed"
- prm.activity_types.type = $.activity_type.type
- if record is found then check that
- If $.activity_type.id is not null then search for current legal entity activity type in prm.activity_types where id = $.activity_type.id
- Check that activity type with the same type does not exist in DB for new activity type
- If $.activity_type.id is null then 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 generate 409 - "Active activity type with the same type already exists"
- If $.activity_type.id is null then search for current legal entity activity type in prm.activity_types where is_active=true and type = $.activity_type.type
- Check $.activity_type.type license obligation and license type needed (see table below)
- If license is a must:
- check that $.activity_type.license_id is not null or ($.licenses has data and $.licenses.id is null)
- in case validation fails - generate 422
- if $.activity_type.license_id is not null then check that $.activity_type.license_id = $.licenses.id
- in case validation fails - generate 409 - "Activity type linked license has to be the same as license"
- If $.license.type is provided then check that $.license.type is of needed type
- in case validation fails - generate 409 - "Activity type does not correspont to its license type"
- If $.license.type is not provided then check that prm.licenses.type is of needed type
- in case validation fails - generate 409 - "Activity type does not correspont to its license type"
- check that $.activity_type.license_id is not null or ($.licenses has data and $.licenses.id is null)
- If license is a must:
Activity types license obligation and corresponding types
Activity type | License needed | License type |
---|---|---|
PRIMARY_CARE | Y | MSP |
AMBULATORY | Y | MSP |
PHARMACY | Y | PHARMACY |
MIS | N | |
NHS | N |
Processing
- Search for current legal entity license in prm.licenses where id = $.license.id
- if record is found update it
- if record is not found create new record
- set nhs_verified = false
- Search for current legal entity activity type in prm.activity_types where id = $.activity_type.id
- If record is found update it
- if prm.activity_types.status <> active then set prm.activity_types.status = active, write to audit_log
- if record is not found create new record with status = active
- set nhs_verified = false
- If record is found update it
- Find contracts by contractor_legal_entity_id for current legal entity where status='VERIFIED' AND ops.contracts.type corresponding to activity_type (use ops.contracts.type to activity_type mapping described in
https://zube.io/edenlabllc/e-health/c/5969:
capitation_activity_types: PRIMARY_CARE,
reimbursement_activity_types: PHARMACY)
- set ops.contracts.is_suspended=true
- Save signed_content to Media Storage
- every version should be saved
- Save data to corresponding collections in DBs
- Save link to the signed content to the activity type
ЕСОЗ - публічна документація