Ver código fonte

Care month single - tabs for calendar/graph

Vijayakrishnan 3 anos atrás
pai
commit
d093cf8b42

+ 312 - 427
resources/views/app/patient/care-month/dashboard.blade.php

@@ -290,480 +290,365 @@
             <div class="col-12">
                 <div class="mt-0">
 
-                    <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="vitalsGraphComponent" class="stag-chart mb-4">
-                        <h4 class="font-weight-bold mb-1 text-secondary font-size-14 text-center">Blood Pressure</h4>
-                        <div id="bp-chart" class="mb-4">BP Graph</div>
-                        <hr class="m-neg-4">
-                        <h4 class="font-weight-bold mb-1 text-secondary font-size-14 text-center">Weight</h4>
-                        <div id="weight-chart">Weight Graph</div>
-                    </div>
+                    <div class="mb-2">
+                        <h6 class="mb-3 font-weight-bold text-dark">Measurements</h6>
+                        <div class="row mb-3">
+                            <div class="col-9">
+                                <div class="d-flex align-items-baseline mb-3" tab-links>
+                                    <a class="tab-link-active" href="#" tab-link="measurements-calendar">Calendar</a>
+                                    <a class="" href="#" tab-link="measurements-graph">Graph</a>
+                                </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');
+                                <div class="cm-tab" tab-key="measurements-calendar">
+                                    <div id="caremonth-measurements-calendar-{{$calendarID}}" class="caremonth-measurements-calendar">
 
-                    $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');
-                    }
+                                    </div>
+                                </div>
 
-                    /** @var \App\Models\Client $patient */
+                                <div class="d-none cm-tab border pr-4" tab-key="measurements-graph">
+                                    <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="vitalsGraphComponent" class="stag-chart mb-4 pt-3">
+                                        <h4 class="font-weight-bold mb-1 text-secondary font-size-14 text-center">Blood Pressure</h4>
+                                        <div id="bp-chart" class="mb-4">BP Graph</div>
+                                        <hr class="my-3">
+                                        <h4 class="font-weight-bold mb-1 text-secondary font-size-14 text-center">Weight</h4>
+                                        <div id="weight-chart">Weight Graph</div>
+                                    </div>
 
-                    // BP
-                    $bpMeasurements = $patient->getNonZeroBpMeasurements->toArray();
-                    $weightMeasurements = $patient->getNonZeroWeightMeasurements->toArray();
+                                    <?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');
 
-                    $bpData = [];
-                    $weightData = [];
+                                    $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');
+                                    }
 
-                    for ($i=0; $i<count($dates); $i++) {
+                                    /** @var \App\Models\Client $patient */
 
-                        $date = $dates[$i];
+                                    // BP
+                                    $bpMeasurements = $patient->getNonZeroBpMeasurements->toArray();
+                                    $weightMeasurements = $patient->getNonZeroWeightMeasurements->toArray();
 
-                        // 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;
-                        }
+                                    $bpData = [];
+                                    $weightData = [];
 
+                                    for ($i=0; $i<count($dates); $i++) {
 
-                        if ($bp) {
-                            $bpData[] = [
-                                "date" => $date,
-                                "sbp" => $bp["sbp_mm_hg"],
-                                "dbp" => $bp["dbp_mm_hg"]
-                            ];
-                        }
+                                        $date = $dates[$i];
 
-                        // 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"]
-                            ];
-                        }
+                                        // 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;
+                                        }
 
-                    }
 
-                    $bpDates = [];
-                    $sbpValues = [];
-                    $dbpValues = [];
-                    for ($i = 0; $i < count($bpData); $i++) {
-                        $bpDates[] = $bpData[$i]['date'];
-                        $sbpValues[] = $bpData[$i]['sbp'];
-                        $dbpValues[] = $bpData[$i]['dbp'];
-                    }
+                                        if ($bp) {
+                                            $bpData[] = [
+                                                "date" => $date,
+                                                "sbp" => $bp["sbp_mm_hg"],
+                                                "dbp" => $bp["dbp_mm_hg"]
+                                            ];
+                                        }
 
-                    $weightDates = [];
-                    $weightValues = [];
-                    for ($i = 0; $i < count($weightData); $i++) {
-                        $weightDates[] = $weightData[$i]['date'];
-                        $weightValues[] = $weightData[$i]['weight'];
-                    }
+                                        // 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"]
+                                            ];
+                                        }
 
