Browse Source

Note single > tickets > Ability to add

Vijayakrishnan 4 năm trước cách đây
mục cha
commit
e3bd8229d0

+ 11 - 4
app/Http/Controllers/NoteController.php

@@ -34,14 +34,21 @@ class NoteController extends Controller
 
         $allyPros = Pro::all(); //TODO: paginate, use select2
 
-        // load today's tickets for patient
-        $ticketsToday = Ticket::where('client_id', $patient->id)
+        // load tickets created on note->effective_date for patient
+        $ticketsOnNoteEffectiveDate = Ticket::where('client_id', $patient->id)
             ->where('is_entry_error', false)
-            ->whereRaw('DATE(created_at) = ?', [date('Y-m-d')])
+            ->whereRaw('DATE(created_at) = DATE(?)', [$note->effective_dateest])
+            ->get();
+
+        // other open tickets as of today
+        $otherOpenTickets = Ticket::where('client_id', $patient->id)
+            ->where('is_entry_error', false)
+            ->where('is_open', true)
+            ->whereRaw('DATE(created_at) <> DATE(?)', [$note->effective_dateest])
             ->get();
 
         return view('app.patient.note.dashboard', compact('patient', 'note',
-            'allyPros', 'allSections', 'ticketsToday'));
+            'allyPros', 'allSections', 'ticketsOnNoteEffectiveDate', 'otherOpenTickets'));
     }
 
     public function renderNote($noteUid, Request $request)

+ 8 - 1
app/Http/Controllers/PatientController.php

@@ -342,9 +342,16 @@ class PatientController extends Controller
         return view('app.patient.vitals-graph', compact('patient', 'pros', 'filter'));
     }
 
