Jelajahi Sumber

implemented simple notes

Josh 4 tahun lalu
induk
melakukan
82b6d54951

+ 15 - 8
app/Http/Controllers/NoteController.php

@@ -91,18 +91,25 @@ class NoteController extends Controller
         }
 
         $newContentData = [];
+        $newSummaryHtml = "";
 
         // we wish to pass THESE arguments into this include:
         // if CREATE, $note and $sectionTemplate, and $request
         // if UPDATE, $section, and $request
-        include(storage_path('sections/' . $sectionTemplate->internal_name . '/processor.php'));
 
-        // now, create summaryHtml appropriate
-        ob_start();
-        include(storage_path('sections/' . $sectionTemplate->internal_name . '/summary.php'));
-        $newSummaryHtml = ob_get_contents();
-        ob_end_clean();
+        if(file_exists(storage_path('sections/' . $sectionTemplate->internal_name . '/form.blade.php'))) {
+          
+            include(storage_path('sections/' . $sectionTemplate->internal_name . '/processor.php'));
 
+            // now, create summaryHtml appropriate
+            ob_start();
+            include(storage_path('sections/' . $sectionTemplate->internal_name . '/summary.php'));
+            $newSummaryHtml = ob_get_contents();
+            ob_end_clean();
+        }else{
+            $newContentData = json_decode($request->get('data'), true);
+            $newSummaryHtml = $newContentData['value'];
+        }
 
         if($section){
             // call Java to update section
@@ -125,8 +132,8 @@ class NoteController extends Controller
             $response = $this->callJava($request, '/section/create', $data);
             //TODO: handle if response->success == false
         }
-        // return redirect(route('patients.view.notes',$note->client->uid));
-        return "";
+        //return redirect(route('patients.view.notes',$note->client->uid));
+         return $newSummaryHtml;
     }
 
     private function callJava($request, $endPoint, $data){

File diff ditekan karena terlalu besar
+ 10 - 0
public/js/jquery.form.min.js


+ 0 - 2
public/js/mc.js

@@ -352,5 +352,3 @@ function initPatientPresenceIndicator() {
         }, 2500);
     }
 }
-
-

+ 1 - 57
resources/views/app/patient/note/dashboard.blade.php

@@ -217,63 +217,7 @@
                         $shortcuts = "";
                         $latestSectionTS = 0;
                         ?>
-                        @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="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>
-                            </div>
-                            <div class="d-none if-not-edit  inset-comment">{!! !empty($section->summary_html) ? $section->summary_html : '-' !!}</div>
-                            <div class="d-none if-edit">@include('sections/'.$section->sectionTemplate->internal_name.'/form')</div>
-                        </div>
-                        @endforeach
+                        @include('app.patient.note.note-list')
                     </div>
                 </div>
 

+ 143 - 0
resources/views/app/patient/note/note-list.blade.php

