diff --git a/app/Controllers/API_Dashboard.php b/app/Controllers/API_Dashboard.php index 6bd6e2e..7383bc1 100644 --- a/app/Controllers/API_Dashboard.php +++ b/app/Controllers/API_Dashboard.php @@ -19,50 +19,50 @@ class API_Dashboard extends ResourceController { $db = \Config\Database::connect(); $date1 = $this->request->getPost('date1'); $date2 = $this->request->getPost('date2'); - $sql = "select sr.COLLECTIONDATE, sr.SP_ACCESSNUMBER, sr.HOSTORDERNUMBER, p.PATNUMBER, p.NAME, - TESTS=stuff(( select ', '+'('+T.SP_TESTCODE+')' from - ( select T.SP_TESTCODE from SP_TESTS T - where T.SP_ACCESSNUMBER=sr.SP_ACCESSNUMBER - and T.DEPTH=0 AND T.SP_TESTCODE <> 'Q' - ) as T - for xml path('')),1,1,''), -case -when exists (select 1 from AUDIT_TRAIL at where at.ATR_ACCESSNUMBER=sr.SP_ACCESSNUMBER and at.STEPTYPE=2 and at.LIS_SESSION='RFC' ) then - case - when exists (select 1 from SP_TUBES st where st.SP_ACCESSNUMBER=sr.SP_ACCESSNUMBER and st.TUBESTATUS=0 ) then 'PartRecv' - when exists (select 1 from TESTS T where T.REQUESTID=r.REQUESTID and T.RESTYPE IN (null,'0') ) then 'Inc' - --when exists (select 1 from TESTS T where T.REQUESTID=r.REQUESTID and T.RESTYPE IN (null,'0') and T.TESTID='1805' ) then 'Inc' - else 'Comp' - end --- inc -when exists (select 1 from TESTS T where T.RESTYPE not in (0,4) and T.REQUESTID=r.REQUESTID ) then - case - when exists ( select 1 from cmod.dbo.CM_TUBES T where T.ACCESSNUMBER=sr.SP_ACCESSNUMBER and T.COLLSTATUS=0 ) then 'PartColl' - when exists (select 1 from SP_TUBES st where st.SP_ACCESSNUMBER=sr.SP_ACCESSNUMBER and st.TUBESTATUS=0 ) then 'PartRecv' - else 'Inc' - end ---rcv -when not exists (select 1 from SP_TUBES st where st.SP_ACCESSNUMBER=sr.SP_ACCESSNUMBER and st.TUBESTATUS=0 ) then - case - when exists (select 1 from cmod.dbo.CM_TUBES T where T.ACCESSNUMBER=sr.SP_ACCESSNUMBER and T.COLLSTATUS=0 ) then 'PartColl' - else 'Recv' - end ---coll -when exists (select 1 FROM cmod.dbo.CM_TUBES T where T.ACCESSNUMBER=sr.SP_ACCESSNUMBER ) then - case - when exists (select 1 from SP_TUBES st where st.SP_ACCESSNUMBER=sr.SP_ACCESSNUMBER and st.TUBESTATUS=4 ) then 'PartRecv' - when not exists (select 1 from cmod.dbo.CM_TUBES T where T.ACCESSNUMBER=sr.SP_ACCESSNUMBER and T.COLLSTATUS=0 ) then 'Coll' - when exists (select 1 from cmod.dbo.CM_TUBES T where T.ACCESSNUMBER=sr.SP_ACCESSNUMBER and T.COLLSTATUS=1 ) then 'PartColl' - else 'Pend' - end -else 'Pend' -end STATS - from SP_REQUESTS sr - left join PATIENTS p on p.PATID=sr.PATID - left join REQUESTS r on r.ACCESSNUMBER=sr.SP_ACCESSNUMBER - where sr.COLLECTIONDATE between '$date1 00:00' and '$date2 23:59'" - .$filter_query. - "order by sr.COLLECTIONDATE desc"; + $sql = "select sr.COLLECTIONDATE, sr.SP_ACCESSNUMBER, sr.HOSTORDERNUMBER, p.PATNUMBER, concat(p.FIRSTNAMESK, ' ', p.NAME) as NAME, + TESTS=stuff(( select ', '+'('+T.SP_TESTCODE+')' from + ( select T.SP_TESTCODE from SP_TESTS T + where T.SP_ACCESSNUMBER=sr.SP_ACCESSNUMBER + and T.DEPTH=0 AND T.SP_TESTCODE <> 'Q' + ) as T + for xml path('')),1,1,''), + case + when exists (select 1 from AUDIT_TRAIL at where at.ATR_ACCESSNUMBER=sr.SP_ACCESSNUMBER and at.STEPTYPE=2 and at.LIS_SESSION='RFC' ) then + case + when exists (select 1 from SP_TUBES st where st.SP_ACCESSNUMBER=sr.SP_ACCESSNUMBER and st.TUBESTATUS=0 ) then 'PartRecv' + when exists (select 1 from TESTS T where T.REQUESTID=r.REQUESTID and T.RESTYPE IN (null,'0') ) then 'Inc' + --when exists (select 1 from TESTS T where T.REQUESTID=r.REQUESTID and T.RESTYPE IN (null,'0') and T.TESTID='1805' ) then 'Inc' + else 'Comp' + end + -- inc + when exists (select 1 from TESTS T where T.RESTYPE not in (0,4) and T.REQUESTID=r.REQUESTID ) then + case + when exists ( select 1 from cmod.dbo.CM_TUBES T where T.ACCESSNUMBER=sr.SP_ACCESSNUMBER and T.COLLSTATUS=0 ) then 'PartColl' + when exists (select 1 from SP_TUBES st where st.SP_ACCESSNUMBER=sr.SP_ACCESSNUMBER and st.TUBESTATUS=0 ) then 'PartRecv' + else 'Inc' + end + --rcv + when not exists (select 1 from SP_TUBES st where st.SP_ACCESSNUMBER=sr.SP_ACCESSNUMBER and st.TUBESTATUS=0 ) then + case + when exists (select 1 from cmod.dbo.CM_TUBES T where T.ACCESSNUMBER=sr.SP_ACCESSNUMBER and T.COLLSTATUS=0 ) then 'PartColl' + else 'Recv' + end + --coll + when exists (select 1 FROM cmod.dbo.CM_TUBES T where T.ACCESSNUMBER=sr.SP_ACCESSNUMBER ) then + case + when exists (select 1 from SP_TUBES st where st.SP_ACCESSNUMBER=sr.SP_ACCESSNUMBER and st.TUBESTATUS=4 ) then 'PartRecv' + when not exists (select 1 from cmod.dbo.CM_TUBES T where T.ACCESSNUMBER=sr.SP_ACCESSNUMBER and T.COLLSTATUS=0 ) then 'Coll' + when exists (select 1 from cmod.dbo.CM_TUBES T where T.ACCESSNUMBER=sr.SP_ACCESSNUMBER and T.COLLSTATUS=1 ) then 'PartColl' + else 'Pend' + end + else 'Pend' + end STATS + from SP_REQUESTS sr + left join PATIENTS p on p.PATID=sr.PATID + left join REQUESTS r on r.ACCESSNUMBER=sr.SP_ACCESSNUMBER + where sr.COLLECTIONDATE between '$date1 00:00' and '$date2 23:59'" + .$filter_query. + "order by sr.COLLECTIONDATE desc"; $query = $db->query($sql); $results = $query->getResultArray(); $data['data'] = $results; diff --git a/app/Views/admin/dashboard.php b/app/Views/admin/dashboard.php index 931b86a..87be006 100644 --- a/app/Views/admin/dashboard.php +++ b/app/Views/admin/dashboard.php @@ -3,7 +3,7 @@ = $this->section('content') ?> @@ -107,7 +107,8 @@ function index() { $("#table-body").html(""); var data = response['data']; for (var i = 0; i < data.length; i++) { - colldate = data[i].COLLECTIONDATE.substr(0,16); + colldate = data[i].COLLECTIONDATE.slice(0,10); + colltime = data[i].COLLECTIONDATE.slice(10,16); if (data[i].PATNUMBER != null) { patnumber = data[i].PATNUMBER.substr(-16,16); @@ -154,9 +155,9 @@ function index() { datafilter = "data-filterrow='7'"; stattext = 'Validated'; } - let datarow = "