Merge branch 'main' of https://github.com/mahdahar/clqms-be
This commit is contained in:
commit
8a8f85a41e
@ -8,12 +8,6 @@ use CodeIgniter\Router\RouteCollection;
|
||||
$routes->options('(:any)', function() { return ''; });
|
||||
$routes->get('/', 'Home::index');
|
||||
|
||||
//PUNYA GUS INI TEMP
|
||||
$routes->get('/api/v1/emr/lab/list-new', 'NUHATEMP::index');
|
||||
$routes->post('/api/v1/emr/lab/insert', 'NUHATEMP::create');
|
||||
$routes->post('/api/v1/emr/lab/update-validasi', 'NUHATEMP::update');
|
||||
$routes->post('/api/v1/emr/lab/detail', 'NUHATEMP::detail');
|
||||
|
||||
$routes->group('api', ['filter' => 'auth'], function($routes) {
|
||||
$routes->get('dashboard', 'Dashboard::index');
|
||||
$routes->get('result', 'Result::index');
|
||||
@ -49,10 +43,23 @@ $routes->get('/api/location', 'Location::index');
|
||||
$routes->get('/api/location/(:num)', 'Location::show/$1');
|
||||
$routes->post('/api/location', 'Location::create');
|
||||
$routes->patch('/api/location', 'Location::update');
|
||||
$routes->delete('/api/location', 'Patient::delete');
|
||||
$routes->delete('/api/location', 'Location::delete');
|
||||
|
||||
$routes->get('/api/contact', 'Contact::index');
|
||||
$routes->get('/api/contact/(:num)', 'Contact::show/$1');
|
||||
$routes->post('/api/contact', 'Contact::create');
|
||||
$routes->patch('/api/contact', 'Contact::update');
|
||||
$routes->delete('/api/contact', 'Contact::delete');
|
||||
|
||||
$routes->get('/api/occupation', 'Occupation::index');
|
||||
$routes->get('/api/occupation/(:num)', 'Occupation::show/$1');
|
||||
$routes->post('/api/occupation', 'Occupation::create');
|
||||
$routes->patch('/api/occupation', 'Occupation::update');
|
||||
//$routes->delete('/api/occupation', 'Occupation::delete');
|
||||
|
||||
$routes->get('/api/valueset', 'ValueSet::index');
|
||||
$routes->get('/api/valueset/(:num)', 'ValueSet::show/$1');
|
||||
$routes->get('/api/valueset/valuesetdef/(:num)', 'ValueSet::showByValueSetDef/$1');
|
||||
$routes->post('/api/valueset', 'ValueSet::create');
|
||||
$routes->patch('/api/valueset', 'ValueSet::update');
|
||||
$routes->delete('/api/valueset', 'ValueSet::delete');
|
||||
|
||||
@ -16,17 +16,17 @@ class Contact extends Controller {
|
||||
}
|
||||
|
||||
public function index() {
|
||||
$rows = $this->db->table('contact')
|
||||
->select("contact.*, contactdetail.ContactEmail, contactdetail.JobTitle, contactdetail.Department, occupation.AbbTex, occupation.FullText, occupation.Description")
|
||||
->join("contactdetail", "contact.ContactID=contactdetail.ContactID")
|
||||
->join("occupation","occupation.OccupationID=contactdetail.OccupationID")
|
||||
->get()->getRowArray();
|
||||
$sql = $this->db->table('contact');
|
||||
$sql->select("*")
|
||||
->join("contactdetail", "contact.ContactID=contactdetail.ContactID", "left")
|
||||
->join("occupation","contactdetail.OccupationID=occupation.OccupationID", "left");
|
||||
$rows = $sql->get()->getRowArray();
|
||||
|
||||
if (empty($rows)) {
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
'message' => "no Data.",
|
||||
'data' => [],
|
||||
'data' => $rows,
|
||||
], 200);
|
||||
}
|
||||
|
||||
@ -38,10 +38,10 @@ class Contact extends Controller {
|
||||
}
|
||||
|
||||
public function show($ContactID = null) {
|
||||
$row=$this->db->table('contact')
|
||||
->select("contact.*, contactdetail.ContactEmail, contactdetail.JobTitle, contactdetail.Department, occupation.AbbTex, occupation.FullText, occupation.Description")
|
||||
->join("contactdetail", "contact.ContactID=contactdetail.ContactID")
|
||||
->join("occupation","occupation.OccupationID=contactdetail.OccupationID")
|
||||
$rows=$this->db->table('contact')
|
||||
->select("*")
|
||||
->join("contactdetail", "contact.ContactID=contactdetail.ContactID", "left")
|
||||
->join("occupation","occupation.OccupationID=contactdetail.OccupationID", "left")
|
||||
->where('contact.ContactID', (int) $ContactID)
|
||||
->get()->getRowArray();
|
||||
|
||||
@ -65,40 +65,38 @@ class Contact extends Controller {
|
||||
$input = $this->request->getJSON(true);
|
||||
|
||||
// Prepare data
|
||||
$dataLocation = $this->prepareLocationData($input);
|
||||
$dataLocationAddress = $this->prepareLocationAddressData($input);
|
||||
$dataContact = $this->prepareContactData($input);
|
||||
$dataContactDetail = $this->prepareContactDetailData($input);
|
||||
|
||||
if (!$this->validateData($dataLocation, $this->rules)) {
|
||||
if (!$this->validateData($dataContact, $this->rulesContact)) {
|
||||
return $this->failValidationErrors($this->validator->getErrors());
|
||||
}
|
||||
|
||||
// Start transaction
|
||||
$this->db->transStart();
|
||||
$this->db->table('contact')->insert($dataContact);
|
||||
$newContactID = $this->db->insertID();
|
||||
|
||||
// Insert location
|
||||
$this->db->table('location')->insert($dataLocation);
|
||||
$newLocationID = $this->db->insertID();
|
||||
|
||||
// Insert address if available
|
||||
if (!empty($dataLocationAddress)) {
|
||||
$dataLocationAddress['LocationID'] = $newLocationID;
|
||||
$this->db->table('locationaddress')->insert($dataLocationAddress);
|
||||
|
||||
if (!empty($dataContactDetail)) {
|
||||
$dataContactDetail['ContactID'] = $newContactID;
|
||||
$this->db->table('contactdetail')->insert($dataContactDetail);
|
||||
}
|
||||
|
||||
// Complete transaction
|
||||
$this->db->transComplete();
|
||||
|
||||
if ($this->db->transStatus() === false) {
|
||||
$dbError = $this->db->error();
|
||||
return $this->failServerError(
|
||||
'Failed to create location data (transaction rolled back): ' . ($dbError['message'] ?? 'Unknown database error')
|
||||
'Failed to create data (transaction rolled back): ' . ( $dbError['message'] ?? 'Unknown database error')
|
||||
);
|
||||
}
|
||||
|
||||
// Complete transaction
|
||||
$this->db->transComplete();
|
||||
|
||||
return $this->respondCreated([
|
||||
'status' => 'success',
|
||||
'message' => 'Location created successfully',
|
||||
'data' => $dataLocation,
|
||||
'message' => 'Contact created successfully',
|
||||
'data' => $dataContact,
|
||||
], 201);
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
@ -115,23 +113,22 @@ class Contact extends Controller {
|
||||
$input = $this->request->getJSON(true);
|
||||
|
||||
// Prepare data
|
||||
$dataLocation = $this->prepareLocationData($input);
|
||||
$dataLocationAddress = $this->prepareLocationAddressData($input);
|
||||
$dataContact = $this->prepareContactData($input);
|
||||
$dataContactDetail = $this->prepareContactDetailData($input);
|
||||
|
||||
if (!$this->validateData($dataLocation, $this->rules)) {
|
||||
if (!$this->validateData($dataContact, $this->rulesContact)) {
|
||||
return $this->failValidationErrors( $this->validator->getErrors());
|
||||
}
|
||||
|
||||
// Start transaction
|
||||
$this->db->transStart();
|
||||
|
||||
// Insert location
|
||||
$this->db->table('location')->where('LocationID', $dataLocation["LocationID"])->update($dataLocation);
|
||||
$this->db->table('contact')->where('ContactID', $dataContact["ContactID"])->update($dataContact);
|
||||
|
||||
// Insert address if available
|
||||
if (!empty($dataLocationAddress)) {
|
||||
$dataLocationAddress['LocationID'] = $input["LocationID"];
|
||||
$this->db->table('locationaddress')->upsert($dataLocationAddress);
|
||||
if (!empty($dataContactDetail)) {
|
||||
$dataContactDetail['ContactID'] = $input["ContactID"];
|
||||
$this->db->table('contactdetail')->upsert($dataContactDetail);
|
||||
}
|
||||
|
||||
// Complete transaction
|
||||
@ -140,14 +137,14 @@ class Contact extends Controller {
|
||||
if ($this->db->transStatus() === false) {
|
||||
$dbError = $this->db->error();
|
||||
return $this->failServerError(
|
||||
'Failed to update location data (transaction rolled back): ' . ($dbError['message'] ?? 'Unknown database error')
|
||||
'Failed to update contact data (transaction rolled back): ' . ($dbError['message'] ?? 'Unknown database error')
|
||||
);
|
||||
}
|
||||
|
||||
return $this->respondCreated([
|
||||
'status' => 'success',
|
||||
'message' => 'Location updated successfully',
|
||||
'data' => $dataLocation,
|
||||
'message' => 'Contact updated successfully',
|
||||
'data' => $dataContact,
|
||||
], 201);
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
@ -162,22 +159,21 @@ class Contact extends Controller {
|
||||
public function delete() {
|
||||
try {
|
||||
$input = $this->request->getJSON(true);
|
||||
$LocationID = $input["LocationID"];
|
||||
if (!$LocationID) {
|
||||
return $this->failValidationError('LocationID is required.');
|
||||
$ContactID = $input["ContactID"];
|
||||
if (!$ContactID) {
|
||||
return $this->failValidationError('ContactID is required.');
|
||||
}
|
||||
|
||||
|
||||
$location = $this->db->table('location')->where('LocationID', $LocationID)->get()->getRow();
|
||||
if (!$location) {
|
||||
return $this->failNotFound("LocationID with {$LocationID} not found.");
|
||||
$contact = $this->db->table('contact')->where('ContactID', $ContactID)->get()->getRow();
|
||||
if (!$contact) {
|
||||
return $this->failNotFound("data with {$ContactID} not found.");
|
||||
}
|
||||
|
||||
$this->db->table('location')->where('LocationID', $LocationID)->update(['DelDate' => NOW()]);
|
||||
$this->db->table('contact')->where('ContactID', $ContactID)->update(['EndDate' => NOW()]);
|
||||
|
||||
return $this->respondDeleted([
|
||||
'status' => 'success',
|
||||
'message' => "Location with {$LocationID} deleted successfully."
|
||||
'message' => "Contact with {$ContactID} deleted successfully."
|
||||
]);
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
@ -189,35 +185,36 @@ class Contact extends Controller {
|
||||
}
|
||||
}
|
||||
|
||||
private function prepareLocationData(array $input): array {
|
||||
$LinkTo = null;
|
||||
if (!empty($input['LinkTo'])) {
|
||||
$ids = array_column($input['LinkTo'], 'InternalPID');
|
||||
$LinkTo = implode(',', $ids);
|
||||
}
|
||||
|
||||
private function prepareContactData(array $input): array {
|
||||
$data = [
|
||||
"LocCode" => $input['LocCode'] ?? null,
|
||||
"Parent" => $input['Parent'] ?? null,
|
||||
"LocFull" => $input['LocFull'] ?? null,
|
||||
"Description" => $input['Description'] ?? null,
|
||||
"NameFirst" => $input['NameFirst'] ?? null,
|
||||
"NameLast" => $input['NameLast'] ?? null,
|
||||
"Title" => $input['Title'] ?? null,
|
||||
"Initial" => $input['Initial'] ?? null,
|
||||
"Birthdate" => $input['Birthdate'] ?? null,
|
||||
"EmailAddress1" => $input['EmailAddress1'] ?? null,
|
||||
"EmailAddress2" => $input['EmailAddress2'] ?? null,
|
||||
"Phone" => $input["Phone"] ?? null,
|
||||
"MobilePhone1" => $input["MobilePhone1"] ?? null,
|
||||
"MobilePhone2" => $input["MobilePhone2"] ?? null,
|
||||
"Specialty" => $input["Specialty"] ?? null,
|
||||
"SubSpecialty" => $input["SubSpecialty"] ?? null,
|
||||
];
|
||||
|
||||
if(!empty($input["LocationID"])) { $data["LocationID"] = $input["LocationID"]; }
|
||||
if(!empty($input["ContactID"])) { $data["ContactID"] = $input["ContactID"]; }
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function prepareLocationAddressData(array $input): array {
|
||||
private function prepareContactDetailData(array $input): array {
|
||||
$data = [
|
||||
"LocationID" => $input['LocationID'] ?? null,
|
||||
"Street1" => $input['Street1'] ?? null,
|
||||
"Street2" => $input['Street2'] ?? null,
|
||||
"City" => $input['City'] ?? null,
|
||||
"Province" => $input['Province'] ?? null,
|
||||
"PostCode" => $input['PostCode'] ?? null,
|
||||
"GeoLocationSystem" => $input['GeoLocationSystem'] ?? null,
|
||||
"GeoLocationData" => $input['GeoLocationData'] ?? null,
|
||||
"Code" => $input['Code'] ?? null,
|
||||
"ContactEmail" => $input['ContactEmail'] ?? null,
|
||||
"OccupationID" => $input['OccupationID'] ?? null,
|
||||
"JobTitle" => $input['JobTitle'] ?? null,
|
||||
"Department" => $input['Department'] ?? null,
|
||||
"ContactStartDate" => $input['ContactStartDate'] ?? null,
|
||||
"ContactEndDate" => $input['ContactEndDate'] ?? null,
|
||||
];
|
||||
|
||||
return $data;
|
||||
|
||||
@ -17,9 +17,10 @@ class Location extends Controller {
|
||||
}
|
||||
|
||||
public function index() {
|
||||
$rows = $this->db->table('location')
|
||||
->select("location.LocationID, LocCode, Parent, LocFull, Description, Street1, Street2, City, Province, PostCode, GeoLocationSystem, GeoLocationData")
|
||||
->join("locationaddress", "location.LocationID=locationaddress.LocationID")
|
||||
$rows = $this->db->table('location l')
|
||||
->select("l.LocationID, LocCode, Parent, LocFull, LocType, v.VDesc ")
|
||||
->join("locationaddress la", "l.LocationID=la.LocationID")
|
||||
->join("valueset v", "v.VSetID=12 and v.VValue=l.LocType")
|
||||
->get()->getRowArray();
|
||||
|
||||
if (empty($rows)) {
|
||||
@ -38,16 +39,17 @@ class Location extends Controller {
|
||||
}
|
||||
|
||||
public function show($LocationID = null) {
|
||||
$rows = $this->db->table('location')
|
||||
->select("location.LocationID, LocCode, Parent, LocFull, Description, Street1, Street2, City, Province, PostCode, GeoLocationSystem, GeoLocationData")
|
||||
->join("locationaddress", "location.LocationID=locationaddress.LocationID")
|
||||
->where('location.LocationID', (int) $LocationID)
|
||||
$rows = $this->db->table('location l')
|
||||
->select("l.*, la.*, v.*")
|
||||
->join("locationaddress la", "l.LocationID=la.LocationID")
|
||||
->join("valueset v", "v.VSetID=12 and v.VValue=l.loctype")
|
||||
->where('l.LocationID', (int) $LocationID)
|
||||
->get()->getResultArray();
|
||||
|
||||
if (empty($rows)) {
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
'message' => "Patient with ID $LocationID not found.",
|
||||
'message' => "Data not found.",
|
||||
'data' => [],
|
||||
], 200);
|
||||
}
|
||||
|
||||
@ -1,197 +0,0 @@
|
||||
<?php
|
||||
namespace App\Controllers;
|
||||
|
||||
use CodeIgniter\API\ResponseTrait;
|
||||
use CodeIgniter\Controller;
|
||||
use CodeIgniter\Database\RawSql;
|
||||
|
||||
class NUHATEMP extends Controller {
|
||||
use ResponseTrait;
|
||||
|
||||
public function __construct() {
|
||||
$this->db = \Config\Database::connect();
|
||||
}
|
||||
|
||||
// OK - Done
|
||||
public function index() {
|
||||
|
||||
$valid_from = $this->request->getVar('valid_from');
|
||||
$valid_to = $this->request->getVar('valid_to');
|
||||
try {
|
||||
// Data pasien ditemukan dan mengembalikan - success 200
|
||||
return $this->respond([
|
||||
"response" => [
|
||||
"list" => [
|
||||
[
|
||||
"tgl" => "2023-07-31T00:12:00Z",
|
||||
"no_lab" => 153304,
|
||||
"no_rm" => "001063898",
|
||||
"nama" => "WAHYUDI",
|
||||
"tgl_lahir" => "1976-05-15T00:00:00Z",
|
||||
"jenis_kelamin" => "Laki-laki",
|
||||
"umur" => "47 tahun, 2 bulan, 15 hari",
|
||||
"alamat" => "KP GEBANG RT 01/03 SANGIANG JAYA PERIUK",
|
||||
"ruang" => "",
|
||||
"kelas" => "",
|
||||
"status" => "BPJS",
|
||||
"dokter_pengirim" => "dr. Arie Asnafi, Sp.U",
|
||||
"jenis_lab" => "pk",
|
||||
"lis_id" => "2307310001",
|
||||
"id_ruangan" => "1",
|
||||
"nama_ruangan" => "Flamboyan",
|
||||
"id_asuransi" => "2",
|
||||
"nama_asuransi" => "BPJS KESEHATAN",
|
||||
"cito" => false,
|
||||
"list_test" => [
|
||||
[
|
||||
"detail_id" => 265833,
|
||||
"no_lab" => 153304,
|
||||
"test_id" => 72,
|
||||
"nama_test" => "Glukosa Sewaktu",
|
||||
"jenis_lab" => "pk",
|
||||
"jenis_test" => "t",
|
||||
"detail_test" => []
|
||||
]
|
||||
]
|
||||
],
|
||||
[
|
||||
"tgl" => "2023-07-31T00:53:00Z",
|
||||
"no_lab" => 153307,
|
||||
"no_rm" => "001301669",
|
||||
"nama" => "RAFFASYAH ALKHALIFI PUTRA H",
|
||||
"tgl_lahir" => "2017-11-28T00:00:00Z",
|
||||
"jenis_kelamin" => "Laki-laki",
|
||||
"umur" => "5 tahun, 8 bulan, 2 hari",
|
||||
"alamat" => "JL TARUMANEGARA I / 4 RT 04 RW 022",
|
||||
"ruang" => "",
|
||||
"kelas" => "",
|
||||
"status" => "BPJS",
|
||||
"dokter_pengirim" => "dr. Arif Budiman, Sp.A (K)",
|
||||
"jenis_lab" => "pk",
|
||||
"lis_id" => "2307310004",
|
||||
"id_ruangan" => "1",
|
||||
"nama_ruangan" => "Flamboyan",
|
||||
"id_asuransi" => "2",
|
||||
"nama_asuransi" => "BPJS KESEHATAN",
|
||||
"list_test" => [
|
||||
[
|
||||
"detail_id" => 265836,
|
||||
"no_lab" => 153307,
|
||||
"test_id" => 31,
|
||||
"nama_test" => "Darah Lengkap",
|
||||
"jenis_lab" => "pk",
|
||||
"jenis_test" => "p",
|
||||
"detail_test" => [
|
||||
["paket_id"=>31,"index"=>1,"spasi"=>"0","test_id"=>16,"nama_test"=>"Hemoglobin"],
|
||||
["paket_id"=>31,"index"=>2,"spasi"=>"0","test_id"=>26,"nama_test"=>"Leukosit"],
|
||||
["paket_id"=>31,"index"=>3,"spasi"=>"0","test_id"=>28,"nama_test"=>"Eritrosit"],
|
||||
["paket_id"=>31,"index"=>4,"spasi"=>"0","test_id"=>29,"nama_test"=>"Hematokrit"],
|
||||
["paket_id"=>31,"index"=>5,"spasi"=>"0","test_id"=>30,"nama_test"=>"Trombosit"],
|
||||
["paket_id"=>31,"index"=>6,"spasi"=>"0","test_id"=>32,"nama_test"=>"Hitung Jenis"],
|
||||
["paket_id"=>31,"index"=>7,"spasi"=>"0","test_id"=>33,"nama_test"=>"Eosinofil"],
|
||||
["paket_id"=>31,"index"=>8,"spasi"=>"0","test_id"=>34,"nama_test"=>"Basofil"],
|
||||
["paket_id"=>31,"index"=>9,"spasi"=>"0","test_id"=>35,"nama_test"=>"Netrofil Batang"],
|
||||
["paket_id"=>31,"index"=>10,"spasi"=>"0","test_id"=>36,"nama_test"=>"Netrofil Segmen"],
|
||||
["paket_id"=>31,"index"=>11,"spasi"=>"0","test_id"=>37,"nama_test"=>"Limfosit"],
|
||||
["paket_id"=>31,"index"=>12,"spasi"=>"0","test_id"=>38,"nama_test"=>"Monosit"],
|
||||
["paket_id"=>31,"index"=>13,"spasi"=>"0","test_id"=>39,"nama_test"=>"Laju Endap Darah"]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
"metadata" => [
|
||||
"message" => "Ok",
|
||||
"code" => 200
|
||||
]
|
||||
], 200);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
// Error Server Mengembalikan 500
|
||||
return $this->failServerError('Something went wrong.'.$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// OK - Done
|
||||
public function create() {
|
||||
try {
|
||||
// Data pasien ditemukan dan mengembalikan - success 200
|
||||
return $this->respond([
|
||||
"message"=> "Ok",
|
||||
'status' => 200
|
||||
], 200);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
// Error Server Mengembalikan 500
|
||||
return $this->failServerError('Something went wrong.'.$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// OK - Done
|
||||
public function update() {
|
||||
try {
|
||||
// Data pasien ditemukan dan mengembalikan - success 200
|
||||
return $this->respond([
|
||||
"message"=> "Ok",
|
||||
'status' => 200
|
||||
], 200);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
// Error Server Mengembalikan 500
|
||||
return $this->failServerError('Something went wrong.'.$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// OK - Done
|
||||
public function detail() {
|
||||
try {
|
||||
// Data pasien ditemukan dan mengembalikan - success 200
|
||||
return $this->respond([
|
||||
"response" => [
|
||||
"tgl" => "2024-03-08T09:37:00Z",
|
||||
"no_lab" => 3021,
|
||||
"no_rm" => "000264395",
|
||||
"nama" => "CANDY RAMADONA, AN",
|
||||
"tgl_lahir" => "2007-09-02",
|
||||
"jenis_kelamin" => "Perempuan",
|
||||
"umur" => "2023 tahun, 2 bulan, 7 hari",
|
||||
"alamat" => "PERUM PONDOK JAGUNG BLOK AC.45 001/004",
|
||||
"ruang" => "",
|
||||
"kelas" => "",
|
||||
"status" => "ASURANSI SINAR MAS, PT",
|
||||
"id_dokter_pengirim" => 2,
|
||||
"dokter_pengirim" => "dr.Mila Agustia.Sp.A",
|
||||
"jenis_lab" => "pk",
|
||||
"lis_id" => "240308208",
|
||||
"id_ruangan" => "1",
|
||||
"nama_ruangan" => "DAMAR",
|
||||
"id_asuransi" => "118",
|
||||
"nama_asuransi" => "ASURANSI SINAR MAS, PT",
|
||||
"cito" => false,
|
||||
"list_test" => [
|
||||
[
|
||||
"detail_id" => 4981,
|
||||
"no_lab" => 3021,
|
||||
"test_id" => 145,
|
||||
"nama_test" => "Urin Lengkap (Paket)",
|
||||
"jenis_lab" => "",
|
||||
"jenis_test" => "",
|
||||
"detail_test" => null
|
||||
]
|
||||
]
|
||||
],
|
||||
"metadata" => [
|
||||
"message" => "Ok",
|
||||
"code" => 200
|
||||
]
|
||||
], 200);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
// Error Server Mengembalikan 500
|
||||
return $this->failServerError('Something went wrong.'.$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
169
app/Controllers/Occupation.php
Normal file
169
app/Controllers/Occupation.php
Normal file
@ -0,0 +1,169 @@
|
||||
<?php
|
||||
namespace App\Controllers;
|
||||
|
||||
use CodeIgniter\API\ResponseTrait;
|
||||
use CodeIgniter\Controller;
|
||||
use CodeIgniter\Database\RawSql;
|
||||
|
||||
class Occupation extends Controller {
|
||||
use ResponseTrait;
|
||||
|
||||
public function __construct() {
|
||||
$this->db = \Config\Database::connect();
|
||||
$this->rulesOccupation = [
|
||||
'AbbTex' => 'required',
|
||||
'FullText' => 'required'
|
||||
];
|
||||
}
|
||||
|
||||
public function index() {
|
||||
$rows = $this->db->table('occupation')->select("*")->get()->getRowArray();
|
||||
|
||||
if (empty($rows)) {
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
'message' => "no Data.",
|
||||
'data' => $rows,
|
||||
], 200);
|
||||
}
|
||||
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
'message'=> "fetch success",
|
||||
'data' => $rows,
|
||||
], 200);
|
||||
}
|
||||
|
||||
public function show($OccupationID = null) {
|
||||
$rows=$this->db->table('occupation')->select("*")->where('occupationID', (int) $OccupationID)->get()->getRowArray();
|
||||
|
||||
if (empty($rows)) {
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
'message' => "Data not found.",
|
||||
'data' => [],
|
||||
], 200);
|
||||
}
|
||||
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
'message'=> "Data fetched successfully",
|
||||
'data' => $rows,
|
||||
], 200);
|
||||
}
|
||||
|
||||
public function create() {
|
||||
try {
|
||||
$input = $this->request->getJSON(true);
|
||||
$dataOccupation = $this->prepareOccupationData($input);
|
||||
|
||||
if (!$this->validateData($dataOccupation, $this->rulesOccupation)) {
|
||||
return $this->failValidationErrors($this->validator->getErrors());
|
||||
}
|
||||
|
||||
$this->db->transStart();
|
||||
$this->db->table('contact')->insert($dataOccupation);
|
||||
|
||||
if ($this->db->transStatus() === false) {
|
||||
$dbError = $this->db->error();
|
||||
return $this->failServerError(
|
||||
'Failed to create data (transaction rolled back): ' . ( $dbError['message'] ?? 'Unknown database error')
|
||||
);
|
||||
}
|
||||
|
||||
// Complete transaction
|
||||
$this->db->transComplete();
|
||||
|
||||
return $this->respondCreated([
|
||||
'status' => 'success',
|
||||
'message' => 'data created successfully',
|
||||
'data' => $dataOccupation,
|
||||
], 201);
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
// Ensure rollback if something goes wrong
|
||||
if ($this->db->transStatus() !== false) {
|
||||
$this->db->transRollback();
|
||||
}
|
||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function update() {
|
||||
try {
|
||||
$input = $this->request->getJSON(true);
|
||||
$dataOccupation = $this->prepareOccupationData($input);
|
||||
|
||||
if (!$this->validateData($dataOccupation, $this->rulesOccupation)) {
|
||||
return $this->failValidationErrors( $this->validator->getErrors());
|
||||
}
|
||||
|
||||
$this->db->transStart();
|
||||
$this->db->table('occupation')->where('OccupationID', $dataOccupation["OccupationID"])->update($dataOccupation);
|
||||
|
||||
if ($this->db->transStatus() === false) {
|
||||
$dbError = $this->db->error();
|
||||
return $this->failServerError(
|
||||
'Failed to update data (transaction rolled back): ' . ($dbError['message'] ?? 'Unknown database error')
|
||||
);
|
||||
}
|
||||
|
||||
$this->db->transComplete();
|
||||
|
||||
return $this->respondCreated([
|
||||
'status' => 'success',
|
||||
'message' => 'Occupation updated successfully',
|
||||
'data' => $dataContact,
|
||||
], 201);
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
// Ensure rollback if something goes wrong
|
||||
if ($this->db->transStatus() !== false) {
|
||||
$this->db->transRollback();
|
||||
}
|
||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
/*
|
||||
public function delete() {
|
||||
try {
|
||||
$input = $this->request->getJSON(true);
|
||||
$OccupationID = $input["OccupationID"];
|
||||
if (!$OccupationID) {
|
||||
return $this->failValidationError('ContactID is required.');
|
||||
}
|
||||
|
||||
$occupation = $this->db->table('occupation')->where('OccupationID', $OccupationID)->get()->getRow();
|
||||
if (!$occupation) {
|
||||
return $this->failNotFound("data with {$OccupationID} not found.");
|
||||
}
|
||||
|
||||
$this->db->table('occupation')->where('OccupationID', $OccupationID)->update(['EndDate' => NOW()]);
|
||||
|
||||
return $this->respondDeleted([
|
||||
'status' => 'success',
|
||||
'message' => "{$ContactID} deleted successfully."
|
||||
]);
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
// Ensure rollback if something goes wrong
|
||||
if ($this->db->transStatus() !== false) {
|
||||
$this->db->transRollback();
|
||||
}
|
||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
private function prepareOccupationData(array $input): array {
|
||||
$data = [
|
||||
"AbbTex" => $input['AbbTex'] ?? null,
|
||||
"FullText" => $input['FullText'] ?? null,
|
||||
"Description" => $input['Description'] ?? null,
|
||||
];
|
||||
|
||||
if(!empty($input["OccupationID"])) { $data["OccupationID"] = $input["OccupationID"]; }
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
217
app/Controllers/OrderTest.php
Normal file
217
app/Controllers/OrderTest.php
Normal file
@ -0,0 +1,217 @@
|
||||
<?php
|
||||
namespace App\Controllers;
|
||||
|
||||
use CodeIgniter\API\ResponseTrait;
|
||||
use CodeIgniter\Controller;
|
||||
use CodeIgniter\Database\RawSql;
|
||||
|
||||
class OrderTest extends Controller {
|
||||
use ResponseTrait;
|
||||
|
||||
public function __construct() {
|
||||
$this->db = \Config\Database::connect();
|
||||
$this->rulesOrderTest = [
|
||||
'NameFirst' => 'required'
|
||||
];
|
||||
}
|
||||
|
||||
public function index() {
|
||||
$rows = $this->db->table('ordertest')->select("*")->get()->getRowArray();
|
||||
|
||||
if (empty($rows)) {
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
'message' => "no Data.",
|
||||
'data' => [],
|
||||
], 200);
|
||||
}
|
||||
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
'message'=> "fetch success",
|
||||
'data' => $rows,
|
||||
], 200);
|
||||
}
|
||||
|
||||
public function show($OrderID = null) {
|
||||
$row=$this->db->table('ordertest')->select("*")->where('OrderID=', $OrderID)->get()->getRowArray();
|
||||
|
||||
if (empty($row)) {
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
'message' => "Data not found.",
|
||||
'data' => [],
|
||||
], 200);
|
||||
}
|
||||
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
'message'=> "Data fetched successfully",
|
||||
'data' => $row,
|
||||
], 200);
|
||||
}
|
||||
|
||||
public function create() {
|
||||
try {
|
||||
$input = $this->request->getJSON(true);
|
||||
|
||||
// Prepare data
|
||||
$dataOrderTest = $this->prepareOrderTestData($input);
|
||||
$dataOrderCom = $this->prepareOrderComData($input);
|
||||
$dataOrderAtt = $this->prepareOrderAttData($input);
|
||||
|
||||
if (!$this->validateData($dataLocation, $this->rules)) {
|
||||
return $this->failValidationErrors($this->validator->getErrors());
|
||||
}
|
||||
|
||||
// Start transaction
|
||||
$this->db->transStart();
|
||||
|
||||
// Insert location
|
||||
$this->db->table('location')->insert($dataLocation);
|
||||
$newLocationID = $this->db->insertID();
|
||||
|
||||
// Insert address if available
|
||||
if (!empty($dataLocationAddress)) {
|
||||
$dataLocationAddress['LocationID'] = $newLocationID;
|
||||
$this->db->table('locationaddress')->insert($dataLocationAddress);
|
||||
}
|
||||
|
||||
// Complete transaction
|
||||
$this->db->transComplete();
|
||||
|
||||
if ($this->db->transStatus() === false) {
|
||||
$dbError = $this->db->error();
|
||||
return $this->failServerError(
|
||||
'Failed to create location data (transaction rolled back): ' . ($dbError['message'] ?? 'Unknown database error')
|
||||
);
|
||||
}
|
||||
|
||||
return $this->respondCreated([
|
||||
'status' => 'success',
|
||||
'message' => 'Location created successfully',
|
||||
'data' => $dataLocation,
|
||||
], 201);
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
// Ensure rollback if something goes wrong
|
||||
if ($this->db->transStatus() !== false) {
|
||||
$this->db->transRollback();
|
||||
}
|
||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function update() {
|
||||
try {
|
||||
$input = $this->request->getJSON(true);
|
||||
|
||||
// Prepare data
|
||||
$dataLocation = $this->prepareLocationData($input);
|
||||
$dataLocationAddress = $this->prepareLocationAddressData($input);
|
||||
|
||||
if (!$this->validateData($dataLocation, $this->rules)) {
|
||||
return $this->failValidationErrors( $this->validator->getErrors());
|
||||
}
|
||||
|
||||
// Start transaction
|
||||
$this->db->transStart();
|
||||
|
||||
// Insert location
|
||||
$this->db->table('location')->where('LocationID', $dataLocation["LocationID"])->update($dataLocation);
|
||||
|
||||
// Insert address if available
|
||||
if (!empty($dataLocationAddress)) {
|
||||
$dataLocationAddress['LocationID'] = $input["LocationID"];
|
||||
$this->db->table('locationaddress')->upsert($dataLocationAddress);
|
||||
}
|
||||
|
||||
// Complete transaction
|
||||
$this->db->transComplete();
|
||||
|
||||
if ($this->db->transStatus() === false) {
|
||||
$dbError = $this->db->error();
|
||||
return $this->failServerError(
|
||||
'Failed to update location data (transaction rolled back): ' . ($dbError['message'] ?? 'Unknown database error')
|
||||
);
|
||||
}
|
||||
|
||||
return $this->respondCreated([
|
||||
'status' => 'success',
|
||||
'message' => 'Location updated successfully',
|
||||
'data' => $dataLocation,
|
||||
], 201);
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
// Ensure rollback if something goes wrong
|
||||
if ($this->db->transStatus() !== false) {
|
||||
$this->db->transRollback();
|
||||
}
|
||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function delete() {
|
||||
try {
|
||||
$input = $this->request->getJSON(true);
|
||||
$LocationID = $input["LocationID"];
|
||||
if (!$LocationID) {
|
||||
return $this->failValidationError('LocationID is required.');
|
||||
}
|
||||
|
||||
|
||||
$location = $this->db->table('location')->where('LocationID', $LocationID)->get()->getRow();
|
||||
if (!$location) {
|
||||
return $this->failNotFound("LocationID with {$LocationID} not found.");
|
||||
}
|
||||
|
||||
$this->db->table('location')->where('LocationID', $LocationID)->update(['DelDate' => NOW()]);
|
||||
|
||||
return $this->respondDeleted([
|
||||
'status' => 'success',
|
||||
'message' => "Location with {$LocationID} deleted successfully."
|
||||
]);
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
// Ensure rollback if something goes wrong
|
||||
if ($this->db->transStatus() !== false) {
|
||||
$this->db->transRollback();
|
||||
}
|
||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private function prepareLocationData(array $input): array {
|
||||
$LinkTo = null;
|
||||
if (!empty($input['LinkTo'])) {
|
||||
$ids = array_column($input['LinkTo'], 'InternalPID');
|
||||
$LinkTo = implode(',', $ids);
|
||||
}
|
||||
|
||||
$data = [
|
||||
"LocCode" => $input['LocCode'] ?? null,
|
||||
"Parent" => $input['Parent'] ?? null,
|
||||
"LocFull" => $input['LocFull'] ?? null,
|
||||
"Description" => $input['Description'] ?? null,
|
||||
];
|
||||
|
||||
if(!empty($input["LocationID"])) { $data["LocationID"] = $input["LocationID"]; }
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function prepareLocationAddressData(array $input): array {
|
||||
$data = [
|
||||
"LocationID" => $input['LocationID'] ?? null,
|
||||
"Street1" => $input['Street1'] ?? null,
|
||||
"Street2" => $input['Street2'] ?? null,
|
||||
"City" => $input['City'] ?? null,
|
||||
"Province" => $input['Province'] ?? null,
|
||||
"PostCode" => $input['PostCode'] ?? null,
|
||||
"GeoLocationSystem" => $input['GeoLocationSystem'] ?? null,
|
||||
"GeoLocationData" => $input['GeoLocationData'] ?? null,
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
48
app/Controllers/PatientAdmission.php
Normal file
48
app/Controllers/PatientAdmission.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
namespace App\Controllers;
|
||||
|
||||
use CodeIgniter\API\ResponseTrait;
|
||||
use CodeIgniter\Controller;
|
||||
use CodeIgniter\Database\RawSql;
|
||||
|
||||
class PatientAdmission extends Controller {
|
||||
use ResponseTrait;
|
||||
|
||||
public function __construct() {
|
||||
$this->db = \Config\Database::connect();
|
||||
}
|
||||
|
||||
private function preparePatVisitData(array $input): array {
|
||||
$data = [
|
||||
"PVID" => $input['PVID'] ?? null,
|
||||
"InternalPID" => $input['InternalPID'] ?? null,
|
||||
"EpisodeID" => $input['EpisodeID'] ?? null
|
||||
];
|
||||
|
||||
if(!empty($input['InternalPVID'])) { $data["InternalPVID"] = $input["InternalPVID"]; }
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function preparePatDiagData(array $input): array {
|
||||
$data = [
|
||||
"InternalPVID" => $input['InternalPVID'] ?? null,
|
||||
"InternalPID" => $input['InternalPID'] ?? null,
|
||||
"DiagCode" => $input['DiagCode'] ?? null,
|
||||
"Diagnosis" => $input['Diagnosis'] ?? null
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function preparePatVisitAdtData(array $input): array {
|
||||
$data = [
|
||||
"InternalPVID" => $input['InternalPVID'] ?? null,
|
||||
"InternalPID" => $input['InternalPID'] ?? null,
|
||||
"DiagCode" => $input['DiagCode'] ?? null,
|
||||
"Diagnosis" => $input['Diagnosis'] ?? null
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
<?php
|
||||
namespace App\Controllers;
|
||||
|
||||
use CodeIgniter\API\ResponseTrait;
|
||||
use CodeIgniter\Controller;
|
||||
use CodeIgniter\Database\RawSql;
|
||||
|
||||
class Patient_Admission extends Controller {
|
||||
use ResponseTrait;
|
||||
|
||||
public function __construct() {
|
||||
$this->db = \Config\Database::connect();
|
||||
$this->now = date('Y-m-d H:i:s');
|
||||
}
|
||||
}
|
||||
@ -17,9 +17,13 @@ class ValueSet extends Controller {
|
||||
}
|
||||
|
||||
public function index() {
|
||||
$rows = $this->db->table('valueset')
|
||||
->select("*")
|
||||
->get()->getResultArray();
|
||||
$builder = $this->db->table('valueset')->select("*");
|
||||
$param = $this->request->getVar('param');
|
||||
if ($param !== null) {
|
||||
$builder->like('VValue', $param, 'both');
|
||||
$builder->orlike('VDesc', $param, 'both');
|
||||
}
|
||||
$rows = $builder->get()->getResultArray();
|
||||
|
||||
if (empty($rows)) {
|
||||
return $this->respond([
|
||||
@ -58,6 +62,27 @@ class ValueSet extends Controller {
|
||||
], 200);
|
||||
}
|
||||
|
||||
public function showByValueSetDef($VSetID = null) {
|
||||
$rows = $this->db->table('valueset')
|
||||
->select("*")
|
||||
->where('VSetID', (int) $VSetID)
|
||||
->get()->getResultArray();
|
||||
|
||||
if (empty($rows)) {
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
'message' => "ValueSet not found.",
|
||||
'data' => [],
|
||||
], 200);
|
||||
}
|
||||
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
'message'=> "Data fetched successfully",
|
||||
'data' => $rows,
|
||||
], 200);
|
||||
}
|
||||
|
||||
public function create() {
|
||||
try {
|
||||
$input = $this->request->getJSON(true);
|
||||
|
||||
@ -17,10 +17,14 @@ class ValueSetDef extends Controller {
|
||||
}
|
||||
|
||||
public function index() {
|
||||
$rows = $this->db->table('valuesetdef')
|
||||
->select("*")
|
||||
->get()->getResultArray();
|
||||
|
||||
$builder = $this->db->table('valuesetdef')->select("*");
|
||||
$param = $this->request->getVar('param');
|
||||
if ($param !== null) {
|
||||
$builder->like('VSName', $param, 'both');
|
||||
$builder->orlike('VSDesc', $param, 'both');
|
||||
}
|
||||
$rows = $builder->get()->getResultArray();
|
||||
|
||||
if (empty($rows)) {
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
|
||||
@ -14,6 +14,7 @@ class CreateLocationTable extends Migration {
|
||||
'Parent' => ['type' => 'INT', 'null' => true],
|
||||
'LocFull' => ['type' => 'varchar', 'constraint' => 255, 'null' => true],
|
||||
'Description' => ['type' => 'varchar', 'constraint' => 255, 'null' => true],
|
||||
'LocType' => ['type' => 'varchar', 'constraint' => 11, 'null' => true],
|
||||
'EndDate' => ['type' => 'DATETIME', 'null' => true]
|
||||
]);
|
||||
$this->forge->addField('CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP');
|
||||
|
||||
@ -8,7 +8,7 @@ class CreateContactTable extends Migration {
|
||||
public function up() {
|
||||
// Contact
|
||||
$this->forge->addField([
|
||||
'ContactID' => [ 'type' => 'INT', 'constraint' => 11 ],
|
||||
'ContactID' => [ 'type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true ],
|
||||
'NameFirst' => [ 'type' => 'VARCHAR', 'constraint' => 100, 'null' => true ],
|
||||
'NameLast' => [ 'type' => 'VARCHAR', 'constraint' => 100, 'null' => true ],
|
||||
'Title' => [ 'type' => 'VARCHAR', 'constraint' => 50, 'null' => true ],
|
||||
@ -32,6 +32,7 @@ class CreateContactTable extends Migration {
|
||||
'ContactDetID' => [ 'type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true ],
|
||||
'ContactID' => [ 'type' => 'INT', 'constraint' => 11 ],
|
||||
'SiteID' => [ 'type' => 'INT', 'constraint' => 11, 'null' => true ],
|
||||
'Code' => [ 'type' => 'varchar', 'constraint' => 11, 'null' => false ],
|
||||
'ContactEmail' => [ 'type' => 'VARCHAR', 'constraint' => 150, 'null' => true ],
|
||||
'OccupationID' => [ 'type' => 'VARCHAR', 'constraint' => 50, 'null' => true ],
|
||||
'JobTitle' => [ 'type' => 'VARCHAR', 'constraint' => 100, 'null' => true ],
|
||||
|
||||
@ -8,7 +8,7 @@ class DummySeeder extends Seeder {
|
||||
public function run() {
|
||||
// location
|
||||
$data = [
|
||||
['LocationID'=>1, 'LocCode'=>'QLOC', 'LocFull'=>'Dummy Location', 'Description'=>'Location made for dummy testing' ]
|
||||
['LocationID'=>1, 'LocCode'=>'QLOC', 'LocFull'=>'Dummy Location', 'LocType'=>'ROOM', 'Description'=>'Location made for dummy testing' ]
|
||||
];
|
||||
$this->db->table('location')->insertBatch($data);
|
||||
|
||||
|
||||
BIN
public/clqms01.sql.gz
Normal file
BIN
public/clqms01.sql.gz
Normal file
Binary file not shown.
BIN
public/upload/meow.jpg
Normal file
BIN
public/upload/meow.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
BIN
public/upload/panda.jpg
Normal file
BIN
public/upload/panda.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
Loading…
x
Reference in New Issue
Block a user