Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

...

  1. Validate request using JSON schema

    1. In case validation fails - generate 422 error

  2. Check declaration request status

    1. If status is not APPROVED, - returned error 'Incorrect status'

Validate person verification status

  • validate patient's verification_status is not equal to NOT_VERIFIED.

    • in case of error return 409, "Patient is not verified"

Validate Parent declaration

Get parent_declaration_id from IL_DB.declaration_requests.parent_declaration_id.

  • If parent_declaration_id is not null, check that parent declaration exists and in status 'active'

    • In case of error - return 404 ("Active parent declaration was not found")

Check signed content

Check decoded signed content with previously created on IL.db.

...

  • If "patient_signed" is not present in request, return 422 ("required property patient_signed was not present")

  • If "patient_signed"=false in request, return 422 ("Patient must sign declaration form")

  • If “patient_signed”=null, check that parent_declaration_id is not null,

    • in case of error, return 422 ("Patient must sign declaration form")

Validate human readable declaration number

...

In case active declarations found - terminate all by changing status to INACTIVE.

In case parent_declaration_id of declaration request is not null - terminate parent_declaration with reason reason = 'auto_reorganization'.

Create declaration

  1. Check authentication_method_current

    Code Block
    SELECT authentication_method_current
    FROM declaration_requests
    WHERE id = {:id}
    
    1. If "type" = "OFFLINE"

      1.  set declaration status to "PENDING_VERIFICATION"

      2. set reason to 'offline'

    2. if "type" = "OTP" - set declaration status to "ACTIVE" 

    3. if "type" = "NA" - check parent_declaration_id, if not null than set declaration status to "ACTIVE"

  2. Check persons 'no_tax_id' flag

    1. if 'no_tax_id'=true and parent_declaration_id is null

      1. set declaration status to "PENDING_VERIFICATION"

      2. set reason to 'no_tax_id'

      3. if ‘no_tax_id’=true and parent_declaration_id is not null - set declaration status to "ACTIVE"

  3. Create a new declaration by adding a new entity to the declarations table ops_db without declaration_id.

    1. if there is existing record in the declarations table with the same id and declaration_request_id, return ok to IL

...

Expand
titleRequest example
Code Block
{
  "meta": {
    "code": 200,
    "url": "https://example.com/resource",
    "type": "object",
    "request_id": "req-adasdoijasdojsda6617aeec-15e2-4d6f-b9bd-53559c358f97#17810"
  },
  "data": {
    "id": "b075f148-7f93-4fc2-b2ec-2d81b19a9b7b",
    "start_date": "2017-03-02",
    "end_date": "2017-03-02",
    "signed_at": "2017-03-02T00:00:00.000Z",
    "status": "active",
    "declaration_request_id": "74a6fae6-4207-4e03-a136-f2e70c6b0c02",
    "person_id": "5fb57a5d-1457-430e-9678-c81cec72779f",
    "legal_entity_id": "b075f148-7f93-4fc2-b2ec-2d81b19a9b7b",
    "employee_id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
    "division_id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
    "inserted_at": "2017-07-06T16:54:05.161571Z",
    "is_active": true,
    "reason": "manual_employee",
    "reason_description": "Згідно постанови 1 від 10.01.2017"
  }
}

...