foreach ($testRecords as $testRecord) { if ($testIds[$labConfigId] == $testRecord->testTypeId) { $testRecord->testTypeId = $testIds[$importLabConfigId]; } } } } DbUtil::switchRestore($saved_db); $saved_db = DbUtil::switchToLabConfig($importLabConfigId); $querySelect = "SELECT * FROM patient " . "WHERE patient_id={$importPatientId}"; $record = query_associative_one($querySelect); $patientName = $record['name']; $patient = Patient::getObject($record); $patient->createdBy = $_SESSION['user_id']; DbUtil::switchRestore($saved_db); add_patient($patient, true); /* $querySelect = "SELECT patient_id FROM patient ". "WHERE name like '$patientName' "; $record = query_associative_one($querySelect); $newPatientId = $record['patient_id']; */ /* Create New Specimen & Test Records */ $i = 0; foreach ($specimenRecords as $specimenRecord) { $saved_db = DbUtil::switchToLabConfig($importLabConfigId); $querySelect = "SELECT * FROM test " . "WHERE specimen_id={$specimenRecord->specimenId}"; $resultset = query_associative_all($querySelect, $rowcount); DbUtil::switchRestore($saved_db); //$specimenRecord->specimenId = get_max_specimen_id() + 1;
} else { if ($_REQUEST['pd_y'] == 1) { # Partial DOB with year only $dob = ""; $partial_dob = trim($_REQUEST['yyyy']); } else { # Full DOB or age $dob = trim($_REQUEST['yyyy']) . "-" . trim($_REQUEST['mm']) . "-" . trim($_REQUEST['dd']); $partial_dob = ""; } } } if ($age == "") { $age = 0; } $sex = $_REQUEST['sex']; $patient = new Patient(); $patient->patientId = $card_num; $patient->addlId = $addl_id; $patient->name = $name; $patient->dob = $dob; $patient->partialDob = $partial_dob; $patient->age = $age; $patient->sex = $sex; $patient->regDate = $date_receipt; $patient->surrogateId = $pid; $patient->createdBy = $_SESSION['user_id']; update_daily_number_registration(); $patient_added = add_patient($patient); echo json_encode($patient_data); SessionUtil::restore($saved_session);
foreach ($testRecords as $testRecord) { if ($testIds[$labConfigId] == $testRecord->testTypeId) { $testRecord->testTypeId = $testIds[$importLabConfigId]; } } } } DbUtil::switchRestore($saved_db); $saved_db = DbUtil::switchToLabConfig($importLabConfigId); $querySelect = "SELECT * FROM patient " . "WHERE patient_id={$importPatientId}"; $record = query_associative_one($querySelect); $patientName = $record['name']; $patient = Patient::getObject($record); $patient->createdBy = $_SESSION['user_id']; DbUtil::switchRestore($saved_db); add_patient($patient); $querySelect = "SELECT patient_id FROM patient " . "WHERE name like '{$patientName}' "; $record = query_associative_one($querySelect); $newPatientId = $record['patient_id']; /* Create New Specimen & Test Records */ $i = 0; foreach ($specimenRecords as $specimenRecord) { $saved_db = DbUtil::switchToLabConfig($importLabConfigId); $querySelect = "SELECT * FROM test " . "WHERE specimen_id={$specimenRecord->specimenId}"; $resultset = query_associative_all($querySelect, $rowcount); DbUtil::switchRestore($saved_db); $specimenRecord->specimenId = get_max_specimen_id() + 1; $specimenRecord->patientId = $newPatientId; $specimenRecord->userId = $_SESSION['user_id']; $specimenRecord->doctor = ''; add_specimen($specimenRecord);