diff --git a/contrib/util/dupecheck/mergerecords.php b/contrib/util/dupecheck/mergerecords.php new file mode 100644 index 00000000000..dad7a71b187 --- /dev/null +++ b/contrib/util/dupecheck/mergerecords.php @@ -0,0 +1,146 @@ + + + +
+ +"; + + UpdateTable("batchcom", "patient_id", $otherPID, $masterPID); + UpdateTable("immunizations", "patient_id", $otherPID, $masterPID); + UpdateTable("prescriptions", "patient_id", $otherPID, $masterPID); + UpdateTable("claims", "patient_id", $otherPID, $masterPID); + + UpdateTable("ar_activity", "pid", $otherPID, $masterPID); + UpdateTable("billing", "pid", $otherPID, $masterPID); + UpdateTable("drug_sales", "pid", $otherPID, $masterPID); + UpdateTable("issue_encounter", "pid", $otherPID, $masterPID); + UpdateTable("lists", "pid", $otherPID, $masterPID); + UpdateTable("payments", "pid", $otherPID, $masterPID); + UpdateTable("pnotes", "pid", $otherPID, $masterPID); + UpdateTable("transactions", "pid", $otherPID, $masterPID); + + UpdateTable("chart_tracker", "ct_pid", $otherPID, $masterPID); + UpdateTable("openemr_postcalendar_events", "pc_pid", $otherPID, $masterPID); + UpdateTable("documents", "foreign_id", $otherPID, $masterPID); + + // update all the forms* tables + $sqlstmt = "show tables like 'form%'"; + $qResults = mysql_query($sqlstmt, $oemrdb); + while ($row = mysql_fetch_assoc($qResults)) { + UpdateTable($row['Tables_in_'.$sqlconf["dbase"].' (form%)'], "pid", $otherPID, $masterPID); + } + + // How to handle the data that should be unique to each patient: + // Demographics, Employment, Insurance, and History ?? + // + //UpdateTable("patient_data", "pid", $otherID, $$parameters['masterid']); + //UpdateTable("employer_data", "pid", $otherPID, $masterPID); + //UpdateTable("history_data", "pid", $otherPID, $masterPID); + //UpdateTable("insurance_data", "pid", $otherPID, $masterPID); + + // alter the patient's last name to indicate they have been merged into another record + $newlname = "~~~MERGED~~~".$orow['lname']; + $sqlstmt = "update patient_data set lname='".$newlname."' where pid='".$otherPID."'"; + if ($commitchanges == true) $qResults = mysql_query($sqlstmt, $oemrdb); + echo "