소스 검색

Merge branch 'dev-segment-update' of rav.triplestart.com:jmudaka/stagfe2 into dev

= 3 년 전
부모
커밋
68def6d8c1

+ 8 - 0
app/Http/Controllers/AdminController.php

@@ -135,6 +135,14 @@ class AdminController extends Controller
         return view('app.mcp.notes', compact('notes'));
     }
 
+    public function notes_pending_summary_suggestion(Request $request){
+        $pro = $this->performer->pro;
+        $data = [
+            'records' => $pro->get_notes_pending_summary_suggestion_as_admin()
+        ];
+        return view('app.admin.notes_pending_summary_suggestion', $data);
+    }
+
     public function appointments(Request $request)
     {
         $appointments = Appointment::paginate(5);

+ 9 - 0
app/Http/Controllers/McpController.php

@@ -286,6 +286,15 @@ class McpController extends Controller
         ];
         return view('app.mcp.notes_pending_signature', $data);
     }
+
+    public function notes_pending_summary_suggestion(Request $request){
+        $pro = $this->performer->pro;
+        $data = [
+            'records' => $pro->get_notes_pending_summary_suggestion_as_mcp()
+        ];
+        return view('app.mcp.notes_pending_summary_suggestion', $data);
+    }
+
     public function notes_pending_billing(Request $request){
         $data = [
             'records' => Note::where('hcp_pro_id', $this->performer->pro->id)

+ 3 - 28
app/Http/Controllers/NoteController.php

@@ -107,33 +107,8 @@ class NoteController extends Controller
             $pro = $performer->pro;
 
             $segment = Segment::where('uid', $segmentUid)->first();
-            $segmentTemplate = $segment->segmentTemplate;
 
-            $note = $segment->note;
-            $patient = $note->client;
-
-            $data = compact('performer', 'pro', 'segment', 'segmentTemplate', 'note', 'patient');
-
-
-            $summaryHtml = view('app.patient.segment-templates.' . $segmentTemplate->internal_name . '/summary', $data)->render();
-
-            $wizardPowered = [
-                'intake_medications',
-                'plan_medications',
-                'intake_problems',
-                'plan_problems',
-                'intake_goals',
-                'plan_goals',
-                'intake_allergies',
-                'plan_allergies',
-                'intake_care_team',
-                'plan_care_team',
-                'intake_supplements',
-                'plan_supplements'
-            ];
-            if(!in_array($segmentTemplate->internal_name, $wizardPowered)) {
-                $editHtml = view('app.patient.segment-templates.' . $segmentTemplate->internal_name . '/edit', $data)->render();
-            }
+            $recalculatedHtml = $segment->getRecalculatedHtml($performer);
 
         } catch (\Throwable $e) {
             return response()->json([
@@ -144,8 +119,8 @@ class NoteController extends Controller
 
         return response()->json([
             'success'=>true,
-            'summaryHtml' => $summaryHtml,
-            'editHtml' => $editHtml
+            'summaryHtml' => $recalculatedHtml['summaryHtml'],
+            'editHtml' => $recalculatedHtml['editHtml'],
         ]);
     }
 

+ 41 - 0
app/Models/Pro.php

@@ -369,6 +369,47 @@ class Pro extends Model
             ->count();
     }
 
+    function get_notes_pending_summary_suggestion_as_mcp_query(){
+        $segmentsWithProposedSummarySuggestion = Segment::whereNotNull('proposed_segment_summary_suggestion_id')->get();
+        $noteIDs = [];
+        foreach($segmentsWithProposedSummarySuggestion as $seg){
+            $noteIDs[] = $seg->note_id;
+        }
+        return Note::where('hcp_pro_id', $this->id)
+            ->where('is_cancelled', '<>', true)
+            ->where('is_core_note', '<>', true)
+            ->where('is_signed_by_hcp', true)
+            ->whereIn('id', $noteIDs);
+    }
+
+    function get_notes_pending_summary_suggestion_count_as_mcp(){
+        return $this->get_notes_pending_summary_suggestion_as_mcp_query()->count();
+    }
+
+    function get_notes_pending_summary_suggestion_as_mcp(){
+        return $this->get_notes_pending_summary_suggestion_as_mcp_query()->get();
+    }
+
+    function get_notes_pending_summary_suggestion_as_admin_query(){
+        $segmentsWithProposedSummarySuggestion = Segment::whereNotNull('proposed_segment_summary_suggestion_id')->get();
+        $noteIDs = [];
+        foreach($segmentsWithProposedSummarySuggestion as $seg){
+            $noteIDs[] = $seg->note_id;
+        }
+        return Note::where('is_cancelled', '<>', true)
+            ->where('is_core_note', '<>', true)
+            ->where('is_signed_by_hcp', true)
+            ->whereIn('id', $noteIDs);
+    }
+
+    function get_notes_pending_summary_suggestion_count_as_admin(){
+        return $this->get_notes_pending_summary_suggestion_as_admin_query()->count();
+    }
+
+    function get_notes_pending_summary_suggestion_as_admin(){
+        return $this->get_notes_pending_summary_suggestion_as_admin_query()->get();
+    }
+
     function get_notes_pending_billing_count_as_mcp() {
         return Note::where('hcp_pro_id', $this->id)
             ->where('is_cancelled', '<>', true)

+ 51 - 0
app/Models/Segment.php

@@ -23,4 +23,55 @@ class Segment extends Model
     public function shortName(){
         return trim(array_reverse(explode('>', $this->display_title))[0]);
     }
+
+    public function summarySuggestions()
+    {
+        return $this->hasMany(SegmentSummarySuggestion::class, 'segment_id', 'id')->orderBy('created_at', 'DESC');
+    }
+
+    public function proposedSegmentSummarySuggestion() {
+        return $this->hasOne(SegmentSummarySuggestion::class, 'id', 'proposed_segment_summary_suggestion_id');
+    }
+
+    public function acceptedSegmentSummarySuggestion() {
+        return $this->hasOne(SegmentSummarySuggestion::class, 'id', 'accepted_segment_summary_suggestion_id');
+    }
+
+    public function getRecalculatedHtml($performer){
+        $pro = $performer->pro;
+        $segment = $this; 
+        $segmentTemplate = $this->segmentTemplate;
+
+        $note = $this->note;
+        $patient = $note->client;
+
+        $data = compact('performer', 'pro', 'segment', 'segmentTemplate', 'note', 'patient');
+
+
+        $summaryHtml = view('app.patient.segment-templates.' . $segmentTemplate->internal_name . '/summary', $data)->render();
+
+        $wizardPowered = [
+            'intake_medications',
+            'plan_medications',
+            'intake_problems',
+            'plan_problems',
+            'intake_goals',
+            'plan_goals',
+            'intake_allergies',
+            'plan_allergies',
+            'intake_care_team',
+            'plan_care_team',
+            'intake_supplements',
+            'plan_supplements'
+        ];
+        if(!in_array($segmentTemplate->internal_name, $wizardPowered)) {
+            $editHtml = view('app.patient.segment-templates.' . $segmentTemplate->internal_name . '/edit', $data)->render();
+        }
+
+        return [
+            'summaryHtml'=> $summaryHtml ,
+            'editHtml' => $editHtml
+        ];
+    }
+
 }

+ 13 - 0
app/Models/SegmentSummaryChange.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace App\Models;
+
+# use Illuminate\Database\Eloquent\Model;
+
+class SegmentSummaryChange extends Model
+{
+    protected $table = 'segment_summary_change';
+
+   
+
+}

+ 13 - 0
app/Models/SegmentSummarySuggestion.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace App\Models;
+
+# use Illuminate\Database\Eloquent\Model;
+
+class SegmentSummarySuggestion extends Model
+{
+    protected $table = 'segment_summary_suggestion';
+
+   
+
+}

+ 47 - 0
resources/views/app/admin/notes_pending_summary_suggestion.blade.php

@@ -0,0 +1,47 @@
+<div class="p-3 mcp-theme-1">
+    <div class="card border-top-0">
+
+        <div class="card-header px-2 py-1 hide-inside-popup border-bottom-0">
+            <strong class="mr-4">
+                <i class="fas fa-sticky-note"></i>
+                Notes With Pending Summary Suggestion
+            </strong>
+        </div>
+
+        <div class="card-body p-0 border-top-0 pb-0">
+            <table class="table table-sm border-top table-striped mb-0">
+                <thead class="bg-light">
+                <tr>
+                    <th class="border-0">Date</th>
+                    <th class="border-0">Patient</th>
+                    <th class="border-0">ICD</th>
+                    <th class="border-0">Status</th>
+                </tr>
+                </thead>
+                <tbody>
+                @foreach($records as $row)
+                    <tr>
+                        <td>
+                            <a native target="_blank" href="/patients/view/{{ $row->client->uid }}/notes/view/{{ $row->uid }}?suggestion_mode=on">
+                                {{ friendlier_date($row->effective_dateest) }}
+                            </a>
+                        </td>
+                        <td>{{$row->client->displayName()}}</td>
+                        <td>
+                            @foreach($row->reasons as $reason)
+                                <span class="pr-2">{{$reason->code}}</span>
+                            @endforeach
+                            @if(!$row->reasons || !count($row->reasons))
+                                -
+                            @endif
+                        </td>
+                        <td>
+                            {{$row->overallStatus()}}
+                        </td>
+                    </tr>
+                @endforeach
+                </tbody>
+            </table>
+        </div>
+    </div>
+</div>

+ 12 - 0
resources/views/app/dashboard-admin.blade.php

@@ -36,6 +36,18 @@
                                     <th class="px-2 text-center">{{$pro->get_notes_pending_signature_count_as_mcp()}}</th>
                                     <th class="pl-2">Notes Pending Signature</th>
                                 </tr>
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_notes_pending_summary_suggestion_count_as_admin()}}</th>
+                                    <th class="pl-2">
+                                        <a href="{{ route('admin.notes_pending_summary_suggestion') }}"
+                                           native target="_blank"
+                                           open-in-stag-popup
+                                           popup-style="tall"
+                                           title="Notes With Pending Summary Suggestion">
+                                            Notes With Pending Summary Suggestion
+                                        </a>
+                                    </th>
+                                </tr>
                                 <tr>
                                     <th class="px-2 text-center">{{$pro->get_notes_pending_billing_count_as_mcp()}}</th>
                                     <th class="pl-2">Notes Pending Billing</th>

