Explorar el Código

Merge branch 'dev-josh-sal' into dev-vj

Vijayakrishnan hace 4 años
padre
commit
5da8a289c0
Se han modificado 31 ficheros con 445 adiciones y 507 borrados
  1. 80 77
      app/Http/Controllers/NoteController.php
  2. 10 0
      public/js/jquery.form.min.js
  3. 0 2
      public/js/mc.js
  4. 0 1
      resources/views/app/patient/canvas-sections/canvas-editor-modal.blade.php
  5. 95 0
      resources/views/app/patient/canvas-sections/fancy/form.blade.php
  6. 3 3
      resources/views/app/patient/canvas-sections/fhx/form.blade.php
  7. 1 0
      resources/views/app/patient/canvas-sections/pmhx/form.blade.php
  8. 1 0
      resources/views/app/patient/canvas-sections/pshx/form.blade.php
  9. 8 3
      resources/views/app/patient/canvas-sections/sochx/form.blade.php
  10. 3 110
      resources/views/app/patient/note/dashboard.blade.php
  11. 154 0
      resources/views/app/patient/note/note-section-list.blade.php
  12. 1 0
      resources/views/layouts/template.blade.php
  13. 3 1
      routes/web.php
  14. 70 0
      spec/updated-section-work
  15. 1 26
      storage/sections/assessment/form.blade.php
  16. 5 7
      storage/sections/cc/default.php
  17. 0 40
      storage/sections/current-goals/form.blade.php
  18. 0 4
      storage/sections/current-goals/processor.php
  19. 0 1
      storage/sections/current-goals/summary.php
  20. 0 40
      storage/sections/goals/form.blade.php
  21. 0 4
      storage/sections/goals/processor.php
  22. 0 1
      storage/sections/goals/summary.php
  23. 1 0
      storage/sections/physical-activity-assessment/form.blade.php
  24. 3 1
      storage/sections/pmhx/form.blade.php
  25. 6 0
      storage/sections/sample/default.php
  26. 0 0
      storage/sections/sample/form.blade.php
  27. 0 0
      storage/sections/sample/processor.php
  28. 0 0
      storage/sections/sample/summary.php
  29. 0 107
      storage/sections/sochx/form.blade.php
  30. 0 35
      storage/sections/sochx/processor.php
  31. 0 44
      storage/sections/sochx/summary.php

+ 80 - 77
app/Http/Controllers/NoteController.php

