Files
2026-05-25 20:01:37 +07:00

73 lines
2.4 KiB
PHP

<?php
class Result extends MY_Controller
{
function __construct()
{
parent::__construct();
}
function getResult()
{
try {
if (!$this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$userid = $this->sys_user['M_UserM_DoctorID'];
$patientId = "";
if (isset($prm['patientId'])) {
$patientId = trim($prm["patientId"]);
} else {
echo json_encode([
"status" => "ERR", "message" => 'Patient id is mandatory',
]);
exit;
}
$sqlCek = "SELECT * FROM one_doctor.order_patient
WHERE OrderPatientID = ?
AND OrderPatientM_DoctorID = ?";
$qryCek =
$this->db->query($sqlCek, [intval($patientId), intval($userid)]);
if (!$qryCek) {
$this->sys_error_db("Error Matching Data");
exit;
}
$resCek = $qryCek->result_array();
if (count($resCek) >= 1) {
$sql = "SELECT oneResultJson FROM one_doctor.one_result
WHERE oneResultOrderPatientID = ?
";
$qry = $this->db->query($sql, [intval($patientId)]);
if (!$qry) {
$this->sys_error_db(
"Error Get Result "
);
exit;
}
$result = $qry->result_array();
$arrResult = array();
if (count($result) > 0) {
foreach ($result as $key => $value) {
$jsonResult = json_decode($value['oneResultJson']);
$arrResult[] = $jsonResult;
}
}
// $result = array(
// $arrResult
// );
// "sql" => $this->db->last_query()
$this->sys_ok($arrResult);
} else {
$this->sys_error_db(
"Not Your Patient " . $userid
);
}
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
}