<?php
$questionnaire = [
    'ess' => [
        'title' => '',
        'questions' => [
            'do_you_snore' => [
                'title' => 'Do you snore?',
                'options' => [
                    [
                        'value' => 'Yes',
                        'label' => 'Yes'
                    ],
                    [
                        'value' => 'No',
                        'label' => 'No'
                    ]
                    ],
                    'problem' => 'Snoring',
                    'problem_if_value' => 'Yes'
            ],
            'your_snoring_is' => [
                'title' => 'Your Snoring is...?',
                'options' => [
                    [
                        'value' => 'Softer than talking',
                        'label' => 'Softer than talking'
                    ],
                    [
                        'value' => 'As loud as talking',
                        'label' => 'As loud as talking'
                    ],
                    [
                        'value' => 'Louder than talking',
                        'label' => 'Louder than talking'
                    ]
                ]
            ],
            'your_snoring_occurs' => [
                'title' => 'Your snoring occurs:',
                'options' => [
                    [
                        'value' => 'Every night',
                        'label' => 'Every night'
                    ],
                    [
                        'value' => 'A few times a week',
                        'label' => 'A few times a week'
                    ],
                    [
                        'value' => 'Once a week or less',
                        'label' => 'Once a week or less'
                    ]
                ]
            ],
            'do_you_snore_in_every_body_poisition' => [
                'title' => 'Do you snore in every body poisition?',
                'options' => [
                    [
                        'value' => 'Yes',
                        'label' => 'Yes'
                    ],
                    [
                        'value' => 'No',
                        'label' => 'No'
                    ],
                    [
                        'value' => "I don't know",
                        'label' => "I don't know"
                    ]
                ]
            ],
            'your_snoring_is_also_interrupted_by_pauses_choking' => [
                'title' => 'Your snoring is also interrupted by pauses/choking?:',
                'options' => [
                    [
                        'value' => 'Frequent',
                        'label' => 'Frequent'
                    ],
                    [
                        'value' => 'Occasionally',
                        'label' => 'Occasionally'
                    ],
                    [
                        'value' => 'Never',
                        'label' => "Never"
                    ]
                ]
            ],
            'do_you_have_or_ever_had_a_bed_partner' => [
                'title' => 'Do you have, or ever had a bed partner?',
                'options' => [
                    [
                        'value' => 'Yes',
                        'label' => 'Yes'
                    ],
                    [
                        'value' => 'No',
                        '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' => 'Yes',
                        'label' => 'Yes'
                    ],
                    [
                        'value' => 'No',
                        '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' => 'Nearly every day',
                        'label' => 'Nearly every day'
                    ],
                    [
                        'value' => 'Once or twice a week',
                        'label' => 'Once or twice a week'
                    ],
                    [
                        'value' => '3 to 4 times a week',
                        'label' => '3 to 4 times a week'
                    ],
                    [
                        'value' => 'Hardly ever',
                        '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' => 'Nearly every day',
                        'label' => 'Nearly every day'
                    ],
                    [
                        'value' => 'Once or twice a week',
                        'label' => 'Once or twice a week'
                    ],
                    [
                        'value' => '3 to 4 times a week',
                        'label' => '3 to 4 times a week'
                    ],
                    [
                        'value' => 'Hardly ever',
                        'label' => 'Hardly ever'
                    ],

                ]
            ],
            'do_you_frequently_wake_up_with_morning_headaches' => [
                'title' => 'Do you frequently wake up with morning headaches?',
                'options' => [
                    [
                        'value' => 'Yes',
                        'label' => 'Yes'
                    ],
                    [
                        'value' => 'No',
                        'label' => 'No'
                    ],

                ]
            ],
            'do_you_frequently_wake_up_with_morning_headaches' => [
                'title' => 'How would you rate your memory?',
                'options' => [
                    [
                        'value' => 'Excellent',
                        'label' => 'Excellent'
                    ],
                    [
                        'value' => 'Fair',
                        'label' => 'Fair'
                    ],
                    [
                        'value' => 'Good',
                        'label' => 'Good'
                    ],
                    [
                        'value' => 'Poor',
                        'label' => 'Poor'
                    ],

                ]
            ],
            'do_you_frequently_wake_up_with_morning_headaches' => [
                'title' => 'How would you rate your sex life?',
                'options' => [
                    [
                        'value' => 'Excellent',
                        'label' => 'Excellent'
                    ],
                    [
                        'value' => 'Fair',
                        'label' => 'Fair'
                    ],
                    [
                        'value' => 'Good',
                        'label' => 'Good'
                    ],
                    [
                        'value' => 'Poor',
                        'label' => 'Poor'
                    ],
                    [
                        'value' => 'NA',
                        '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' => 'Yes',
                        'label' => 'Yes'
                    ],
                    [
                        'value' => 'No',
                        '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' => 'Yes',
                        'label' => 'Yes'
                    ],
                    [
                        'value' => 'No',
                        'label' => 'No'
                    ],
                    [
                        'value' => 'NA',
                        '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' => 'Yes',
                        'label' => 'Yes'
                    ],
                    [
                        'value' => 'No',
                        'label' => 'No'
                    ],
                    [
                        'value' => 'NA',
                        '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' => 'Yes',
                        'label' => 'Yes'
                    ],
                    [
                        'value' => 'No',
                        'label' => 'No'
                    ],
                    [
                        'value' => 'NA',
                        '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' => 'Yes',
                        'label' => 'Yes'
                    ],
                    [
                        'value' => 'No',
                        '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' => 'Yes',
                        'label' => 'Yes'
                    ],
                    [
                        'value' => 'No',
                        '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' => 'Yes',
                        'label' => 'Yes'
                    ],
                    [
                        'value' => 'No',
                        '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' => 'Nearly every day',
                        'label' => 'Nearly every day'
                    ],
                    [
                        'value' => 'Once or twice a week',
                        'label' => 'Once or twice a week'
                    ],
                    [
                        'value' => '3 to 4 times a week',
                        'label' => '3 to 4 times a week'
                    ],
                    [
                        'value' => 'Hardly ever',
                        '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' => 'Fall asleep right away',
                        'label' => 'Fall asleep right away'
                    ],
                    [
                        'value' => 'Half an hour',
                        'label' => 'Half an hour'
                    ],
                    [
                        'value' => '1 hour',
                        'label' => '1 hour'
                    ],
                    [
                        'value' => '2 hours',
                        'label' => '2 hours'
                    ],
                    [
                        'value' => '3 or more hours',
                        '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' => 'Right away',
                        'label' => 'Right away'
                    ],
                    [
                        'value' => 'Half an hour',
                        'label' => 'Half an hour'
                    ],
                    [
                        'value' => '1 hour',
                        'label' => '1 hour'
                    ],
                    [
                        'value' => '2 or more hours',
                        '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' => 'Yes',
                        'label' => 'Yes'
                    ],
                    [
                        'value' => 'No',
                        'label' => 'No'
                    ],
                ]
            ],
            'in_the_past_month_have_you_been_bothered_by' => [
                'title' => 'In the past month, have you been bothered by:',
                'options' => [
                    [
                        'nested' => true,
                        'key' => 'feeling_down_depressed_or_hopeless',
                        'title' => 'Feeling down, depressed, or hopeless?',
                        'options' => [
                            [
                                'value' => 'Yes',
                                'label' => 'Yes'
                            ],
                            [
                                'value' => 'No',
                                'label' => 'No'
                            ],
                        ]
                    ],
                    [
                        'nested' => true,
                        'key' => 'by_nerves_or_feeling_anxious_or_on_edge',
                        'title' => 'By "nerves" or feeling anxious or on edge?',
                        'options' => [
                            [
                                'value' => 'Yes',
                                'label' => 'Yes'
                            ],
                            [
                                'value' => 'No',
                                'label' => 'No'
                            ],
                        ]
                    ],
                    [
                        'nested' => true,
                        'key' => 'had_an_anxiety_attack_suddenly_feeling_fear_or_panic',
                        'title' => 'Had an anxiety attack (Suddenly feeling fear or panic)?',
                        'options' => [
                            [
                                'value' => 'Yes',
                                'label' => 'Yes'
                            ],
                            [
                                'value' => 'No',
                                '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' => '8 to 10 pm',
                        'label' => '8 to 10 pm'
                    ],
                    [
                        'value' => '10 pm to midnight',
                        'label' => '10 pm to midnight'
                    ],
                    [
                        'value' => 'Midnight to 2 am',
                        'label' => 'Midnight to 2 am'
                    ],
                    [
                        'value' => '2 to 4 am',
                        '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' => '5 to 7 a.m.',
                        'label' => '5 to 7 a.m.'
                    ],
                    [
                        'value' => '7 to 9 a.m.',
                        'label' => '7 to 9 a.m.'
                    ],
                    [
                        'value' => '9 to 11 a.m.',
                        'label' => '9 to 11 a.m.'
                    ],
                    [
                        'value' => '11 a.m to 1 p.m',
                        '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' => '8 to 10 p.m.',
                        'label' => '8 to 10 p.m.'
                    ],
                    [
                        'value' => '10 p.m. to Midnight',
                        'label' => '10 p.m. to Midnight'
                    ],
                    [
                        'value' => 'midnight to 2 a.m.',
                        'label' => 'midnight to 2 a.m.'
                    ],
                    [
                        'value' => '2 to 4 a.m.',
                        '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' => '5 to 7 p.m.',
                        'label' => '5 to 7 p.m.'
                    ],
                    [
                        'value' => '7 to 9 a.m.',
                        'label' => '7 to 9 a.m.'
                    ],
                    [
                        'value' => '9 to 11 a.m.',
                        'label' => '9 to 11 a.m.'
                    ],
                    [
                        'value' => '11 a.m. to 1 p.m.',
                        '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' => '2-4 hours',
                        'label' => '2-4 hours'
                    ],
                    [
                        'value' => '5 hours',
                        'label' => '5 hours'
                    ],
                    [
                        'value' => '6 hours',
                        'label' => '6 hours'
                    ],
                    [
                        'value' => '7 hours',
                        'label' => '7 hours'
                    ],
                    [
                        'value' => '8 hours',
                        'label' => '8 hours'
                    ],
                    [
                        'value' => '9 hours',
                        'label' => '9 hours'
                    ],
                    [
                        'value' => '10 hours',
                        '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' => '2-4 hours',
                        'label' => '2-4 hours'
                    ],
                    [
                        'value' => '5 hours',
                        'label' => '5 hours'
                    ],
                    [
                        'value' => '6 hours',
                        'label' => '6 hours'
                    ],
                    [
                        'value' => '7 hours',
                        'label' => '7 hours'
                    ],
                    [
                        'value' => '8 hours',
                        'label' => '8 hours'
                    ],
                    [
                        'value' => '9 hours',
                        'label' => '9 hours'
                    ],
                    [
                        'value' => '10 hours',
                        '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' => 'Yes',
                        'label' => 'Yes'
                    ],
                    [
                        'value' => 'No',
                        'label' => 'No'
                    ],

                ]
            ],
        ]
    ]
];
?>
<div class="row mb-1">
  <div class="col-md-12">
      <h6 class="my-3"><b><u>Obstructive Sleep Apnea</u></b></h6>
  </div>
    <div class="col-md-12 section bg-light">
        <div>
            @foreach($questionnaire as $qK => $qV)
            <div class=" border-bottom border-info mb-3 pt-2">
                <h6 class="font-weight-bold"><u>{{ $qV['title'] }}</u></h6>
                <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="{{ $questionKey }}" data-name="{{ $questionKey }}" value="{{ @$contentData[$questionKey] }}" @keyup="onInputChange" />
                                <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="radio" name="{{ $option['key'] }}" value="{{ $_option['value'] }}" data-name="{{ $_option['value'] }}" <?= @$contentData[$option['key']] === $_option['value']  ? 'checked' : '' ?> @change="onInputChange" />
                                            <span>{{ $_option['label'] }}</span>
                                        </label>
                                        @endforeach
                                    </div>
                                </div>
                            </div>
                            @else
                            <label class="mb-0 mr-3">
                                <input type="radio" <?= @$questionValue['problem'] ? 'data-problem="'.@$questionValue['problem'].'" data-problem-value="'.@$questionValue['problem_if_value'].'"': '' ?> name="{{ $questionKey }}" data-name="{{ $questionKey }}" value="{{ $option['value'] }}" <?= @$contentData[$questionKey] === $option['value'] ? 'checked' : '' ?> @change="onInputChange" />
                                <span>{{ $option['label'] }}</span>
                            </label>
                            @endif
                            @endforeach
                        </div>
                    </div>
                    @endforeach
                </div>
            </div>
            @endforeach
        </div>
    </div>
</div>