@@ -14,7 +14,8 @@ use App\Models\SectionTemplate;
 
 class NoteController extends Controller
 {
-    public function dashboard(Request $request, Client $patient, Note $note )
+    
+    public function dashboard(Request $request, Client $patient, Note $note)
     {
         $pros = Pro::all();
         $noteSections = $note->sections;
@@ -22,7 +23,7 @@ class NoteController extends Controller
         foreach ($allSections as $section) {
             $section->used = false;
             foreach ($noteSections as $noteSection) {
-                if($noteSection->sectionTemplate->id === $section->id) {
+                if ($noteSection->sectionTemplate->id === $section->id) {
                     $section->used = true;
                     $section->section_uid = $noteSection->uid;
                     break;
@@ -41,100 +42,102 @@ class NoteController extends Controller
         return view('client/note', compact('note', 'client'));
     }
 
-    public function sectionCreateForm($note_uid, $section_template_uid, Request $request)
+    // JAVA ONLY
+    public function getDefaultValueForSection($patientID, $sectionTemplateID)
     {
-        $note = Note::where('uid', $note_uid)->first();
-        $sectionTemplate = SectionTemplate::where('uid', $section_template_uid)->first();
-        $section = null; // convenience
-        include(storage_path('sections/' . $sectionTemplate->internal_name . '/form.blade.php'));
-    }
-
-    public function sectionUpdateForm($section_uid, Request $request)
-    {
-        $section = Section::where('uid', $section_uid)->first();
-        $note = Note::where('id', $section->note_id)->first();
-        $sectionTemplate = SectionTemplate::where('id', $section->section_template_id)->first();
-        include(storage_path('sections/' . $sectionTemplate->internal_name . '/form.blade.php'));
-    }
-
-    public function getDefaultValueForSection($section, $patient_uid) {
-        $defaultData = [
-            "summary" => "",
-            "value" => ""
-        ];
-        $patient = Client::where('uid', $patient_uid)->first();
-        if(file_exists(storage_path('sections/' . $section . '/default.php'))) {
-            include(storage_path('sections/' . $section . '/default.php'));
+        $contentData = [];
+        $summaryHtml = '';
+        $patient = Client::where('id', $patientID)->first();
+        $sectionTemplate = SectionTemplate::where('id', $sectionTemplateID)->first();
+        
+        if (file_exists(storage_path('sections/' . $sectionTemplate->internal_name . '/default.php'))) {
+            // default should simply assign to $contentData and $summaryHtml as needed
+            include(storage_path('sections/' . $sectionTemplate->internal_name . '/default.php'));
         }
-        return json_encode($defaultData);
+        return [
+            'contentData' => $contentData,
+            'summaryHtml' => $summaryHtml
+        ];
     }
 
     public function processFormSubmit(Request $request)
     {
-        // for CREATE
-        $note_uid =  $request->note_uid;
-        $section_template_uid =  $request->section_template_uid;
-
-        // for UPDATE
-        $section_uid =  $request->section_uid;
-
-        $section = $section_uid ? Section::where('uid', $section_uid)->first() : null;
-        $note = null;
-        $sectionTemplate = null;
+        // TODO require
+        $section_uid =  $request->get('section_uid');
 
-        if($section == null){
-            $note = Note::where('uid', $note_uid)->first();
-            $sectionTemplate = SectionTemplate::where('uid', $section_template_uid)->first();
-        } else {
-            $note = Note::where('id', $section->note_id)->first();
-            $sectionTemplate = SectionTemplate::where('id', $section->section_template_id)->first();
-        }
+        $section = Section::where('uid', $section_uid)->first();
+        $note = Note::where('id', $section->note_id)->first();
+        $client = Client::where('id', $note->client_id)->first();
+        $patient = $client;
+        $sectionTemplate = SectionTemplate::where('id', $section->section_template_id)->first();
 
         $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();
-
+        $sectionInternalName = $sectionTemplate->internal_name;
+        if ($sectionTemplate->is_canvas) {
 
-        if($section){
-            // call Java to update section
+            $response = null;
             $data = [
-                'uid' => $section->uid,
-                'contentData' => json_encode($newContentData),
-                'summaryHtml' => $newSummaryHtml
-            ];
-            $response = $this->calljava($request, '/section/update', $data);
-            //TODO: handle if response->success == false
-        }else{
-            // call Java to create section
-            $data = [
-                'noteUid' => $note->uid,
-                'sectionTemplateUid' => $sectionTemplate->uid,
-                'contentData' => json_encode($newContentData),
-                'summaryHtml' => $newSummaryHtml
+                'uid' => $client->uid,
+                'key' => $sectionTemplate->internal_name,
+                'data' => $request->get('data')
             ];
+            $response = $this->calljava($request, '/client/updateCanvasData', $data);
+            //TODO: handle $response->success == false
+
+            $client = Client::where('id', $note->client_id)->first();
+            $patient = $client;
+            if (file_exists(resource_path("views/app/patient/canvas-sections/{$sectionInternalName}/processor.php"))) {
+                include(resource_path("views/app/patient/canvas-sections/{$sectionInternalName}/processor.php"));
+            } else {
+                $newContentData = json_decode($request->get('data'), true);
+            }
+        
+            ob_start();
+            include(resource_path("views/app/patient/canvas-sections/{$sectionInternalName}/summary.php"));
+            $newSummaryHtml = ob_get_contents();
+            ob_end_clean();
+            // TODO call Java to update the canvas
+        } elseif (file_exists(storage_path('sections/' . $sectionTemplate->internal_name . '/form.blade.php'))) {
+
+            include(storage_path('sections/' . $sectionTemplate->internal_name . '/processor.php'));
+
+            ob_start();
+            include(storage_path('sections/' . $sectionTemplate->internal_name . '/summary.php'));
+            $newSummaryHtml = ob_get_contents();
+            ob_end_clean();
+        } else {
 
-            $response = $this->callJava($request, '/section/create', $data);
-            //TODO: handle if response->success == false
+            $newContentData = json_decode($request->get('data'), true);
+            if (isset($newContentData['value'])) {
+                $newSummaryHtml = $newContentData['value'];
+            }
         }
-        // return redirect(route('patients.view.notes',$note->client->uid));
-        return "";
+
+        $response = null;
+        $data = [
+            'uid' => $section->uid,
+            'contentData' => json_encode($newContentData),
+            'summaryHtml' => $newSummaryHtml
+        ];
+        $response = $this->calljava($request, '/section/update', $data);
+
+        return [
+            'success' => $response['success'],
+            'newSummaryHtml' => $newSummaryHtml
+        ];
     }
 
-    private function callJava($request, $endPoint, $data){
+    // TODO move to utility
+    private function callJava($request, $endPoint, $data)
+    {
         $url =  config('stag.backendUrl') . $endPoint;
         $response = Http::asForm()
-        ->withHeaders(['sessionKey'=>$request->cookie('sessionKey')])
-        ->post($url, $data)
-        ->json();
+            ->withHeaders(['sessionKey' => $request->cookie('sessionKey')])
+            ->post($url, $data)
+            ->json();
         return $response;
     }
+
 }

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 10 - 0
public/js/jquery.form.min.js


+ 0 - 2
public/js/mc.js

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

+ 0 - 1
resources/views/app/patient/canvas-sections/canvas-editor-modal.blade.php

@@ -12,7 +12,6 @@
     <form method="POST" action="/api/client/updateCanvasData">
         <input type="hidden" name="uid" value="{{$patient->uid}}">
         <input type="hidden" name="key" value="{{$key}}">
-        <input type="hidden" name="canvasData" value="">
 
         @include("app.patient.canvas-sections.{$key}.form")
 

+ 95 - 0
resources/views/app/patient/canvas-sections/fancy/form.blade.php

@@ -0,0 +1,95 @@
+<?php
+if(!$contentData) {
+    $contentData = [
+        "count" => 1,
+        "unknown" => false,
+        "items" => [[]]
+    ];
+}
+
+$formID = rand(0, 100000);
+?>
+<div id="fancyModule">
+    <input type="hidden" name="data" value="">
+
+
+</div>
+<script>
+    (function() {
+        function init() {
+            window.clientFHXApp = new Vue({
+                el: '#fhx_{{ $formID }}',
+                data: {
+                    count: {{ $contentData['count'] }},
+                    unknown: {{ $contentData['unknown'] ? 'true' : 'false' }},
+                    items: <?= json_encode($contentData['items']) ?>
+                },
+                mounted: function() {
+
+                },
+                watch: {
+                    $data: {
+                        handler: function(val, oldVal) {
+                            $(this.$el).closest('form').find('[name="canvasData"]').val(JSON.stringify({
+                                count: this.count,
+                                unknown: this.unknown,
+                                items: this.cleanArray(this.items)
+                            }));
+                        },
+                        deep: true
+                    }
+                },
+                methods: {
+                    addItem: function() {
+                        this.items.push({
+                            relationship: '',
+                            status: '',
+
+                            general_no_health_concern: null,
+                            general_arthritis: null,
+                            general_asthma: null,
+                            general_bleeding_disorder: null,
+                            general_cad_lt_age_55: null,
+                            general_copd: null,
+                            general_diabetes: null,
+                            general_heart_attack: null,
+                            general_heart_disease: null,
+                            general_high_cholesterol: null,
+                            general_hypertension: null,
+                            general_mental_illness: null,
+                            general_osteoporosis: null,
+                            general_stroke: null,
+
+                            cancer_breast_ca: null,
+                            cancer_colon_ca: null,
+                            cancer_other_ca: null,
+                            cancer_ovarian_ca: null,
+                            cancer_uterine_ca: null,
+
+                            comments: '',
+                        });
+                        this.count = this.items.length;
+                    },
+                    removeItem: function(_index) {
+                        this.items.splice(_index, 1);
+                        this.count = this.items.length;
+                    },
+                    cleanArray: function(_source) {
+                        let plItems = [], plObject = {};
+                        for (let x=0; x<_source.length; x++) {
+                            plObject = {};
+                            for (let y in _source[x]) {
+                                if(_source[x].hasOwnProperty(y)) {
+                                    plObject[y] = _source[x][y];
+                                }
+                            }
+                            plItems.push(plObject);
+                        }
+                        return plItems;
+                    }
+                }
+            });
+        }
+        addMCInitializer('client-fhx-{{ $patient->uid }}', init);
+    })();
+</script>

+ 3 - 3
resources/views/app/patient/canvas-sections/fhx/form.blade.php

@@ -9,8 +9,8 @@ if(!$contentData) {
 
 $formID = rand(0, 100000);
 ?>
-<div id="{{$key}}_{{ $formID }}">
-
+<div id="fhxSection">
+    <input type="hidden" name="data" value="">
     <div class="border border-secondary rounded mb-2 p-2">
         <label class="my-0 d-flex align-items-center">
             <input type="checkbox" class="my-0 mr-2" v-model="unknown" name="unknown">
@@ -230,7 +230,7 @@ $formID = rand(0, 100000);
     (function() {
         function init() {
             window.clientFHXApp = new Vue({
-                el: '#fhx_{{ $formID }}',
+                el: '#fhxSection',
                 data: {
                     count: {{ $contentData['count'] }},
                     unknown: {{ $contentData['unknown'] ? 'true' : 'false' }},

+ 1 - 0
resources/views/app/patient/canvas-sections/pmhx/form.blade.php

@@ -44,6 +44,7 @@ if(!$contentData) {
 $formID = rand(0, 100000);
 ?>
 <div id="{{$key}}_{{ $formID }}">
+    <input type="hidden" name="data" value="">
     <div class="mb-3 d-flex align-items-start">
         <div class="width-100px mr-3">
             <label class="text-secondary mb-1">Blood Type</label>

+ 1 - 0
resources/views/app/patient/canvas-sections/pshx/form.blade.php

@@ -30,6 +30,7 @@ if(!$contentData) {
 $formID = rand(0, 100000);
 ?>
 <div id="{{$key}}_{{ $formID }}">
+    <input type="hidden" name="data" value="">
     <div class="row">
         <div class="col-12">
             <div class="font-weight-bold my-1">Common Surgeries</div>

+ 8 - 3
resources/views/app/patient/canvas-sections/sochx/form.blade.php

@@ -32,8 +32,8 @@ if(!$contentData) {
 
 $formID = rand(0, 100000);
 ?>
-<div id="{{$key}}_{{ $formID }}">
-
+<div id="sochx_{{ $formID }}">
+    <input type="hidden" name="data" value="">
     <div class="row">
         @for ($i = 0; $i < count($fields); $i++)
             <div class="col-md-3">
@@ -154,11 +154,16 @@ $formID = rand(0, 100000);
                 mounted: function () {
                     $('#sochx_{{ $formID }} [moe][initialized]').removeAttr('initialized');
                     initMoes();
+                    $('#sochx_{{ $formID }}').find('[name="data"]').val(JSON.stringify({
+                        common: this.cleanObject(this.common),
+                        customFields: this.customFields,
+                        comments: this.comments,
+                    }));
                 },
                 watch: {
                     $data: {
                         handler: function(val, oldVal) {
-                            $(this.$el).closest('form').find('[name="canvasData"]').val(JSON.stringify({
+                            $('#sochx_{{ $formID }}').find('[name="data"]').val(JSON.stringify({
                                 common: this.cleanObject(this.common),
                                 customFields: this.customFields,
                                 comments: this.comments,

+ 3 - 110
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-section-list')
                     </div>
                 </div>
 
@@ -632,27 +576,7 @@
                         return false;
                     });
 
-                $('.note-section.pending-initialization').each(function() {
-                    let sName = $(this).attr('data-section-template-name');
-                    if(['vitals', 'allergies', 'medication', 'care-team', 'assessment', 'new-patient-intake', 'cc'].indexOf(sName) === -1) {
-                        $(this).removeClass('pending-initialization');
-                    }
-                });
-
-                let sectionsPendingInitialization = $('.note-section.pending-initialization');
-                numSectionsPendingInitialization = sectionsPendingInitialization.length;
-                if(numSectionsPendingInitialization > 0) {
-                    showMask('Initializing note. Please wait...');
-                    sectionsPendingInitialization.each(function() {
-                        initializeSection(
-                            $(this).attr('data-section-uid'),
-                            $(this).attr('data-section-template-name')
-                        );
-                    });
-                }
-                else {
-                    scrollToLatest();
-                }
+                scrollToLatest();
 
                 function __moveSection(_uid, _direction) {
                     $.post('/api/section/move' + _direction, {
@@ -697,33 +621,6 @@
                 }, 100);
             }
 
-            function initializeSection(_sectionUid, _sectionTemplateName) {
-                $.get('/get-default-section-data/' + _sectionTemplateName + '/{{$patient->uid}}' , function(_data) {
-                    if(!_data) {
-                        numSectionsPendingInitialization--;
-                        if(numSectionsPendingInitialization <= 0) {
-                            fastReload();
-                        }
-                        return;
-                    }
-                    let payload = {
-                        section_uid: _sectionUid
-                    };
-                    for(let x in _data) {
-                        if(_data.hasOwnProperty(x)) {
-                            payload[x] = _data[x];
-                        }
-                    }
-                    $.post('/process_form_submit', payload, function(_data) {
-                        console.log('done: ', _sectionTemplateName);
-                        numSectionsPendingInitialization--;
-                        if(numSectionsPendingInitialization <= 0) {
-                            fastReload();
-                        }
-                    });
-                }, 'json');
-            }
-
             function loadTemplateSet(_chooser) {
                 if(!_chooser.length || !_chooser.val()) return false;
                 let container = _chooser.closest('.note-template-container');
@@ -858,12 +755,9 @@
                         sections: allSections
                     },
                     methods: {
-                        add: function(_uid, _section) {
-                            $.get('/get-default-section-data/' + _section + '/{{$patient->uid}}' , function(_data) {
+                        add: function(_uid, _section) {                            
                                 $.post('/api/section/create', {
                                     noteUid: '{{$note->uid}}',
-                                    summaryHtml: _data.summary,
-                                    contentData: JSON.stringify({value: _data.value}),
                                     sectionTemplateUid: _uid,
                                 }, function(_data) {
                                     if(_data) {
@@ -878,7 +772,6 @@
                                         toastr.error('Unable to add section!');
                                     }
                                 }, 'json');
-                            }, 'json');
                         },
                         remove: function(_uid) {
                             $.post('/api/section/deactivate', {

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

@@ -0,0 +1,154 @@
+<?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>
+
+            <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 class="d-none if-edit">
+
+            <?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
+            }
+
+            // 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
+            }
+            ?>
+
+            <div class="form-control">
+                <button  class="btn btn-sm btn-primary" btn-save-form><i class="fa fa-save"></i></button>
+            </div>
+        </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('.note-section').find('input[name=data]').val(dataValue);
+                });
+            })
+
+            $('[btn-save-form]').on('click', function(){
+                var  dataField = $(this).closest('.note-section').find('input[name=data]')
+                var value = $(dataField).val();
+
+                var summaryContainer = $(this).closest('.note-section').find('.summary-container')
+                
+                var sectionUid = $(this).closest('.note-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);
+                   }
+                },'json');
+            })
+            
+        })
+
+    </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>
 

+ 3 - 1
routes/web.php

@@ -142,9 +142,11 @@ Route::middleware('pro.auth')->group(function () {
     Route::get('/section_create_form/{note_uid}/{section_template_uid}', 'NoteController@sectionCreateForm')->name('section_create_form');
     Route::get('/section_update_form/{section_uid}', 'NoteController@sectionUpdateForm')->name('section_update_form');
     Route::post("/process_form_submit", 'NoteController@processFormSubmit')->name('process_form_submit');
-    Route::get("/get-default-section-data/{section}/{uid}", 'NoteController@getDefaultValueForSection')->name('get_default_section_data');
 
     Route::get("/log_in_as", 'HomeController@logInAs')->name('log-in-as');
     Route::post("/process-log_in_as", 'HomeController@processLogInAs')->name('process-log-in-as');
     Route::post("/back_to_admin_pro", 'HomeController@backToAdminPro')->name('back-to-admin-pro');
 });
+
+Route::get("/get-default-section-data/{patientID}/{sectionTemplateID}", 'NoteController@getDefaultValueForSection')->name('get_default_section_data');
+

+ 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  - DONE
+				
+					@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
+
+=====================================================================================================

+ 1 - 26
storage/sections/assessment/form.blade.php

@@ -1,15 +1,3 @@
-<?php
-$contentData = false;
-if($section){
-    $contentData = json_decode($section->content_data, true);
-}
-if(!$contentData || !isset($contentData['value'])) {
-    $contentData = [
-        '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?>">
@@ -24,17 +12,4 @@ $formID = rand(0, 100000);
         <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>
+</form>

+ 5 - 7
storage/sections/cc/default.php

@@ -2,7 +2,6 @@
 $value = [];
 $infoLines = json_decode($patient->info_lines);
 $infoLines = !$infoLines ? [] : $infoLines;
-global $defaultData;
 foreach($infoLines as $category => $lines):
     if($category === "dx"):
         foreach ($lines as $line):
@@ -10,11 +9,10 @@ foreach($infoLines as $category => $lines):
         endforeach;
     endif;
 endforeach;
-$result = $patient->displayName() . ", {$patient->age_in_years} years old {$patient->sex} ";
+$summaryHtml = $patient->displayName() . ", {$patient->age_in_years} years old {$patient->sex} ";
 if(count($value)) {
-    $result .= "presenting with " . implode(", ", $value);
+    $summaryHtml .= "presenting with " . implode(", ", $value);
 }
-$defaultData = [
-    "summary" => $result,
-    "value" => $result,
-];
+$contentData = [
+    'value' => $summaryHtml
+];

+ 0 - 40
storage/sections/current-goals/form.blade.php

@@ -1,40 +0,0 @@
-<?php
-$contentData = false;
-if($section){
-    $contentData = json_decode($section->content_data, true);
-}
-if(!$contentData || !isset($contentData['value'])) {
-    $contentData = [
-        '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>

+ 0 - 4
storage/sections/current-goals/processor.php

@@ -1,4 +0,0 @@
-<?php
-$newContentData = [
-    'value' => $request->get('value')
-];

+ 0 - 1
storage/sections/current-goals/summary.php

@@ -1 +0,0 @@
-<div><?= $newContentData['value']; ?></div>

+ 0 - 40
storage/sections/goals/form.blade.php

@@ -1,40 +0,0 @@
-<?php
-$contentData = false;
-if($section){
-    $contentData = json_decode($section->content_data, true);
-}
-if(!$contentData || !isset($contentData['value'])) {
-    $contentData = [
-        '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>

+ 0 - 4
storage/sections/goals/processor.php

@@ -1,4 +0,0 @@
-<?php
-$newContentData = [
-    'value' => $request->get('value')
-];

+ 0 - 1
storage/sections/goals/summary.php

@@ -1 +0,0 @@
-<div><?= $newContentData['value']; ?></div>

+ 1 - 0
storage/sections/physical-activity-assessment/form.blade.php

@@ -7,6 +7,7 @@ if (!$contentData) {
     $contentData = [];
 }
 $formID = rand(0, 100000);
+
 ?>
 <form method="POST" action="/process_form_submit" onsubmit="return submitForm_NoteSection_{{ $formID }}(this);">
     <?php if($section): ?>

+ 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"

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

@@ -0,0 +1,6 @@
+<?php
+
+$defaultData = [
+    "summary" => $result,
+    "value" => $result,
+];

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


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


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


+ 0 - 107
storage/sections/sochx/form.blade.php

@@ -1,107 +0,0 @@
-<?php
-$fields = [
-    [
-        "Tobacco:::Current every day smoker|Current some day smoker|Former smoker|Heavy tobacco smoker|Light tobacco smoker|Never smoker|Smoker, current status unknown|Unknown if ever smoked ",
-    ],
-    [
-        "Alcohol:::Do not drink|Drink daily|Frequently drink|Hx of Alcoholism|Occasional drink",
-        "Drug Abuse:::IVDU|Illicit drug use|No illicit drug use",
-    ],
-    [
-        "Cardiovascular:::Eat healthy meals|Regular exercise|Take daily aspirin",
-        "Safety:::Household Smoke detector|Keep Firearms in home|Wear seatbelts",
-    ],
-    [
-        "Sexual Activity:::Exposure to STI|Homosexual encounters|Not sexually active|Safe sex practices|Sexually active",
-        "Birth Gender:::Male|Female|Undifferentiated",
-    ]
-];
-
-$contentData = false;
-if($section){
-    $contentData = json_decode($section->content_data, true);
-}
-if(!$contentData) {
-    $contentData = [];
-}
-for ($i = 0; $i < count($fields); $i++) {
-    for($j = 0; $j < count($fields[$i]); $j++) {
-        $parts = explode(":::", $fields[$i][$j]);
-        $head = 'custom';
-        if(!empty($parts[0])) $head = $parts[0];
-        $values = explode("|", $parts[1]);
-        for($k = 0; $k < count($values); $k++) {
-            $fName = $head . '_' . sanitize_field_name($values[$k]);
-            if(!isset($contentData[$fName])) {
-                $contentData[$fName] = '';
-            }
-        }
-    }
-}
-
-$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="row">
-        @for ($i = 0; $i < count($fields); $i++)
-            <div class="col-md-3">
-                @for($j = 0; $j < count($fields[$i]); $j++)
-                    <?php
-                        $parts = explode(":::", $fields[$i][$j]);
-                        $head = 'custom';
-                        if(!empty($parts[0])) $head = $parts[0];
-                        $values = explode("|", $parts[1]);
-                    ?>
-                    <div class="mb-3">
-                        @if($head !== 'custom')
-                            <div class="font-weight-bold mb-2">{{ $head }}</div>
-                        @endif
-                        @for($k = 0; $k < count($values); $k++)
-                            <?php
-                                $fName = $head . '_' . sanitize_field_name($values[$k]);
-                            ?>
-                             <label class="d-flex align-items-center mb-1">
-                                 <input type="checkbox" name="{{ $fName }}" {{ $contentData[$fName] ? 'checked' : '' }} class="m-0">
-                                 <span class="ml-2">{{ $values[$k] }}</span>
-                             </label>
-                        @endfor
-                    </div>
-                @endfor
-            </div>
-        @endfor
-    </div>
-
-    <div class="row mb-3">
-        <div class="col-12">
-            <textarea rte type="text" class="form-control form-control-sm p-2"
-                      name="comments"
-                      data-shortcuts=""
-                      placeholder="Value"><?= isset($contentData['comments']) ? $contentData['comments'] : '' ?></textarea>
-        </div>
-    </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>

+ 0 - 35
storage/sections/sochx/processor.php

@@ -1,35 +0,0 @@
-<?php
-$fields = [
-    [
-        "Tobacco:::Current every day smoker|Current some day smoker|Former smoker|Heavy tobacco smoker|Light tobacco smoker|Never smoker|Smoker, current status unknown|Unknown if ever smoked ",
-    ],
-    [
-        "Alcohol:::Do not drink|Drink daily|Frequently drink|Hx of Alcoholism|Occasional drink",
-        "Drug Abuse:::IVDU|Illicit drug use|No illicit drug use",
-    ],
-    [
-        "Cardiovascular:::Eat healthy meals|Regular exercise|Take daily aspirin",
-        "Safety:::Household Smoke detector|Keep Firearms in home|Wear seatbelts",
-    ],
-    [
-        "Sexual Activity:::Exposure to STI|Homosexual encounters|Not sexually active|Safe sex practices|Sexually active",
-        "Birth Gender:::Male|Female|Undifferentiated",
-    ]
-];
-
-$newContentData = [];
-
-for ($i = 0; $i < count($fields); $i++) {
-    for($j = 0; $j < count($fields[$i]); $j++) {
-        $parts = explode(":::", $fields[$i][$j]);
-        $head = 'custom';
-        if(!empty($parts[0])) $head = $parts[0];
-        $values = explode("|", $parts[1]);
-        for($k = 0; $k < count($values); $k++) {
-            $fName = $head . '_' . sanitize_field_name($values[$k]);
-            $newContentData[$fName] = $request->get($fName);
-        }
-    }
-}
-
-$newContentData['comments'] = $request->get('comments');

+ 0 - 44
storage/sections/sochx/summary.php

@@ -1,44 +0,0 @@
-<?php
-$fields = [
-    [
-        "Tobacco:::Current every day smoker|Current some day smoker|Former smoker|Heavy tobacco smoker|Light tobacco smoker|Never smoker|Smoker, current status unknown|Unknown if ever smoked ",
-    ],
-    [
-        "Alcohol:::Do not drink|Drink daily|Frequently drink|Hx of Alcoholism|Occasional drink",
-        "Drug Abuse:::IVDU|Illicit drug use|No illicit drug use",
-    ],
-    [
-        "Cardiovascular:::Eat healthy meals|Regular exercise|Take daily aspirin",
-        "Safety:::Household Smoke detector|Keep Firearms in home|Wear seatbelts",
-    ],
-    [
-        "Sexual Activity:::Exposure to STI|Homosexual encounters|Not sexually active|Safe sex practices|Sexually active",
-        "Birth Gender:::Male|Female|Undifferentiated",
-    ]
-];
-
-for ($i = 0; $i < count($fields); $i++) {
-    for($j = 0; $j < count($fields[$i]); $j++) {
-        $parts = explode(":::", $fields[$i][$j]);
-        $head = 'custom';
-        if(!empty($parts[0])) $head = $parts[0];
-        $values = explode("|", $parts[1]);
-        for($k = 0; $k < count($values); $k++) {
-            $fName = $head . '_' . sanitize_field_name($values[$k]);
-            if(isset($newContentData[$fName])) { ?>
-                <div>
-                    <?= ucwords($head) ?>
-                    <i class="fa fa-arrow-right text-sm text-secondary"></i>
-                    <span class="font-weight-bold"><?= $values[$k] ?></span>
-                </div>
-            <?php }
-        }
-    }
-}
-
-if(isset($newContentData['comments'])) { ?>
-    <div class="mt-2 mb-1">
-        <div class="font-weight-bold">Comments:</div>
-        <div><?= $newContentData['comments'] ?></div>
-    </div>
-<?php }

Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio