Selaa lähdekoodia

fixed canvas related note

Josh 4 vuotta sitten
vanhempi
commit
1eb28e43cd

+ 19 - 3
app/Http/Controllers/NoteController.php

@@ -67,6 +67,8 @@ class NoteController extends Controller
 
         $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 = [];
@@ -75,15 +77,28 @@ class NoteController extends Controller
         $sectionInternalName = $sectionTemplate->internal_name;
         if ($sectionTemplate->is_canvas) {
 
-            if (file_exists("app.patient.canvas-sections.{$sectionInternalName}.processor")) {
-                include("app.patient.canvas-sections.{$sectionInternalName}.processor");
+            $response = null;
+            $data = [
+                '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("app.patient.canvas-sections.{$sectionInternalName}.summary");
+            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'));
@@ -107,6 +122,7 @@ class NoteController extends Controller
             'summaryHtml' => $newSummaryHtml
         ];
         $response = $this->calljava($request, '/section/update', $data);
+
         return [
             'success' => $response['success'],
             'newSummaryHtml' => $newSummaryHtml

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

@@ -135,6 +135,7 @@
             })
 
             $('[btn-save-form]').on('click', function(){
+                debugger;
                 var  dataField = $(this).closest('.note-section').find('input[name=data]')
                 var value = $(dataField).val();
 

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