Versions Compared

Key

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

Table of Contents

...

Declaration request can be signed either by doctor or admin (user with scope declaration_request:sign) from legal entity as in declaration request.

❗ Important

Invoke Get Declaration Request by ID to obtain seed - Hash of previous block in declarations chain or other random component that should be signed with declaration.

...

  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

...