Эх сурвалжийг харах

Read/Edit modes on all wizards

Vijayakrishnan 3 жил өмнө
parent
commit
6f4f55b012

+ 100 - 44
resources/views/app/patient/allergies-center.blade.php

@@ -41,7 +41,7 @@ function isFavoriteAllergy($_allergy, $_favorites) {
             </label>
         </div>
 
-        <table class="table table-sm table-bordered mb-0 bg-white mb-2 point-table">
+        <table class="table table-sm table-bordered mb-0 bg-white mb-2 point-table read">
             <thead>
             <tr class="">
                 @if($patient->core_note_id !== $note->id)
@@ -149,55 +149,73 @@ function isFavoriteAllergy($_allergy, $_favorites) {
                     </div>
                 </td>
                 <td>
-                    <div class="d-flex align-items-start">
-                        <div class="flex-grow-1">
-                            <?php
-                            $point = $allergy;
-                            include resource_path('views/app/patient/segment-templates/_child_review/last-review.php');
-                            ?>
-                        </div>
-                        <div class="d-inline-flex flex-column ml-1">
-                            <a class="px-1 view-review-log"
-                               native target="_blank"
-                               open-in-stag-popup
-                               popup-style="stag-popup-md"
-                               title="Subjective log<?= !!@($allergy->data->name) ? ' for ' . @($allergy->data->name) : '' ?>"
-                               href="/point/review-log/<?= $allergy->uid ?>?popupmode=1">
-                                <i class="fa fa-history"></i>
-                            </a>
-                            <?php
-                            $segment = $note->getSegmentByInternalName('intake_allergies');
-                            if($segment) {
-                                include resource_path('views/app/patient/segment-templates/_child_review/edit-review.php');
-                            }
-                            ?>
+                    <?php $segment = $note->getSegmentByInternalName('intake_allergies'); ?>
+                    <div if-read-mode>
+                        <div class="d-flex align-items-start">
+                            <div class="flex-grow-1">
+                                <?php
+                                $point = $allergy;
+                                include resource_path('views/app/patient/segment-templates/_child_review/last-review.php');
+                                ?>
+                            </div>
+                            <div class="d-inline-flex flex-column ml-1">
+                                <a class="px-1 view-review-log"
+                                   native target="_blank"
+                                   open-in-stag-popup
+                                   popup-style="stag-popup-md"
+                                   title="Subjective log<?= !!@($allergy->data->name) ? ' for ' . @($allergy->data->name) : '' ?>"
+                                   href="/point/review-log/<?= $allergy->uid ?>?popupmode=1">
+                                    <i class="fa fa-history"></i>
+                                </a>
+                                <?php
+                                if($segment) {
+                                    include resource_path('views/app/patient/segment-templates/_child_review/edit-review.php');
+                                }
+                                ?>
+                            </div>
                         </div>
                     </div>
+                    <div if-edit-mode>
+                        <?php
+                        if($segment) {
+                            include resource_path('views/app/patient/segment-templates/_child_review/edit-review-in-place.php');
+                        }
+                        ?>
+                    </div>
                 </td>
                 <td>
-                    <div class="d-flex align-items-start position-relative">
-                        <div class="flex-grow-1">
-                            <?php
-                            include resource_path('views/app/patient/segment-templates/_child_plan/last-plan.php');
-                            ?>
-                        </div>
-                        <div class="d-inline-flex flex-column ml-1">
-                            <a class="px-1 view-review-log"
-                               native target="_blank"
-                               open-in-stag-popup
-                               popup-style="stag-popup-md"
-                               title="Plan log<?= !!@($allergy->data->name) ? ' for ' . @($allergy->data->name) : '' ?>"
-                               href="/point/plan-log/<?= $allergy->uid ?>?popupmode=1">
-                                <i class="fa fa-history"></i>
-                            </a>
-                            <?php
-                            $segment = $note->getSegmentByInternalName('plan_allergies');
-                            if($segment) {
-                                include resource_path('views/app/patient/segment-templates/_child_plan/edit-plan.php');
-                            }
-                            ?>
+                    <?php $segment = $note->getSegmentByInternalName('plan_allergies'); ?>
+                    <div if-read-mode>
+                        <div class="d-flex align-items-start position-relative">
+                            <div class="flex-grow-1">
+                                <?php
+                                include resource_path('views/app/patient/segment-templates/_child_plan/last-plan.php');
+                                ?>
+                            </div>
+                            <div class="d-inline-flex flex-column ml-1">
+                                <a class="px-1 view-review-log"
+                                   native target="_blank"
+                                   open-in-stag-popup
+                                   popup-style="stag-popup-md"
+                                   title="Plan log<?= !!@($allergy->data->name) ? ' for ' . @($allergy->data->name) : '' ?>"
+                                   href="/point/plan-log/<?= $allergy->uid ?>?popupmode=1">
+                                    <i class="fa fa-history"></i>
+                                </a>
+                                <?php
+                                if($segment) {
+                                    include resource_path('views/app/patient/segment-templates/_child_plan/edit-plan.php');
+                                }
+                                ?>
+                            </div>
                         </div>
                     </div>
+                    <div if-edit-mode>
+                        <?php
+                        if($segment) {
+                            include resource_path('views/app/patient/segment-templates/_child_plan/edit-plan-in-place.php');
+                        }
+                        ?>
+                    </div>
                 </td>
                 <td>
                     <div class="position-relative c-pointer stag-tooltip">
@@ -325,6 +343,44 @@ function isFavoriteAllergy($_allergy, $_favorites) {
                     $(this).closest('.on-click-menu').find('[menu]').hide();
                     return false;
                 });
+
+            let mode = 'read';
+
+            // custom buttons on title bar
+            $('.button-container').remove();
+            let buttonContainer = $('<div/>').addClass('button-container ml-4 mr-auto');
+            let titleElem = $('#allergies-center-{{$note->id}}').closest('.stag-popup').find('.stag-popup-title>span');
+            titleElem.next().removeClass('ml-auto');
+            titleElem.parent().addClass('align-items-center');
+
+            // add button for "Edit Mode"
+            $('.btn-toggle-edit-mode').remove();
+            let button = $('<a href="#" native target="_blank" data-mode="read" ' +
+                'class="btn-toggle-edit-mode btn btn-sm mr-2 btn-info text-white font-weight-bold shadow-none">Switch to Edit Mode</a>')
+                .appendTo(buttonContainer);
+
+            $('<div class="d-inline-flex align-self-stretch align-items-center">' +
+                '<span class="autosave-indicator saving text-sm text-secondary">Saving changes &hellip;</span>' +
+                '<span class="autosave-indicator saved text-sm text-secondary">' +
+                '<i class="fa fa-check"></i>' +
+                ' Saved' +
+                '</span>' +
+                '</div>').appendTo(buttonContainer);
+
+            button
+                .off('click.toggle-edit')
+                .on('click.toggle-edit', function () {
+                    if (mode === 'read') {
+                        mode = 'edit';
+                        $(this).text('Back to Read Mode');
+                        $('#allergies-center-{{$note->id}} .point-table').removeClass('read').addClass('edit');
+                    } else {
+                        refreshDynamicStagPopup();
+                    }
+                    return false;
+                });
+
+            buttonContainer.insertAfter(titleElem);
         }
         addMCInitializer('allergies-center-{{$note->id}}', init, '#allergies-center-{{$note->id}}');
     }).call(window);

