Parcourir la source

RPM manager - entries popup (wip)

Vijayakrishnan il y a 2 ans
Parent
commit
1256f34cba
1 fichiers modifiés avec 279 ajouts et 37 suppressions
  1. 279 37
      resources/views/app/practice-management/rpm-manager/index.blade.php

+ 279 - 37
resources/views/app/practice-management/rpm-manager/index.blade.php

@@ -10,6 +10,51 @@
     <script src="/c3/d3.v5.min.js" charset="utf-8"></script>
     <script src="/c3/c3.min.js"></script>
 
+    <?php
+    $careMonths = [];
+    foreach ($patients as $iPatient) {
+        if(!!$iPatient->entries_json) {
+            $iPatient->entries_json = json_decode($iPatient->entries_json);
+            $myEntries = [];
+            $otherEntries = [];
+            for ($i = 0; $i < count($iPatient->entries_json); $i++) {
+                if($iPatient->entries_json[$i]->proUid === $pro->uid) {
+                    $myEntries[] = $iPatient->entries_json[$i];
+                }
+                else {
+                    $otherEntries[] = $iPatient->entries_json[$i];
+                }
+            }
+            $iPatient->myEntries = $myEntries;
+            $iPatient->otherEntries = $otherEntries;
+        }
+        if(!!$iPatient->measurements_json) {
+            $iPatient->measurements_json = json_decode($iPatient->measurements_json);
+        }
+        if(!!$iPatient->measurements_bp_json) {
+            $iPatient->measurements_bp_json = json_decode($iPatient->measurements_bp_json);
+            for ($i = 0; $i < count($iPatient->measurements_bp_json); $i++) {
+                $timestampInSec = floor($iPatient->measurements_bp_json[$i]->ts / 1000);
+                $iPatient->measurements_bp_json[$i]->date_display = friendly_date_time_short_with_tz_from_timestamp($timestampInSec, 'EASTERN', '-', 'm/d/y');
+                $iPatient->measurements_bp_json[$i]->date_standard = friendly_date_time_short_with_tz_from_timestamp($timestampInSec, 'EASTERN', '-', 'Y-m-d');
+                $iPatient->measurements_bp_json[$i]->time_display = friendly_date_time_short_with_tz_from_timestamp($timestampInSec, 'EASTERN', '-', 'h:i A') . ' EST';
+            }
+        }
+        if(!!$iPatient->measurements_weight_json) {
+            $iPatient->measurements_weight_json = json_decode($iPatient->measurements_weight_json);
+            for ($i = 0; $i < count($iPatient->measurements_weight_json); $i++) {
+                $timestampInSec = floor($iPatient->measurements_weight_json[$i]->ts / 1000);
+                $iPatient->measurements_weight_json[$i]->date_display = friendly_date_time_short_with_tz_from_timestamp($timestampInSec, 'EASTERN', '-', 'm/d/y');
+                $iPatient->measurements_weight_json[$i]->date_standard = friendly_date_time_short_with_tz_from_timestamp($timestampInSec, 'EASTERN', '-', 'Y-m-d');
+                $iPatient->measurements_weight_json[$i]->time_display = friendly_date_time_short_with_tz_from_timestamp($timestampInSec, 'EASTERN', '-', 'h:i A') . ' EST';
+                $iPatient->measurements_weight_json[$i]->numericValue = round($iPatient->measurements_weight_json[$i]->numericValue, 1);
+            }
+        }
+        $iPatient->month_display = friendly_month($iPatient->care_month_start_date);
+        $careMonths[$iPatient->care_month_uid] = $iPatient;
+    }
+    ?>
+
     <div class="p-3 mcp-theme-1" id="practice-rpm-manager">
 
         <div class="card h-100">
@@ -94,7 +139,7 @@
                                 <th class="border-top-0 border-bottom-0"></th>
                                 <th class="border-top-0 border-bottom-0"></th>
                                 @if($viewingAs !== 'RME')
