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.
...
Validate request using JSON schema
In case validation fails - generate 422 error
Check declaration request status
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
Check authentication_method_current
Code Block SELECT authentication_method_current FROM declaration_requests WHERE id = {:id}
If "type" = "OFFLINE"
set declaration status to "PENDING_VERIFICATION"
set reason to 'offline'
if "type" = "OTP" - set declaration status to "ACTIVE"
if "type" = "NA" - check parent_declaration_id, if not null than set declaration status to "ACTIVE"
Check persons 'no_tax_id' flag
if 'no_tax_id'=true and parent_declaration_id is null
set declaration status to "PENDING_VERIFICATION"
set reason to 'no_tax_id'
if ‘no_tax_id’=true and parent_declaration_id is not null - set declaration status to "ACTIVE"
Create a new declaration by adding a new entity to the declarations table ops_db without declaration_id.
if there is existing record in the declarations table with the same id and declaration_request_id, return ok to IL
...