Explorar el Código

Updated caremonth

Samson Mutunga hace 1 año
padre
commit
5c8cea0d47

+ 34 - 98
app/Models/CareMonth.php

@@ -175,70 +175,36 @@ class CareMonth extends Model
 
     public function calculateBillabilityForMcp(){
 
-
-        $strategy = $this->mcp_rpm_payment_strategy;
-        if(!$strategy){
+        $tier1Strategy = $this->mcp_rpm_payment_tier_one_strategy;
+        $tier2Strategy = $this->mcp_rpm_payment_tier_two_strategy;
+        if(!$tier1Strategy || !$tier2Strategy){
             return [
                 'billable' => false, 
                 'reason' => 'MCP RPM strategy has not been set.'
             ];
         }
-        
-        $mcpRpmPaymentAmount =  $this->mcp_rpm_payment_amount;
-        $has16PlusDays = $this->number_of_days_with_remote_measurements >= 16;
-        $hasMcpBilled20Minutes = $this->rm_total_time_in_seconds_by_mcp >= 1200;
-        $hasMcpInteracted = $this->has_mcp_interacted_with_client_about_rm;
 
-        if (is_null($this->days_between_most_recent_mcp_note_date_and_end_of_care_month) || $this->days_between_most_recent_mcp_note_date_and_end_of_care_month > config('app.maxDaysSinceLastVisit')) {
+        $tier = determineTier($this);
+
+        if (!$tier) {
             return [
                 'billable' => false,
                 'reason' => "Patient has not had a visit recent enough to bill for RPM"
             ];
         }
 
-        if($strategy == 'X16_DAYS'){
-            //only check for 16 days
-            if($has16PlusDays){
-                return [
-                    'billable' => true, 
-                    'amount' => $mcpRpmPaymentAmount
-                ];
-            } else {
-                //not billable
-                return [
-                    'billable' => false, 
-                    'reason' => "This care month does not have 16 or more measurement days."
-                ];
-            }
+        if($tier == 'TIER_1'){
+            return [
+                'billable' => true, 
+                'amount' => $this->mcp_rpm_payment_tier_one_amount
+            ];
         }
-    
-        if($strategy == 'X16_DAYS_20_MINS_ON_OWN_MCP_COM_DURING_CM'){
-            if ($has16PlusDays && $hasMcpBilled20Minutes && $hasMcpInteracted) {
-                return [
-                    'billable' => true, 
-                    'amount' => $mcpRpmPaymentAmount
-                ];
-            } else {
-                if(!$has16PlusDays){
-                    return [
-                        'billable' => false, 
-                        'reason' => 'Care month does not have 16 or more measurement days.'
-                    ];
-                }
-                if(!$hasMcpBilled20Minutes){
-                    return [
-                        'billable' => false, 
-                        'reason' => 'Care month does not have 20 minutes billed time.'
-                    ];
-                }
-                if(!$hasMcpInteracted){
-                    return [
-                        'billable' => false, 
-                        'reason' => 'Care month does MCP interaction.'
-                    ];
-                }
-                
-            }
+
+        if($tier == 'TIER_2'){
+            return [
+                'billable' => true, 
+                'amount' => $this->mcp_rpm_payment_tier_two_amount
+            ];
         }
     
     }
@@ -252,69 +218,39 @@ class CareMonth extends Model
             ];
         }
 
-        $strategy = $this->rmm_payment_strategy;
-        if(!$strategy){
+        $tier1Strategy = $this->mcp_rpm_payment_tier_one_strategy;
+        $tier2Strategy = $this->mcp_rpm_payment_tier_two_strategy;
+
+        if(!$tier1Strategy || !$tier2Strategy){
             return [
                 'billable' => false,
                 'reason' => 'RPM strategy has not been set.'
             ];
         }
 
+        $tier = determineTier($this);
+
         $rmmRpmPaymentAmount =  $this->rmm_payment_amount;
-        $has16PlusDays = $this->number_of_days_with_remote_measurements >= 16;
-        $hasRmmBilled20Minutes = $this->rm_total_time_in_seconds_by_rmm_pro >= 1200;
-        $hasMcpInteracted = $this->has_mcp_interacted_with_client_about_rm;
 
-        if (is_null($this->days_between_most_recent_mcp_note_date_and_end_of_care_month) || $this->days_between_most_recent_mcp_note_date_and_end_of_care_month > config('app.maxDaysSinceLastVisit')) {
+        if (!$tier) {
             return [
                 'billable' => false,
                 'reason' => "Patient has not had a visit recent enough to bill for RPM"
             ];
         }
 
-        if($strategy == 'X16_DAYS'){
-            //only check for 16 days
-            if($has16PlusDays){
-                return [
-                    'billable' => true,
-                    'amount' => $rmmRpmPaymentAmount
-                ];
-            } else {
-                //not billable
-                return [
-                    'billable' => false,
-                    'reason' => "This care month does not have 16 or more measurement days."
-                ];
-            }
+        if($tier == 'TIER_1'){
+            return [
+                'billable' => true,
+                'amount' => $rmmRpmPaymentAmount
+            ];
         }
 
-        if($strategy == 'X16_DAYS_20_MINS_ON_OWN_MCP_COM_DURING_CM'){
-            if ($has16PlusDays && $hasRmmBilled20Minutes && $hasMcpInteracted) {
-                return [
-                    'billable' => true,
-                    'amount' => $rmmRpmPaymentAmount
-                ];
-            } else {
-                if(!$has16PlusDays){
-                    return [
-                        'billable' => false,
-                        'reason' => 'Care month does not have 16 or more measurement days.'
-                    ];
-                }
-                if(!$hasRmmBilled20Minutes){
-                    return [
-                        'billable' => false,
-                        'reason' => 'Care month does not have 20 minutes in entries.'
-                    ];
-                }
-                if(!$hasMcpInteracted){
-                    return [
-                        'billable' => false,
-                        'reason' => 'Care month does not have MCP interaction.'
-                    ];
-                }
-
-            }
+        if($tier == 'TIER_2'){
+            return [
+                'billable' => true,
+                'amount' => $rmmRpmPaymentAmount
+            ];
         }
 
     }

+ 1 - 13
resources/views/app/mcp/dashboard/caremonth-tiers-list.blade.php

@@ -48,19 +48,7 @@
                         @else
                             <span class="text-danger">No</span>
                         @endif
-
-                        <div class="on-hover-show d-inline-block on-hover-opaque">
-                            <i class="fa fa-info-circle ml-1"></i>
-                            <div class="on-hover-content p-2 text-dark width-200px">
-                              @if(!$cm->tier())
-                              <h5 class="mb-2 font-weight-bold">Tier 1 Qualification:</h5>
-                              <p class="m-0 text-muted">Minimum of <b>7 days</b>, <b>10 mins</b> and <b>interaction</b> is required.</p>
-                              @elseif($cm->tier() === 'TIER_1')
-                              <h5 class="mb-2 font-weight-bold">Tier 2 Qualification:</h5>
-                              <p class="m-0 text-muted">Minimum of <b>16 days</b>, <b>20 mins</b> and <b>interaction</b> is required.</p>
-                              @endif
-                            </div>
-                        </div>
+                        @include('app.patient.care-month.partials.tier-explainer', ['careMonth' => $cm])
                     </td>
                 </tr>
                 @endforeach

+ 5 - 15
resources/views/app/patient/care-month/dashboard.blade.php

@@ -213,16 +213,11 @@
                                 <!-- days with meas. -->
                                 <div class="mt-2">
                                     <span class="font-weight-bold text-secondary">Days with meas.:</span>
-                                    <b class="{{$careMonth->number_of_days_with_remote_measurements >= 16 ? 'text-success' : 'text-warning-mellow'}}">
+                                    <b class="{{ determineTier($careMonth) ? 'text-success' : 'text-warning-mellow'}}">
                                         {{$careMonth->number_of_days_with_remote_measurements}}
-                                        @if($careMonth->number_of_days_with_remote_measurements >= 16)
-                                            <i class="fa fa-check"></i>
-                                        @else
-                                            <i class="fa fa-exclamation-triangle"></i>
-                                        @endif
-                                        <span class="ml-1 text-secondary text-sm font-weight-normal">(16 needed)</span>
+                                        @include('app.patient.care-month.partials.tier-explainer', ['careMonth' => $careMonth])
                                     </b>
-                                    @if($careMonth->number_of_days_with_remote_measurements < 16)
+                                    @if(!determineTier($careMonth))
                                         <div moe relative class="ml-2">
                                             <a href="#" start show class="text-sm">SMS Patient</a>
                                             <form url="/api/clientSms/createOutgoing" right="" class="mcp-theme-1" noreload="" style="display: none;">
@@ -245,7 +240,7 @@
                                 </div>
                                 @if($careMonth->showMeasurementDaysWarning())
                                     <?php
-                                    $moreDays = 16 - $careMonth->number_of_days_with_remote_measurements;
+                                    $moreDays = 7 - $careMonth->number_of_days_with_remote_measurements;
                                     if($moreDays < 0) $moreDays = 0;
                                     ?>
                                     @if($moreDays > 0)
@@ -298,12 +293,7 @@
 
                                     <b class="{{$minsBilled >= 20 ? 'text-success' : 'text-warning-mellow'}}">
                                         {{$minsBilled}}
-                                        @if($minsBilled < 20)
-                                            <i class="fa fa-exclamation-triangle"></i>
-                                        @else
-                                            <i class="fa fa-check"></i>
-                                        @endif
-                                        <span class="ml-1 text-secondary text-sm font-weight-normal">(20 needed)</span>
+                                        @include('app.patient.care-month.partials.tier-explainer', ['careMonth' => $careMonth])
                                     </b>
                                     <span class="mx-2 text-secondary">|</span>
                                     @include('app.practice-management.care_month_add_entry_form', ['right' => true])

+ 16 - 0
resources/views/app/patient/care-month/partials/tier-explainer.blade.php

@@ -0,0 +1,16 @@
+<div class="on-hover-show d-inline-block on-hover-opaque">
+    @if (!determineTier($careMonth))
+        <i class="fa fa-exclamation-triangle"></i>
+    @else
+        <i class="fa fa-check"></i>
+    @endif
+    <div class="on-hover-content p-2 text-dark width-200px">
+        @if (!$careMonth->tier())
+            <h5 class="mb-2 font-weight-bold">Tier 1 Qualification:</h5>
+            <p class="m-0 text-muted">Minimum of <b>7 days</b>, <b>10 mins</b> and <b>interaction</b> is required.</p>
+        @elseif($careMonth->tier() === 'TIER_1')
+            <h5 class="mb-2 font-weight-bold">Tier 2 Qualification:</h5>
+            <p class="m-0 text-muted">Minimum of <b>16 days</b>, <b>20 mins</b> and <b>interaction</b> is required.</p>
+        @endif
+    </div>
+</div>

+ 2 - 7
resources/views/app/patient/care-months.blade.php

@@ -146,14 +146,9 @@
 
                             $minsBilled = floor($minsBilled / 60);
                         ?>
-                        <b class="{{$minsBilled >= 20 ? 'text-success' : 'text-warning-mellow'}}">
+                        <b class="{{ determineTier($careMonth) ? 'text-success' : 'text-warning-mellow'}}">
                             {{$minsBilled}}
-                            @if($minsBilled < 20)
-                                <i class="fa fa-exclamation-triangle"></i>
-                            @else
-                                <i class="fa fa-check"></i>
-                            @endif
-                            <span class="ml-1 text-secondary text-sm font-weight-normal">(20 needed)</span>
+                            @include('app.patient.care-month.partials.tier-explainer', ['careMonth' => $careMonth])
                         </b>
                     </td>
                     <td>

+ 4 - 9
resources/views/app/patient/partials/caremonth-summary.blade.php

@@ -29,16 +29,11 @@
 
     <div class="mt-2">
         <span class="font-weight-bold text-secondary">Days with meas.:</span>
-        <b class="{{$careMonth->number_of_days_with_remote_measurements >= 16 ? 'text-success' : 'text-warning-mellow'}}">
+        <b class="{{determineTier($careMonth) ? 'text-success' : 'text-warning-mellow'}}">
             {{$careMonth->number_of_days_with_remote_measurements}}
-            @if($careMonth->number_of_days_with_remote_measurements >= 16)
-                <i class="fa fa-check"></i>
-            @else
-                <i class="fa fa-exclamation-triangle"></i>
-            @endif
-            <span class="ml-1 text-secondary text-sm font-weight-normal">(16 needed)</span>
+            @include('app.patient.care-month.partials.tier-explainer', ['careMonth' => $careMonth])
         </b>
-        @if($careMonth->number_of_days_with_remote_measurements < 16)
+        @if(!determineTier($careMonth))
             <div moe relative class="ml-2">
                 <a href="#" start show class="text-sm">SMS Patient</a>
                 <form url="/api/clientSms/createOutgoing" right="" class="mcp-theme-1" noreload="" style="display: none;">
@@ -61,7 +56,7 @@
     </div>
     @if($careMonth->showMeasurementDaysWarning())
         <div class="alert alert-warning p-2 mt-1">
-            Need <b>{{16 - $careMonth->number_of_days_with_remote_measurements}} more days</b> with measurements before RM becomes billable.
+            Need <b>{{7 - $careMonth->number_of_days_with_remote_measurements}} more days</b> with measurements before RM becomes billable.
         </div>
     @endif