3 Commits 087dd78592 ... 1d855ea909

Autore SHA1 Messaggio Data
  = 1d855ea909 fixed chat 1 mese fa
  = d248719e75 Merge branch 'rpm-report-fix' of https://rav.triplestart.com/tigerphp/stagfe2 into rpm-report-fix 1 mese fa
  = af07462c4d styling 1 mese fa

+ 0 - 0
app/Helpers/grata.http


+ 15 - 0
app/Models/CareMonth.php

@@ -49,6 +49,15 @@ class CareMonth extends Model
             ->get();
     }
 
+    public function entriesByProForCareMonth($_proId, $_careMonthId) {
+        return CareMonthEntry::where('care_month_id', $this->id)
+            ->where('pro_id', $_proId)
+            ->where('care_month_id', $_careMonthId)
+            ->where('cm_or_rm_or_rtm_msk_or_rtm_lung', 'RM')
+            ->orderBy('effective_date', 'DESC')
+            ->get();
+    }
+
     public function entriesNotByPro($_proId) {
         return CareMonthEntry::where('care_month_id', $this->id)
             ->where('pro_id', '!=', $_proId)
@@ -135,6 +144,11 @@ class CareMonth extends Model
             ->where('status', '<>', 'CANCELLED');
     }
 
+    public function mcpPro()
+    {
+        return $this->hasOne(Pro::class, 'id', 'mcp_pro_id');
+    }
+
     public function mostRecentMcpNote()
     {
         return $this->hasOne(Note::class, 'id', 'most_recent_mcp_note_id');
@@ -152,6 +166,7 @@ class CareMonth extends Model
 
     public function mcpRmGenericBill()
     {
+
         return $this->hasOne(Bill::class, 'id', 'mcp_rm_generic_bill_id')->where('is_cancelled', false)->where('is_cancelled_by_administrator', false);
     }
     public function rmmRmGenericBill()

+ 4 - 0
app/Models/CompanyLocation.php

@@ -13,4 +13,8 @@ class CompanyLocation extends Model
         return implode(" ", [$this->line1, $this->city, $this->state]);
     }
 
+    public function format(){
+        return $this->line1.($this->line2? ', '.$this->line2: '').($this->city?', '.$this->city:'').($this->state?', '.$this->state:'').($this->zip? ' '.$this->zip:'');
+    }
+
 }

+ 155 - 0
resources/views/app/patient/care-month/partials/print/chart.blade.php

