Bladeren bron

Universal medications - wip

Universal medications - wip 5
Vijayakrishnan 4 jaren geleden
bovenliggende
commit
39d944553b

+ 6 - 0
app/Http/Controllers/NoteController.php

@@ -2,6 +2,7 @@
 
 namespace App\Http\Controllers;
 
+use App\Models\Page;
 use App\Models\Pro;
 use App\Models\SupplyOrder;
 use App\Models\Ticket;
@@ -76,6 +77,11 @@ class NoteController extends Controller
         return view('client/note', compact('note', 'client'));
     }
 
+    public function sectionView(Request $request, Client $patient, Note $note, Section $section, $form, Page $page = null) {
+        return view("app.patient.page-sections." . $section->sectionTemplate->internal_name . "." . $form,
+            compact('patient', 'note', 'section', 'page'));
+    }
+
     // JAVA ONLY
     // ... if hcpProId is passed, get from request
     public function getDefaultValueForSection($patientID, $sectionTemplateID)

+ 9 - 0
app/Models/Client.php

@@ -530,5 +530,14 @@ class Client extends Model
             ->orderBy('created_at', 'desc');
     }
 
+    public function pages($_type, $_returnShadows, $_note) {
+        return Page
+            ::where('client_id', $this->id)
+            ->where('note_id', $_note->id)
+            ->where('category', $_type)
+            ->where('is_shadow', !!$_returnShadows)
+            ->orderBy('key', 'ASC')
+            ->get();
+    }
 
 }

+ 12 - 0
app/Models/Page.php

@@ -0,0 +1,12 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Model;
+
+class Page extends Model
+{
+
+    protected $table = 'page';
+
+}

+ 26 - 3
public/js/stag-popup.js

@@ -50,6 +50,7 @@ function closeStagPopup(_noEvent = false) {
             }
             else {
                 fastReload()
+                return;
             }
         }
     }
@@ -63,7 +64,7 @@ function closeStagPopup(_noEvent = false) {
     }
     return false;
 }
