Эх сурвалжийг харах

Fix allergies & assessment sections

Vijayakrishnan Krishnan 4 жил өмнө
parent
commit
0b21407b68

+ 43 - 0
storage/sections/allergies/actions.php

@@ -0,0 +1,43 @@
+<?php
+$infoLines = json_decode($patient->info_lines);
+$infoLines = !$infoLines ? [] : $infoLines;
+$rows = [];
+foreach ($infoLines as $category => $lines):
+    if ($category === "allergy"):
+        foreach ($lines as $line):
+            $rows[] = '<label class="d-flex align-items-center current-allergy-item mb-1 c-pointer">' .
+                '<input type="checkbox" checked class="my-0 mr-2">' .
+                '<span><b>' . $line->contentText . '</b>&nbsp;' .
+                '</span></label>';
+        endforeach;
+    endif;
+endforeach;
+?>
+
+<div moe class="position-relative d-none if-edit ml-3 pl-3 border-left">
+    <a start show href="#">Current Allergies</a>
+    <form url="/no-op" class="current-allergy-form">
+        <div class="min-width-200px">
+            <?= implode("", $rows) ?>
+            <div class="mt-2 mb-0">
+                <button class="btn btn-primary btn-sm mr-1" type="button" onclick="return applySelectedAllergy()">Apply</button>
+                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+            </div>
+        </div>
+    </form>
+</div>
+
+<script>
+    function applySelectedAllergy() {
+        let html = [];
+        $('.current-allergy-item input:checkbox:checked').each(function() {
+            html.push('<p>' + $(this).next().html() + '</p>');
+        });
+        $('.current-allergy-form').hide();
+        hideMask();
+        hideMoeFormMask();
+        $('.ql-editor[contenteditable]:visible').first().html(html.join('')).focus();
+        return false;
+    }
+</script>
+

+ 17 - 0
storage/sections/allergies/default.php

@@ -0,0 +1,17 @@
+<?php
+$value = [];
+$infoLines = json_decode($patient->info_lines);
+$infoLines = !$infoLines ? [] : $infoLines;
+global $defaultData;
+foreach($infoLines as $category => $lines):
+    if($category === "allergy"):
+        foreach ($lines as $line):
+            $value[] = '<p><b>' . $line->contentText . '</b></p>';
+        endforeach;
+    endif;
+endforeach;
+$value = implode("", $value);
+$defaultData = [
+    "summary" => $value,
+    "value" => $value,
+];

+ 6 - 13
storage/sections/allergies/form.blade.php

@@ -3,29 +3,22 @@ $contentData = false;
 if($section){
     $contentData = json_decode($section->content_data, true);
 }
-if(!$contentData || !isset($contentData['clientInfoLineMulti'])) {
+if(!$contentData || !isset($contentData['value'])) {
     $contentData = [
-        'clientInfoLineMulti'=> [
-            'category' => 'allergy',
-            'contentTexts' => ''
-        ]
+        '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?>">
+    <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 ?>">
+    <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">
-        <label class="text-secondary text-sm mb-1 d-block">One allergy per line:</label>
-        <?php
-        $value = $contentData['clientInfoLineMulti']['contentTexts'];
-        ?>
-        <textarea type="text" class="form-control form-control-sm p-2" name="value" placeholder="Value"><?= $value ?></textarea>
+        <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>

+ 1 - 5
storage/sections/allergies/processor.php

@@ -1,8 +1,4 @@
 <?php
 $newContentData = [
-    "clientInfoLineMulti" => [
-        "category" => "allergy",
-        "contentTexts" => $request->get('value')
-    ]
+    'value' => $request->get('value')
 ];
-

+ 1 - 4
storage/sections/allergies/summary.php

@@ -1,4 +1 @@
-<?php if(!empty($newContentData['clientInfoLineMulti']) && isset($newContentData['clientInfoLineMulti']['contentTexts'])): ?>
-<pre><?= $newContentData['clientInfoLineMulti']['contentTexts'] ?></pre>
-<?php else: ?>-<?php endif; ?>
-
+<div><?= $newContentData['value']; ?></div>

+ 19 - 0
storage/sections/assessment/default.php

@@ -0,0 +1,19 @@
+<?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[] = '<p><b>' . $line->contentText . '</b> ';
+            $value[] = @$line->contentDetail->{"ICD"};
+            $value[] = '</p>';
+        endforeach;
+    endif;
+endforeach;
+$value = implode("", $value);
+$defaultData = [
+    "summary" => $value,
+    "value" => $value,
+];