+ 100 - 44
resources/views/app/patient/careteam-center.blade.php

@@ -14,7 +14,7 @@ list($careTeamMembers, $counts) = Point::getPointsOfCategoryExtended($patient, '
 <div class="mt-3 p-3 border-top min-height-500px" id="careteam-center-{{$note->id}}">
     <div class="point-table-container">
 
-        <table class="table table-sm table-bordered mb-0 bg-white mb-2 point-table">
+        <table class="table table-sm table-bordered mb-0 bg-white mb-2 point-table read">
             <thead>
             <tr class="">
                 @if($patient->core_note_id !== $note->id)
@@ -153,55 +153,73 @@ list($careTeamMembers, $counts) = Point::getPointsOfCategoryExtended($patient, '
                     </div>
                 </td>
                 <td>
-                    <div class="d-flex align-items-start">
-                        <div class="flex-grow-1">
-                            <?php
-                            $point = $careTeamMember;
-                            include resource_path('views/app/patient/segment-templates/_child_review/last-review.php');
-                            ?>
-                        </div>
-                        <div class="d-inline-flex flex-column ml-1">
-                            <a class="px-1 view-review-log"
-                               native target="_blank"
-                               open-in-stag-popup
-                               popup-style="stag-popup-md"
-                               title="Subjective log<?= !!@($careTeamMember->data->name) ? ' for ' . @($careTeamMember->data->name) : '' ?>"
-                               href="/point/review-log/<?= $careTeamMember->uid ?>?popupmode=1">
-                                <i class="fa fa-history"></i>
-                            </a>
-                            <?php
-                            $segment = $note->getSegmentByInternalName('intake_care_team');
-                            if($segment) {
-                                include resource_path('views/app/patient/segment-templates/_child_review/edit-review.php');
-                            }
-                            ?>
+                    <?php $segment = $note->getSegmentByInternalName('intake_care_team'); ?>
+                    <div if-read-mode>
+                        <div class="d-flex align-items-start">
+                            <div class="flex-grow-1">
+                                <?php
+                                $point = $careTeamMember;
+                                include resource_path('views/app/patient/segment-templates/_child_review/last-review.php');
+                                ?>
+                            </div>
+                            <div class="d-inline-flex flex-column ml-1">
+                                <a class="px-1 view-review-log"
+                                   native target="_blank"
+                                   open-in-stag-popup
+                                   popup-style="stag-popup-md"
+                                   title="Subjective log<?= !!@($careTeamMember->data->name) ? ' for ' . @($careTeamMember->data->name) : '' ?>"
+                                   href="/point/review-log/<?= $careTeamMember->uid ?>?popupmode=1">
+                                    <i class="fa fa-history"></i>
+                                </a>
+                                <?php
+                                if($segment) {
+                                    include resource_path('views/app/patient/segment-templates/_child_review/edit-review.php');
+                                }
+                                ?>
+                            </div>
                         </div>
                     </div>
+                    <div if-edit-mode>
+                        <?php
+                        if($segment) {
+                            include resource_path('views/app/patient/segment-templates/_child_review/edit-review-in-place.php');
+                        }
+                        ?>
+                    </div>
                 </td>
                 <td>
-                    <div class="d-flex align-items-start position-relative">
-                        <div class="flex-grow-1">
-                            <?php
-                            include resource_path('views/app/patient/segment-templates/_child_plan/last-plan.php');
-                            ?>
-                        </div>
-                        <div class="d-inline-flex flex-column ml-1">
-                            <a class="px-1 view-review-log"
-                               native target="_blank"
-                               open-in-stag-popup
-                               popup-style="stag-popup-md"
-                               title="Plan log<?= !!@($careTeamMember->data->name) ? ' for ' . @($careTeamMember->data->name) : '' ?>"
-                               href="/point/plan-log/<?= $careTeamMember->uid ?>?popupmode=1">
-                                <i class="fa fa-history"></i>
-                            </a>
-                            <?php
-                            $segment = $note->getSegmentByInternalName('plan_care_team');
-                            if($segment) {
-                                include resource_path('views/app/patient/segment-templates/_child_plan/edit-plan.php');
-                            }
-                            ?>
+                    <?php $segment = $note->getSegmentByInternalName('plan_care_team'); ?>
+                    <div if-read-mode>
+                        <div class="d-flex align-items-start position-relative">
+                            <div class="flex-grow-1">
+                                <?php
+                                include resource_path('views/app/patient/segment-templates/_child_plan/last-plan.php');
+                                ?>
+                            </div>
+                            <div class="d-inline-flex flex-column ml-1">
+                                <a class="px-1 view-review-log"
+                                   native target="_blank"
+                                   open-in-stag-popup
+                                   popup-style="stag-popup-md"
+                                   title="Plan log<?= !!@($careTeamMember->data->name) ? ' for ' . @($careTeamMember->data->name) : '' ?>"
+                                   href="/point/plan-log/<?= $careTeamMember->uid ?>?popupmode=1">
+                                    <i class="fa fa-history"></i>
+                                </a>
+                                <?php
+                                if($segment) {
+                                    include resource_path('views/app/patient/segment-templates/_child_plan/edit-plan.php');
+                                }
+                                ?>
+                            </div>
                         </div>
                     </div>
+                    <div if-edit-mode>
+                        <?php
+                        if($segment) {
+                            include resource_path('views/app/patient/segment-templates/_child_plan/edit-plan-in-place.php');
+                        }
+                        ?>
+                    </div>
                 </td>
                 <td>
                     <?= '<span class="text-secondary">Ph: </span>' . (!!@($careTeamMember->data->phone) ? @($careTeamMember->data->phone) : '-') ?><br>
@@ -331,6 +349,44 @@ list($careTeamMembers, $counts) = Point::getPointsOfCategoryExtended($patient, '
 
             initSegmentMoes($('#careteam-center-{{$note->id}}'));
             __initRTEs(parentSegment.find('[note-rte]:not(.ql-container)'));
+
+            let mode = 'read';
+
+            // custom buttons on title bar
+            $('.button-container').remove();
+            let buttonContainer = $('<div/>').addClass('button-container ml-4 mr-auto');
+            let titleElem = $('#careteam-center-{{$note->id}}').closest('.stag-popup').find('.stag-popup-title>span');
+            titleElem.next().removeClass('ml-auto');
+            titleElem.parent().addClass('align-items-center');
+
+            // add button for "Edit Mode"
+            $('.btn-toggle-edit-mode').remove();
+            let button = $('<a href="#" native target="_blank" data-mode="read" ' +
+                'class="btn-toggle-edit-mode btn btn-sm mr-2 btn-info text-white font-weight-bold shadow-none">Switch to Edit Mode</a>')
+                .appendTo(buttonContainer);
+
+            $('<div class="d-inline-flex align-self-stretch align-items-center">' +
+                '<span class="autosave-indicator saving text-sm text-secondary">Saving changes &hellip;</span>' +
+                '<span class="autosave-indicator saved text-sm text-secondary">' +
+                '<i class="fa fa-check"></i>' +
+                ' Saved' +
+                '</span>' +
+                '</div>').appendTo(buttonContainer);
+
+            button
+                .off('click.toggle-edit')
+                .on('click.toggle-edit', function () {
+                    if (mode === 'read') {
+                        mode = 'edit';
+                        $(this).text('Back to Read Mode');
+                        $('#careteam-center-{{$note->id}} .point-table').removeClass('read').addClass('edit');
+                    } else {
+                        refreshDynamicStagPopup();
+                    }
+                    return false;
+                });
+
+            buttonContainer.insertAfter(titleElem);
         }
         addMCInitializer('careteam-center-{{$note->id}}', init, '#careteam-center-{{$note->id}}');
     }).call(window);

