ソースを参照

Patient dashboard show deprecated/new etc. only if there is data in canvas/point

Vijayakrishnan 3 年 前
コミット
8f1b2eafbe

+ 30 - 0
app/Models/Client.php

@@ -930,5 +930,35 @@ ORDER BY m.ts DESC
         return $this->hasOne(Status::class, 'id', 'client_engagement_status_id');
     }
 
+    public function hasDataInCanvas($_type) {
+        $page = Page::where('client_id', $this->id)->where('category', 'CANVAS')->where('key', $_type)->first();
+        $contentData = [];
+        if($page){
+            $contentData = json_decode($page->data, true);
+        }else{
+            if($this->canvas_data) {
+                $canvasData = json_decode($this->canvas_data, true);
+                if(isset($canvasData[$_type])) {
+                    $contentData = $canvasData[$_type];
+                    if($_type !== 'vitals') {
+                        if(!isset($contentData['items'])){
+                            $contentData['items'] = [];
+                        }
+                    }
+                }
+            }
+        }
+        if($_type !== 'vitals') {
+            if (isset($contentData['items']) && count($contentData['items'])) {
+                return true;
+            }
+        }
+        else {
+            foreach ($contentData as $cd) {
+                if(isset($cd['value']) && !empty($cd['value'])) return true;
+            }
+        }
+        return false;
+    }
 
 }

+ 27 - 9
resources/views/app/patient/dashboard.blade.php

@@ -43,8 +43,10 @@
                 {{-- appointments --}}
                 @include('app/patient/partials/appointments')
 
+                <?php $hasAllergiesInCanvas = $patient->hasDataInCanvas('allergies'); ?>
+
                 {{-- canvas based allergies --}}
-                @if($isOldClient)
+                @if($isOldClient && $hasAllergiesInCanvas)
                 <div class="pt-2 mt-2 border-top">
                     <div class="d-flex align-items-center pb-2">
                         <h6 class="my-0 font-weight-bold text-secondary">Allergies</h6>
@@ -59,8 +61,10 @@
                 <!-- allergies - point -->
                 @include('app.patient.point-based-partials.allergies')
 
+                <?php $hasRxInCanvas = $patient->hasDataInCanvas('rx'); ?>
+
                 {{-- canvas based rx --}}
-                @if($isOldClient)
+                @if($isOldClient && $hasRxInCanvas)
                 <div class="pt-2 mt-2 border-top">
                     <div class="d-flex align-items-center pb-2">
                         <h6 class="my-0 font-weight-bold text-secondary">Current Medications</h6>
@@ -196,8 +200,10 @@
                 {{-- vitals --}}
                 {{--@include('app/patient/partials/vitals')--}}
 
+                <?php $hasVitalsInCanvas = $patient->hasDataInCanvas('vitals'); ?>
+
                 {{-- canvas based vitals --}}
-                @if($isOldClient)
+                @if($isOldClient && $hasVitalsInCanvas)
                 <div class="pt-2 border-top">
                     <div class="d-flex align-items-center pb-2">
                         <h6 class="my-0 font-weight-bold text-secondary">Vitals</h6>
@@ -220,7 +226,7 @@
                                 </span>
                             @endif
                         </h6>
-                        @if($isOldClient)
+                        @if($isOldClient && $hasVitalsInCanvas)
                         <div class="px-2 font-weight-bold alert alert-info text-sm my-0 ml-2 py-1">New</div>
                         @endif
                     </div>
@@ -236,6 +242,8 @@
             </div>
             <div class="col-6">
 
+                <?php $hasDxInCanvas = $patient->hasDataInCanvas('dx'); ?>
+
                 {{-- canvas based dx --}}
                 @if($isOldClient)
                     <div class="pt-2 mb-2 border-top">
@@ -252,8 +260,10 @@
                 <!-- probs - point -->
                 @include('app.patient.point-based-partials.dx')
 
+                <?php $hasCareTeamInCanvas = $patient->hasDataInCanvas('care-team'); ?>
+
                 {{-- canvas based careteam --}}
-                @if($isOldClient)
+                @if($isOldClient && $hasCareTeamInCanvas)
                     <div class="pt-2 mt-2 border-top">
                         <div class="d-flex align-items-center pb-2">
                             <h6 class="my-0 font-weight-bold text-secondary">Care Team</h6>
@@ -268,8 +278,10 @@
                 <!-- careteam - point -->
                 @include('app.patient.point-based-partials.care-team')
 
+                <?php $hasPmhxInCanvas = $patient->hasDataInCanvas('pmhx'); ?>
+
                 {{-- history_medical --}}
-                @if($isOldClient)
+                @if($isOldClient && $hasPmhxInCanvas)
                 <div class="pt-2 mt-2 border-top">
                     <div class="d-flex align-items-center pb-2">
                         <h6 class="my-0 font-weight-bold text-secondary">Medical History</h6>
@@ -284,8 +296,10 @@
                 <!-- pmhx - point -->
                 @include('app.patient.point-based-partials.pmhx')
 
+                <?php $hasPshxInCanvas = $patient->hasDataInCanvas('pshx'); ?>
+
                 {{-- history_surgical --}}
-                @if($isOldClient)
+                @if($isOldClient && $hasPshxInCanvas)
                 <div class="mt-2 border-top pt-2">
                     <div class="d-flex align-items-center pb-2">
                         <h6 class="my-0 font-weight-bold text-secondary">Surgical History</h6>
@@ -300,8 +314,10 @@
                 <!-- pshx - point -->
                 @include('app.patient.point-based-partials.shx')
 
