|
@@ -8,22 +8,7 @@ use App\Models\Segment;
|
|
|
/** @var Client $patient */
|
|
|
/** @var Note $note */
|
|
|
|
|
|
-$points = Point
|
|
|
- ::where('client_id', $patient->id)
|
|
|
- ->where('category', 'GOAL')
|
|
|
- ->where('is_removed_due_to_entry_error', false)
|
|
|
- ->orderBy('category')
|
|
|
- ->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);
|
|
|
- }
|
|
|
-}
|
|
|
-$goals = $points;
|
|
|
-
|
|
|
+$goals = Point::getPointsOfCategoryExtended($patient, 'GOAL', $note);
|
|
|
?>
|
|
|
|
|
|
<div class="mt-3 p-3 border-top min-height-500px" id="goals-center-{{$note->id}}">
|
|
@@ -37,23 +22,23 @@ $goals = $points;
|
|
|
@endif
|
|
|
<th class="border-bottom-0 text-secondary">Goal</th>
|
|
|
<th class="border-bottom-0 text-secondary">Category</th>
|
|
|
- <th class="border-bottom-0 text-secondary w-25">Directions</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">Last Review</th>
|
|
|
+ <th class="border-bottom-0 text-secondary w-25">Review</th>
|
|
|
+ <th class="border-bottom-0 text-secondary w-25">Plan</th>
|
|
|
</tr>
|
|
|
</thead>
|
|
|
- <?php $prevRowRemoved = -1; ?>
|
|
|
+ <?php $prevRowState = -1; ?>
|
|
|
<?php foreach($goals as $goal): ?>
|
|
|
<?php $point = $goal; ?>
|
|
|
- @if($prevRowRemoved !== -1 && $prevRowRemoved !== $goal->is_removed)
|
|
|
+ @if($prevRowState !== -1 && $prevRowState !== $goal->state)
|
|
|
<tr>
|
|
|
- <td colspan="10" class="px-0 pt-1 pb-0 on-hover-opaque bg-secondary"></td>
|
|
|
+ <td colspan="9" class="px-0 pt-1 pb-0 on-hover-opaque bg-secondary"></td>
|
|
|
</tr>
|
|
|
@endif
|
|
|
- <?php $prevRowRemoved = $goal->is_removed; ?>
|
|
|
+ <?php $prevRowState = $goal->state; ?>
|
|
|
<?php $rel = $goal->relevanceToNote($note); ?>
|
|
|
<tr class="">
|
|
|
@if($patient->core_note_id !== $note->id)
|
|
@@ -73,10 +58,14 @@ $goals = $points;
|
|
|
@endif
|
|
|
<td>
|
|
|
<div class="d-flex align-items-baseline">
|
|
|
- @if($goal->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>
|
|
|
+ @if($goal->state === 1)
|
|
|
+ <i class="text-success fa fa-circle text-sm on-hover-opaque mr-2 active-record"></i>
|
|
|
+ @elseif($goal->state === 2)
|
|
|
+ <i class="text-info fa fa-circle text-sm on-hover-opaque mr-2 active-record"></i>
|
|
|
+ @elseif($goal->state === 3)
|
|
|
+ <i class="text-warning-mellow fa fa-circle text-sm on-hover-opaque mr-2 active-record"></i>
|
|
|
+ @elseif($goal->state === 4)
|
|
|
+ <i class="text-secondary fa fa-circle text-sm on-hover-opaque mr-2"></i>
|
|
|
@endif
|
|
|
<div>
|
|
|
<b><?= !!@($goal->data->goal) ? @($goal->data->goal) : '-' ?></b>
|
|
@@ -111,31 +100,6 @@ $goals = $points;
|
|
|
<td>
|
|
|
<?= !!@($goal->data->category) ? @($goal->data->category) : '-' ?>
|
|
|
</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<?= !!@($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');
|
|
|
- }
|
|
|
- ?>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </td>
|
|
|
<td>
|
|
|
@if($goal->is_removed)
|
|
|
NO
|
|
@@ -151,9 +115,9 @@ $goals = $points;
|
|
|
<input type="hidden" name="noteUid" value="<?= $note->uid ?>">
|
|
|
<p class="mb-2"><b>Update Goal</b></p>
|
|
|
|
|
|
- @if($goal->added_in_note_id === $note->id)
|
|
|
+ <input type="hidden" name="data" value='{{json_encode($goal->data)}}'>
|
|
|
|
|
|
- <input type="hidden" name="data">
|
|
|
+ @if($goal->added_in_note_id === $note->id)
|
|
|
|
|
|
<div class="mb-2">
|
|
|
<label class="text-sm text-secondary mb-1">Category</label>
|
|
@@ -234,23 +198,6 @@ $goals = $points;
|
|
|
value="{{@$goal->data->goal}}">
|
|
|
</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="{{@$goal->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="{{@$goal->data->prescriber}}"
|
|
|
- class="form-control form-control-sm min-width-unset">
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-
|
|
|
@else
|
|
|
|
|
|
<div class="mb-2 bg-light p-2 border">
|
|
@@ -266,74 +213,11 @@ $goals = $points;
|
|
|
|
|
|
@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" {{$goal->addition_reason_category === 'ON_INTAKE' ? 'selected' : ''}}>On Intake</option>
|
|
|
- <option value="DURING_VISIT" {{$goal->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="{{$goal->addition_reason_memo}}"
|
|
|
- class="form-control form-control-sm min-width-unset">
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-
|
|
|
- <hr class="my-3">
|
|
|
+ @include('app.patient.wizard-partials.common-fields', ['label' => 'goal', 'point' => $goal])
|
|
|
|
|
|
- <div class="row mb-2">
|
|
|
- <div class="col-6 pr-0">
|
|
|
- <label class="text-sm mb-0 min-width-unset">Is goal active?</label>
|
|
|
- <select class="form-control form-control-sm min-width-unset" name="isRemoved" required>
|
|
|
- <option value="">-- select --</option>
|
|
|
- <option value="0" {{!$goal->is_removed ? 'selected' : ''}}>Yes</option>
|
|
|
- <option value="1" {{$goal->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" {{$goal->is_removed_due_to_entry_error ? 'selected' : ''}}>Yes</option>
|
|
|
- <option value="0" {{!$goal->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" {{$goal->removal_reason_category === 'ON_INTAKE' ? 'selected' : ''}}>On Intake</option>
|
|
|
- <option value="DURING_VISIT" {{$goal->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="{{$goal->removal_effective_date ? $goal->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="{{$goal->removal_reason_memo}}"
|
|
|
- class="form-control form-control-sm min-width-unset">
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-
|
|
|
- <div>
|
|
|
+ <div class="mt-3 pt-2 d-flex align-items-center border-top">
|
|
|
<button type="submit" class="btn-save-goal btn btn-sm btn-primary mr-2">Save</button>
|
|
|
- <button cancel class="btn btn-sm btn-default border">Cancel</button>
|
|
|
+ <button cancel class="btn btn-sm bg-light btn-default border">Cancel</button>
|
|
|
</div>
|
|
|
</form>
|
|
|
</div>
|
|
@@ -376,6 +260,31 @@ $goals = $points;
|
|
|
</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<?= !!@($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');
|
|
|
+ }
|
|
|
+ ?>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </td>
|
|
|
</tr>
|
|
|
<?php endforeach; ?>
|
|
|
</table>
|
|
@@ -387,6 +296,8 @@ $goals = $points;
|
|
|
<input type="hidden" name="category" value="GOAL">
|
|
|
<input type="hidden" name="data">
|
|
|
|
|
|
+ <input type="hidden" name="isRemovedDueToEntryError" value="0">
|
|
|
+
|
|
|
<p class="mb-2"><b>Add Goal</b></p>
|
|
|
|
|
|
<div class="row">
|
|
@@ -474,86 +385,8 @@ $goals = $points;
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
- <div class="mb-2">
|
|
|
- <label class="text-sm mb-1">Directions</label>
|
|
|
- <div note-rte
|
|
|
- class="form-group mb-2 border-left border-right rte-holder bg-white"
|
|
|
- data-field-name="value"></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 goal 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>
|
|
|
+ <?php $point = null; ?>
|
|
|
+ @include('app.patient.wizard-partials.common-fields', ['label' => 'goal'])
|
|
|
|
|
|
</div>
|
|
|
<div class="col-5 border-left">
|
|
@@ -572,58 +405,6 @@ $goals = $points;
|
|
|
|
|
|
<script>
|
|
|
(function() {
|
|
|
- function initRTEs(_collection) {
|
|
|
- _collection.each(function() {
|
|
|
-
|
|
|
- $(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
|
|
|
- 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 = $('#goals-center-{{$note->id}}');
|
|
|
|
|
@@ -635,227 +416,10 @@ $goals = $points;
|
|
|
})
|
|
|
.trigger('change');
|
|
|
|
|
|
- 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('.prescriber_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('.prescriber_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();
|
|
|
- form.find('.prescriber_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')}}');
|
|
|
- form.find('.prescriber_ui').show().find('input').val('{{$note->hcpPro->displayName()}}');
|
|
|
- }
|
|
|
-
|
|
|
- });
|
|
|
-
|
|
|
- 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-goal')
|
|
|
- .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());
|
|
|
- }
|
|
|
-
|
|
|
- // store plan content
|
|
|
- let planContent = parsed.value ? parsed.value : '';
|
|
|
- if(!$.trim($('<div/>').html(planContent).text())) {
|
|
|
- toastr.error('Directions cannot be empty');
|
|
|
- return false;
|
|
|
- }
|
|
|
- if(parsed.value) delete parsed.value;
|
|
|
-
|
|
|
- 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)) {
|
|
|
-
|
|
|
- // save child plan
|
|
|
- $.post('/api/visitPoint/upsertChildPlan', {
|
|
|
- uid: _data.data,
|
|
|
- segmentUid: '{{$note->getSegmentByInternalName('plan_goals')->uid}}',
|
|
|
- data: JSON.stringify({value: planContent})
|
|
|
- }, _data => {
|
|
|
- if(!hasResponseError(_data)) {
|
|
|
- hideMask();
|
|
|
- refreshDynamicStagPopup();
|
|
|
- }
|
|
|
- }, 'json');
|
|
|
-
|
|
|
- $('.visit-segment[data-segment-template-name="intake_goals"]').find('.refresh-segment').trigger('click');
|
|
|
- }
|
|
|
- }, 'json');
|
|
|
- return false;
|
|
|
- });
|
|
|
-
|
|
|
- parentSegment.find('.frm-edit-goal')
|
|
|
- .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_goals"]').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');
|
|
|
+ @include('app.patient.wizard-partials.common-script', ['label' => 'goal'])
|
|
|
|
|
|
initSegmentMoes($('#goals-center-{{$note->id}}'));
|
|
|
- initRTEs(parentSegment.find('[note-rte]:not(.ql-container)'));
|
|
|
+ __initRTEs(parentSegment.find('[note-rte]:not(.ql-container)'));
|
|
|
}
|
|
|
addMCInitializer('goals-center-{{$note->id}}', init, '#goals-center-{{$note->id}}');
|
|
|
}).call(window);
|