Explorar o código

Erx popup updates (as in list)

Vijayakrishnan %!s(int64=3) %!d(string=hai) anos
pai
achega
08ccc7a90c

+ 44 - 1
resources/views/app/patient/prescriptions-popup/list-popup.blade.php

@@ -1,6 +1,6 @@
 <div id="prescriptions-popup-{{$patient->id}}" v-cloak class="mt-3 p-3 border-top">
     <div class="d-flex align-items-baseline pb-2">
-        <h6 class="my-0 font-weight-bold text-secondary font-size-14">Prescriptions</h6>
+        <h6 class="my-0 font-weight-bold text-secondary font-size-14">ERx &amp; Orders</h6>
         @if(!request()->input('erx_category') || request()->input('erx_category') === 'DRUG')
             <span class="mx-2 text-secondary on-hover-opaque">|</span>
             <a href="#" v-on:click.prevent="newERx('DRUG')">+ New eRx</a>
@@ -47,6 +47,10 @@
                     @if(@$note)
                         <div v-if="prescription.note_id === {{$note->id}}" class="text-info mt-1">* Create on this note</div>
                     @endif
+                    <div v-if="prescription.pro_declared_status === 'CANCELLED'" class="text-secondary font-weight-bold mt-1 text-sm d-flex align-items-baseline">
+                        <i class="fa fa-ban mr-1 text-sm"></i>
+                        CANCELLED
+                    </div>
                 </td>
                 @if(!request()->input('erx_category'))
                 <td class="px-2">@{{prescription.erx_category}}</td>
@@ -343,6 +347,11 @@
                     <a href="#" v-on:click.prevent="transmit(currentPrescription)">Transmit</a>
                 </div>
             </div>
+            <div v-if="!currentPrescription.has_hcp_pro_signed">
+                <hr class="my-2">
+                <div v-if="currentPrescription.pro_declared_status === 'CANCELLED'" class="text-secondary font-weight-bold">CANCELLED</div>
+                <a v-else href="#" class="text-danger d-block" v-on:click.prevent="cancelItem()">Cancel</a>
+            </div>
         </div>
     </div>
     @include('app.patient.prescriptions-popup.drug-form')
@@ -358,6 +367,20 @@
     @include('app.patient.prescriptions-popup.client-status-form')
     @include('app.patient.prescriptions-popup.transmit-form')
 </div>
+<?php
+$uCounts = [];
+if (@$note) {
+    $unsignedCounts = DB::select("SELECT erx_Category, count(id) FROM erx
+WHERE (has_hcp_pro_signed IS NULL OR has_hcp_pro_signed = FALSE) AND
+    note_id = {$note->id} AND
+    (pro_declared_status <> 'CANCELLED' OR pro_declared_status IS NULL)
+GROUP BY erx_category");
+    $uCounts = [];
+    foreach ($unsignedCounts as $c) {
+        $uCounts[$c->erx_category] = $c->count;
+    }
+}
+?>
 <script>
     (function() {
 
@@ -411,6 +434,8 @@
 
                     prescriptions: <?= json_encode($prescriptions) ?>,
 
+                    numUnsigned: <?= json_encode($uCounts) ?>,
+
                     currentPrescriptionAction: '',
                     currentPrescriptionType: '',
 
@@ -547,8 +572,26 @@
                 },
                 methods: {
 
+                    cancelItem: function() {
+                        let payload = {
+                            uid: this.currentPrescription.uid,
+                            status: 'CANCELLED',
+                            memo: 'Cancelled',
+                        };
+                        $.post('/api/erx/updateProDeclaredStatus', payload, _data => {
+                            if(!hasResponseError(_data)) {
+                                refreshDynamicStagPopup();
+                            }
+                        }, 'json');
+                    },
+
                     // new eRx (only for popup-list)
                     newERx: function(_type) {
+                        if(!!this.numUnsigned[_type]) {
+                            toastr.error('There is already an unsigned ERx of type ' + _type + ' in this note.');
+                            return false;
+                        }
+
                         let payload = {
                             noteUid: '{{ @$note ? $note->uid : '' }}',
                             clientUid: '{{$patient->uid}}',