@@ -0,0 +1,143 @@
+@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="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>
+
+        </div>
+        <div class="d-none if-not-edit  inset-comment">{!! !empty($section->summary_html) ? $section->summary_html : '-' !!}</div>
+
+        <div class="d-none if-edit">
+            <?php
+                $contentData = false;
+                if($section){
+                    $contentData = json_decode($section->content_data, true);
+                }
+                if(!$contentData || !isset($contentData['value'])) {
+                    $contentData = [
+                        'value'=>''
+                    ];
+                }
+                $formID = rand(0, 100000);
+            ?>
+            <form ajax-form method="POST" action="/process_form_submit">
+                
+                <input type="hidden" name="section_uid" value="<?= $section->uid?>">
+
+                <input type="hidden" name="data" value="">
+
+                <?php
+                    if(file_exists(storage_path('sections/' . $sectionInternalName . '/form.blade.php'))) {
+                         include(storage_path('sections/' . $sectionInternalName . '/form.blade.php'));
+                    }else{
+                ?>
+                    <div note-rte data-content="{{$contentData['value']}}" class="form-group mb-2 border-left border-right rte-holder"></div>
+                <?php
+                    }
+                ?>
+
+                <div class="form-group m-0 d-flex">
+                    <button class="btn btn-sm btn-primary mr-2">Submit</button>
+                    <button class="btn btn-sm btn-default border" onclick="return cancelFormNoteSection(this)">Cancel</button>
+                </div>
+            </form>
+        </div>
+    </div>
+    @endforeach
+    <script>
+        $(document).ready(function(){
+            $('[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.on('text-change', function(delta, oldDelta, source){
+                    var content = quill.root.innerHTML;
+                    var dataValue = JSON.stringify({value: content});
+                    var dataField = $(el).closest('form').find('input[name=data]').val(dataValue);
+                });
+                
+            })
+
+            $('[ajax-form]').each(function(){
+                showMask();
+                $(this).ajaxForm(function(result){
+                    console.log("DONE: "+result);
+                    fastReload();
+                });
+            })
+
+            function cancelFormNoteSection(el) {
+                $(el).closest('.note-section').toggleClass('edit');
+                return false;
+            }
+        })
+    </script>

+ 1 - 0
resources/views/layouts/template.blade.php

@@ -31,6 +31,7 @@
 
     <script src="{{ asset('js/app.js') }}" type="application/javascript"></script>
     <script src="/js/jquery-3.5.1.min.js"></script>
+    <script src="/js/jquery.form.min.js"></script>
     <script src="{{ asset('js/toastr.min.js') }}" type="application/javascript"></script>
     <script src="/js/yemi.js?_=7" type="application/javascript"></script>
 

+ 70 - 0
spec/updated-section-work

