Ubah Endpoint patientIdCheck menjadi patientCheck
This commit is contained in:
parent
e7f568f8fa
commit
850119316c
@ -19,7 +19,7 @@ $routes->post('/api/patient', 'Patient::create');
|
||||
$routes->get('/api/patient/(:num)', 'Patient::show/$1');
|
||||
$routes->delete('/api/patient/(:num)', 'Patient::delete/$1');
|
||||
$routes->patch('/api/patient/(:num)', 'Patient::update/$1');
|
||||
$routes->patch('/api/patient/patid-check/(:any)', 'Patient::patientIdCheck/$1');
|
||||
$routes->get('/api/patient/check', 'Patient::patientCheck');
|
||||
|
||||
$routes->get('/api/race', 'Race::index');
|
||||
$routes->get('/api/race/(:num)', 'Race::show/$1');
|
||||
|
||||
@ -488,34 +488,47 @@ class Patient extends Controller {
|
||||
}
|
||||
}
|
||||
|
||||
public function patientIdCheck($PatientID = null) {
|
||||
// OK - Done
|
||||
public function patientCheck() {
|
||||
|
||||
try {
|
||||
if (empty($PatientID)) {
|
||||
return $this->failValidationError('PatientID is required.');
|
||||
|
||||
$PatientID = $this->request->getVar('PatientID');
|
||||
$EmailAddress1 = $this->request->getVar('EmailAddress1');
|
||||
|
||||
if ($PatientID!=null){
|
||||
$tableName = 'PatientID';
|
||||
$searchName = $PatientID;
|
||||
}
|
||||
|
||||
if ($EmailAddress1!=null){
|
||||
$tableName = 'EmailAddress1';
|
||||
$searchName = $EmailAddress1;
|
||||
}
|
||||
|
||||
$patient = $this->db->table('patient')
|
||||
->where('PatientID', $PatientID)
|
||||
->where($tableName, $searchName)
|
||||
->get()
|
||||
->getRowArray();
|
||||
|
||||
if (!$patient) {
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
'message' => "PatientID {$PatientID} not found.",
|
||||
'message' => "$tableName not found.",
|
||||
'data' => true,
|
||||
], 200);
|
||||
}
|
||||
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
'message' => "PatientID {$PatientID} already exists.",
|
||||
'message' => "$tableName already exists.",
|
||||
'data' => false,
|
||||
], 200);
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
log_message('error', $e->getMessage());
|
||||
return $this->failServerError('Something went wrong. Please try again later.');
|
||||
|
||||
} catch (\Exception $e) {
|
||||
// Error Server Mengembalikan 500
|
||||
return $this->failServerError('Something went wrong.'.$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user