Ver Fonte

erx - pull meds from page (category: canvas, key: erx, and matching client id)

Vijayakrishnan há 3 anos atrás
pai
commit
9190133f9c
2 ficheiros alterados com 20 adições e 6 exclusões
  1. 8 0
      app/Models/Client.php
  2. 12 6
      resources/views/app/patient/tickets.blade.php

+ 8 - 0
app/Models/Client.php

@@ -554,4 +554,12 @@ class Client extends Model
             ->get();
     }
 
+    public function firstPageByCategoryAndKey($_category, $_key) {
+        return Page
+            ::where('client_id', $this->id)
+            ->where('category', $_category)
+            ->where('key', $_key)
+            ->first();
+    }
+
 }

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

@@ -191,16 +191,22 @@
                         <?php } ?>
 
                         <?php
-                            $contentData = false;
-                            if ($patient->canvas_data) {
-                                $canvasData = json_decode($patient->canvas_data, true);
-                                if (isset($canvasData['rx'])) {
-                                    $contentData = $canvasData['rx'];
+                            $contentData = $patient->firstPageByCategoryAndKey('CANVAS', 'rx');
+                            if ($contentData) {
+                                $contentData = json_decode($contentData);
+                                if($contentData && $contentData->data) {
+                                    $contentData = json_decode($contentData->data);
                                 }
+                                else {
+                                    $contentData = false;
+                                }
+                            }
+                            else {
+                                $contentData = false;
                             }
                         ?>
 
-                        patientRx: <?= $contentData ? json_encode($contentData['items']) : '[]' ?>,
+                        patientRx: <?= $contentData ? json_encode($contentData->items) : '[]' ?>,
                     },
                     computed: {
                         numAll: function() {