This works fine to query whether or not the patient exists but then dies when trying to create patients. Actually, it creates the first patient, but then dies on subsequent patients with the error Duplicate entry ‘0’ for key ‘patient_data.pid’ due to the fact that the pid is being set to 0 and is not being autoincremented (assuming that is even OK).
I am a noob to openemr and am just figuring things out as I go. Is it OK to query and find the last/highest pid and just start autoincrementing from there? Ideally I’d like to call openemr methods to do this work, but do they exist? I found library/patient.inc and the newPatientData() which looks promising, but I’m not sure how to call this method from within my script.
I did try adding require_once DIR.’/interface/globals.php’ to my script in hopes of getting access to some of these methods but am getting the error Site ID is missing from session data! when I try that.
Thanks…that looks like exactly what I need Could you share some guidance on how to make it accessible to my script?
I’ve tried adding require_once DIR.’/src/Services/PatientService.php’; and I get an error on line 25 of patient service. Also tried added globals but am getting the session error I mentioned above.