Samson Mutunga 3 年 前
コミット
628c8bca33

+ 38 - 0
app/Helpers/helpers.php

@@ -916,4 +916,42 @@ if(!function_exists('format_number')) {
     function format_number($number, $places = 2) {     
         return number_format((float)$number, $places, '.', '');
     }
+}
+
+if(!function_exists('toHumanReadable')) {
+    function toHumanReadable($name) {     
+        return ucwords(preg_replace("/[^0-9a-z]/i", " ", $name));
+    }
+}
+if(!function_exists('parseRender')) {
+    function parseRender($_data) {     
+        if($_data) {
+            $type = gettype($_data);
+            if(is_string($_data) || is_numeric($_data)) {
+                echo $_data;
+            }
+            else {
+                echo "<table class='table table-sm border w-100'>";
+                foreach($_data as $k => $v) {
+                    echo "<tr>";
+                    echo "<td><b class='text-secondary'>" . toHumanReadable($k) . "</b></td>";
+                    echo "<td>";
+                    if(is_object($v)) {
+                        parseRender($v);
+                    }
+                    elseif(is_array($v)) {
+                        foreach($v as $k2 => $v2) {
+                            parseRender($v2);
+                        }
+                    }
+                    else {
+                        echo $v;
+                    }
+                    echo "</td>";
+                    echo "</tr>";
+                }
+                echo "</table>";
+            }
+        }
+    }
 }

+ 93 - 0
resources/views/app/patient/partials/coverage-information.blade.php

@@ -0,0 +1,93 @@
+<div class="mt-2 pt-2">
+    @php
+        $cpc = $coverage;
+    @endphp
+</div>
+    @if(!$cpc)
+        <div class="alert alert-info">No coverage for this client</div>
+    @else
+        <?php
+            $cpc->auto_detail_json = null;
+            $creationStrategy = $cpc->creation_strategy ?? null;
+            if($creationStrategy === 'NEW' || $creationStrategy === 'AUTO_REFRESH'){
+                if($cpc->plan_type === 'MEDICARE'){
+                   $cpc->auto_detail_json = json_decode($cpc->auto_medicare_detail_json ?? null); 
+                }
+                if($cpc->plan_type === 'MEDICID'){
+                    $cpc->auto_detail_json = json_decode($cpc->auto_medicaid_detail_json ?? null); 
+                }
+                if($cpc->plan_type === 'COMMERCIAL'){
+                    $cpc->auto_detail_json = json_decode($cpc->auto_commercial_detail_json ?? null); 
+                }
+                
+            }
+        ?>
+        <div class="d-flex align-items-center mb-2">
+            @if($cpc->is_manually_determined)
+                <div>
+                    <span class="d-inline bg-warning px-2 rounded mr-1"><i class="fas fa-map-pin"></i> Manually Determined</span> 
+                    @if($cpc->is_cancelled)
+                    <span class="mr-1 text-danger text-sm">Cancelled</span>
+                    @else
+                        @include('app.patient.partials.undo-manual-determination')
+                    @endif
+                    <span class="mx-1 text-muted text-sm">|</span>
+                </div>
+                
+            @else
+
+            @endif
+            <h1 class="mr-2 mb-0">Is Covered: {{$cpc->is_covered}}</h1>
+            @if($cpc->plan_type == 'MEDICARE')
+                @include('app.patient.primary-coverage-refresh', ['endpoint'=>'refreshCoverageForMedicare'])
+                <span class="mx-2 text-secondary text-sm">|</span>
+                <a native target="_blank"
+                   open-in-stag-popup
+                   mc-initer="manual-determination-form-{{$patient->uid}}"
+                   title="Medicare Part B (Primary)"
+                   href="/patients/view/primary-coverage-manual-determination-modal/{{$patient->uid}}">
+                    Manual Determination for Medicare Part B (Primary)
+                </a>
+            @endif
+            @if($cpc->plan_type == 'MEDICAID')
+                @include('app.patient.primary-coverage-refresh', ['endpoint'=>'refreshCoverageForMedicaid'])
+                <span class="mx-2 text-secondary text-sm">|</span>
+                <a native target="_blank"
+                   open-in-stag-popup
+                   mc-initer="manual-determination-form-{{$patient->uid}}"
+                   title="Medicaid (Primary)"
+                   href="/patients/view/primary-coverage-manual-determination-modal/{{$patient->uid}}">
+                    Manual Determination for Medicaid (Primary)
+                </a>
+            @endif
+            @if($cpc->plan_type == 'COMMERCIAL')
+                @include('app.patient.primary-coverage-refresh', ['endpoint'=>'refreshCoverageForCommercial'])
+                <span class="mx-2 text-secondary text-sm">|</span>
+                <a native target="_blank"
+                   open-in-stag-popup
+                   mc-initer="manual-determination-form-{{$patient->uid}}"
+                   title="Commercial (Primary)"
+                   href="/patients/view/primary-coverage-manual-determination-modal/{{$patient->uid}}">
+                    Manual Determination for Commercial (Primary)
+                </a>
+            @endif
+        </div>
+
+        <div class="mt-4 {{ $cpc->is_cancelled ? 'cpc-cancelled':'' }}">
+          <div class="row">
+            <div class="col-md-12">
+              @include('app.patient.primary-coverage-view')
+            </div>
+          </div>
+            {{--
+            @php
+            dump(json_decode($cpc->toJson(JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)));
+            @endphp
+            --}}
+            {{--
+            @php
+            dump($cpc->auto_detail_json);
+            @endphp
+            --}}
+        </div>
+    @endif

