Quellcode durchsuchen

Sleep Apnea template

Samson Mutunga vor 2 Jahren
Ursprung
Commit
ef212e5587

+ 50 - 0
resources/views/app/patient/segment-templates/a_p/edit.blade.php

@@ -0,0 +1,50 @@
+<?php
+
+use App\Models\Point;
+
+$category = 'INFORMED_CONSENT';
+$endPoint = 'upsertNoteSingleton';
+
+$point = Point::where('added_in_note_id', $note->id)->where('category', $category)->orderBy('id', 'DESC')->first();
+$contentData = [
+    "informed_consent" => false
+];
+if (!!@$point->data) {
+    $contentData = json_decode($point->data, true);
+}
+?>
+<div visit-moe close-on-save close-on-cancel class="d-block pb-2">
+    <form show url="/api/visitPoint/<?= $endPoint ?>" class="mcp-theme-1">
+        <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+        <input type="hidden" name="category" value="<?= $category ?>">
+        <input type="hidden" name="data" value="{{json_encode($contentData)}}">
+        @if(false)
+        <label class="d-flex align-items-baseline">
+            <div class="mr-2 align-self-stretch" style="padding-top: 2px;">
+                <input type="checkbox" data-name="informed_consent" {{@($contentData["informed_consent"] ? 'checked' : '')}}>
+            </div>
+            <div>
+                <div>This is a {{$note->method}} visit that was performed on {{friendly_date($note->effective_dateest)}}. Verbal consent to participate was obtained.</div>
+                <div>This visit occurred during the Coronavirus (COVID-19) Public Health Emergency.</div>
+                <div>I discussed with the patient the nature of our visit, that:</div>
+                <div class="ml-3">- I would evaluate the patient and recommend diagnostics and treatments based on my assessment.</div>
+                <div class="ml-3">- Our sessions are not being recorded, and that personal health information is protected.</div>
+                <div class="ml-3">- Our team would provide follow-up care in person if/when the patient needs it.</div>
+                <div class="ml-3">- No physical exam was performed due to the remote nature of this evaluation.</div>
+            </div>
+        </label>
+        @endif
+        <div class="pt-2">
+            <button submit class="btn btn-sm btn-primary mr-2"><i class="fa fa-save"></i></button>
+            <div class="d-inline-flex align-self-stretch align-items-center">
+                <span class="autosave-indicator saving text-sm text-secondary">Saving changes &hellip;</span>
+                <span class="autosave-indicator saved text-sm text-secondary">
+                    <i class="fa fa-check"></i>
+                    Saved
+                </span>
+            </div>
+        </div>
+    </form>
+</div>
+
+

+ 30 - 0
resources/views/app/patient/segment-templates/a_p/summary.blade.php

@@ -0,0 +1,30 @@
+<?php
+
+use App\Models\Point;
+
+$category = 'INFORMED_CONSENT';
+$endPoint = 'upsertNoteSingleton';
+
+$point = Point::where('added_in_note_id', $note->id)->where('category', $category)->orderBy('id', 'DESC')->first();
+$contentData = [
+    "informed_consent" => false
+];
+if (!!@$point->data) {
+    $contentData = json_decode($point->data, true);
+}
+?>
+
+<div class="d-flex align-items-baseline">
+    @if(!@($contentData["informed_consent"]))
+        <div class="align-self-stretch min-width-30px text-left">
+            <i class="fa fa-exclamation-triangle"></i>
+        </div>
+    @endif
+    <div class="flex-grow-1">
+    @if(@($contentData["informed_consent"]))
+        
+    @else
+        <div>Please click here to document Tests Performed.</div>
+    @endif
+    </div>
+</div>

+ 419 - 0
resources/views/app/patient/segment-templates/epworth_sleepiness_scale/edit.blade.php