-                    ?>
-
-                    <script>
-                        (function() {
-                            function init() {
-                                bpChart();
-                                weightChart();
-                            }
-                            function bpChart() {
-                                var chart = c3.generate({
-                                    bindto: '#bp-chart',
-                                    data: {
-                                        x: 'x',
-                                        // xFormat: '%Y%m%d', // 'xFormat' can be used as custom format of 'x'
-                                        columns: [
-                                            ['x', <?= implode(", ", array_map(function($_x) { return "'" . $_x . "'"; }, $bpDates)) ?>],
-                                            ['Systolic BP', <?= implode(", ", array_map(function($_x) { return "'" . $_x . "'"; }, $sbpValues)) ?>],
-                                            ['Diastolic BP', <?= implode(", ", array_map(function($_x) { return "'" . $_x . "'"; }, $dbpValues)) ?>]
-                                        ]
-                                    },
-                                    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
-                                        },
-                                    },
-                                    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'}
-                                    ]
-                                });
-                            }
-                            function weightChart() {
-                                var chart = c3.generate({
-                                    bindto: '#weight-chart',
-                                    data: {
-                                        x: 'x',
-                                        columns: [
-                                            ['x', <?= implode(", ", array_map(function($_x) { return "'" . $_x . "'"; }, $weightDates)) ?>],
-                                            ['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: 'Weight (lbs)',
-                                                position: 'outer-middle'
-                                            },
-                                            min: 70,
-                                            max: 250
-                                        },
-                                    },
-                                    regions: [
-                                        // {axis: 'y', start: 100, end: 140, class: 'safe-region', label: 'Safe Weight: 100 to 140 lbs'},
-                                    ]
-                                });
-                            }
-                            addMCInitializer('vitalsGraph', init, '#vitalsGraphComponent');
-                        }).call(window);
-                    </script>
-
-                    <hr class="my-3 m-neg-4">
-
-                    <div class="d-flex align-items-center mb-2">
-                        <h6 class="my-0 font-weight-bold text-dark">Measurements</h6>
-                        <!--<span class="mx-2 text-secondary">|</span>
-                        <div moe>
-                            <a start show class="py-0 font-weight-normal">Add</a>
-                            <form url="/api/measurement/create">
-                                <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
-                                <div class="mb-2">
-                                    <input required autofocus type="text" class="form-control form-control-sm" name="label" value="" placeholder="Type">
-                                </div>
-                                <div class="mb-2">
-                                    <input required type="text" class="form-control form-control-sm" name="value" value="" placeholder="Value">
-                                </div>
-                                <div class="mb-2">
-                                    <input required type="date" class="form-control form-control-sm" name="effectiveDate" max="{{ date('Y-m-d') }}" value="{{ date('Y-m-d') }}">
-                                </div>
-                                <div class="d-flex align-items-center">
-                                    <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
-                                    <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
-                                </div>
-                            </form>
-                        </div>-->
-                        @if(0 && $pro->pro_type === 'ADMIN')
-                            <span class="mx-2 text-secondary">|</span>
-                            <div moe>
-                                <a start show class="py-0 font-weight-normal text-secondary">+ BP BDT Measurement</a>
-                                <form url="/api/bdtMeasurement/create">
-                                    <div class="mb-2">
-                                        <input autofocus type="text" class="form-control form-control-sm" name="imei" value="987987987983" placeholder="imei">
-                                    </div>
-                                    <div class="mb-2">
-                                        <input type="text" class="form-control form-control-sm" name="ts" value="1600727786754" placeholder="ts">
-                                    </div>
-                                    <div class="mb-2">
-                                        <input type="text" class="form-control form-control-sm" name="batteryVoltage" value="6308" placeholder="batteryVoltage">
-                                    </div>
-                                    <div class="mb-2">
-                                        <input type="text" class="form-control form-control-sm" name="signalStrength" value="85" placeholder="signalStrength">
-                                    </div>
-                                    <div class="mb-2">
-                                        <input type="text" class="form-control form-control-sm" name="valueTare" value="" placeholder="valueTare">
-                                    </div>
-                                    <div class="mb-2">
-                                        <input type="text" class="form-control form-control-sm" name="valueWeight" value="" placeholder="valueWeight">
-                                    </div>
-                                    <div class="mb-2">
-                                        <input type="text" class="form-control form-control-sm" name="valueSystolic" value="20700" placeholder="valueSystolic">
-                                    </div>
-                                    <div class="mb-2">
-                                        <input type="text" class="form-control form-control-sm" name="valueDiastolic" value="9700" placeholder="valueDiastolic">
-                                    </div>
-                                    <div class="mb-2">
-                                        <input type="text" class="form-control form-control-sm" name="valuePulse" value="64" placeholder="valuePulse">
-                                    </div>
-                                    <div class="mb-2">
-                                        <input type="text" class="form-control form-control-sm" name="valueUnit" value="" placeholder="valueUnit">
-                                    </div>
-                                    <div class="mb-2">
-                                        <input type="text" class="form-control form-control-sm" name="valueIrregular" value="0" placeholder="valueIrregular">
-                                    </div>
-                                    <div class="mb-2">
-                                        <input type="text" class="form-control form-control-sm" name="rssi" value="71" placeholder="rssi">
-                                    </div>
-                                    <div class="mb-2">
-                                        <input type="text" class="form-control form-control-sm" name="deviceId" value="86011204403081" placeholder="deviceId">
-                                    </div>
-                                    <input type="hidden" name="secret" value="LTZS20QAFE">
-                                    <div class="d-flex align-items-center">
-                                        <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
-                                        <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
-                                    </div>
-                                </form>
-                            </div>
-                            <span class="mx-2 text-secondary">|</span>
-                            <div moe>
-                                <a start show class="py-0 font-weight-normal text-secondary">+ Weight BDT Measurement</a>
-                                <form url="/api/bdtMeasurement/create">
-                                    <div class="mb-2">
-                                        <input autofocus type="text" class="form-control form-control-sm" name="imei" value="987987987984" placeholder="imei">
-                                    </div>
-                                    <div class="mb-2">
-                                        <input type="text" class="form-control form-control-sm" name="ts" value="1600727786754" placeholder="ts">
-                                    </div>
-                                    <div class="mb-2">
-                                        <input type="text" class="form-control form-control-sm" name="batteryVoltage" value="6308" placeholder="batteryVoltage">
-                                    </div>
-                                    <div class="mb-2">
-                                        <input type="text" class="form-control form-control-sm" name="signalStrength" value="85" placeholder="signalStrength">
-                                    </div>
-                                    <div class="mb-2">
-                                        <input type="text" class="form-control form-control-sm" name="valueTare" value="0" placeholder="valueTare">
-                                    </div>
-                                    <div class="mb-2">
-                                        <input type="text" class="form-control form-control-sm" name="valueWeight" value="61400" placeholder="valueWeight">
-                                    </div>
-                                    <div class="mb-2">
-                                        <input type="text" class="form-control form-control-sm" name="valueSystolic" value="" placeholder="valueSystolic">
-                                    </div>
-                                    <div class="mb-2">
-                                        <input type="text" class="form-control form-control-sm" name="valueDiastolic" value="" placeholder="valueDiastolic">
-                                    </div>
-                                    <div class="mb-2">
-                                        <input type="text" class="form-control form-control-sm" name="valuePulse" value="" placeholder="valuePulse">
-                                    </div>
-                                    <div class="mb-2">
-                                        <input type="text" class="form-control form-control-sm" name="valueUnit" value="1" placeholder="valueUnit">
-                                    </div>
-                                    <div class="mb-2">
-                                        <input type="text" class="form-control form-control-sm" name="valueIrregular" value="" placeholder="valueIrregular">
-                                    </div>
-                                    <div class="mb-2">
-                                        <input type="text" class="form-control form-control-sm" name="rssi" value="78" placeholder="rssi">
-                                    </div>
-                                    <div class="mb-2">
-                                        <input type="text" class="form-control form-control-sm" name="deviceId" value="86528404866623" placeholder="deviceId">
-                                    </div>
-                                    <input type="hidden" name="secret" value="LTZS20QAFE">
-                                    <div class="d-flex align-items-center">
-                                        <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
-                                        <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
-                                    </div>
-                                </form>
-                            </div>
-                        @endif
-                    </div>
-                    <div class="row mb-3 d-none">
-                        <div class="col-8">
-                            <div id="caremonth-measurements-calendar-{{$calendarID}}" class="caremonth-measurements-calendar">
+                                    }
 