@@ -0,0 +1,70 @@
+
+	section_template
+		id
+		internal_name
+		title
+		is_canvas // remember: canvas_key == internal_name
+		
+	DIRECTORY:
+		
+		/{$section->internal_name}
+			
+			default.php
+			
+			summary.php
+			processor.php
+			
+			form.php
+			actions.php
+
+	*WILDCARD* there may be /template from (C) to enable smart-update of text into the free text field.
+
+----------------------------------------------------------------
+
+	@foreach($sections as $section)
+	
+		{{$section->title}} [edit/view toggle] MAYBE:: [templates] OPTIONAL:: [actions...]
+		
+		--------------------------------------------------------------------------
+			
+			VIEW-MODE:
+				{{$section->summary_html}} - DONE
+			
+		--------------------------------------------------------------------------
+		
+			EDIT-MODE: // if [name=data], just listen for changes to [name=data] and auto-save / replace summary_html.
+
+				@if($section->section_template->canvas_key) // PAST_MEDICAL_HISTORY
+				
+					@include(/vijay-folder/{{$section->section_template->canvas_key}}.php) // expected: <input type="hidden" name="data">
+					
+				@elseif(file_exists('form.php') // PHYSICAL_ACTIVITY
+				
+					@include('form.php') // may contain <input type="hidden" name="data">
+			
+				@else // CC
+					
+					<input type="hidden" name="data"> // always  -  DONE
+					
+					<rich-editor onChange... update data as {value: ...}> - DONE
+						$section->content_data['value']
+					</rich-editor>
+				
+		--------------------------------------------------------------------------
+	
+	@endforeach
+	
+====================================================================================================
+
+	WHEN update on section... DONE
+	
+		// take the $data - DONE
+		// check if processor.php. - DONE
+		// if not, 
+			// assume it's mud - the new contentData as is replaces. !!! NOT $request->all(), $request->get('data') - DONE
+			// save it
+			// generate summary_html... 
+				// run summary.php if there, ob_start/flush... etc. - DONE
+				// else, use data->value as the summary_html. - DONE
+
+=====================================================================================================

+ 0 - 0
storage/sections/cc/default.php → storage/sections/cc_deleted/default.php


+ 0 - 0
storage/sections/cc/form.blade.php → storage/sections/cc_deleted/form.blade.php


+ 0 - 0
storage/sections/cc/processor.php → storage/sections/cc_deleted/processor.php


+ 0 - 0
storage/sections/cc/summary.php → storage/sections/cc_deleted/summary.php


+ 7 - 31
storage/sections/current-goals/form.blade.php

@@ -1,40 +1,16 @@
 <?php
 $contentData = false;
-if($section){
+if ($section) {
     $contentData = json_decode($section->content_data, true);
 }
-if(!$contentData || !isset($contentData['value'])) {
+if (!$contentData || !isset($contentData['value'])) {
     $contentData = [
-        'value'=>''
+        'value' => ''
     ];
 }
 $formID = rand(0, 100000);
 ?>
-<form method="POST" action="/process_form_submit" onsubmit="return submitForm_NoteSection_{{ $formID }}(this);">
-    <?php if($section): ?>
-        <input type="hidden" name="section_uid" value="<?= $section->uid?>">
-    <?php else: ?>
-        <input type="hidden" name="note_uid" value="<?= $note->uid?>">
-        <input type="hidden" name="section_template_uid" value="<?= $sectionTemplate->uid ?>">
-    <?php endif; ?>
-    <div class="form-group mb-2">
-        <textarea rte type="text" class="form-control form-control-sm p-2" name="value" placeholder="Value"><?= $contentData['value'] ?></textarea>
-    </div>
-    <div class="form-group m-0 d-flex">
-        <button class="btn btn-sm btn-primary mr-2">Submit</button>
-        <button class="btn btn-sm btn-default border" onclick="return cancelForm_NoteSection_{{ $formID }}(this)">Cancel</button>
-    </div>
-</form>
-<script>
-    function submitForm_NoteSection_{{ $formID }}(_form) {
-        showMask();
-        $.post(_form.action, $(_form).serialize(), function(_data) {
-            fastReload();
-        });
-        return false;
-    }
-    function cancelForm_NoteSection_{{ $formID }}(_trigger) {
-        $(_trigger).closest('.note-section').toggleClass('edit');
-        return false;
-    }
-</script>
+
+<div class="form-group mb-2">
+    <textarea rte type="text" class="form-control form-control-sm p-2" name="value" placeholder="Value"><?= $contentData['value'] ?></textarea>
+</div>

+ 3 - 1
storage/sections/pmhx/form.blade.php

@@ -142,7 +142,9 @@ $formID = rand(0, 100000);
                     @endif
                     @for($k = 0; $k < count($values); $k++)
                         <?php
-                            $fName = $head . '_' . sanitize_field_name($values[$k]);
+                            if(isset($values[$k])){
+                                $fName = $head . '_' . sanitize_field_name($values[$k]);
+                            }
                         ?>
                         <label class="d-flex align-items-center mb-1">
                             <input type="checkbox" name="{{ $fName }}" class="m-0"

+ 20 - 0
storage/sections/sample/default.php

@@ -0,0 +1,20 @@
+<?php
+$value = [];
+$infoLines = json_decode($patient->info_lines);
+$infoLines = !$infoLines ? [] : $infoLines;
+global $defaultData;
+foreach($infoLines as $category => $lines):
+    if($category === "dx"):
+        foreach ($lines as $line):
+            $value[] = $line->contentText;
+        endforeach;
+    endif;
+endforeach;
+$result = $patient->displayName() . ", {$patient->age_in_years} years old {$patient->sex} ";
+if(count($value)) {
+    $result .= "presenting with " . implode(", ", $value);
+}
+$defaultData = [
+    "summary" => $result,
+    "value" => $result,
+];

+ 0 - 0
storage/sections/goals/form.blade.php → storage/sections/sample/form.blade.php


+ 0 - 0
storage/sections/goals/processor.php → storage/sections/sample/processor.php


+ 0 - 0
storage/sections/goals/summary.php → storage/sections/sample/summary.php


Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini