<?php
use App\Models\Client;
use App\Models\Note;
use App\Models\Point;
/** @var Client $patient */
/** @var Note $note */
/** @var Point $point */

// replace content data
$contentData = [
    "uncontrollable_things_life" => "",
    "lack_confidence" => "",
    "things_not_going_well" => "",
    "let_things_go_hard" => "",
    "cope_stress" => [],
    "extreme_stress_learn_from_experience" => "",
    "extreme_stress_take_action" => "",
    "extreme_stress_prioritize_importance" => "",
    "extreme_stress_opportunity_to_grow" => "",
    "extreme_stress_set_goals" => "",
    "extreme_stress_ways_around_problem" => "",
    "extreme_stress_motivated_to_pursue_goals" => "",
    "extreme_stress_know_can_get_through_it" => "",
    "body_connect_set_goals" => "",
    "body_connect_feelings_affect" => "",
    "body_connect_emotion_experience" => "",
    "body_connect_tension_aware" => "",
    "body_connect_angry" => "",
    "body_connect_stress" => "",
    "body_connect_emotion_react" => "",
    "depression_little_interest" => "",
    "depression_feeling_depressed" => "",
    "depression_trouble_sleeping" => "",
    "depression_feeling_tired" => "",
    "depression_poor_appetite" => "",
    "depression_feeling_bad_self" => "",
    "depression_trouble_concentrating" => "",
    "depression_moving_slow" => "",
    "depression_hurting_self" => "",
    "anxiety_feeling_nervous" => "",
    "anxiety_uncontrollable_worry" => "",
    "anxiety_worry_different_things" => "",
    "anxiety_trouble_relaxing" => "",
    "anxiety_restless" => "",
    "anxiety_easily_annoyed" => ""
];

$point = Point::getGlobalSingletonOfCategory($patient, 'LIFESTYLE_STRESS', true);