@@ -0,0 +1,155 @@
+
+<link href="/c3/c3.min.css" rel="stylesheet">
+<script src="/c3/d3.v5.min.js" charset="utf-8"></script>
+<script src="/c3/c3.min.js"></script>
+
+<div id="vitalsGraphComponentUnified_{{$careMonth->id}}{{@$suffix ?: ''}}" class="stag-chart mb-4 pt-3">
+    <div id="unified-chart_{{$careMonth->id}}{{@$suffix ?: ''}}"></div>
+</div>
+
+<?php
+$dates = [];
+$startDate = $careMonth->start_date;
+$nextMonthFirstDay = date_format(date_add(date_create($startDate), date_interval_create_from_date_string("1 month")), 'Y-m-d');
+
+$nextDay = $startDate;
+while ($nextDay !== $nextMonthFirstDay) {
+    $dates[] = $nextDay;
+    $nextDay = date_format(date_add(date_create($nextDay), date_interval_create_from_date_string('1 day')), 'Y-m-d');
+}
+
+/** @var \App\Models\Client $patient */
+
+// BP
+$bpMeasurements = $patient->getNonZeroBpMeasurements->toArray();
+$weightMeasurements = $patient->getNonZeroWeightMeasurements->toArray();
+
+$bpData = [];
+$weightData = [];
+
+for ($i=0; $i<count($dates); $i++) {
+
+    $date = $dates[$i];
+
+    // bp
+    $bp = array_filter($bpMeasurements, function($_measurement) use ($date) {
+        return $_measurement['effective_date'] === $date;
+    });
+    if(count($bp)) {
+        $bp = array_values($bp);
+        $bp = $bp[count($bp) - 1];
+    }
+    else {
+        $bp = null;
+    }
+
+
+    if ($bp) {
+        $bpData[] = [
+            "date" => $date,
+            "sbp" => $bp["sbp_mm_hg"],
+            "dbp" => $bp["dbp_mm_hg"]
+        ];
+    }
+
+    // weight
+    $weight = array_filter($weightMeasurements, function($_measurement) use ($date) {
+        return $_measurement['effective_date'] === $date;
+    });
+    if(count($weight)) {
+        $weight = array_values($weight);
+        $weight = $weight[count($weight) - 1];
+        $weightData[] = [
+            "date" => $date,
+            "weight" => $weight["numeric_value"]
+        ];
+    }
+
+}
+
+$bpDates = [];
+$sbpValues = [];
+$dbpValues = [];
+for ($i = 0; $i < count($bpData); $i++) {
+    $bpDates[] = $bpData[$i]['date'];
+    $sbpValues[] = round($bpData[$i]['sbp'], 1);
+    $dbpValues[] = round($bpData[$i]['dbp'], 1);
+}
+
+$weightDates = [];
+$weightValues = [];
+for ($i = 0; $i < count($weightData); $i++) {
+    $weightDates[] = $weightData[$i]['date'];
+    $weightValues[] = round($weightData[$i]['weight'], 1);
+}
+
+?>
+
+<script>
+    (function() {
+        init();
+        function init() {
+            unifiedChart();
+        }
+        function unifiedChart() {
+            $('#vitalsGraphComponentUnified_{{$careMonth->id}}{{@$suffix ?: ''}}')
+                .empty()
+                .append('<div id="unified-chart_{{$careMonth->id}}{{@$suffix ?: ''}}"></div>');
+            window['vgUnifiedChart_{{$careMonth->id}}{{@$suffix ?: ''}}'] = c3.generate({
+                bindto: '#unified-chart_{{$careMonth->id}}{{@$suffix ?: ''}}',
+                data: {
+                    xs: {
+                        'Systolic BP' : 'x1',
+                        'Diastolic BP' : 'x1',
+                        'Weight': 'x2',
+                    },
+                    axes: {
+                        'Systolic BP' : 'y',
+                        'Diastolic BP' : 'y',
+                        'Weight': 'y2',
+                    },
+                    columns: [
+                        ['x1', <?= implode(", ", array_map(function($_x) { return "'" . $_x . "'"; }, $bpDates)) ?>],
+                        ['x2', <?= implode(", ", array_map(function($_x) { return "'" . $_x . "'"; }, $weightDates)) ?>],
+                        ['Systolic BP', <?= implode(", ", array_map(function($_x) { return "'" . $_x . "'"; }, $sbpValues)) ?>],
+                        ['Diastolic BP', <?= implode(", ", array_map(function($_x) { return "'" . $_x . "'"; }, $dbpValues)) ?>],
+                        ['Weight', <?= implode(", ", array_map(function($_x) { return "'" . $_x . "'"; }, $weightValues)) ?>]
+                    ]
+                },
+                axis: {
+                    x: {
+                        type: 'timeseries',
+                        tick: {
+                            format: '%Y-%m-%d',
+                            multiline: true,
+                            fit: true,
+                            rotate: -45
+                        },
+                    },
+                    y: {
+                        show: true,
+                        label: {
+                            text: 'Blood Pressure (mmHg)',
+                            position: 'outer-middle'
+                        },
+                        min: 60,
+                        max: 220
+                    },
+                    y2: {
+                        show: true,
+                        label: {
+                            text: 'Weight (lbs)',
+                            position: 'outer-middle'
+                        },
+                        min: 80,
+                        max: 280
+                    },
+                },
+                regions: [
+                    {axis: 'y', start: 100, end: 130, class: 'safe-region', label: 'Safe Systolic BP: 100 to 130 mmHg'},
+                    {axis: 'y', start: 60, end: 90, class: 'safe-region', label: 'Safe Diastolic BP: 60 to 90 mmHg'}
+                ]
+            });
+        }
+    }).call(window);
+</script>

