Samson Mutunga 6 miesięcy temu
rodzic
commit
b671b9856e

+ 48 - 0
app/Helpers.php

@@ -303,4 +303,52 @@ function getTestDisplayName($key){
 
     return toHumanReadable($key);
 }
+
+function getAllTests(){
+    return (array) config('constants.lbs_tests');
+}
+
+function getTest($testKey) {
+    return @getAllTests()[$testKey];
+}
+
+function getTestLabelByKey( $testKey ) {
+    $label = getTestLabel(getTest($testKey));
+    if($label) return $label;
+    return toHumanReadable($testKey);
+}
+
+function getTestLabel( $test ) {
+    return @$test[ 'label' ];
+}
+
+function getTestPrice( $testKey ) {
+    return floatval( config( 'app.'.$testKey ) );
+}
+
+if ( !function_exists( 'get_lab_station_summary2' ) ) {
+    function get_lab_station_summary2( $lab ) {
+        $states = config( 'constants.states' );
+
+        $data  = json_decode( $lab->data );
+
+        return [
+            'id' => @$data->id,
+            'city' => @$data->city,
+            'distance' => '', //todo use zips table to get distance between zips
+            'fax_number' => @$data->fax_number,
+            'lab_title' => @$data->title,
+            'latitude' => @$data->latitude,
+            'longitude' => @$data->longitude,
+            'phone_number' => @$data->phone_number,
+            'postcode' => @$data->zip_code,
+            'state' => @$data->state,
+            'street' => @$data->address,
+            // 'services' => json_decode( $lab->services ),
+            'hrs_of_operation' => @$data->opening_hours,
+            'show_hrs_of_operation' => false,
+            'augmented' => @$data->augmented
+        ];
+    }
+}
 ?>

+ 19 - 5
app/Http/Controllers/AdminController.php

@@ -20,6 +20,7 @@ use OpenTok\OpenTok;
 use Illuminate\Support\Facades\Storage;
 use Exception;
 use Ramsey\Uuid\Uuid;
