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 |
---|---|---|
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 update
key_seq_generator
set
key_sequence_id = <max specimen number like 1000>
where
key_type = 'Specimen' and
key_value = 'SYS_UID'; |
Participant (Registration) | SYS_UID | To check if there is a value already present
To update the value (if a value is already present):
To insert a value (if no value is present) (MySQL): |
Participant | CP_UID(n) | Oracle MySQL
|
Visit | EVENT_UID(n) | Check for presence of any existing sequences
If the token is used for create KIT-NAMES for visits, the use below query to find the existing counter:
Oracle: Recreate sequences for all visits
MySQL: : Recreate sequences for all visits
Note: If the table Delete all pre-existing sequences |
Visit | PPI_UID | Check for presence of any existing sequences
|
Visit | PUID | Check for presence of any existing sequences
|
Visit | VISIT_UID | Check for existing sequence
|
Visit | SYS_UID | Oracle MySQL
Note: If the table |
Specimen | PSPEC_UID | Check for presence of any pre-existing sequences
Delete pre-existing sequences Oracle: Recreate sequences for all parent specimens
|
Specimen | CP_PPI_UID | Oracle
|
Specimen | VISIT_SP_TYPE_UID | Note: If the table MySQL
Delete pre-existing sequences
MySQL: Recreate sequences for all specimens |
Specimen | PPI_SPEC_TYPE_UID | Check for presence of any pre-existing sequences
MySQL: : Recreate sequences for all primary specimens
Resetting existing sequence:
|
Distribution Protocol | DP_UID | Oracle MySQL
|
Specimen | PRIMARY_SPMN_SP_TYPE_ABBR_UID | Delete pre-existing sequences MySQL: Recreate sequences |
Specimen | SPEC_CP_UID | Resetting existing key sequence ID Adding the new key sequence ID |
Leave a comment at the end of this page or email contact@krishagni.com