I’ve noticed that the patient identifier, or “pid”, is a numeric value which is auto-generated using an “optimistic” database query. Just meaning that there isn’t any locking which means that a race condition could occur based on how many users are in the system, along with what they’re doing.
I’m not suggesting we add share locks and such into the code, as that may lead you down another rabbit hole. Rather would it make sense to migrate the pid column to utilize an “auto-incrementing” database column? This would allow OpenEMR to have a patient id that is physically separate from the database’s primary key, while allowing the database to handle allocating the value and the concurrency aspects. To be fair, this change would require a more complex deployment (code updates + SQL), but it would remove the complexity in managing this identifier.
If there is interest in taking a look at this, I can add it to “the backlog”.