This is more of a report than a request for help. It is to document what I have run into again. I have just upgraded from 4.2.2 and the patient_data table has 25113 records. When they try to create a new patient with the native code there is an error thrown by the database that says there is a duplicate record 10000.
To fix this issue, I changed the code from this.
$result = sqlQuery(“SELECT MAX(pid)+1 AS pid FROM patient_data”);
$newpid = 1;
if ($result[‘pid’] > 1) $newpid = $result[‘pid’];
To this:
$result = sqlQuery(“SELECT id AS pid FROM patient_data ORDER BY id DESC LIMIT 1”);
$newpid = 1;
if ($result[‘pid’] > 1) $newpid = $result[‘pid’] + 1; //Changed by Sherwin
setpid($newpid);
There seems to be a limit as to how many records the MAX(pid)+1 can read. It always stops at 10000.