+ 12 - 0
resources/views/app/dashboard-mcp.blade.php

@@ -63,6 +63,18 @@
                                         </a>
                                     </th>
                                 </tr>
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_notes_pending_summary_suggestion_count_as_mcp()}}</th>
+                                    <th class="pl-2">
+                                        <a href="{{ route('mcp.notes_pending_summary_suggestion') }}"
+                                           native target="_blank"
+                                           open-in-stag-popup
+                                           popup-style="tall"
+                                           title="Notes With Pending Summary Suggestion">
+                                            Notes With Pending Summary Suggestion
+                                        </a>
+                                    </th>
+                                </tr>
                                 <tr>
                                     <th class="px-2 text-center">{{$pro->get_notes_pending_billing_count_as_mcp()}}</th>
                                     <th class="pl-2">

+ 47 - 0
resources/views/app/mcp/notes_pending_summary_suggestion.blade.php

@@ -0,0 +1,47 @@
+<div class="p-3 mcp-theme-1">
+    <div class="card border-top-0">
+
+        <div class="card-header px-2 py-1 hide-inside-popup border-bottom-0">
+            <strong class="mr-4">
+                <i class="fas fa-sticky-note"></i>
+                Notes With Pending Summary Suggestion
+            </strong>
+        </div>
+
+        <div class="card-body p-0 border-top-0 pb-0">
+            <table class="table table-sm border-top table-striped mb-0">
+                <thead class="bg-light">
+                <tr>
+                    <th class="border-0">Date</th>
+                    <th class="border-0">Patient</th>
+                    <th class="border-0">ICD</th>
+                    <th class="border-0">Status</th>
+                </tr>
+                </thead>
+                <tbody>
+                @foreach($records as $row)
+                    <tr>
+                        <td>
+                            <a native target="_blank" href="/patients/view/{{ $row->client->uid }}/notes/view/{{ $row->uid }}?suggestion_mode=on">
+                                {{ friendlier_date($row->effective_dateest) }}
+                            </a>
+                        </td>
+                        <td>{{$row->client->displayName()}}</td>
+                        <td>
+                            @foreach($row->reasons as $reason)
+                                <span class="pr-2">{{$reason->code}}</span>
+                            @endforeach
+                            @if(!$row->reasons || !count($row->reasons))
+                                -
+                            @endif
+                        </td>
+                        <td>
+                            {{$row->overallStatus()}}
+                        </td>
+                    </tr>
+                @endforeach
+                </tbody>
+            </table>
+        </div>
+    </div>
+</div>

