Add resume status upsert and publish table SQL
This commit is contained in:
@@ -29,6 +29,68 @@ class Mcudashboard
|
||||
return array(false, "invalid source argument");
|
||||
}
|
||||
|
||||
public function upsert_patient_resume_status($Mcu_ResumeID = 0)
|
||||
{
|
||||
$Mcu_ResumeID = intval($Mcu_ResumeID);
|
||||
if ($Mcu_ResumeID <= 0) {
|
||||
return array(false, "invalid Mcu_ResumeID");
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
mr.Mcu_ResumeID,
|
||||
mr.Mcu_ResumeStatus,
|
||||
mr.Mcu_ResumeValidation,
|
||||
oh.T_OrderHeaderID,
|
||||
oh.T_OrderHeaderMgm_McuID AS mcu_id,
|
||||
pp.Mcu_PreregisterPatientsID AS preregister_id,
|
||||
IFNULL(pmd.Published_McuDasboardStatus, 'N') AS published_status
|
||||
FROM mcu_resume mr
|
||||
JOIN t_orderheader oh ON oh.T_OrderHeaderID = mr.Mcu_ResumeT_OrderHeaderID
|
||||
AND oh.T_OrderHeaderIsActive = 'Y'
|
||||
JOIN mcu_preregister_patients pp ON pp.Mcu_PreregisterPatientsT_OrderHeaderID = oh.T_OrderHeaderID
|
||||
AND pp.Mcu_PreregisterPatientsIsActive = 'Y'
|
||||
LEFT JOIN published_mcu_dashboard pmd ON pmd.Published_McuDasboardT_OrderHeaderID = oh.T_OrderHeaderID
|
||||
AND pmd.Published_McuDasboardIsActive = 'Y'
|
||||
WHERE mr.Mcu_ResumeID = ? AND mr.Mcu_ResumeIsActive = 'Y'
|
||||
LIMIT 1";
|
||||
$qry = $this->db_onedev->query($sql, array($Mcu_ResumeID));
|
||||
if (!$qry) {
|
||||
return array(false, $this->db_onedev->error()["message"]);
|
||||
}
|
||||
if ($qry->num_rows() === 0) {
|
||||
return array(false, "resume not found");
|
||||
}
|
||||
|
||||
$row = $qry->row_array();
|
||||
|
||||
$sql = "INSERT INTO mcu_patient_resume_status (
|
||||
Mcu_PatientResumeStatusPreregisterID,
|
||||
Mcu_PatientResumeStatusMcuID,
|
||||
Mcu_PatientResumeStatusStatus,
|
||||
Mcu_PatientResumeStatusValidated,
|
||||
Mcu_PatientResumeStatusPublished,
|
||||
Mcu_PatientResumeSyncedAt
|
||||
) VALUES (?, ?, ?, ?, ?, NOW())
|
||||
ON DUPLICATE KEY UPDATE
|
||||
Mcu_PatientResumeStatusStatus = VALUES(Mcu_PatientResumeStatusStatus),
|
||||
Mcu_PatientResumeStatusValidated = VALUES(Mcu_PatientResumeStatusValidated),
|
||||
Mcu_PatientResumeStatusPublished = VALUES(Mcu_PatientResumeStatusPublished),
|
||||
Mcu_PatientResumeSyncedAt = NOW()";
|
||||
$ok = $this->db_dashboard->query($sql, array(
|
||||
intval($row['preregister_id']),
|
||||
intval($row['mcu_id']),
|
||||
$row['Mcu_ResumeStatus'],
|
||||
$row['Mcu_ResumeValidation'],
|
||||
$row['published_status']
|
||||
));
|
||||
|
||||
if (!$ok) {
|
||||
return array(false, $this->db_dashboard->error()["message"]);
|
||||
}
|
||||
|
||||
return array(true, "ok");
|
||||
}
|
||||
|
||||
private function upsert_from_lab($orderSampleID)
|
||||
{
|
||||
$sql = "SELECT
|
||||
|
||||
Reference in New Issue
Block a user