Jelajahi Sumber

Tests records

Samson Mutunga 1 tahun lalu
induk
melakukan
e53b1e3319

+ 21 - 0
app/Models/StoreOrder.php

@@ -5,6 +5,7 @@ namespace App\Models;
 use Illuminate\Database\Eloquent\Factories\HasFactory;
 use Illuminate\Database\Eloquent\Model;
 use App\Models\BaseModel;
+use Illuminate\Support\Arr;
 
 class StoreOrder extends BaseModel
 {
@@ -42,6 +43,26 @@ class StoreOrder extends BaseModel
         return (array) @$selectedOptions->tests;
     }
 
+    public function testsRequested(){
+        $tests = $this->tests();
+        $data = [];
+        foreach($tests as $key=>$value){
+            if($value){
+                array_push($data, $key);
+            }
+        }
+        return $data;
+    }
+
+    public function testsRequestedInHumanReadable(){
+        $data = [];
+        $tests = $this->testsRequested();
+        foreach($tests as $test){
+            array_push($data, config('constants.tests.'.$test));
+        }
+        return $data;
+    }
+
 
     public function total(){
         $detail = json_decode($this->detail_json);

+ 16 - 0
config/constants.php

@@ -13,6 +13,22 @@ return [
       'clientUrl' => 'https://letsbesafe.com'
     ],
 
+    'tests' => [
+      'check_10_test_panel_with_early_rna' => '10 Test Panel With Early RNA',
+      'check_10_test_panel' => '10 Test Panel',
+      'check_hsv_1' => 'Herpes 1',
+      'check_hsv_2' => 'Herpes 2',
+      'check_chlamydia' => 'Chlamydia',
+      'check_gonorrhea' => 'Gonorrhea',
+      'check_chlamydia_gonorrhea' => 'Chlamydia + Gonorrhea',
+      'check_syphillis' => 'Syphilis',
+      'check_hepatitis_a' => 'Hepatitis A',
+      'check_hepatitis_b' => 'Hepatitis B',
+      'check_hepatitis_c' => 'Hepatitis C',
+      'check_hiv_antibody' => 'HIV-1 + HIV-2',
+      'check_hiv_rna' => 'HIV RNA Early Detection'
+    ],
+
     'countries' => [
         "AF" => "Afghanistan",
         "AL" => "Albania",

+ 12 - 0
resources/views/app/my-account/admin/orders/partials/order-tests-summary.blade.php

@@ -0,0 +1,12 @@
+<?php
+$tests = (object) $order->testsRequestedInHumanReadable();
+?>
+<table class="table table-sm table-bordered border w-100 mb-0">
+    <tbody>
+        @foreach ($tests as $test)
+            <tr>
+                <td class="w-50 w-lg-75 px-2">{{ $test }}</td>
+            </tr>
+        @endforeach
+    </tbody>
+</table>

+ 4 - 0
resources/views/app/my-account/admin/orders/partials/table.blade.php

@@ -15,6 +15,7 @@
                 <th>#</th>
                 <th>Created At</th>
                 <th>Total Amount</th>
+                <th>Orders</th>
                 <th>Trx</th>
             </tr>
         </thead>
@@ -27,6 +28,9 @@
                     </td>
                     <td class="text-nowrap">{{ friendly_date_time($order->created_at) }}</td>
                     <td>{{ displayAmount('$', $order->total()) }}</td>
+                    <td>
+                        @include('app.my-account.admin.orders.partials.order-tests-summary')
+                    </td>
                     <td class="text-nowrap">
                         <?php $finalTrx = $order->finalFinancialTransaction(); ?>
                         @if (@$finalTrx)

+ 25 - 16
resources/views/app/my-account/admin/orders/sub/dashboard.blade.php

@@ -25,19 +25,19 @@
                                 </th>
                             </tr>
 
-                            @if($order->lab())
-                            <tr>
-                                <th class="px-2" colspan="2">
-                                    <span class="text-secondary">Lab:</span>
-                                    <?= $order->lab()->name ?>
-                                </th>
-                            </tr>
-                            <tr>
-                                <th class="px-2" colspan="2">
-                                    <span class="text-secondary">Lab Address:</span>
-                                    <?= $order->lab()->address() ?>
-                                </th>
-                            </tr>
+                            @if ($order->lab())
+                                <tr>
+                                    <th class="px-2" colspan="2">
+                                        <span class="text-secondary">Lab:</span>
+                                        <?= $order->lab()->name ?>
+                                    </th>
+                                </tr>
+                                <tr>
+                                    <th class="px-2" colspan="2">
+                                        <span class="text-secondary">Lab Address:</span>
+                                        <?= $order->lab()->address() ?>
+                                    </th>
+                                </tr>
                             @endif
                             <tr>
                                 <th class="px-2" colspan="2">
@@ -54,16 +54,25 @@
             <div class="card">
                 <div class="card-header">
                     <div class="d-flex align-items-center justify-content-between">
-                        <h5 class="mb-0 fw-bold">Tests</h5>
+                        <h5 class="mb-0 fw-bold">Tests Requested</h5>
                     </div>
                 </div>
                 <div class="card-body">
                     <div>
                         <?php
-                        $tests = $order->tests();
-                        parseRender($tests);
+                        $tests = (object) $order->testsRequestedInHumanReadable();
                         ?>
+
                     </div>
+                    <table class="table table-sm table-bordered border w-100 mb-0">
+                        <tbody>
+                            @foreach ($tests as $test)
+                                <tr>
+                                    <td class="w-50 w-lg-75 px-2">{{ $test }}</td>
+                                </tr>
+                            @endforeach
+                        </tbody>
+                    </table>
                 </div>
             </div>
         </div>

+ 4 - 0
resources/views/app/my-account/admin/users/sub/orders.blade.php

@@ -10,6 +10,7 @@
                         <th>IID</th>
                         <th>Created At</th>
                         <th>Total Amount</th>
+                        <th>Tests</th>
                         <th>Trx</th>
                     </tr>
                 </thead>
@@ -20,6 +21,9 @@
                             </td>
                             <td>{{ friendly_date($order->created_at) }}</td>
                             <td>{{ displayAmount('$', $order->total()) }}</td>
+                            <td>
+                                @include('app.my-account.admin.orders.partials.order-tests-summary')
+                            </td>
                             <td>
                                 <div>
                                     @include('app.my-account.admin.orders.forms.create-charge')