+ 20 - 0
resources/views/app/patient/note/dashboard.blade.php

@@ -355,6 +355,26 @@
             </div>
             @endif
 
+
+            @if($note->is_signed_by_hcp)
+                @php 
+                    $suggestionMode = request()->get('suggestion_mode');
+                @endphp 
+                @if($suggestionMode == 'on')
+                    <a class="ml-3 native font-weight-normal refresh-segment c-pointer screen-only"
+                        href="/patients/view/{{$note->client->uid}}/notes/view/{{$note->uid}}?suggestion_mode=off"
+                        title="Update with latest patient data">
+                        Toggle Suggestion Mode Off
+                    </a>
+                @else 
+                    <a class="ml-3 native font-weight-normal refresh-segment c-pointer screen-only"
+                        href="/patients/view/{{$note->client->uid}}/notes/view/{{$note->uid}}?suggestion_mode=on"
+                        title="Update with latest patient data">
+                        Turn Suggestion Mode On
+                    </a>
+                @endif
+            @endif
+
             <div class="ml-auto d-flex align-items-start">
                 <div class="">
                     <div>

+ 10 - 1
resources/views/app/patient/note/note-segment-list-rhs.blade.php

@@ -3,6 +3,9 @@
     $previousHeading = null;
     $previousSubHeading = null;
 	$rhsSegments = config('app.note_rhs_segments');
+
+    $suggestionModeOn = request()->get('suggestion_mode') == 'on' && $note->is_signed_by_hcp 
+
     ?>
     @foreach($rhsSegments as $segmentIName)
 		<?php $segment = $note->getSegmentByInternalName($segmentIName); ?>
@@ -25,7 +28,13 @@
 			$previousHeading = $segment->heading;
 		}
 		?>
-        <div>@include('app.patient.note.segment')</div>
+        <div>
+			@if($suggestionModeOn)
+				@include('app.patient.note.segment.suggestions_and_updates')
+			@else 
+				@include('app.patient.note.segment')
+			@endif
+		</div>
         @endif
     @endforeach
     <?php

+ 13 - 2
resources/views/app/patient/note/note-segment-list.blade.php

@@ -1,3 +1,6 @@
+<?php  
+    $suggestionModeOn = request()->get('suggestion_mode') == 'on' && $note->is_signed_by_hcp 
+?> 
 <div class="segments-list" id="note-segments-list">
     <?php
     $previousHeading = null;
@@ -25,12 +28,20 @@
         ?>
 		@if($note->visitTemplate->internal_name !== 'soap_visit')
 			<div class="{{$segment->segmentTemplate->internal_name === 'medrisk_vigilence' ? 'd-none' : ''}}">
-				@include('app.patient.note.segment')
+                @if($suggestionModeOn)
+                    @include('app.patient.note.segment.suggestions_and_updates')
+                @else 
+                    @include('app.patient.note.segment')
+                @endif
 			</div>
 		@else
 			@if(in_array($segment->segmentTemplate->internal_name, config('app.note_lhs_segments')))
 				<div>