+ 0 - 36
resources/views/app/patient/primary-coverage-view.blade.php

@@ -1,39 +1,3 @@
-<?php
-    function toHumanReadable($name) {
-        return ucwords(preg_replace("/[^0-9a-z]/i", " ", $name));
-    }
-    function parseRender($_data) {
-        if($_data) {
-            $type = gettype($_data);
-            if(is_string($_data) || is_numeric($_data)) {
-                echo $_data;
-            }
-            else {
-                echo "<table class='table table-sm border w-100'>";
-                foreach($_data as $k => $v) {
-                    echo "<tr>";
-                    echo "<td><b class='text-secondary'>" . toHumanReadable($k) . "</b></td>";
-                    echo "<td>";
-                    if(is_object($v)) {
-                        parseRender($v);
-                    }
-                    elseif(is_array($v)) {
-                        foreach($v as $k2 => $v2) {
-                            parseRender($v2);
-                        }
-                    }
-                    else {
-                        echo $v;
-                    }
-                    echo "</td>";
-                    echo "</tr>";
-                }
-                echo "</table>";
-            }
-        }
-    }
-?>
-
 <div class="container-fluid px-lg-0">
 	<div class="row">
 		<div class="col-lg-5">

+ 64 - 73
resources/views/app/patient/primary-coverage.blade.php

@@ -13,86 +13,77 @@
         </a>
     </div>
 </div>
-
-<div class="mt-2 pt-2">
-    @php
-        $cpc = $patient->getPrimaryCoverage();
-    @endphp
-</div>
-    @if(!$cpc)
-        <div class="alert alert-info">No coverage for this client</div>
-    @else
-        @php
-            $cpc->auto_detail_json = json_decode($cpc->auto_detail_json);
-        @endphp
-        <div class="d-flex align-items-center mb-2">
-            @if($cpc->is_manually_determined)
-                <div>
-                    <span class="d-inline bg-warning px-2 rounded mr-1"><i class="fas fa-map-pin"></i> Manually Determined</span> 
-                    @if($cpc->is_cancelled)
-                    <span class="mr-1 text-danger text-sm">Cancelled</span>
-                    @else
-                        @include('app.patient.partials.undo-manual-determination')
+<div class="page-tabs coverage-tabs-display mt-3">
+        <div class="links">
+            @if($patient->latestNewClientPrimaryCoverage)
+                <a class="c-pointer {{ $patient->getPrimaryCoverage()->id == $patient->latestNewClientPrimaryCoverage->id ? 'active':'' }}" data-link="latest_new_client_primary_coverage">
+                    Latest New Client Primary Coverage
+                    @if($patient->getPrimaryCoverage()->id == $patient->latestNewClientPrimaryCoverage->id)
+                        <i class="fas fa-star ml-2"></i>
                     @endif
-                    <span class="mx-1 text-muted text-sm">|</span>
-                </div>
-                
-            @else
-
-            @endif
-            <h1 class="mr-2 mb-0">Is Covered: {{$cpc->is_covered}}</h1>
-            @if($cpc->plan_type == 'MEDICARE')
-                @include('app.patient.primary-coverage-refresh', ['endpoint'=>'refreshCoverageForMedicare'])
-                <span class="mx-2 text-secondary text-sm">|</span>
-                <a native target="_blank"
-                   open-in-stag-popup
-                   mc-initer="manual-determination-form-{{$patient->uid}}"
-                   title="Medicare Part B (Primary)"
-                   href="/patients/view/primary-coverage-manual-determination-modal/{{$patient->uid}}">
-                    Manual Determination for Medicare Part B (Primary)
                 </a>
             @endif
