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