fix patvisit route

This commit is contained in:
mahdahar 2025-10-21 09:55:28 +07:00
parent d7d90de798
commit e28b58282e
3 changed files with 11 additions and 12 deletions

View File

@ -32,8 +32,8 @@ $routes->get('/api/patient/check', 'Patient\Patient::patientCheck');
$routes->get('/api/patvisit', 'PatVisit::index'); $routes->get('/api/patvisit', 'PatVisit::index');
$routes->post('/api/patvisit', 'PatVisit::create'); $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/patient/(:num)', 'PatVisit::showByPatient/$1');
$routes->get('/api/patvisit/(:any)', 'PatVisit::show/$1');
$routes->delete('/api/patvisit', 'PatVisit::delete'); $routes->delete('/api/patvisit', 'PatVisit::delete');
$routes->patch('/api/patvisit', 'PatVisit::update'); $routes->patch('/api/patvisit', 'PatVisit::update');

View File

@ -29,14 +29,12 @@ class PatVisit extends BaseController {
} }
public function showByPatient($InternalPID = null) { public function showByPatient($InternalPID = null) {
echo "dit tolongin dit";
try { try {
$row = $this->model->showByPatient($InternalPID); $rows = $this->model->showByPatient($InternalPID);
if($row == []) { if($rows == []) { $message = "data not found"; }
$message = "data not found"; else { $message = "data found"; }
} else { return $this->respond(['status' => 'success', 'message'=> $message, 'data' => $rows ], 200);
$message = "data found";
}
return $this->respond(['status' => 'success', 'message'=> $message, 'data' => $row ], 200);
} catch (\Exception $e) { } catch (\Exception $e) {
return $this->failServerError('Something went wrong '.$e->getMessage()); return $this->failServerError('Something went wrong '.$e->getMessage());
} }

View File

@ -25,10 +25,11 @@ class PatVisitModel extends BaseModel {
} }
public function showByPatient($InternalPID) { public function showByPatient($InternalPID) {
$rows = $this->join('patdiag pd', 'pd.InternalPVID=patvisit.InternalPVID', 'left') $rows = $this
->join('patvisitadt pva', 'pd.InternalPVID=pva.InternalPVID', 'left') //->join('patdiag pd', 'pd.InternalPVID=patvisit.InternalPVID', 'left')
->join('location l', 'l.LocationID=pva.LocationID', 'left') //->join('patvisitadt pva', 'pd.InternalPVID=pva.InternalPVID', 'left')
->where('patvisit.InternalPID',$InternalPID)->findAll(); //->join('location l', 'l.LocationID=pva.LocationID', 'left')
->where('InternalPID',$InternalPID)->findAll();
return $rows; return $rows;
} }