Reporting an ID bug

If you create a patient it is assigned an id automatically lets say id =66. but if you delete tht entry no 66 and add another pt, the newly added pt is assigned the id no 67
BUT
when you open detailes of this pt no 67 from finer view, then next to the pt it shows one id less which is the deleted id no 66.

i was using id to sort n find pts, but this issue then changes the id no of pts.
if some one else has found a solution pl tell.

You should not be deleting anything in the database manually. Is that what you did? Make sure to use OpenEMR to disable / delete patients.

No no the delete button was clicked and then deleted.

So i feel the id around the pts name is not getting fetched from pid.

There are 3 ids as part of the standard code
id - internal serial, auto incremented
pid - set to max(pid)+1 during add
pubpid - set to pid during add but can be overwritten, displayed at top

Since code does not allow updates to pid you should not worry about corruption. Unless of course you find a scenario that you can replicate on demo system(s).

ok that solved my issue.
Instead of pointing to id, or pid now i pointed
Pt Unit No to pubpid, so on deleting a patient entry, the pubpid is increasing by an increment of 1 where as id skips the deleted no.

Thanks