@@ -0,0 +1,419 @@
+<?php
+
+use App\Models\Point;
+
+$category = 'SLEEP_APNEA_INTAKE_EPWORTH_SLEEPINESS_SCALE';
+$endPoint = 'upsertNoteSingleton';
+
+$point = Point::where('added_in_note_id', $note->id)->where('category', $category)->orderBy('id', 'DESC')->first();
+$contentData = (object) [];
+if (!!@$point->data) {
+    $contentData = json_decode($point->data, true);
+}
+
+?>
+<style>
+    .select-esc-option {
+        max-width: 200px;
+    }
+</style>
+
+<!-- Modal -->
+<div class="modal fade" id="addDropdownOptionModal" tabindex="-1" aria-labelledby="addDropdownOptionModalLabel" aria-hidden="true">
+    <div class="modal-dialog" style="margin-top:200px;">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h5 class="modal-title font-weight-bold" id="addDropdownOptionModalLabel"><span></span> - Enter new List Item</h5>
+                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                    <span aria-hidden="true">&times;</span>
+                </button>
+            </div>
+            <div class="modal-body">
+                <form>
+                    <div class="row">
+                        <div class="col-12">
+                            <div class="form-group">
+                                <label>Field Label</label>
+                                <input type="text" class="form-control" name="fieldLabel" />
+                            </div>
+                        </div>
+                    </div>
+                </form>
+            </div>
+            <div class="modal-footer">
+                <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
+                <button type="button" class="btn btn-primary" save-option data-dismiss="modal">Save changes</button>
+            </div>
+        </div>
+    </div>
+</div>
+
+<div visit-moe close-on-save close-on-cancel class="d-block pb-2">
+    <form show url="/api/visitPoint/<?= $endPoint ?>" class="mcp-theme-1">
+        <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+        <input type="hidden" name="category" value="<?= $category ?>">
+        <input type="hidden" name="mainData" value="{{json_encode($contentData)}}">
+        <div id="edit_epworth_sleepiness_scale" class="p-1">
+            <div class="mb-2">
+                <label class="text-sm text-secondary mb-1">How likely are you to doze off or fall asleep in the following situations, in contrast to feeling just tired? This refers to your usual way of life in recent times. Use the following scale (0, 1, 2, and 3) to choose the most appropriate number for each situation.</label>
+                <div class="d-flex align-items-center">
+                    <select v-if="data.dropdownOptions" data-name="Dozing" class="form-control form-control-sm select-esc-option" score-input v-model="data.Dozing">
+                        <option value=""></option>
+                        <option v-for="o in data.dropdownOptions.Dozing" :value="o.value">@{{ o.label }}</option>
+                    </select>
+                    <div>
+                        <span add-dropdown-option data-name="Dozing" data-title="Dozing" class="ml-1 c-pointer" data-toggle="modal" data-target="#addDropdownOptionModal"><i class="fas fa-plus-circle fa-fw text-success"></i></span>
+                    </div>
+
+                </div>
+            </div>
+            <div class="d-flex align-items-center flex-wrap mb-2">
+                <label class="text-sm text-secondary mb-0 mr-2">Sitting and reading</label>
+                <select v-if="data.dropdownOptions" data-name="Sitting" class="form-control form-control-sm select-esc-option" score-input v-model="data.Sitting">
+                    <option value=""></option>
+                    <option v-for="o in data.dropdownOptions.Sitting" :value="o.value">@{{ o.label }}</option>
+                </select>
+                <div>
+                    <span add-dropdown-option data-name="Sitting" data-title="Sitting" class="ml-1 c-pointer" data-toggle="modal" data-target="#addDropdownOptionModal"><i class="fas fa-plus-circle fa-fw text-success"></i></span>
+                </div>
+            </div>
+            <div class="d-flex align-items-center flex-wrap mb-2">
+                <label class="text-sm text-secondary mb-0 mr-2">Watching TV</label>
+                <select v-if="data.dropdownOptions" data-name="Watching" class="form-control form-control-sm select-esc-option" score-input v-model="data.Watching">
+                    <option value=""></option>
+                    <option v-for="o in data.dropdownOptions.Watching" :value="o.value">@{{ o.label }}</option>
+                </select>
+                <div>
+                    <span add-dropdown-option data-name="Watching" data-title="Watching" class="ml-1 c-pointer" data-toggle="modal" data-target="#addDropdownOptionModal"><i class="fas fa-plus-circle fa-fw text-success"></i></span>
+                </div>
+            </div>
+            <div class="d-flex align-items-center flex-wrap mb-2">
+                <label class="text-sm text-secondary mb-0 mr-2">Sitting inactive in a public place (e.g. a theatre or a meeting)</label>
+                <select v-if="data.dropdownOptions" data-name="Sitting_Inactive" class="form-control form-control-sm select-esc-option" score-input v-model="data.Sitting_Inactive">
+                    <option value=""></option>
+                    <option v-for="o in data.dropdownOptions.Sitting_Inactive" :value="o.value">@{{ o.label }}</option>
+                </select>
+                <div>
+                    <span add-dropdown-option data-name="Sitting_Inactive" data-title="Sitting Inactive" class="ml-1 c-pointer" data-toggle="modal" data-target="#addDropdownOptionModal"><i class="fas fa-plus-circle fa-fw text-success"></i></span>
+                </div>
+            </div>
+            <div class="d-flex align-items-center flex-wrap mb-2">
+                <label class="text-sm text-secondary mb-0 mr-2">As a passenger in a car for an hour without a break</label>
+                <select v-if="data.dropdownOptions" data-name="Passenger_Car" class="form-control form-control-sm select-esc-option" score-input v-model="data.Passenger_Car">
+                    <option value=""></option>
+                    <option v-for="o in data.dropdownOptions.Passenger_Car" :value="o.value">@{{ o.label }}</option>
+                </select>
+                <div>
+                    <span add-dropdown-option data-name="Passenger_Car" data-title="Passenger Car" class="ml-1 c-pointer" data-toggle="modal" data-target="#addDropdownOptionModal"><i class="fas fa-plus-circle fa-fw text-success"></i></span>
+                </div>
+            </div>
+            <div class="d-flex align-items-center flex-wrap mb-2">
+                <label class="text-sm text-secondary mb-0 mr-2">Sitting quietly after a lunch without alcohol</label>
+                <select v-if="data.dropdownOptions" data-name="Sitting_Quietly" class="form-control form-control-sm select-esc-option" score-input v-model="data.Sitting_Quietly">
+                    <option value=""></option>
+                    <option v-for="o in data.dropdownOptions.Sitting_Quietly" :value="o.value">@{{ o.label }}</option>
+                </select>
+                <div>
+                    <span add-dropdown-option data-name="Sitting_Quietly" data-title="Sitting Quietly" class="ml-1 c-pointer" data-toggle="modal" data-target="#addDropdownOptionModal"><i class="fas fa-plus-circle fa-fw text-success"></i></span>
+                </div>
+            </div>
+            <div class="d-flex align-items-center flex-wrap mb-2">
+                <label class="text-sm text-secondary mb-0 mr-2">Lying down to rest in the afternoon when circumstances permit</label>
+                <select v-if="data.dropdownOptions" data-name="LyingDown" class="form-control form-control-sm select-esc-option" score-input v-model="data.LyingDown">
+                    <option value=""></option>
+                    <option v-for="o in data.dropdownOptions.LyingDown" :value="o.value">@{{ o.label }}</option>
+                </select>
+                <div>
+                    <span add-dropdown-option data-name="LyingDown" data-title="Lying Down" class="ml-1 c-pointer" data-toggle="modal" data-target="#addDropdownOptionModal"><i class="fas fa-plus-circle fa-fw text-success"></i></span>
+                </div>
+            </div>
+            <div class="d-flex align-items-center flex-wrap mb-2">
+                <label class="text-sm text-secondary mb-0 mr-2">Sitting and talking to someone</label>
+                <select v-if="data.dropdownOptions" data-name="SittingandTalking" class="form-control form-control-sm select-esc-option" score-input v-model="data.SittingandTalking">
+                    <option value=""></option>
+                    <option v-for="o in data.dropdownOptions.SittingandTalking" :value="o.value">@{{ o.label }}</option>
+                </select>
+                <div>
+                    <span add-dropdown-option data-name="SittingandTalking" data-title="Sitting and Talking" class="ml-1 c-pointer" data-toggle="modal" data-target="#addDropdownOptionModal"><i class="fas fa-plus-circle fa-fw text-success"></i></span>
+                </div>
+            </div>
+            <div class="d-flex align-items-center flex-wrap mb-2">
+                <label class="text-sm text-secondary mb-0 mr-2">In a car, while stopped for a few minutes in traffic</label>
+                <select v-if="data.dropdownOptions" data-name="Traffic" class="form-control form-control-sm select-esc-option" score-input v-model="data.Traffic">
+                    <option value=""></option>
+                    <option v-for="o in data.dropdownOptions.Traffic" :value="o.value">@{{ o.label }}</option>
+                </select>
+                <div>
+                    <span add-dropdown-option data-name="Traffic" data-title="Traffic" class="ml-1 c-pointer" data-toggle="modal" data-target="#addDropdownOptionModal"><i class="fas fa-plus-circle fa-fw text-success"></i></span>
+                </div>
+            </div>
+            <div class="my-2">
+                <div class="d-flex align-items-center">
+                    <span class="font-weight-bold">Score:</span>
+                    <div class="border p-2 mx-1" style="width:50px;">
+                        <input type="hidden" name="Score" v-model="data.Score">
+                        <span id="scoreValue">@{{ data.Score }}</span>
+                    </div>
+                    <div class="d-none">
+                        <span class="mr-1 text-primary c-pointer">Calculate</span>
+                        <span class="text-danger c-pointer">Clear</span>
+                    </div>
+                </div>
+            </div>
+
+        </div>
+
+        <div class="pt-2">
+            <button submit class="btn btn-sm btn-primary mr-2"><i class="fa fa-save"></i></button>
+            <div class="d-inline-flex align-self-stretch align-items-center">
+                <span class="autosave-indicator saving text-sm text-secondary">Saving changes &hellip;</span>
+                <span class="autosave-indicator saved text-sm text-secondary">
+                    <i class="fa fa-check"></i>
+                    Saved
+                </span>
+            </div>
+        </div>
+    </form>
+</div>
+<script>
+    (function() {
+        window.segmentInitializers.<?= $segment->segmentTemplate->internal_name ?> = function() {
+            // any JS can come here
+            // will be run on page-load as well as whenever this segment is refreshed
+            new Vue({
+                el: '#edit_epworth_sleepiness_scale',
+                delimiters: ["@{{", "}}"],
+                data: {
+                    addDropdownOptionModal: null,
+                    form: $('#edit_epworth_sleepiness_scale').closest('form'),
+                    data: <?= json_encode($contentData) ?>,
+                    defaultDropdownOptions: {
+                        Dozing: [{
+                                label: 'Never Chance of Doze',
+                                value: 0
+                            },
+                            {
+                                label: 'Slight Chance of Dozing',
+                                value: 1
+                            },
+                            {
+                                label: 'Moderate Chance of Dozing',
+                                value: 2
+                            },
+                            {
+                                label: 'High Chance of Dozing',
+                                value: 3
+                            },
+                        ],
+                        Sitting: [{
+                                label: 0,
+                                value: 0
+                            },
+                            {
+                                label: 1,
+                                value: 1
+                            },
+                            {
+                                label: 2,
+                                value: 2
+                            },
+                            {
+                                label: 3,
+                                value: 3
+                            },
+                        ],
+                        Watching: [{
+                                label: 0,
+                                value: 0
+                            },
+                            {
+                                label: 1,
+                                value: 1
+                            },
+                            {
+                                label: 2,
+                                value: 2
+                            },
+                            {
+                                label: 3,
+                                value: 3
+                            },
+                        ],
+                        Sitting_Inactive: [{
+                                label: 0,
+                                value: 0
+                            },
+                            {
+                                label: 1,
+                                value: 1
+                            },
+                            {
+                                label: 2,
+                                value: 2
+                            },
+                            {
+                                label: 3,
+                                value: 3
+                            },
+                        ],
+                        Passenger_Car: [{
+                                label: 0,
+                                value: 0
+                            },
+                            {
+                                label: 1,
+                                value: 1
+                            },
+                            {
+                                label: 2,
+                                value: 2
+                            },
+                            {
+                                label: 3,
+                                value: 3
+                            },
+                        ],
+                        Sitting_Quietly: [{
+                                label: 0,
+                                value: 0
+                            },
+                            {
+                                label: 1,
+                                value: 1
+                            },
+                            {
+                                label: 2,
+                                value: 2
+                            },
+                            {
+                                label: 3,
+                                value: 3
+                            },
+                        ],
+                        LyingDown: [{
+                                label: 0,
+                                value: 0
+                            },
+                            {
+                                label: 1,
+                                value: 1
+                            },
+                            {
+                                label: 2,
+                                value: 2
+                            },
+                            {
+                                label: 3,
+                                value: 3
+                            },
+                        ],
+                        SittingandTalking: [{
+                                label: 0,
+                                value: 0
+                            },
+                            {
+                                label: 1,
+                                value: 1
+                            },
+                            {
+                                label: 2,
+                                value: 2
+                            },
+                            {
+                                label: 3,
+                                value: 3
+                            },
+                        ],
+                        Traffic: [{
+                                label: 0,
+                                value: 0
+                            },
+                            {
+                                label: 1,
+                                value: 1
+                            },
+                            {
+                                label: 2,
+                                value: 2
+                            },
+                            {
+                                label: 3,
+                                value: 3
+                            },
+                        ]
+                    }
+                },
+                watch: {
+                    $data: {
+                        handler: function(val, oldVal) {
+                            this.saveForm();
+                        },
+                        deep: true
+                    }
+                },
+                methods: {
+                    saveForm: function() {
+                        var self = this;
+                        var url = self.form.attr('url');
+                        var data = self.data;
+                        var dataInput = self.form.find('[name="mainData"]');
+                        dataInput.val(JSON.stringify(data));
+                        var dataArray = self.form.serializeArray();
+                        dataArray.push({name: 'data', value: dataInput.val()});
+                        $.post(url, dataArray, function(response) {}, 'json');
+                    },
+                    calculateScore: function() {
+                        var self = this;
+                        var fields = self.form.find('[score-input]');
+                        var score = 0;
+                        $.each(fields, function(i, field) {
+                            var value = parseInt($(field).val());
+                            value = isNaN(value) ? 0 : value;
+                            score = score + value;
+                        });
+                        self.data.Score = score;
+                        self.saveForm();
+                    },
+                    initOnSelectChange: function() {
+                        var self = this;
+                        self.form.find('select').on('change', function() {
+                            self.calculateScore();
+                        });
+                    },
+                    initOnAddDropdownOption: function() {
+                        var self = this;
+                        self.addDropdownOptionModal = $('#addDropdownOptionModal');
+                        self.form.find('[add-dropdown-option]').off('click');
+                        self.form.find('[add-dropdown-option]').click(function(e) {
+                            var btn = $(e.currentTarget);
+                            var name = btn.data('name');
+                            var title = btn.data('title');
+                            self.addDropdownOptionModal.find('#addDropdownOptionModalLabel').find('span').text(title);
+                            self.addDropdownOptionModal.find('[save-option]').off('click');
+                            self.addDropdownOptionModal.find('[save-option]').click(function() {
+                                var newOption = self.addDropdownOptionModal.find('input[name=fieldLabel]').val();
+                                var options = self.data.dropdownOptions[name];
+                                var value = options.length;
+                                options[value] = {label: newOption, value: value};
+                                self.data.dropdownOptions[name] = options;
+                                Vue.set(self.data, name, value);
+                                self.saveForm();
+                                //TODO: Refresh UI to show new value
+                            });
+
+                        });
+                    },
+                },
+                mounted: function() {
+                    if (!this.data.dropdownOptions) {
+                        this.data.dropdownOptions = this.defaultDropdownOptions;
+                        this.$forceUpdate();
+                    }
+                    this.initOnSelectChange();
+                    this.initOnAddDropdownOption();
+
+                }
+            });
+        };
+    })();
+</script>