+                                    $bpDates = [];
+                                    $sbpValues = [];
+                                    $dbpValues = [];
+                                    for ($i = 0; $i < count($bpData); $i++) {
+                                        $bpDates[] = $bpData[$i]['date'];
+                                        $sbpValues[] = $bpData[$i]['sbp'];
+                                        $dbpValues[] = $bpData[$i]['dbp'];
+                                    }
+
+                                    $weightDates = [];
+                                    $weightValues = [];
+                                    for ($i = 0; $i < count($weightData); $i++) {
+                                        $weightDates[] = $weightData[$i]['date'];
+                                        $weightValues[] = $weightData[$i]['weight'];
+                                    }
+
+                                    ?>
+
+                                    <script>
+                                        (function() {
+                                            function init() {
+                                                bpChart();
+                                                weightChart();
+                                            }
+                                            function bpChart() {
+                                                window.vgBPChart = c3.generate({
+                                                    bindto: '#bp-chart',
+                                                    data: {
+                                                        x: 'x',
+                                                        // xFormat: '%Y%m%d', // 'xFormat' can be used as custom format of 'x'
+                                                        columns: [
+                                                            ['x', <?= implode(", ", array_map(function($_x) { return "'" . $_x . "'"; }, $bpDates)) ?>],
+                                                            ['Systolic BP', <?= implode(", ", array_map(function($_x) { return "'" . $_x . "'"; }, $sbpValues)) ?>],
+                                                            ['Diastolic BP', <?= implode(", ", array_map(function($_x) { return "'" . $_x . "'"; }, $dbpValues)) ?>]
+                                                        ]
+                                                    },
+                                                    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
+                                                        },
+                                                    },
+                                                    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'}
+                                                    ]
+                                                });
+                                            }
+                                            function weightChart() {
+                                                window.vgWtChart = c3.generate({
+                                                    bindto: '#weight-chart',
+                                                    data: {
+                                                        x: 'x',
+                                                        columns: [
+                                                            ['x', <?= implode(", ", array_map(function($_x) { return "'" . $_x . "'"; }, $weightDates)) ?>],
+                                                            ['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: 'Weight (lbs)',
+                                                                position: 'outer-middle'
+                                                            },
+                                                            min: 70,
+                                                            max: 250
+                                                        },
+                                                    },
+                                                    regions: [
+                                                        // {axis: 'y', start: 100, end: 140, class: 'safe-region', label: 'Safe Weight: 100 to 140 lbs'},
+                                                    ]
+                                                });
+                                            }
+                                            addMCInitializer('vitalsGraph', init, '#vitalsGraphComponent');
+                                        }).call(window);
+                                    </script>
+                                </div>
                             </div>
