|
@@ -0,0 +1,665 @@
|
|
|
|
+<?php
|
|
|
|
+
|
|
|
|
+use App\Models\Point;
|
|
|
|
+use App\Models\Client;
|
|
|
|
+use App\Models\Note;
|
|
|
|
+use App\Models\Segment;
|
|
|
|
+
|
|
|
|
+/** @var Client $patient */
|
|
|
|
+/** @var Note $note */
|
|
|
|
+
|
|
|
|
+$points = Point
|
|
|
|
+ ::where('client_id', $patient->id)
|
|
|
|
+ ->where('category', 'ALLERGY')
|
|
|
|
+ ->where('is_removed_due_to_entry_error', false)
|
|
|
|
+ ->orderBy('is_removed')
|
|
|
|
+ ->orderBy('removal_effective_date', 'DESC')
|
|
|
|
+ ->orderBy('created_at')
|
|
|
|
+ ->get();
|
|
|
|
+foreach ($points as $point) {
|
|
|
|
+ if ($point->data) {
|
|
|
|
+ $point->data = json_decode($point->data);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+$allergies = $points;
|
|
|
|
+?>
|
|
|
|
+
|
|
|
|
+<div class="mt-3 p-3 border-top min-height-500px" id="allergies-center-{{$note->id}}">
|
|
|
|
+ <div>
|
|
|
|
+
|
|
|
|
+ <div class="mb-2 font-weight-bold font-size-14 text-secondary">Allergies</div>
|
|
|
|
+ <table class="table table-sm table-bordered table-striped mb-0 bg-white mb-2">
|
|
|
|
+ <thead>
|
|
|
|
+ <tr class="">
|
|
|
|
+ <th class="border-bottom-0 text-secondary text-center width-30px">Rel.</th>
|
|
|
|
+ <th class="border-bottom-0 text-secondary">Name</th>
|
|
|
|
+ <th class="border-bottom-0 text-secondary">Active?</th>
|
|
|
|
+ <th class="border-bottom-0 text-secondary">Edit</th>
|
|
|
|
+ <th class="border-bottom-0 text-secondary">Started</th>
|
|
|
|
+ <th class="border-bottom-0 text-secondary">Ended</th>
|
|
|
|
+ <th class="border-bottom-0 text-secondary w-25">Last Review</th>
|
|
|
|
+ <th class="border-bottom-0 text-secondary w-25">Last Plan</th>
|
|
|
|
+ </tr>
|
|
|
|
+ </thead>
|
|
|
|
+ <?php $prevRowRemoved = -1; ?>
|
|
|
|
+ <?php foreach($allergies as $allergy): ?>
|
|
|
|
+ <?php $point = $allergy; ?>
|
|
|
|
+ @if($prevRowRemoved !== -1 && $prevRowRemoved !== $allergy->is_removed)
|
|
|
|
+ <tr>
|
|
|
|
+ <td colspan="9" class="px-0 pt-1 pb-0 on-hover-opaque bg-secondary"></td>
|
|
|
|
+ </tr>
|
|
|
|
+ @endif
|
|
|
|
+ <?php $prevRowRemoved = $allergy->is_removed; ?>
|
|
|
|
+ <?php $rel = $allergy->relevanceToNote($note); ?>
|
|
|
|
+ <tr class="">
|
|
|
|
+ <td class="text-center">
|
|
|
|
+ <a href="#" class="toggle-relevance"
|
|
|
|
+ data-relevant="{{$rel ? '1' : '0'}}"
|
|
|
|
+ data-rel-uid="{{$rel ? $rel->uid : ''}}"
|
|
|
|
+ data-point-uid="{{$allergy->uid}}"
|
|
|
|
+ title="Mark as{{$rel ? ' not ' : ' '}}relevant to this visit">
|
|
|
|
+ @if($rel)
|
|
|
|
+ <i class="fa fa-star text-sm text-info"></i>
|
|
|
|
+ @else
|
|
|
|
+ <i class="fa fa-star text-sm text-secondary on-hover-opaque"></i>
|
|
|
|
+ @endif
|
|
|
|
+ </a>
|
|
|
|
+ </td>
|
|
|
|
+ <td>
|
|
|
|
+ <div class="d-flex align-items-baseline">
|
|
|
|
+ @if($allergy->is_removed)
|
|
|
|
+ <i class="text-warning-mellow fa fa-circle text-sm on-hover-opaque mr-2"></i>
|
|
|
|
+ @else
|
|
|
|
+ <i class="text-success fa fa-circle text-sm on-hover-opaque mr-2"></i>
|
|
|
|
+ @endif
|
|
|
|
+ <div>
|
|
|
|
+ <b><?= !!@($allergy->data->name) ? @($allergy->data->name) : '-' ?></b>
|
|
|
|
+ @if(!$allergy->is_removed && $allergy->added_in_note_id === $note->id)
|
|
|
|
+ <div class="mt-1 text-sm text-secondary">Added during this visit
|
|
|
|
+ @if($allergy->addition_reason_category === 'ON_INTAKE')
|
|
|
|
+ (existing)
|
|
|
|
+ @elseif($allergy->addition_reason_category === 'DURING_VISIT')
|
|
|
|
+ (new)
|
|
|
|
+ @endif
|
|
|
|
+ </div>
|
|
|
|
+ @endif
|
|
|
|
+ @if($allergy->is_removed && $allergy->removed_in_note_id === $note->id)
|
|
|
|
+ <div class="mt-1 text-sm text-secondary">Removed during this visit</div>
|
|
|
|
+ @endif
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ </td>
|
|
|
|
+ <td>
|
|
|
|
+ @if($allergy->is_removed)
|
|
|
|
+ NO
|
|
|
|
+ @else
|
|
|
|
+ <b>YES</b>
|
|
|
|
+ @endif
|
|
|
|
+ </td>
|
|
|
|
+ <td>
|
|
|
|
+ <div moe wide>
|
|
|
|
+ <a start show href="#" title="Edit">Edit</a>
|
|
|
|
+ <form url="/api/visitPoint/updateTopLevel" class="mcp-theme-1 frm-edit-allergy">
|
|
|
|
+ <input type="hidden" name="uid" value="<?= $allergy->uid ?>">
|
|
|
|
+ <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
|
|
|
|
+ <p class="mb-2"><b>Update Allergy</b></p>
|
|
|
|
+
|
|
|
|
+ @if($allergy->added_in_note_id === $note->id)
|
|
|
|
+
|
|
|
|
+ <input type="hidden" name="data">
|
|
|
|
+
|
|
|
|
+ <input type="hidden" data-name="damConceptId" value="{{@$allergy->data->damConceptId}}">
|
|
|
|
+ <input type="hidden" data-name="damConceptIdType" value="{{@$allergy->data->damConceptIdType}}">
|
|
|
|
+
|
|
|
|
+ <div class="mb-2">
|
|
|
|
+ <label class="text-sm text-secondary mb-0">Name</label>
|
|
|
|
+ <input type="text" data-name="name" class="form-control form-control-sm"
|
|
|
|
+ value="{{@$allergy->data->name}}"
|
|
|
|
+ stag-suggest
|
|
|
|
+ stag-suggest-ep="/fdb-allergy-suggest/json">
|
|
|
|
+ </div>
|
|
|
|
+
|
|
|
|
+ <div class="row mb-2">
|
|
|
|
+ <div class="col-6 pr-0">
|
|
|
|
+ <label class="text-sm mb-0">Start Date</label>
|
|
|
|
+ <input type="date"
|
|
|
|
+ data-name="start_date"
|
|
|
|
+ value="{{@$allergy->data->start_date}}"
|
|
|
|
+ class="form-control form-control-sm min-width-unset">
|
|
|
|
+ </div>
|
|
|
|
+ <div class="col-6">
|
|
|
|
+ <label class="text-sm mb-0">Added By</label>
|
|
|
|
+ <input type="text"
|
|
|
|
+ data-name="prescriber"
|
|
|
|
+ value="{{@$allergy->data->prescriber}}"
|
|
|
|
+ class="form-control form-control-sm min-width-unset">
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+
|
|
|
|
+ @else
|
|
|
|
+
|
|
|
|
+ <div class="mb-2 bg-light p-2 border">
|
|
|
|
+ <p class="mb-1 font-weight-bold">
|
|
|
|
+ {{ @$allergy->data->name }}
|
|
|
|
+ </p>
|
|
|
|
+ <div class="text-secondary text-sm">Clinical details cannot be modified since the allergy was added prior to this visit.</div>
|
|
|
|
+ </div>
|
|
|
|
+
|
|
|
|
+ @endif
|
|
|
|
+
|
|
|
|
+ <hr class="my-3">
|
|
|
|
+
|
|
|
|
+ <div class="row mb-2">
|
|
|
|
+ <div class="col-4 pr-0">
|
|
|
|
+ <label class="text-sm mb-0">When Added</label>
|
|
|
|
+ <select class="form-control form-control-sm min-width-unset" name="additionReasonCategory" required>
|
|
|
|
+ <option value="">-- select --</option>
|
|
|
|
+ <option value="ON_INTAKE" {{$allergy->addition_reason_category === 'ON_INTAKE' ? 'selected' : ''}}>On Intake</option>
|
|
|
|
+ <option value="DURING_VISIT" {{$allergy->addition_reason_category === 'DURING_VISIT' ? 'selected' : ''}}>During Visit</option>
|
|
|
|
+ </select>
|
|
|
|
+ </div>
|
|
|
|
+ <div class="col-8">
|
|
|
|
+ <label class="text-sm mb-0 min-width-unset">Addition Memo</label>
|
|
|
|
+ <input type="text"
|
|
|
|
+ name="additionReasonMemo"
|
|
|
|
+ value="{{$allergy->addition_reason_memo}}"
|
|
|
|
+ class="form-control form-control-sm min-width-unset">
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+
|
|
|
|
+ <hr class="my-3">
|
|
|
|
+
|
|
|
|
+ <div class="row mb-2">
|
|
|
|
+ <div class="col-6 pr-0">
|
|
|
|
+ <label class="text-sm mb-0 min-width-unset">Is allergy active?</label>
|
|
|
|
+ <select class="form-control form-control-sm min-width-unset" name="isRemoved" required>
|
|
|
|
+ <option value="">-- select --</option>
|
|
|
|
+ <option value="0" {{!$allergy->is_removed ? 'selected' : ''}}>Yes</option>
|
|
|
|
+ <option value="1" {{$allergy->is_removed ? 'selected' : ''}}>No</option>
|
|
|
|
+ </select>
|
|
|
|
+ </div>
|
|
|
|
+ <div class="col-6 is_removed_ui_1" style="display: none">
|
|
|
|
+ <label class="text-sm mb-0 min-width-unset">Is entry error?</label>
|
|
|
|
+ <select class="form-control form-control-sm min-width-unset" name="isRemovedDueToEntryError">
|
|
|
|
+ <option value="1" {{$allergy->is_removed_due_to_entry_error ? 'selected' : ''}}>Yes</option>
|
|
|
|
+ <option value="0" {{!$allergy->is_removed_due_to_entry_error ? 'selected' : ''}}>No</option>
|
|
|
|
+ </select>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+
|
|
|
|
+ <div class="row mb-2 is_removed_ui_2" style="display: none">
|
|
|
|
+ <div class="col-4 pr-0">
|
|
|
|
+ <label class="text-sm mb-0 min-width-unset">When Removed</label>
|
|
|
|
+ <select class="form-control form-control-sm min-width-unset" name="removalReasonCategory">
|
|
|
|
+ <option value="">-- select --</option>
|
|
|
|
+ <option value="ON_INTAKE" {{$allergy->removal_reason_category === 'ON_INTAKE' ? 'selected' : ''}}>On Intake</option>
|
|
|
|
+ <option value="DURING_VISIT" {{$allergy->removal_reason_category === 'DURING_VISIT' ? 'selected' : ''}}>During Visit</option>
|
|
|
|
+ </select>
|
|
|
|
+ </div>
|
|
|
|
+ <div class="col-4 pr-0">
|
|
|
|
+ <label class="text-sm mb-0 min-width-unset">End Date</label>
|
|
|
|
+ <input type="date"
|
|
|
|
+ name="removalEffectiveDate"
|
|
|
|
+ value="{{$allergy->removal_effective_date ? $allergy->removal_effective_date : ''}}"
|
|
|
|
+ class="form-control form-control-sm min-width-unset">
|
|
|
|
+ </div>
|
|
|
|
+ <div class="col-4">
|
|
|
|
+ <label class="text-sm mb-0 min-width-unset">Removal By/Memo</label>
|
|
|
|
+ <input type="text"
|
|
|
|
+ name="removalReasonMemo"
|
|
|
|
+ value="{{$allergy->removal_reason_memo}}"
|
|
|
|
+ class="form-control form-control-sm min-width-unset">
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+
|
|
|
|
+ <div>
|
|
|
|
+ <button type="submit" class="btn-save-allergy btn btn-sm btn-primary mr-2">Save</button>
|
|
|
|
+ <button cancel class="btn btn-sm btn-default border">Cancel</button>
|
|
|
|
+ </div>
|
|
|
|
+ </form>
|
|
|
|
+ </div>
|
|
|
|
+ </td>
|
|
|
|
+ <td>
|
|
|
|
+ <?= !!@($allergy->data->start_date) ? @($allergy->data->start_date) : '-' ?>
|
|
|
|
+ </td>
|
|
|
|
+ <td>
|
|
|
|
+ <?= !!@($allergy->removal_effective_date) ? @($allergy->removal_effective_date) : '-' ?>
|
|
|
|
+ @if(!!@($allergy->removal_reason_memo))
|
|
|
|
+ <div class="mt-1 text-sm text-secondary"><?= !!@($allergy->removal_reason_memo) ? @($allergy->removal_reason_memo) : '-' ?></div>
|
|
|
|
+ @endif
|
|
|
|
+ </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-nowrap">
|
|
|
|
+ <a class="px-2 view-review-log"
|
|
|
|
+ native target="_blank"
|
|
|
|
+ open-in-stag-popup
|
|
|
|
+ popup-style="stag-popup-md"
|
|
|
|
+ title="Review 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');
|
|
|
|
+ }
|
|
|
|
+ ?>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ </td>
|
|
|
|
+ <td>
|
|
|
|
+ <div class="d-flex align-items-start">
|
|
|
|
+ <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-nowrap">
|
|
|
|
+ <a class="px-2 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');
|
|
|
|
+ }
|
|
|
|
+ ?>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ </td>
|
|
|
|
+ </tr>
|
|
|
|
+ <?php endforeach; ?>
|
|
|
|
+ </table>
|
|
|
|
+
|
|
|
|
+ <div class="d-flex align-items-center">
|
|
|
|
+ <div class="mt-1 w-100 border p-2 bg-aliceblue border-info rounded">
|
|
|
|
+ <form action="/api/visitPoint/addTopLevel" class="mcp-theme-1 w-100" id="frm-add-allergy">
|
|
|
|
+ <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
|
|
|
|
+ <input type="hidden" name="category" value="ALLERGY">
|
|
|
|
+ <input type="hidden" name="data">
|
|
|
|
+
|
|
|
|
+ <input type="hidden" data-name="damConceptId">
|
|
|
|
+ <input type="hidden" data-name="damConceptIdType">
|
|
|
|
+
|
|
|
|
+ <p class="mb-2"><b>Add Allergy</b></p>
|
|
|
|
+
|
|
|
|
+ <div class="row">
|
|
|
|
+ <div class="col-7">
|
|
|
|
+ <div class="row mb-2">
|
|
|
|
+ <div class="col-12">
|
|
|
|
+ <label class="text-sm text-secondary mb-0">Name</label>
|
|
|
|
+ <input type="text" data-name="name" class="form-control form-control-sm"
|
|
|
|
+ stag-suggest
|
|
|
|
+ stag-suggest-ep="/fdb-allergy-suggest/json"
|
|
|
|
+ required>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ <div class="row mb-2">
|
|
|
|
+ <div class="col-6 pr-0">
|
|
|
|
+ <label class="text-sm mb-0">Start Date</label>
|
|
|
|
+ <input type="date"
|
|
|
|
+ data-name="start_date"
|
|
|
|
+ class="form-control form-control-sm min-width-unset">
|
|
|
|
+ </div>
|
|
|
|
+ <div class="col-6">
|
|
|
|
+ <label class="text-sm mb-0">Added By</label>
|
|
|
|
+ <input type="text"
|
|
|
|
+ data-name="prescriber"
|
|
|
|
+ class="form-control form-control-sm min-width-unset">
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ <!--<div class="mb-2">
|
|
|
|
+ <label class="text-sm mb-1">Description</label>
|
|
|
|
+ <textarea rows="1" data-name="description" class="form-control form-control-sm"></textarea>
|
|
|
|
+ </div>-->
|
|
|
|
+
|
|
|
|
+ <hr class="my-3">
|
|
|
|
+
|
|
|
|
+ <div class="row mb-2">
|
|
|
|
+ <div class="col-4 pr-0">
|
|
|
|
+ <label class="text-sm mb-0">When Added</label>
|
|
|
|
+ <select class="form-control form-control-sm min-width-unset" name="additionReasonCategory" required>
|
|
|
|
+ <option value="">-- select --</option>
|
|
|
|
+ <option value="ON_INTAKE">On Intake</option>
|
|
|
|
+ <option value="DURING_VISIT">During Visit</option>
|
|
|
|
+ </select>
|
|
|
|
+ </div>
|
|
|
|
+ <div class="col-8">
|
|
|
|
+ <label class="text-sm mb-0 min-width-unset">Addition Memo</label>
|
|
|
|
+ <input type="text"
|
|
|
|
+ name="additionReasonMemo"
|
|
|
|
+ class="form-control form-control-sm min-width-unset">
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+
|
|
|
|
+ <hr class="my-3">
|
|
|
|
+
|
|
|
|
+ <div class="row mb-2">
|
|
|
|
+ <div class="col-6 pr-0">
|
|
|
|
+ <label class="text-sm mb-0 min-width-unset">Is allergy active?</label>
|
|
|
|
+ <select class="form-control form-control-sm min-width-unset" name="isRemoved" required>
|
|
|
|
+ <option value="0" selected>Yes</option>
|
|
|
|
+ <option value="1">No</option>
|
|
|
|
+ </select>
|
|
|
|
+ </div>
|
|
|
|
+ <input type="hidden" name="isRemovedDueToEntryError" value="0">
|
|
|
|
+ </div>
|
|
|
|
+
|
|
|
|
+ <div class="row mb-2 is_removed_ui_2" style="display: none">
|
|
|
|
+ <div class="col-4 pr-0">
|
|
|
|
+ <label class="text-sm mb-0 min-width-unset">When Removed</label>
|
|
|
|
+ <select class="form-control form-control-sm min-width-unset" name="removalReasonCategory">
|
|
|
|
+ <option value="">-- select --</option>
|
|
|
|
+ <option value="ON_INTAKE">On Intake</option>
|
|
|
|
+ <option value="DURING_VISIT">During Visit</option>
|
|
|
|
+ </select>
|
|
|
|
+ </div>
|
|
|
|
+ <div class="col-4 pr-0">
|
|
|
|
+ <label class="text-sm mb-0 min-width-unset">End Date</label>
|
|
|
|
+ <input type="date"
|
|
|
|
+ name="removalEffectiveDate"
|
|
|
|
+ class="form-control form-control-sm min-width-unset">
|
|
|
|
+ </div>
|
|
|
|
+ <div class="col-4">
|
|
|
|
+ <label class="text-sm mb-0 min-width-unset">Removal By/Memo</label>
|
|
|
|
+ <input type="text"
|
|
|
|
+ name="removalReasonMemo"
|
|
|
|
+ class="form-control form-control-sm min-width-unset">
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+
|
|
|
|
+ </div>
|
|
|
|
+ <div class="col-5 border-left">
|
|
|
|
+
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+
|
|
|
|
+ <div class="d-flex align-items-center">
|
|
|
|
+ <button type="submit" class="btn btn-sm btn-primary mr-2 my-1">Save Allergy</button>
|
|
|
|
+ </div>
|
|
|
|
+ </form>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+</div>
|
|
|
|
+
|
|
|
|
+<script>
|
|
|
|
+ (function() {
|
|
|
|
+ function initVisitMoeRTEs() {
|
|
|
|
+ $('.stag-popup [visit-moe]').find('[note-rte]:not(.ql-container)').each(function() {
|
|
|
|
+
|
|
|
|
+ let noteRTE = $(this);
|
|
|
|
+
|
|
|
|
+ $(this).wrap(
|
|
|
|
+ $('<div class="border-left border-right rte-holder"/>')
|
|
|
|
+ .attr('data-shortcuts', '')
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ // give a unique id to this editor instance
|
|
|
|
+ var editorID = Math.ceil(Math.random() * 99999),
|
|
|
|
+ fieldName = $(this).attr('data-field-name') ? $(this).attr('data-field-name') : 'free_text';
|
|
|
|
+
|
|
|
|
+ var el = this;
|
|
|
|
+ var existingContent = $(el).html();
|
|
|
|
+ var quill = new Quill(el, {
|
|
|
|
+ theme: 'snow',
|
|
|
|
+ modules: stagQuillConfig
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ var toolbar = $(quill.container).prev('.ql-toolbar');
|
|
|
|
+
|
|
|
|
+ // add button for new shortcut
|
|
|
|
+ if(!noteRTE.is('[use-shortcuts]') || !noteRTE.attr('use-shortcuts')) {
|
|
|
|
+ var newSCButton = $('<button class="btn bg-white btn-sm btn-default text-primary w-auto px-2 border py-0 ' +
|
|
|
|
+ 'text-sm add-shortcut" data-editor-id="' + editorID + '">+ Shortcut</button>');
|
|
|
|
+ toolbar.append(newSCButton);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ quill.root.innerHTML = existingContent;
|
|
|
|
+
|
|
|
|
+ let onTextChange = function(delta, oldDelta, source) {
|
|
|
|
+ var content = quill.root.innerHTML;
|
|
|
|
+ let dataObject = {};
|
|
|
|
+ dataObject[fieldName] = content;
|
|
|
|
+ var dataValue = JSON.stringify(dataObject);
|
|
|
|
+ let pElem = $(el).closest('[visit-moe]');
|
|
|
|
+ if(!pElem.length) {
|
|
|
|
+ pElem = $(el).closest('form');
|
|
|
|
+ }
|
|
|
|
+ pElem.find('input[name=data]').val(dataValue);
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ quill.on('text-change', onTextChange);
|
|
|
|
+
|
|
|
|
+ $(quill.container)
|
|
|
|
+ .find('.ql-editor[contenteditable]')
|
|
|
|
+ .attr('data-field', fieldName)
|
|
|
|
+ .attr('data-editor-id', editorID)
|
|
|
|
+ .attr('with-shortcuts', 1);
|
|
|
|
+
|
|
|
|
+ // set value initially
|
|
|
|
+ onTextChange();
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ function init() {
|
|
|
|
+ let parentSegment = $('#allergies-center-{{$note->id}}');
|
|
|
|
+ parentSegment.find('input[stag-suggest][data-name="name"]')
|
|
|
|
+ .off('stag-suggest-selected')
|
|
|
|
+ .on('stag-suggest-selected', (_e, _input, _data) => {
|
|
|
|
+ _input.closest('form').find('input[data-name="damConceptId"]').val(_data.dam_concept_id);
|
|
|
|
+ _input.closest('form').find('input[data-name="damConceptIdType"]').val(_data.dam_concept_id_typ);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ parentSegment.find('.additionReasonCategory_ui')
|
|
|
|
+ .off('change')
|
|
|
|
+ .on('change', function() {
|
|
|
|
+
|
|
|
|
+ let form = $(this).closest('form');
|
|
|
|
+
|
|
|
|
+ // additionReasonCategory
|
|
|
|
+ // isRemoved
|
|
|
|
+ // removalReasonCategory
|
|
|
|
+ form.find('[name="isRemovedDueToEntryError"]').val('0');
|
|
|
|
+
|
|
|
|
+ form.find('.start_date_ui').hide();
|
|
|
|
+ form.find('.removalEffectiveDate_ui').hide();
|
|
|
|
+ form.find('.removalReasonMemo_ui').hide();
|
|
|
|
+
|
|
|
|
+ if(this.value === 'HISTORIC') {
|
|
|
|
+ form.find('[name="additionReasonCategory"]').val('ON_INTAKE');
|
|
|
|
+ form.find('[name="isRemoved"]').val('1');
|
|
|
|
+ form.find('.start_date_ui').show();
|
|
|
|
+ form.find('.removalEffectiveDate_ui').show();
|
|
|
|
+ form.find('.removalReasonMemo_ui').show();
|
|
|
|
+ }
|
|
|
|
+ else if(this.value === 'PRE_EXISTING') {
|
|
|
|
+ form.find('[name="additionReasonCategory"]').val('ON_INTAKE');
|
|
|
|
+ form.find('[name="isRemoved"]').val('0');
|
|
|
|
+ form.find('.start_date_ui').show();
|
|
|
|
+ }
|
|
|
|
+ else if(this.value === 'NEW') {
|
|
|
|
+ form.find('[name="additionReasonCategory"]').val('DURING_VISIT');
|
|
|
|
+ form.find('[name="isRemoved"]').val('0');
|
|
|
|
+ form.find('.start_date_ui').show().find('input').val('{{date('Y-m-d')}}');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ parentSegment.find('[name="isRemoved"], [name="isRemovedDueToEntryError"]')
|
|
|
|
+ .off('change')
|
|
|
|
+ .on('change', function () {
|
|
|
|
+ let form = $(this).closest('form');
|
|
|
|
+
|
|
|
|
+ form.find('.is_removed_ui_1').hide();
|
|
|
|
+ if(form.find('[name="isRemoved"]').val() === '1') {
|
|
|
|
+ form.find('.is_removed_ui_1').show();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ form.find('.is_removed_ui_2').hide();
|
|
|
|
+ if(form.find('[name="isRemoved"]').val() === '1' && form.find('[name="isRemovedDueToEntryError"]').val() !== '1') {
|
|
|
|
+ form.find('.is_removed_ui_2').show();
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ parentSegment.find('#frm-add-allergy')
|
|
|
|
+ .off('submit')
|
|
|
|
+ .on('submit', function () {
|
|
|
|
+
|
|
|
|
+ let form = $(this);
|
|
|
|
+
|
|
|
|
+ if (!form[0].checkValidity()) {
|
|
|
|
+ form[0].reportValidity();
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // add [data-name] values to payload
|
|
|
|
+ let dataField = form.find('[name="data"]').first();
|
|
|
|
+ let parsed = null;
|
|
|
|
+ if(dataField.val()) {
|
|
|
|
+ parsed = JSON.parse(dataField.val());
|
|
|
|
+ }
|
|
|
|
+ form.find('[data-name]').each(function() {
|
|
|
|
+ if(!parsed) parsed = {};
|
|
|
|
+
|
|
|
|
+ let keys = $(this).attr('data-name').split('->');
|
|
|
|
+ let currentNode = parsed;
|
|
|
|
+ for (let i = 0; i < keys.length; i++) {
|
|
|
|
+ if(i !== keys.length - 1) {
|
|
|
|
+ if(typeof currentNode[keys[i]] === 'undefined') {
|
|
|
|
+ currentNode[keys[i]] = {};
|
|
|
|
+ }
|
|
|
|
+ currentNode = currentNode[keys[i]];
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ if($(this).is(':checkbox')) {
|
|
|
|
+ currentNode[keys[i]] = $(this).prop('checked');
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ currentNode[keys[i]] = $(this).val();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ });
|
|
|
|
+ if(parsed) {
|
|
|
|
+ dataField.val(JSON.stringify(parsed));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $.post(form.attr('action'), form.serialize(), _data => {
|
|
|
|
+ if(!hasResponseError(_data)) {
|
|
|
|
+ hideMask();
|
|
|
|
+ refreshDynamicStagPopup();
|
|
|
|
+ $('.visit-segment[data-segment-template-name="intake_allergies"]').find('.refresh-segment').trigger('click');
|
|
|
|
+ }
|
|
|
|
+ }, 'json');
|
|
|
|
+ return false;
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ parentSegment.find('.frm-edit-allergy')
|
|
|
|
+ .off('submit')
|
|
|
|
+ .on('submit', function () {
|
|
|
|
+
|
|
|
|
+ let form = $(this);
|
|
|
|
+
|
|
|
|
+ if (!form[0].checkValidity()) {
|
|
|
|
+ form[0].reportValidity();
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // add [data-name] values to payload
|
|
|
|
+ let dataField = form.find('[name="data"]').first();
|
|
|
|
+ let parsed = null;
|
|
|
|
+ if(dataField.val()) {
|
|
|
|
+ parsed = JSON.parse(dataField.val());
|
|
|
|
+ }
|
|
|
|
+ form.find('[data-name]').each(function() {
|
|
|
|
+ if(!parsed) parsed = {};
|
|
|
|
+
|
|
|
|
+ let keys = $(this).attr('data-name').split('->');
|
|
|
|
+ let currentNode = parsed;
|
|
|
|
+ for (let i = 0; i < keys.length; i++) {
|
|
|
|
+ if(i !== keys.length - 1) {
|
|
|
|
+ if(typeof currentNode[keys[i]] === 'undefined') {
|
|
|
|
+ currentNode[keys[i]] = {};
|
|
|
|
+ }
|
|
|
|
+ currentNode = currentNode[keys[i]];
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ if($(this).is(':checkbox')) {
|
|
|
|
+ currentNode[keys[i]] = $(this).prop('checked');
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ currentNode[keys[i]] = $(this).val();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ });
|
|
|
|
+ if(parsed) {
|
|
|
|
+ dataField.val(JSON.stringify(parsed));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $.post(form.attr('url'), form.serialize(), _data => {
|
|
|
|
+ if(!hasResponseError(_data)) {
|
|
|
|
+ hideMask();
|
|
|
|
+ refreshDynamicStagPopup();
|
|
|
|
+ $('.visit-segment[data-segment-template-name="intake_allergies"]').find('.refresh-segment').trigger('click');
|
|
|
|
+ }
|
|
|
|
+ }, 'json');
|
|
|
|
+ return false;
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ parentSegment.find('.toggle-relevance')
|
|
|
|
+ .off('click.toggle-relevance')
|
|
|
|
+ .on('click.toggle-relevance', function () {
|
|
|
|
+ if(+$(this).attr('data-relevant') === 0) {
|
|
|
|
+ $.post('/api/visitPoint/markPointRelevantToNote', {
|
|
|
|
+ noteUid: '{{$note->uid}}',
|
|
|
|
+ pointUid: $(this).attr('data-point-uid')
|
|
|
|
+ }, _data => {
|
|
|
|
+ if(!hasResponseError(_data)) {
|
|
|
|
+ refreshDynamicStagPopup();
|
|
|
|
+ }
|
|
|
|
+ }, 'json');
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ if($(this).attr('data-rel-uid')) {
|
|
|
|
+ $.post('/api/visitPoint/undoMarkPointRelevantToNote', {
|
|
|
|
+ uid: $(this).attr('data-rel-uid')
|
|
|
|
+ }, _data => {
|
|
|
|
+ if(!hasResponseError(_data)) {
|
|
|
|
+ refreshDynamicStagPopup();
|
|
|
|
+ }
|
|
|
|
+ }, 'json');
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ console.log('Error - missing rel uid');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ initStagSuggest();
|
|
|
|
+
|
|
|
|
+ parentSegment.find('.additionReasonCategory_ui').trigger('change');
|
|
|
|
+ parentSegment.find('[name="isRemoved"]').trigger('change');
|
|
|
|
+
|
|
|
|
+ initSegmentMoes($('#allergies-center-{{$note->id}}'));
|
|
|
|
+ initVisitMoeRTEs();
|
|
|
|
+ }
|
|
|
|
+ addMCInitializer('allergies-center-{{$note->id}}', init, '#allergies-center-{{$note->id}}');
|
|
|
|
+ }).call(window);
|
|
|
|
+</script>
|