Reuse preregister form row
This commit is contained in:
@@ -163,22 +163,47 @@ class Order extends MY_Controller
|
||||
return lab_uuid_v4();
|
||||
}
|
||||
|
||||
function generate_code_form($preid, $orderid)
|
||||
{
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sql = "SELECT COUNT(*) as total
|
||||
FROM form_riwayat_pasien
|
||||
WHERE FormRiwayatPasienT_OrderHeaderID = ? AND
|
||||
FormRiwayatPasienIsActive = 'Y'
|
||||
";
|
||||
$qry = $this->db_onedev->query($sql, [$orderid]);
|
||||
//echo $this->db_onedev->last_query();
|
||||
//exit;
|
||||
if ($qry) {
|
||||
$total = $qry->result_array()[0]['total'];
|
||||
if ($total == 0) {
|
||||
$code = $this->generate_code_string();
|
||||
$uuid = $this->generate_uuid();
|
||||
function generate_code_form($preid, $orderid)
|
||||
{
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sql = "SELECT FormRiwayatPasienID, FormRiwayatPasienCode, FormRiwayatPasienUUID, FormRiwayatPasienT_OrderHeaderID
|
||||
FROM form_riwayat_pasien
|
||||
WHERE FormRiwayatPasienPreregisterID = ? AND
|
||||
FormRiwayatPasienIsActive = 'Y'
|
||||
ORDER BY FormRiwayatPasienID DESC
|
||||
LIMIT 1";
|
||||
$qry = $this->db_onedev->query($sql, [$preid]);
|
||||
if (!$qry) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$exist = $qry->row_array();
|
||||
if ($exist) {
|
||||
if ((int) $exist['FormRiwayatPasienT_OrderHeaderID'] !== (int) $orderid) {
|
||||
$sql = "UPDATE form_riwayat_pasien
|
||||
SET FormRiwayatPasienT_OrderHeaderID = ?,
|
||||
FormRiwayatPasienLasUpdated = NOW(),
|
||||
FormRiwayatPasienLasUpdatedUserID = ?
|
||||
WHERE FormRiwayatPasienID = ?";
|
||||
$qry = $this->db_onedev->query($sql, [$orderid, $userid, $exist['FormRiwayatPasienID']]);
|
||||
if (!$qry) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
return array('uuid' => $exist['FormRiwayatPasienUUID'], 'code' => $exist['FormRiwayatPasienCode']);
|
||||
}
|
||||
|
||||
$sql = "SELECT COUNT(*) as total
|
||||
FROM form_riwayat_pasien
|
||||
WHERE FormRiwayatPasienT_OrderHeaderID = ? AND
|
||||
FormRiwayatPasienIsActive = 'Y'
|
||||
";
|
||||
$qry = $this->db_onedev->query($sql, [$orderid]);
|
||||
if ($qry) {
|
||||
$total = $qry->result_array()[0]['total'];
|
||||
if ($total == 0) {
|
||||
$code = $this->generate_code_string();
|
||||
$uuid = $this->generate_uuid();
|
||||
|
||||
$sql = "INSERT INTO form_riwayat_pasien (
|
||||
FormRiwayatPasienPreregisterID,
|
||||
@@ -191,16 +216,14 @@ class Order extends MY_Controller
|
||||
$qry = $this->db_onedev->query($sql, [$preid, $code, $uuid, $orderid, $userid]);
|
||||
//echo $this->db_onedev->last_query();
|
||||
//exit;
|
||||
if (!$qry) {
|
||||
return '';
|
||||
}
|
||||
return array('uuid' => $uuid, 'code' => $code);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
if (!$qry) {
|
||||
return '';
|
||||
}
|
||||
return array('uuid' => $uuid, 'code' => $code);
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function check_duplicate_nat_tests($data)
|
||||
{
|
||||
|
||||
@@ -171,43 +171,53 @@ class Order extends MY_Controller
|
||||
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
|
||||
}
|
||||
|
||||
function generate_code_form($preid, $orderid)
|
||||
{
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sql = "SELECT COUNT(*) as total
|
||||
FROM form_riwayat_pasien
|
||||
WHERE FormRiwayatPasienPreregisterID = ? AND
|
||||
FormRiwayatPasienIsActive = 'Y'
|
||||
";
|
||||
$qry = $this->db_onedev->query($sql, [$preid]);
|
||||
//echo $this->db_onedev->last_query();
|
||||
//exit;
|
||||
if ($qry) {
|
||||
$total = $qry->result_array()[0]['total'];
|
||||
if ($total == 0) {
|
||||
$code = $this->generate_code_string();
|
||||
$uuid = $this->generate_uuid();
|
||||
|
||||
$sql = "INSERT INTO form_riwayat_pasien (
|
||||
FormRiwayatPasienPreregisterID,
|
||||
FormRiwayatPasienCode,
|
||||
FormRiwayatPasienUUID,
|
||||
FormRiwayatPasienT_OrderHeaderID,
|
||||
FormRiwayatPasienCreated,
|
||||
FormRiwayatPasienCreatedUserID)
|
||||
VALUES (?, ?, ?, ?, NOW(), ?)";
|
||||
$qry = $this->db_onedev->query($sql, [$preid, $code, $uuid, $orderid, $userid]);
|
||||
//echo $this->db_onedev->last_query();
|
||||
//exit;
|
||||
if (!$qry) {
|
||||
return '';
|
||||
}
|
||||
return array('uuid' => $uuid, 'code' => $code);
|
||||
}
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
function generate_code_form($preid, $orderid)
|
||||
{
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sql = "SELECT FormRiwayatPasienID, FormRiwayatPasienCode, FormRiwayatPasienUUID, FormRiwayatPasienT_OrderHeaderID
|
||||
FROM form_riwayat_pasien
|
||||
WHERE FormRiwayatPasienPreregisterID = ? AND
|
||||
FormRiwayatPasienIsActive = 'Y'
|
||||
ORDER BY FormRiwayatPasienID DESC
|
||||
LIMIT 1";
|
||||
$qry = $this->db_onedev->query($sql, [$preid]);
|
||||
if (!$qry) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$exist = $qry->row_array();
|
||||
if ($exist) {
|
||||
if ((int) $exist['FormRiwayatPasienT_OrderHeaderID'] !== (int) $orderid) {
|
||||
$sql = "UPDATE form_riwayat_pasien
|
||||
SET FormRiwayatPasienT_OrderHeaderID = ?,
|
||||
FormRiwayatPasienLasUpdated = NOW(),
|
||||
FormRiwayatPasienLasUpdatedUserID = ?
|
||||
WHERE FormRiwayatPasienID = ?";
|
||||
$qry = $this->db_onedev->query($sql, [$orderid, $userid, $exist['FormRiwayatPasienID']]);
|
||||
if (!$qry) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
return array('uuid' => $exist['FormRiwayatPasienUUID'], 'code' => $exist['FormRiwayatPasienCode']);
|
||||
}
|
||||
|
||||
$code = $this->generate_code_string();
|
||||
$uuid = $this->generate_uuid();
|
||||
|
||||
$sql = "INSERT INTO form_riwayat_pasien (
|
||||
FormRiwayatPasienPreregisterID,
|
||||
FormRiwayatPasienCode,
|
||||
FormRiwayatPasienUUID,
|
||||
FormRiwayatPasienT_OrderHeaderID,
|
||||
FormRiwayatPasienCreated,
|
||||
FormRiwayatPasienCreatedUserID)
|
||||
VALUES (?, ?, ?, ?, NOW(), ?)";
|
||||
$qry = $this->db_onedev->query($sql, [$preid, $code, $uuid, $orderid, $userid]);
|
||||
if (!$qry) {
|
||||
return '';
|
||||
}
|
||||
return array('uuid' => $uuid, 'code' => $code);
|
||||
}
|
||||
|
||||
function check_duplicate_nat_tests($data)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user