+                <?php $hasFhxInCanvas = $patient->hasDataInCanvas('fhx'); ?>
+
                 {{-- history_family --}}
-                @if($isOldClient)
+                @if($isOldClient && $hasFhxInCanvas)
                 <div class="mt-2 border-top pt-2">
                     <div class="d-flex align-items-center pb-2">
                         <h6 class="my-0 font-weight-bold text-secondary">Family History</h6>
@@ -316,8 +332,10 @@
                 <!-- fhx - point -->
                 @include('app.patient.point-based-partials.fhx')
 
+                <?php $hasSochxInCanvas = $patient->hasDataInCanvas('sochx'); ?>
+
                 {{-- history_social --}}
-                @if($isOldClient)
+                @if($isOldClient && $hasSochxInCanvas)
                 <div class="mt-2 border-top pt-2">
                     <div class="d-flex align-items-center pb-2">
                         <h6 class="my-0 font-weight-bold text-secondary">Social History</h6>

+ 1 - 1
resources/views/app/patient/point-based-partials/allergies.blade.php

@@ -4,7 +4,7 @@ $allergies = \App\Models\Point::getPointsOfCategory($patient, "ALLERGY");
 <div class="pt-2 mt-2">
     <div class="d-flex align-items-center pb-2">
         <h6 class="my-0 font-weight-bold">Allergies</h6>
-        @if($isOldClient)
+        @if($isOldClient && @$hasAllergiesInCanvas)
             <div class="px-2 font-weight-bold alert alert-info text-sm my-0 ml-2 py-1">New</div>
         @endif
         @if($patient->coreNote)

+ 1 - 1
resources/views/app/patient/point-based-partials/care-team.blade.php

@@ -4,7 +4,7 @@ $careTeamMembers = \App\Models\Point::getPointsOfCategory($patient, "CARE_TEAM_M
 <div class="pt-2 mt-2">
     <div class="d-flex align-items-center pb-2">
         <h6 class="my-0 font-weight-bold">Care Team</h6>
-        @if($isOldClient)
+        @if($isOldClient && @$hasCareTeamInCanvas)
             <div class="px-2 font-weight-bold alert alert-info text-sm my-0 ml-2 py-1">New</div>
         @endif
         @if($patient->coreNote)

+ 1 - 1
resources/views/app/patient/point-based-partials/dx.blade.php

@@ -4,7 +4,7 @@ $problems = \App\Models\Point::getPointsOfCategory($patient, "PROBLEM");
 <div class="pt-2">
     <div class="d-flex align-items-center pb-2">
         <h6 class="my-0 font-weight-bold">Current Problems / Focus Areas</h6>
-        @if($isOldClient)
+        @if($isOldClient && @$hasDxInCanvas)
             <div class="px-2 font-weight-bold alert alert-info text-sm my-0 ml-2 py-1">New</div>
         @endif
         @if($patient->coreNote)

+ 1 - 1
resources/views/app/patient/point-based-partials/fhx.blade.php

@@ -1,7 +1,7 @@
 <div class="pt-2 mt-2">
     <div class="d-flex align-items-center pb-2">
         <h6 class="my-0 font-weight-bold text-secondary">Family History</h6>
-        @if($isOldClient)
+        @if($isOldClient && @$hasFhxInCanvas)
             <div class="px-2 font-weight-bold alert alert-info text-sm my-0 ml-2 py-1">New</div>
         @endif
         <a native="" target="_blank"

+ 1 - 1
resources/views/app/patient/point-based-partials/pmhx.blade.php

@@ -1,7 +1,7 @@
 <div class="pt-2 mt-2">
     <div class="d-flex align-items-center pb-2">
         <h6 class="my-0 font-weight-bold text-secondary">Medical History</h6>
-        @if($isOldClient)
+        @if($isOldClient && @$hasPmhxInCanvas)
             <div class="px-2 font-weight-bold alert alert-info text-sm my-0 ml-2 py-1">New</div>
         @endif
         <a native="" target="_blank"

+ 1 - 1
resources/views/app/patient/point-based-partials/rx.blade.php

@@ -4,7 +4,7 @@ $medications = \App\Models\Point::getPointsOfCategory($patient, "MEDICATION");
 <div class="pt-2 mt-2">
     <div class="d-flex align-items-center pb-2">
         <h6 class="my-0 font-weight-bold">Current Medications</h6>
-        @if($isOldClient)
+        @if($isOldClient && @$hasRxInCanvas)
             <div class="px-2 font-weight-bold alert alert-info text-sm my-0 ml-2 py-1">New</div>
         @endif
         @if($patient->coreNote)

+ 1 - 1
resources/views/app/patient/point-based-partials/shx.blade.php

@@ -1,7 +1,7 @@
 <div class="pt-2 mt-2">
     <div class="d-flex align-items-center pb-2">
         <h6 class="my-0 font-weight-bold text-secondary">Surgical History</h6>
-        @if($isOldClient)
+        @if($isOldClient && @$hasPshxInCanvas)
             <div class="px-2 font-weight-bold alert alert-info text-sm my-0 ml-2 py-1">New</div>
         @endif
         <a native="" target="_blank"

+ 1 - 1
resources/views/app/patient/point-based-partials/sochx.blade.php

@@ -1,7 +1,7 @@
 <div class="pt-2 mt-2">
     <div class="d-flex align-items-center pb-2">
         <h6 class="my-0 font-weight-bold text-secondary">Social History</h6>
-        @if($isOldClient)
+        @if($isOldClient && @$hasSochxInCanvas)
             <div class="px-2 font-weight-bold alert alert-info text-sm my-0 ml-2 py-1">New</div>
         @endif
         <a native="" target="_blank"