Pārlūkot izejas kodu

Merge branch 'master' into dev-vj

Vijayakrishnan Krishnan 5 gadi atpakaļ
vecāks
revīzija
ac45dcf4d7

+ 12 - 0
app/Http/Controllers/Controller.php

@@ -2,11 +2,14 @@
 
 namespace App\Http\Controllers;
 
+use App\Models\AppSession;
 use App\Models\Pro;
 use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
 use Illuminate\Foundation\Bus\DispatchesJobs;
 use Illuminate\Foundation\Validation\ValidatesRequests;
+use Illuminate\Http\Request;
 use Illuminate\Routing\Controller as BaseController;
+use Illuminate\Support\Facades\Cookie;
 
 class Controller extends BaseController
 {
@@ -21,4 +24,13 @@ class Controller extends BaseController
         }
         view()->share('pros', Pro::all());
     }
+
+    public function performer(){
+        $sessionKey = Cookie::get('sessionKey');
+        if ($sessionKey == null){
+            throw new \Exception('No session key in cookie.');
+        }
+        $performer = AppSession::where('session_key', $sessionKey)->first();
+        return $performer;
+    }
 }

+ 57 - 1
app/Http/Controllers/HomeController.php

@@ -4,13 +4,69 @@ namespace App\Http\Controllers;
 
 use App\Models\AppSession;
 use App\Models\Client;
+use App\Models\Bill;
+use App\Models\Note;
+use App\Models\ProTransaction;
 use Illuminate\Http\Request;
