Got feedback or spotted a mistake?

Leave a comment at the end of this page or email contact@krishagni.com

How to reset label sequences?

OpenSpecimen allows to auto-generate labels based on various tokens. For more details, refer to Label configuration.

When a new center starts using OpenSpecimen, the legacy data might be in other sources like Excel, different DB, etc. Once the legacy data is imported, the sequences of new participants and specimens need to start from the last number of legacy data. To achieve this, the administrator has to reset the sequences based on the tokens used. Currently, this is achieved using SQLs. Below are some examples:

Please take a backup of the database before running any SQLs

If there are sequence records for the same key_type and key_value, it needs to be deleted before new entries are created



Level

Token

SQL to reset sequence

Level

Token

SQL to reset sequence

Specimen

SYS_UID

Oracle

insert into key_seq_generator (identifier, key_type, key_value, key_sequence_id) values (key_generator_seq.nextval, 'Specimen', 'SYS_UID', <max specimen number like 1000>);

MySQL

insert into key_seq_generator (key_type, key_value, key_sequence_id) values ('Specimen', 'SYS_UID', <max specimen number like 1000>);

Note: If the table key_seq_generator already has a row for the combination ('Specimen', 'SYS_UID') then update the row with the new sequence value using below SQL.