瀏覽代碼

Null pointer fix

Samson Mutunga 3 年之前
父節點
當前提交
4aa79ff4f4
共有 1 個文件被更改,包括 18 次插入12 次删除
  1. 18 12
      resources/views/app/patient/claims-resolver.blade.php

+ 18 - 12
resources/views/app/patient/claims-resolver.blade.php

@@ -23,14 +23,17 @@
     $totalNotesWithClaimingClosed = 0;
     foreach($patient->notesAscending as $note){
         if($note->is_cancelled) continue;
-        $hcpIdToProMap[$note->hcp_pro_id] = $note->hcpPro;
+        if($note->hcpPro){
+            $hcpIdToProMap[$note->hcp_pro_id] = $note->hcpPro;    
+        }
+        
         $d = $note->effective_dateest;
         $firstDateSeenByHcpMap[$note->hcp_pro_id] = isset($firstDateSeenByHcpMap[$note->hcp_pro_id]) ? $firstDateSeenByHcpMap[$note->hcp_pro_id] : $d;
         $lastDateSeenByHcpMap[$note->hcp_pro_id] = $d;
         $noteCount = $hcpNoteCountMap[$note->hcp_pro_id] = isset($hcpNoteCountMap[$note->hcp_pro_id]) ? $hcpNoteCountMap[$note->hcp_pro_id]  + 1 : 1;
         $firstDateSeenByThisHcp = $firstDateSeenByHcpMap[$note->hcp_pro_id];
         $firstDateEverSeenByAnyone = $firstDateEverSeenByAnyone ? $firstDateEverSeenByAnyone : $d;
-        if($note->hcpPro->is_enrolled_as_mcp){
+        if($note->hcpPro && $note->hcpPro->is_enrolled_as_mcp){
             $firstDateEverSeenByMcpTypePro = $firstDateEverSeenByMcpTypePro ? $firstDateEverSeenByMcpTypePro : $d;
             if($note->client->mcp && $note->hcpPro->id == $note->client->mcp->id){
                 $firstDateEverSeenByCurrentMcp = $firstDateEverSeenByMcpTypePro;
@@ -41,9 +44,11 @@
         $daysWithHcp = (strtotime($d) - strtotime($firstDateSeenByThisHcp)) / (60 * 60 * 24);
         $lastVisitWithHcp = isset($loopLastDateSeenByHcpMap[$note->hcp_pro_id]) ? $loopLastDateSeenByHcpMap[$note->hcp_pro_id] : null;
         $daysSinceLastNoteByThisHcp = $lastVisitWithHcp ? (strtotime($d) - strtotime($lastVisitWithHcp)) / (60 * 60 * 24) : null;
-        $daysSinceLastMcpTypeVisit = $note->hcpPro->is_enrolled_as_mcp && $loopLastDateSeenByMcpTypePro ? (strtotime($d) - strtotime($loopLastDateSeenByMcpTypePro)) / (60 * 60 * 24) : null;
-        $loopLastDateSeenByHcpMap[$note->hcpPro->id] = $d;
-        if($note->hcpPro->is_enrolled_as_mcp){
+        $daysSinceLastMcpTypeVisit = $note->hcpPro && $note->hcpPro->is_enrolled_as_mcp && $loopLastDateSeenByMcpTypePro ? (strtotime($d) - strtotime($loopLastDateSeenByMcpTypePro)) / (60 * 60 * 24) : null;
+        if($note->hcpPro){
+          $loopLastDateSeenByHcpMap[$note->hcpPro->id] = $d;  
+        }        
+        if($note->hcpPro && $note->hcpPro->is_enrolled_as_mcp){
             $loopLastDateSeenByMcpTypePro = $d;
         }
         $daysInMcpProgramTotal = (strtotime(date('Y-m-d')) - strtotime($firstDateSeenByThisHcp)) / (60 * 60 * 24);
@@ -250,7 +255,7 @@
                 $firstDateSeenByThisHcp = $firstDateSeenByHcpMap[$note->hcp_pro_id];
 
                 $firstDateEverSeenByAnyone = $firstDateEverSeenByAnyone ? $firstDateEverSeenByAnyone : $d;
-                if($note->hcpPro->is_enrolled_as_mcp){
+                if($note->hcpPro && $note->hcpPro->is_enrolled_as_mcp){
                     $firstDateEverSeenByMcpTypePro = $firstDateEverSeenByMcpTypePro ? $firstDateEverSeenByMcpTypePro : $d;
                 }
 
@@ -262,7 +267,7 @@
                 $lastVisitWithHcp = isset($loopLastDateSeenByHcpMap[$note->hcp_pro_id]) ? $loopLastDateSeenByHcpMap[$note->hcp_pro_id] : null;
                 $daysSinceLastNoteByThisHcp = $lastVisitWithHcp ? (strtotime($d) - strtotime($lastVisitWithHcp)) / (60 * 60 * 24) : null;
 
-                $daysSinceLastMcpTypeVisit = $note->hcpPro->is_enrolled_as_mcp && $loopLastDateSeenByMcpTypePro ? (strtotime($d) - strtotime($loopLastDateSeenByMcpTypePro)) / (60 * 60 * 24) : null;
+                $daysSinceLastMcpTypeVisit = $note->hcpPro && $note->hcpPro->is_enrolled_as_mcp && $loopLastDateSeenByMcpTypePro ? (strtotime($d) - strtotime($loopLastDateSeenByMcpTypePro)) / (60 * 60 * 24) : null;
 
                 // content
 
@@ -273,7 +278,7 @@
                     echo '<hr>';
                 }
                 $content = ob_get_clean();
-                $lastContent = isset($loopLastContentByHcp[$note->hcpPro->id]) ? $loopLastContentByHcp[$note->hcpPro->id] : "-";
+                $lastContent = isset($loopLastContentByHcp[@$note->hcpPro->id]) ? $loopLastContentByHcp[@$note->hcpPro->id] : "-";
 
                 $contentText = Html2Text::convert($content);
                 $lastContentText = Html2Text::convert($lastContent);
@@ -282,7 +287,7 @@
         <tr>
             <td>{{$rowIndex}}</td>
             <td>
-                <strong>{{ $note->hcpPro->displayName() }}</strong>
+                <strong>{{ $note->hcpPro ?$note->hcpPro->displayName() : '' }}</strong>
             </td>
             <td>
                 <a native target="_blank"
@@ -404,11 +409,12 @@
             </td>
         </tr>
         <?php
-                $loopLastDateSeenByHcpMap[$note->hcpPro->id] = $d;
-                if($note->hcpPro->is_enrolled_as_mcp){
+                if($note->hcpPro) $loopLastDateSeenByHcpMap[$note->hcpPro->id] = $d;
+                
+                if($note->hcpPro && $note->hcpPro->is_enrolled_as_mcp){
                     $loopLastDateSeenByMcpTypePro = $d;
                 }
-                $loopLastContentByHcp[$note->hcpPro->id] = $content;
+                if($note->hcpPro) $loopLastContentByHcp[$note->hcpPro->id] = $content;
             }
         ?>