ЕСОЗ - публічна документація

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 12 Next »


Method is used to register new employee or to update an existing one. There is 2 different flows of registration depend on whether the employee has tax_id or doesn't have.

Authorize user

    1. Validate MIS API Key
    2. Check MIS scopes employee_request:write in order to perform this action
      1. In case error - generate 401 response

Digital signature

Decode content that is encrypted in an electronic digital signature.
Use Digital signature WS. Method checks digital signature and returns result.
See service specification

Validate DRFO

  1. Check that DRFO in Certificate details exists and not empty
  2. Check that DRFO in Certificate details is equal to DRFO of the user that creates employee_request in Party
    1. Get party.tax_id using user_id from employee request payload
    2. Compare DRFO in Certificate with party.tax_id
      1. Convert DRFO and TAX_ID to uppercase
      2. Compare DRFO and TAX_ID as Cyrillic letters
      3. Convert DRFO to Cyrillic and compare as Cyrillic letters
    3. In case validation fails - generate 422 error

Latin to Cyrillic mapping using legal table 


Validate request (JSON schema)

    1. Validate request using JSON schema
      1. In case validation fails - generate 422 error

GitHub JSON schema file link


Validate request (Logic)

  1. Check employee_type: Employee configurable validation rules and dictionaries
  2. If employee_id is passed in the payload:
    1. search employees by employee_id
      1. if not found - return error 404
      2. else check * employee_type and (* tax_id or passport_id)
        1. If dosn't match, return error 409
        2. If match, check that employee is active

          for (employee_type = OWNER or PHARMACY_OWNER), status = APPROVED and is_active = false

          for (employee_type not OWNER and not PHARMACY_OWNER), status = DISMISSED and is_active = true

          1. if employee is active - create employee request

          2. if employee is not active - return error 409

  3. Check allowed employee types for legal_entity type: Legal_Entity_Type vs Employee_Type validation rules
    1. if not found - return error 404
  4. Validate legal entity type status for current legal entity: status should be active or suspended
  5. Validate party
    1. first_name, last_name, second_name have the same validation pattern - `^(?!.*[ЫЪЭЁыъэё@%&$^#])[А-ЯҐЇІЄа-яґїіє’\\'\\- ]+$` 
      1. if doesn't match, return error 422 "string does not match pattern ..."
    2. validate birth_date
      1. birth_date > 1900-01-01 and birth_date < current date
        1. otherwise return error 422 "invalid birth_date value"
      2. birth_date has validation pattern - `^(\\d{4}(?!\\d{2}\\b))((-?)((0[1-9]|1[0-2])(\\3([12]\\d|0[1-9]|3[01]))?|W([0-4]\\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\\d|[12]\\d{2}|3([0-5]\\d|6[1-6])))?)?$`
        1. if doesn't match, return error 422 "expected 'birth_date' to be a valid ISO 8601 date"
    3. gender has one of the following values - "FEMALE", "MALE"
      1. otherwise return error 422 "value is not allowed in enum"
    4. validate tax_id
      1. tax_id has validation pattern - `^([0-9]{9,10}|[А-ЯЁЇIЄҐ]{2}\\d{6})$`
        1. if doesn't match, return error 422 "string does not match pattern ..."
      2. tax_id should suite following rules
        1. 1-5 digits - encoded date of birth 
        2. 6-9 digits - the Register number (Tax Register) in correspondence with date of birth 
        3. 9th digit - additionalдy gender is encoded (even - Female, odd - Male)
        4. 10th digit - has the following formula: 

          code: ABCDEFGHIZ
          Х = А*(-1) + B*5 + C*7 + D*9 + E*4 + F*6 + G*10 + H*5 + I*7
          Z = Х-(11 * whole part of (Х/11))
          Z is 10th digit

          1. all negative scenarios (1-4) return error 422 "invalid tax_id value"
    5. email has validation pattern - `^[\\w!#$%&'*+/=?`{|}~^-]+(?:\\.[\\w!#$%&'*+/=?`{|}~^-]+)*@(?:[A-Z0-9-]+\\.)+[A-Z]{2,6}$`
      1. if doesn't match, return error 422 "expected 'email' to be an email address"
    6. validate documents
      1. documents.type has one of the following values:
        1. "BIRTH_CERTIFICATE"
        2. "BIRTH_CERTIFICATE_FOREIGN"
        3. "COMPLEMENTARY_PROTECTION_CERTIFICATE"
        4. "NATIONAL_ID"
        5. "PASSPORT"
        6. "PERMANENT_RESIDENCE_PERMIT"
        7. "REFUGEE_CERTIFICATE"
        8. "TEMPORARY_CERTIFICATE"
        9. "TEMPORARY_PASSPORT"
          1. otherwise return error 422 "value is not allowed in enum"
      2. documents.number has validation pattern according to documents.type
        1. BIRTH_CERTIFICATE - `^((?![ЫЪЭЁыъэё@%&$^#`~:,.*|}{?!])[A-ZА-ЯҐЇІЄ0-9№\\/()-]){2,25}$`
        2. COMPLEMENTARY_PROTECTION_CERTIFICATE - `^((?![ЫЪЭЁ])([А-ЯҐЇІЄ])){2}[0-9]{6}$`
        3. NATIONAL_ID - `^[0-9]{9}$`
        4. PASSPORT - `^((?![ЫЪЭЁ])([А-ЯҐЇІЄ])){2}[0-9]{6}$`
        5. PERMANENT_RESIDENCE_PERMIT - `^(((?![ЫЪЭЁ])([А-ЯҐЇІЄ])){2}[0-9]{4,6}|[0-9]{9}|((?![ЫЪЭЁ])([А-ЯҐЇІЄ])){2}[0-9]{5}\\/[0-9]{5})$`
        6. REFUGEE_CERTIFICATE - `^((?![ЫЪЭЁ])([А-ЯҐЇІЄ])){2}[0-9]{6}$`
        7. TEMPORARY_CERTIFICATE - `^(((?![ЫЪЭЁ])([А-ЯҐЇІЄ])){2}[0-9]{4,6}|[0-9]{9}|((?![ЫЪЭЁ])([А-ЯҐЇІЄ])){2}[0-9]{5}\\/[0-9]{5})$`
        8. TEMPORARY_PASSPORT - `^((?![ЫЪЭЁыъэё@%&$^#`~:,.*|}{?!])[A-ZА-ЯҐЇІЄ0-9№\\/()-]){2,25}$`
      3. validate documents.issued_at 
        1. documents.issued_at has validation pattern - `^(\\d{4}(?!\\d{2}\\b))((-?)((0[1-9]|1[0-2])(\\3([12]\\d|0[1-9]|3[01]))?|W([0-4]\\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\\d|[12]\\d{2}|3([0-5]\\d|6[1-6])))?)?$`
          1. if doesn't match, return error 422 "expected 'issued_at' to be a valid ISO 8601 date"
    7. validate phones
      1. phones.type has one of the following values - "LAND_LINE", "MOBILE"
        1. otherwise return error 422 "value is not allowed in enum"
      2. phones.number has validation pattern - `^\\+38[0-9]{10}$`
        1. if doesn't match, return error 422 "string does not match pattern ..."


Alternative notation 2 of validation :

if (employee_id is passed in the payload) {
	result=search employees by employee_id;
	if (result == false) {
		return error 404 }
	else { 
		result=check * employee_type and * tax_id
		if (result == false) {
			return error 409}
		else {
			if (employee is active) {
				if (employee_type = OWNER || employee_type = PHARMACY_OWNER) {
					set status = APPROVED
					set is_active = false}
				if (employee_type not OWNER && employee_type not PHARMACY_OWNER) {
					set status = DISMISSED
					set is_active = true}
				if (employee is active) {
					create employee request }
				else {
					return error 409 }
					}
				}
			}
		}
	}
}	

result=search employee_type_legal_entity_type_links by employee_type+legal_entity_type
if (result == false) {
		return error 404 }

Save signed declaration to media storage

  1. Get url for declaration upload.
    Use Request a Secret WS

    Parameter
    Source
    action'GET'
    bucket'EMPLOYEE_REQUESTS'
    resource_id: EMPLOYEE_REQUEST_ID
    resource_name: signed_employee_request
  2. Upload signed declaration to media storage

Create employee request

Create employee request in IL_DB table - employee_request.

    1. generate GUID and writte in id column
    2. write JSON object with employee request details

Send activation link on email

  1. Generate activation link, which contains Employee request GUID
  2. Send activation URL on user email
    1. invoke service - Send message
      See service specification 

Updating employee data

To update the data of an existing employee use the endpoint `Create Employee Request`.
It is necessary to transfer the same JSON as when creating employee request with the same id of an existing employee.

There are several rules when updating employee data:

  1. Position can not be changed

    1. in case of failure, return error 422 "position can not be changed"

  2. If specialities.speciality_officio:true, in this object value of speciality can not be changed

    1. in case of failure, return error 422 "main speciality can not be changed"

  • No labels