+ 111 - 0
resources/views/app/patient/segment-templates/epworth_sleepiness_scale/summary.blade.php

@@ -0,0 +1,111 @@
+<?php
+
+use App\Models\Point;
+
+$category = 'SLEEP_APNEA_INTAKE_EPWORTH_SLEEPINESS_SCALE';
+$endPoint = 'upsertNoteSingleton';
+
+$point = Point::where('added_in_note_id', $note->id)->where('category', $category)->orderBy('id', 'DESC')->first();
+$contentData = null;
+if (!!@$point->data) {
+    $contentData = json_decode($point->data, true);
+}
+
+function getvalueLabel($value, $key, $contentData)
+{
+    $data = $contentData['dropdownOptions'];
+    $array = @$data[$key];
+    if (!$array) return null;
+    foreach ($array as $k => $v) {
+        if ($k == $key) {
+            foreach ($v as $_k => $_v) {
+                if (@$_v['value'] == $value) return @$_v['label'];
+            }
+        }
+    }
+    return null;
+}
+
+?>
+
+<div class="d-flex align-items-baseline">
+    @if(!@$contentData)
+    <div class="align-self-stretch min-width-30px text-left">
+        <i class="fa fa-exclamation-triangle"></i>
+    </div>
+    @endif
+    <div class="flex-grow-1">
+        @if(@$contentData)
+        <div>
+            <div class="p-1">
+                <div class="mb-2">
+                    <label class="text-sm text-secondary mb-1">How likely are you to doze off or fall asleep in the following situations, in contrast to feeling just tired? This refers to your usual way of life in recent times. Use the following scale (0, 1, 2, and 3) to choose the most appropriate number for each situation.</label>
+                    <div>
+                        <span class="font-weight-bold">{{ @$contentData['Dozing'] }}</span>
+                        <span> - {{ getvalueLabel(@$contentData['Dozing'], 'Dozing', $contentData) }}</span>
+                    </div>
+                </div>
+                <div class="d-flex align-items-center flex-wrap mb-2">
+                    <label class="text-sm text-secondary mb-0 mr-2">Sitting and reading</label>
+                    <div>
+                        <span class="font-weight-bold">{{ @$contentData['Sitting'] ?? '--' }}</span>
+                    </div>
+                </div>
+                <div class="d-flex align-items-center flex-wrap mb-2">
+                    <label class="text-sm text-secondary mb-0 mr-2">Watching TV</label>
+                    <div>
+                        <span class="font-weight-bold">{{ @$contentData['Watching'] ?? '--' }}</span>
+                    </div>
+                </div>
+                <div class="d-flex align-items-center flex-wrap mb-2">
+                    <label class="text-sm text-secondary mb-0 mr-2">Sitting inactive in a public place (e.g. a theatre or a meeting)</label>
+                    <div>
+                        <span class="font-weight-bold">{{ @$contentData['Sitting_Inactive'] ?? '--' }}</span>
+                    </div>
+                </div>
+                <div class="d-flex align-items-center flex-wrap mb-2">
+                    <label class="text-sm text-secondary mb-0 mr-2">As a passenger in a car for an hour without a break</label>
+                    <div>
+                        <span class="font-weight-bold">{{ @$contentData['Passenger_Car'] ?? '--' }}</span>
+                    </div>
+                </div>
+                <div class="d-flex align-items-center flex-wrap mb-2">
+                    <label class="text-sm text-secondary mb-0 mr-2">Sitting quietly after a lunch without alcohol</label>
+                    <div>
+                        <span class="font-weight-bold">{{ @$contentData['Sitting_Quietly'] ?? '--' }}</span>
+                    </div>
+                </div>
+                <div class="d-flex align-items-center flex-wrap mb-2">
+                    <label class="text-sm text-secondary mb-0 mr-2">Lying down to rest in the afternoon when circumstances permit</label>
+                    <div>
+                        <span class="font-weight-bold">{{ @$contentData['LyingDown'] ?? '--' }}</span>
+                    </div>
+                </div>
+                <div class="d-flex align-items-center flex-wrap mb-2">
+                    <label class="text-sm text-secondary mb-0 mr-2">Sitting and talking to someone</label>
+                    <div>
+                        <span class="font-weight-bold">{{ @$contentData['SittingandTalking'] ?? '--' }}</span>
+                    </div>
+                </div>
+                <div class="d-flex align-items-center flex-wrap mb-2">
+                    <label class="text-sm text-secondary mb-0 mr-2">In a car, while stopped for a few minutes in traffic</label>
+                    <div>
+                        <span class="font-weight-bold">{{ @$contentData['Traffic'] ?? '--' }}</span>
+                    </div>
+                </div>
+                <div class="my-2">
+                    <div class="d-flex align-items-center">
+                        <span class="font-weight-bold">Score:</span>
+                        <div class="border p-2 mx-1" style="width:50px;">
+                            <span id="scoreValue">{{ @$contentData['Score'] ?? '--' }}</span>
+                        </div>
+                    </div>
+                </div>
+
+            </div>
+        </div>
+        @else
+        <div>Please click here to document Epworth Sleepiness Scale.</div>
+        @endif
+    </div>
+</div>

+ 731 - 0
resources/views/app/patient/segment-templates/obstructive_sleep_apnea/edit.blade.php