+ 80 - 60
resources/views/app/patient/care-month/partials/print/measurements.blade.php

@@ -1,33 +1,37 @@
-<h6 class="font-weight-bold">Measurements</h6>
-<table class="table table-striped table-sm table-bordered mt-2 mb-0">
+<h3 style="font-weight: bolder; font-size: 18px; line-height:18px; margin:0px;" class="mb-3"><b>Remote Monitoring:</b>
+</h3>
+<table class="table table-sm table-bordered mt-2 mb-0">
     <thead>
-        <tr>
-            <th class="px-1 text-secondary">Date & Time</th>
-            <th class="px-1 text-secondary w-25">Measurement</th>
-            <th class="px-1 text-secondary w-25">Type</th>
-            <th class="px-1 text-secondary w-25">Interaction</th>
-            <th class="px-4 text-secondary">Comments</th>
-        </tr>
+    <tr>
+        <th class="px-1 text-nowrap"><b>Date & Time</b></th>
+        <th class="px-1"><b>Measurement</b></th>
+        <th class="px-1"><b>Type</b></th>
+        <th class="px-1"><b>Interaction</b></th>
+        <th class="px-4 w-100"><b>Comments</b></th>
+    </tr>
     </thead>
     <tbody>
-        @php
-            $measurementsInCareMonth = $patient->measurementsInCareMonth($careMonth);
-            $plottableMeasurements = [];
-        @endphp
-        @foreach ($measurementsInCareMonth as $measurement)
-            @if($measurementType && stripos($measurement->label, $measurementType) === false ) @continue @endif
-            @if (!empty($measurement->label) && !in_array($measurement->label, ['SBP', 'DBP']) && !$measurement->is_cellular_zero)
-                <tr>
-                    <td class="px-2">
-                        @if ($measurement->ts)
+    @php
+        $measurementsInCareMonth = $patient->measurementsInCareMonth($careMonth);
+        $plottableMeasurements = [];
+    @endphp
+    @foreach ($measurementsInCareMonth as $measurement)
+        @if($measurementType && stripos($measurement->label, $measurementType) === false )
+            @continue
+        @endif
+        @if (!empty($measurement->label) && !in_array($measurement->label, ['SBP', 'DBP']) && !$measurement->is_cellular_zero)
+            <tr>
+                <td class="px-2 text-nowrap">
+                    @if ($measurement->ts)
                             <?php $timestampInSec = floor($measurement->ts / 1000); ?>
-                            {{ friendly_date_time_short_with_tz_from_timestamp($timestampInSec, 'EASTERN') }}
-                        @else
-                            {{ friendly_date_time_short_with_tz($measurement->effective_date, true, 'EASTERN') }}
-                        @endif
-                        EST
-                    </td>
-                    <td class="px-1">
+                        {{ friendly_date_time_short_with_tz_from_timestamp($timestampInSec, 'EASTERN') }}
+                    @else
+                        {{ friendly_date_time_short_with_tz($measurement->effective_date, true, 'EASTERN') }}
+                    @endif
+                    EST
+                </td>
+                <td class="px-1 text-nowrap">
+                    <div class="text-nowrap">
                         @if ($measurement->is_cellular_zero)
                             <i class="font-size-11 fa fa-rss"></i>
                         @elseif($measurement->label === 'BP')
@@ -37,45 +41,61 @@
                         @else
                             {{ $measurement->value }}
                         @endif
