broken patvisit
This commit is contained in:
parent
9145d74907
commit
33e7c84fc4
@ -30,7 +30,7 @@ $routes->delete('/api/patient', 'Patient\Patient::delete');
|
||||
$routes->patch('/api/patient', 'Patient\Patient::update');
|
||||
$routes->get('/api/patient/check', 'Patient\Patient::patientCheck');
|
||||
|
||||
//$routes->get('/api/patvisit', 'Patient::index');
|
||||
$routes->get('/api/patvisit', 'PatVisit::index');
|
||||
$routes->post('/api/patvisit', 'PatVisit::create');
|
||||
$routes->get('/api/patvisit/(:num)', 'PatVisit::show/$1');
|
||||
$routes->get('/api/patvisit/patient/(:num)', 'PatVisit::showByPatient/$1');
|
||||
@ -59,7 +59,7 @@ $routes->get('/api/contact', 'Contact\Contact::index');
|
||||
$routes->get('/api/contact/(:num)', 'Contact\Contact::show/$1');
|
||||
$routes->post('/api/contact', 'Contact\Contact::create');
|
||||
$routes->patch('/api/contact', 'Contact\Contact::update');
|
||||
$routes->delete('/api/contact', 'Contact\Contact::delete');
|
||||
$routes->delete('/api/contact', 'Contact\git Contact::delete');
|
||||
|
||||
$routes->get('/api/occupation', 'Contact\Occupation::index');
|
||||
$routes->get('/api/occupation/(:num)', 'Contact\Occupation::show/$1');
|
||||
|
||||
@ -2,10 +2,10 @@
|
||||
namespace App\Controllers;
|
||||
|
||||
use CodeIgniter\API\ResponseTrait;
|
||||
use CodeIgniter\Controller;
|
||||
use App\Models\PatVisitModel;
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\PatVisit\PatVisitModel;
|
||||
|
||||
class PatVisit extends Controller {
|
||||
class PatVisit extends BaseController {
|
||||
use ResponseTrait;
|
||||
|
||||
protected $model;
|
||||
@ -17,7 +17,7 @@ class PatVisit extends Controller {
|
||||
public function show($PVID = null) {
|
||||
try {
|
||||
$row = $this->model->show($PVID);
|
||||
return $this->respond([ 'status' => 'success', 'message'=> "data found", 'data' => $row ], 200);
|
||||
return $this->respond([ 'status' => 'success', 'message'=> "data found", 'data' => $row ], 200);
|
||||
} catch (\Exception $e) {
|
||||
return $this->failServerError('Something went wrong '.$e->getMessage());
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\BaseModel;
|
||||
class CounterModel extends BaseModel {
|
||||
protected $table = 'counter';
|
||||
protected $primaryKey = 'CounterID';
|
||||
|
||||
18
app/Models/PatVisit/PatDiagModel.php
Normal file
18
app/Models/PatVisit/PatDiagModel.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\PatVisit;
|
||||
use App\Models\BaseModel;
|
||||
|
||||
class PatDiagModel extends BaseModel {
|
||||
protected $table = 'patdiag';
|
||||
protected $primaryKey = 'InternalPVID';
|
||||
protected $allowedFields = ['InternalPID', 'DiagCode', 'Diagnosis', 'CreateDate', 'EndDate', 'ArchivedDate', 'DelDate'];
|
||||
protected $visnum_prefix;
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'CreateDate';
|
||||
protected $updatedField = '';
|
||||
protected $useSoftDeletes = true;
|
||||
protected $deletedField = 'DelDate';
|
||||
|
||||
}
|
||||
19
app/Models/PatVisit/PatVisitADTModel.php
Normal file
19
app/Models/PatVisit/PatVisitADTModel.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\PatVisit;
|
||||
use App\Models\BaseModel;
|
||||
|
||||
class PatVisitADTModel extends BaseModel {
|
||||
protected $table = 'patvisitadt';
|
||||
protected $primaryKey = 'PVADTID';
|
||||
protected $allowedFields = ['InternalPVID', 'ADTCode', 'LocationID', 'AttDoc', 'RefDoc', 'AdmDoc', 'CnsDoc',
|
||||
'CreateDate', 'EndDate', 'ArchivedDate', 'DelDate'];
|
||||
protected $visnum_prefix;
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'CreateDate';
|
||||
protected $updatedField = '';
|
||||
protected $useSoftDeletes = true;
|
||||
protected $deletedField = 'DelDate';
|
||||
|
||||
}
|
||||
@ -1,14 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
namespace App\Models\PatVisit;
|
||||
use App\Models\CounterModel;
|
||||
use App\Models\BaseModel;
|
||||
|
||||
class PatVisitModel extends BaseModel {
|
||||
protected $table = 'patvisit';
|
||||
protected $primaryKey = 'InternalPVID';
|
||||
protected $allowedFields = ['PVID', 'InternalPID', 'EpisodeID', 'CreateDate', 'EndDate'];
|
||||
protected $db;
|
||||
protected $allowedFields = ['PVID', 'InternalPID', 'EpisodeID', 'CreateDate', 'EndDate', 'ArchivedDate', 'DelDate'];
|
||||
protected $visnum_prefix;
|
||||
|
||||
protected $useTimestamps = true;
|
||||
@ -37,49 +36,35 @@ class PatVisitModel extends BaseModel {
|
||||
}
|
||||
|
||||
public function createPatVisit($input) {
|
||||
$db = \Config\Database::connect();
|
||||
try{
|
||||
//$input = $this->transformPatVisit($input);
|
||||
$db->transStart();
|
||||
if (!isset($input['PVID']) || $input['PVID']=='') {
|
||||
$counter = new CounterModel();
|
||||
$input['PVID'] = $this->visnum_prefix .$counter->use(2);
|
||||
}
|
||||
$this->db->transStart();
|
||||
|
||||
$this->insert($input);
|
||||
$InternalPVID = $this->getInsertID();
|
||||
|
||||
$InternalPVID = $this->insert($input, true);
|
||||
/*
|
||||
if(!empty($input['PatDiag'])) {
|
||||
$input['PatDiag']['InternalPVID'] = $InternalPVID;
|
||||
$this->db->table('patdiag')->insert($input['PatDiag']);
|
||||
$db->table('patdiag')->insert($input['PatDiag']);
|
||||
}
|
||||
if(!empty($input['PatVisitADT'])) {
|
||||
$input['PatVisitADT']['InternalPVID'] = $InternalPVID;
|
||||
$this->db->table('patvisitadt')->insert($input['PatVisitADT']);
|
||||
$db->table('patvisitadt')->insert($input['PatVisitADT']);
|
||||
}
|
||||
|
||||
$this->db->transComplete();
|
||||
$data = [ "PVID"=>$input['PVID'], "InternalPVID"=>$InternalPVID ];
|
||||
*/
|
||||
$db->transComplete();
|
||||
//$data = [ "PVID"=>$input['PVID'], "InternalPVID"=>$InternalPVID ];
|
||||
return $data;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$this->db->transRollback();
|
||||
$db->transRollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
private function transformPatVisit(array $input): array {
|
||||
|
||||
// Ubah jadi null saat string kosong
|
||||
$fields = ['LocationID','AttDoc', 'RefDoc', 'AdmDoc', 'CnsDoc'];
|
||||
foreach ($fields as $field) {
|
||||
if (isset($input['PatVisitADT'][$field]) && $input['PatVisitADT'][$field] === '') {
|
||||
$input['PatVisitADT'][$field] = null;
|
||||
}
|
||||
}
|
||||
|
||||
return $input;
|
||||
}
|
||||
|
||||
public function updatePatVisit($input) {
|
||||
$InternalPVID = $input['InternalPVID'];
|
||||
try{
|
||||
Loading…
x
Reference in New Issue
Block a user