Versions Compared

Key

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

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

Table of Contents

Purpose

This process is designed to 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.

...

Uploading and processing registers

Terminate declaration

...

Logic

NHS admin download files with fields according to file structure.

...

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

  1. If the file was processed with errors in lines or without it will be in status "PROCESSED"

  2. If the file could nor be parsed as it is not correct it will be in status "INVALID"

  3. If the file was just add - it will be in status "NEW"

File structure

  1. Death registration

    • type (il.dictionary: name='PERSONS_DEACTIVATION_IDENTITIES')

    • number

...

  1. Termination by declaration_id

  2. Reset authentication method

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

  1. In case file in not a csv file 

    1. set status INVALID and stop processing the file

In case file structure = Death registration of patients

  1. Validate that $document.type 

    1. one of from dictionary (name='PERSONS_DEACTIVATION_IDENTITIES') or is MPI_ID. If type is not as in dictionary or not MPI_ID show the row in the errors field.

  2. Validate MPI_ID

    1.  in case MPI_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}$")

      1. show the row with not found MPI_ID with status "error"

    2. in case MPI_ID was not found in mpi.persons.id

...

      1. show the row with MPI_ID with status "not_found"

    1. in case MPI_ID was found

...

    1. , but could not be deactivated

      1. show row with MPI_ID with status "processed"

...

  1. show row with MPI_ID with status "processed"

...

  1. Validate death_date if exists

    1. in

...

    1. case death_date <> valid date ()

      1. show the row with MPI_ID with status "date_error"

    2. in case

...

    1. death_date does not exist

      1. show the row with MPI_ID with status "date_error"

    2. in case

...

    1. death_date year < 1900

      1. show the row with MPI_ID with status "date_error"

    2. in case

...

    1. death_date < birth_date

      1. show the row with MPI_ID with status "date_error"

      2. Validate that $type one of from dictionary (name='REGISTER_TYPE'). If type is not as in dictionary show the 422 error 'Incorrect register type'

      3. Validate headers in file: type, number, deathDatedeath_date. In case of error show the 422 error 'Incorrect headers in file' 

In case file structure = Termination by declaration_id

  1. Validate headers – should be type,number

    1. in case headers are different return error 422, msg 'Incorrect headers in file' 

  2. Validate that $type exists in dictionary (name='REGISTER_TYPE').

    1. In case error show the 422 error "value is not allowed in enum"

  3. Validate declaration_id

    1. in case declaration_id was not found in ops.declarations.id

      1. show the row with not found ID with status "not_found"

    2. in case $declaration_id.status <> active

      1. show the row with ID with status "processed"

    3. in case $declaration_id can not be deactivated

      1. show the row with declaration ID with status "error"

  4. In case technical error happened, but declaration found

    1. show the row with not found ID with status "error"

In case file structure = Reset authentication method

  1. Validate headers – should be person_id

    1. in case headers are different return error 422, msg 'Incorrect headers in file' 

  2. Validate person_id

    1.  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}$")

      1. show the row with not found MPI_ID with status "error"

    2. in case person_id was not found in mpi.persons.id

      1. show the row with person_id with status "not_found"

    3. in case person_id was found, but could not be deactivated

      1. show row with MPI_ID with status "processed"

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

, preperson

)


type

$type

document_type

number

$number

document_number

status

  • processing

  • matched, not_found


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 the person was matched then

  1. update declarations.status to `terminated`

  2. update persons.status='INACTIVE'

  3. change declarations.reason to $"auto_"||type

  4. update il.registers.status='matched'

  5. update mpi.persons.death_date =

...

  1. $death_date

If the person was found, but declaration not in status "active" - il.registers.status='matched'

...

If the person was not matched then

  1. update il.registers.status='not_found'

If declaration_id was matched

  1. update ops.declarations.status to `terminated`

  2. update ops.declaration.updated_at = now()

  3. update ops.declaration.updated_by = $user_id

  4. change declarations.reason to $"auto_"||type

  5. update il.registers.status='matched'

  6. involve Event Manager for changed status 

Reset authentication method

If the person was matched then

  1. update mpi.person_authentication_methods.

...

  1. type to `NA`

  2. update mpi.person_authentication_methods.phone_

...

  1. number to `null`

  2. update mpi.person_authentication_methods.updated_

...

  1. at to `now`

  2. 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

...

  1. update medical_data.patients.status='inactive'

  2. update il.registers.status='matched'

  3. update medical_data.patients.death_date = $death_date

  4. update medication requests related to preperson if status is NEW. Set status = 'REJECTED'.

  5. update medication request request related to preperson if status is ACTIVE. Set status = 'REJECTED'.

...

person

...

was not matched then

  1. 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.

...

Update  il.registers_stats calculating quantities (qty):

  • not_found=count(not_found)

  • processing=count(processing)

  • errors = count(errors)

  • qty_total=count(*)