Explorar o código

Include optional client id in non-note generic bills where applicable

Vijayakrishnan %!s(int64=3) %!d(string=hai) anos
pai
achega
b0bd93698d
Modificáronse 1 ficheiros con 12 adicións e 1 borrados
  1. 12 1
      app/Http/Controllers/HomeController.php

+ 12 - 1
app/Http/Controllers/HomeController.php

@@ -1038,6 +1038,17 @@ WHERE measurement.label NOT IN ('SBP', 'DBP')
     }
 
     public function genericBill(Request $request, $entityType, $entityUid) {
-        return view('app.generic-bills.inline', ['class' => 'p-3 border-top mt-3', 'entityType' => $entityType, 'entityUid' => $entityUid]);
+        $patient = null;
+        if ($entityType && $entityUid) {
+            try {
+                $entityClass = "\\App\\Models\\" . $entityType;
+                $entity = $entityClass::where('uid', $entityUid)->first();
+                if ($entity->client) {
+                    $patient = $entity->client;
+                }
+            } catch (\Exception $e) {
+            }
+        }
+        return view('app.generic-bills.inline', ['class' => 'p-3 border-top mt-3', 'entityType' => $entityType, 'entityUid' => $entityUid, 'patient' => $patient]);
     }
 }