Due to a bug in Tools -> Update Table Indexes, sometimes Extras IDs will be reused for multiple patients, effectively 'sharing' the data row.


To fix:


Run the following query a few times (3 or 4 times, until it stops modifying rows):


update 'patient.db' p
set p.'extra index' = 0
where p.'patient index' in
(
select min(p.'patient index')
from 'patient.db' p
where p.'extra index' > 0
group by p.'extra index'
having count(p.'patient index') > 1
)


Run the following query once:


update '!indxnum.db' i
set i.'index' = (select max(e.'extraindex') + 1 from 'extra2.db' e)
where i.'index name' = 'Extra'


This bug was fixed late 2018. All previous versions with the Tools -> Update Table Indexes were impacted.