+ 100 - 44
resources/views/app/patient/goals-center.blade.php

@@ -14,7 +14,7 @@ list($goals, $counts) = Point::getPointsOfCategoryExtended($patient, 'GOAL', $no
 <div class="mt-3 p-3 border-top min-height-500px" id="goals-center-{{$note->id}}">
     <div class="point-table-container">
 
-        <table class="table table-sm table-bordered mb-0 bg-white mb-2 point-table">
+        <table class="table table-sm table-bordered mb-0 bg-white mb-2 point-table read">
             <thead>
             <tr class="">
                 @if($patient->core_note_id !== $note->id)
@@ -96,55 +96,73 @@ list($goals, $counts) = Point::getPointsOfCategoryExtended($patient, 'GOAL', $no
                     </div>
                 </td>
                 <td>
-                    <div class="d-flex align-items-start">
-                        <div class="flex-grow-1">
-                            <?php
-                            $point = $goal;
-                            include resource_path('views/app/patient/segment-templates/_child_review/last-review.php');
-                            ?>
-                        </div>
-                        <div class="d-inline-flex flex-column ml-1">
-                            <a class="px-1 view-review-log"
-                               native target="_blank"
-                               open-in-stag-popup
-                               popup-style="stag-popup-md"
-                               title="Subjective log<?= !!@($goal->data->goal) ? ' for ' . @($goal->data->goal) : '' ?>"
-                               href="/point/review-log/<?= $goal->uid ?>?popupmode=1">
-                                <i class="fa fa-history"></i>
-                            </a>
-                            <?php
-                            $segment = $note->getSegmentByInternalName('intake_goals');
-                            if($segment) {
-                                include resource_path('views/app/patient/segment-templates/_child_review/edit-review.php');
-                            }
-                            ?>
+                    <?php $segment = $note->getSegmentByInternalName('intake_goals'); ?>
+                    <div if-read-mode>
+                        <div class="d-flex align-items-start">
+                            <div class="flex-grow-1">
+                                <?php
+                                $point = $goal;
+                                include resource_path('views/app/patient/segment-templates/_child_review/last-review.php');
+                                ?>
+                            </div>
+                            <div class="d-inline-flex flex-column ml-1">
+                                <a class="px-1 view-review-log"
+                                   native target="_blank"
+                                   open-in-stag-popup
+                                   popup-style="stag-popup-md"
+                                   title="Subjective log<?= !!@($goal->data->goal) ? ' for ' . @($goal->data->goal) : '' ?>"
+                                   href="/point/review-log/<?= $goal->uid ?>?popupmode=1">
+                                    <i class="fa fa-history"></i>
+                                </a>
+                                <?php
+                                if($segment) {
+                                    include resource_path('views/app/patient/segment-templates/_child_review/edit-review.php');
+                                }
+                                ?>
+                            </div>
                         </div>
                     </div>
+                    <div if-edit-mode>
+                        <?php
+                        if($segment) {
+                            include resource_path('views/app/patient/segment-templates/_child_review/edit-review-in-place.php');
+                        }
+                        ?>
+                    </div>
                 </td>
                 <td>
-                    <div class="d-flex align-items-start position-relative">
-                        <div class="flex-grow-1">
-                            <?php
-                            include resource_path('views/app/patient/segment-templates/_child_plan/last-plan.php');
-                            ?>
-                        </div>
-                        <div class="d-inline-flex flex-column ml-1">
-                            <a class="px-1 view-review-log"
-                               native target="_blank"
-                               open-in-stag-popup
-                               popup-style="stag-popup-md"
-                               title="Plan log<?= !!@($goal->data->goal) ? ' for ' . @($goal->data->goal) : '' ?>"
-                               href="/point/plan-log/<?= $goal->uid ?>?popupmode=1">
-                                <i class="fa fa-history"></i>
-                            </a>
-                            <?php
-                            $segment = $note->getSegmentByInternalName('plan_goals');
-                            if($segment) {
-                                include resource_path('views/app/patient/segment-templates/_child_plan/edit-plan.php');
-                            }
-                            ?>
+                    <?php $segment = $note->getSegmentByInternalName('plan_goals'); ?>
+                    <div if-read-mode>
+                        <div class="d-flex align-items-start position-relative">
+                            <div class="flex-grow-1">
+                                <?php
+                                include resource_path('views/app/patient/segment-templates/_child_plan/last-plan.php');
+                                ?>
+                            </div>
+                            <div class="d-inline-flex flex-column ml-1">
+                                <a class="px-1 view-review-log"
+                                   native target="_blank"
+                                   open-in-stag-popup
+                                   popup-style="stag-popup-md"
+                                   title="Plan log<?= !!@($goal->data->goal) ? ' for ' . @($goal->data->goal) : '' ?>"
+                                   href="/point/plan-log/<?= $goal->uid ?>?popupmode=1">
+                                    <i class="fa fa-history"></i>
+                                </a>
+                                <?php
+                                if($segment) {
+                                    include resource_path('views/app/patient/segment-templates/_child_plan/edit-plan.php');
+                                }
+                                ?>
+                            </div>
                         </div>
                     </div>
+                    <div if-edit-mode>
+                        <?php
+                        if($segment) {
+                            include resource_path('views/app/patient/segment-templates/_child_plan/edit-plan-in-place.php');
+                        }
+                        ?>
+                    </div>
                 </td>
                 <td>
                     <div class="position-relative c-pointer stag-tooltip">
@@ -226,6 +244,44 @@ list($goals, $counts) = Point::getPointsOfCategoryExtended($patient, 'GOAL', $no
 
             initSegmentMoes($('#goals-center-{{$note->id}}'));
             __initRTEs(parentSegment.find('[note-rte]:not(.ql-container)'));
+
+            let mode = 'read';
+
+            // custom buttons on title bar
+            $('.button-container').remove();
+            let buttonContainer = $('<div/>').addClass('button-container ml-4 mr-auto');
+            let titleElem = $('#goals-center-{{$note->id}}').closest('.stag-popup').find('.stag-popup-title>span');
+            titleElem.next().removeClass('ml-auto');
+            titleElem.parent().addClass('align-items-center');
+
+            // add button for "Edit Mode"
+            $('.btn-toggle-edit-mode').remove();
+            let button = $('<a href="#" native target="_blank" data-mode="read" ' +
+                'class="btn-toggle-edit-mode btn btn-sm mr-2 btn-info text-white font-weight-bold shadow-none">Switch to Edit Mode</a>')
+                .appendTo(buttonContainer);
+
+            $('<div class="d-inline-flex align-self-stretch align-items-center">' +
+                '<span class="autosave-indicator saving text-sm text-secondary">Saving changes &hellip;</span>' +
+                '<span class="autosave-indicator saved text-sm text-secondary">' +
+                '<i class="fa fa-check"></i>' +
+                ' Saved' +
+                '</span>' +
+                '</div>').appendTo(buttonContainer);
+
+            button
+                .off('click.toggle-edit')
+                .on('click.toggle-edit', function () {
+                    if (mode === 'read') {
+                        mode = 'edit';
+                        $(this).text('Back to Read Mode');
+                        $('#goals-center-{{$note->id}} .point-table').removeClass('read').addClass('edit');
+                    } else {
+                        refreshDynamicStagPopup();
+                    }
+                    return false;
+                });
+
+            buttonContainer.insertAfter(titleElem);
         }
         addMCInitializer('goals-center-{{$note->id}}', init, '#goals-center-{{$note->id}}');
     }).call(window);

