Table of Contents |
---|
...
This process is designed to terminate declaration make changes in system according to uploaded by NHS admin registers. As for now declaration could be terminated and person's authentication method could be reset.
Apiary
Uploading and processing registers
...
The file is saving to database (il.registers) and based on it
Termination of declaration
- Person
- 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".
- Declaration
- if declaration was not found, the status of declaration_id will be "NOT_FOUND".
- if declaration was found in status=TERMINATED, declaration will not be terminated and this id will have status "PROCESSED"
- if declaration was found in status<>TERMINATED, declaration will be terminated and status of declaration_id will be "MATCHED"
- if unexpected error happened declaration_id will be in status "ERROR"
Reset authentication method
- Person
- if the person was matched, authentication method will be reseted and this id will have status "MATCHED".
- If the person wasn't matched the status will be "NOT_FOUND".
Register file statuses
- If the file was processed with errors in lines or without it will be in status "PROCESSED"
- If the file could nor be parsed as it is not correct it will be in status "INVALID"
- If the file was just add - it will be in status "NEW"
...
Death registration
- type (il.dictionary: name='DOCUMENT_TYPE')
- number
- death_date
- file example: person_example.csv
Termination by declaration_id
- declaration_id
- file example: declaration.csv
- declaration_id
Reset authentication method
- person_id
- file example:
- person_id
At least one of fields must be filled. Also choose the type of register (drop down list - dictionary: name='REGISTER_TYPE', type='death_registration,fraud,authentication_method').
Validation
Validate file
...
- Validate headers – should be type,number
- in case headers are different return error 422, msg 'Incorrect headers in file'
- Validate that $type exists in dictionary (name='REGISTER_TYPE').
- In case error show the 422 error "value is not allowed in enum"
- Validate declaration_id
- in case declaration_id was not found in ops.declarations.id
- show the row with not found ID with status "not_found"
- in case $declaration_id.status <> active
- show the row with ID with status "processed"
- in case $declaration_id can not be deactivated
- show the row with declaration ID with status "error"
- in case declaration_id was not found in ops.declarations.id
- In case technical error happened, but declaration found
- show the row with not found ID with status "error"
In case file structure = Reset authentication method
- Validate headers – should be person_id
- in case headers are different return error 422, msg 'Incorrect headers in file'
- Validate person_id
- in case person_id is not UUID ("^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$")
- show the row with not found MPI_ID with status "error"
- in case person_id was not found in mpi.persons.id
- show the row with person_id with status "not_found"
- in case person_id was found, but could not be deactivated
- show row with MPI_ID with status "processed"
- in case person_id is not UUID ("^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$")
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 | |
person_type | enum(employee,patient) | |
type | $type | document_type |
number | $number | document_number |
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.
...
If the person was matched then
- update declarations.status to `terminated`
- update persons.status='INACTIVE'
- change declarations.reason to $"auto_"||type
- update il.registers.status='matched'
- update mpi.persons.death_date = $death_date
...
If declaration_id was matched
- update ops.declarations.status to `terminated`
- update ops.declaration.updated_at = now()
- update ops.declaration.updated_by = $user_id
- change declarations.reason to $"auto_"||type
- update il.registers.status='matched'
- involve Event Manager for changed status
Reset authentication method
If the person was matched then
- update mpi.person_authentication_methods.type to `NA`
- update mpi.person_authentication_methods.phone_number to `null`
- update mpi.person_authentication_methods.updated_at to `now`
- 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.
...