-            @if($cpc->plan_type == 'MEDICAID')
-                @include('app.patient.primary-coverage-refresh', ['endpoint'=>'refreshCoverageForMedicaid'])
-                <span class="mx-2 text-secondary text-sm">|</span>
-                <a native target="_blank"
-                   open-in-stag-popup
-                   mc-initer="manual-determination-form-{{$patient->uid}}"
-                   title="Medicaid (Primary)"
-                   href="/patients/view/primary-coverage-manual-determination-modal/{{$patient->uid}}">
-                    Manual Determination for Medicaid (Primary)
-                </a>
-            @endif
-            @if($cpc->plan_type == 'COMMERCIAL')
-                @include('app.patient.primary-coverage-refresh', ['endpoint'=>'refreshCoverageForCommercial'])
-                <span class="mx-2 text-secondary text-sm">|</span>
-                <a native target="_blank"
-                   open-in-stag-popup
-                   mc-initer="manual-determination-form-{{$patient->uid}}"
-                   title="Commercial (Primary)"
-                   href="/patients/view/primary-coverage-manual-determination-modal/{{$patient->uid}}">
-                    Manual Determination for Commercial (Primary)
+            @if($patient->latestAutoRefreshClientPrimaryCoverage)
+                <a class="c-pointer {{ $patient->getPrimaryCoverage()->id == $patient->latestAutoRefreshClientPrimaryCoverage->id ? 'active':'' }}" data-link="latest_auto_refresh_client_primary_coverage">
+                    Latest Auto Refresh Client Primary Coverage
+                    @if($patient->getPrimaryCoverage()->id == $patient->latestAutoRefreshClientPrimaryCoverage->id)
+                        <i class="fas fa-star ml-2"></i>
+                    @endif
                 </a>
             @endif
+            @if($patient->latestManualClientPrimaryCoverage)
+                <a class="c-pointer {{ $patient->getPrimaryCoverage()->id == $patient->latestManualClientPrimaryCoverage->id ? 'active':'' }}" data-link="latest_manual_client_primary_coverage">
+                    Latest Manual Client Primary Coverage
+                    @if($patient->getPrimaryCoverage()->id == $patient->latestManualClientPrimaryCoverage->id)
+                        <i class="fas fa-star ml-2"></i>
+                    @endif
+                </a>   
+            @endif     
         </div>
-
-        <div class="mt-4 {{ $cpc->is_cancelled ? 'cpc-cancelled':'' }}">
-          <div class="row">
-            <div class="col-md-12">
-              @include('app.patient.primary-coverage-view')
+        <div class="page-tab">
+            @if($patient->latestNewClientPrimaryCoverage)
+            <div tab id="latest_new_client_primary_coverage" class="{{ $patient->getPrimaryCoverage()->id == $patient->latestNewClientPrimaryCoverage->id ? '':'d-none' }}">
+                @include('app.patient.partials.coverage-information', ['coverage' => $patient->latestNewClientPrimaryCoverage])
             </div>
-          </div>
-            {{--
-            @php
-            dump(json_decode($cpc->toJson(JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)));
-            @endphp
-            --}}
-            {{--
-            @php
-            dump($cpc->auto_detail_json);
-            @endphp
-            --}}
+            @endif
+            @if($patient->latestAutoRefreshClientPrimaryCoverage)
+            <div tab id="latest_auto_refresh_client_primary_coverage" class="{{ $patient->getPrimaryCoverage()->id == $patient->latestAutoRefreshClientPrimaryCoverage->id ? '':'d-none' }}">
+                @include('app.patient.partials.coverage-information', ['coverage' => $patient->latestAutoRefreshClientPrimaryCoverage])
+            </div>
+            @endif
+            @if($patient->latestManualClientPrimaryCoverage)
+            <div tab id="latest_manual_client_primary_coverage" class="{{ $patient->getPrimaryCoverage()->id == $patient->latestManualClientPrimaryCoverage->id ? '':'d-none' }}">
+                @include('app.patient.partials.coverage-information', ['coverage' => $patient->latestManualClientPrimaryCoverage])
+            </div>
+            @endif
         </div>
-    @endif
 </div>
+
+<script>
+    (function($){
+        var coverageTabsComponent = {
+            initTabs: function(){
+                var section = $('.coverage-tabs-display');
+                var sectionContent = section.find('.page-tab');
+                var tabsLinks = section.find('.links a');
+
+                $.each(tabsLinks, function(i, link){
+                    $(link).click(function(evt){
+                        evt.preventDefault();
+                        var target = $(link).data('link');
+                        tabsLinks.removeClass('active');
+                        $(link).addClass('active');
+                        sectionContent.find('[tab]').addClass('d-none');
+                        sectionContent.find('#'+target).removeClass('d-none'); 
+                    });                   
+                });
+            },
+            init: function(){
+                this.initTabs();
+            }
+        };
+        coverageTabsComponent.init();
+    })(jQuery);
+</script>
+
 @endsection