+ 97 - 48
resources/views/app/patient/medications-center.blade.php

@@ -35,7 +35,7 @@ function isFavoriteMedication($_medication, $_favorites) {
             </label>
         </div>
 
-        <table class="table table-sm table-bordered mb-0 bg-white mb-2 point-table">
+        <table class="table table-sm table-bordered mb-0 bg-white mb-2 point-table read">
             <thead>
             <tr class="">
                 @if($patient->core_note_id !== $note->id)
@@ -147,55 +147,73 @@ function isFavoriteMedication($_medication, $_favorites) {
                         </div>
                     </td>
                     <td>
-                        <div class="d-flex align-items-start">
-                            <div class="flex-grow-1">
-                                <?php
-                                $point = $medication;
-                                include resource_path('views/app/patient/segment-templates/_child_review/last-review.php');
-                                ?>
-                            </div>
-                            <div class="d-inline-flex flex-column ml-1">
-                                <a class="px-1 view-review-log"
-                                   native target="_blank"
-                                   open-in-stag-popup
-                                   popup-style="stag-popup-md"
-                                   title="Subjective log<?= !!@($medication->data->name) ? ' for ' . @($medication->data->name) : '' ?>"
-                                   href="/point/review-log/<?= $medication->uid ?>?popupmode=1">
-                                    <i class="fa fa-history"></i>
-                                </a>
-                                <?php
-                                $segment = $note->getSegmentByInternalName('intake_medications');
-                                if($segment) {
-                                    include resource_path('views/app/patient/segment-templates/_child_review/edit-review.php');
-                                }
-                                ?>
+                        <?php $segment = $note->getSegmentByInternalName('intake_medications'); ?>
+                        <div if-read-mode>
+                            <div class="d-flex align-items-start">
+                                <div class="flex-grow-1">
+                                    <?php
+                                    $point = $medication;
+                                    include resource_path('views/app/patient/segment-templates/_child_review/last-review.php');
+                                    ?>
+                                </div>
+                                <div class="d-inline-flex flex-column ml-1">
+                                    <a class="px-1 view-review-log"
+                                       native target="_blank"
+                                       open-in-stag-popup
+                                       popup-style="stag-popup-md"
+                                       title="Subjective log<?= !!@($medication->data->name) ? ' for ' . @($medication->data->name) : '' ?>"
+                                       href="/point/review-log/<?= $medication->uid ?>?popupmode=1">
+                                        <i class="fa fa-history"></i>
+                                    </a>
+                                    <?php
+                                    if($segment) {
+                                        include resource_path('views/app/patient/segment-templates/_child_review/edit-review.php');
+                                    }
+                                    ?>
+                                </div>
                             </div>
                         </div>
+                        <div if-edit-mode>
+                            <?php
+                            if($segment) {
+                                include resource_path('views/app/patient/segment-templates/_child_review/edit-review-in-place.php');
+                            }
+                            ?>
+                        </div>
                     </td>
                     <td>
-                        <div class="d-flex align-items-start position-relative">
-                            <div class="flex-grow-1">
-                                <?php
-                                include resource_path('views/app/patient/segment-templates/_child_plan/last-plan.php');
-                                ?>
-                            </div>
-                            <div class="d-inline-flex flex-column ml-1">
-                                <a class="px-1 view-review-log"
-                                   native target="_blank"
-                                   open-in-stag-popup
-                                   popup-style="stag-popup-md"
-                                   title="Plan log<?= !!@($medication->data->name) ? ' for ' . @($medication->data->name) : '' ?>"
-                                   href="/point/plan-log/<?= $medication->uid ?>?popupmode=1">
-                                    <i class="fa fa-history"></i>
-                                </a>
-                                <?php
-                                $segment = $note->getSegmentByInternalName('plan_medications');
-                                if($segment) {
-                                    include resource_path('views/app/patient/segment-templates/_child_plan/edit-plan.php');
-                                }
-                                ?>
+                        <?php $segment = $note->getSegmentByInternalName('plan_medications'); ?>
+                        <div if-read-mode>
+                            <div class="d-flex align-items-start position-relative">
+                                <div class="flex-grow-1">
+                                    <?php
+                                    include resource_path('views/app/patient/segment-templates/_child_plan/last-plan.php');
+                                    ?>
+                                </div>
+                                <div class="d-inline-flex flex-column ml-1">
+                                    <a class="px-1 view-review-log"
+                                       native target="_blank"
+                                       open-in-stag-popup
+                                       popup-style="stag-popup-md"
+                                       title="Plan log<?= !!@($medication->data->name) ? ' for ' . @($medication->data->name) : '' ?>"
+                                       href="/point/plan-log/<?= $medication->uid ?>?popupmode=1">
+                                        <i class="fa fa-history"></i>
+                                    </a>
+                                    <?php
+                                    if($segment) {
+                                        include resource_path('views/app/patient/segment-templates/_child_plan/edit-plan.php');
+                                    }
+                                    ?>
+                                </div>
                             </div>
                         </div>
+                        <div if-edit-mode>
+                            <?php
+                            if($segment) {
+                                include resource_path('views/app/patient/segment-templates/_child_plan/edit-plan-in-place.php');
+                            }
+                            ?>
+                        </div>
                     </td>
                     <td>
                         <div class="position-relative c-pointer stag-tooltip">
@@ -337,11 +355,25 @@ function isFavoriteMedication($_medication, $_favorites) {
 
         // custom buttons on title bar
         $('.button-container').remove();
-        let buttonContainer = $('<div/>').addClass('button-container ml-auto mr-3');
+        let buttonContainer = $('<div/>').addClass('button-container ml-4 mr-2 d-inline-flex align-items-center flex-grow-1');
         let titleElem = $('#medications-center-{{$note->id}}').closest('.stag-popup').find('.stag-popup-title>span');
-        titleElem.next().removeClass('ml-auto');
+        titleElem.next().removeClass('ml-4');
         titleElem.parent().addClass('align-items-baseline');
 
+        // add button for "Edit Mode"
+        $('.btn-toggle-edit-mode').remove();
+        let button = $('<a href="#" native target="_blank" data-mode="read" ' +
+            'class="btn-toggle-edit-mode btn btn-sm btn-info text-white font-weight-bold shadow-none">Switch to Edit Mode</a>')
+            .appendTo(buttonContainer);
+
+        $('<div class="d-inline-flex align-self-stretch align-items-center ml-3 mr-auto">' +
+            '<span class="autosave-indicator saving text-sm text-secondary">Saving changes &hellip;</span>' +
+            '<span class="autosave-indicator saved text-sm text-secondary">' +
+            '<i class="fa fa-check"></i>' +
+            ' Saved' +
+            '</span>' +
+            '</div>').appendTo(buttonContainer);
+
         // add button for "reconcile active medications"
         if($('.active-record').length) {
             $('.btn-reconcile-active').remove();
@@ -352,7 +384,7 @@ function isFavoriteMedication($_medication, $_favorites) {
                 'open-in-stag-popup ' +
                 'mc-initer="medications-reconcile-{{$note->id}}" ' +
                 'popup-style="medium" ' +
-                'class="btn-reconcile-active btn btn-sm mr-2 btn-info text-white font-weight-bold">Reconcile Active Medications</a>')
+                'class="btn-reconcile-active btn btn-sm mr-2 btn-primary text-white font-weight-bold">Reconcile Active Medications</a>')
                 .appendTo(buttonContainer);
         }
 
@@ -361,7 +393,7 @@ function isFavoriteMedication($_medication, $_favorites) {
         $('<a ' +
             'href="#" ' +
             'data-non-segment-target="Prescriptions" ' +
-            'class="btn-manage-erx btn btn-sm mr-2 btn-info text-white font-weight-bold">Manage eRx</a>')
+            'class="btn-manage-erx btn btn-sm mr-2 btn-primary text-white font-weight-bold">Manage eRx</a>')
             .appendTo(buttonContainer);
 
         buttonContainer.insertAfter(titleElem);
@@ -385,6 +417,23 @@ function isFavoriteMedication($_medication, $_favorites) {
                 $(this).closest('.on-click-menu').find('[menu]').hide();
                 return false;
             });
+
+        let mode = 'read';
+
+        button
+            .off('click.toggle-edit')
+            .on('click.toggle-edit', function () {
+                if (mode === 'read') {
+                    mode = 'edit';
+                    $(this).text('Back to Read Mode');
+                    $('#medications-center-{{$note->id}} .point-table').removeClass('read').addClass('edit');
+                } else {
+                    refreshDynamicStagPopup();
+                }
+                return false;
+            });
+
+        buttonContainer.insertAfter(titleElem);
     }
     addMCInitializer('medications-center-{{$note->id}}', init, '#medications-center-{{$note->id}}');
 }).call(window);

