Explorar o código

Process notes (wip)

Vijayakrishnan %!s(int64=4) %!d(string=hai) anos
pai
achega
7ac4aff4f2

+ 61 - 0
app/Http/Controllers/PracticeManagementController.php

@@ -1178,6 +1178,67 @@ ORDER BY claim.created_at ASC
         return  view('app.practice-management.process-notes', compact('mode', 'counts'));
     }
 
+    public function getNextNote(Request $request, $mode)
+    {
+        $note = null;
+        switch (+$mode) {
+            case 1:
+                $note = Note::where('is_cancelled', false)
+                    ->where('is_signed_by_hcp', false)
+                    ->whereRaw("((detail_json)::json->>'isBad' is null OR ((detail_json)::json->>'isBad')::text != 'true')")
+                    ->whereNull('current_note_pickup_for_processing_id')
+                    ->orderBy('effective_dateest', 'ASC')
+                    ->first();
+                break;
+            case 2:
+                $note = Note::where('is_cancelled', false)
+                    ->where('is_signed_by_hcp', true)
+                    ->whereRaw("((detail_json)::json->>'isBad' is null OR ((detail_json)::json->>'isBad')::text != 'true')")
+                    ->whereNull('current_note_pickup_for_processing_id')
+                    ->where('is_billing_marked_done', false)
+                    ->orderBy('effective_dateest', 'ASC')
+                    ->first();
+                break;
+            case 3:
+                $note = Note::where('is_cancelled', false)
+                    ->where('is_signed_by_hcp', true)
+                    ->whereRaw("((detail_json)::json->>'isBad' is null OR ((detail_json)::json->>'isBad')::text != 'true')")
+                    ->whereNull('current_note_pickup_for_processing_id')
+                    ->where('is_billing_marked_done', true)
+                    ->where('is_bill_closed', false)
+                    ->orderBy('effective_dateest', 'ASC')
+                    ->first();
+                break;
+            case 4:
+                $note = Note::where('is_cancelled', false)
+                    ->where('is_signed_by_hcp', true)
+                    ->whereRaw("((detail_json)::json->>'isBad' is null OR ((detail_json)::json->>'isBad')::text != 'true')")
+                    ->whereNull('current_note_pickup_for_processing_id')
+                    ->where('is_billing_marked_done', true)
+                    ->where('is_bill_closed', true)
+                    ->where('is_claim_closed', false)
+                    ->orderBy('effective_dateest', 'ASC')
+                    ->first();
+                break;
+            case 5:
+                $note = Note::where('is_cancelled', false)
+                    ->where('is_signed_by_hcp', true)
+                    ->whereRaw("((detail_json)::json->>'isBad' is null OR ((detail_json)::json->>'isBad')::text != 'true')")
+                    ->whereNull('current_note_pickup_for_processing_id')
+                    ->where('is_billing_marked_done', true)
+                    ->where('is_bill_closed', true)
+                    ->where('is_claim_closed', true)
+                    ->whereRaw("(SELECT count(id) FROM claim WHERE note_id = note.id AND is_cancelled IS FALSE AND status != 'CANCELLED' AND status != 'SUBMITTED') > 0")
+                    ->orderBy('effective_dateest', 'ASC')
+                    ->first();
+                break;
+        }
+        if($note) {
+            $note->client_uid = $note->client->uid;
+        }
+        return json_encode($note);
+    }
+
     public function currentMbClaim(Request $request, $claimUid) {
         $claim = Claim::where('uid', $claimUid)->first();
         return json_encode(MBClaim::where('claim_version_id', $claim->currentVersion->id)->first());

+ 65 - 3
resources/views/app/practice-management/process-notes.blade.php

@@ -1,8 +1,17 @@
 @extends ('layouts/template')
 
 @section('content')
-
-    <div class="p-3 mcp-theme-1">
+    <?php
+    $modeLabel = '';
+    switch(+$mode) {
+        case 1: $modeLabel = 'Not Yet Signed'; break;
+        case 2: $modeLabel = 'Billing Not Marked Done'; break;
+        case 3: $modeLabel = 'Billing Not Closed'; break;
+        case 4: $modeLabel = 'Claiming Not Closed'; break;
+        case 5: $modeLabel = 'Has Unsubmitted Claims'; break;
+    }
+    ?>
+    <div id="process-notes" class="p-3 mcp-theme-1">
         <h2 class="font-size-16 font-weight-bold pb-3 border-bottom mb-3">Process Notes</h2>
         <div class="d-flex align-items-center border-bottom mb-3 pb-3">
             <span class="mr-3">Notes: </span>
@@ -47,8 +56,61 @@
             </div>
         </div>
 
-        Hello
+        <div class="pt-5 d-flex align-items-center justify-content-center">
+            <button class="btn btn-primary font-size-14 font-weight-normal px-4" id="btn-pick">
+                <b class="font-size-14">{{$modeLabel}} ({{$counts["mode-" . $mode]}})</b>&nbsp;&nbsp;<i class="fa fa-arrow-right"></i>&nbsp;&nbsp;Pick Up Next Available Note
+            </button>
+        </div>
 
     </div>
+    <script>
+        (function() {
+            function init() {
+
+                function hasError(_data) {
+                    let msg = 'Unknown error!';
+                    if (_data) {
+                        if (_data.success) return false;
+                        else if (_data.message) msg = _data.message;
+                    }
+                    toastr.error(msg);
+                    return true;
+                }
+
+                $('#btn-pick')
+                    .off('click')
+                    .on('click', function() {
+                        $.get('{{route('practice-management.get-next-note', ['mode' => $mode])}}', _data => {
+                            if(_data) {
+
+                                let clientUid = _data.client_uid, noteUid = _data.uid;
+
+                                // mark as picked up
+                                $.post('/api/note/pickUpForProcessing', {
+                                    uid: noteUid
+                                }, _data => {
+                                    if (!hasError(_data)) {
+
+                                        // open in popup
+                                        openDynamicStagPopup(
+                                            '/patients/view/' + clientUid + '/notes/view/' + noteUid,
+                                            'note-single',
+                                            'Note - {{$modeLabel}}',
+                                            true
+                                        );
+                                    }
+                                }, 'json');
+
+                            }
+                            else {
+                                toastr.error('No notes available for pickup in the selected mode')
+                            }
+                        }, 'json');
+                        return false;
+                    });
+            }
+            addMCInitializer('process-notes', init, '#process-notes')
+        }).call(window);
+    </script>
 
 @endsection

+ 1 - 0
routes/web.php

@@ -96,6 +96,7 @@ Route::middleware('pro.auth')->group(function () {
 
         Route::get('process-claims', 'PracticeManagementController@processClaims')->name('process-claims');
         Route::get('process-notes', 'PracticeManagementController@processNotes')->name('process-notes');
+        Route::get('get-next-note/{mode}', 'PracticeManagementController@getNextNote')->name('get-next-note');
 
 
         Route::middleware('pro.auth.admin')->group(function(){