-                                    <th class="border-top-0 border-bottom-0 bg-aliceblue" colspan="2">Entries</th>
+                                    <th class="border-top-0 border-bottom-0 bg-aliceblue" colspan="{{$viewingAs === 'ADMIN' ? 2 : 1}}">Entries</th>
                                 @endif
                                 <th class="border-top-0 border-bottom-0"></th>
                                 @if($viewingAs !== 'RME')
@@ -125,7 +170,9 @@
 
                                 @if($viewingAs !== 'RME')
                                     <th class="border-bottom-0 border-top">Mine</th>
-                                    <th class="border-bottom-0 border-top">Others</th>
+                                    @if($viewingAs === 'ADMIN')
+                                        <th class="border-bottom-0 border-top">Others</th>
+                                    @endif
                                 @endif
 
                                 <th class="border-bottom-0 border-top">Comm.</th>
@@ -272,8 +319,42 @@
                                     </td>
 
                                     @if($viewingAs !== 'RME')
-                                        <td>my entries</td>
-                                        <td>other entries</td>
+                                        <td class="width-300px">
+                                            <div class="d-flex align-items-baseline">
+                                                @if(@$iPatient->myEntries && count($iPatient->myEntries))
+                                                    <div class="d-inline-flex align-items-baseline" title="{{$iPatient->myEntries[0]->proNameFirst}} {{$iPatient->myEntries[0]->proNameLast}}: {{strip_tags($iPatient->myEntries[0]->contentText)}}">
+                                                        <span>{{round($iPatient->myEntries[0]->timeInSeconds/30)}}m</span>
+                                                        <span class="ml-1 text-secondary text-sm">
+                                                            {{$iPatient->myEntries[0]->effectiveDate->month}}/{{$iPatient->myEntries[0]->effectiveDate->day}}/{{$iPatient->myEntries[0]->effectiveDate->year}}
+                                                        </span>
+                                                    </div>
+                                                @else
+                                                    <span class="text-secondary">None</span>
+                                                @endif
+                                                <span class="mx-1 text-secondary text-sm">|</span>
+                                                <a href="#" class="btn-my-entries-popup"
+                                                   data-uid="{{$iPatient->care_month_uid}}">All</a>
+                                            </div>
+                                        </td>
+                                        @if($viewingAs === 'ADMIN')
+                                            <td class="width-300px">
+                                                <div class="d-flex align-items-baseline">
+                                                    @if(@$iPatient->otherEntries && count($iPatient->otherEntries))
+                                                        <div class="d-inline-flex align-items-baseline" title="{{$iPatient->otherEntries[0]->proNameFirst}} {{$iPatient->otherEntries[0]->proNameLast}}: {{strip_tags($iPatient->otherEntries[0]->contentText)}}">
+                                                            <span>{{round($iPatient->otherEntries[0]->timeInSeconds/30)}}m</span>
+                                                            <span class="ml-1 text-secondary text-sm">
+                                                                {{$iPatient->otherEntries[0]->effectiveDate->month}}/{{$iPatient->otherEntries[0]->effectiveDate->day}}/{{$iPatient->otherEntries[0]->effectiveDate->year}}
+                                                            </span>
+                                                        </div>
+                                                    @else
+                                                        <span class="text-secondary">None</span>
+                                                    @endif
+                                                    <span class="mx-1 text-secondary text-sm">|</span>
+                                                    <a href="#" class="btn-other-entries-popup"
+                                                       data-uid="{{$iPatient->care_month_uid}}">All</a>
+                                                </div>
+                                            </td>
+                                        @endif
                                     @endif
 
                                     <td>
@@ -521,40 +602,66 @@
                 </form>
             </div>
         </div>