+ 92 - 54
resources/views/app/patient/problems-center.blade.php

@@ -55,7 +55,7 @@ function isFavoriteProblem($_problem, $_favorites) {
         @endif
 
         <div class="mb-2 font-weight-bold font-size-14 text-secondary">Problems</div>
-        <table class="table table-sm table-bordered mb-0 bg-white mb-2 point-table">
+        <table class="table table-sm table-bordered mb-0 bg-white mb-2 point-table read">
             <thead>
             <tr class="">
                 @if($patient->core_note_id !== $note->id)
@@ -186,55 +186,73 @@ function isFavoriteProblem($_problem, $_favorites) {
                     </div>
                 </td>
                 <td>
-                    <div class="d-flex align-items-start">
-                        <div class="flex-grow-1">
-                            <?php
-                            $point = $problem;
-                            include resource_path('views/app/patient/segment-templates/_child_review/last-review.php');
-                            ?>
-                        </div>
-                        <div class="d-inline-flex flex-column ml-1">
-                            <a class="px-1 view-review-log"
-                               native target="_blank"
-                               open-in-stag-popup
-                               popup-style="stag-popup-md"
-                               title="Subjective log<?= !!@($problem->data->name) ? ' for ' . @($problem->data->name) : '' ?>"
-                               href="/point/review-log/<?= $problem->uid ?>?popupmode=1">
-                                <i class="fa fa-history"></i>
-                            </a>
-                            <?php
-                            $segment = $note->getSegmentByInternalName('intake_problems');
-                            if($segment) {
-                                include resource_path('views/app/patient/segment-templates/_child_review/edit-review.php');
-                            }
-                            ?>
+                    <?php $segment = $note->getSegmentByInternalName('intake_problems'); ?>
+                    <div if-read-mode>
+                        <div class="d-flex align-items-start">
+                            <div class="flex-grow-1">
+                                <?php
+                                $point = $problem;
+                                include resource_path('views/app/patient/segment-templates/_child_review/last-review.php');
+                                ?>
+                            </div>
+                            <div class="d-inline-flex flex-column ml-1">
+                                <a class="px-1 view-review-log"
+                                   native target="_blank"
+                                   open-in-stag-popup
+                                   popup-style="stag-popup-md"
+                                   title="Subjective log<?= !!@($problem->data->name) ? ' for ' . @($problem->data->name) : '' ?>"
+                                   href="/point/review-log/<?= $problem->uid ?>?popupmode=1">
+                                    <i class="fa fa-history"></i>
+                                </a>
+                                <?php
+                                if($segment) {
+                                    include resource_path('views/app/patient/segment-templates/_child_review/edit-review.php');
+                                }
+                                ?>
+                            </div>
                         </div>
                     </div>
+                    <div if-edit-mode>
+                        <?php
+                        if($segment) {
+                            include resource_path('views/app/patient/segment-templates/_child_review/edit-review-in-place.php');
+                        }
+                        ?>
+                    </div>
                 </td>
                 <td>
-                    <div class="d-flex align-items-start position-relative">
-                        <div class="flex-grow-1">
-                            <?php
-                            include resource_path('views/app/patient/segment-templates/_child_plan/last-plan.php');
-                            ?>
-                        </div>
-                        <div class="d-inline-flex flex-column ml-1">
-                            <a class="px-1 view-review-log"
-                               native target="_blank"
-                               open-in-stag-popup
-                               popup-style="stag-popup-md"
-                               title="Plan log<?= !!@($problem->data->name) ? ' for ' . @($problem->data->name) : '' ?>"
-                               href="/point/plan-log/<?= $problem->uid ?>?popupmode=1">
-                                <i class="fa fa-history"></i>
-                            </a>
-                            <?php
-                            $segment = $note->getSegmentByInternalName('plan_problems');
-                            if($segment) {
-                                include resource_path('views/app/patient/segment-templates/_child_plan/edit-plan.php');
-                            }
-                            ?>
+                    <?php $segment = $note->getSegmentByInternalName('plan_problems'); ?>
+                    <div if-read-mode>
+                        <div class="d-flex align-items-start position-relative">
+                            <div class="flex-grow-1">
+                                <?php
+                                include resource_path('views/app/patient/segment-templates/_child_plan/last-plan.php');
+                                ?>
+                            </div>
+                            <div class="d-inline-flex flex-column ml-1">
+                                <a class="px-1 view-review-log"
+                                   native target="_blank"
+                                   open-in-stag-popup
+                                   popup-style="stag-popup-md"
+                                   title="Plan log<?= !!@($problem->data->name) ? ' for ' . @($problem->data->name) : '' ?>"
+                                   href="/point/plan-log/<?= $problem->uid ?>?popupmode=1">
+                                    <i class="fa fa-history"></i>
+                                </a>
+                                <?php
+                                if($segment) {
+                                    include resource_path('views/app/patient/segment-templates/_child_plan/edit-plan.php');
+                                }
+                                ?>
+                            </div>
                         </div>
                     </div>
+                    <div if-edit-mode>
+                        <?php
+                        if($segment) {
+                            include resource_path('views/app/patient/segment-templates/_child_plan/edit-plan-in-place.php');
+                        }
+                        ?>
+                    </div>
                 </td>
                 <td>
                     <div class="position-relative c-pointer stag-tooltip">
@@ -414,14 +432,36 @@ function isFavoriteProblem($_problem, $_favorites) {
                     return false;
                 });
 
-            setTimeout(() => {
-                // custom buttons on title bar
-                $('.button-container').remove();
-                let buttonContainer = $('<div/>').addClass('button-container ml-4 mr-auto');
-                let titleElem = $('#problems-center-{{$note->id}}').closest('.stag-popup').find('.stag-popup-title>span');
-                titleElem.next().removeClass('ml-auto');
-                titleElem.parent().addClass('align-items-center');
+            let mode = 'read';
+
+            $('.button-container').remove();
+            let buttonContainer = $('<div/>').addClass('button-container ml-4 mr-auto');
+            let titleElem = $('#problems-center-{{$note->id}}').closest('.stag-popup').find('.stag-popup-title>span');
+            titleElem.next().removeClass('ml-auto');
+            titleElem.parent().addClass('align-items-center');
+
+            // add button for "Edit Mode"
+            $('.btn-toggle-edit-mode').remove();
+            let button = $('<a href="#" native target="_blank" data-mode="read" ' +
+                'class="btn-toggle-edit-mode btn btn-sm mr-2 btn-info text-white font-weight-bold shadow-none">Switch to Edit Mode</a>')
+                .appendTo(buttonContainer);
+
+            button
+                .off('click.toggle-edit')
+                .on('click.toggle-edit', function () {
+                    if (mode === 'read') {
+                        mode = 'edit';
+                        $(this).text('Back to Read Mode');
+                        $('#problems-center-{{$note->id}} .point-table').removeClass('read').addClass('edit');
+                    } else {
+                        refreshDynamicStagPopup();
+                    }
+                    return false;
+                });
 
+            buttonContainer.insertAfter(titleElem);
+
+            setTimeout(() => {
                 $('<div class="d-inline-flex align-self-stretch align-items-center">' +
                     '<span class="autosave-indicator saving text-sm text-secondary">Saving changes &hellip;</span>' +
                     '<span class="autosave-indicator saved text-sm text-secondary">' +
@@ -429,9 +469,7 @@ function isFavoriteProblem($_problem, $_favorites) {
                     ' Saved' +
                     '</span>' +
                     '</div>').appendTo(buttonContainer);
-
-                buttonContainer.insertAfter(titleElem);
-            }, 1000); // HACK - don't autosave the init-time induced 'change' events
+            }, 1000);
         }
         addMCInitializer('problems-center-{{$note->id}}', init, '#problems-center-{{$note->id}}');
     }).call(window);

