|
@@ -1,198 +1,221 @@
|
|
|
<?php $canvasData = json_decode($patient->canvas_data, true); ?>
|
|
|
@foreach($note->sections as $section)
|
|
|
- <?php
|
|
|
- $sectionTS = strtotime($section->created_at);
|
|
|
- if($latestSectionTS === 0 || $latestSectionTS < $sectionTS){
|
|
|
- $latestSectionTS = $sectionTS;
|
|
|
- }
|
|
|
- ?>
|
|
|
- <div data-ts="{{$sectionTS}}"
|
|
|
- class="p-3 border-bottom note-section {{ $note->is_signed_by_hcp ? 'signed-note' : '' }} {{ $section->is_initialized ? '' : 'pending-initialization' }}"
|
|
|
- {!! $note->is_signed_by_hcp ? 'title="Signed note. Cannot be edited further."' : '' !!}
|
|
|
- data-section-uid="{{ $section->uid }}"
|
|
|
- data-section-template-uid="{{ $section->sectionTemplate->uid }}"
|
|
|
- data-section-template-name="{{ $section->sectionTemplate->internal_name }}">
|
|
|
- <div class="d-flex align-items-start">
|
|
|
- @if(!$note->is_signed_by_hcp)
|
|
|
- <a class="font-weight-bold mb-2 d-flex align-items-center c-pointer">
|
|
|
- {{$section->sectionTemplate->title}}
|
|
|
- <span class="d-none if-not-edit"><i class="fa fa-edit ml-2"></i></span>
|
|
|
- <span class="d-none if-edit edit-trigger"><i class="fa fa-times ml-2"></i></span>
|
|
|
- <span class="edit-trigger"></span>
|
|
|
- </a>
|
|
|
- @else
|
|
|
- <span class="font-weight-bold mb-2 d-flex align-items-center">
|
|
|
- {{$section->sectionTemplate->title}}
|
|
|
- </span>
|
|
|
- @endif
|
|
|
- <?php $sectionInternalName = $section->sectionTemplate->internal_name; ?>
|
|
|
-
|
|
|
- <?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
|
|
|
- }
|
|
|
- ?>
|
|
|
-
|
|
|
- <a href="#" class="d-none text-danger if-edit ml-auto remove-section-trigger mr-1"
|
|
|
- data-uid="{{$section->uid}}"
|
|
|
- title="Remove {{$section->sectionTemplate->title}}">
|
|
|
- Remove {{$section->sectionTemplate->title}}
|
|
|
- </a>
|
|
|
-
|
|
|
- <a href="#" class="d-none if-edit ml-2 move-up-trigger" data-uid="{{$section->uid}}" title="Move Up">
|
|
|
- <i class="fa fa-arrow-up"></i>
|
|
|
- </a>
|
|
|
+<?php
|
|
|
+$sectionTS = strtotime($section->created_at);
|
|
|
+if ($latestSectionTS === 0 || $latestSectionTS < $sectionTS) {
|
|
|
+ $latestSectionTS = $sectionTS;
|
|
|
+}
|
|
|
+?>
|
|
|
+<div data-ts="{{$sectionTS}}" class="p-3 border-bottom note-section {{ $note->is_signed_by_hcp ? 'signed-note' : '' }} {{ $section->is_initialized ? '' : 'pending-initialization' }}" {!! $note->is_signed_by_hcp ? 'title="Signed note. Cannot be edited further."' : '' !!}
|
|
|
+ data-section-uid="{{ $section->uid }}"
|
|
|
+ data-section-template-uid="{{ $section->sectionTemplate->uid }}"
|
|
|
+ data-section-template-name="{{ $section->sectionTemplate->internal_name }}">
|
|
|
+ <div class="d-flex align-items-start">
|
|
|
+ @if(!$note->is_signed_by_hcp)
|
|
|
+ <a class="font-weight-bold mb-2 d-flex align-items-center c-pointer">
|
|
|
+ {{$section->sectionTemplate->title}}
|
|
|
+ <span class="d-none if-not-edit"><i class="fa fa-edit ml-2"></i></span>
|
|
|
+ <span class="d-none if-edit edit-trigger"><i class="fa fa-times ml-2"></i></span>
|
|
|
+ <span class="edit-trigger"></span>
|
|
|
+ </a>
|
|
|
+ @else
|
|
|
+ <span class="font-weight-bold mb-2 d-flex align-items-center">
|
|
|
+ {{$section->sectionTemplate->title}}
|
|
|
+ </span>
|
|
|
+ @endif
|
|
|
+ <?php $sectionInternalName = $section->sectionTemplate->internal_name; ?>
|
|
|
+
|
|
|
+ @if($sectionInternalName === "exam" || $sectionInternalName === "objective")
|
|
|
+ @include('app/patient/note/_templates-exam-index')
|
|
|
+ @else
|
|
|
+ @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
|
|
|
+ }
|
|
|
+ ?>
|
|
|
+
|
|
|
+ <a href="#" class="d-none text-danger if-edit ml-auto remove-section-trigger mr-1" data-uid="{{$section->uid}}" title="Remove {{$section->sectionTemplate->title}}">
|
|
|
+ Remove {{$section->sectionTemplate->title}}
|
|
|
+ </a>
|
|
|
+
|
|
|
+ <a href="#" class="d-none if-edit ml-2 move-up-trigger" data-uid="{{$section->uid}}" title="Move Up">
|
|
|
+ <i class="fa fa-arrow-up"></i>
|
|
|
+ </a>
|
|
|
+
|
|
|
+ <a href="#" class="d-none if-edit ml-2 move-down-trigger" data-uid="{{$section->uid}}" title="Move Down">
|
|
|
+ <i class="fa fa-arrow-down"></i>
|
|
|
+ </a>
|
|
|
|
|
|
- <a href="#" class="d-none if-edit ml-2 move-down-trigger" data-uid="{{$section->uid}}" title="Move Down">
|
|
|
- <i class="fa fa-arrow-down"></i>
|
|
|
- </a>
|
|
|
-
|
|
|
- </div>
|
|
|
- <div class="d-none if-not-edit inset-comment summary-container">
|
|
|
- {!! !empty($section->summary_html) ? $section->summary_html : '-' !!}
|
|
|
- </div>
|
|
|
+ </div>
|
|
|
+ <div class="d-none if-not-edit inset-comment summary-container">
|
|
|
+ {!! !empty($section->summary_html) ? $section->summary_html : '-' !!}
|
|
|
+ </div>
|
|
|
|
|
|
- <div class="d-none if-edit">
|
|
|
+ <div class="d-none if-edit">
|
|
|
|
|
|
- <?php
|
|
|
- // if canvas
|
|
|
- if($section->sectionTemplate->is_canvas) {
|
|
|
- $contentData = false;
|
|
|
- if ($canvasData) {
|
|
|
- if (isset($canvasData[$sectionInternalName])) {
|
|
|
- $contentData = $canvasData[$sectionInternalName];
|
|
|
- }
|
|
|
+ <?php
|
|
|
+ // if canvas
|
|
|
+ if ($section->sectionTemplate->is_canvas) {
|
|
|
+ $contentData = false;
|
|
|
+ if ($canvasData) {
|
|
|
+ if (isset($canvasData[$sectionInternalName])) {
|
|
|
+ $contentData = $canvasData[$sectionInternalName];
|
|
|
}
|
|
|
- ?>
|
|
|
- @include("app.patient.canvas-sections.{$sectionInternalName}.form")
|
|
|
- <?php
|
|
|
}
|
|
|
-
|
|
|
- // if form driven
|
|
|
- else if(file_exists(storage_path('sections/' . $sectionInternalName . '/form.blade.php'))) {
|
|
|
- ?>
|
|
|
- @include('sections.' . $sectionInternalName . '.form')
|
|
|
- <?php
|
|
|
+ ?>
|
|
|
+ @include("app.patient.canvas-sections.{$sectionInternalName}.form")
|
|
|
+ <?php
|
|
|
+ }
|
|
|
+
|
|
|
+ // if form driven
|
|
|
+ else if (file_exists(storage_path('sections/' . $sectionInternalName . '/form.blade.php'))) {
|
|
|
+ ?>
|
|
|
+ @include('sections.' . $sectionInternalName . '.form')
|
|
|
+ <?php
|
|
|
+ }
|
|
|
+
|
|
|
+ // if neither canvas nor form driven
|
|
|
+ else {
|
|
|
+ $contentData = false;
|
|
|
+ if ($section) {
|
|
|
+ $contentData = json_decode($section->content_data, true);
|
|
|
}
|
|
|
-
|
|
|
- // if neither canvas nor form driven
|
|
|
- else {
|
|
|
- $contentData = false;
|
|
|
- if($section){
|
|
|
- $contentData = json_decode($section->content_data, true);
|
|
|
- }
|
|
|
- if(!$contentData || !isset($contentData['value'])) {
|
|
|
- $contentData = [
|
|
|
- 'value'=>''
|
|
|
- ];
|
|
|
- }
|
|
|
- ?>
|
|
|
- <input type="hidden" name="data">
|
|
|
- <div note-rte data-content="{{$contentData['value']}}" class="form-group mb-2 border-left border-right rte-holder"></div>
|
|
|
- <?php
|
|
|
+ if (!$contentData || !isset($contentData['value'])) {
|
|
|
+ $contentData = [
|
|
|
+ 'value' => ''
|
|
|
+ ];
|
|
|
}
|
|
|
- ?>
|
|
|
-
|
|
|
- <div class="d-flex align-items-center">
|
|
|
- <button class="btn btn-sm btn-primary" btn-save-form><i class="fa fa-save"></i></button>
|
|
|
- <span class="ml-2 text-secondary text-sm text-saving d-none"><i>Saving ...</i></span>
|
|
|
- </div>
|
|
|
+ ?>
|
|
|
+ <input type="hidden" name="data">
|
|
|
+ <div note-rte data-content="{{$contentData['value']}}" class="form-group mb-2 border-left border-right rte-holder"></div>
|
|
|
+ <?php
|
|
|
+ }
|
|
|
+ ?>
|
|
|
+
|
|
|
+ <div class="d-flex align-items-center">
|
|
|
+ <button class="btn btn-sm btn-primary" btn-save-form><i class="fa fa-save"></i></button>
|
|
|
+ <span class="ml-2 text-secondary text-sm text-saving d-none"><i>Saving ...</i></span>
|
|
|
</div>
|
|
|
</div>
|
|
|
- @endforeach
|
|
|
- <script>
|
|
|
- (function(){
|
|
|
-
|
|
|
- function init() {
|
|
|
- $('[note-rte]').each(function(){
|
|
|
- var el = this;
|
|
|
- var existingContent = $(el).attr('data-content');
|
|
|
- var quill = new Quill(el, {
|
|
|
- theme: 'snow',
|
|
|
- modules: {
|
|
|
- keyboard: {
|
|
|
- bindings: {
|
|
|
- handleEnter: {
|
|
|
- key: 13,
|
|
|
- handler: function() {
|
|
|
- if(!$('.stag-shortcuts:visible').length) return true;
|
|
|
- }
|
|
|
+</div>
|
|
|
+@endforeach
|
|
|
+<script>
|
|
|
+ (function() {
|
|
|
+
|
|
|
+ function init() {
|
|
|
+ $('[note-rte]').each(function() {
|
|
|
+ var el = this;
|
|
|
+ var existingContent = $(el).attr('data-content');
|
|
|
+ var quill = new Quill(el, {
|
|
|
+ theme: 'snow',
|
|
|
+ modules: {
|
|
|
+ keyboard: {
|
|
|
+ bindings: {
|
|
|
+ handleEnter: {
|
|
|
+ key: 13,
|
|
|
+ handler: function() {
|
|
|
+ if (!$('.stag-shortcuts:visible').length) return true;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- });
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
- quill.root.innerHTML = existingContent;
|
|
|
+ quill.root.innerHTML = existingContent;
|
|
|
|
|
|
- quill.on('text-change', function(delta, oldDelta, source){
|
|
|
- var content = quill.root.innerHTML;
|
|
|
- var dataValue = JSON.stringify({value: content});
|
|
|
- var dataField = $(el).closest('.note-section').find('input[name=data]').val(dataValue);
|
|
|
+ quill.on('text-change', function(delta, oldDelta, source) {
|
|
|
+ var content = quill.root.innerHTML;
|
|
|
+ var dataValue = JSON.stringify({
|
|
|
+ value: content
|
|
|
});
|
|
|
- })
|
|
|
-
|
|
|
- $('[btn-save-form]').on('click', function(){
|
|
|
- doSave($(this).closest('.note-section'));
|
|
|
+ var dataField = $(el).closest('.note-section').find('input[name=data]').val(dataValue);
|
|
|
});
|
|
|
+ })
|
|
|
|
|
|
- // [name="data"] change listener
|
|
|
- $('.note-section input[name="data"]').each(function() {
|
|
|
- initChangeListener($(this));
|
|
|
- });
|
|
|
+ $('[btn-save-form]').on('click', function() {
|
|
|
+ doSave($(this).closest('.note-section'));
|
|
|
+ });
|
|
|
|
|
|
- }
|
|
|
+ // [name="data"] change listener
|
|
|
+ $('.note-section input[name="data"]').each(function() {
|
|
|
+ initChangeListener($(this));
|
|
|
+ });
|
|
|
|
|
|
- const debounce = (func, wait) => {
|
|
|
- let timeout;
|
|
|
+ }
|
|
|
|
|
|
- return function executedFunction(...args) {
|
|
|
- const later = () => {
|
|
|
- clearTimeout(timeout);
|
|
|
- func(...args);
|
|
|
- };
|
|
|
+ const debounce = (func, wait) => {
|
|
|
+ let timeout;
|
|
|
|
|
|
+ return function executedFunction(...args) {
|
|
|
+ const later = () => {
|
|
|
clearTimeout(timeout);
|
|
|
- timeout = setTimeout(later, wait);
|
|
|
+ func(...args);
|
|
|
};
|
|
|
- };
|
|
|
-
|
|
|
- function doSave(_section) {
|
|
|
- console.log(_section.attr('data-section-template-name'));
|
|
|
|
|
|
- _section.find('[btn-save-form]').prop('disabled', true);
|
|
|
- _section.find('.text-saving').removeClass('d-none');
|
|
|
-
|
|
|
- var dataField = _section.find('input[name=data]')
|
|
|
- var value = $(dataField).val();
|
|
|
-
|
|
|
- var summaryContainer = _section.find('.summary-container')
|
|
|
-
|
|
|
- var sectionUid = _section.attr('data-section-uid')
|
|
|
- $.post("/process_form_submit", {"section_uid":sectionUid , "data": value}, function(resp) {
|
|
|
- console.log(resp);
|
|
|
- if(resp.success){
|
|
|
- summaryContainer.html(resp.newSummaryHtml);
|
|
|
- }
|
|
|
- _section.find('[btn-save-form]').prop('disabled', false);
|
|
|
- _section.find('.text-saving').addClass('d-none');
|
|
|
- },'json');
|
|
|
+ clearTimeout(timeout);
|
|
|
+ timeout = setTimeout(later, wait);
|
|
|
+ };
|
|
|
+ };
|
|
|
+
|
|
|
+ function doSave(_section) {
|
|
|
+ console.log(_section.attr('data-section-template-name'));
|
|
|
+
|
|
|
+ _section.find('[btn-save-form]').prop('disabled', true);
|
|
|
+ _section.find('.text-saving').removeClass('d-none');
|
|
|
+
|
|
|
+ var dataField = _section.find('input[name=data]')
|
|
|
+ var value = $(dataField).val();
|
|
|
+
|
|
|
+ var summaryContainer = _section.find('.summary-container')
|
|
|
+
|
|
|
+ var sectionUid = _section.attr('data-section-uid')
|
|
|
+
|
|
|
+ var _form = _section.find('form')[0];
|
|
|
+ console.log("Form found: ", _form);
|
|
|
+ if(_form){
|
|
|
+ console.log("Form found. submitting normally");
|
|
|
+ $.post("/process_form_submit", $(_form).serialize(), function(resp) {
|
|
|
+ handleSubmitResponse(resp,_section, summaryContainer)
|
|
|
+ }, 'json');
|
|
|
+ }else{
|
|
|
+ console.log("Form not found.");
|
|
|
+ $.post("/process_form_submit", {
|
|
|
+ "section_uid": sectionUid,
|
|
|
+ "data": value
|
|
|
+ }, function(resp) {
|
|
|
+ handleSubmitResponse(resp,_section, summaryContainer)
|
|
|
+ }, 'json');
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- function initChangeListener(_elem) {
|
|
|
- new MutationObserver(debounce(function() {
|
|
|
- doSave(_elem.closest('.note-section'))
|
|
|
- }, 250))
|
|
|
- .observe(_elem[0], {attributes: true});
|
|
|
+ function handleSubmitResponse(resp,_section, summaryContainer){
|
|
|
+ console.log(resp);
|
|
|
+ if (resp.success) {
|
|
|
+ summaryContainer.html(resp.newSummaryHtml);
|
|
|
}
|
|
|
+ _section.find('[btn-save-form]').prop('disabled', false);
|
|
|
+ _section.find('.text-saving').addClass('d-none');
|
|
|
+ }
|
|
|
+
|
|
|
+ function initChangeListener(_elem) {
|
|
|
+ new MutationObserver(debounce(function() {
|
|
|
+ doSave(_elem.closest('.note-section'))
|
|
|
+ }, 250))
|
|
|
+ .observe(_elem[0], {
|
|
|
+ attributes: true
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
- addMCInitializer('note-sections-list-{{ $patient->uid }}', init);
|
|
|
-
|
|
|
- })();
|
|
|
+ addMCInitializer('note-sections-list-{{ $patient->uid }}', init);
|
|
|
|
|
|
- </script>
|
|
|
+ })();
|
|
|
+</script>
|