+use App\Models\Lab2;
 
 class AdminController extends Controller
 {
@@ -368,26 +369,39 @@ class AdminController extends Controller
 
     public function orderCreate(Request $request){
         $userUid = $request->get('userUid');
-        $allTests = config('constants.tests');
         $selectedTests = $request->get('tests', []);
         if(!count($selectedTests)){
             return $this->fail('Please select a test!');
         }
         $tests = [];
-        foreach($allTests as $key=>$title){
-            $tests[$key] = in_array($key, $selectedTests) ? 1 : 0;
+        $total = 0;
+        foreach($selectedTests as $index=>$key){
+            $tests[$key] = getTestPrice($key);
+            $total = $total + floatval($tests[$key]);
         }
         $data = [
             'tests' => $tests,
-            'tests_total' => $request->get('total'),
+            'tests_total' => $total,
             'tests_lab_id' => $request->get('tests_lab_id')
         ];
 
+        $selectedLabId = $data['tests_lab_id'];
+
+        $labDetails = null;
+        if ($selectedLabId) {
+            $lab = Lab2::whereRaw("data->>'id' = '" . $selectedLabId . "'")->first();
+            if ($lab) {
+                $labDetails = get_lab_station_summary2($lab);
+            }
+        }
+
+        $data['lab'] = $labDetails;
+
         $detailJson = [
             'selected_options' => json_encode($data)
         ];
 
-        $javaResponse = $this->callJava('/api/customerStore/submitOrderAsAdmin', ['userUid' => $userUid, 'detailJson' => json_encode($detailJson)], $this->sessionKey);
+        $javaResponse = $this->callJava('/api/customerStore/submitOrderAsAdmin', ['userUid' => $userUid, 'detailJson' => json_encode($detailJson), 'orderTotal' => $total], $this->sessionKey);
         if (!@$javaResponse['success']) {
             return $this->fail($javaResponse['message']);
         }

+ 45 - 0
app/Models/Lab2.php

@@ -0,0 +1,45 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+use App\Models\BaseModel;
+
+class Lab2 extends BaseModel
+{
+    use HasFactory;
+
+    protected $table = 'labs2';
+
+    public function address($short = false){
+        $data = json_decode($this->data);
+       
+        $labAddress = [];
+        $labAddressShort = [];
+
+        if($data->address2) {
+            $labAddress[] = $data->address2;
+        }
+
+        if($data->city) {
+            $labAddress[] = '<br>' . $data->city;
+            $labAddressShort[] = $data->city;
+        }
+        if($data->state) {
+            $labAddress[] = ' ' . $data->state . ', ';
+            $labAddressShort[] = $data->state;
+        }
+        if($data->zip_code) {
+            $labAddress[] = ' ' . $data->zip_code;
+            $labAddressShort[] = $data->zip_code;
+        }
+        $labAddress = implode('', $labAddress);
+        $labAddressShort = implode(' ', $labAddressShort);
+        if($short) return $labAddressShort;
+        return $labAddress;
+    }
+    public function labData(){
+        return json_decode($this->data);
+    }
+}

+ 4 - 2
app/Models/StoreOrder.php

@@ -86,8 +86,9 @@ class StoreOrder extends BaseModel
     public function testsRequestedInHumanReadable(){
         $data = [];
         $tests = $this->testsRequested();
+        $allTests = getAllTests();
         foreach($tests as $test){
-            $testName = config('constants.tests.'.$test);
+            $testName = @$allTests[$test]['label'];
             $testPrice = displayAmount('$', config('app.'.$test));
             $string = $testName . ' - '.$testPrice;
             array_push($data, $string);
@@ -99,8 +100,9 @@ class StoreOrder extends BaseModel
         $data = [];
         $tests = $this->partnerTestsRequested();
         $discount = $this->getPartnerTestDiscount();
+        $allTests = getAllTests();
         foreach($tests as $test){
-            $testName = config('constants.tests.'.$test);
+            $testName = $allTests[$test]['label'];
             $testPrice = floatval(config('app.'.$test));
             $testCost = $testPrice - $discount;
             $string = $testName . ' - '. displayAmount('$', $testCost);

+ 22 - 16
config/app.php

@@ -38,22 +38,28 @@ return [
     'opentokApiSecret' => env('OPENTOK_API_SECRET'),
     'opentokSessionId' => env('OPENTOK_SESSION_ID'),
 
-    'check_10_test_panel_with_early_rna' => env('check_10_test_panel_with_early_rna'),
-    'check_10_test_panel' => env('check_10_test_panel'),
-    'check_hsv_1' => env('check_hsv_1'),
-    'check_hsv_2' => env('check_hsv_2'),
-    'check_chlamydia' => env('check_chlamydia'),
-    'check_gonorrhea' => env('check_gonorrhea'),
-    'check_chlamydia_gonorrhea' => env('check_chlamydia_gonorrhea'),
-    'check_syphillis' => env('check_syphillis'),
-    'check_hepatitis_a' => env('check_hepatitis_a'),
-    'check_hepatitis_b' => env('check_hepatitis_b'),
-    'check_hepatitis_c' => env('check_hepatitis_c'),
-    'check_hiv_antibody' => env('check_hiv_antibody'),
-    'check_hiv_rna' => env('check_hiv_rna'),
-    'check_trichomoniasis' => env('check_trichomoniasis'),
-    'check_doxy_pep' => env('check_doxy_pep'),
-    'check_trichomoniasis_test_and_comprehensive_wellness_with_urinalysis' => env('check_trichomoniasis_test_and_comprehensive_wellness_with_urinalysis'),
+    'HSV_1'=> env('HSV_1'),
+    'HSV_2'=> env('HSV_2'),
+    'HSV_1_2_PANEL'=> env('HSV_1_2_PANEL'),
+    'HIV_1_2'=> env('HIV_1_2'),
+    'HEP_A'=> env('HEP_A'),
+    'HEP_B'=> env('HEP_B'),
+    'HEP_C'=> env('HEP_C'),
+    'GEN_CHL'=> env('GEN_CHL'),
+    'GEN_GON'=> env('GEN_GON'),
+    'GEN_CHL_GON'=> env('GEN_CHL_GON'),
+    'ORAL_CHL_GON'=> env('ORAL_CHL_GON'),
+    'CHL_GON_PANEL'=> env('CHL_GON_PANEL'),
+    'SYPH'=> env('SYPH'),
+    'HIV_RNA'=> env('HIV_RNA'),
+    '12TP'=> env('12TP'),
+    '12TP_WITH_HIV_RNA'=> env('12TP_WITH_HIV_RNA'),
+    'UA'=> env('UA'),
+    'TRICH_MALE'=> env('TRICH_MALE'),
+    'TRICH_MALE_WITH_URINALYSIS'=> env('TRICH_MALE_WITH_URINALYSIS'),
+    'TRICH_FEMALE'=> env('TRICH_FEMALE'),
+    'TRICH_FEMALE_WITH_URINALYSIS'=> env('TRICH_FEMALE_WITH_URINALYSIS'),
+    'MYCO_GEN'=> env('MYCO_GEN'),
 
     /*
     |--------------------------------------------------------------------------

+ 5 - 22
resources/views/app/my-account/admin/orders/forms/create-order.blade.php

@@ -1,12 +1,5 @@
 <?php
-    $tests = config('constants.tests');
-    $packages = array_filter(
-        $tests,
-        function ($value){
-            return(strpos($value,'Test Panel') !== false);
-        }
-    );
-    $individualTests = array_diff($tests, $packages);
+    $tests = getAllTests();
 ?>
 <div moe normal>
     <a start show href="#" class="text-primary">+ Create Order</a>
@@ -17,21 +10,11 @@
             <div id="createOrder" v-cloak>
                 <input type="hidden" name="total" v-model="form.total" />
                 <input type="hidden" name="userUid" value="{{$user->uid}}" />
-                <div class="form-group mb-3">
-                    <label class="me-3"><input type="radio" name="testType" value="11PanelTest" v-model="form.testType" required /> Comprehensive 11-Panel Test</label>
-                    <label><input type="radio" name="testType" value="individualTests" v-model="form.testType" required /> Individual Tests</label>
-                </div>
-                <div v-if="form.testType === '11PanelTest'" class="px-3">
-                    <div class="d-flex flex-column">
-                        @foreach($packages as $key=>$title)
-                            <label><input type="radio" name="tests[]" value="{{ $key }}" data-amount="{{ config('app.'.$key) }}" required /> {{ $title }} - {{ displayAmount('$', config('app.'.$key)) }}</label>
-                        @endforeach
-                    </div>
-                </div>
-                <div v-if="form.testType === 'individualTests'" class="px-3">
+
+                <div class="px-3">
                     <div class="d-flex flex-column">
-                        @foreach($individualTests as $k=>$t)
-                            <label><input type="checkbox" name="tests[]" value="{{ $k }}" data-amount="{{  config('app.'.$k) }}" /> {{ $t }} - {{ displayAmount('$', config('app.'.$k)) }}</label>
+                        @foreach($tests as $k=>$t)
+                            <label><input type="checkbox" name="tests[]" value="{{ $k }}" data-amount="{{  config('app.'.$k) }}" /> {{ @$t['label'] ?? @$t['page_title'] }} - {{ displayAmount('$', floatval(config('app.'.$k))) }}</label>
                         @endforeach
                     </div>
                 </div>

+ 1 - 19
resources/views/app/my-account/admin/orders/partials/table.blade.php

@@ -26,7 +26,6 @@
                 <th>Name</th>
                 <th class="text-nowrap">Created At</th>
                 <th class="text-nowrap">Total Amount</th>
-                <th>Orders</th>
                 <th>Lab</th>
                 <th>Lab Request</th>
                 <th>Trx</th>
@@ -53,24 +52,7 @@
                     <td class="text-nowrap" style="width:1px">{{ $order->user->full_name }}</td>
                     <td class="text-nowrap" style="width:1px">{{ friendly_date_time($order->created_at) }}</td>
                     <td style="width:1px">{{ displayAmount('$', $order->total()) }}</td>
-                    <td style="width:550px">
-                      @foreach($order->testsRequested() as  $tkey => $test)
-                       <small>{{ config('constants.tests.'.$test) }}</small>@if(count($order->associatedOrders($order->id)) || count($order->testsRequested()) -1 !== $tkey),@endif
-                       @endforeach
-                       {{-- Associated Orders --}}
-                       @foreach($order->associatedOrders($order->id) as $tOrder => $assocOrder)
-                         <?php $orderTotal = $orderTotal + $assocOrder->order_total; ?>
-                         @foreach($assocOrder->testsRequested() as  $tkey => $test)
-                         <small>{{ config('constants.tests.'.$test) }}<small>@if(count($order->associatedOrders($order->id)) -1 !== $tOrder),@endif
-                         @endforeach
-                       @endforeach
-                       @if(@$storeOrderSelectedOptions->partner == 1)
-                       <p class="mt-2 mb-0"><b style="font-family:sans-serif">Partner: {{@$storeOrderSelectedOptions->partner_email}}</b></p>
-                       @endif
-                        @if(@$results_attachment)
-                        <p class="mt-2 p-1 bg-light border text-sm"><b>Lab Report: <a class="ms-2 text-success" href="{{ $results_attachment['attachmentAccessTokenUrl'] }}" target="_blank"><i class="fal fa-file-pdf"></i> Download PDF</a></b></p>
-                        @endif
-                    </td>
+                    
                     <td>
                         @if($selectedLab)
                             <?= selected_lab_html_address($selectedLab); ?>