Sfoglia il codice sorgente

Visit UI - screenings hx

Vijayakrishnan 3 anni fa
parent
commit
9c9fe3f2bc

+ 114 - 1
resources/views/app/patient/segment-templates/history_screenings/edit.blade.php

@@ -1 +1,114 @@
-<h1>Edit for history_screenings</h1>
+<?php
+
+use App\Models\Client;
+use App\Models\Point;
+use App\Models\Note;
+/** @var Client $patient */
+/** @var Note $note */
+
+// try loading afresh - since base section might have gotten dynamically updated
+$point = Point::getGlobalSingletonOfCategory($patient, 'SCREENINGS_HISTORY', true);
+
+$contentData = $parsed = @$point && @$point->data ? $point->data : false;
+
+if(!$contentData) {
+    $contentData = [
+        "count" => 1,
+        "items" => [
+            [
+                "screening" => '',
+                "comments" => '',
+            ]
+        ]
+    ];
+}
+
+?>
+
+<div class="p-3 border-top mt-3 mcp-theme-1">
+    <div visit-moe close-on-save close-on-cancel class="d-block">
+        <form show url="/api/visitPoint/upsertGlobalSingleton" class="mcp-theme-1">
+            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+            <input type="hidden" name="category" value="SCREENINGS_HISTORY">
+            <input type="hidden" name="data">
+
+            <div id="edit-univ_history_screenings-container">
+
+                <div v-for="(item, index) in items" class="note-section-item-row">
+                    <div class="row mb-2">
+                        <div class="col-md-3">
+                            <label class="text-secondary text-sm mb-1 d-block">Screening</label>
+                            <input type="text" class="form-control form-control-sm min-width-unset" v-model="item.screening" required>
+                        </div>
+                        <div class="col-md-2">
+                            <label class="text-secondary text-sm mb-1 d-block">&nbsp;</label>
+                            <a v-if="items.length > 1" href="#" v-on:click.prevent="removeItem(index)"
+                               class="on-hover-opaque text-danger mt-1 d-inline-block">
+                                <i class="fa fa-trash-alt"></i>
+                            </a>
+                        </div>
+                    </div>
+                    <div class="row mb-2">
+                        <div class="col-md-12">
+                        <textarea class="form-control form-control-sm" type="text" v-model="item.comments" :model-index="index" placeholder="Additional details (optional)">
+                        </textarea>
+                        </div>
+                    </div>
+                    <hr class="m-neg-4">
+                </div>
+
+                <div class="form-group my-2">
+                    <button class="btn btn-sm btn-default text-primary border border-primary mr-2"
+                            v-on:click.prevent="addItem()"
+                    >Add Screening</button>
+                </div>
+
+            </div>
+
+            <div>
+                <button submit class="btn btn-sm btn-primary mr-2">Submit</button>
+                <button cancel class="btn btn-sm btn-default border">Cancel</button>
+            </div>
+
+        </form>
+    </div>
+</div>
+<script>
+    (function() {
+
+        window.segmentInitializers.<?= $segment->segmentTemplate->internal_name ?> = function() {
+
+            new Vue({
+                el: '#edit-univ_history_screenings-container',
+                data: {
+                    count: {{ $contentData['count'] }},
+                    items: <?= json_encode($contentData['items']) ?>
+                },
+                watch: {
+                    $data: {
+                        handler: function(val, oldVal) {
+                            let parent = $('#edit-univ_history_screenings-container').closest('form');
+                            parent.find('[name="data"]').val(JSON.stringify(this.$data));
+                        },
+                        deep: true
+                    }
+                },
+                methods: {
+                    addItem: function() {
+                        this.items.push({
+                            screening: '',
+                            comments: '',
+                        });
+                        this.count = this.items.length;
+                    },
+                    removeItem: function(_index) {
+                        this.items.splice(_index, 1);
+                        this.count = this.items.length;
+                    }
+                }
+            });
+
+        };
+
+    }).call(window);
+</script>

+ 37 - 1
resources/views/app/patient/segment-templates/history_screenings/summary.blade.php

@@ -1 +1,37 @@
-<h1>Summary for history_screenings</h1>
+<?php
+
+use App\Models\Client;
+use App\Models\Point;
+use App\Models\Note;
+/** @var Client $patient */
+/** @var Note $note */
+
+$contentData = [
+    "count" => 0,
+    "items" => []
+];
+$isempty = false;
+
+$point = Point::getGlobalSingletonOfCategory($patient, 'SCREENINGS_HISTORY', true);
+
+if ($point && @$point->data) {
+    $contentData = $point->data;
+    for ($i = 0; $i < $contentData['count']; $i++) {
+    ?>
+    <div class="<?= $i > 0 ? 'mt-2' : '' ?>">
+        <div class="pb-1">
+            <b><?= isset($contentData['items'][$i]['screening']) ? $contentData['items'][$i]['screening'] : '--' ?></b>
+            <?php if(isset($contentData['items'][$i]['comments']) && !empty($contentData['items'][$i]['comments'])): ?>
+            <span class="ml-1 text-secondary">(<?= $contentData['items'][$i]['comments'] ?>)</span>
+            <?php endif; ?>
+        </div>
+    </div>
+    <?php
+    }
+}
+else {
+?>
+<div class="text-secondary">Screenings History is unknown/unavailable</div>
+<?php
+}
+?>