FHM09062601IBL - end_session delegate ke endsession agar FE existing langsung pakai logic baru

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
sas.fajri
2026-06-11 09:42:22 +07:00
parent ee3ec98f44
commit 655757599a

View File

@@ -399,124 +399,7 @@ class Screening extends MY_Controller
}
function end_session(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$userID = $this->sys_user['M_UserID'];
//print_r($prm['subgroup']);
$sql = "SELECT COUNT(*) as xcount
FROM one_klinik.order_screening
WHERE
orderScreeningOrderID = ? AND orderScreeningIsActive = 'Y'";
$query = $this->db_oneklinik->query($sql,array($prm['orderID']));
if(!$query){
$this->sys_error("count exist");
echo $this->db_oneklinik->last_query();
}
$check_exist = $query->row()->xcount;
if($check_exist == 0){
$sql = "INSERT one_klinik.order_screening (
orderScreeningOrderID,
orderScreeningKesanUmum,
orderScreeningValueKesadaran,
orderScreeningValuePernafasan,
orderScreeningValueResikoJatuh,
orderScreeningValueNyeriDada,
orderScreeningValueSkalaNyeri,
orderScreeningValueBatuk,
orderScreeningValueKeputusan,
orderScreeningCreated,
orderScreeningUserID
)
VALUES(
?,?,?,?,?,?,?,?,?,NOW(),?
)";
$query = $this->db_oneklinik->query($sql,array(
$prm['orderID'],
$prm['kesan_umum'],
$prm['kesadaran'],
$prm['pernafasan'],
$prm['resiko_jatuh'],
$prm['nyeri_dada'],
$prm['skala_nyeri'],
$prm['batuk'],
$prm['keputusan'],
$userID)
);
if(!$query){
$this->sys_error("Gagal insert");
}
}else{
$sql = "UPDATE one_klinik.order_screening SET
orderScreeningKesanUmum = ?,
orderScreeningValueKesadaran = ?,
orderScreeningValuePernafasan = ?,
orderScreeningValueResikoJatuh = ?,
orderScreeningValueNyeriDada = ?,
orderScreeningValueSkalaNyeri = ?,
orderScreeningValueBatuk = ?,
orderScreeningValueKeputusan = ?,
orderScreeningUserID = ?
WHERE
orderScreeningOrderID = ?
";
$query = $this->db_oneklinik->query($sql,[
$prm['kesan_umum'],
$prm['kesadaran'],
$prm['pernafasan'],
$prm['resiko_jatuh'],
$prm['nyeri_dada'],
$prm['skala_nyeri'],
$prm['batuk'],
$prm['keputusan'],
$userID,
$prm['orderID']
]);
if(!$query){
echo $this->db_oneklinik->last_query();
$this->sys_error("Gagal Update");
}
}
$sql = "INSERT INTO one_klinik.order_status (
orderStatusOrderID,
orderStatusCode,
orderStatusValue,
orderStatusUserID
)
VALUES(
?,?,?,?
)";
$query = $this->db_oneklinik->query($sql,array($prm['orderID'],'S','D',$userID));
if(!$query){
$this->sys_error("Gagal End");
}
$sql = "UPDATE one_klinik.`order` SET orderIsScreening = 'D', orderUserID = ?
WHERE
orderID = ?";
$query = $this->db_oneklinik->query($sql,array($userID,$prm['orderID']));
if(!$query){
$this->sys_error("Gagal ENd");
}
$result = array('process'=>'OK');
$this->sys_ok($result);
exit;
$this->endsession();
}