Explorar el Código

ERx - allow easy cancellation of unsigned

Vijayakrishnan hace 3 años
padre
commit
7881a38cbd

+ 4 - 0
app/Models/Client.php

@@ -99,6 +99,10 @@ class Client extends Model
     public function prescriptions()
     {
         return $this->hasMany(Erx::class, 'client_id', 'id')
+            ->where(function ($q) {
+                $q->whereNull('pro_declared_status')
+                    ->orWhere('pro_declared_status', '<>', 'CANCELLED');
+            })
             ->orderBy('created_at', 'desc')
             ->orderByRaw('note_id DESC NULLS LAST');
     }

+ 0 - 1
resources/views/app/patient/prescriptions-popup/pro-status-form.blade.php

@@ -14,7 +14,6 @@
                 <option value="SENT">Sent</option>
                 <option value="RECEIVED_BY_CLIENT">Received by client</option>
                 <option value="RECEIPT_CONFIRMED_BY_FACILITY">Receipt confirmed by facility</option>
-                <option value="CANCELLED">Cancelled</option>
             </select>
         </div>
         <div class="mb-2">

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

@@ -43,10 +43,17 @@
             <tr v-for="(prescription, index) in prescriptions" :class="currentPrescription && currentPrescription.id === prescription.id ? 'bg-aliceblue' : ''">
                 <td class="px-2">
                     <a href="#" v-on:click.prevent="currentPrescription=prescription"
-                       :class="currentPrescription && currentPrescription.id === prescription.id ? 'font-weight-bold' : ''">@{{prescription.created_at_friendly_short}}</a>
+                       class="text-nowrap"
+                       :class="currentPrescription && currentPrescription.id === prescription.id ? 'font-weight-bold' : ''">
+                        @{{prescription.created_at_friendly_short}}
+                    </a>
                     @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>
@@ -349,6 +356,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.drug-form')
@@ -553,6 +565,20 @@
                 },
                 methods: {
 
+                    cancelItem: function() {
+                        let payload = {
+                            uid: this.currentPrescription.uid,
+                            status: 'CANCELLED',
+                            memo: 'Cancelled',
+                        };
+                        $.post('/api/erx/updateProDeclaredStatus', payload, _data => {
+                            if(!hasResponseError(_data)) {
+                                closeStagPopup();
+                                fastReload();
+                            }
+                        }, 'json');
+                    },
+
                     // new eRx (only for popup-list)
                     newERx: function(_type) {
                         let payload = {

+ 0 - 1
resources/views/app/patient/prescriptions/pro-status-form.blade.php

@@ -14,7 +14,6 @@
                 <option value="SENT">Sent</option>
                 <option value="RECEIVED_BY_CLIENT">Received by client</option>
                 <option value="RECEIPT_CONFIRMED_BY_FACILITY">Receipt confirmed by facility</option>
-                <option value="CANCELLED">Cancelled</option>
             </select>
         </div>
         <div class="mb-2">