Purpose
This process is designed to terminate declaration according to uploaded by NHS admin registers.
Apiary
Uploading and processing registers
WS Logic
NHS admin download files with fields tax_id, national_id, passport, birth_certificate, temporary_certificate. At least one of the field must be not empty.
The file is saving to database (il.registers) and based on it if the person was matched, declaration will be terminated and this id will have status "matched". If the person wasn't matched the status will be "not_found". In case some errors happened and the row wasn't processed the status will be "processing".
File structure
- Tax_id
- national_id
- passport
- birth_certificate
- temporary_certificate
At least one of fields must be filled. Also choose the type of register (drop down list - dictionary: name='REGISTER_TYPE', type='death_registration'). As for now we have only one type of auto termination declaration - patient's death.
Table structure
Each uploaded file must be added to the table: il.registers with status='new'.
Name | Source | Description |
---|---|---|
id | $batch_id | id=batch_id from il.registers |
file_name | $file_name | file_name=file_name from il.registers |
status | [new, processing, processed ] | new - file was downloaded and not processed processing - when processing entries>0 processed - when processing entries=0 |
type | $type | type=type from il.dictionaries.name='REGISTER_TYPE' |
qty | {not_found: number, processing: number, errors: number, total: number} | |
errors | ["Row has length 4 - expected length 5 on line 5", "Row has length 1 - expected length 5 on line 7"] | |
inserted_at | user_id | |
inserted_by | :timestamp | |
updated_at | user_id | |
updated_by | :timestamp |
The data from file must be stored to il.register_entries. In case some rows had errors those entries will be shown in filed "errors" and won't be processed.
Name | Source | Description |
---|---|---|
id | ||
register_id | the unique id for the batch upload | |
tax_id | $tax_id | |
national_id | $national_id | |
passport | $passport | |
birth_certificate | $birth_certificate | |
temporary_certificate | $temporary_certificate | |
status |
| |
inserted_at | user_id | from token |
inserted_by | :timestamp | |
updated_at | user_id | |
updated_by | :timestamp |
After the file was processed the field "qty" from table il.registers must be updated.
Terminate declaration
If few fields are filled in the file then priority must be next: tax_id, national_id, passport, birth_certificate, temporary_certificate.
If the person was matched then
- update declarations.status to `terminated`
- change declarations.reason to $"auto_"||type
- update il.registers.status='matched'
If the person was found, but declaration not in status "active" - il.registers.status='matched'
If the person was found, but declaration doesn't exist - il.registers.status='matched'
If the person was not matched then
- update il.registers.status='not_found'
Backward compatibility is not possible for this kind of termination. In case the wrong declaration was terminated, the patient must sign the new one.
Statistic for terminated declaration
Update il.registers_stats calculating quantities (qty):
- not_found=count(not_found)
- processing=count(processing)
- errors = count(errors)
- qty_total=count(*)