-                    </td>
-                    <td class="px-1">{{ $measurement->label }}</td>
-                    <td>
-                        @if($careMonth->mcpInteractionNote)
-                            $careMonth->mcpInteractionNote->method
-                        @else
-
-                        @endif
-                    </td>
-{{--                    <td colspan="px-2">--}}
-{{--                        <?php--}}
-{{--                        $stamps = ['has_been_stamped_by_mcp', 'has_been_stamped_by_non_hcp', 'has_been_stamped_by_rme', 'has_been_stamped_by_rmm'];--}}
-{{--                        $isStamped = false;--}}
-{{--                        foreach ($stamps as $stamp) {--}}
-{{--                            if ($measurement->{$stamp}) {--}}
-{{--                                $isStamped = true;--}}
-{{--                            }--}}
-{{--                        }--}}
-{{--                        ?>--}}
-{{--                        @if ($isStamped)--}}
-{{--                            ✓--}}
-{{--                        @endif--}}
-{{--                    </td>--}}
-                    <td class="px-4">
+                    </div>
+                </td>
+                <td class="px-1 text-nowrap">{{ $measurement->label }}</td>
+                <td class="text-nowrap">
+                    <div class="">
+                        @php $found = false; @endphp
                         @foreach($careMonth->entries as $entry)
-                            @if($entry->achieved_mcp_time_in_seconds > 0 && $entry->is_removed != true )
-                            <p>{{$entry->achieved_mcp_time_in_seconds/60}}m: {!!  $entry->content_text  !!}</p>
+                            @if(friendly_date($entry->effective_date) == friendly_date($measurement->effective_date) && $entry->did_pro_interact_with_client_about_rm && !$found)
+                                Text/Audio call
+                                @php $found = true; @endphp
                             @endif
                         @endforeach
-                    </td>
-                </tr>
-            @endif
-        @endforeach
-        @if (!$patient->measurements || !count($patient->measurements) === 0)
-            <tr>
-                <td class="text-secondary p-0 border-0">
-                    No items to show
+                    </div>
+                </td>
+                {{--                    <td colspan="px-2">--}}
+                {{--                        <?php--}}
+                {{--                        $stamps = ['has_been_stamped_by_mcp', 'has_been_stamped_by_non_hcp', 'has_been_stamped_by_rme', 'has_been_stamped_by_rmm'];--}}
+                {{--                        $isStamped = false;--}}
+                {{--                        foreach ($stamps as $stamp) {--}}
+                {{--                            if ($measurement->{$stamp}) {--}}
+                {{--                                $isStamped = true;--}}
+                {{--                            }--}}
+                {{--                        }--}}
+                {{--                        ?>--}}
+                {{--                        @if ($isStamped)--}}
+                {{--                            ✓--}}
+                {{--                        @endif--}}
+                {{--                    </td>--}}
+                @php $rowSpan = 0 @endphp
+                @foreach($careMonth->entries() as $entry)
+                    @if(friendly_date($entry->effective_date) == friendly_date($measurement->effective_date))
+                        @php $rowSpan = $rowSpan + 1; @endphp
+                    @endif
+                @endforeach
+                <td class="px-4">
+                    <div class="">
+                        @foreach($careMonth->entries as $entry)
+                            @if(friendly_date($entry->effective_date) == friendly_date($measurement->effective_date))
+                                <div class="d-flex align-items-start">
+                                    <span class="mr-2">{{$entry->time_in_seconds/60}}m: </span>
+                                    <div>{!!  $entry->content_text  !!}</div>
+                                </div>
+                            @endif
+                        @endforeach
+                    </div>
                 </td>
             </tr>
         @endif
+    @endforeach
+    @if (!$patient->measurements || !count($patient->measurements) === 0)
+        <tr>
+            <td class="text-secondary p-0 border-0">
+                No items to show
+            </td>
+        </tr>
+    @endif
     </tbody>
 </table>

+ 6 - 10
resources/views/app/patient/care-month/partials/print/rm-reasons.blade.php

@@ -1,11 +1,7 @@
 <h6 class="font-weight-bold">Diagnosis</h6>