+ 77 - 0
resources/views/app/patient/segment-templates/_child_plan/edit-plan-in-place.php

@@ -0,0 +1,77 @@
+<?php
+$currentValue = '';
+$previousValue = '';
+$previousChildPlan = null;
+if ($point->lastChildPlan && $point->last_child_plan_point_scoped_note_id === $note->id) {
+    $parsedPlan = json_decode($point->lastChildPlan->data);
+    $currentValue = $parsedPlan->value;
+    $previousChildPlan = \App\Models\Point::where('id', '<', $point->lastChildPlan->id)
+        ->where('category', 'PLAN')
+        ->where('parent_point_id', $point->id)
+        ->orderBy('id', 'DESC')
+        ->first();
+    if($previousChildPlan && $previousChildPlan->data) {
+        $parsedPlan = json_decode($previousChildPlan->data);
+        $previousValue = $parsedPlan->value;
+    }
+}
+else {
+    $previousChildPlan = \App\Models\Point::where('parent_point_id', $point->id)
+        ->where('category', 'PLAN')
+        ->orderBy('id', 'DESC')
+        ->first();
+    if($previousChildPlan && $previousChildPlan->data) {
+        $parsedPlan = json_decode($previousChildPlan->data);
+        $previousValue = $parsedPlan->value;
+    }
+}
+?>
+<div class="d-flex align-items-start">
+    <div visit-moe relative class="d-block flex-grow-1">
+        <form show url="/api/visitPoint/upsertChildPlan" class="mcp-theme-1 w-100" left>
+            <input type="hidden" name="uid" value="<?= $point->uid ?>">
+            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+            <input type="hidden" name="data">
+
+            <?php if($segment->segmentTemplate->internal_name === 'plan_problems' && $previousValue): ?>
+            <div class="d-none disallow-if-value-same-as"><?= str_compact($previousValue) ?></div>
+            <?php endif; ?>
+
+            <?php if($previousValue): ?>
+            <div class="mb-2">
+                <div class="d-flex align-items-baseline mb-1">
+                    <span class="text-sm text-secondary">Previous Plan / <?= friendlier_date($previousChildPlan->created_at) ?> (click to copy)</span>
+                </div>
+                <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
+            </div>
+            <?php endif; ?>
+
+            <div class="mb-0">
+                <div note-rte slim-rte
+                     class="form-group mb-0 border-left border-right rte-holder"
+                     data-field-name="value"><?= $currentValue ?></div>
+            </div>
+            <div class="d-none">
+                <button submit class="btn btn-sm btn-primary mr-2">Save</button>
+                <button cancel class="btn btn-sm btn-default border">Cancel</button>
+            </div>
+        </form>
+    </div>
+    <?php if(!empty($currentValue)): ?>
+        <div visit-moe relative class="d-inline">
+            <a start show href="#" class="pl-2 pr-1 text-center d-block" title="Delete Plan">
+                <i class="fa fa-trash-alt text-danger on-hover-opaque"></i>
+            </a>
+            <form url="/api/visitPoint/destroyCurrentChildPlan" class="mcp-theme-1" right>
+                <input type="hidden" name="uid" value="<?= $point->uid ?>">
+
+                <p class="mb-2">Delete this plan?</p>
+
+                <div>
+                    <button submit class="btn btn-sm btn-danger mr-2">Delete</button>
+                    <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                </div>
+            </form>
+        </div>
+    <?php endif; ?>
+</div>

