Browse Source

Dynamic questions engine (wip)

Vijayakrishnan 3 năm trước cách đây
mục cha
commit
e27fa60455

+ 21 - 0
public/js/dq.js

@@ -0,0 +1,21 @@
+(function() {
+    window.initDQ = function() {
+        $(document)
+            .off('change input paste', '.dq-edit-container input, .dq-edit-container textarea, .dq-edit-container select')
+            .on('change input paste', '.dq-edit-container input, .dq-edit-container textarea, .dq-edit-container select', function() {
+                let key = $(this).closest('.dq-line').attr('dq-key'),
+                    dataElem = $(this).closest('.dq-edit-container').find('>.dq-data-map').first(),
+                    current = JSON.parse(dataElem.text());
+                current[key] = $(this).val();
+                let serialized = JSON.stringify(current);
+                dataElem.text(serialized);
+                $(this).closest('form').find('input[name="data"]').val(serialized);
+                let fullData = {
+                    lines: JSON.parse($(this).closest('.dq-edit-container').find('>.dq-definition').first().text()),
+                    dataMap: current
+                };
+                $(this).closest('form').find('input[name="data"]').val(JSON.stringify(fullData));
+            });
+    };
+    addMCInitializer('dq-edit', initDQ, '.dq-edit-container');
+}).call(window);

+ 2 - 20
resources/views/app/dq-engine/edit.blade.php

@@ -12,31 +12,13 @@ if(!$loadedData || !@$loadedData->lines || !@$loadedData->dataMap) {
 }
 ?>
 <div class="dq-edit-container">
-    <div class="dq-definition"><?= json_encode($loadedData->lines) ?></div>
-    <div class="dq-data-map"><?= json_encode($loadedData->dataMap) ?></div>
+    <div class="dq-definition d-none"><?= json_encode($loadedData->lines) ?></div>
+    <div class="dq-data-map d-none"><?= json_encode($loadedData->dataMap) ?></div>
     @foreach ($template->lines as $line)
         @include('app.dq-engine.line', compact('line'))
     @endforeach
 </div>
-<script>
-    (function() {
-        function init() {
-            $('.dq-edit-container')
-                .off('change input paste', 'input, textarea, select')
-                .on('change input paste', 'input, textarea, select', function() {
-                    let key = $(this).closest('.dq-line').attr('dq-key'),
-                        dataElem = $(this).closest('.dq-edit-container').find('>.dq-data-map').first(),
-                        current = JSON.parse(dataElem.text());
-                    current[key] = $(this).val();
-                    dataElem.text(JSON.stringify(current));
-                });
-        }
-        function populate() {
 
-        }
-        addMCInitializer('dq-edit', init, '.dq-edit-container');
-    }).call(window);
-</script>
 
 
 

+ 1 - 1
resources/views/app/dq-engine/field/date.blade.php

@@ -1 +1 @@
-<input type="date" class="form-control form-control-sm" id="" value="{{ @$loadedData->dataMap->{$line->key} ?: '' }}>
+<input type="date" class="form-control form-control-sm" id="" value="{{ @$loadedData->dataMap->{$line->key} ?: '' }}">

+ 1 - 1
resources/views/app/dq-engine/field/numeric.blade.php

@@ -1 +1 @@
-<input type="number" class="form-control form-control-sm" id="" value="{{ @$loadedData->dataMap->{$line->key} ?: '' }}>
+<input type="number" class="form-control form-control-sm" id="" value="{{ @$loadedData->dataMap->{$line->key} ?: '' }}">

+ 1 - 1
resources/views/app/dq-engine/field/time.blade.php

@@ -1 +1 @@
-<input type="time" class="form-control form-control-sm" id="" value="{{ @$loadedData->dataMap->{$line->key} ?: '' }}>
+<input type="time" class="form-control form-control-sm" id="" value="{{ @$loadedData->dataMap->{$line->key} ?: '' }}">

+ 35 - 1
resources/views/app/patient/note/edit-hpi.blade.php

@@ -73,8 +73,42 @@
     }
     $patient = $note->client;
     $data = $currentReview ? $currentReview : null;
+    $segment = null;
+    if($note->id !== $patient->core_note_id) {
+        $segment = $note->getSegmentByInternalName('intake_problems');
+    }
     ?>
-    @include('app.dq-engine.edit', compact('template', 'note', 'patient', 'point', 'data'))
+    <div id="edit-hpi-{{$point->id}}">
+
+        <div moe relative class="d-block">
+            <form show url="/api/visitPoint/upsertChildReview" class="mcp-theme-1" right>
+                <input type="hidden" name="uid" value="<?= $point->uid ?>">
+                <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
+                @if(!!$segment)
+                    <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+                @endif
+
+                <input type="hidden" name="data">
 
+                @include('app.dq-engine.edit', compact('template', 'note', 'patient', 'point', 'data'))
+
+                <div>
+                    <button submit class="btn btn-sm btn-primary mr-2">Save</button>
+                    <button cancel class="btn btn-sm btn-default border" onclick="closeStagPopup()">Cancel</button>
+                </div>
+            </form>
+        </div>
+
+    </div>
+
+    <script src="/js/dq.js?v={{config('app.asset_version')}}"></script>
+    <script>
+        (function() {
+            function init() {
+                initDQ();
+            }
+            addMCInitializer('edit-hpi-{{$point->id}}', init, '#edit-hpi-{{$point->id}}');
+        }).call(window);
+    </script>
 
 </div>

+ 4 - 3
resources/views/app/patient/problems-center.blade.php

@@ -68,12 +68,13 @@ $ccSegment = $note->getSegmentByInternalName('chief_complaint');
                 </td>
                 <td>
                     <div class="d-flex align-items-start">
-                        <div class="flex-grow-1">
+                        {{--<div class="flex-grow-1">
                             <?php
                             $point = $problem;
                             include resource_path('views/app/patient/segment-templates/_child_review/last-review.php');
                             ?>
-                        </div>
+                        </div>--}}
+                        <div class="flex-grow-1">dg read ui</div>
                         <div>
                             <div class="">
                                 <a class="pl-2 view-review-log"
@@ -89,7 +90,7 @@ $ccSegment = $note->getSegmentByInternalName('chief_complaint');
                                 <a class="pl-2 view-review-log"
                                    native target="_blank"
                                    open-in-stag-popup
-                                   mc-initer="dq-edit"
+                                   mc-initer="edit-hpi-{{$problem->id}}"
                                    popup-style="stag-popup-md"
                                    title="HPI<?= !!@($problem->data->name) ? ' for ' . @($problem->data->name) : '' ?> / <?= $patient->displayName() ?>"
                                    href="/point/edit-hpi/<?= $note->uid ?>/<?= $problem->uid ?>?popupmode=1">

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

@@ -404,6 +404,7 @@
     <script src="/js/stag-suggest.js?v={{config('app.asset_version')}}"></script>
     <script src="/js/option-list.js?v={{config('app.asset_version')}}"></script>
     <script src="/js/show-on-click.js?v={{config('app.asset_version')}}"></script>
+    <script src="/js/dq.js?v={{config('app.asset_version')}}"></script>
     @include('app/pdf/viewer')
     @if(config('app.enableSockets'))
     <script>