-<table class="table table-striped table-sm table-bordered mt-2 mb-0">
-    <tr>
-        <td>
-            @include('app.patient.partials.rm-reasons-print-display', [
-                'recordType' => 'CARE_MONTH',
-                'record' => $careMonth,
-            ])
-        </td>
-    </tr>
-</table>
+
+@include('app.patient.partials.rm-reasons-print-display', [
+    'recordType' => 'CARE_MONTH',
+    'record' => $careMonth,
+])
+

+ 49 - 27
resources/views/app/patient/care-month/print.blade.php

@@ -1,13 +1,14 @@
-@extends('layouts.print2')
+@extends('layouts.print')
 
 @section('content')
     <style>
         html,
         body {
             height: max-content;
-            display:flex;
+            display: flex;
             margin: auto;
         }
+
         #printableScreen {
             width: 11in;
         }
@@ -37,7 +38,8 @@
         <div
             style="width: 100%  !important; background-color: black !important; color: snow  !important">
             <div class="p-3 text-right">
-                <h3 style="font-weight: bolder; font-size: 18px; line-height:18px; margin:0px;">Remote Patient Monitoring</h3>
+                <h3 style="font-weight: bolder; font-size: 18px; line-height:18px; margin:0px;">Remote Patient
+                    Monitoring</h3>
             </div>
         </div>
         <div>
@@ -59,7 +61,7 @@
                     <td><b>Measurement Period:</b> {{friendly_month($careMonth->start_date)}}</td>
                 </tr>
                 <tr>
-                    <td><b>Date of Enrollment:</b> {{friendly_month($careMonth->enrolled_in_rm_at)}}</td>
+                    <td><b>Date of Enrollment:</b> {{friendly_month($careMonth->client->enrolled_in_rm_at)}}</td>
                     <td><b>Consent Received:</b> Yes</td>
                 </tr>
             </table>
@@ -80,8 +82,10 @@
         </div>
 
         <div>
-            <h3>Remote Monitoring Measurements:</h3>
-            @include('app.patient.care-month._vitals_graph_unified')
+            <h3 style="font-weight: bolder; font-size: 18px; line-height:18px; margin:0px;" class="mt-4 mb-3"><b>Remote
+                    Monitoring Measurements:</b>
+{{--            @include('app.patient.care-month._vitals_graph_unified')--}}
+            @include('app.patient.care-month.partials.print.chart')
         </div>
 
         <div>
@@ -93,45 +97,63 @@
         </div>
 
         <div>
-            <h3>Devices</h3>
-            <ul>
+            <h3 style="font-weight: bolder; font-size: 18px; line-height:18px; margin:0px;" class="mb-2"><b>Devices:</b>
+            </h3>
+            <ol>
                 @foreach($careMonth->client->devices as $device)
                     @if($device->device->category == 'BP')
-                        <ol>Cellular BP Cuff: IMEI# {{$device->device->imei}}</ol>
+                        <li>Cellular BP Cuff: IMEI# {{$device->device->imei}}</li>
                     @endif
                     @if($device->device->category == 'WEIGHT')
-                        <ol>Cellular Weight Scale: IMEI# {{$device->device->imei}}</ol>
+                        <li>Cellular Weight Scale: IMEI# {{$device->device->imei}}</li>
                     @endif
                 @endforeach
-            </ul>
+            </ol>
         </div>
 
         <div>
-            <h3>Signature: </h3>
-            <table>
-                <tr>
-                    <td>Date of Service</td>
-                    <td>Service</td>
-                    <td>Place of Service</td>
+            <h3 style="font-weight: bolder; font-size: 18px; line-height:18px; margin:0px;" class="mb-3">
+                <b>Signature:</b>
+            </h3>
+
+            <table class="table table-sm">
+                <tr class="bg-light">
+                    <th>Date of Service</th>
+                    <th>Service</th>
+                    <th>Place of Service</th>
                 </tr>
                 <tr>
-                    <td>12/31/2024</td>
+                    <td>{{$careMonth->mcpRmGenericBill? friendly_date($careMonth->mcpRmGenericBill->signed_by_generic_pro_at): ''}}</td>
                     <td>Remote Patient Monitoring</td>