if ($point && @$point->data) {
    $contentData = $point->data;
}
?>
<div class="p-3 mcp-theme-1">
    <div visit-moe close-on-save close-on-cancel class="d-block">
        <form show url="/api/visitPoint/upsertGlobalSingleton" class="mcp-theme-1">
            <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
            <input type="hidden" name="category" value="LIFESTYLE_STRESS">
            <input type="hidden" name="data">

            <div id="edit-univ_sub_stress_assessment-container">
                <p class="font-weight-bold my-3 font-size-14"><i>Mental Health</i></p>
                <p><b>PERCEIVED STRESS</b></p>
                <div class="d-flex align-items-baseline mb-3">
                    <div class="pr-2 text-secondary font-weight-bold width-30px">a.</div>
                    <div class="flex-grow-1">
                        <div class="row">
                            <div class="col-6">
                                How often have you felt that you were unable to control the important things in your life?
                            </div>
                            <div class="col-6">
                                <select class="form-control form-control-sm width-200px" v-model="data.uncontrollable_things_life">
                                    <option v-for="(opt, i) in options_a" :value="i+1">@{{opt}}</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="d-flex align-items-baseline mb-3">
                    <div class="pr-2 text-secondary font-weight-bold width-30px">b.</div>
                    <div class="flex-grow-1">
                        <div class="row">
                            <div class="col-6">
                                How often have you felt <b>lack of</b> confidence about your ability to handle your personal problems?
                            </div>
                            <div class="col-6">
                                <select class="form-control form-control-sm width-200px" v-model="data.lack_confidence">
                                    <option v-for="(opt, i) in options_a" :value="i+1">@{{opt}}</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="d-flex align-items-baseline mb-3">
                    <div class="pr-2 text-secondary font-weight-bold width-30px">c.</div>
                    <div class="flex-grow-1">
                        <div class="row">
                            <div class="col-6">
                                How often have you felt that things were <b>not</b> going your way?
                            </div>
                            <div class="col-6">
                                <select class="form-control form-control-sm width-200px" v-model="data.things_not_going_well">
                                    <option v-for="(opt, i) in options_a" :value="i+1">@{{opt}}</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="d-flex align-items-baseline mb-3">
                    <div class="pr-2 text-secondary font-weight-bold width-30px">a.</div>
                    <div class="flex-grow-1">
                        <div class="row">
                            <div class="col-6">
                                Have often have you found it hard to let go of things that upset you?
                            </div>
                            <div class="col-6">
                                <select class="form-control form-control-sm width-200px" v-model="data.let_things_go_hard">
                                    <option v-for="(opt, i) in options_a" :value="i+1">@{{opt}}</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>

                <p><b>How do you COPE with stress? <em>Check all that apply</em></b></p>
                <table class="table table-sm table-striped table-bordered m-0">
                    <tbody>
                    <tr v-for="cope in stress_cope">
                        <td class="text-nowrap align-middle width-40px text-center"><input type="checkbox" class="m-0" v-model="data.cope_stress" :value="cope"></td>
                        <td class="text-nowrap align-middle" colspan="2">@{{cope}}</td>
                    </tr>
                    </tbody>
                </table>

                <p class="mt-2"><b>RESILIENCE</b></p>
                <p><b>When I am under extreme stress</b></p>
                <div class="d-flex align-items-baseline mb-3">
                    <div class="pr-2 text-secondary font-weight-bold width-30px">a.</div>
                    <div class="flex-grow-1">
                        <div class="row">
                            <div class="col-6">
                                I find a way to learn from my experience.
                            </div>
                            <div class="col-6">
                                <select class="form-control form-control-sm width-200px" v-model="data.extreme_stress_learn_from_experience">
                                    <option v-for="(opt, i) in options_a" :value="i+1">@{{opt}}</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="d-flex align-items-baseline mb-3">
                    <div class="pr-2 text-secondary font-weight-bold width-30px">b.</div>
                    <div class="flex-grow-1">
                        <div class="row">
                            <div class="col-6">
                                I find a way to take action.
                            </div>
                            <div class="col-6">
                                <select class="form-control form-control-sm width-200px" v-model="data.extreme_stress_take_action">
                                    <option v-for="(opt, i) in options_a" :value="i+1">@{{opt}}</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="d-flex align-items-baseline mb-3">
                    <div class="pr-2 text-secondary font-weight-bold width-30px">c.</div>
                    <div class="flex-grow-1">
                        <div class="row">
                            <div class="col-6">
                                I find it easy to prioritize what is important in my life.
                            </div>
                            <div class="col-6">
                                <select class="form-control form-control-sm width-200px" v-model="data.extreme_stress_prioritize_importance">
                                    <option v-for="(opt, i) in options_a" :value="i+1">@{{opt}}</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="d-flex align-items-baseline mb-3">
                    <div class="pr-2 text-secondary font-weight-bold width-30px">d.</div>
                    <div class="flex-grow-1">
                        <div class="row">
                            <div class="col-6">
                                I look at a stressful situation as an opportunity to grow.
                            </div>
                            <div class="col-6">
                                <select class="form-control form-control-sm width-200px" v-model="data.extreme_stress_opportunity_to_grow">
                                    <option v-for="(opt, i) in options_a" :value="i+1">@{{opt}}</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="d-flex align-items-baseline mb-3">
                    <div class="pr-2 text-secondary font-weight-bold width-30px">e.</div>
                    <div class="flex-grow-1">
                        <div class="row">
                            <div class="col-6">
                                I meet the goals I set for myself.
                            </div>
                            <div class="col-6">
                                <select class="form-control form-control-sm width-200px" v-model="data.extreme_stress_set_goals">
                                    <option v-for="(opt, i) in options_a" :value="i+1">@{{opt}}</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="d-flex align-items-baseline mb-3">
                    <div class="pr-2 text-secondary font-weight-bold width-30px">f.</div>
                    <div class="flex-grow-1">
                        <div class="row">
                            <div class="col-6">
                                I believe that there are a lot of ways around a problem.
                            </div>
                            <div class="col-6">
                                <select class="form-control form-control-sm width-200px" v-model="data.extreme_stress_ways_around_problem">
                                    <option v-for="(opt, i) in options_a" :value="i+1">@{{opt}}</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="d-flex align-items-baseline mb-3">
                    <div class="pr-2 text-secondary font-weight-bold width-30px">g.</div>
                    <div class="flex-grow-1">
                        <div class="row">
                            <div class="col-6">
                                I feel motivated to pursue my goals.
                            </div>
                            <div class="col-6">
                                <select class="form-control form-control-sm width-200px" v-model="data.extreme_stress_motivated_to_pursue_goals">
                                    <option v-for="(opt, i) in options_a" :value="i+1">@{{opt}}</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="d-flex align-items-baseline mb-3">
                    <div class="pr-2 text-secondary font-weight-bold width-30px">h.</div>
                    <div class="flex-grow-1">
                        <div class="row">
                            <div class="col-6">
                                I know I can get through it.
                            </div>
                            <div class="col-6">
                                <select class="form-control form-control-sm width-200px" v-model="data.extreme_stress_know_can_get_through_it">
                                    <option v-for="(opt, i) in options_a" :value="i+1">@{{opt}}</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>

                <p class="mt-2"><b>MIND-BODY CONNECTION</b></p>
                <div class="d-flex align-items-baseline mb-3">
                    <div class="pr-2 text-secondary font-weight-bold width-30px">a.</div>
                    <div class="flex-grow-1">
                        <div class="row">
                            <div class="col-6">
                                I meet the goals I set for myself.
                            </div>
                            <div class="col-6">
                                <select class="form-control form-control-sm width-200px" v-model="data.body_connect_set_goals">
                                    <option v-for="(opt, i) in options_a" :value="i+1">@{{opt}}</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="d-flex align-items-baseline mb-3">
                    <div class="pr-2 text-secondary font-weight-bold width-30px">b.</div>
                    <div class="flex-grow-1">
                        <div class="row">
                            <div class="col-6">
                                Do thoughts or feelings affect your physical health?
                            </div>
                            <div class="col-6">
                                <select class="form-control form-control-sm width-200px" v-model="data.body_connect_feelings_affect">
                                    <option v-for="(opt, i) in options_a" :value="i+1">@{{opt}}</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="d-flex align-items-baseline mb-3">
                    <div class="pr-2 text-secondary font-weight-bold width-30px">c.</div>
                    <div class="flex-grow-1">
                        <div class="row">
                            <div class="col-6">
                                Could you be experiencing some emotion and not be aware of it?
                            </div>
                            <div class="col-6">
                                <select class="form-control form-control-sm width-200px" v-model="data.body_connect_emotion_experience">
                                    <option v-for="(opt, i) in options_a" :value="i+1">@{{opt}}</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="d-flex align-items-baseline mb-3">
                    <div class="pr-2 text-secondary font-weight-bold width-30px">d.</div>
                    <div class="flex-grow-1">
                        <div class="row">
                            <div class="col-6">
                                Are you aware of tension in your body?
                            </div>
                            <div class="col-6">
                                <select class="form-control form-control-sm width-200px" v-model="data.body_connect_tension_aware">
                                    <option v-for="(opt, i) in options_a" :value="i+1">@{{opt}}</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="d-flex align-items-baseline mb-3">
                    <div class="pr-2 text-secondary font-weight-bold width-30px">e.</div>
                    <div class="flex-grow-1">
                        <div class="row">
                            <div class="col-6">
                                Do you notice how your body changes when angry?
                            </div>
                            <div class="col-6">
                                <select class="form-control form-control-sm width-200px" v-model="data.body_connect_angry">
                                    <option v-for="(opt, i) in options_a" :value="i+1">@{{opt}}</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="d-flex align-items-baseline mb-3">
                    <div class="pr-2 text-secondary font-weight-bold width-30px">f.</div>
                    <div class="flex-grow-1">
                        <div class="row">
                            <div class="col-6">
                                Do you notice stress in your body?
                            </div>
                            <div class="col-6">
                                <select class="form-control form-control-sm width-200px" v-model="data.body_connect_stress">
                                    <option v-for="(opt, i) in options_a" :value="i+1">@{{opt}}</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="d-flex align-items-baseline mb-3">
                    <div class="pr-2 text-secondary font-weight-bold width-30px">g.</div>
                    <div class="flex-grow-1">
                        <div class="row">
                            <div class="col-6">
                                Do you notice how your body reacts to emotions?
                            </div>
                            <div class="col-6">
                                <select class="form-control form-control-sm width-200px" v-model="data.body_connect_emotion_react">
                                    <option v-for="(opt, i) in options_a" :value="i+1">@{{opt}}</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>

                <p class="mt-2"><b>DEPRESSION</b></p>
                <p><b>Over the last 2 weeks, how often have you been bothered by the following?</b></p>
                <div class="d-flex align-items-baseline mb-3">
                    <div class="pr-2 text-secondary font-weight-bold width-30px">a.</div>
                    <div class="flex-grow-1">
                        <div class="row">
                            <div class="col-6">
                                Little interest or pleasure in doing things.
                            </div>
                            <div class="col-6">
                                <select class="form-control form-control-sm width-200px" v-model="data.depression_little_interest">
                                    <option v-for="(opt, i) in options_b" :value="i">@{{opt}}</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="d-flex align-items-baseline mb-3">
                    <div class="pr-2 text-secondary font-weight-bold width-30px">b.</div>
                    <div class="flex-grow-1">
                        <div class="row">
                            <div class="col-6">
                                Feeling down, depressed or hopeless.
                            </div>
                            <div class="col-6">
                                <select class="form-control form-control-sm width-200px" v-model="data.depression_feeling_depressed">
                                    <option v-for="(opt, i) in options_b" :value="i">@{{opt}}</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="d-flex align-items-baseline mb-3">
                    <div class="pr-2 text-secondary font-weight-bold width-30px">c.</div>
                    <div class="flex-grow-1">
                        <div class="row">
                            <div class="col-6">
                                Trouble falling asleep, staying asleep, or sleeping too much.
                            </div>
                            <div class="col-6">
                                <select class="form-control form-control-sm width-200px" v-model="data.depression_trouble_sleeping">
                                    <option v-for="(opt, i) in options_b" :value="i">@{{opt}}</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="d-flex align-items-baseline mb-3">
                    <div class="pr-2 text-secondary font-weight-bold width-30px">d.</div>
                    <div class="flex-grow-1">
                        <div class="row">
                            <div class="col-6">
                                Feeling tired or having little energy.
                            </div>
                            <div class="col-6">
                                <select class="form-control form-control-sm width-200px" v-model="data.depression_feeling_tired">
                                    <option v-for="(opt, i) in options_b" :value="i">@{{opt}}</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="d-flex align-items-baseline mb-3">
                    <div class="pr-2 text-secondary font-weight-bold width-30px">e.</div>
                    <div class="flex-grow-1">
                        <div class="row">
                            <div class="col-6">
                                Poor appetite or overeating.
                            </div>
                            <div class="col-6">
                                <select class="form-control form-control-sm width-200px" v-model="data.depression_poor_appetite">
                                    <option v-for="(opt, i) in options_b" :value="i">@{{opt}}</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="d-flex align-items-baseline mb-3">
                    <div class="pr-2 text-secondary font-weight-bold width-30px">f.</div>
                    <div class="flex-grow-1">
                        <div class="row">
                            <div class="col-6">
                                Feeling bad about yourself or that you’re a failure or have let yourself or your family down.
                            </div>
                            <div class="col-6">
                                <select class="form-control form-control-sm width-200px" v-model="data.depression_feeling_bad_self">
                                    <option v-for="(opt, i) in options_b" :value="i">@{{opt}}</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="d-flex align-items-baseline mb-3">
                    <div class="pr-2 text-secondary font-weight-bold width-30px">g.</div>
                    <div class="flex-grow-1">
                        <div class="row">
                            <div class="col-6">
                                Trouble concentrating on things, such as reading the newspaper or watching television.
                            </div>
                            <div class="col-6">
                                <select class="form-control form-control-sm width-200px" v-model="data.depression_trouble_concentrating">
                                    <option v-for="(opt, i) in options_b" :value="i">@{{opt}}</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="d-flex align-items-baseline mb-3">
                    <div class="pr-2 text-secondary font-weight-bold width-30px">h.</div>
                    <div class="flex-grow-1">
                        <div class="row">
                            <div class="col-6">
                                Moving or speaking so slowly that other people could have noticed. Or the opposite, being so fidgety or restless that you have been moving around a lot more than usual.
                            </div>
                            <div class="col-6">
                                <select class="form-control form-control-sm width-200px" v-model="data.depression_moving_slow">
                                    <option v-for="(opt, i) in options_b" :value="i">@{{opt}}</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="d-flex align-items-baseline mb-3">
                    <div class="pr-2 text-secondary font-weight-bold width-30px">i.</div>
                    <div class="flex-grow-1">
                        <div class="row">
                            <div class="col-6">
                                Thoughts that you would be better off dead or of hurting yourself in some way.
                            </div>
                            <div class="col-6">
                                <select class="form-control form-control-sm width-200px" v-model="data.depression_hurting_self">
                                    <option v-for="(opt, i) in options_b" :value="i">@{{opt}}</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>

                <p class="mt-2"><b>ANXIETY</b></p>
                <p><b>Over the last 2 weeks, how often have you been bothered by the following?</b></p>
                <div class="d-flex align-items-baseline mb-3">
                    <div class="pr-2 text-secondary font-weight-bold width-30px">i.</div>
                    <div class="flex-grow-1">
                        <div class="row">
                            <div class="col-6">
                                Feeling nervous, anxious, or on edge.
                            </div>
                            <div class="col-6">
                                <select class="form-control form-control-sm width-200px" v-model="data.anxiety_feeling_nervous">
                                    <option v-for="(opt, i) in options_b" :value="i">@{{opt}}</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="d-flex align-items-baseline mb-3">
                    <div class="pr-2 text-secondary font-weight-bold width-30px">i.</div>
                    <div class="flex-grow-1">
                        <div class="row">
                            <div class="col-6">
                                Not being able to stop or control worrying.
                            </div>
                            <div class="col-6">
                                <select class="form-control form-control-sm width-200px" v-model="data.anxiety_uncontrollable_worry">
                                    <option v-for="(opt, i) in options_b" :value="i">@{{opt}}</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="d-flex align-items-baseline mb-3">
                    <div class="pr-2 text-secondary font-weight-bold width-30px">i.</div>
                    <div class="flex-grow-1">
                        <div class="row">
                            <div class="col-6">
                                Worrying too much about different things.
                            </div>
                            <div class="col-6">
                                <select class="form-control form-control-sm width-200px" v-model="data.anxiety_worry_different_things">
                                    <option v-for="(opt, i) in options_b" :value="i">@{{opt}}</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="d-flex align-items-baseline mb-3">
                    <div class="pr-2 text-secondary font-weight-bold width-30px">i.</div>
                    <div class="flex-grow-1">
                        <div class="row">
                            <div class="col-6">
                                Trouble relaxing.
                            </div>
                            <div class="col-6">
                                <select class="form-control form-control-sm width-200px" v-model="data.anxiety_trouble_relaxing">
                                    <option v-for="(opt, i) in options_b" :value="i">@{{opt}}</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="d-flex align-items-baseline mb-3">
                    <div class="pr-2 text-secondary font-weight-bold width-30px">i.</div>
                    <div class="flex-grow-1">
                        <div class="row">
                            <div class="col-6">
                                Being so restless that it’s hard to sit still.
                            </div>
                            <div class="col-6">
                                <select class="form-control form-control-sm width-200px" v-model="data.anxiety_restless">
                                    <option v-for="(opt, i) in options_b" :value="i">@{{opt}}</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="d-flex align-items-baseline mb-3">
                    <div class="pr-2 text-secondary font-weight-bold width-30px">i.</div>
                    <div class="flex-grow-1">
                        <div class="row">
                            <div class="col-6">
                                Becoming easily annoyed or irritable.
                            </div>
                            <div class="col-6">
                                <select class="form-control form-control-sm width-200px" v-model="data.anxiety_easily_annoyed">
                                    <option v-for="(opt, i) in options_b" :value="i">@{{opt}}</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="mt-3 pt-3 border-top text-center">
                    <button type="button" v-on:click.prevent="saveForm()" class="btn btn-sm btn-primary mr-2">Submit</button>
                    <button type="button" onclick="closeStagPopup()" class="btn btn-sm btn-default border">Cancel</button>
                </div>

            </div>

            <div class="d-none">
                <button submit class="btn btn-sm btn-primary mr-2">Submit</button>
                <button cancel class="btn btn-sm btn-default border">Cancel</button>
            </div>
        </form>
    </div>
