diff --git a/app/Config/Routes.php b/app/Config/Routes.php index bcb7dca..8908f7d 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -32,8 +32,8 @@ $routes->get('/api/patient/check', 'Patient\Patient::patientCheck'); $routes->get('/api/patvisit', 'PatVisit::index'); $routes->post('/api/patvisit', 'PatVisit::create'); -$routes->get('/api/patvisit/(:any)', 'PatVisit::show/$1'); $routes->get('/api/patvisit/patient/(:num)', 'PatVisit::showByPatient/$1'); +$routes->get('/api/patvisit/(:any)', 'PatVisit::show/$1'); $routes->delete('/api/patvisit', 'PatVisit::delete'); $routes->patch('/api/patvisit', 'PatVisit::update'); diff --git a/app/Controllers/PatVisit.php b/app/Controllers/PatVisit.php index 4eb42ad..ecbe1e3 100644 --- a/app/Controllers/PatVisit.php +++ b/app/Controllers/PatVisit.php @@ -29,14 +29,12 @@ class PatVisit extends BaseController { } public function showByPatient($InternalPID = null) { + echo "dit tolongin dit"; try { - $row = $this->model->showByPatient($InternalPID); - if($row == []) { - $message = "data not found"; - } else { - $message = "data found"; - } - return $this->respond(['status' => 'success', 'message'=> $message, 'data' => $row ], 200); + $rows = $this->model->showByPatient($InternalPID); + if($rows == []) { $message = "data not found"; } + else { $message = "data found"; } + return $this->respond(['status' => 'success', 'message'=> $message, 'data' => $rows ], 200); } catch (\Exception $e) { return $this->failServerError('Something went wrong '.$e->getMessage()); } diff --git a/app/Models/PatVisit/PatVisitModel.php b/app/Models/PatVisit/PatVisitModel.php index 79d35fe..1aa1b8c 100644 --- a/app/Models/PatVisit/PatVisitModel.php +++ b/app/Models/PatVisit/PatVisitModel.php @@ -25,10 +25,11 @@ class PatVisitModel extends BaseModel { } public function showByPatient($InternalPID) { - $rows = $this->join('patdiag pd', 'pd.InternalPVID=patvisit.InternalPVID', 'left') - ->join('patvisitadt pva', 'pd.InternalPVID=pva.InternalPVID', 'left') - ->join('location l', 'l.LocationID=pva.LocationID', 'left') - ->where('patvisit.InternalPID',$InternalPID)->findAll(); + $rows = $this + //->join('patdiag pd', 'pd.InternalPVID=patvisit.InternalPVID', 'left') + //->join('patvisitadt pva', 'pd.InternalPVID=pva.InternalPVID', 'left') + //->join('location l', 'l.LocationID=pva.LocationID', 'left') + ->where('InternalPID',$InternalPID)->findAll(); return $rows; }