-                    <td>133 Rollins Ave, Suite 3, Rockville, MD 20852</td>
+                    <td>{{$careMonth->companyLocation ? $careMonth->companyLocation->format()  : '-'}}</td>
                 </tr>
-                <tr>
-                    <td>Total Time Spent</td>
-                    <td>Provider(HCP)</td>
-                    <td>Signature</td>
+                <tr class="bg-light">
+                    <th>Total Time Spent</th>
+                    <th>Provider(HCP)</th>
+                    <th>Signature</th>
                 </tr>
                 <tr>
-                    <td>42 Minutes</td>
-                    <td>Lilieth Poleon, FNP-C</td>
-                    <td>Signed</td>
+                    <td>{{$careMonth->rm_total_time_in_seconds_by_mcp/60}} Minutes</td>
+                    <td>
+                        @if($careMonth->mcpPro)
+                        {{$careMonth->mcpPro->displayName()}}
+                        @endif
+                    </td>
+                    <td>
+                        @if($careMonth->mcpRmGenericBill && $careMonth->mcpRmGenericBill->is_signed_by_generic_pro)
+                            Signed
+                        @else
+                            -
+                        @endif
+
+                    </td>
                 </tr>
             </table>
             <div>
-                Signed electronically on 12/31/2024 11:06 AM EST
+                Signed electronically on
+                @if($careMonth->mcpRmGenericBill)
+                    {{friendlier_date_time($careMonth->mcpRmGenericBill->signed_by_generic_pro_at)}}
+                @endif
             </div>
         </div>
     </div>

+ 16 - 18
resources/views/app/patient/partials/rm-reasons-print-display.blade.php

@@ -58,25 +58,23 @@ if($recordType === 'NOTE'){
 }
 ?>
 <div>
-	<div class="d-flex">
+	<div>
 		<?php $emptyICDs = true; ?>
-		<ol class="pl-3 mb-2">
-			@foreach($displayData as $rmKey=>$rmData)
-				<?php
-				$emptyICD = true;
-				if (!empty($rmData['reason']) || !empty($rmData['description'])) {
-					$emptyICDs = false;
-					$emptyICD = false;
-				}
-				?>
-				@if(!$emptyICD)
-					<li  style="margin-bottom: 10px;">
-					{{$rmData['reason']}} 
-					@if(!empty($rmData['description']))({{ $rmData['description'] }})@endif
-					</li>
-				@endif
-			@endforeach
-		</ol>
+        @foreach($displayData as $rmKey=>$rmData)
+                <?php
+                $emptyICD = true;
+                if (!empty($rmData['reason']) || !empty($rmData['description'])) {
+                    $emptyICDs = false;
+                    $emptyICD = false;
+                }
+                ?>
+            @if(!$emptyICD)
+                <div>
+                    {{$rmData['reason']}}
+                    @if(!empty($rmData['description']))({{ $rmData['description'] }})@endif
+                </div>
+            @endif
+        @endforeach
 		@if($emptyICDs)
 			Relevant RM reason(s) not specified.
 		@endif

+ 1 - 3
resources/views/layouts/print.blade.php

@@ -26,6 +26,7 @@
     {{-- inline bootstrap datepicker --}}
 {{--    <link href='/bootstrap-datepicker/css/bootstrap-datepicker.standalone.min.css' rel="stylesheet">
     <script src='/bootstrap-datepicker/js/bootstrap-datepicker.min.js'></script>--}}
+    <script src="/js/jquery-3.5.1.min.js"></script>
 
     <link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
     {{-- mc initializers --}}
@@ -40,13 +41,10 @@
 
     <main role="main" class="stag-content px-0 mcp-theme-1">
         @yield('content')
-
     </main><!-- /.container -->
 
     <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/dt-1.10.24/fc-3.3.2/fh-3.1.8/datatables.min.css"/>
 
-
-
 </body>
 
 </html>