add pva cr
This commit is contained in:
parent
95e44415cb
commit
a71a587573
@ -36,6 +36,8 @@ $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');
|
||||
$routes->post('/api/patvisitadt', 'PatVisit::createADT');
|
||||
$routes->patch('/api/patvisitadt', 'PatVisit::updateADT');
|
||||
|
||||
$routes->get('/api/race', 'Race::index');
|
||||
$routes->get('/api/race/(:num)', 'Race::show/$1');
|
||||
|
||||
@ -4,6 +4,7 @@ namespace App\Controllers;
|
||||
use CodeIgniter\API\ResponseTrait;
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\PatVisit\PatVisitModel;
|
||||
use App\Models\PatVisit\PatVisitADTModel;
|
||||
|
||||
class PatVisit extends BaseController {
|
||||
use ResponseTrait;
|
||||
@ -17,11 +18,8 @@ class PatVisit extends BaseController {
|
||||
public function show($PVID = null) {
|
||||
try {
|
||||
$row = $this->model->show($PVID);
|
||||
if($row == []) {
|
||||
$message = "data not found";
|
||||
} else {
|
||||
$message = "data found";
|
||||
}
|
||||
if($row == []) { $message = "data not found"; }
|
||||
else { $message = "data found"; }
|
||||
return $this->respond([ 'status' => 'success', 'message'=> $message, 'data' => $row ], 200);
|
||||
} catch (\Exception $e) {
|
||||
return $this->failServerError('Something went wrong '.$e->getMessage());
|
||||
@ -42,7 +40,6 @@ class PatVisit extends BaseController {
|
||||
public function update() {
|
||||
$input = $this->request->getJSON(true);
|
||||
try {
|
||||
// if(empty($input)){throw new \Exception('Input data is empty or invalid');}
|
||||
if (!$input["InternalPVID"] || !is_numeric($input["InternalPVID"])) { return $this->respond(['status' => 'error', 'message' => 'Invalid or missing ID'], 400); }
|
||||
$data = $this->model->updatePatVisit($input);
|
||||
return $this->respond(['status' => 'success', 'message' => 'Data updated successfully', 'data' => $data], 201);
|
||||
@ -54,7 +51,6 @@ class PatVisit extends BaseController {
|
||||
public function create() {
|
||||
$input = $this->request->getJSON(true);
|
||||
try {
|
||||
// if(empty($input)){throw new \Exception('Input data is empty or invalid');}
|
||||
$data = $this->model->createPatVisit($input);
|
||||
return $this->respond(['status' => 'success', 'message' => 'Data created successfully', 'data' => $data], 201);
|
||||
} catch (\Exception $e) {
|
||||
@ -62,4 +58,27 @@ class PatVisit extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
public function createADT() {
|
||||
$input = $this->request->getJSON(true);
|
||||
if (!$input["InternalPVID"] || !is_numeric($input["InternalPVID"])) { return $this->respond(['status' => 'error', 'message' => 'Invalid or missing ID'], 400); }
|
||||
$modelPVA = new PatVisitADTModel();
|
||||
try {
|
||||
$data = $modelPVA->insert($input, true);
|
||||
return $this->respond(['status' => 'success', 'message' => 'Data created successfully', 'data' => $data], 201);
|
||||
} catch (\Exception $e) {
|
||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function updateADT() {
|
||||
$input = $this->request->getJSON(true);
|
||||
if (!$input["PVADTID"] || !is_numeric($input["PVADTID"])) { return $this->respond(['status' => 'error', 'message' => 'Invalid or missing ID'], 400); }
|
||||
$modelPVA = new PatVisitADTModel();
|
||||
try {
|
||||
$data = $modelPVA->update($input['PVADTID'], $input);
|
||||
return $this->respond(['status' => 'success', 'message' => 'Data updated successfully', 'data' => $data], 201);
|
||||
} catch (\Exception $e) {
|
||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -89,7 +89,6 @@ class PatVisitModel extends BaseModel {
|
||||
|
||||
// patdiag
|
||||
$exist = $modelPD->where('InternalPVID',$InternalPVID)->find();
|
||||
$tmp = '';
|
||||
if($exist) {
|
||||
if( !empty($input['PatDiag']) && ( !empty($input['PatDiag']['DiagCode']) || !empty($input['PatDiag']['Diagnosis']) ) ) {
|
||||
$tmp = $modelPD->where('InternalPVID',$InternalPVID)->set($input['PatDiag'])->update();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user