@@ -0,0 +1,731 @@
+<?php
+
+use App\Models\Point;
+
+$category = 'SLEEP_APNEA_OBSTRUCTIVR_SLEEP_APNEA';
+$endPoint = 'upsertNoteSingleton';
+
+$point = Point::where('added_in_note_id', $note->id)->where('category', $category)->orderBy('id', 'DESC')->first();
+$contentData = [
+    'SnoreYes' => false
+];
+if (!!@$point->data) {
+    $contentData = json_decode($point->data, true);
+}
+
+$questionnaire = [
+    'ess' => [
+        'title' => 'Epworth Sleepiness Scale',
+        'questions' => [
+            'do_you_snore' => [
+                'title' => 'Do you snore?',
+                'options' => [
+                    [
+                        'value' => 'SnoreYes',
+                        'label' => 'Yes'
+                    ],
+                    [
+                        'value' => 'SnoreNo',
+                        'label' => 'No'
+                    ]
+                ]
+            ],
+            'your_snoring_is' => [
+                'title' => 'Your Snoring is...?',
+                'options' => [
+                    [
+                        'value' => 'SofterSnoring',
+                        'label' => 'Softer than talking'
+                    ],
+                    [
+                        'value' => 'MidSnoring',
+                        'label' => 'As loud as talking'
+                    ],
+                    [
+                        'value' => 'LouderSnoring',
+                        'label' => 'Louder than talking'
+                    ]
+                ]
+            ],
+            'your_snoring_occurs' => [
+                'title' => 'Your snoring occurs:',
+                'options' => [
+                    [
+                        'value' => 'SnoringEveryNight',
+                        'label' => 'Every night'
+                    ],
+                    [
+                        'value' => 'AFewTimesSnoring',
+                        'label' => 'A few times a week'
+                    ],
+                    [
+                        'value' => 'OnceAWeekSnoring',
+                        'label' => 'Once a week or less'
+                    ]
+                ]
+            ],
+            'do_you_snore_in_every_body_poisition' => [
+                'title' => 'Do you snore in every body poisition?',
+                'options' => [
+                    [
+                        'value' => 'yessnoreposition',
+                        'label' => 'Yes'
+                    ],
+                    [
+                        'value' => 'NoSnorePosition',
+                        'label' => 'No'
+                    ],
+                    [
+                        'value' => 'DontKnowSnorePosition',
+                        'label' => "I don't know"
+                    ]
+                ]
+            ],
+            'your_snoring_is_also_interrupted_by_pauses_choking' => [
+                'title' => 'Your snoring is also interrupted by pauses/choking?:',
+                'options' => [
+                    [
+                        'value' => 'FrequentSnoring',
+                        'label' => 'Frequent'
+                    ],
+                    [
+                        'value' => 'OccasionalSnoring',
+                        'label' => 'Occasionally'
+                    ],
+                    [
+                        'value' => 'NeverSnoring',
+                        'label' => "Never"
+                    ]
+                ]
+            ],
+            'do_you_have_or_ever_had_a_bed_partner' => [
+                'title' => 'Do you have, or ever had a bed partner?',
+                'options' => [
+                    [
+                        'value' => 'PartnerYes',
+                        'label' => 'Yes'
+                    ],
+                    [
+                        'value' => 'PartnerNo',
+                        'label' => 'No'
+                    ]
+                ]
+            ],
+            'has_your_bed_partner_ever_said_that_you_have_pauses_in_your_breathing_or_stop_breathing_during_sleep' => [
+                'title' => 'Has your bed partner ever said that you have pauses in your breathing or stop breathing during sleep?:',
+                'options' => [
+                    [
+                        'value' => 'PartnerSaysYes',
+                        'label' => 'Yes'
+                    ],
+                    [
+                        'value' => 'PartnerSaysNo',
+                        'label' => 'No'
+                    ]
+                ]
+            ],
+            'do_you_feel_that_in_some_way_your_sleep_is_not_refreshing_or_restful' => [
+                'title' => 'Do you feel that in some way your sleep is not refreshing or restful?',
+                'options' => [
+                    [
+                        'value' => 'UnrestfulEveryday',
+                        'label' => 'Nearly every day'
+                    ],
+                    [
+                        'value' => 'OnceAWeekUnrestful',
+                        'label' => 'Once or twice a week'
+                    ],
+                    [
+                        'value' => '3to4Unrestful',
+                        'label' => '3 to 4 times a week'
+                    ],
+                    [
+                        'value' => 'HardlyUnrestful',
+                        'label' => 'Hardly ever'
+                    ],
+
+                ]
+            ],
+            'do_you_feel_fatigued_exhausted_tired_or_not_up_to_par' => [
+                'title' => 'Do you feel fatigued, exhausted, tired, or not up to par?',
+                'options' => [
+                    [
+                        'value' => 'ExhaustedEveryDay',
+                        'label' => 'Nearly every day'
+                    ],
+                    [
+                        'value' => 'ExhaustedOnceAWeek',
+                        'label' => 'Once or twice a week'
+                    ],
+                    [
+                        'value' => '3To4TimesExhausted',
+                        'label' => '3 to 4 times a week'
+                    ],
+                    [
+                        'value' => 'HardlyEverExhausted',
+                        'label' => 'Hardly ever'
+                    ],
+
+                ]
+            ],
+            'do_you_frequently_wake_up_with_morning_headaches' => [
+                'title' => 'Do you frequently wake up with morning headaches?',
+                'options' => [
+                    [
+                        'value' => 'HeadacheYes',
+                        'label' => 'Yes'
+                    ],
+                    [
+                        'value' => 'HeadachesNo',
+                        'label' => 'No'
+                    ],
+
+                ]
+            ],
+            'do_you_frequently_wake_up_with_morning_headaches' => [
+                'title' => 'How would you rate your memory?',
+                'options' => [
+                    [
+                        'value' => 'ExMemory',
+                        'label' => 'Excellent'
+                    ],
+                    [
+                        'value' => 'PoorMemory',
+                        'label' => 'Fair'
+                    ],
+                    [
+                        'value' => 'GoodMemory',
+                        'label' => 'Good'
+                    ],
+                    [
+                        'value' => 'HeadacheNo',
+                        'label' => 'Poor'
+                    ],
+
+                ]
+            ],
+            'do_you_frequently_wake_up_with_morning_headaches' => [
+                'title' => 'How would you rate your sex life?',
+                'options' => [
+                    [
+                        'value' => 'ExSexLife',
+                        'label' => 'Excellent'
+                    ],
+                    [
+                        'value' => 'FairSexLife',
+                        'label' => 'Fair'
+                    ],
+                    [
+                        'value' => 'GoodSexLife',
+                        'label' => 'Good'
+                    ],
+                    [
+                        'value' => 'PoorSexLife',
+                        'label' => 'Poor'
+                    ],
+                    [
+                        'value' => 'NASexLife',
+                        'label' => 'NA'
+                    ],
+
+                ]
+            ],
+        ]
+    ],
+    'rls' => [
+        'title' => 'Restless Legs Syndrome',
+        'questions' => [
+            'do_you_experience_creeping_crawling_feeling_and_urge_to_move_your_legs' => [
+                'title' => 'Do you experience creeping/crawling feeling and urge to move your legs?',
+                'options' => [
+                    [
+                        'value' => 'MoveLegsYes',
+                        'label' => 'Yes'
+                    ],
+                    [
+                        'value' => 'MoveLegsNo',
+                        'label' => 'No'
+                    ],
+
+                ]
+            ],
+            'do_these_sensations_and_urge_to_move_your_legs_occur_during_periods_of_rest_or_inactivity_and_are_relieved_by_movement' => [
+                'title' => 'Do these sensations and urge to move your legs occur during periods of rest or inactivity, and are relieved by movement?',
+                'options' => [
+                    [
+                        'value' => 'legsmoveyes',
+                        'label' => 'Yes'
+                    ],
+                    [
+                        'value' => 'legsmoveNo',
+                        'label' => 'No'
+                    ],
+                    [
+                        'value' => 'legsmoveNA',
+                        'label' => 'NA'
+                    ],
+
+                ]
+            ],
+            'do_the_sensations_and_urge_to_move_bother_you_more_in_the_evening_and_at_night_rather_than_during_the_day' => [
+                'title' => 'Do the sensations and urge to move bother you more in the evening and at night, rather than during the day?',
+                'options' => [
+                    [
+                        'value' => 'sensationyes',
+                        'label' => 'Yes'
+                    ],
+                    [
+                        'value' => 'sensationno',
+                        'label' => 'No'
+                    ],
+                    [
+                        'value' => 'sensationna',
+                        'label' => 'NA'
+                    ],
+
+                ]
+            ],
+            'does_your_bed_partner_tell_you_that_you_jerk_your_legs_arms_when_you_are_asleep' => [
+                'title' => 'Does your bed partner tell you that you jerk your legs/arms when you are asleep?',
+                'options' => [
+                    [
+                        'value' => 'jerklegsYes',
+                        'label' => 'Yes'
+                    ],
+                    [
+                        'value' => 'jerklegsno',
+                        'label' => 'No'
+                    ],
+                    [
+                        'value' => 'kerklegsNA',
+                        'label' => 'NA'
+                    ],
+
+                ]
+            ],
+        ]
+    ],
+    'narcolepsy' => [
+        'title' => 'Narcolepsy',
+        'questions' => [
+            'have_you_ever_experience_sudden_body_weakness_brought_on_by_laughter_surprise_or_fear' => [
+                'title' => 'Have you ever experience sudden body weakness brought on by laughter, surprise, or fear?',
+                'options' => [
+                    [
+                        'value' => 'BodyMovementYes',
+                        'label' => 'Yes'
+                    ],
+                    [
+                        'value' => 'BodyMovementNo',
+                        'label' => 'No'
+                    ],
+                ]
+            ],
+            'have_you_ever_experienced_seeing_or_hearing_things_that_was_not_real_when_you_were_falling_asleep_or_had_just_awakened' => [
+                'title' => 'Have you ever experienced seeing or hearing things that was not real when you were falling asleep or had just awakened?',
+                'options' => [
+                    [
+                        'value' => 'hearingthingsyes',
+                        'label' => 'Yes'
+                    ],
+                    [
+                        'value' => 'hearingthingsno',
+                        'label' => 'No'
+                    ],
+                ]
+            ],
+            'have_you_ever_felt_as_if_you_were_awake_but_could_not_move_sleep_paralysis' => [
+                'title' => 'Have you ever felt as if you were awake but could not move (sleep paralysis)?',
+                'options' => [
+                    [
+                        'value' => 'sleepparalysisyes',
+                        'label' => 'Yes'
+                    ],
+                    [
+                        'value' => 'sleepparalysisno',
+                        'label' => 'No'
+                    ],
+                ]
+            ],
+        ]
+    ],
+    'insomnia' => [
+        'title' => 'Insomnia',
+        'questions' => [
+            'do_you_have_trouble_initiating_and_or_maintaining_sleep' => [
+                'title' => 'Do you have trouble initiating and/or maintaining sleep?',
+                'options' => [
+                    [
+                        'value' => 'NearlyEveryDayTrouble',
+                        'label' => 'Nearly every day'
+                    ],
+                    [
+                        'value' => 'OnceorTwice',
+                        'label' => 'Once or twice a week'
+                    ],
+                    [
+                        'value' => '3to4TimesWeeksTrouble',
+                        'label' => '3 to 4 times a week'
+                    ],
+                    [
+                        'value' => 'HardEverTrouble',
+                        'label' => 'Hardly ever'
+                    ],
+                ]
+            ],
+            'how_long_does_it_take_to_fall_asleep_at_night' => [
+                'title' => 'How long does it take to fall asleep at night?',
+                'options' => [
+                    [
+                        'value' => 'sleepinstantly',
+                        'label' => 'Fall asleep right away'
+                    ],
+                    [
+                        'value' => 'SleepInHalfHour',
+                        'label' => 'Half an hour'
+                    ],
+                    [
+                        'value' => 'SleepIn1Hour',
+                        'label' => '1 hour'
+                    ],
+                    [
+                        'value' => 'SleepIn2Hours',
+                        'label' => '2 hours'
+                    ],
+                    [
+                        'value' => 'SleepIn3hours',
+                        'label' => '3 or more hours'
+                    ],
+                ]
+            ],
+            'how_often_do_you_wake_up_in_the_middle_of_the_night' => [
+                'title' => 'How often do you wake up in the middle of the night?',
+                'options' => [
+                    [
+                        'inlineField' => true,
+                        'name' => 'WakeUpTimes',
+                        'label' => 'times'
+                    ],
+                ]
+            ],
+            'how_long_does_it_take_to_fall_back_asleep_when_you_wake_up_in_the_middle_of_the_night' => [
+                'title' => 'How long does it take to fall back asleep when you wake up in the middle of the night?',
+                'options' => [
+                    [
+                        'value' => 'rightawaybacktosleep',
+                        'label' => 'Right away'
+                    ],
+                    [
+                        'value' => 'halfanhours',
+                        'label' => 'Half an hour'
+                    ],
+                    [
+                        'value' => 'halfhourbacaktosleep',
+                        'label' => '1 hour'
+                    ],
+                    [
+                        'value' => '2hoursbacktosleep',
+                        'label' => '2 or more hours'
+                    ],
+                ]
+            ],
+            'do_you_wake_up_very_early_in_the_morning_and_find_it_hard_to_get_back_to_sleep' => [
+                'title' => 'Do you wake up very early in the morning and find it hard to get back to sleep?',
+                'options' => [
+                    [
+                        'value' => 'wakeupearlyyes',
+                        'label' => 'Yes'
+                    ],
+                    [
+                        'value' => 'wakeupearlyno',
+                        'label' => 'No'
+                    ],
+                ]
+            ],
+            'in_the_past_month_have_you_been_bothered_by' => [
+                'title' => 'In the past month, have you been bothered by:',
+                'options' => [
+                    [
+                        'nested' => true,
+                        'title' => 'Feeling down, depressed, or hopeless?',
+                        'options' => [
+                            [
+                                'value' => 'wakeupearlyy',
+                                'label' => 'Yes'
+                            ],
+                            [
+                                'value' => 'wakeupearlyn',
+                                'label' => 'No'
+                            ],
+                        ]
+                    ],
+                    [
+                        'nested' => true,
+                        'title' => 'By "nerves" or feeling anxious or on edge?',
+                        'options' => [
+                            [
+                                'value' => 'wakeupearlyyess',
+                                'label' => 'Yes'
+                            ],
+                            [
+                                'value' => 'wakeupearlynon',
+                                'label' => 'No'
+                            ],
+                        ]
+                    ],
+                    [
+                        'nested' => true,
+                        'title' => 'Had an anxiety attack (Suddenly feeling fear or panic)?',
+                        'options' => [
+                            [
+                                'value' => 'wakeupearlyyesss',
+                                'label' => 'Yes'
+                            ],
+                            [
+                                'value' => 'wakeupearlynonono',
+                                'label' => 'No'
+                            ],
+                        ]
+                    ],
+                ]
+            ],
+        ]
+    ],
+    'sleep_habits' => [
+        'title' => 'Sleep habits',
+        'questions' => [
+            'on_the_weekdays_what_time_do_you_go_to_bed' => [
+                'title' => 'On the weekdays, what time do you go to bed?',
+                'options' => [
+                    [
+                        'value' => 'badtime8to10',
+                        'label' => '8 to 10 pm'
+                    ],
+                    [
+                        'value' => '10pmbedtime',
+                        'label' => '10 pm to midnight'
+                    ],
+                    [
+                        'value' => 'midnightbedtime',
+                        'label' => 'Midnight to 2 am'
+                    ],
+                    [
+                        'value' => '2to4bedtime',
+                        'label' => '2 to 4 am'
+                    ],
+
+                ]
+            ],
+            'on_the_weekdays_what_time_do_you_get_up_in_the_morning' => [
+                'title' => 'On the weekdays, what time do you get up in the morning?',
+                'options' => [
+                    [
+                        'value' => 'weekday5to7',
+                        'label' => '5 to 7 a.m.'
+                    ],
+                    [
+                        'value' => 'weekdays7to9am',
+                        'label' => '7 to 9 a.m.'
+                    ],
+                    [
+                        'value' => 'weekdays9to11',
+                        'label' => '9 to 11 a.m.'
+                    ],
+                    [
+                        'value' => 'weekdays11to1pm',
+                        'label' => '11 a.m to 1 p.m'
+                    ],
+
+                ]
+            ],
+            'on_the_weekends_what_time_do_you_go_to_bed' => [
+                'title' => 'On the weekends, what time do you go to bed?',
+                'options' => [
+                    [
+                        'value' => '8to10pmweekendssleep',
+                        'label' => '8 to 10 p.m.'
+                    ],
+                    [
+                        'value' => '10weekendssleep',
+                        'label' => '10 p.m. to Midnight'
+                    ],
+                    [
+                        'value' => 'midnightto2amsleep',
+                        'label' => 'midnight to 2 a.m.'
+                    ],
+                    [
+                        'value' => '2to4amweekendsleep',
+                        'label' => '2 to 4 a.m.'
+                    ],
+
+                ]
+            ],
+            'on_the_weekends_what_time_do_you_get_up_in_the_morning' => [
+                'title' => 'On the weekends, what time do you get up in the morning?',
+                'options' => [
+                    [
+                        'value' => '8to10pmweekendswakeup',
+                        'label' => '5 to 7 p.m.'
+                    ],
+                    [
+                        'value' => '10weekendswakeup',
+                        'label' => '7 to 9 a.m.'
+                    ],
+                    [
+                        'value' => 'midnightto2amwakeup',
+                        'label' => '9 to 11 a.m.'
+                    ],
+                    [
+                        'value' => '2to4amweekendwakeup',
+                        'label' => '11 a.m. to 1 p.m.'
+                    ],
+
+                ]
+            ],
+            'what_do_you_feel_is_your_ideal_amount_of_sleep_per_day' => [
+                'title' => 'What do you feel is your ideal amount of sleep per day?',
+                'options' => [
+                    [
+                        'value' => 'hourofsleep1',
+                        'label' => '2-4 hours'
+                    ],
+                    [
+                        'value' => 'hourofsleep5',
+                        'label' => '5 hours'
+                    ],
+                    [
+                        'value' => 'hourofsleep6',
+                        'label' => '6 hours'
+                    ],
+                    [
+                        'value' => 'hourofsleep7',
+                        'label' => '7 hours'
+                    ],
+                    [
+                        'value' => 'hourofsleep8',
+                        'label' => '8 hours'
+                    ],
+                    [
+                        'value' => 'hourofsleep9',
+                        'label' => '9 hours'
+                    ],
+                    [
+                        'value' => 'hourofsleep10',
+                        'label' => '10 hours'
+                    ],
+
+                ]
+            ],
+            'estimate_the_average_number_of_hours_of_sleep_you_had_per_day_during_the_last_week' => [
+                'title' => 'Estimate the average number of hours of sleep you had per day during the last week.',
+                'options' => [
+                    [
+                        'value' => 'averagesleep1',
+                        'label' => '2-4 hours'
+                    ],
+                    [
+                        'value' => 'averagesleep5',
+                        'label' => '5 hours'
+                    ],
+                    [
+                        'value' => 'averagesleep6',
+                        'label' => '6 hours'
+                    ],
+                    [
+                        'value' => 'averagesleep7',
+                        'label' => '7 hours'
+                    ],
+                    [
+                        'value' => 'averagesleep8',
+                        'label' => '8 hours'
+                    ],
+                    [
+                        'value' => 'averagesleep9',
+                        'label' => '9 hours'
+                    ],
+                    [
+                        'value' => 'averagesleep10',
+                        'label' => '10 hours'
+                    ],
+
+                ]
+            ],
+            'are_you_a_shift_worker' => [
+                'title' => 'Estimate the average number of hours of sleep you had per day during the last week.Are you a shift worker?',
+                'options' => [
+                    [
+                        'value' => 'shiftworkeryes',
+                        'label' => 'Yes'
+                    ],
+                    [
+                        'value' => 'shiftworkerno',
+                        'label' => 'No'
+                    ],
+
+                ]
+            ],
+        ]
+    ]
+];
+?>
+<div visit-moe close-on-save close-on-cancel class="d-block pb-2">
+    <form show url="/api/visitPoint/<?= $endPoint ?>" class="mcp-theme-1">
+        <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+        <input type="hidden" name="category" value="<?= $category ?>">
+        <input type="hidden" name="data" value="{{json_encode($contentData)}}">
+        <div class="p-2">
+            @foreach($questionnaire as $qK => $qV)
+            <div class="bg-light border mb-3 p-2">
+                <h3 class="font-weight-bold" style="font-size:16px;">{{ $qV['title'] }}</h3>
+                <div class="pl-2">
+                    @foreach($qV['questions'] as $questionKey => $questionValue)
+                    <div class="form-group">
+                        <label class="font-weight-bold">{{ $questionValue['title'] }}</label>
+                        <div class="d-flex align-items-start flex-wrap pl-2">
+                            @foreach($questionValue['options'] as $option)
+                            @if(@$option['inlineField'])
+                            <div class="d-flex align-items-center flex-erap mb-0 mr-3">
+                                <input type="text" class="form-control mr-2" name="{{ $option['name'] }}" data-name="{{ $option['name'] }}" value="{{ @$contentData[$option['name']] }}" />
+                                <span>{{ $option['label'] }}</span>
+                            </div>
+                            @elseif(@$option['nested'])
+                            <div class="w-100">
+                                <div class="d-flex flex-wrap align-items-start">
+                                    <label class="font-weight-bold">{{ $option['title'] }}</label>
+                                    <div class="ml-2">
+                                        @foreach($option['options'] as $_option)
+                                        <label class="mb-0 mr-3">
+                                            <input type="checkbox" name="{{ $_option['value'] }}" data-name="{{ $_option['value'] }}" <?= @$contentData[$_option['value']] === true ? 'checked':'' ?> />
+                                            <span>{{ $_option['label'] }}</span>
+                                        </label>
+                                        @endforeach
+                                    </div>
+                                </div>
+                            </div>
+                            @else
+                            <label class="mb-0 mr-3">
+                                <input type="checkbox" name="{{ $option['value'] }}" data-name="{{ $option['value'] }}" <?= @$contentData[$option['value']] === true ? 'checked':'' ?> />
+                                <span>{{ $option['label'] }}</span>
+                            </label>
+                            @endif
+                            @endforeach
+                        </div>
+                    </div>
+                    @endforeach
+                </div>
+            </div>
+            @endforeach
+
+            <div class="pt-2">
+                <button submit class="btn btn-sm btn-primary mr-2"><i class="fa fa-save"></i></button>
+                <div class="d-inline-flex align-self-stretch align-items-center">
+                    <span class="autosave-indicator saving text-sm text-secondary">Saving changes &hellip;</span>
+                    <span class="autosave-indicator saved text-sm text-secondary">
+                        <i class="fa fa-check"></i>
+                        Saved
+                    </span>
+                </div>
+            </div>
+        </div>
+    </form>
+</div>

