diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 33a50b0..bcb31f7 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -24,6 +24,8 @@ $routes->group('admin', ['filter' => 'role:1'], function($routes) { $routes->post('user/create', 'User::create'); $routes->post('user/update', 'User::update'); $routes->post('user/delete', 'User::delete'); + $routes->get('specimenDetail', 'Admin::specimenDetailApi'); //Ini Api ya ges ya + }); $routes->group('doctor', ['filter' => 'role:2'], function($routes) { @@ -39,4 +41,4 @@ $routes->group('cs', ['filter' => 'role:4'], function($routes) { }); // ------------------------------------------------------For API------------------------------------------------------ // -$routes->get('/api/dashboard', 'ApiDashboard::index'); \ No newline at end of file +// $routes->get('/api/dashboard', 'ApiDashboard::index'); \ No newline at end of file diff --git a/app/Controllers/Admin.php b/app/Controllers/Admin.php index 434d2a2..aeb3726 100644 --- a/app/Controllers/Admin.php +++ b/app/Controllers/Admin.php @@ -5,7 +5,150 @@ class Admin extends BaseController { public function index() { - return view('admin/index'); + $today = date('Y-m-d'); + $date1 = $this->request->getVar('date1') ?? $today; + $date2 = $this->request->getVar('date2') ?? $today; + + $db = \Config\Database::connect(); + $sql = "SELECT * from GDC_CMOD.dbo.V_DASHBOARD_DEV + where COLLECTIONDATE between '$date1 00:00' and '$date2 23:59' and ODR_DDATE between '$date1 00:00' and '$date2 23:59'"; + $query = $db->query($sql); + $results = $query->getResultArray(); + + // === Variabel counter === + $CPending = 0; $CPColl = 0; $CColl = 0; $CPRecv = 0; + $CRecv = 0; $CInc = 0; $CPenV = 0; $CFin = 0; $CFinV = 0; + + $dataList = []; + + foreach ($results as $row) { + $reqdate = ''; + if (!empty($row['REQDATE'])) { + $reqdate = date('Y-m-d H:i', strtotime($row['REQDATE'])); + } + $patname = $row['Name'] ?? ''; + $sp_accessnumber = $row['SP_ACCESSNUMBER'] ?? ''; + $hostordernumber = $row['HOSTORDERNUMBER'] ?? ''; + $stats = $row['STATS'] ?? ''; + $tests = $row['TESTS'] ?? ''; + $isDelete = $row['ISDELETE'] ?? 0; + + // Bersihkan test string + $test = str_replace(['(', ')', ',', 'FA'], '', $tests); + + if (!is_numeric($test) && $isDelete == 0) { + switch ($stats) { + case 'Pend': $statscode = 1; $CPending++; break; + case 'PartColl':$statscode = 2; $CPColl++; break; + case 'Coll': $statscode = 3; $CColl++; break; + case 'PartRecv':$statscode = 4; $CPRecv++; break; + case 'Recv': $statscode = 5; $CRecv++; break; + case 'Inc': $statscode = 6; $CInc++; break; + case 'PenV': $statscode = 7; $CPenV++; break; + case 'Fin': $statscode = 8; $CFin++; break; + case 'FinV': $statscode = 9; $CFinV++; break; + default: $statscode = 0; break; + } + + // Simpan ke array + $dataList[] = [ + 'statscode' => $statscode, + 'reqdate' => $reqdate, + 'patname' => $patname, + 'sp_accessnumber' => $sp_accessnumber, + 'hostordernumber' => $hostordernumber, + 'reff' => $row['REFF'] ?? '', + 'doc' => $row['DOC'] ?? '', + 'tests' => $row['TESTS'] ?? '', + 'stats' => $stats, + 'odr_cresult_to' => $row['ODR_CRESULT_TO'], + 'isprinted'=> $row['ODR_ISPRINTED'] ?? 0, + 'ispending'=> $row['ODR_ISPENDING'] ?? 0, + 'ishardcopy'=> $row['ODR_NFLAGHARDCOPY'] ?? 0, + 'isval' => $row['ISVAL'] ?? 0, + 'isdelete' => $isDelete, + ]; + + } + } + + // === Total counter === + $counter = [ + 'pending' => $CPending, + 'partialCollected' => $CPColl, + 'collected' => $CColl, + 'partialReceived' => $CPRecv, + 'received' => $CRecv, + 'incomplete' => $CInc, + 'pendingValidation' => $CPenV, + 'final' => $CFin, + 'finalValidation' => $CFinV, + ]; + + $data['dataList'] = $dataList; + $data['counter'] = $counter; + $data['date1'] = $date1; + $data['date2'] = $date2; + + // dd($results); + + + return view('admin/index', $data); + } + + // Khusus Untuk API + public function specimenDetailApi() + { + $access = $this->request->getGet('access'); + $db = \Config\Database::connect(); + + $sql = "SELECT right(p.PATNUMBER,16) as [Rm], ISNULL(p.FIRSTNAME,'') + ' ' + ISNULL(p.NAME,'') as [Name], + case when format(p.BIRTHDATE,'MMdd')=format(spr.COLLECTIONDATE,'MMdd') then DATEDIFF(YEAR,p.BIRTHDATE, spr.COLLECTIONDATE) + else FLOOR(DATEDIFF(DAY, p.BIRTHDATE, spr.COLLECTIONDATE) / 365.25) end , + [Gender] = case + when p.SEX = 1 then 'Male' + when p.SEX = 2 then 'Female' + else '' + end, spr.REQDATE, spo.COMMENTTEXT, dmg.DMG_CKTPNO, dmg.DMG_CPLACEOFBIRTH + from SP_REQUESTS spr + left join PATIENTS p on p.PATID=spr.PATID + left join SP_REQUESTS_OCOM spo on spr.SP_ACCESSNUMBER=spo.SP_ACCESSNUMBER + left join GDC_CMOD.dbo.TDL_DEMOGRAPHIC dmg on right(dmg.DMG_CPATNUMBER,15)=right(p.PATNUMBER,15) + where spr.PATID=p.PATID and spr.SP_ACCESSNUMBER='$access'"; + $query = $db->query($sql); + $results = $query->getRowArray(); + $patientIdentity = [ + 'rm' => $results["Rm"], + 'age' => $results[""], // key kosong + 'name' => $results['Name'] ?? '', + 'reqdate' => $results['REQDATE'] ?? '', + 'gender' => $results['Gender'] ?? '', + 'placeofbirth' => $results['DMG_CPLACEOFBIRTH'] ?? '', + 'ktp' => $results['DMG_CKTPNO'] ?? '', + 'comment' => $results['COMMENTTEXT'] ?? '', + ]; + + $samples = []; + $sql = "SELECT req.SAMPTYPEID, req.SAMPCODE, req.SHORTTEXT, tu.STATUS, st.TUBESTATUS + from GDC_CMOD.dbo.v_sp_reqtube req + left join GDC_CMOD.dbo.TUBES tu on req.SP_ACCESSNUMBER=tu.ACCESSNUMBER and req.SAMPCODE=tu.TUBENUMBER + left join glendb.dbo.SP_TUBES st on st.SP_ACCESSNUMBER=req.SP_ACCESSNUMBER and req.SAMPCODE=st.SAMPLETYPE + where req.SP_ACCESSNUMBER='$access'"; + $query = $db->query($sql); + $results = $query->getResultArray(); + foreach ($results as $row) { + $samples[] = [ + 'samptypeid' => $row['SAMPTYPEID'] ?? null, + 'sampcode' => $row['SAMPCODE'] ?? null, + 'name' => $row['SHORTTEXT'] ?? '', + 'colstatus' => $row['STATUS'] ?? '', + 'tubestatus' => $row['TUBESTATUS'] ?? '', + ]; + } + + $data = ['patientIdentity' => $patientIdentity, 'samples' => $samples]; + + return $this->response->setJSON($data); } } diff --git a/app/Controllers/ApiDashboard.php b/app/Controllers/ApiDashboard.php index 8172750..cd30906 100644 --- a/app/Controllers/ApiDashboard.php +++ b/app/Controllers/ApiDashboard.php @@ -15,11 +15,81 @@ class ApiDashboard extends ResourceController where COLLECTIONDATE between '$date1 00:00' and '$date2 23:59' and ODR_DDATE between '$date1 00:00' and '$date2 23:59'"; $query = $db->query($sql); $results = $query->getResultArray(); - $data['data'] = $results; - - return $this->respond($data, 200); + + // === Variabel counter === + $CPending = 0; $CPColl = 0; $CColl = 0; $CPRecv = 0; + $CRecv = 0; $CInc = 0; $CPenV = 0; $CFin = 0; $CFinV = 0; + + $dataList = []; + + foreach ($results as $row) { + $reqdate = ''; + if (!empty($row['REQDATE'])) { + $reqdate = date('Y-m-d H:i', strtotime($row['REQDATE'])); + } + + $patname = $row['Name'] ?? ''; + $reqnum = $row['SP_ACCESSNUMBER'] ?? ''; + $hosnum = $row['HOSTORDERNUMBER'] ?? ''; + $stats = $row['STATS'] ?? ''; + $tests = $row['TESTS'] ?? ''; + $isDelete = $row['ISDELETE'] ?? 0; + + // Bersihkan test string + $test = str_replace(['(', ')', ',', 'FA'], '', $tests); + + if (!is_numeric($test) && $isDelete == 0) { + switch ($stats) { + case 'Pend': $statCode = 1; $CPending++; break; + case 'PartColl':$statCode = 2; $CPColl++; break; + case 'Coll': $statCode = 3; $CColl++; break; + case 'PartRecv':$statCode = 4; $CPRecv++; break; + case 'Recv': $statCode = 5; $CRecv++; break; + case 'Inc': $statCode = 6; $CInc++; break; + case 'PenV': $statCode = 7; $CPenV++; break; + case 'Fin': $statCode = 8; $CFin++; break; + case 'FinV': $statCode = 9; $CFinV++; break; + default: $statCode = 0; break; + } + + // Simpan ke array + $dataList[] = [ + 'statCode' => $statCode, + 'reqdate' => $reqdate, + 'patname' => $patname, + 'reqnum' => $reqnum, + 'hosnum' => $hosnum, + 'reff' => $row['REFF'] ?? '', + 'doc' => $row['DOC'] ?? '', + 'tests' => $row['TESTS'] ?? '', + 'stats' => $stats, + 'isPrinted'=> $row['ODR_ISPRINTED'] ?? 0, + 'isPending'=> $row['ODR_ISPENDING'] ?? 0, + 'isHardcopy'=> $row['ODR_NFLAGHARDCOPY'] ?? 0, + 'isVal' => $row['ISVAL'] ?? 0, + 'isDelete' => $isDelete, + ]; + } + } + + // === Total Summary === + $summary = [ + 'Pending' => $CPending, + 'PartialCollected' => $CPColl, + 'Collected' => $CColl, + 'PartialReceived' => $CPRecv, + 'Received' => $CRecv, + 'Incomplete' => $CInc, + 'PendingValidation' => $CPenV, + 'Final' => $CFin, + 'FinalValidation' => $CFinV, + ]; + + // === Response JSON (misal API) === + return $this->respond([ + 'status' => 'success', + 'summary' => $summary, + 'data' => $dataList, + ]); } - - - -} +} \ No newline at end of file diff --git a/app/Views/_layouts/main.php b/app/Views/_layouts/main.php index 0b36b4d..deeff52 100644 --- a/app/Views/_layouts/main.php +++ b/app/Views/_layouts/main.php @@ -3,8 +3,6 @@ $uri = service('uri'); $path = $uri->getPath(); $activeUrls = ['/admin', '/cs', '/analyst', '/doctor']; - - // dd(session()->get('userid')); ?> @@ -88,7 +86,7 @@ .status-card { width: 123px; /* lebar tetap */ - height: 65px; + height: 60px; /* tinggi seragam */ border-radius: 8px; background-color: #fff; @@ -145,47 +143,57 @@ cursor: pointer; } + /* 1 */ .Pend { background-color: white; } + /* 2 */ .PartColl { - background-color: #ff99aa; - } - - .Coll { - background-color: #d63031; + background-color: #ff99aaaf !important; + } + + /* 3 */ + .Collected { + background-color: #d6303086 !important; } + /* 4 */ .PartRecv { - background-color: #a0c0d9; + background-color: #a0c0d9af !important; } - .Recv { - background-color: #0984e3; + /* 5 */ + .Received { + background-color: #0985e39d !important; } - .Inc { - background-color: yellow; + /* 6 */ + .Incomplete { + background-color: #fbff009a !important; } - .Fin { - background-color: lightgreen; + /* 7 */ + .Final { + background-color: #90EE90 !important; } - .FinV { - background-color: green; + /* 8 */ + .FinVerification { + background-color: #09ff00ab !important; } - .PenV { - background-color: #EE5A24; + /* 9 */ + .PenVerification { + background-color: #ee5a24c7 !important; } + /* 10 */ .Suspend { background-color: purple; } - + renderSection('css'); ?> @@ -253,6 +261,7 @@ $('#datatables').DataTable({ pageLength: 100, // jumlah baris per halaman lengthMenu: [10, 25, 50, 75, 100], + order: [[0, 'asc'], [1, 'asc']], columnDefs: [{ className: 'text-center', targets: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] diff --git a/app/Views/admin/index.php b/app/Views/admin/index.php index 0fd05ff..baab1f9 100644 --- a/app/Views/admin/index.php +++ b/app/Views/admin/index.php @@ -1,8 +1,3 @@ - extend('_layouts/main.php') ?> section('title') ?> @@ -14,7 +9,7 @@
- +
@@ -28,7 +23,7 @@
-
'> + '>
Date : @@ -61,8 +56,7 @@
- -
+
@@ -88,7 +81,6 @@
-
@@ -102,7 +94,6 @@
-
@@ -117,8 +108,7 @@
-
- +
-->
@@ -128,107 +118,107 @@
-
8
-
Pending
+
+
Pending
-
+
-
7
-
Partial Collected
+
+
Partial Collected
-
+
-
79
-
Collected
+
+
Collected
-
+
-
5
-
Partial Received
+
+
Partial Received
-
+
-
0
-
Received
+
+
Received
-
+
-
0
-
Incomplete
+
+
Incomplete
-
+
-
2
-
Printed
Not complete
+
+
Final
-
+
-
10
-
Complete
+
+
Final(Verified)
-
+
-
4
-
1-validation
+
+
Pending(Verified)
-
+
- +
@@ -241,25 +231,65 @@ - + + + - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
STests Result To ValidationStatusStatus
12025-10-25 11:25TEGUH PUTRA SIE, MR510272362801251002841PT. PRUDENTIAL LIFE ASSURANCE✶ HERNI SUPRAPTI, Dr - (DL), (DBIL), (IBIL), (SGOT), (SGPT), (ALP), (GGT), (ALB), (GLOBU), - (CHOL), (TG), (HDL), (LDL), (GLUP), (HBA1C), (UL) + + + + + + + + + + + + + + + + + + C/W
@@ -269,77 +299,10 @@ Result
Invalidation
Pending - Preview -
- Print | Eng -
- Pdf -
- Printed
- Hardcopy -
12025-10-25 11:25TEGUH PUTRA SIE, MR510272362801251002841PT. PRUDENTIAL LIFE ASSURANCE✶ HERNI SUPRAPTI, Dr - (DL), (DBIL), (IBIL), (SGOT), (SGPT), (ALP), (GGT), (ALB), (GLOBU), - (CHOL), (TG), (HDL), (LDL), (GLUP), (HBA1C), (UL) - C/W -
- - 1 - -
- Result
- Invalidation
-
Pending - Preview -
- Print | Eng -
- Pdf -
- Printed
- Hardcopy -
12025-10-25 11:25TEGUH PUTRA SIE, MR510272362801251002841PT. PRUDENTIAL LIFE ASSURANCE✶ HERNI SUPRAPTI, Dr - (DL), (DBIL), (IBIL), (SGOT), (SGPT), (ALP), (GGT), (ALB), (GLOBU), - (CHOL), (TG), (HDL), (LDL), (GLUP), (HBA1C), (UL) - C/W -
- - 2 - -
- Result
- Invalidation
-
Pending + + Preview
@@ -352,11 +315,12 @@ Hardcopy
- +
@@ -364,18 +328,16 @@
- +
endSection() ?> section('script') ?> endSection() ?> \ No newline at end of file