-function openDynamicStagPopup(url, initer, title, updateParent) {
+function openDynamicStagPopup(url, initer, title, updateParent, style = '') {
     url += (url.indexOf('?') !== -1 ? '&' : '?') + 'popupmode=1';
     showMask();
     window.noMc = true;
@@ -71,7 +72,7 @@ function openDynamicStagPopup(url, initer, title, updateParent) {
         let popup = $('.dynamic-popup[stag-popup-key="' + url + '"]');
         if(!popup.length) {
             $('main.stag-content').append(
-                '<div class="stag-popup stag-popup-lg dynamic-popup mcp-theme-1" stag-popup-key="' + url + '">' +
+                '<div class="stag-popup ' + (style ? style : 'stag-popup-lg') + ' dynamic-popup mcp-theme-1" stag-popup-key="' + url + '">' +
                 '<div class="stag-popup-content p-0">' +
                 '<h3 class="stag-popup-title mb-0 mt-3 mx-3 pb-0 border-bottom-0"><span></span>' +
                 '<a href="#" class="ml-auto text-secondary" onclick="return closeStagPopup()"><i class="fa fa-times-circle"></i></a>\n' +
@@ -125,6 +126,15 @@ function refreshDynamicStagPopup(_url = false) {
     }
     return false;
 }
+function hasResponseError(_data) {
+    let msg = 'Unknown error!';
+    if (_data) {
+        if (_data.success) return false;
+        else if (_data.message) msg = _data.message;
+    }
+    toastr.error(msg);
+    return true;
+}
 (function() {
     window.initStagPopupEvents = function () {
         $(document)
@@ -152,10 +162,23 @@ function refreshDynamicStagPopup(_url = false) {
         $(document)
             .off('click.open-in-stag-popup', 'a[open-in-stag-popup]')
             .on('click.open-in-stag-popup', 'a[open-in-stag-popup]', function() {
-                openDynamicStagPopup(this.href, $(this).attr('mc-initer'), $(this).attr('title'), $(this).is('[update-parent]'));
+                let trig = $(this);
+                openDynamicStagPopup(
+                    this.href,
+                    trig.attr('mc-initer'),
+                    trig.attr('title'),
+                    trig.is('[update-parent]'),
+                    trig.attr('popup-style')
+                );
                 return false;
             });
 
+        $(document)
+            .off('click.close-stag-popup', '.btn-close-stag-popup')
+            .on('click.close-stag-popup', '.btn-close-stag-popup', function() {
+                closeStagPopup();
+                return false;
+            });
     }
     addMCInitializer('stag-popups', window.initStagPopupEvents);
 })();

+ 9 - 2
resources/views/app/patient/note/dashboard_script.blade.php

@@ -290,8 +290,8 @@
                 });
 
                 $(document)
-                    .off('mousedown.enable-edit', '.note-section:not(.edit)')
-                    .on('mousedown.enable-edit', '.note-section:not(.edit)', function(e) {
+                    .off('mousedown.enable-edit', '.note-section:not(.edit):not(.page-driven)')
+                    .on('mousedown.enable-edit', '.note-section:not(.edit):not(.page-driven)', function(e) {
                         if($(this).closest('.note-signed-by-hcp').length) return;
                         e.stopPropagation();
                         e.preventDefault();
@@ -299,6 +299,13 @@
                         return false;
                     });
 
+                // $(document)
+                //     .off('mousedown.enable-edit', '.note-section:not(.edit).page-driven')
+                //     .on('mousedown.enable-edit', '.note-section:not(.edit).page-driven', function(e) {
+                //         alert('booya');
+                //         return false;
+                //     });
+
                 scrollToLatest();
 
                 function __moveSection(_uid, _direction) {

+ 27 - 13
resources/views/app/patient/note/section.blade.php

@@ -4,7 +4,7 @@ if ($latestSectionTS === 0 || $latestSectionTS < $sectionTS) {
     $latestSectionTS = $sectionTS;
 }
 ?>
-<div data-ts="{{$sectionTS}}" class="p-3 border-bottom note-section "
+<div data-ts="{{$sectionTS}}" class="p-3 border-bottom note-section {{ $section->sectionTemplate->is_page_driven ? 'page-driven' : '' }}"
     data-section-uid="{{ $section->uid }}"
     data-section-template-uid="{{ $section->sectionTemplate->uid }}"
     data-section-template-name="{{ $section->sectionTemplate->internal_name }}">
@@ -12,7 +12,7 @@ if ($latestSectionTS === 0 || $latestSectionTS < $sectionTS) {
         @if(!isset($note) || (isset($note) && !$note->is_signed_by_hcp))
             <a class="font-weight-bold mb-2 d-flex align-items-center c-pointer">
                 {{$section->sectionTemplate->title}}
-                @if(!isset($guestAccessCode))
+                @if(!isset($guestAccessCode) && !$section->sectionTemplate->is_page_driven)
                     <span class="d-none if-not-edit"><i class="fa fa-edit ml-2"></i></span>
                     <span class="d-none if-edit edit-trigger font-weight-normal ml-2">Collapse</span>
                     <span class="edit-trigger"></span>
@@ -31,14 +31,17 @@ if ($latestSectionTS === 0 || $latestSectionTS < $sectionTS) {
         @include('app/patient/note/_templates-index')
         @endif
 
-        <?php
-        if (file_exists(storage_path('sections/' . $sectionInternalName . '/actions.php'))) {
-            include(storage_path('sections/' . $sectionInternalName . '/actions.php'));
-        }
-        ?>
-        <?php if (file_exists(storage_path('sections/' . $sectionInternalName . '/actions.blade.php'))): ?>
-        @include('sections/' . $sectionInternalName . '/actions')
-        <?php endif; ?>
+        @if (!$section->sectionTemplate->is_page_driven)
+            @if (file_exists(storage_path('sections/' . $sectionInternalName . '/actions.php'))) {
+            <?php include(storage_path('sections/' . $sectionInternalName . '/actions.php')); ?>
+            @elseif (file_exists(storage_path('sections/' . $sectionInternalName . '/actions.blade.php')))
+                @include('sections/' . $sectionInternalName . '/actions')
+            @endif
+        @else
+            @if (file_exists(resource_path('views/app/patient/page-sections/' . $sectionInternalName . '/actions.blade.php')))
+                @include("app.patient.page-sections.{$sectionInternalName}.actions")
+            @endif
+        @endif
 
         {{-- refresh from client data --}}
         <?php if ($section->sectionTemplate->is_canvas): ?>
@@ -80,16 +83,27 @@ if ($latestSectionTS === 0 || $latestSectionTS < $sectionTS) {
     </div>
     @if(!isset($guestAccessCode) || $section->guest_access_level == 'READ')
     <div class="{{isset($guestAccessCode)?'':'d-none'}} if-not-edit  inset-comment summary-container">
-        {!! !empty($section->summary_html) ? $section->summary_html : '-' !!}
+        <?php if ($section->sectionTemplate->is_page_driven): ?>
+            @include("app.patient.page-sections.{$sectionInternalName}.summary")
+        <?php else: ?>
+            {!! !empty($section->summary_html) ? $section->summary_html : '-' !!}
+        <?php endif; ?>
     </div>
     @endif
 
-    @if(!isset($guestAccessCode) || $section->guest_access_level == 'WRITE')
+    @if(!$section->sectionTemplate->is_page_driven && (!isset($guestAccessCode) || $section->guest_access_level == 'WRITE'))
     <div class="{{isset($guestAccessCode)?'':'d-none'}} if-edit">
 
         <?php
+        // if page
+        if ($section->sectionTemplate->is_page_driven) {
+        $contentData = false;
+        ?>
+        @include("app.patient.page-sections.{$sectionInternalName}.form")
+        <?php
+        }
         // if canvas
-        if ($section->sectionTemplate->is_canvas) {
+        else if ($section->sectionTemplate->is_canvas) {
             $contentData = false;
             if ($canvasData) {
                 $contentData = json_decode($section->content_data, true);

+ 46 - 0
resources/views/app/patient/notes.blade.php

@@ -46,6 +46,52 @@
                     </div>
                 </form>
             </div>
+            <span class="mx-2 text-secondary">|</span>
+            <div moe>
+                <a start show class="py-0 mb-3">Add (univ) *</a>
+                <form url="/api/note/createUsingTemplateWithPages"
+                      redir="/patients/view/{{$patient->uid}}/notes/view/[data]"
+                      class="mcp-theme-1">
+                    <input type="hidden" name="clientUid" value="{{$patient->uid}}">
+                    <input type="hidden" name="hcpProUid" value="{{$pro->uid}}">
+                    <input type="hidden" name="effectiveDateEST" value="{{date("Y-m-d")}}">
+                    <input type="hidden" name="effectiveTime" value="{{date("h:i")}}">
+                    <input type="hidden" name="title" id="note-create-title" value="">
+                    <div class="form-group mb-2">
+                        <label for="" class="text-secondary text-sm mb-1">Note Template *</label>
+                        <select name="noteTemplateUid" class="form-control form-control-sm"
+                                onchange="$('#note-create-title').val($(this).find('option:selected').text())"
+                                required>
+                            <option value=""> --select--</option>
+                            @foreach($pro->noteTemplates as $noteTemplate)
+                                <?php $nT = $noteTemplate->template(); ?>
+                                <option value="{{$nT->uid}}">{{$nT->title}}</option>
+                            @endforeach
+                        </select>
+                    </div>
+                    <div class="mb-2">
+                        <label for="" class="text-secondary text-sm mb-1">Method *</label>
+                        <select name="method" class="form-control form-control-sm note-method-select" required>
+                            <option value="AUDIO">Audio</option>
+                            <option value="VIDEO">Video</option>
+                            <option value="IN_CLINIC">In-Clinic</option>
+                            <option value="HOUSE_CALL">House Call</option>
+                        </select>
+                    </div>
+                    <div class="form-group if-in-clinic">
+                        <label for="" class="text-secondary text-sm mb-1">Location</label>
+                        <select name="hcpCompanyLocationUid" class="form-control">
+                            <option value=""></option>
+                            @foreach($pro->companyLocations() as $location)
+                                <option value="{{$location->uid}}">{{$location->line1}} {{$location->city}}</option>
+                            @endforeach
+                        </select>
+                    </div>
+                    <div class="form-group m-0">
+                        <button submit class="btn btn-primary btn-sm">submit</button>
+                    </div>
+                </form>
+            </div>
             <select class="ml-auto max-width-300px form-control form-control-sm"
                     onchange="fastLoad('/patients/view/{{$patient->uid}}/notes/' + this.value, true, false, false)">
                 <option value="active" {{ $filter === 'active' ? 'selected' : '' }}>Active notes</option>

+ 12 - 0
resources/views/app/patient/page-sections/v0521_rx/actions.blade.php

@@ -0,0 +1,12 @@
+<?php $view = 'form'; ?>
+<div id="v0521_rx_actions" class="ml-2">
+    <a native target="_blank"
+       open-in-stag-popup
+       update-parent
+       mc-initer="medications-{{$patient->id}}"
+       popup-style=""
+       title="Medications"
+       href="{{route('patients.view.notes.view.section-view', compact('patient', 'note', 'section', 'view'))}}">
+        Edit
+    </a>
+</div>

+ 72 - 0
resources/views/app/patient/page-sections/v0521_rx/add.blade.php

@@ -0,0 +1,72 @@
+<div class="p-3 border-top mt-3 mcp-theme-1" id="add-medication-container">
+    <form action="">
+        <div class="mb-2">
+            <label class="mb-1 text-secondary text-sm">Title *</label>
+            <input type="text" class="form-control form-control-sm" name="title" required>
+        </div>
+        <div class="row mb-2">
+            <div class="col-6">
+                <label class="mb-1 text-secondary text-sm">Strength/Form *</label>
+                <input type="text" class="form-control form-control-sm" name="strength" required>
+            </div>
+            <div class="col-6 pl-0">
+                <label class="mb-1 text-secondary text-sm">Frequency</label>
+                <input type="text" class="form-control form-control-sm" name="frequency">
+            </div>
+        </div>
+        <div class="mb-2">
+            <label class="mb-1 text-secondary text-sm">Detail</label>
+            <textarea class="form-control form-control-sm" name="detail"></textarea>
+        </div>
+        <hr class="m-neg-4">
+        <div class="">
+            <label class="mb-1 text-secondary d-flex align-items-center">
+                <input type="checkbox" name="was_existing_at_visit_start">
+                <span class="ml-2">Patient is already on this medication</span>
+            </label>
+        </div>
+        <hr class="m-neg-4">
+        <div class="d-flex align-items-center justify-content-center">
+            <button class="btn btn-sm btn-primary px-3 mr-2 btn-save" type="button">Save</button>
+            <button class="btn btn-sm btn-default border btn-close-stag-popup" type="button">Cancel</button>
+        </div>
+    </form>
+</div>
+<script>
+    (function() {
+        function init() {
+            let parent = $('#add-medication-container'),
+                form = parent.find('form').first();
+            parent.find('.btn-save')
+                .off('click')
+                .on('click', function() {
+                    if(!form[0].checkValidity()) {
+                        form[0].reportValidity();
+                        return false;
+                    }
+                    showMask();
+                    let payload = {
+                        noteUid: '{{$note->uid}}',
+                        clientUid: '{{$patient->uid}}',
+                        category: 'medication',
+                        key: form.find('[name="title"]').val(),
+                        data: JSON.stringify({
+                            title: form.find('[name="title"]').val(),
+                            strength: form.find('[name="strength"]').val(),
+                            frequency: form.find('[name="frequency"]').val(),
+                            detail: form.find('[name="detail"]').val(),
+                            was_existing_at_visit_start: form.find('[name="was_existing_at_visit_start"]').is(':checked'),
+                        })
+                    };
+                    $.post('/api/page/createCore', payload, _data => {
+                        if(!hasResponseError(_data)) {
+                            toastr.success('Medication added!');
+                            closeStagPopup();
+                        }
+                    }, 'json');
+                    return false;
+                });
+        }
+        addMCInitializer('add-medication', init, '#add-medication-container');
+    }).call(window);
+</script>

+ 3 - 0
resources/views/app/patient/page-sections/v0521_rx/default.php

@@ -0,0 +1,3 @@
+<?php
+
+$contentData = $patient->pages('medication');

+ 76 - 0
resources/views/app/patient/page-sections/v0521_rx/edit.blade.php

@@ -0,0 +1,76 @@
+<?php $parsed = $page->data ? json_decode($page->data) : false; ?>
+@if(!!$parsed)
+<div class="p-3 border-top mt-3 mcp-theme-1" id="edit-medication-container-{{$page->id}}">
+    <form action="">
+        <div class="mb-2">
+            <label class="mb-1 text-secondary text-sm">Title *</label>
+            <input type="text" class="form-control form-control-sm" name="title" value="{{$page->key}}" readonly>
+        </div>
+        <div class="row mb-2">
+            <div class="col-6">
+                <label class="mb-1 text-secondary text-sm">Strength/Form *</label>
+                <input type="text" class="form-control form-control-sm" name="strength" value="{{$parsed->strength}}" required>
+            </div>
+            <div class="col-6 pl-0">
+                <label class="mb-1 text-secondary text-sm">Frequency</label>
+                <input type="text" class="form-control form-control-sm" name="frequency" value="{{$parsed->frequency}}">
+            </div>
+        </div>
+        <div class="mb-2">
+            <label class="mb-1 text-secondary text-sm">Detail</label>
+            <textarea class="form-control form-control-sm" name="detail">{!! $parsed->detail  !!}</textarea>
+        </div>
+        <hr class="m-neg-4">
+        <div class="">
+            <label class="mb-1 text-secondary d-flex align-items-center">
+                <input type="checkbox" name="was_existing_at_visit_start">
+                <span class="ml-2">Patient is already on this medication</span>
+            </label>
+        </div>
+        <hr class="m-neg-4">
+        <div class="d-flex align-items-center justify-content-center">
+            <button class="btn btn-sm btn-primary px-3 mr-2 btn-save" type="button">Save</button>
+            <button class="btn btn-sm btn-default border btn-close-stag-popup" type="button">Cancel</button>
+        </div>
+    </form>
+</div>
+<script>
+    (function() {
+        function init() {
+            let parent = $('#edit-medication-container-{{$page->id}}'),
+                form = parent.find('form').first();
+            parent.find('.btn-save')
+                .off('click')
+                .on('click', function() {
+                    if(!form[0].checkValidity()) {
+                        form[0].reportValidity();
+                        return false;
+                    }
+                    showMask();
+                    let payload = {
+                        uid: '{{$page->uid}}',
+                        newData: JSON.stringify({
+                            title: form.find('[name="title"]').val(),
+                            strength: form.find('[name="strength"]').val(),
+                            frequency: form.find('[name="frequency"]').val(),
+                            detail: form.find('[name="detail"]').val(),
+                            was_existing_at_visit_start: form.find('[name="was_existing_at_visit_start"]').is(':checked'),
+                        })
+                    };
+                    $.post('/api/page/change', payload, _data => {
+                        if(!hasResponseError(_data)) {
+                            toastr.success('Medication updated!');
+                            closeStagPopup();
+                        }
+                    }, 'json');
+                    return false;
+                });
+        }
+        addMCInitializer('edit-medication-{{$page->id}}', init, '#edit-medication-container-{{$page->id}}');
+    }).call(window);
+</script>
+@else
+    <div class="p-3 border-top mt-3 mcp-theme-1" id="edit-medication-container-{{$page->id}}">
+        <div class="text-secondary">Invalid/corrupt input!</div>
+    </div>
+@endif

+ 104 - 0
resources/views/app/patient/page-sections/v0521_rx/form.blade.php

@@ -0,0 +1,104 @@
+<?php
+use App\Models\Client;
+use App\Models\Note;
+/** @var Client $patient */
+/** @var Note $note */
+?>
+<div class="p-3 border-top mt-3 mcp-theme-1" id="medications-container">
+    <?php $view = 'add'; ?>
+    <a class="btn btn-sm btn-primary text-white btn-add-medication"
+       native target="_blank"
+       open-in-stag-popup
+       mc-initer="add-medication"
+       update-parent
+       popup-style="narrow"
+       title="Add Medication"
+       href="{{route('patients.view.notes.view.section-view', compact('patient', 'note', 'section', 'view'))}}">
+        + Add
+    </a>
+    <?php
+        $items = $patient->pages('medication', true, $note);
+        $sorted = [];
+
+    ?>
+    <table class="table table-striped table-sm table-bordered mb-0">
+        @if($items && count($items))
+            <thead>
+            <tr>
+                <th class="border-bottom-0 px-2 text-secondary w-25">Title</th>
+                <th class="border-bottom-0 px-2 text-secondary">Strength/Form</th>
+                <th class="border-bottom-0 px-2 text-secondary">Frequency</th>
+                <th class="border-bottom-0 px-2 text-secondary w-25">Detail</th>
+                <th class="border-bottom-0 px-2 text-secondary w-25">Created</th>
+                <th class="border-bottom-0 px-2 text-secondary">Actions</th>
+            </tr>
+            </thead>
+            <tbody>
+            <?php foreach($items as $page):
+                $parsed = $page->data ? json_decode($page->data) : false; ?>
+                @if($parsed)
+                    <tr>
+                        <td class="px-2">{{ $page->key }}
+                            <?php if(!!@$parsed->removed_during_note_uid): ?>
+                                <span class="text-warning-mellow text-sm mr-2 font-weight-bold">(Removed<?= @$parsed->removed_during_note_uid === $note->uid ? ' during this visit' : '' ?>)</span>
+                            <?php elseif(!!@$parsed->was_existing_at_visit_start): ?>
+                                <span class="text-secondary text-sm mr-2 font-weight-bold">(Existing)</span>
+                            <?php endif; ?>
+                        </td>
+                        <td class="px-2">{{ $parsed->strength ? $parsed->strength : '-' }}</td>
+                        <td class="px-2">{{ $parsed->frequency ? $parsed->frequency : '-' }}</td>
+                        <td class="px-2">{{ $parsed->detail ? $parsed->detail : '-' }}</td>
+                        <td class="px-2">{{ friendlier_date_time($page->created_at) }}</td>
+                        <td class="px-2 text-nowrap">
+                            <?php $view = 'edit'; ?>
+                            <a native target="_blank"
+                               open-in-stag-popup
+                               mc-initer="edit-medication-{{$page->id}}"
+                               update-parent
+                               popup-style="narrow"
+                               title="Edit Medication"
+                               href="{{route('patients.view.notes.view.section-view', compact('patient', 'note', 'section', 'view', 'page'))}}">
+                                Edit
+                            </a>
+                            @if(!@$parsed->removed_during_note_uid)
+                                <?php $view = 'remove'; ?>
+                                <a class="text-danger ml-2"
+                                   native target="_blank"
+                                   open-in-stag-popup
+                                   mc-initer="remove-medication-{{$page->id}}"
+                                   update-parent
+                                   popup-style="narrow"
+                                   title="Remove Medication?"
+                                   href="{{route('patients.view.notes.view.section-view', compact('patient', 'note', 'section', 'view', 'page'))}}">
+                                    Remove
+                                </a>
+                            @endif
+                        </td>
+                    </tr>
+                @endif
+            <?php endforeach; ?>
+            </tbody>
+        @else
+            <tbody>
+            <tr>
+                <td class="text-secondary p-3">No medications added yet!</td>
+            </tr>
+            </tbody>
+        @endif
+    </table>
+</div>
+<script>
+    (function() {
+        function init() {
+            $('.stag-popup-content .stag-popup-title .btn-add-medication').remove();
+            $('.btn-add-medication')
+                .addClass('ml-3')
+                .insertAfter(
+                    $('#medications-container')
+                        .closest('.stag-popup-content')
+                        .find('.stag-popup-title>span')
+                );
+        }
+        addMCInitializer('medications-{{$patient->id}}', init, '#medications-container');
+    }).call(window);
+</script>

+ 0 - 0
resources/views/app/patient/page-sections/v0521_rx/processor.php


+ 52 - 0
resources/views/app/patient/page-sections/v0521_rx/remove.blade.php

@@ -0,0 +1,52 @@
+<?php $parsed = $page->data ? json_decode($page->data) : false; ?>
+@if(!!$parsed)
+<div class="p-3 border-top mt-3 mcp-theme-1" id="remove-medication-container-{{$page->id}}">
+    <form action="">
+        <div class="mb-2">
+            <label class="mb-1 text-secondary text-sm">Removal Reason/Memo *</label>
+            <textarea class="form-control form-control-sm" name="removal_memo" required>{!! @$parsed->removal_memo ? $parsed->removal_memo : '' !!}</textarea>
+        </div>
+        <hr class="m-neg-4">
+        <div class="d-flex align-items-center justify-content-center">
+            <button class="btn btn-sm btn-danger px-3 mr-2 btn-save" type="button">Yes</button>
+            <button class="btn btn-sm btn-default border btn-close-stag-popup px-3" type="button">No</button>
+        </div>
+    </form>
+</div>
+<script>
+    (function() {
+        function init() {
+            let parent = $('#remove-medication-container-{{$page->id}}'),
+                form = parent.find('form').first();
+            parent.find('.btn-save')
+                .off('click')
+                .on('click', function() {
+                    if(!form[0].checkValidity()) {
+                        form[0].reportValidity();
+                        return false;
+                    }
+                    showMask();
+                    let newData = {!! $page->data !!};
+                    newData.removed_during_note_uid = '{{$note->uid}}';
+                    newData.removal_memo = form.find('[name="memo"]').val()
+                    let payload = {
+                        uid: '{{$page->uid}}',
+                        newData: JSON.stringify(newData)
+                    };
+                    $.post('/api/page/change', payload, _data => {
+                        if(!hasResponseError(_data)) {
+                            toastr.success('Medication updated!');
+                            closeStagPopup();
+                        }
+                    }, 'json');
+                    return false;
+                });
+        }
+        addMCInitializer('remove-medication-{{$page->id}}', init, '#remove-medication-container-{{$page->id}}');
+    }).call(window);
+</script>
+@else
+    <div class="p-3 border-top mt-3 mcp-theme-1" id="remove-medication-container-{{$page->id}}">
+        <div class="text-secondary">Invalid/corrupt input!</div>
+    </div>
+@endif

+ 39 - 0
resources/views/app/patient/page-sections/v0521_rx/summary.php

@@ -0,0 +1,39 @@
+<?php
+
+use App\Models\Client;
+/** @var Client $patient */
+
+$items = $patient->pages('medication', true, $note);
+
+if($items && count($items)) {
+    for ($i = 0; $i < count($items); $i++) {
+        $page = $items[$i];
+        $parsed = $page->data ? json_decode($page->data) : false;
+        if(!!$parsed) {
+        ?>
+            <div class="mt-2 <?= !!@$parsed->removed_during_note_uid ? 'on-hover-opaque' : '' ?>">
+                <div class="">
+                    <b><?= $page->key ?></b>
+                    <?= !!@$parsed->strength ? '/&nbsp;' . @$parsed->strength : '' ?>
+                    <?= !!@$parsed->frequency ? '/&nbsp;' . @$parsed->frequency : '' ?>
+                    <?php if(!!@$parsed->removed_during_note_uid): ?>
+                        /&nbsp;<span class="text-warning-mellow text-sm mr-2 font-weight-bold">(Removed<?= @$parsed->removed_during_note_uid === $note->uid ? ' during this visit' : '' ?>)</span>
+                    <?php elseif(!!@$parsed->was_existing_at_visit_start): ?>
+                        /&nbsp;<span class="text-secondary text-sm mr-2 font-weight-bold">(Existing)</span>
+                    <?php endif; ?>
+                </div>
+                <?php
+                $detailPlain = @$parsed->detail ? $parsed->detail : '';
+                if(!!$detailPlain):
+                ?>
+                <div class="text-secondary"><?= $detailPlain ?></div>
+                <?php endif; ?>
+            </div>
+        <?php
+        }
+    }
+}
+else {
+    echo '<div class="text-secondary">Nothing here yet!</div>';
+}
+?>

+ 1 - 0
routes/web.php

@@ -187,6 +187,7 @@ Route::middleware('pro.auth')->group(function () {
             Route::get('notes/{filter?}', 'PatientController@notes')->name('notes');
             Route::name('notes.view.')->prefix('notes/view/{note}')->group(function () {
                 Route::get('', 'NoteController@dashboard')->name('dashboard');
+                Route::get('section-view/{section}/{view}/{page?}', 'NoteController@sectionView')->name('section-view');
             });
             Route::get('sections', 'PatientController@sections')->name('sections');
             Route::get('handouts', 'PatientController@handouts')->name('handouts');