+ 742 - 0
resources/views/app/patient/segment-templates/obstructive_sleep_apnea/summary.blade.php

@@ -0,0 +1,742 @@
+<?php
+
+use App\Models\Point;
+
+$category = 'SLEEP_APNEA_OBSTRUCTIVR_SLEEP_APNEA';
+$endPoint = 'upsertNoteSingleton';
+
+$point = Point::where('added_in_note_id', $note->id)->where('category', $category)->orderBy('id', 'DESC')->first();
+$contentData = null;
+if (!!@$point->data) {
+    $contentData = json_decode($point->data, true);
+}
+$questionnaire = [
+    'ess' => [
+        'title' => 'Epworth Sleepiness Scale',
+        'questions' => [
+            'do_you_snore' => [
+                'title' => 'Do you snore?',
+                'options' => [
+                    [
+                        'value' => 'SnoreYes',
+                        'label' => 'Yes'
+                    ],
+                    [
+                        'value' => 'SnoreNo',
+                        'label' => 'No'
+                    ]
+                ]
+            ],
+            'your_snoring_is' => [
+                'title' => 'Your Snoring is...?',
+                'options' => [
+                    [
+                        'value' => 'SofterSnoring',
+                        'label' => 'Softer than talking'
+                    ],
+                    [
+                        'value' => 'MidSnoring',
+                        'label' => 'As loud as talking'
+                    ],
+                    [
+                        'value' => 'LouderSnoring',
+                        'label' => 'Louder than talking'
+                    ]
+                ]
+            ],
+            'your_snoring_occurs' => [
+                'title' => 'Your snoring occurs:',
+                'options' => [
+                    [
+                        'value' => 'SnoringEveryNight',
+                        'label' => 'Every night'
+                    ],
+                    [
+                        'value' => 'AFewTimesSnoring',
+                        'label' => 'A few times a week'
+                    ],
+                    [
+                        'value' => 'OnceAWeekSnoring',
+                        'label' => 'Once a week or less'
+                    ]
+                ]
+            ],
+            'do_you_snore_in_every_body_poisition' => [
+                'title' => 'Do you snore in every body poisition?',
+                'options' => [
+                    [
+                        'value' => 'yessnoreposition',
+                        'label' => 'Yes'
+                    ],
+                    [
+                        'value' => 'NoSnorePosition',
+                        'label' => 'No'
+                    ],
+                    [
+                        'value' => 'DontKnowSnorePosition',
+                        'label' => "I don't know"
+                    ]
+                ]
+            ],
+            'your_snoring_is_also_interrupted_by_pauses_choking' => [
+                'title' => 'Your snoring is also interrupted by pauses/choking?:',
+                'options' => [
+                    [
+                        'value' => 'FrequentSnoring',
+                        'label' => 'Frequent'
+                    ],
+                    [
+                        'value' => 'OccasionalSnoring',
+                        'label' => 'Occasionally'
+                    ],
+                    [
+                        'value' => 'NeverSnoring',
+                        'label' => "Never"
+                    ]
+                ]
+            ],
+            'do_you_have_or_ever_had_a_bed_partner' => [
+                'title' => 'Do you have, or ever had a bed partner?',
+                'options' => [
+                    [
+                        'value' => 'PartnerYes',
+                        'label' => 'Yes'
+                    ],
+                    [
+                        'value' => 'PartnerNo',
+                        'label' => 'No'
+                    ]
+                ]
+            ],
+            'has_your_bed_partner_ever_said_that_you_have_pauses_in_your_breathing_or_stop_breathing_during_sleep' => [
+                'title' => 'Has your bed partner ever said that you have pauses in your breathing or stop breathing during sleep?:',
+                'options' => [
+                    [
+                        'value' => 'PartnerSaysYes',
+                        'label' => 'Yes'
+                    ],
+                    [
+                        'value' => 'PartnerSaysNo',
+                        'label' => 'No'
+                    ]
+                ]
+            ],
+            'do_you_feel_that_in_some_way_your_sleep_is_not_refreshing_or_restful' => [
+                'title' => 'Do you feel that in some way your sleep is not refreshing or restful?',
+                'options' => [
+                    [
+                        'value' => 'UnrestfulEveryday',
+                        'label' => 'Nearly every day'
+                    ],
+                    [
+                        'value' => 'OnceAWeekUnrestful',
+                        'label' => 'Once or twice a week'
+                    ],
+                    [
+                        'value' => '3to4Unrestful',
+                        'label' => '3 to 4 times a week'
+                    ],
+                    [
+                        'value' => 'HardlyUnrestful',
+                        'label' => 'Hardly ever'
+                    ],
+
+                ]
+            ],
+            'do_you_feel_fatigued_exhausted_tired_or_not_up_to_par' => [
+                'title' => 'Do you feel fatigued, exhausted, tired, or not up to par?',
+                'options' => [
+                    [
+                        'value' => 'ExhaustedEveryDay',
+                        'label' => 'Nearly every day'
+                    ],
+                    [
+                        'value' => 'ExhaustedOnceAWeek',
+                        'label' => 'Once or twice a week'
+                    ],
+                    [
+                        'value' => '3To4TimesExhausted',
+                        'label' => '3 to 4 times a week'
+                    ],
+                    [
+                        'value' => 'HardlyEverExhausted',
+                        'label' => 'Hardly ever'
+                    ],
+
+                ]
+            ],
+            'do_you_frequently_wake_up_with_morning_headaches' => [
+                'title' => 'Do you frequently wake up with morning headaches?',
+                'options' => [
+                    [
+                        'value' => 'HeadacheYes',
+                        'label' => 'Yes'
+                    ],
+                    [
+                        'value' => 'HeadachesNo',
+                        'label' => 'No'
+                    ],
+
+                ]
+            ],
+            'do_you_frequently_wake_up_with_morning_headaches' => [
+                'title' => 'How would you rate your memory?',
+                'options' => [
+                    [
+                        'value' => 'ExMemory',
+                        'label' => 'Excellent'
+                    ],
+                    [
+                        'value' => 'PoorMemory',
+                        'label' => 'Fair'
+                    ],
+                    [
+                        'value' => 'GoodMemory',
+                        'label' => 'Good'
+                    ],
+                    [
+                        'value' => 'HeadacheNo',
+                        'label' => 'Poor'
+                    ],
+
+                ]
+            ],
+            'do_you_frequently_wake_up_with_morning_headaches' => [
+                'title' => 'How would you rate your sex life?',
+                'options' => [
+                    [
+                        'value' => 'ExSexLife',
+                        'label' => 'Excellent'
+                    ],
+                    [
+                        'value' => 'FairSexLife',
+                        'label' => 'Fair'
+                    ],
+                    [
+                        'value' => 'GoodSexLife',
+                        'label' => 'Good'
+                    ],
+                    [
+                        'value' => 'PoorSexLife',
+                        'label' => 'Poor'
+                    ],
+                    [
+                        'value' => 'NASexLife',
+                        'label' => 'NA'
+                    ],
+
+                ]
+            ],
+        ]
+    ],
+    'rls' => [
+        'title' => 'Restless Legs Syndrome',
+        'questions' => [
+            'do_you_experience_creeping_crawling_feeling_and_urge_to_move_your_legs' => [
+                'title' => 'Do you experience creeping/crawling feeling and urge to move your legs?',
+                'options' => [
+                    [
+                        'value' => 'MoveLegsYes',
+                        'label' => 'Yes'
+                    ],
+                    [
+                        'value' => 'MoveLegsNo',
+                        'label' => 'No'
+                    ],
+
+                ]
+            ],
+            'do_these_sensations_and_urge_to_move_your_legs_occur_during_periods_of_rest_or_inactivity_and_are_relieved_by_movement' => [
+                'title' => 'Do these sensations and urge to move your legs occur during periods of rest or inactivity, and are relieved by movement?',
+                'options' => [
+                    [
+                        'value' => 'legsmoveyes',
+                        'label' => 'Yes'
+                    ],
+                    [
+                        'value' => 'legsmoveNo',
+                        'label' => 'No'
+                    ],
+                    [
+                        'value' => 'legsmoveNA',
+                        'label' => 'NA'
+                    ],
+
+                ]
+            ],
+            'do_the_sensations_and_urge_to_move_bother_you_more_in_the_evening_and_at_night_rather_than_during_the_day' => [
+                'title' => 'Do the sensations and urge to move bother you more in the evening and at night, rather than during the day?',
+                'options' => [
+                    [
+                        'value' => 'sensationyes',
+                        'label' => 'Yes'
+                    ],
+                    [
+                        'value' => 'sensationno',
+                        'label' => 'No'
+                    ],
+                    [
+                        'value' => 'sensationna',
+                        'label' => 'NA'
+                    ],
+
+                ]
+            ],
+            'does_your_bed_partner_tell_you_that_you_jerk_your_legs_arms_when_you_are_asleep' => [
+                'title' => 'Does your bed partner tell you that you jerk your legs/arms when you are asleep?',
+                'options' => [
+                    [
+                        'value' => 'jerklegsYes',
+                        'label' => 'Yes'
+                    ],
+                    [
+                        'value' => 'jerklegsno',
+                        'label' => 'No'
+                    ],
+                    [
+                        'value' => 'kerklegsNA',
+                        'label' => 'NA'
+                    ],
+
+                ]
+            ],
+        ]
+    ],
+    'narcolepsy' => [
+        'title' => 'Narcolepsy',
+        'questions' => [
+            'have_you_ever_experience_sudden_body_weakness_brought_on_by_laughter_surprise_or_fear' => [
+                'title' => 'Have you ever experience sudden body weakness brought on by laughter, surprise, or fear?',
+                'options' => [
+                    [
+                        'value' => 'BodyMovementYes',
+                        'label' => 'Yes'
+                    ],
+                    [
+                        'value' => 'BodyMovementNo',
+                        'label' => 'No'
+                    ],
+                ]
+            ],
+            'have_you_ever_experienced_seeing_or_hearing_things_that_was_not_real_when_you_were_falling_asleep_or_had_just_awakened' => [
+                'title' => 'Have you ever experienced seeing or hearing things that was not real when you were falling asleep or had just awakened?',
+                'options' => [
+                    [
+                        'value' => 'hearingthingsyes',
+                        'label' => 'Yes'
+                    ],
+                    [
+                        'value' => 'hearingthingsno',
+                        'label' => 'No'
+                    ],
+                ]
+            ],
+            'have_you_ever_felt_as_if_you_were_awake_but_could_not_move_sleep_paralysis' => [
+                'title' => 'Have you ever felt as if you were awake but could not move (sleep paralysis)?',
+                'options' => [
+                    [
+                        'value' => 'sleepparalysisyes',
+                        'label' => 'Yes'
+                    ],
+                    [
+                        'value' => 'sleepparalysisno',
+                        'label' => 'No'
+                    ],
+                ]
+            ],
+        ]
+    ],
+    'insomnia' => [
+        'title' => 'Insomnia',
+        'questions' => [
+            'do_you_have_trouble_initiating_and_or_maintaining_sleep' => [
+                'title' => 'Do you have trouble initiating and/or maintaining sleep?',
+                'options' => [
+                    [
+                        'value' => 'NearlyEveryDayTrouble',
+                        'label' => 'Nearly every day'
+                    ],
+                    [
+                        'value' => 'OnceorTwice',
+                        'label' => 'Once or twice a week'
+                    ],
+                    [
+                        'value' => '3to4TimesWeeksTrouble',
+                        'label' => '3 to 4 times a week'
+                    ],
+                    [
+                        'value' => 'HardEverTrouble',
+                        'label' => 'Hardly ever'
+                    ],
+                ]
+            ],
+            'how_long_does_it_take_to_fall_asleep_at_night' => [
+                'title' => 'How long does it take to fall asleep at night?',
+                'options' => [
+                    [
+                        'value' => 'sleepinstantly',
+                        'label' => 'Fall asleep right away'
+                    ],
+                    [
+                        'value' => 'SleepInHalfHour',
+                        'label' => 'Half an hour'
+                    ],
+                    [
+                        'value' => 'SleepIn1Hour',
+                        'label' => '1 hour'
+                    ],
+                    [
+                        'value' => 'SleepIn2Hours',
+                        'label' => '2 hours'
+                    ],
+                    [
+                        'value' => 'SleepIn3hours',
+                        'label' => '3 or more hours'
+                    ],
+                ]
+            ],
+            'how_often_do_you_wake_up_in_the_middle_of_the_night' => [
+                'title' => 'How often do you wake up in the middle of the night?',
+                'options' => [
+                    [
+                        'inlineField' => true,
+                        'name' => 'WakeUpTimes',
+                        'label' => 'times'
+                    ],
+                ]
+            ],
+            'how_long_does_it_take_to_fall_back_asleep_when_you_wake_up_in_the_middle_of_the_night' => [
+                'title' => 'How long does it take to fall back asleep when you wake up in the middle of the night?',
+                'options' => [
+                    [
+                        'value' => 'rightawaybacktosleep',
+                        'label' => 'Right away'
+                    ],
+                    [
+                        'value' => 'halfanhours',
+                        'label' => 'Half an hour'
+                    ],
+                    [
+                        'value' => 'halfhourbacaktosleep',
+                        'label' => '1 hour'
+                    ],
+                    [
+                        'value' => '2hoursbacktosleep',
+                        'label' => '2 or more hours'
+                    ],
+                ]
+            ],
+            'do_you_wake_up_very_early_in_the_morning_and_find_it_hard_to_get_back_to_sleep' => [
+                'title' => 'Do you wake up very early in the morning and find it hard to get back to sleep?',
+                'options' => [
+                    [
+                        'value' => 'wakeupearlyyes',
+                        'label' => 'Yes'
+                    ],
+                    [
+                        'value' => 'wakeupearlyno',
+                        'label' => 'No'
+                    ],
+                ]
+            ],
+            'in_the_past_month_have_you_been_bothered_by' => [
+                'title' => 'In the past month, have you been bothered by:',
+                'block' => true,
+                'options' => [
+                    [
+                        'nested' => true,
+                        'title' => 'Feeling down, depressed, or hopeless?',
+                        'options' => [
+                            [
+                                'value' => 'wakeupearlyy',
+                                'label' => 'Yes'
+                            ],
+                            [
+                                'value' => 'wakeupearlyn',
+                                'label' => 'No'
+                            ],
+                        ]
+                    ],
+                    [
+                        'nested' => true,
+                        'title' => 'By "nerves" or feeling anxious or on edge?',
+                        'options' => [
+                            [
+                                'value' => 'wakeupearlyyess',
+                                'label' => 'Yes'
+                            ],
+                            [
+                                'value' => 'wakeupearlynon',
+                                'label' => 'No'
+                            ],
+                        ]
+                    ],
+                    [
+                        'nested' => true,
+                        'title' => 'Had an anxiety attack (Suddenly feeling fear or panic)?',
+                        'options' => [
+                            [
+                                'value' => 'wakeupearlyyesss',
+                                'label' => 'Yes'
+                            ],
+                            [
+                                'value' => 'wakeupearlynonono',
+                                'label' => 'No'
+                            ],
+                        ]
+                    ],
+                ]
+            ],
+        ]
+    ],
+    'sleep_habits' => [
+        'title' => 'Sleep habits',
+        'questions' => [
+            'on_the_weekdays_what_time_do_you_go_to_bed' => [
+                'title' => 'On the weekdays, what time do you go to bed?',
+                'options' => [
+                    [
+                        'value' => 'badtime8to10',
+                        'label' => '8 to 10 pm'
+                    ],
+                    [
+                        'value' => '10pmbedtime',
+                        'label' => '10 pm to midnight'
+                    ],
+                    [
+                        'value' => 'midnightbedtime',
+                        'label' => 'Midnight to 2 am'
+                    ],
+                    [
+                        'value' => '2to4bedtime',
+                        'label' => '2 to 4 am'
+                    ],
+
+                ]
+            ],
+            'on_the_weekdays_what_time_do_you_get_up_in_the_morning' => [
+                'title' => 'On the weekdays, what time do you get up in the morning?',
+                'options' => [
+                    [
+                        'value' => 'weekday5to7',
+                        'label' => '5 to 7 a.m.'
+                    ],
+                    [
+                        'value' => 'weekdays7to9am',
+                        'label' => '7 to 9 a.m.'
+                    ],
+                    [
+                        'value' => 'weekdays9to11',
+                        'label' => '9 to 11 a.m.'
+                    ],
+                    [
+                        'value' => 'weekdays11to1pm',
+                        'label' => '11 a.m to 1 p.m'
+                    ],
+
+                ]
+            ],
+            'on_the_weekends_what_time_do_you_go_to_bed' => [
+                'title' => 'On the weekends, what time do you go to bed?',
+                'options' => [
+                    [
+                        'value' => '8to10pmweekendssleep',
+                        'label' => '8 to 10 p.m.'
+                    ],
+                    [
+                        'value' => '10weekendssleep',
+                        'label' => '10 p.m. to Midnight'
+                    ],
+                    [
+                        'value' => 'midnightto2amsleep',
+                        'label' => 'midnight to 2 a.m.'
+                    ],
+                    [
+                        'value' => '2to4amweekendsleep',
+                        'label' => '2 to 4 a.m.'
+                    ],
+
+                ]
+            ],
+            'on_the_weekends_what_time_do_you_get_up_in_the_morning' => [
+                'title' => 'On the weekends, what time do you get up in the morning?',
+                'options' => [
+                    [
+                        'value' => '8to10pmweekendswakeup',
+                        'label' => '5 to 7 p.m.'
+                    ],
+                    [
+                        'value' => '10weekendswakeup',
+                        'label' => '7 to 9 a.m.'
+                    ],
+                    [
+                        'value' => 'midnightto2amwakeup',
+                        'label' => '9 to 11 a.m.'
+                    ],
+                    [
+                        'value' => '2to4amweekendwakeup',
+                        'label' => '11 a.m. to 1 p.m.'
+                    ],
+
+                ]
+            ],
+            'what_do_you_feel_is_your_ideal_amount_of_sleep_per_day' => [
+                'title' => 'What do you feel is your ideal amount of sleep per day?',
+                'options' => [
+                    [
+                        'value' => 'hourofsleep1',
+                        'label' => '2-4 hours'
+                    ],
+                    [
+                        'value' => 'hourofsleep5',
+                        'label' => '5 hours'
+                    ],
+                    [
+                        'value' => 'hourofsleep6',
+                        'label' => '6 hours'
+                    ],
+                    [
+                        'value' => 'hourofsleep7',
+                        'label' => '7 hours'
+                    ],
+                    [
+                        'value' => 'hourofsleep8',
+                        'label' => '8 hours'
+                    ],
+                    [
+                        'value' => 'hourofsleep9',
+                        'label' => '9 hours'
+                    ],
+                    [
+                        'value' => 'hourofsleep10',
+                        'label' => '10 hours'
+                    ],
+
+                ]
+            ],
+            'estimate_the_average_number_of_hours_of_sleep_you_had_per_day_during_the_last_week' => [
+                'title' => 'Estimate the average number of hours of sleep you had per day during the last week.',
+                'options' => [
+                    [
+                        'value' => 'averagesleep1',
+                        'label' => '2-4 hours'
+                    ],
+                    [
+                        'value' => 'averagesleep5',
+                        'label' => '5 hours'
+                    ],
+                    [
+                        'value' => 'averagesleep6',
+                        'label' => '6 hours'
+                    ],
+                    [
+                        'value' => 'averagesleep7',
+                        'label' => '7 hours'
+                    ],
+                    [
+                        'value' => 'averagesleep8',
+                        'label' => '8 hours'
+                    ],
+                    [
+                        'value' => 'averagesleep9',
+                        'label' => '9 hours'
+                    ],
+                    [
+                        'value' => 'averagesleep10',
+                        'label' => '10 hours'
+                    ],
+
+                ]
+            ],
+            'are_you_a_shift_worker' => [
+                'title' => 'Estimate the average number of hours of sleep you had per day during the last week.Are you a shift worker?',
+                'options' => [
+                    [
+                        'value' => 'shiftworkeryes',
+                        'label' => 'Yes'
+                    ],
+                    [
+                        'value' => 'shiftworkerno',
+                        'label' => 'No'
+                    ],
+
+                ]
+            ],
+        ]
+    ]
+];
+?>
+<style>
+    .text-underline {
+        text-decoration: underline;
+    }
+</style>
+<div class="d-flex align-items-baseline">
+    @if(!@$contentData)
+    <div class="align-self-stretch min-width-30px text-left">
+        <i class="fa fa-exclamation-triangle"></i>
+    </div>
+    @endif
+    <div class="flex-grow-1">
+        @if(@$contentData)
+        <div>
+            @foreach($questionnaire as $qK => $qV)
+            <div class="bg-light border mb-3 p-2">
+                <h3 class="font-weight-bold" style="font-size:16px;">{{ $qV['title'] }}</h3>
+                <div class="pl-2">
+                    @foreach($qV['questions'] as $questionKey => $questionValue)
+                    <div class="form-group mb-0 <?= @$questionValue['block'] ? '' : 'd-flex align-items-start flex-wrap' ?>">
+                        <label class="font-weight-bold">{{ $questionValue['title'] }}</label>
+                        <div class="d-flex align-items-start flex-wrap pl-2">
+                            @foreach($questionValue['options'] as $option)
+                            @if(@$option['inlineField'])
+                            <div>
+                                @if(@$contentData[$option['name']])
+                                <div class="d-flex align-items-center flex-erap mb-0 mr-3">
+                                    <span class="text-underline mr-3">{{ @$contentData[$option['name']] }}</span>
+                                    <span>{{ $option['label'] }}</span>
+                                </div>
+                                @endif
+                            </div>
+                            
+                            @elseif(@$option['nested'])
+                            <div class="w-100">
+                                <div class="d-flex flex-wrap align-items-start">
+                                    <label class="font-weight-bold">{{ $option['title'] }}</label>
+                                    <div class="d-flex align-items-start ml-2">
+                                        @foreach($option['options'] as $_option)
+                                        <div>
+                                            @if(@$contentData[$_option['value']] === true)
+                                            <label class="mb-0 mr-3">
+                                                <span class="text-underline">{{ $_option['label'] }}</span>
+                                            </label>
+                                            @endif
+                                        </div>
+                                        
+                                        @endforeach
+                                    </div>
+                                </div>
+                            </div>
+                            @else
+                            <div>
+                                @if(@$contentData[$option['value']] === true)
+                                    <label class="mb-0 mr-3">
+                                        <span class="text-underline">{{ $option['label'] }}</span>
+                                    </label> 
+                                @endif
+                            </div>
+                            
+                            @endif
+                            @endforeach
+                        </div>
+                    </div>
+                    @endforeach
+                </div>
+            </div>
+            @endforeach
+        </div>
+        @else
+        <div>Please click here to document Obstructive Sleep Apnea.</div>
+        @endif
+    </div>
+</div>