ЕСОЗ - публічна документація

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 26 Next »

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 according to file structure.

File should be in .csv format and is converted to base64 by FE.

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

  1. Death registration

  2. Termination by declaration_id

    • declaration_id
      • file example: 

At least one of fields must be filled. Also choose the type of register (drop down list - dictionary: name='REGISTER_TYPE', type='death_registration'). 

Validation

In case file structure = Death registration

  1. Validate that document $type one of from dictionary (name='DOCUMENT_TYPE'). If type is not as in dictionary show the row in the errors field. 

      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. In case of error show the 422 error 'Incorrect headers in file' 

In case file structure = Termination by declaration_id

  1. Validate headers – ?
  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 uniqueness on declaration_id data
    1. in case declaration_id repeated more then once show error 422, msg "Declaration_id in file should be unique. Please, check your file" 
  4. Validate declaration_id
    1. in case declaration_id does not match the pattern "^[0-9a-f]{8}(-?)[0-9a-f]{4}(-?)[0-9a-f]{4}(-?)[0-9a-f]{4}(-?)[0-9a-f]{12}$" 
      1. show the row with unmatched id in the error field with msg "String X does not match pattern \"^[0-9a-f]{8}(-?)[0-9a-f]{4}(-?)[0-9a-f]{4}(-?)[0-9a-f]{4}(-?)[0-9a-f]{12}$\""
    2. in case declaration_id was not find in ops.declarations.id
      1. show the row with not found ID in the error field with msg "String X - declaration was not find in DataBase"
    3. in case $declaration_id.status <> active
      1. show the row with declaration_id in the error field with msg "String X - declaration status is not active"

Table structure

Each uploaded file must be added to the table:  il.registers with status='new'.

NameSourceDescription
id$batch_idid=batch_id from il.registers
file_name$file_namefile_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$typetype=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_atuser_id
inserted_by:timestamp
updated_atuser_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 SourceDescription
id

register_id
the unique id for the batch upload
person_typeenum(employee,patient)
type$typedocument_type
number$numberdocument_number
status
  • processing
  • matched, not_found

inserted_atuser_idfrom token
inserted_by:timestamp
updated_atuser_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'

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

  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 

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(*)


  • No labels