From afb99a2eb9f9fbe1bf4ea74c7d8208677660a893 Mon Sep 17 00:00:00 2001 From: mikael-zakaria Date: Fri, 8 Aug 2025 15:41:25 +0700 Subject: [PATCH] Update Patient Show, Menambahkan Join Tabel patient dan patidt --- app/Controllers/Patient.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/Controllers/Patient.php b/app/Controllers/Patient.php index a81a08c..aa9f7e0 100644 --- a/app/Controllers/Patient.php +++ b/app/Controllers/Patient.php @@ -61,8 +61,10 @@ class Patient extends Controller { try { - $builder = $this->db->table('patient'); - $patient = $builder->where('InternalPID', ((int) $InternalPID))->get()->getRowArray(); + $builder = $this->db->table('patient')->select('patient.*, patidt.Identifier, patidt.IdentifierType'); + $patient = $builder->join('patidt', 'patidt.InternalPID = patient.InternalPID') + ->where('patient.InternalPID', ((int) $InternalPID)) + ->get()->getRowArray(); // Data pasien tidak ada mengembalikan - success 200 if (empty($patient)) { @@ -143,12 +145,10 @@ class Patient extends Controller { 'Gender' => 'required' ]; - // ========================= - // 2. Data untuk tabel patidt - // ========================= $dataPatidt = [ "IdentifierType" => $input['IdentifierType'] ?? null, - "Identifier" => $input['Identifier'] ?? null + "Identifier" => $input['Identifier'] ?? null, + "CreateDate" => date('Y-m-d H:i:s'), ]; $rulesDataPatidt = [ @@ -194,7 +194,7 @@ class Patient extends Controller { $this->db->transComplete(); if ($this->db->transStatus() === false) { - $dbError = $this->db->error(); // ambil error terakhir + $dbError = $this->db->error(); return $this->failServerError( 'Failed to create patient data (transaction rolled back): ' . ($dbError['message'] ?? 'Unknown database error') );