|
@@ -10,7 +10,6 @@ use App\Models\Note;
|
|
|
$points = Point
|
|
|
::where('client_id', $patient->id)
|
|
|
->where('category', 'MEDICATION')
|
|
|
- ->where('is_removed_due_to_entry_error', false)
|
|
|
->where('is_removed', false)
|
|
|
->orderBy('created_at')
|
|
|
->get();
|
|
@@ -27,17 +26,55 @@ $medications = $points;
|
|
|
<table class="table table-sm table-striped table-bordered">
|
|
|
<thead>
|
|
|
<tr>
|
|
|
- <th class="border-bottom-0">Medication</th>
|
|
|
- <th class="border-bottom-0">Review</th>
|
|
|
+ <th class="text-secondary bg-light border-bottom-0 w-25">Medication</th>
|
|
|
+ <th class="text-secondary bg-light border-bottom-0 w-25">Previous Subjective</th>
|
|
|
+ <th class="text-secondary bg-light border-bottom-0 w-25">Previous Plan</th>
|
|
|
+ <th class="text-secondary bg-light border-bottom-0 w-25">New Subjective</th>
|
|
|
</tr>
|
|
|
</thead>
|
|
|
@foreach($medications as $medication)
|
|
|
- <tr>
|
|
|
- <td class="w-50">{{$medication->data->name}}</td>
|
|
|
- <td class="p-0">
|
|
|
- <input type="text" class="form-control form-control-sm border-0 rounded-0 shadow-none" data-point-uid="{{$medication->uid}}" value="Reconciled">
|
|
|
- </td>
|
|
|
- </tr>
|
|
|
+ <?php
|
|
|
+ $default = '';
|
|
|
+
|
|
|
+ // get most recent child plan for this point that was created before this note
|
|
|
+ $mostRecentPlanBeforeThisNote = Point::where('parent_point_id', $medication->id)
|
|
|
+ ->where('category', 'PLAN')
|
|
|
+ ->where('added_in_note_id', '<', $note->id)
|
|
|
+ ->orderBy('id', 'DESC')
|
|
|
+ ->first();
|
|
|
+
|
|
|
+ // get most recent child review for this point that was created before this note
|
|
|
+ $mostRecentReviewBeforeThisNote = Point::where('parent_point_id', $medication->id)
|
|
|
+ ->where('category', 'REVIEW')
|
|
|
+ ->where('added_in_note_id', '<', $note->id)
|
|
|
+ ->orderBy('id', 'DESC')
|
|
|
+ ->first();
|
|
|
+
|
|
|
+ // get child review for this point created on this note
|
|
|
+ $newReview = Point::where('parent_point_id', $medication->id)
|
|
|
+ ->where('category', 'REVIEW')
|
|
|
+ ->where('added_in_note_id', $note->id)
|
|
|
+ ->orderBy('id', 'DESC')
|
|
|
+ ->first();
|
|
|
+ if($newReview && $newReview->data) {
|
|
|
+ $newReview->data = json_decode($newReview->data);
|
|
|
+ $default = $newReview->data->value;
|
|
|
+ }
|
|
|
+ ?>
|
|
|
+ <tr>
|
|
|
+ <td class="bg-light font-weight-bold">{{$medication->data->name}}</td>
|
|
|
+ <td class="bg-light">
|
|
|
+ @include('app/patient/wizard-partials/show-review', ['point' => $medication, 'review' => $mostRecentReviewBeforeThisNote])
|
|
|
+ </td>
|
|
|
+ <td class="bg-light">
|
|
|
+ @include('app/patient/wizard-partials/show-plan', ['point' => $medication, 'plan' => $mostRecentPlanBeforeThisNote])
|
|
|
+ </td>
|
|
|
+ <td class="p-0 bg-white">
|
|
|
+ <div note-rte slim-rte ignore-changes
|
|
|
+ data-point-uid="{{$medication->uid}}"
|
|
|
+ class="form-group rte-holder mb-0 bg-white border-0 rounded-0"><?= $default ?></div>
|
|
|
+ </td>
|
|
|
+ </tr>
|
|
|
@endforeach
|
|
|
</table>
|
|
|
<div class="d-flex align-items-center justify-content-center">
|
|
@@ -48,7 +85,43 @@ $medications = $points;
|
|
|
|
|
|
<script>
|
|
|
(function() {
|
|
|
+ function __initRTEs(_collection) {
|
|
|
+ _collection.each(function() {
|
|
|
+ let noteRTE = $(this);
|
|
|
+ $(this).wrap(
|
|
|
+ $('<div class="rte-holder"/>')
|
|
|
+ .attr('data-shortcuts', '')
|
|
|
+ );
|
|
|
+ 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: {
|
|
|
+ toolbar: false
|
|
|
+ }
|
|
|
+ });
|
|
|
+ quill.root.innerHTML = existingContent;
|
|
|
+ $(quill.container)
|
|
|
+ .find('.ql-editor[contenteditable]')
|
|
|
+ .attr('data-field', fieldName)
|
|
|
+ .attr('data-editor-id', editorID)
|
|
|
+ .attr('with-shortcuts', 1);
|
|
|
+ $(el).data('quillInstance', quill);
|
|
|
+ });
|
|
|
+ }
|
|
|
function init() {
|
|
|
+ $('#medications-reconcile-{{$note->id}} .copy-to-new-subjective')
|
|
|
+ .off('click')
|
|
|
+ .on('click', function() {
|
|
|
+ let html = $.trim($(this).parent().prev('.inline-html-container').html());
|
|
|
+ let quillInstance = $(this).closest('tr').find('[note-rte][data-point-uid]').first().data('quillInstance');
|
|
|
+ // quillInstance.setContent(html);
|
|
|
+ quillInstance.root.innerHTML = html;
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+
|
|
|
$('#medications-reconcile-{{$note->id}} .btn-save-reviews')
|
|
|
.off('click')
|
|
|
.on('click', function() {
|
|
@@ -57,14 +130,16 @@ $medications = $points;
|
|
|
noteUid: '{{$note->uid}}',
|
|
|
reviews: []
|
|
|
}
|
|
|
- $('#medications-reconcile-{{$note->id}} [data-point-uid]').each(function() {
|
|
|
- payload.reviews.push({
|
|
|
- parentPointUid: $(this).attr('data-point-uid'),
|
|
|
- data: JSON.stringify({
|
|
|
- isReconciled: true,
|
|
|
- value: $(this).val()
|
|
|
- })
|
|
|
- });
|
|
|
+ $('#medications-reconcile-{{$note->id}} [data-point-uid]').each(function () {
|
|
|
+ if($.trim($('<div/>').html($(this).find('.ql-editor').html()).text())) {
|
|
|
+ payload.reviews.push({
|
|
|
+ parentPointUid: $(this).attr('data-point-uid'),
|
|
|
+ data: JSON.stringify({
|
|
|
+ isReconciled: true,
|
|
|
+ value: $(this).find('.ql-editor').html()
|
|
|
+ })
|
|
|
+ });
|
|
|
+ }
|
|
|
});
|
|
|
|
|
|
$.ajax({
|
|
@@ -83,6 +158,7 @@ $medications = $points;
|
|
|
});
|
|
|
|
|
|
});
|
|
|
+ __initRTEs($('#medications-reconcile-{{$note->id}} [note-rte]'))
|
|
|
}
|
|
|
addMCInitializer('medications-reconcile-{{$note->id}}', init, '#medications-reconcile-{{$note->id}}')
|
|
|
}).call(window);
|