+ 83 - 0
resources/views/app/patient/segment-templates/_child_review/edit-review-in-place.php

@@ -0,0 +1,83 @@
+<?php
+$currentValue = '';
+$previousValue = '';
+$previousChildReview = null;
+if ($point->lastChildReview && $point->last_child_review_point_scoped_note_id === $note->id) {
+    $parsedReview = json_decode($point->lastChildReview->data);
+    if(@$parsedReview->value) {
+        $currentValue = $parsedReview->value;
+        $previousChildReview = \App\Models\Point::where('id', '<', $point->lastChildReview->id)
+            ->where('category', 'REVIEW')
+            ->where('parent_point_id', $point->id)
+            ->orderBy('id', 'DESC')
+            ->first();
+        if($previousChildReview && $previousChildReview->data) {
+            $parsedReview = json_decode($previousChildReview->data);
+            $previousValue = $parsedReview->value;
+        }
+    }
+}
+else {
+    $previousChildReview = \App\Models\Point::where('parent_point_id', $point->id)
+        ->where('category', 'REVIEW')
+        ->orderBy('id', 'DESC')
+        ->first();
+    if($previousChildReview && $previousChildReview->data) {
+        $parsedReview = json_decode($previousChildReview->data);
+        if(@$parsedReview->value) {
+            $previousValue = $parsedReview->value;
+        }
+    }
+}
+?>
+<div class="d-flex align-items-start">
+    <div visit-moe relative class="d-block flex-grow-1">
+        <form show url="/api/visitPoint/upsertChildReview" class="mcp-theme-1" right>
+            <input type="hidden" name="uid" value="<?= $point->uid ?>">
+            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+            <input type="hidden" name="data">
+
+            <?php if($segment->segmentTemplate->internal_name === 'intake_problems' && $previousValue): ?>
+                <div class="d-none disallow-if-value-same-as"><?= str_compact($previousValue) ?></div>
+            <?php endif; ?>
+
+            <?php if($previousValue): ?>
+                <div class="mb-2">
+                    <div class="d-flex align-items-baseline mb-1">
+                        <span class="text-sm text-secondary">Previous Subjective / <?= friendlier_date($previousChildReview->created_at) ?> (click to copy)</span>
+                    </div>
+                    <div class="p-2 bg-light border inline-html-container click-to-copy"><?= $previousValue ?></div>
+                </div>
+            <?php endif; ?>
+
+            <div class="mb-0">
+                <div note-rte slim-rte
+                     <?= $segment->segmentTemplate->internal_name === 'intake_problems' ? 'use-shortcuts="hpi,user"' : '' ?>
+                     class="form-group mb-0 border-left border-right rte-holder"
+                     data-field-name="value"><?= $currentValue ?></div>
+            </div>
+            <div class="d-none">
+                <button submit class="btn btn-sm btn-primary mr-2">Save</button>
+                <button cancel class="btn btn-sm btn-default border">Cancel</button>
+            </div>
+        </form>
+    </div>
+    <?php if(!empty($currentValue)): ?>
+        <div visit-moe relative class="d-inline">
+            <a start show href="#" class="pl-2 pr-1 text-center d-block" title="Delete Subjective">
+                <i class="fa fa-trash-alt text-danger on-hover-opaque"></i>
+            </a>
+            <form url="/api/visitPoint/destroyCurrentChildReview" class="mcp-theme-1" right>
+                <input type="hidden" name="uid" value="<?= $point->uid ?>">
+
+                <p class="mb-2">Delete this subjective?</p>
+
+                <div>
+                    <button submit class="btn btn-sm btn-danger mr-2">Delete</button>
+                    <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                </div>
+            </form>
+        </div>
+    <?php endif; ?>
+</div>
+

