瀏覽代碼

Changes during the call

Vijayakrishnan 4 年之前
父節點
當前提交
bf3f2e4de3

+ 23 - 4
app/Http/Controllers/NoteController.php

@@ -82,6 +82,7 @@ class NoteController extends Controller
         $note = null;
         $sectionTemplate = null;
 
+        // if CREATE
         if($section == null){
             // TODO require valid note_uid & section_template_uid
             $note = Note::where('uid', $note_uid)->first();
@@ -101,8 +102,20 @@ class NoteController extends Controller
         // if UPDATE, $section, and $request
 
         // remember: the existence of form.php overrides section_template.is_canvas == TRUE
-        if(file_exists(storage_path('sections/' . $sectionTemplate->internal_name . '/form.blade.php'))) {
-          
+
+        if($sectionTemplate->is_canvas){
+            if(file_exists()){
+                include(storage_path('sections/' . $sectionTemplate->internal_name . '/processor.php'));
+            }else{
+                $newContentData = json_decode($request->get('data'), true);
+            }
+            ob_start();
+            // TODO include the resource_path
+            include(storage_path('sections/' . $sectionTemplate->internal_name . '/summary.php'));
+            $newSummaryHtml = ob_get_contents();
+            ob_end_clean();
+        }elseif(file_exists(storage_path('sections/' . $sectionTemplate->internal_name . '/form.blade.php'))) {
+
             include(storage_path('sections/' . $sectionTemplate->internal_name . '/processor.php'));
 
             // now, create summaryHtml appropriate
@@ -114,7 +127,7 @@ class NoteController extends Controller
             $newContentData = json_decode($request->get('data'), true);
             if(isset($newContentData['value'])){
                 $newSummaryHtml = $newContentData['value'];
-            }  
+            }
         }
 
         $response = null;
@@ -129,6 +142,12 @@ class NoteController extends Controller
             //TODO: handle if response->success == false
         }else{
             // call Java to create section
+            // if default.php, run it to hydrate $newContentData and $newSummaryHtml
+
+            if(file_exists(storage_path('sections/' . $sectionTemplate->internal_name . '/default.php'))) {
+                include(storage_path('sections/' . $sectionTemplate->internal_name . '/default.php'));
+            }
+
             $data = [
                 'noteUid' => $note->uid,
                 'sectionTemplateUid' => $sectionTemplate->uid,
@@ -139,7 +158,7 @@ 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 redirect(route('patients.view.notes',$note->client->uid));
          return [
              'success' => $response->success,
              'newSummaryHtml' => $newSummaryHtml

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

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

@@ -33,7 +33,7 @@ if(!$contentData) {
 $formID = rand(0, 100000);
 ?>
 <div id="{{$key}}_{{ $formID }}">
-
+    <input type="hidden" name="data" value="">
     <div class="row">
         @for ($i = 0; $i < count($fields); $i++)
             <div class="col-md-3">

+ 27 - 29
resources/views/app/patient/note/note-section-list.blade.php

@@ -1,3 +1,4 @@
+<?php $canvasData = json_decode($patient->canvas_data, true); ?>
 @foreach($note->sections as $section)
     <?php
     $sectionTS = strtotime($section->created_at);
@@ -26,7 +27,7 @@
                 </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'));
@@ -58,24 +59,30 @@
         </div>
 
         <div class="d-none if-edit">
-            
-            <?php if($section->sectionTemplate->is_canvas){ ?>
-                <div class="pl-2 mt-2">
-                    <div class="d-flex align-items-center pb-2">
-                        <h6 class="my-0 font-weight-bold">{{$section->sectionTemplate->title}}</h6>
-                        <span class="mx-2 text-secondary">|</span>
-                        @include('app.patient.canvas-sections.canvas-editor-modal', ['key' => $sectionInternalName])
-                    </div>
-                   
-                </div>
+
+            <?php
+            // if canvas
+            if($section->sectionTemplate->is_canvas) {
+                $contentData = false;
+                if ($canvasData) {
+                    if (isset($canvasData[$sectionInternalName])) {
+                        $contentData = $canvasData[$sectionInternalName];
+                    }
+                }
+            ?>
+                @include("app.patient.canvas-sections.{$key}.form")
             <?php
-                } else if(file_exists(storage_path('sections/' . $sectionInternalName . '/form.blade.php'))) {
+            }
+
+            // if form driven
+            else if(file_exists(storage_path('sections/' . $sectionInternalName . '/form.blade.php'))) {
             ?>
-            
                 @include('sections.' . $sectionInternalName . '.form')
-                
             <?php
-                }else{
+            }
+
+            // if neither canvas nor form driven
+            else {
                 $contentData = false;
                 if($section){
                     $contentData = json_decode($section->content_data, true);
@@ -86,19 +93,10 @@
                     ];
                 }
             ?>
-            <form ajax-form method="POST" action="/process_form_submit">
-                <input type="hidden" name="section_uid" value="<?= $section->uid?>">
-                <input type="hidden" name="data" value="">
                 <div note-rte data-content="{{$contentData['value']}}" class="form-group mb-2 border-left border-right rte-holder"></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 cancelFormNoteSection(this)">Cancel</button>
-                </div>
-            </form>
-            
             <?php
-                }
-            ?>     
+            }
+            ?>
         </div>
     </div>
     @endforeach
@@ -130,7 +128,7 @@
                     var dataValue = JSON.stringify({value: content});
                     var dataField = $(el).closest('form').find('input[name=data]').val(dataValue);
                 });
-                
+
             })
 
             $('[ajax-form]').each(function(){
@@ -148,5 +146,5 @@
             }
 
         })
-        
-    </script>
+
+    </script>

+ 4 - 6
storage/sections/cc_deleted/default.php → 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} ";
+$newSummaryHtml = $patient->displayName() . ", {$patient->age_in_years} years old {$patient->sex} ";
 if(count($value)) {
-    $result .= "presenting with " . implode(", ", $value);
+    $newSummaryHtml .= "presenting with " . implode(", ", $value);
 }
-$defaultData = [
-    "summary" => $result,
-    "value" => $result,
+$newContentData = [
+    'value' => $newSummaryHtml
 ];

+ 0 - 40
storage/sections/cc_deleted/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/cc_deleted/processor.php

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

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

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