-					@include('app.patient.note.segment')
+                    @if($suggestionModeOn)
+                        @include('app.patient.note.segment.suggestions_and_updates')
+                    @else 
+                        @include('app.patient.note.segment')
+                    @endif
 				</div>
 			@endif
 		@endif

+ 7 - 1
resources/views/app/patient/note/segment.blade.php

@@ -62,6 +62,7 @@
                 <i class="fa fa-sync"></i>
             </a>
 
+           
             <!-- if intake - link to plan segment-->
             <?php
             $isIntake = strpos($iName, 'intake_') === 0;
@@ -101,9 +102,14 @@
     <?php if(!$isLSSegment): ?>
 
     <div class="d-none if-not-edit inset-comment summary-container {{$iName === 'medrisk_vigilence' ? 'px-0' : 'p-2 pl-4'}}">
-        {!! $segment->summary_html !!}
+        @if($note->is_signed_by_hcp && $segment->accepted_suggestion_summary_html)
+            {!! $segment->accepted_suggestion_summary_html !!}
+        @else 
+            {!! $segment->summary_html !!}
+        @endif 
     </div>
 
+
     <?php
     $wizardPowered = [
         'intake_medications',

+ 107 - 0
resources/views/app/patient/note/segment/suggestions_and_updates.blade.php

@@ -0,0 +1,107 @@
+
+<?php $iName = $segment->segmentTemplate->internal_name; ?>
+<?php $isLSSegment = strpos($iName, 'lifestyle_') === 0; ?>
+<div class="ml-2">
+    @if($iName === 'medrisk_vigilence')
+        <div class="font-weight-bold text-center flex-grow-1">
+            <div class="on-hover-hide font-weight-normal text-info font-weight-bold text-center pt-2 font-size-11">MRV</div>
+            <span class="on-hover-only text-left">MedRisk Vigilence</span>
+        </div>
+    @else
+        <span class="font-weight-bold d-flex align-items-center {{$isLSSegment || $iName === 'medrisk_vigilence' ? '' : 'xxxmb-2'}}" style="">
+            <span style="color: black; text-decoration: underline; font-size: 13px;">
+    @if($isLSSegment && $iName === 'lifestyle_general')
+                Lifestyle
+            @else
+                {{$segment->display_title}}
+            @endif
+    </span>
+            @if($segment->heading && $iName !== 'medrisk_vigilence')
+                <span class="text-secondary ml-2 text-sm font-weight-normal">({{$segment->heading}})</span>
+            @endif
+        </span>
+    @endif
+
+    @if($isLSSegment)
+        @if($iName === 'lifestyle_general')
+            <a href="#" class="ls-segment-trigger ml-2" data-target="lifestyle_general">General</a>
+            <span class="mx-2 text-secondary text-sm">|</span>
+            <a href="#" class="ls-segment-trigger" data-target="lifestyle_nutrition">Nutrition</a>
+            <span class="mx-2 text-secondary text-sm">|</span>
+            <a href="#" class="ls-segment-trigger" data-target="lifestyle_physical_activity">Physical Act.</a>
+            <span class="mx-2 text-secondary text-sm">|</span>
+            <a href="#" class="ls-segment-trigger" data-target="lifestyle_sleep">Sleep</a>
+            <span class="mx-2 text-secondary text-sm">|</span>
+            <a href="#" class="ls-segment-trigger" data-target="lifestyle_social">Social Relns.</a>
+            <span class="mx-2 text-secondary text-sm">|</span>
+            <a href="#" class="ls-segment-trigger" data-target="lifestyle_substances">Subst. Use</a>
+            <span class="mx-2 text-secondary text-sm">|</span>
+            <a href="#" class="ls-segment-trigger" data-target="lifestyle_stress">Stress</a>
+        @else
+            <span class="text-info ml-auto font-weight-normal">(click to view)</span>
+        @endif
+    @endif
+</div>
+@if($segment->proposedSegmentSummarySuggestion)
+    <div class=" m-2 p-2">
+        {!! $segment->proposedSegmentSummarySuggestion->summary_html !!}
+        <div class="d-flex">
+            @if($note->hcp_pro_id == $performer->pro_id)
+            <div class="d-block mt-1 mr-2" moe>
+                <form url="/api/segment/acceptProposedSegmentSummarySuggestion" show>
+                    <input type="hidden" name="uid" value="{{$segment->uid}}">
+                    <div class="mb-0">
+                        <button class="btn btn-primary btn-sm" submit>Accept</button>
+                    </div>
+                </form>
+            </div>
+            <div class="d-block mt-1  mr-2" moe>
+                <form url="/api/segment/rejectProposedSegmentSummarySuggestion" show>
+                    <input type="hidden" name="uid" value="{{$segment->uid}}">
+                    <div class="mb-0">
+                        <button class="btn btn-primary btn-sm" submit>Reject</button>
+                    </div>
+                </form>
+            </div>
+            @endif
+
+            <div class="d-block mt-1" moe>
+                <a class="btn btn-outline-primary btn-sm " start>Override proposed suggestion</a>
+                <form url="/api/segment/overrideProposedSegmentSummarySuggestion">
+                    <input type="hidden" name="uid" value="{{$segment->uid}}">
+                    <textarea name="proposedSuggestedSummaryHtml" class="form-control" rte>{!! $segment->proposedSegmentSummarySuggestion->summary_html !!}</textarea>
+                    <div class="mb-0">
+                        <button class="btn btn-primary btn-sm" submit>Submit</button>
+                        <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+@else
+    <div class=" ml-2 border m-2 p-2">
+        @if($segment->accepted_suggestion_summary_html)
+            {!! $segment->accepted_suggestion_summary_html !!}
+        @else 
+            {!! $segment->summary_html !!}
+        @endif 
+        <hr>
+        <div class="d-block mt-1" moe>
+            <a href="" start>Propose suggestion</a>
+            <form url="/api/segment/proposeSegmentSummarySuggestion">
+                <input type="hidden" name="uid" value="{{$segment->uid}}">
+                <textarea name="proposedSuggestedSummaryHtml" rte>
+                    @if($segment->accepted_suggestion_summary_html)
+                        {!! $segment->accepted_suggestion_summary_html !!}
+                    @else 
+                        {!! $segment->getRecalculatedHtml($performer)['summaryHtml'] !!}
+                    @endif 
+                </textarea>
+                <div class="mb-0 mt-2">
+                    <button class="btn btn-primary btn-sm" submit>Submit</button>
+                    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                </div>
+            </form>
+        </div>
+    </div>
+@endif

+ 2 - 0
routes/web.php

@@ -91,6 +91,7 @@ Route::middleware('pro.auth')->group(function () {
 
         Route::get('new-patients-awaiting-visit', 'McpController@new_patients_awaiting_visit')->name('new_patients_awaiting_visit');
         Route::get('notes-pending-signature', 'McpController@notes_pending_signature')->name('notes_pending_signature');
+        Route::get('notes-pending-summary-suggestion', 'McpController@notes_pending_summary_suggestion')->name('notes_pending_summary_suggestion');
         Route::get('notes-pending-billing', 'McpController@notes_pending_billing')->name('notes_pending_billing');
         Route::get('bills-pending-signature', 'McpController@bills_pending_signature')->name('bills_pending_signature');
         Route::get('reports-pending-signature', 'McpController@reports_pending_signature')->name('reports_pending_signature');
@@ -194,6 +195,7 @@ Route::middleware('pro.auth')->group(function () {
 
         Route::get('patients', 'AdminController@patients')->name('patients');
         Route::get('notes', 'AdminController@notes')->name('notes');
+        Route::get('notes-pending-summary-suggestion', 'AdminController@notes_pending_summary_suggestion')->name('notes_pending_summary_suggestion');
         Route::get('appointments', 'AdminController@appointments')->name('appointments');
         Route::get('bills', 'AdminController@bills')->name('bills');
         Route::get('erx-and-orders', 'AdminController@erx_and_orders')->name('erx_and_orders');