Browse Source

fixed chat

= 1 tháng trước cách đây
mục cha
commit
1d855ea909

+ 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>

+ 20 - 10
resources/views/app/patient/care-month/partials/print/measurements.blade.php

@@ -30,7 +30,7 @@
                     @endif
                     EST
                 </td>
-                <td class="px-1 ">
+                <td class="px-1 text-nowrap">
                     <div class="text-nowrap">
                         @if ($measurement->is_cellular_zero)
                             <i class="font-size-11 fa fa-rss"></i>
@@ -43,13 +43,17 @@
                         @endif
                     </div>
                 </td>
-                <td class="px-1">{{ $measurement->label }}</td>
-                <td>
-                    @if($careMonth->mcpInteractionNote)
-                        $careMonth->mcpInteractionNote->method
-                    @else
-                        Audio call
-                    @endif
+                <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(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
+                    </div>
                 </td>
                 {{--                    <td colspan="px-2">--}}
                 {{--                        <?php--}}
@@ -65,12 +69,18 @@
                 {{--                            ✓--}}
                 {{--                        @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($entry->achieved_mcp_time_in_seconds > 0 && $entry->is_removed != true )
+                            @if(friendly_date($entry->effective_date) == friendly_date($measurement->effective_date))
                                 <div class="d-flex align-items-start">
-                                    <span class="mr-2">{{$entry->achieved_mcp_time_in_seconds/60}}m: </span>
+                                    <span class="mr-2">{{$entry->time_in_seconds/60}}m: </span>
                                     <div>{!!  $entry->content_text  !!}</div>
                                 </div>
                             @endif

+ 32 - 17
resources/views/app/patient/care-month/print.blade.php

@@ -61,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>
@@ -84,7 +84,8 @@
         <div>
             <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._vitals_graph_unified')--}}
+            @include('app.patient.care-month.partials.print.chart')
         </div>
 
         <div>
@@ -115,30 +116,44 @@
                 <b>Signature:</b>
             </h3>
 
-            <table>
-                <tr>
-                    <td>Date of Service</td>
-                    <td>Service</td>
-                    <td>Place of Service</td>
+            <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>

+ 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>