-    public function tickets(Request $request, Client $patient, $type = '', Ticket $currentTicket = null) {
+    public function tickets(Request $request, Client $patient, $type = '', String $currentTicket = '') {
         $pros = $this->pros;
         $allPros = Pro::all();
+        $qlTicket = $currentTicket;
+        if(!!$currentTicket) {
+            $qlTicket = Ticket::where('uid', $currentTicket)->first();
+            if($qlTicket) {
+                $currentTicket = $qlTicket;
+            }
+        }
         return view('app.patient.tickets', compact('patient', 'pros', 'allPros', 'type', 'currentTicket'));
     }
 

+ 141 - 4
resources/views/app/patient/note/dashboard.blade.php

@@ -358,10 +358,32 @@
                 <div class="p-3 border-bottom">
                     <div class="">
                         <div class="d-flex align-items-center mb-2">
-                            <p class="font-weight-bold text-secondary m-0 mr-2">ERx/Orders Summary - {{date('m/d/Y')}}</p>
+                            <p class="font-weight-bold text-secondary m-0 font-size-14">ERx/Orders Summary</p>
+                            <span class="mx-2 text-secondary">|</span>
+                            <a href="/patients/view/{{$patient->uid}}/tickets/erx/create?popupmode=1"
+                               native target="_blank"
+                               class="ticket-popup-trigger note-dashboard-action d-block text-nowrap font-weight-bold">
+                                + ERx
+                            </a>
+                            <span class="mx-2 text-secondary">|</span>
+                            <a href="/patients/view/{{$patient->uid}}/tickets/lab/create?popupmode=1"
+                               native target="_blank"
+                               class="ticket-popup-trigger note-dashboard-action d-block text-nowrap font-weight-bold">
+                                + Lab
+                            </a>
+                            <span class="mx-2 text-secondary">|</span>
+                            <a href="/patients/view/{{$patient->uid}}/tickets/imaging/create?popupmode=1"
+                               native target="_blank"
+                               class="ticket-popup-trigger note-dashboard-action d-block text-nowrap font-weight-bold">
+                                + Imaging
+                            </a>
                         </div>
+
+                        <hr class="my-2">
+
+                        <p class="font-weight-bold text-secondary mb-2 mr-2">Ordered on {{friendlier_date($note->effective_dateest)}} <span class="font-weight-normal">(note's effective date)</span></p>
                         <div>
-                            @if($ticketsToday && count($ticketsToday))
+                            @if($ticketsOnNoteEffectiveDate && count($ticketsOnNoteEffectiveDate))
                                 <table class="table table-sm table-bordered mb-0">
                                 <thead>
                                 <tr class="bg-light">
@@ -374,7 +396,7 @@
                                 </tr>
                                 </thead>
                                 <tbody>
-                                @foreach($ticketsToday as $ticket)
+                                @foreach($ticketsOnNoteEffectiveDate as $ticket)
                                     <?php $data = json_decode($ticket->data); ?>
                                     @if($ticket->category === 'erx' || $ticket->category === 'lab' || $ticket->category === 'imaging')
                                     <tr class="{{$ticket->is_open ? '' : 'bg-light on-hover-opaque'}}">
@@ -468,11 +490,126 @@
                                     @endif
                                 @endforeach
                                 </tbody>
-                            </table>
+                                </table>
                             @else
                                 <div class="text-secondary">None</div>
                             @endif
                         </div>
+
+                        <hr class="my-2">
+
+                        <p class="font-weight-bold text-secondary mb-2 mr-2 mt-3">Others open as of {{friendlier_date(date('Y-m-d'))}}</p>
+                        @if($otherOpenTickets && count($otherOpenTickets))
+                            <table class="table table-sm table-bordered mb-0">
+                                <thead>
+                                <tr class="bg-light">
+                                    <th class="px-2 text-secondary border-bottom-0 width-30px">Created</th>
+                                    <th class="px-2 text-secondary border-bottom-0 width-30px">Type</th>
+                                    <th class="px-2 text-secondary border-bottom-0 width-30px">Pro</th>
+                                    <th class="px-2 text-secondary border-bottom-0 width-30px">View</th>
+                                    <th class="px-2 text-secondary border-bottom-0 width-30px">Status</th>
+                                    <th class="px-2 text-secondary border-bottom-0">Detail</th>
+                                </tr>
+                                </thead>
+                                <tbody>
+                                @foreach($otherOpenTickets as $ticket)
+                                    <?php $data = json_decode($ticket->data); ?>
+                                    @if($ticket->category === 'erx' || $ticket->category === 'lab' || $ticket->category === 'imaging')
+                                        <tr class="{{$ticket->is_open ? '' : 'bg-light on-hover-opaque'}}">
+                                            <td class="px-2 text-nowrap">
+                                                {{friendly_time($ticket->created_at)}}
+                                            </td>
+                                            <td class="px-2 text-nowrap">
+                                                {{$ticket->category}}
+                                            </td>
+                                            <td class="px-2 text-nowrap">
+                                                @if($ticket->orderingPro)
+                                                    @if($ticket->orderingPro->id !== $pro->id)
+                                                        <b>{{$ticket->orderingPro->displayName()}}</b>
+                                                    @else
+                                                        You
+                                                    @endif
+                                                @else
+                                                    -
+                                                @endif
+                                            </td>
+                                            <td class="px-2 text-nowrap">
+                                                <div class="d-flex align-items-center flex-nowrap">
+                                                    <a href="/patients/view/{{$ticket->patient->uid}}/tickets/{{$ticket->category}}/{{$ticket->uid}}?popupmode=1"
+                                                       native target="_blank"
+                                                       class="ticket-popup-trigger note-dashboard-action d-block text-nowrap mr-3">
+                                                        View
+                                                    </a>
+                                                </div>
+                                            </td>
+                                            <td class="px-2 text-nowrap">
+                                                {{$ticket->is_open ? 'Open' : 'Closed'}}
+                                            </td>
+                                            <td class="px-2">
+                                                @if($ticket->category === 'erx')
+                                                    <div class="font-size-13 mb-1">{{$data->medication}}</div>
+                                                    <div class="d-flex align-items-center flex-wrap text-secondary">
+                                                        @if($data->strength)
+                                                            <span class="d-inline-flex align-items-center">
+                                                    <span class="mx-2 text-secondary">•</span>
+                                                    <span>{{$data->strength}}</span>
+                                                </span>
+                                                        @endif
+                                                        @if($data->route)
+                                                            <span class="d-inline-flex align-items-center">
+                                                    <span class="mx-2 text-secondary">•</span>
+                                                    <span>{{$data->route}}</span>
+                                                </span>
+                                                        @endif
+                                                        @if($data->frequency)
+                                                            <span class="d-inline-flex align-items-center">
+                                                    <span class="mx-2 text-secondary">•</span>
+                                                    <span>{{$data->frequency}}</span>
+                                                </span>
+                                                        @endif
+                                                        @if($data->dispense)
+                                                            <span class="d-inline-flex align-items-center">
+                                                    <span class="mx-2 text-secondary">•</span>
+                                                    <span>Dispense:</span> {{$data->dispense}}
+                                                </span>
+                                                        @endif
+                                                        @if($data->frequency)
+                                                            <span class="d-inline-flex align-items-center">
+                                                    <span class="mx-2 text-secondary">•</span>
+                                                    <span><span>Refills:</span> {{$data->refills}}</span>
+                                                </span>
+                                                        @endif
+                                                        @if($data->dispense)
+                                                            <span class="d-inline-flex align-items-center">
+                                                    <span class="mx-2 text-secondary">•</span>
+                                                    <span><span>Purpose:</span> {{$data->purpose}}</span>
+                                                </span>
+                                                        @endif
+                                                    </div>
+                                                @endif
+                                                @if($ticket->category === 'lab' || $ticket->category === 'imaging')
+                                                    @if(@$data->tests && is_array($data->tests))
+                                                        <div>
+                                                            <span class="text-secondary">Tests:</span>
+                                                            {{implode(", ", $data->tests)}}
+                                                        </div>
+                                                    @endif
+                                                    @if(@$data->icds && is_array($data->icds))
+                                                        <div>
+                                                            <span class="text-secondary">ICDs:</span>
+                                                            {{implode(", ", $data->icds)}}
+                                                        </div>
+                                                    @endif
+                                                @endif
+                                            </td>
+                                        </tr>
+                                    @endif
+                                @endforeach
+                                </tbody>
+                            </table>
+                        @else
+                            <div class="text-secondary">None</div>
+                        @endif
                     </div>
                 </div>
 

+ 12 - 6
resources/views/app/patient/tickets.blade.php

@@ -974,12 +974,18 @@
                             }, 1000);
                         @endfor
 
-                        @if(@$currentTicket && $currentTicket->category && $currentTicket->uid)
-                            setTimeout(() => {
-                                let currentTicket = this.tickets.filter(_x => _x.uid === '{{$currentTicket->uid}}');
-                                if (currentTicket && currentTicket.length)
-                                    this['{{$currentTicket->category}}ShowPopup'](currentTicket[0]);
-                            }, 10);
+                        @if(@$currentTicket)
+                            @if($currentTicket === 'create')
+                                setTimeout(() => {
+                                    this['{{$type}}ShowPopup']();
+                                });
+                            @elseif($currentTicket->category && $currentTicket->uid)
+                                setTimeout(() => {
+                                    let currentTicket = this.tickets.filter(_x => _x.uid === '{{$currentTicket->uid}}');
+                                    if (currentTicket && currentTicket.length)
+                                        this['{{$currentTicket->category}}ShowPopup'](currentTicket[0]);
+                                }, 10);
+                            @endif
                         @endif
 
                     }