+        <div class="stag-popup tall draggable resizable mcp-theme-1"
+             update-parent
+             stag-popup-key="rpm-manager-my-entries-popup">
+            <div class="stag-popup-content p-0">
+                <h3 class="stag-popup-title mb-0 mt-3 mx-3 pb-0 border-bottom-0">
+                    <span id="rpm-manager-my-entries-popup-title">xxx</span>
+                    <a href="#" class="ml-auto text-secondary" onclick="return closeStagPopup()">
+                        <i class="fa fa-times-circle"></i>
+                    </a>
+                </h3>
+                <div class="stag-popup-content-inner">
+                    <div class="popup-content-container px-3">
+                        <h3 class="m-0 font-size-16" id="rpm-manager-my-entries-caremonth"></h3>
+                        <table class="table table-condensed table-sm table-bordered mt-3 cm-tab" id="rpm-manager-my-entries-matrix">
+                            <thead>
+                            <tr>
+                                <th class="text-secondary text-sm">Date</th>
+                                <th class="text-secondary text-sm">Minutes</th>
+                                <th class="text-secondary text-sm">Communicated</th>
+                                <th class="text-secondary text-sm">Comments</th>
+                                <th class="text-secondary text-sm"></th>
+                            </tr>
+                            </thead>
+                            <tbody></tbody>
+                        </table>
+                    </div>
+                </div>
+            </div>
+        </div>
+        <div class="stag-popup tall draggable resizable mcp-theme-1"
+             update-parent
+             stag-popup-key="rpm-manager-other-entries-popup">
+            <div class="stag-popup-content p-0">
+                <h3 class="stag-popup-title mb-0 mt-3 mx-3 pb-0 border-bottom-0">
+                    <span id="rpm-manager-other-entries-popup-title">xxx</span>
+                    <a href="#" class="ml-auto text-secondary" onclick="return closeStagPopup()">
+                        <i class="fa fa-times-circle"></i>
+                    </a>
+                </h3>
+                <div class="stag-popup-content-inner">
+                    <div class="popup-content-container px-3">
+                        <h3 class="m-0 font-size-16" id="rpm-manager-other-entries-caremonth"></h3>
+                        <table class="table table-condensed table-sm table-bordered mt-3 cm-tab" id="rpm-manager-other-entries-matrix">
+                            <thead>
+                            <tr>
+                                <th class="text-secondary text-sm">Pro</th>
+                                <th class="text-secondary text-sm">Date</th>
+                                <th class="text-secondary text-sm">Minutes</th>
+                                <th class="text-secondary text-sm">Communicated</th>
+                                <th class="text-secondary text-sm">Comments</th>
+                            </tr>
+                            </thead>
+                            <tbody></tbody>
+                        </table>
+                    </div>
+                </div>
+            </div>
+        </div>
     </div>
     <script>
-        <?php
-            $careMonths = [];
-            foreach ($patients as $iPatient) {
-                if(!!$iPatient->entries_json) {
-                    $iPatient->entries_json = json_decode($iPatient->entries_json);
-                }
-                if(!!$iPatient->measurements_json) {
-                    $iPatient->measurements_json = json_decode($iPatient->measurements_json);
-                }
-                if(!!$iPatient->measurements_bp_json) {
-                    $iPatient->measurements_bp_json = json_decode($iPatient->measurements_bp_json);
-                    for ($i = 0; $i < count($iPatient->measurements_bp_json); $i++) {
-                        $timestampInSec = floor($iPatient->measurements_bp_json[$i]->ts / 1000);
-                        $iPatient->measurements_bp_json[$i]->date_display = friendly_date_time_short_with_tz_from_timestamp($timestampInSec, 'EASTERN', '-', 'm/d/y');
-                        $iPatient->measurements_bp_json[$i]->date_standard = friendly_date_time_short_with_tz_from_timestamp($timestampInSec, 'EASTERN', '-', 'Y-m-d');
-                        $iPatient->measurements_bp_json[$i]->time_display = friendly_date_time_short_with_tz_from_timestamp($timestampInSec, 'EASTERN', '-', 'h:i A') . ' EST';
-                    }
-                }
-                if(!!$iPatient->measurements_weight_json) {
-                    $iPatient->measurements_weight_json = json_decode($iPatient->measurements_weight_json);
-                    for ($i = 0; $i < count($iPatient->measurements_weight_json); $i++) {
-                        $timestampInSec = floor($iPatient->measurements_weight_json[$i]->ts / 1000);
-                        $iPatient->measurements_weight_json[$i]->date_display = friendly_date_time_short_with_tz_from_timestamp($timestampInSec, 'EASTERN', '-', 'm/d/y');
-                        $iPatient->measurements_weight_json[$i]->date_standard = friendly_date_time_short_with_tz_from_timestamp($timestampInSec, 'EASTERN', '-', 'Y-m-d');
-                        $iPatient->measurements_weight_json[$i]->time_display = friendly_date_time_short_with_tz_from_timestamp($timestampInSec, 'EASTERN', '-', 'h:i A') . ' EST';
-                        $iPatient->measurements_weight_json[$i]->numericValue = round($iPatient->measurements_weight_json[$i]->numericValue, 1);
-                    }
-                }
-                $iPatient->month_display = friendly_month($iPatient->care_month_start_date);
-                $careMonths[$iPatient->care_month_uid] = $iPatient;
-            }
-        ?>
         (function () {
 
             let careMonths = {!! json_encode($careMonths) !!};
@@ -585,8 +692,23 @@
                         return false;
                     });
 