-                        </div>
-                        <div class="col-4 px-0">
+                            <div class="col-3 px-0">
 
-                            <div class="mt-2">
-                                <?php $daysDiff = -1; ?>
-                                @if($patient->most_recent_completed_mcp_note_date)
-                                    <?php
+                                <div class="mt-2">
+                                    <?php $daysDiff = -1; ?>
+                                    @if($patient->most_recent_completed_mcp_note_date)
+                                        <?php
                                         $careMonthLastDay = date_add(date_create($careMonth->start_date), date_interval_create_from_date_string("1 month"));
                                         $careMonthLastDay = date_sub($careMonthLastDay, date_interval_create_from_date_string("1 day"));
                                         $daysDiff = date_diff($careMonthLastDay, date_create($patient->most_recent_completed_mcp_note_date))->days;
-                                    ?>
+                                        ?>
+                                    @endif
+                                    <span class="font-weight-bold text-secondary">Last Visit:</span>
+                                    <b class="{{$daysDiff === -1 ? 'text-secondary' : ($daysDiff <= 90 ? 'text-success' : 'text-warning-mellow')}}">
+                                        {{friendly_date($patient->most_recent_completed_mcp_note_date)}}
+                                        @if($daysDiff !== -1)
+                                            @if($daysDiff > 90)
+                                                <i class="fa fa-exclamation-triangle"></i>
+                                                <span class="ml-1 text-secondary text-sm font-weight-normal">({{$daysDiff}} days ago)</span>
+                                            @else
+                                                <i class="fa fa-check"></i>
+                                            @endif
+                                        @endif
+                                    </b>
+                                </div>
+
+                                <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'}}">
+                                        {{$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>
+                                    </b>
+                                    @if($careMonth->number_of_days_with_remote_measurements < 16)
+                                        <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;">
+                                                <input type="hidden" name="uid" value="{{ $patient->uid }}">
+                                                <div class="mb-2">
+                                                    <label for="" class="text-sm text-secondary mb-1">Cell Number</label>
+                                                    <input type="text" class="form-control form-control-sm" name="cellNumber" value="{{$patient->cell_number}}">
+                                                </div>
+                                                <div class="mb-2">
+                                                    <label for="" class="text-sm text-secondary mb-1">Message</label>
+                                                    <textarea rows="5" class="form-control form-control-sm" name="message">Please use your weight-scale and BP meter more often to stay safe during this pandemic! Leadership Health.</textarea>
+                                                </div>
+                                                <div class="d-flex align-items-center">
+                                                    <button class="btn btn-sm btn-primary mr-2" submit="">Send</button>
+                                                    <button class="btn btn-sm btn-default mr-2 border" cancel="">Cancel</button>
+                                                </div>
+                                            </form>
+                                        </div>
+                                    @endif
+                                </div>
+                                @if($careMonth->number_of_days_with_remote_measurements < 16)
+                                    <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.
+                                    </div>
                                 @endif
-                                <span class="font-weight-bold text-secondary">Last Visit:</span>
-                                <b class="{{$daysDiff === -1 ? 'text-secondary' : ($daysDiff <= 90 ? 'text-success' : 'text-warning-mellow')}}">
-                                    {{friendly_date($patient->most_recent_completed_mcp_note_date)}}
-                                    @if($daysDiff !== -1)
-                                        @if($daysDiff > 90)
+
+                                <div class="mt-2">
+                                    <?php $spoken = $careMonth->has_anyone_interacted_with_client_about_rm_outside_note; ?>
+                                    <span class="font-weight-bold text-secondary">MCP spoke to patient:</span>
+                                    <b class="{{$spoken ? 'text-success' : 'text-warning-mellow'}}">
+                                        {{$spoken ? 'Yes' : 'No'}}
+                                        @if(!$spoken)
                                             <i class="fa fa-exclamation-triangle"></i>
-                                            <span class="ml-1 text-secondary text-sm font-weight-normal">({{$daysDiff}} days ago)</span>
                                         @else
                                             <i class="fa fa-check"></i>
                                         @endif
+                                    </b>
+                                    @if($careMonth->mcp && $pro->id === $careMonth->mcp->id)
+                                        <div moe relative class="ml-2">
+                                            <a href="#" start show class="text-sm">Toggle</a>
+                                            <form url="/api/careMonth/setHasAnyoneInteractedWithClientAboutRmOutsideNoteTo{{$spoken ? 'False' : 'True'}}" right>
+                                                <input type="hidden" name="uid" value="{{$careMonth->uid}}">
+                                                <p>Set to {{$spoken ? 'No' : 'Yes'}}?</p>
+                                                <div class="d-flex align-items-center">
+                                                    <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
+                                                    <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
+                                                </div>
+                                            </form>
+                                        </div>
                                     @endif
-                                </b>
-                            </div>
+                                </div>
 
-                            <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'}}">
-                                    {{$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>
-                                </b>
-                                @if($careMonth->number_of_days_with_remote_measurements < 16)
+                                <div class="mt-2">
+                                    <?php
+                                    $minsBilled = 0;
+                                    if($careMonth->mcp && $pro->id === $careMonth->mcp->id) {
+                                        $minsBilled = $careMonth->rm_total_time_in_seconds_by_mcp;
+                                    }
+                                    elseif($careMonth->rmm && $pro->id === $careMonth->rmm->id) {
+                                        $minsBilled = $careMonth->rm_total_time_in_seconds_by_rmm_pro;
+                                    }
+                                    elseif($careMonth->rme && $pro->id === $careMonth->rme->id) {
+                                        $minsBilled = $careMonth->rm_total_time_in_seconds_by_rme_pro;
+                                    }
+                                    $minsBilled = floor($minsBilled / 60);
+                                    ?>
+                                    <span class="font-weight-bold text-secondary">Mins. I have billed:</span>
+                                    <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>
+                                    </b>
                                     <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;">
-                                            <input type="hidden" name="uid" value="{{ $patient->uid }}">
+                                        <a href="#" start show class="text-sm">+ Entry</a>
+                                        <form url="/api/careMonthEntry/createForRm" right>
+                                            <input type="hidden" name="careMonthUid" value="{{$careMonth->uid}}">
+                                            <input type="hidden" name="proUid" value="{{$pro->uid}}">
                                             <div class="mb-2">
-                                                <label for="" class="text-sm text-secondary mb-1">Cell Number</label>
-                                                <input type="text" class="form-control form-control-sm" name="cellNumber" value="{{$patient->cell_number}}">
+                                                <label class="mb-1 text-secondary">Effective Date *</label>
+                                                <input type="date" value="{{date('Y-m-d')}}"
+                                                       class="form-control form-control-sm" name="effectiveDate"
+                                                       required>
                                             </div>
                                             <div class="mb-2">
-                                                <label for="" class="text-sm text-secondary mb-1">Message</label>
-                                                <textarea rows="5" class="form-control form-control-sm" name="message">Please use your weight-scale and BP meter more often to stay safe during this pandemic! Leadership Health.</textarea>
+                                                <label class="mb-1 text-secondary">Time (mins) *</label>
+                                                <input autofocus type="number"
+                                                       class="form-control form-control-sm" name="timeInMinutes"
+                                                       required>
                                             </div>
-                                            <div class="d-flex align-items-center">
-                                                <button class="btn btn-sm btn-primary mr-2" submit="">Send</button>
-                                                <button class="btn btn-sm btn-default mr-2 border" cancel="">Cancel</button>
+                                            <div class="mb-2">
+                                                <label class="mb-1 text-secondary">Memo</label>
+                                                <textarea class="form-control form-control-sm" name="contentText"
+                                                          placeholder="" rows="2"></textarea>
                                             </div>
-                                        </form>
-                                    </div>
-                                @endif
-                            </div>
-                            @if($careMonth->number_of_days_with_remote_measurements < 16)
-                                <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.
-                                </div>
-                            @endif
-
-                            <div class="mt-2">
-                                <?php $spoken = $careMonth->has_anyone_interacted_with_client_about_rm_outside_note; ?>
-                                <span class="font-weight-bold text-secondary">MCP spoke to patient:</span>
-                                <b class="{{$spoken ? 'text-success' : 'text-warning-mellow'}}">
-                                    {{$spoken ? 'Yes' : 'No'}}
-                                    @if(!$spoken)
-                                        <i class="fa fa-exclamation-triangle"></i>
-                                    @else
-                                        <i class="fa fa-check"></i>
-                                    @endif
-                                </b>
-                                @if($careMonth->mcp && $pro->id === $careMonth->mcp->id)
-                                    <div moe relative class="ml-2">
-                                        <a href="#" start show class="text-sm">Toggle</a>
-                                        <form url="/api/careMonth/setHasAnyoneInteractedWithClientAboutRmOutsideNoteTo{{$spoken ? 'False' : 'True'}}" right>
-                                            <input type="hidden" name="uid" value="{{$careMonth->uid}}">
-                                            <p>Set to {{$spoken ? 'No' : 'Yes'}}?</p>
                                             <div class="d-flex align-items-center">
                                                 <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
                                                 <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
                                             </div>
                                         </form>
                                     </div>
-                                @endif
-                            </div>
-
-                            <div class="mt-2">
-                                <?php
-                                $minsBilled = 0;
-                                if($careMonth->mcp && $pro->id === $careMonth->mcp->id) {
-                                    $minsBilled = $careMonth->rm_total_time_in_seconds_by_mcp;
-                                }
-                                elseif($careMonth->rmm && $pro->id === $careMonth->rmm->id) {
-                                    $minsBilled = $careMonth->rm_total_time_in_seconds_by_rmm_pro;
-                                }
-                                elseif($careMonth->rme && $pro->id === $careMonth->rme->id) {
-                                    $minsBilled = $careMonth->rm_total_time_in_seconds_by_rme_pro;
-                                }
-                                $minsBilled = floor($minsBilled / 60);
-                                ?>
-                                <span class="font-weight-bold text-secondary">Mins. I have billed:</span>
-                                <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>
-                                </b>
-                                <div moe relative class="ml-2">
-                                    <a href="#" start show class="text-sm">+ Entry</a>
-                                    <form url="/api/careMonthEntry/createForRm" right>
-                                        <input type="hidden" name="careMonthUid" value="{{$careMonth->uid}}">
-                                        <input type="hidden" name="proUid" value="{{$pro->uid}}">
-                                        <div class="mb-2">
-                                            <label class="mb-1 text-secondary">Effective Date *</label>
-                                            <input type="date" value="{{date('Y-m-d')}}"
-                                                   class="form-control form-control-sm" name="effectiveDate"
-                                                   required>
-                                        </div>
-                                        <div class="mb-2">
-                                            <label class="mb-1 text-secondary">Time (mins) *</label>
-                                            <input autofocus type="number"
-                                                   class="form-control form-control-sm" name="timeInMinutes"
-                                                   required>
-                                        </div>
-                                        <div class="mb-2">
-                                            <label class="mb-1 text-secondary">Memo</label>
-                                            <textarea class="form-control form-control-sm" name="contentText"
-                                                      placeholder="" rows="2"></textarea>
-                                        </div>
-                                        <div class="d-flex align-items-center">
-                                            <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
-                                            <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
-                                        </div>
-                                    </form>
                                 </div>
-                            </div>
 
-                            @if(($daysDiff !== -1 && $daysDiff <= 90) &&
-                                $careMonth->number_of_days_with_remote_measurements >= 16 &&
-                                $careMonth->has_anyone_interacted_with_client_about_rm_outside_note &&
-                                $minsBilled >= 20)
-                                <div class="mt-2 border border-info p-2">
-                                    @include('app.rm-bills.inline', ['patient' => $patient, 'entityType' => 'CareMonth', 'entityUid' => $careMonth->uid, 'label' => 'RM'])
-                                </div>
-                            @endif
+                                @if(($daysDiff !== -1 && $daysDiff <= 90) &&
+                                    $careMonth->number_of_days_with_remote_measurements >= 16 &&
+                                    $careMonth->has_anyone_interacted_with_client_about_rm_outside_note &&
+                                    $minsBilled >= 20)
+                                    <div class="mt-2 border border-info p-2">
+                                        @include('app.rm-bills.inline', ['patient' => $patient, 'entityType' => 'CareMonth', 'entityUid' => $careMonth->uid, 'label' => 'RM'])
+                                    </div>
+                                @endif
 
-                            <div class="mt-2">
-                                {{-- rm reasons --}}
-                                <div class="mb-2">
-                                    @include('app/patient/care-month/rm-reasons')
+                                <div class="mt-2">
+                                    {{-- rm reasons --}}
+                                    <div class="mb-2">
+                                        @include('app/patient/care-month/rm-reasons')
+                                    </div>
                                 </div>
-                            </div>
 
-                            <div class="mb-2">
-                                @if($careMonth->rmBill && $careMonth->rmBill->code != 'RMB')
-                                    @if(true && 'TODO Check if MCP and echo as needed for rme/rmm')
+                                <div class="mb-2">
+                                    @if($careMonth->rmBill && $careMonth->rmBill->code != 'RMB')
+                                        @if(true && 'TODO Check if MCP and echo as needed for rme/rmm')
 
+                                        @endif
+                                        @if($performer->pro->id == $careMonth->mcp_pro_id)
+                                            Reimbursement: {{ $careMonth->rmBill->hcp_payment_amount }}
+                                        @endif
                                     @endif
-                                    @if($performer->pro->id == $careMonth->mcp_pro_id)
-                                        Reimbursement: {{ $careMonth->rmBill->hcp_payment_amount }}
-                                    @endif
-                                @endif
+                                </div>
                             </div>
                         </div>
                     </div>

+ 5 - 2
resources/views/layouts/template.blade.php

@@ -407,8 +407,11 @@
                     let tab = $(this).attr('tab-link');
                     $(this).siblings().removeClass('tab-link-active');
                     $(this).addClass('tab-link-active');
-                    $('.cm-tab').addClass('d-none');
-                    $('.cm-tab[tab-key="' + tab + '"]').removeClass('d-none');
+                    $(this).closest('[tab-links]').siblings('.cm-tab').addClass('d-none');
+                    $(this).closest('[tab-links]').siblings('.cm-tab[tab-key="' + tab + '"]').removeClass('d-none');
+                    // TODO: move to context
+                    if(window.vgBPChart) window.vgBPChart.flush();
+                    if(window.vgWtChart) window.vgWtChart.flush();
                     return false;
                 });
         });