</div>
<script>
    (function() {
        window.segmentInitializers.<?= $segment->segmentTemplate->internal_name ?> = function() {
            // any JS can come here
            // will be run on page-load as well as whenever this segment is refreshed
            new Vue({
                el: '#edit-univ_sub_stress_assessment-container',
                delimiters: ["@{{","}}"],
                data: {
                    data: <?= json_encode($contentData) ?>,
                    options_a: [
                        "1 - Never",
                        "2 - Seldom",
                        "3 - Sometimes",
                        "4 - Often",
                        "5 - Always"
                    ],
                    options_b: [
                        "0 - Not at all",
                        "1 - Several days",
                        "2 - Most days",
                        "3 - Daily"
                    ],
                    stress_cope: [
                        "Meditation",
                        "Exercise/Physical Activity",
                        "Counseling/Psychotherapy ",
                        "Socializing with friends or",
                        "family ",
                        "Art",
                        "Food (too much, too little) ",
                        "Spirituality/Faith",
                        "Sex",
                        "Recreational drugs (i.e.",
                        "marijuana, cocaine, etc.)",
                        "Television and/or video games",
                        "Gambling ",
                        "Journaling",
                        "Massage/Body work ",
                        "Prayer",
                        "Substance (tobacco, alcohol)",
                        "Distraction",
                        "Hurting yourself (i.e. cutting, etc.)",
                        "Pet therapy",
                        "Other"
                    ]
                },
                watch: {
                    $data: {
                        handler: function(val, oldVal) {
                            let parent = $('#edit-univ_sub_stress_assessment-container').closest('form');
                            parent.find('[name="data"]').val(JSON.stringify(this.data));

                            // autosave on change
                            autoSaveSegment(parent.find('[submit]').first());
                        },
                        deep: true
                    }
                },
                methods: {
                    calculateTotal: function() {
                        var days = !isNaN(parseInt(this.data.days_exercise)) ? parseInt(this.data.days_exercise) : 0;
                        var min = !isNaN(parseInt(this.data.min_exercise)) ? parseInt(this.data.min_exercise) : 0;
                        this.data.total_exercise = days * min;
                    },
                    saveForm: function() {
                        let parent = $('#edit-univ_sub_stress_assessment-container').closest('form');
                        parent.find('[name="data"]').val(JSON.stringify(this.data));
                        autoSaveSegmentAndClose(parent.find('[submit]').first());
                    }
                }
            });
        };
    })();
</script>