-                console.log(careMonths);
+                parent
+                    .off('click', '.btn-my-entries-popup')
+                    .on('click', '.btn-my-entries-popup', function() {
+                        showStagPopup('rpm-manager-my-entries-popup');
+                        prepareEntriesPopup($(this).attr('data-uid'), 'my');
+                        reInitMoes();
+                        return false;
+                    });
 
+                parent
+                    .off('click', '.btn-other-entries-popup')
+                    .on('click', '.btn-other-entries-popup', function() {
+                        showStagPopup('rpm-manager-other-entries-popup');
+                        prepareEntriesPopup($(this).attr('data-uid'), 'other');
+                        reInitMoes();
+                        return false;
+                    });
             }
 
             function prepareMeasurementsPopup(_careMonthUid, _type) {
@@ -805,6 +927,126 @@
                 });
             }
 
+            function prepareEntriesPopup(_careMonthUid, _type) {
+                let careMonth = careMonths[_careMonthUid],
+                    entries = careMonth[_type + 'Entries'];
+
+                // misc
+                $('#rpm-manager-' + _type + '-entries-popup-title').text(careMonth.client_name + ' (' + careMonth.dob + ')');
+                $('#rpm-manager-' + _type + '-entries-caremonth').text('Care Month of: ' + careMonth.month_display + '  |  ' + (_type === 'my' ? 'My Time Entries' : 'Other Time Entries'));
+
+                // matrix
+                if(!entries) entries = [];
+                let table = $('#rpm-manager-' + _type + '-entries-matrix'), tbody = table.find('tbody');
+                tbody.empty();
+                for (let i = 0; i < entries.length; i++) {
+                    let e = entries[i];
+
+                    // tr
+                    let tr = $('<tr/>').attr('data-uid', e.uid);
+
+                    // pro
+                    if(_type === 'other') {
+                        $('<td/>').text(e.proNameFirst + ' ' + e.proNameLast).appendTo(tr);
+                    }
+
+                    // date
+                    $('<td/>').text(e.effectiveDate.month + '/' + e.effectiveDate.day + '/' + e.effectiveDate.year).appendTo(tr);
+
+                    // minutes
+                    $('<td/>').text(Math.round(e.timeInSeconds/60)).appendTo(tr);
+
+                    // communicated
+                    $('<td/>').text('-').appendTo(tr);
+
+                    // comments
+                    $('<td/>').text($('<div/>').html(e.contentText).text()).appendTo(tr);
+
+                    // stamp
+                    // MCPs and RMMs get stamp UI
+                    /*
+                    let stamp = '';
+                    @if($viewingAs === 'MCP')
+                    if(!m.hasBeenStampedByMcp) {
+                        addMCHook('refresh-measurement-' + m.uid, function () {
+                            $('tr[data-uid="' + m.uid + '"] td:eq(3)').html('' +
+                                '<div class="d-flex align-items-baseline text-secondary">' +
+                                '<i class="fa fa-check"></i>' +
+                                '<span class="ml-1">Stamped</span>' +
+                                '</div>'
+                            );
+                            return false;
+                        });
+                        stamp = $($('#stamp-moe-template').html());
+                        stamp.find('[name="uid"]').val(m.uid);
+                        stamp.find('.stamp-moe-type').text(m.bdtDeviceCategory);
+                        if(_type === 'bp') {
+                            stamp.find('.stamp-moe-value').text(m.sbpMmHg + '/' + m.dbpMmHg + ' mmHg');
+                        }
+                        else if(_type === 'weight') {
+                            stamp.find('.stamp-moe-value').text(m.numericValue + ' lbs');
+                        }
+                        stamp.find('.stamp-moe-date-time').text(m.date_display + ' ' + m.time_display);
+                        stamp.find('form').attr('hook', 'refresh-measurement-' + m.uid);
+                    }
+                    else {
+                        stamp = $('<div class="d-flex align-items-baseline text-secondary" />');
+                        stamp.append('<i class="fa fa-check" />');
+                        stamp.append('<span class="ml-1">Stamped</span>');
+                    }
+                    @elseif($viewingAs === 'RMM')
+                    if(!m.hasBeenStampedByRmm) {
+                        addMCHook('refresh-measurement-' + m.uid, function () {
+                            $('tr[data-uid="' + m.uid + '"] td:eq(3)').html('' +
+                                '<div class="d-flex align-items-baseline text-secondary">' +
+                                '<i class="fa fa-check"></i>' +
+                                '<span class="ml-1">Stamped</span>' +
+                                '</div>'
+                            );
+                            return false;
+                        });
+                        stamp = $($('#stamp-moe-template').html());
+                        stamp.find('[name="uid"]').val(m.uid);
+                        stamp.find('.stamp-moe-type').text(m.bdtDeviceCategory);
+                        if(_type === 'bp') {
+                            stamp.find('.stamp-moe-value').text(m.sbpMmHg + '/' + m.dbpMmHg + ' mmHg');
+                        }
+                        else if(_type === 'weight') {
+                            stamp.find('.stamp-moe-value').text(m.numericValue + ' lbs');
+                        }
+                        stamp.find('.stamp-moe-date-time').text(m.date_display + ' ' + m.time_display);
+                        stamp.find('form').attr('hook', 'refresh-measurement-' + m.uid);
+                    }
+                    else {
+                        stamp = $('<div class="d-flex align-items-baseline text-secondary" />');
+                        stamp.append('<i class="fa fa-check" />');
+                        stamp.append('<span class="ml-1">Stamped</span>');
+                    }
+                    @elseif($viewingAs === 'ADMIN')
+                        stamp = $('<div class="d-flex align-items-baseline flex-nowrap" />');
+                    if(!m.hasBeenStampedByMcp) {
+                        stamp.append('<i class="fa fa-circle text-sm opacity-35 text-danger"></i>');
+                    }
+                    else {
+                        stamp.append('<i class="fa fa-circle text-sm opacity-35 text-success"></i>');
+                    }
+                    stamp.append('<span class="ml-1 mr-2 text-sm">MCP</span>');
+                    if(!m.hasBeenStampedByRmm) {
+                        stamp.append('<i class="fa fa-circle text-sm opacity-35 text-danger"></i>');
+                    }
+                    else {
+                        stamp.append('<i class="fa fa-circle text-sm opacity-35 text-success"></i>');
+                    }
+                    stamp.append('<span class="ml-1 text-sm">RMM</span>');
+                    @endif
+
+                    $('<td/>').append(stamp).appendTo(tr);
+                    */
+
+                    tr.appendTo(tbody);
+                }
+            }
+
             addMCInitializer('practice-rpm-manager', init, '#practice-rpm-manager');
         }).call(window);
     </script>