From 9ba5121cda42b1fbb98396f8c3a37dbfb690b29e Mon Sep 17 00:00:00 2001 From: mikael-zakaria Date: Mon, 11 Aug 2025 14:37:47 +0700 Subject: [PATCH] Update Patient create, perbaikan LinkTo --- app/Controllers/Patient.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/Controllers/Patient.php b/app/Controllers/Patient.php index f6aff20..3083c3b 100644 --- a/app/Controllers/Patient.php +++ b/app/Controllers/Patient.php @@ -81,13 +81,23 @@ class Patient extends Controller { } else { + if ($patient['LinkTo'] != null) { + + $ids = explode(',', $patient['LinkTo']); // dari string jadi array + $patientLinkTo = $this->db->table('patient') + ->select('InternalPID, PatientID') + ->whereIn('InternalPID', $ids) + ->get() + ->getResultArray(); + $patient["LinkTo"] = $patientLinkTo == [] ? null : $patientLinkTo; + } + $patidt = $this->db->table('patidt') ->select('PatIdtID, IdentifierType, Identifier') ->where('InternalPID', (int) $InternalPID) ->get() ->getResultArray(); - - $patient['Identity'] = $patidt; + $patient['Identity'] = $patidt == [] ? null : $patidt; } // Data pasien ditemukan dan mengembalikan - success 200