+ 8 - 8
resources/views/app/patient/wizard-partials/common-script.blade.php

@@ -708,7 +708,7 @@ const debounce = (func, wait) => {
     };
 };
 
-let debouncedLifestyleSaver = debounce(function(_trigger) {
+let debouncedWizardEditModeSaver = debounce(function(_trigger) {
     $(_trigger).closest('.stag-popup').find('.autosave-indicator').removeClass('show');
     $(_trigger).closest('.stag-popup').find('.autosave-indicator.saving').addClass('show');
     saveVisitForm(_trigger, true, false, () => {
@@ -721,44 +721,44 @@ let debouncedLifestyleSaver = debounce(function(_trigger) {
 $(document).off('input.auto-save-input', '[if-edit-mode] [visit-moe] form input[type="text"]');
 $(document).on('input.auto-save-input', '[if-edit-mode] [visit-moe] form input[type="text"]', function () {
     if($(this).closest('.point-table').is('.edit')) {
-        debouncedLifestyleSaver(this);
+        debouncedWizardEditModeSaver(this);
     }
 });
 $(document).off('change.auto-save-select-change', '[if-edit-mode] [visit-moe] form select');
 $(document).on('change.auto-save-select-change', '[if-edit-mode] [visit-moe] form select', function () {
     if($(this).closest('.point-table').is('.edit')) {
-        debouncedLifestyleSaver(this);
+        debouncedWizardEditModeSaver(this);
     }
 });
 $(document).off('change.auto-save-checkbox-change', '[if-edit-mode] [visit-moe] form input[type="checkbox"]');
 $(document).on('change.auto-save-checkbox-change', '[if-edit-mode] [visit-moe] form input[type="checkbox"]', function () {
     if($(this).closest('.point-table').is('.edit')) {
-        debouncedLifestyleSaver(this);
+        debouncedWizardEditModeSaver(this);
     }
 });
 $(document).off('change.auto-save-radio-change', '[if-edit-mode] [visit-moe] form input[type="radio"]');
 $(document).on('change.auto-save-radio-change', '[if-edit-mode] [visit-moe] form input[type="radio"]', function () {
     if($(this).closest('.point-table').is('.edit')) {
-        debouncedLifestyleSaver(this);
+        debouncedWizardEditModeSaver(this);
     }
 });
 $(document).off('input.auto-save-textarea-input', '[if-edit-mode] [visit-moe] form textarea');
 $(document).on('input.auto-save-textarea-input', '[if-edit-mode] [visit-moe] form textarea', function () {
     if($(this).closest('.point-table').is('.edit')) {
-        debouncedLifestyleSaver(this);
+        debouncedWizardEditModeSaver(this);
     }
 });
 
 $(document).off('rich-text-input.auto-save-rich-text-input', '[if-edit-mode] [visit-moe] form [note-rte]');
 $(document).on('rich-text-input.auto-save-rich-text-input', '[if-edit-mode] [visit-moe] form [note-rte]', function () {
     if($(this).closest('.point-table').is('.edit')) {
-        debouncedLifestyleSaver(this);
+        debouncedWizardEditModeSaver(this);
     }
 });
 
 $(document).off('rich-text-input.auto-save-rich-text-input', '#frm-cc-regenerate [note-rte]');
 $(document).on('rich-text-input.auto-save-rich-text-input', '#frm-cc-regenerate [note-rte]', function () {
-    debouncedLifestyleSaver(this);
+    debouncedWizardEditModeSaver(this);
 });
 
 initStagSuggest();