Forráskód Böngészése

Disallow erx create if there is unsigned of type in note

Vijayakrishnan 3 éve
szülő
commit
545f53ef53
1 módosított fájl, 20 hozzáadás és 0 törlés
  1. 20 0
      resources/views/app/patient/prescriptions/list.blade.php

+ 20 - 0
resources/views/app/patient/prescriptions/list.blade.php

@@ -376,6 +376,19 @@
     @include('app.patient.prescriptions.client-status-form')
     @include('app.patient.prescriptions.transmit-form')
 </div>
+<?php
+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() {
 
@@ -429,6 +442,8 @@
 
                     prescriptions: <?= json_encode($prescriptions) ?>,
 
+                    numUnsigned: <?= json_encode($uCounts) ?>,
+
                     currentPrescriptionAction: '',
                     currentPrescriptionType: '',
 
@@ -581,6 +596,11 @@
 
                     // 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}}',