+use Illuminate\Support\Facades\DB;
 
 class HomeController extends Controller
 {
     public function dashboard(Request $request)
     {
-        return view('app/dashboard');
+
+        //patients where performer is the mcp
+        $performer = $this->performer();
+
+        $keyNumbers  = [];
+
+        $totalPatients = Client::where('mcp_pro_id', $performer->pro->id)->count();
+        $keyNumbers['totalPatients'] = $totalPatients;
+
+        $patientNotSeenYet = Client::where('mcp_pro_id', $performer->pro->id)
+            ->where(function($query){
+                $query->where('has_mcp_done_onboarding_visit', 'UNKNOWN')
+                ->orWhere('has_mcp_done_onboarding_visit', 'NO');
+            })->count();
+        $keyNumbers['patientsNotSeenYet'] = $patientNotSeenYet;
+
+        $performerProID = $performer->pro->id;
+        $pendingBillsToSign = Bill::where(function($query) use ($performerProID){
+            $query->where('hcp_pro_id', $performerProID)->where('is_signed_by_hcp', false);
+        })
+        ->orWhere(function($query) use ($performerProID){
+            $query->where('cm_pro_id', $performerProID)->where('is_signed_by_cm', false);
+        })->orWhere(function($query) use ($performerProID){
+            $query->where('rme_pro_id', $performerProID)->where('is_signed_by_rme', false);
+        })->orWhere(function($query) use ($performerProID){
+            $query->where('rmm_pro_id', $performerProID)->where('is_signed_by_rmm', false);
+        })->count();
+        
+        $keyNumbers['pendingBillsToSign'] = $pendingBillsToSign;
+
+        $pendingNotesToSign = Note::where(function($query) use ($performerProID){
+            $query->where('hcp_pro_id', $performerProID)->where('is_signed_by_hcp', false);
+        })
+        ->orWhere(function($query) use ($performerProID){
+            $query->where('ally_pro_id', $performerProID)->where('is_signed_by_ally', false);
+        })->count();
+        
+        $keyNumbers['pendingNotesToSign'] = $pendingNotesToSign;
+
+        $reimbursement = [];
+        $reimbursement["currentBalance"] = $performer->pro->balance;
+        $reimbursement["nextPaymentDate"] = '--';
+        $lastPayment = ProTransaction::where('pro_id', $performerProID)->where('plus_or_minus', 'PLUS')->orderBy('created_at', 'DESC')->first();
+        if($lastPayment) {
+            $reimbursement["lastPayment"] = $lastPayment->amount;
+            $reimbursement["lastPaymentDate"] = $lastPayment->created_at;
+        }else{
+            $reimbursement["lastPayment"] = '--';
+            $reimbursement["lastPaymentDate"] = '--';   
+        }
+        
+
+        return view('app/dashboard', compact('keyNumbers','reimbursement'));
     }
 
     public function patients(Request $request)

+ 1 - 1
app/Models/ProTransaction.php

@@ -6,5 +6,5 @@ namespace App\Models;
 
 class ProTransaction extends Model
 {
-    //
+    protected $table = 'pro_transaction';
 }

+ 47 - 37
public/js/mc.js

@@ -1,6 +1,6 @@
 var findEventHandlers = function (eventType, jqSelector) {
     var results = [];
-    var $ = jQuery;// to avoid conflict between others frameworks like Mootools
+    var $ = jQuery; // to avoid conflict between others frameworks like Mootools
 
     var arrayIntersection = function (array1, array2) {
         return $(array1).filter(function (index, element) {
@@ -16,7 +16,9 @@ var findEventHandlers = function (eventType, jqSelector) {
     var addEventHandlerInfo = function (element, event, $elementsCovered) {
         var extendedEvent = event;
         if ($elementsCovered !== void 0 && $elementsCovered !== null) {
-            $.extend(extendedEvent, { targets: $elementsCovered.toArray() });
+            $.extend(extendedEvent, {
+                targets: $elementsCovered.toArray()
+            });
         }
         var eventInfo;
         var eventsInfo = $.grep(results, function (evInfo, index) {
@@ -37,7 +39,7 @@ var findEventHandlers = function (eventType, jqSelector) {
 
 
     var $elementsToWatch = $(jqSelector);
-    if (jqSelector === "*")//* does not include document and we might be interested in handlers registered there
+    if (jqSelector === "*") //* does not include document and we might be interested in handlers registered there
         $elementsToWatch = $elementsToWatch.add(document);
     var $allElements = $("*").add(document);
 
@@ -45,7 +47,7 @@ var findEventHandlers = function (eventType, jqSelector) {
         var allElementEvents = $._data(element, "events");
         if (allElementEvents !== void 0 && allElementEvents[eventType] !== void 0) {
             var eventContainer = allElementEvents[eventType];
-            $.each(eventContainer, function(eventIndex, event){
+            $.each(eventContainer, function (eventIndex, event) {
                 var isDelegateEvent = event.selector !== void 0 && event.selector !== null;
                 var $elementsCovered;
                 if (isDelegateEvent) {
@@ -63,27 +65,28 @@ var findEventHandlers = function (eventType, jqSelector) {
     return results;
 };
 
-window.top.addEventListener('popstate', function(event) {
-    window.setTimeout(function() {
-        if(!event) return;
+window.top.addEventListener('popstate', function (event) {
+    window.setTimeout(function () {
+        if (!event) return;
         var state = event.state;
-        if(state === '') state = '/';
-        if(state[0] !== '/') state = '/' + state;
-        if(!!state) fastLoad(state, false, true);
+        if (state === '') state = '/';
+        if (state[0] !== '/') state = '/' + state;
+        if (!!state) fastLoad(state, false, true);
     }, 0);
 });
-$(document).ready(function() {
-    $(document).on('click', '.stag_rhs_toggle', function() {
-        var state = window.top.toggleRHS(), icon = $(this).find('i');
-        if(state === 'collapsed') {
+$(document).ready(function () {
+    $(document).on('click', '.stag_rhs_toggle', function () {
+        var state = window.top.toggleRHS(),
+            icon = $(this).find('i');
+        if (state === 'collapsed') {
             icon.removeClass().addClass('fa fa-arrow-left');
-        }
-        else {
+        } else {
             icon.removeClass().addClass('fa fa-arrow-right');
         }
     });
-    var body = $(window.top.document.body), icon = $('.stag_rhs_toggle i');
-    if(body.is('.stag_rhs_collapsed')) {
+    var body = $(window.top.document.body),
+        icon = $('.stag_rhs_toggle i');
+    if (body.is('.stag_rhs_collapsed')) {
         icon.removeClass().addClass('fa fa-arrow-left');
     }
     initFastLoad();
@@ -100,18 +103,17 @@ function initFastLoad(_parent = false) {
     fastCache = {};
 
     var allAs = $('a:not([onclick]):not([href="#"])');
-    if(_parent) {
+    if (_parent) {
         allAs = _parent.find('a:not([onclick]):not([href="#"])');
     }
     // find links without event handlers
-    allAs.each(function() {
-        if(!$(this).closest('[moe]').length) {
-            if($(this).closest('.dropdown-menu[aria-labelledby="practice-management"]').length) {
+    allAs.each(function () {
+        if (!$(this).closest('[moe]').length) {
+            if ($(this).closest('.dropdown-menu[aria-labelledby="practice-management"]').length) {
                 enableFastLoad(this, true);
-            }
-            else {
+            } else {
                 var handlers = findEventHandlers('click', this);
-                if(!handlers || !handlers.length) {
+                if (!handlers || !handlers.length) {
                     enableFastLoad(this);
                 }
             }
@@ -119,9 +121,9 @@ function initFastLoad(_parent = false) {
     });
 
     function enableFastLoad(_a, _menuItem = false) {
-        $(_a).on('click', function() {
+        $(_a).on('click', function () {
             fastLoad(this.href, true, true);
-            if(_menuItem) {
+            if (_menuItem) {
                 $(this).closest('.dropdown-menu')
                     .removeClass('show')
                     .prev('.dropdown-toggle').attr('aria-expanded', 'false');
@@ -133,7 +135,7 @@ function initFastLoad(_parent = false) {
 
     // fast cache
     allAs = $('a:not([onclick]):not([href="#"])');
-    allAs.each(function() {
+    allAs.each(function () {
         var a = this;
         $.get(a.href, function (_data) {
             fastCache[a.href] = _data;
@@ -141,44 +143,44 @@ function initFastLoad(_parent = false) {
     });
 
 }
+
 function fastLoad(_href, _history = true, _useCache = true) {
     function onData(_data) {
         var targetParent = $('.stag-content');
         _data = '<div>' + _data + '</div>';
         var content = $(_data).find('.stag-content');
-        if(content && content.length) {
+        if (content && content.length) {
             content = content.html();
             content += '<script src="/js/yemi.js"></script>';
             targetParent.html(content);
             initFastLoad(targetParent);
 
             // push state
-            if(_history) {
+            if (_history) {
                 var target = _href;
-                if(target.indexOf('//') !== -1) {
+                if (target.indexOf('//') !== -1) {
                     target = target.split('//')[1];
-                    if(target.indexOf('/') !== -1) {
+                    if (target.indexOf('/') !== -1) {
                         target = target.substr(target.indexOf('/') + 1);
                     }
                 }
                 window.top.history.pushState(target, null, '/mc/' + target);
             }
 
-        }
-        else {
+        } else {
             console.warn('Target page not found: ' + _href);
             window.location.href = _href; // fallback
         }
         hideMask();
     }
     showMask();
-    if(_useCache && !!fastCache[_href]) {
+    if (_useCache && !!fastCache[_href]) {
         onData(fastCache[_href]);
-    }
-    else {
+    } else {
         $.get(_href, onData);
     }
 }
+
 function openInRHS(_url) {
     window.top.showRHS();
     var icon = $('.stag_rhs_toggle i');
@@ -186,3 +188,11 @@ function openInRHS(_url) {
     window.top.openInRHS(_url);
     return false;
 }
+
+function initializeCalendar() {
+    var calendarEl = document.getElementById('calendar');
+    var calendar = new FullCalendar.Calendar(calendarEl, {
+        initialView: 'dayGridMonth'
+    });
+    calendar.render();
+}

+ 8 - 19
resources/views/app/dashboard.blade.php

@@ -16,19 +16,19 @@
                             <table class="table table-condensed table-bordered m-0">
                                 <tbody>
                                 <tr>
-                                    <th>0</th>
+                                    <th>{{$keyNumbers['totalPatients']}}</th>
                                     <th>Total patients</th>
                                 </tr>
                                 <tr>
-                                    <th>0</th>
+                                    <th>{{$keyNumbers['patientsNotSeenYet']}}</th>
                                     <th>Patients I have not seen yet</th>
                                 </tr>
                                 <tr>
-                                    <th>0</th>
+                                    <th>{{$keyNumbers['pendingBillsToSign']}}</th>
                                     <th>Pending bills to sign</th>
                                 </tr>
                                 <tr>
-                                    <th>0</th>
+                                    <th>{{$keyNumbers['pendingNotesToSign']}}</th>
                                     <th>Pending notes to sign</th>
                                 </tr>
                                 </tbody>
@@ -45,19 +45,19 @@
                             <table class="table table-condensed table-bordered m-0">
                                 <tbody>
                                 <tr>
-                                    <th>$1034.90</th>
+                                    <th>{{$reimbursement['currentBalance']}}</th>
                                     <th>Current balance</th>
                                 </tr>
                                 <tr>
-                                    <th>30 June, 2020</th>
+                                    <th>{{$reimbursement['nextPaymentDate']}}</th>
                                     <th>Next Payment Date</th>
                                 </tr>
                                 <tr>
-                                    <th>$1023.00</th>
+                                    <th>{{$reimbursement['lastPayment']}}</th>
                                     <th>Last payment</th>
                                 </tr>
                                 <tr>
-                                    <th>15 June, 2020</th>
+                                    <th>{{$reimbursement['lastPaymentDate']}}</th>
                                     <th>Last payment date</th>
                                 </tr>
                                 </tbody>
@@ -71,15 +71,4 @@
             </div>
         </div>
     </div>
-    <script>
-
-        document.addEventListener('DOMContentLoaded', function() {
-          var calendarEl = document.getElementById('calendar');
-          var calendar = new FullCalendar.Calendar(calendarEl, {
-            initialView: 'dayGridMonth'
-          });
-          calendar.render();
-        });
-  
-      </script>
 @endsection