<template>
    <div>
        <v-dialog v-model="dialogprintlang" persistent  max-width="450">
            <v-card class="align-center justify-center">
                <v-card-title style="padding:0px;" primary-title dark color="blue-grey"  class="blue-grey white--text">
                    <v-subheader style="color:#fff!important">PILIH BAHASA</v-subheader>
                </v-card-title>
                <v-card-text>
                    <!--<v-select class="ma-1 mini-select"  :items="dialoglangs" 
                        item-text="name"
                        return-object
                        v-model="xselectedlang"
                        label="Bahasa" outline hide-details>
                    </v-select>-->
                   <v-switch style="margin-top:0;padding-top:0"
                     @change="changeSwitch(lang.chex,index)" 
                     v-for="(lang,index) in dialoglangs" 
                     v-model="lang.chex === 'Y'" 
                     :label="lang.name"
                     :disabled="lang.chex === 'N'">
                    </v-switch>
                </v-card-text>
                <v-card-actions>
                <v-spacer></v-spacer>
                    <v-btn color="grey ligthen-1" flat @click="dialogprintlang = false">Batal</v-btn>
                    <v-btn color="blue-grey" flat @click="doPrintAfterLang()">Cetak</v-btn>
                    
                </v-card-actions>
            </v-card>
        </v-dialog>
        <v-dialog v-model="dialogtemplates" persistent  max-width="450">
            <v-card class="align-center justify-center">
                <v-card-title style="padding:0px;" primary-title dark color="primary"  class="primary white--text">
                    <v-subheader style="color:#fff!important">PILIH TEMPLATE</v-subheader>
                </v-card-title>
                <v-card-text>
                   <v-select class="ma-1 mini-select"  :items="xtemplates" 
                        item-text="label"
                        return-object
                        v-model="xselectedtemplate"
                        label="Template" outline hide-details>
                    </v-select>
                </v-card-text>
                <v-card-actions>
                <v-spacer></v-spacer>
                    <v-btn color="grey ligthen-1" flat @click="dialogtemplates = false">Batal</v-btn>
                    <v-btn color="blue-grey" flat @click="doPasteTemplate()">Terapkan</v-btn>
                </v-card-actions>
            </v-card>
        </v-dialog>
        <v-dialog v-model="xdialogdoctor" persistent  max-width="350">
            <v-card class="align-center justify-center">
                <v-card-title primary-title dark color="warning"  class="warning white--text headline">PILIH DOKTER</v-card-title>
                <v-card-text>
                <p  v-if="requiredoctor" class="error pl-2 pr-2" style="color:#fff">Dokter harus dipilih salah satu dong</p>

                <v-select class="ma-1 mini-select"  :items="xdoctors" 
                    item-text="doctor_fullname"
                    
                    return-object
                    v-model="xselecteddoctor"
                    label="DOKTER" outline hide-details></v-select>
                </v-card-text>
                <v-card-actions>
                <v-spacer></v-spacer>
                <v-btn color="red darken-1" flat @click="xdialogdoctor = false">Tutup</v-btn>
                <v-btn color="green darken-1" @click="savedoctor" flat >Simpan</v-btn>
                </v-card-actions>
            </v-card>
        </v-dialog>
        <v-dialog v-model="xdialogaction" persistent  max-width="350">
            <v-card>
                <v-card-title color="warning"  class="headline">Konfirmasi</v-card-title>
                <v-card-text v-html="xmsgaction">
                    
                </v-card-text>
                <v-card-actions>
                <v-spacer></v-spacer>
                    <v-btn color="primary darken-1" flat @click="closeDialogAction()">Ya</v-btn>
                    <v-btn color="error darken-1" flat @click="xdialogaction = false">Tutup</v-btn>
                </v-card-actions>
            </v-card>
        </v-dialog>
        <v-dialog v-model="xdialogimage" persistent  max-width="650" max-height="500">
            <v-card color="amber lighten-5">
                <v-container grid-list-sm fluid>
                    <v-layout row wrap>
                        <v-flex>
                            <v-card flat tile class="d-flex">
                                <v-img
                                :src="ximage"
                                aspect-ratio="1"
                                class="grey lighten-2"
                                >
                                <template v-slot:placeholder>
                                    <v-layout
                                    fill-height
                                    align-center
                                    justify-center
                                    ma-0
                                    >
                                    <v-progress-circular indeterminate color="grey lighten-5"></v-progress-circular>
                                    </v-layout>
                                </template>
                                </v-img>
                            </v-card>
                        </v-flex>
                    </v-layout>
                </v-container>
                <v-card-actions>
                   
                    <v-spacer></v-spacer>
                    <v-btn color="black" dark @click="xdialogimage = false">Tutup</v-btn>
                </v-card-actions>
            <v-card>
        </v-dialog>
        <v-layout row mb-2 wrap>
            <v-flex xs12 pr-1>
                <v-card>
                     <v-layout pt-1 pb-1 row>
                         <v-flex pt-1 pb-1 pl-2 pr-2 xs12>
                            <span class="left" style="font-size:x-large">{{patient.ordernumber}}</span>
                            <span class="right">
                                <v-chip label color="#fa8072" text-color="white">
                                   {{patient.deliveries}}
                                </v-chip>
                            </span>
                         </v-flex>
                    </v-layout>
                    <v-divider></v-divider>
                    <v-layout pt-1 pb-2 row>
                            <v-flex pt-1 pb-1 pl-2 xs3>
                                <v-text-field ma-1
                                label="NAMA PASIEN"
                                class="text-uppercase"
                                :value="patient.patient_fullname"
                                hide-details
                                ></v-text-field>
                            </v-flex>
                            <v-flex pt-1 pb-1 pl-2 xs2>
                                <v-text-field ma-1
                                label="JENIS KELAMIN"
                                class="text-uppercase"
                                :value="patient.sexname"
                                hide-details
                                ></v-text-field>
                            </v-flex>
                            <v-flex pt-1 pb-1 pl-2 xs4>
                                <v-text-field ma-1
                                label="UMUR"
                                class="text-uppercase"
                                :value="patient.umur"
                                :title="patient.dob"
                                hide-details
                                ></v-text-field>
                            </v-flex>
                            <v-flex pt-1 pb-1 pl-2 pr-1 xs3>
                                <v-text-field ma-1
                                label="PENGIRIM"
                                class="text-uppercase"
                                :value="patient.doctor_fullname"
                                hide-details
                                ></v-text-field>
                            </v-flex>
                    </v-layout>
                </v-card>
            </v-flex>
        </v-layout>
        <v-layout mb-2 row v-for="(test,index) in xtests" wrap>
            <v-flex xs12 pr-1>
                <v-card>
                    <v-layout row>
                        <v-flex  xs12>
                            <v-subheader red--text text--lighten-1> 
                            <v-chip v-if="test.status === 'NEW'" label color="grey" text-color="white">
                                <v-icon left>label</v-icon>{{test.test_name}}
                            </v-chip>
                            <v-chip v-if="test.status === 'VAL1'" label color="warning" text-color="white">
                                <v-icon left>label</v-icon>{{test.test_name}}
                            </v-chip>
                            <v-chip v-if="test.status === 'VAL2'" label color="success" text-color="white">
                                <v-icon left>label</v-icon>{{test.test_name}}
                            </v-chip>
                            <v-chip  v-if="!cantedit" @click="opendialogdoctor(test)" label color="info" outline >
                                 <v-icon left>assignment_ind</v-icon>{{test.doctor_fullname}}
                            </v-chip>
                            <v-chip style="color:white"  v-if="cantedit" label color="grey"  >
                                 <v-icon left>assignment_ind</v-icon>{{test.doctor_fullname}}
                            </v-chip>
                            <v-menu
                                bottom
                                origin="center center"
                                transition="scale-transition"
                            >
                                <template v-slot:activator="{ on }">
                                <v-btn
                                    color="primary"
                                    dark
                                    small
                                    v-on="on"
                                >
                                    {{selectedlangName(test)}}
                                </v-btn>
                                </template>

                                <v-list>
                                <v-list-tile
                                v-for="(lang, i) in xlangs"
                                :key="i"
                                @click="selectLang(test,lang)"
                                >
                                <v-list-tile-title>{{ lang.name }}</v-list-tile-title>
                                </v-list-tile>
                                </v-list>
                            </v-menu>
                            <v-tooltip left>
                                <template v-slot:activator="{ on }">
                                    <v-icon v-on="on" @click="pasteTemplate(test,index)" style="cursor: pointer;" large>assignment</v-icon>
                                </template>
                                <span>pasang template</span>
                            </v-tooltip>
                             <v-flex text-md-right>
                                <span  v-if="test.status === 'VAL1' || test.status === 'VAL2'" @click="print(test,'print')"  class="icon-medium-fill-base-small xs1 white--text blue-grey icon-print"></span>
                                <span  v-if="test.status === 'VAL1'" @click="unval1(test,'unval1')"  class="icon-medium-fill-base-small xs1 white--text warning icon-unval"></span>
                                <span  v-if="test.status === 'NEW' && check_saved(test)" @click="val1(test,'val1')"  class="icon-medium-fill-base-small xs1 white--text warning icon-v"></span>
                                <span  v-if="test.status === 'NEW'" @click="saveResult(test,'save')"  class="icon-medium-fill-base-small xs1 white--text info icon-save"></span>
                            </v-flex>
                            </v-subheader>
                            <v-divider></v-divider>
                            <v-layout v-if="test.template_flag_other === 'N'" row wrap>
                                <v-flex xs12 pa-2 mb-1 pt-1>
                                    <v-layout  align-center justify-center v-for="(result,idxresult) in test.details" row>
                                        <v-flex pl-2 class="text-xs-center" xs1>
                                            <v-switch
                                                v-model="result.flag_print === 'Y'"
                                                @change="changeFlagPrint(result.flag_print,idxresult,index)"
                                            ></v-switch>
                                            
                                        </v-flex>
                                        <v-flex xs11 pa-1>
                                            <v-textarea
                                                filled
                                                outline
                                                hide-details
                                                :label="result.result_label"
                                                @change="changeResult()"
                                                :disabled="test.status !== 'NEW'"
                                                v-model="result.result_value"
                                                rows="3"
                                            ></v-textarea>
                                        </v-flex>
                                    </v-layout>
                                </v-flex>
                            </v-layout>
                            <v-layout v-if="test.template_flag_other === 'Y' && test.template_name.includes('UMUM')" row wrap>
                               <v-flex xs12>
                                    <v-stepper style="background:#fa8072" v-model="tab">
                                        <v-stepper-header>
                                            <template v-for="n in tabs_fisik">
                                                <v-stepper-step
                                                    color="red"
                                                    :key="`${n.id}-step`"
                                                    :step="n.id"
                                                    editable
                                                >
                                                    <span style="color:#ffe4e1">{{ n.name }}</span>
                                                </v-stepper-step>
                                                <v-divider
                                                    class="x_step"
                                                    style="border-color:#fff"
                                                    v-if="n.id !== tabs_fisik.length"
                                                    :key="n.id"
                                                ></v-divider>
                                            </template>
                                        </v-stepper-header>
                                        <v-stepper-items>
                                            <v-stepper-content class="x_form" step="1">
                                                <div v-for="(riwayat,idx_r) in riwayats">
                                                    <v-card class="mb-2">
                                                        <v-layout pb-2 row>
                                                            <v-flex xs12>
                                                                <v-subheader red--text text--lighten-1> 
                                                                    <v-btn v-if="riwayat.show_all === 'N'" @click="toggleDetailRiwayat(idx_r)" style="min-width:30px;" small flat color="#fa8072"><v-icon small>add</v-icon></v-btn> 
                                                                    <v-btn v-if="riwayat.show_all === 'Y'" @click="toggleDetailRiwayat(idx_r)" style="min-width:30px;" small flat color="#fa8072"><v-icon small>remove</v-icon></v-btn> 
                                                                    {{riwayat.title}}
                                                                    
                                                                    <v-flex text-md-right>
                                                                        <v-btn v-if="riwayat.flag_normal === 'N'" :disabled="cantedit"  @click="changeFlagNormal(idx_r)" small color="error"><v-icon class="pr-1" small>close</v-icon> {{riwayat.label_flag_normal}}</v-btn>
                                                                        <v-btn v-if="riwayat.flag_normal === 'Y'" :disabled="cantedit"  @click="changeFlagNormal(idx_r)"  small color="info"><v-icon class="pr-1" small>check</v-icon> {{riwayat.label_flag_normal}}</v-btn>
                                                                        
                                                                    </v-flex>
                                                                </v-subheader>
                                                                <v-divider class="mb-2" ></v-divider>
                                                                <div v-if="riwayat.type_form === 'XV'">
                                                                    <v-layout v-if="riwayat.subtitle !== ''" class="pl-2 caption pb-2" row>{{riwayat.subtitle}}</v-layout>
                                                                    <v-layout pl-2  pb-1 pt-1 v-for="(r_detail,idx_detail) in generate_rows(riwayat.details)" v-if="riwayat.show_all === 'Y'" wrap>
                                                                        <v-flex xs6 pa-1>
                                                                            <v-layout v-if="r_detail[0]" align-center row>
                                                                                <v-flex xs1>
                                                                                    <v-checkbox row
                                                                                        class="mt-0 pt-0"
                                                                                        v-model="r_detail[0].chx"
                                                                                        :disabled="riwayat.flag_normal === 'Y' || cantedit"
                                                                                        color="red"
                                                                                        hide-details
                                                                                    ></v-checkbox>
                                                                                </v-flex>
                                                                                <v-flex xs7>
                                                                                    <span style="font-size:12px" >{{r_detail[0].label}}</span>
                                                                                </v-flex>
                                                                                <v-flex xs4 pl-1 pr-2>
                                                                                    <v-text-field
                                                                                        style="font-size:12px;margin-top:0;padding-top:0;line-height:25px!important"
                                                                                        outline
                                                                                        v-model="r_detail[0].value"
                                                                                        :disabled="riwayat.flag_normal === 'Y' || cantedit"
                                                                                        single-line
                                                                                        placeholder="Keterangan"
                                                                                        hide-details
                                                                                    ></v-text-field>
                                                                                </v-flex>
                                                                            </v-layout>
                                                                            
                                                                        </v-flex>
                                                                        <v-flex xs6 pa-1>
                                                                            <v-layout  v-if="r_detail[1]" align-center  row>
                                                                                <v-flex xs1>
                                                                                    <v-checkbox row
                                                                                        class="mt-0 pt-0"
                                                                                        v-model="r_detail[1].chx"
                                                                                        :disabled="riwayat.flag_normal === 'Y' || cantedit"
                                                                                        color="red"
                                                                                        hide-details
                                                                                        ></v-checkbox>
                                                                                </v-flex>
                                                                                <v-flex xs7>
                                                                                    <span style="font-size:12px" >{{r_detail[1].label}}</span>
                                                                                </v-flex>
                                                                                <v-flex xs4 pl-1 pr-2>
                                                                                    <v-text-field
                                                                                        style="font-size:12px;margin-top:0;padding-top:0;line-height:25px!important"
                                                                                        outline
                                                                                        v-model="r_detail[1].value"
                                                                                        :disabled="riwayat.flag_normal === 'Y' || cantedit"
                                                                                        single-line
                                                                                        placeholder="Keterangan"
                                                                                        hide-details
                                                                                    ></v-text-field>
                                                                                </v-flex>
                                                                            </v-layout>
                                                                            
                                                                        </v-flex>
                                                                    </v-layout>
                                                                </div>
                                                                
                                                                <div v-if="riwayat.type_form === 'XVS'">
                                                                    <v-layout pl-2 v-for="segment in riwayat.details" wrap>
                                                                        <v-flex xs12>
                                                                            <v-layout v-if="riwayat.show_all === 'Y'" row>{{segment.name}}</v-layout>
                                                                            <v-layout pl-2  pb-1 pt-1 v-for="(r_detail,idx_detail) in generate_rows(segment.details)" v-if="riwayat.show_all === 'Y'" wrap>
                                                                                <v-flex xs6 pa-1>
                                                                                    <v-layout v-if="r_detail[0]" align-center row>
                                                                                        <v-flex xs1>
                                                                                            <v-checkbox row
                                                                                                class="mt-0 pt-0"
                                                                                                v-model="r_detail[0].chx"
                                                                                                :disabled="riwayat.flag_normal === 'Y' || cantedit"
                                                                                                color="red"
                                                                                                hide-details
                                                                                            ></v-checkbox>
                                                                                        </v-flex>
                                                                                        <v-flex xs7>
                                                                                            <span style="font-size:12px" >{{r_detail[0].label}}</span>
                                                                                        </v-flex>
                                                                                        <v-flex xs4 pl-1 pr-2>
                                                                                            <v-text-field
                                                                                                style="font-size:12px;margin-top:0;padding-top:0;line-height:25px!important"
                                                                                                outline
                                                                                                v-model="r_detail[0].value"
                                                                                                :disabled="riwayat.flag_normal === 'Y' || cantedit"
                                                                                                single-line
                                                                                                placeholder="Keterangan"
                                                                                                hide-details
                                                                                            ></v-text-field>
                                                                                        </v-flex>
                                                                                    </v-layout>
                                                                                    
                                                                                </v-flex>
                                                                                <v-flex xs6 pa-1>
                                                                                    <v-layout  v-if="r_detail[1]" align-center  row>
                                                                                        <v-flex xs1>
                                                                                            <v-checkbox row
                                                                                                class="mt-0 pt-0"
                                                                                                v-model="r_detail[1].chx"
                                                                                                :disabled="riwayat.flag_normal === 'Y' || cantedit"
                                                                                                color="red"
                                                                                                hide-details
                                                                                                ></v-checkbox>
                                                                                        </v-flex>
                                                                                        <v-flex xs7>
                                                                                            <span style="font-size:12px" >{{r_detail[1].label}}</span>
                                                                                        </v-flex>
                                                                                        <v-flex xs4 pl-1 pr-2>
                                                                                            <v-text-field
                                                                                                style="font-size:12px;margin-top:0;padding-top:0;line-height:25px!important"
                                                                                                outline
                                                                                                v-model="r_detail[1].value"
                                                                                                :disabled="riwayat.flag_normal === 'Y' || cantedit"
                                                                                                single-line
                                                                                                placeholder="Keterangan"
                                                                                                hide-details
                                                                                            ></v-text-field>
                                                                                        </v-flex>
                                                                                    </v-layout>
                                                                                    
                                                                                </v-flex>
                                                                            </v-layout>
                                                                        </v-flex>
                                                                    </v-layout>
                                                                </div>
                                                                
                                                            </v-flex>
                                                        </v-layout>    
                                                    </v-card>
                                                </div>    

                                            
                                            </v-stepper-content>
                                            <v-stepper-content class="x_form"  step="2">
                                                <div v-for="(fisik,idx_f) in fisiks">
                                                    <v-card class="mb-2">
                                                        <v-layout pb-2 row>
                                                            <v-flex xs12>
                                                                <v-subheader red--text text--lighten-1> 
                                                                    <v-btn v-if="fisik.show_all === 'N'" @click="toggleDetailFisik(idx_f)" style="min-width:30px;" small flat color="#fa8072"><v-icon small>add</v-icon></v-btn> 
                                                                    <v-btn v-if="fisik.show_all === 'Y'" @click="toggleDetailFisik(idx_f)" style="min-width:30px;" small flat color="#fa8072"><v-icon small>remove</v-icon></v-btn>
                                                                    {{fisik.title}}
                                                                    <v-flex text-md-right>
                                                                        <v-btn v-if="fisik.details[0].table_name === 'status_gizi'" :disabled="cantedit"  @click="changeStandartBMI(idx_f)" small color="info">{{fisik.standart_bmi}}</v-btn>
                                                                        
                                                                        <v-btn v-if="fisik.type_form === 'TOOTH' && fisik.is_normal === 'Y'" 
                                                                            :disabled="cantedit" 
                                                                            style="color:white" 
                                                                            @click="changeStatusTooth(idx_f)"
                                                                            small 
                                                                            color="info"> 
                                                                            <v-icon class="pr-1" small>check</v-icon> TIDAK DIPERIKSA
                                                                        </v-btn>
                                                                        <v-btn v-if="fisik.type_form === 'TOOTH' && fisik.is_normal === 'N'"
                                                                            :disabled="cantedit" 
                                                                            style="color:white" 
                                                                            @click="changeStatusTooth(idx_f)"
                                                                            small 
                                                                            color="error"> 
                                                                            <v-icon class="pr-1" small>close</v-icon> TIDAK DIPERIKSA
                                                                        </v-btn>
                                                                    </v-flex>
                                                                </v-subheader>
                                                                <v-divider class="mb-2" ></v-divider>
                                                                <div v-if="fisik.type_form === 'TOOTH'" >
                                                                    <v-layout wrap v-if="fisik.show_all === 'Y'" >
                                                                        <v-flex pl-2 pt-2 pb-2 pr-2 xs12>
                                                                            <v-layout row>
                                                                                <v-flex xs12>
                                                                                    <table>
                                                                                        <!--<tr>
                                                                                            <th colspan="18">Gigi Geligi</th>
                                                                                        </tr>-->
                                                                                        <tr class="bggrey">
                                                                                            <th></th>
                                                                                            <th class="text-xs-center" colspan="8">GIGI KANAN</th>
                                                                                            <th class="text-xs-center" colspan="8">GIGI KIRI</th>
                                                                                            <th></th>
                                                                                        </tr>
                                                                                        <tr>
                                                                                            <th>KODE</th>
                                                                                            <th v-for="gigiatasketiga in fisik.details[0].details" class="thgigi">
                                                                                                <input 
                                                                                                    type="text" 
                                                                                                    v-model="gigiatasketiga.value" 
                                                                                                    :disabled="cantedit || fisik.is_normal === 'Y'"
                                                                                                    @change="changeToothValue('atasketiga',gigiatasketiga,idx_f)"
                                                                                                    v-bind:class="{'background-black':gigiatasketiga.value.toUpperCase() === 'X','background-teal':gigiatasketiga.value.toUpperCase() === 'C','background-brown':gigiatasketiga.value.toUpperCase() === 'R','background-red':gigiatasketiga.value.toUpperCase() === 'O','background-yellow-accent-4':gigiatasketiga.value.toUpperCase() === 'A','background-info':gigiatasketiga.value.toUpperCase() === 'K'}"
                                                                                                    class="input_gigi mono"
                                                                                                />
                                                                                            </th>
                                                                                            <th>KODE</th>
                                                                                        </tr>
                                                                                        <tr>
                                                                                            <th>KODE</th>
                                                                                            <th v-for="gigiataskedua in fisik.details[1].details" class="thgigi">
                                                                                                <input 
                                                                                                    type="text" 
                                                                                                    v-model="gigiataskedua.value" 
                                                                                                    :disabled="cantedit || fisik.is_normal === 'Y'"
                                                                                                    @change="changeToothValue('ataskedua',gigiataskedua,idx_f)"
                                                                                                    v-bind:class="{'background-black':gigiataskedua.value.toUpperCase() === 'X','background-teal':gigiataskedua.value.toUpperCase() === 'C','background-brown':gigiataskedua.value.toUpperCase() === 'R','background-red':gigiataskedua.value.toUpperCase() === 'O','background-yellow-accent-4':gigiataskedua.value.toUpperCase() === 'A','background-info':gigiataskedua.value.toUpperCase() === 'K'}"
                                                                                                    class="input_gigi mono"
                                                                                                />
                                                                                            </th>
                                                                                            <th>KODE</th>
                                                                                        </tr>
                                                                                        <tr>
                                                                                            <th>KODE</th>
                                                                                            <th v-for="gigiatas in fisik.details[2].details" class="thgigi">
                                                                                                <input 
                                                                                                    type="text" 
                                                                                                    v-model="gigiatas.value" 
                                                                                                    :disabled="cantedit || fisik.is_normal === 'Y'"
                                                                                                    @change="changeToothValue('atas',gigiatas,idx_f)"
                                                                                                    v-bind:class="{'background-black':gigiatas.value.toUpperCase() === 'X','background-teal':gigiatas.value.toUpperCase() === 'C','background-brown':gigiatas.value.toUpperCase() === 'R','background-red':gigiatas.value.toUpperCase() === 'O','background-yellow-accent-4':gigiatas.value.toUpperCase() === 'A','background-info':gigiatas.value.toUpperCase() === 'K'}"
                                                                                                    class="input_gigi mono"
                                                                                                />
                                                                                            </th>
                                                                                            <th>KODE</th>
                                                                                        </tr>
                                                                                        <tr class="bggrey">
                                                                                            <th>ATAS</th>
                                                                                            <th v-for="gigiatas in fisik.details[0].details" class="thgigi">
                                                                                                {{gigiatas.label}}
                                                                                            </th>
                                                                                            <th>ATAS</th>
                                                                                        </tr>
                                                                                        <tr class="bggrey">
                                                                                            <th>BAWAH</th>
                                                                                            <th v-for="gigibawah in fisik.details[1].details" class="thgigi">
                                                                                                {{gigibawah.label}}
                                                                                            </th>
                                                                                            <th>BAWAH</th>
                                                                                        </tr>
                                                                                        <tr>
                                                                                            <th>KODE</th>
                                                                                            <th v-for="gigibawah in fisik.details[3].details" class="thgigi">
                                                                                                <input 
                                                                                                    type="text" 
                                                                                                    v-model="gigibawah.value" 
                                                                                                    :disabled="cantedit || fisik.is_normal === 'Y'"
                                                                                                    @change="changeToothValue('bawah',gigibawah,idx_f)"
                                                                                                    v-bind:class="{'background-black':gigibawah.value.toUpperCase() === 'X','background-teal':gigibawah.value.toUpperCase() === 'C','background-brown':gigibawah.value.toUpperCase() === 'R','background-red':gigibawah.value.toUpperCase() === 'O','background-yellow-accent-4':gigibawah.value.toUpperCase() === 'A','background-info':gigibawah.value.toUpperCase() === 'K'}"
                                                                                                    class="input_gigi mono"/>
                                                                                            </th>
                                                                                            <th>KODE</th>
                                                                                        </tr>
                                                                                        <tr>
                                                                                            <th>KODE</th>
                                                                                            <th v-for="gigibawahkedua in fisik.details[4].details" class="thgigi">
                                                                                                <input 
                                                                                                    type="text" 
                                                                                                    v-model="gigibawahkedua.value" 
                                                                                                    :disabled="cantedit || fisik.is_normal === 'Y'"
                                                                                                    @change="changeToothValue('bawahkedua',gigibawahkedua,idx_f)"
                                                                                                    v-bind:class="{'background-black':gigibawahkedua.value.toUpperCase() === 'X','background-teal':gigibawahkedua.value.toUpperCase() === 'C','background-brown':gigibawahkedua.value.toUpperCase() === 'R','background-red':gigibawahkedua.value.toUpperCase() === 'O','background-yellow-accent-4':gigibawahkedua.value.toUpperCase() === 'A','background-info':gigibawahkedua.value.toUpperCase() === 'K'}"
                                                                                                    class="input_gigi mono"/>
                                                                                            </th>
                                                                                            <th>KODE</th>
                                                                                        </tr>
                                                                                        <tr>
                                                                                            <th>KODE</th>
                                                                                            <th v-for="gigibawahketiga in fisik.details[5].details" class="thgigi">
                                                                                                <input 
                                                                                                    type="text" 
                                                                                                    v-model="gigibawahketiga.value"
                                                                                                    :disabled="cantedit || fisik.is_normal === 'Y'" 
                                                                                                    @change="changeToothValue('bawahketiga',gigibawahketiga,idx_f)"
                                                                                                    v-bind:class="{'background-black':gigibawahketiga.value.toUpperCase() === 'X','background-teal':gigibawahketiga.value.toUpperCase() === 'C','background-brown':gigibawahketiga.value.toUpperCase() === 'R','background-red':gigibawahketiga.value.toUpperCase() === 'O','background-yellow-accent-4':gigibawahketiga.value.toUpperCase() === 'A','background-info':gigibawahketiga.value.toUpperCase() === 'K'}"
                                                                                                    class="input_gigi mono"/>
                                                                                            </th>
                                                                                            <th>KODE</th>
                                                                                        </tr>
                                                                                        <tr class="bggrey">
                                                                                            <th></th>
                                                                                            <th class="text-xs-center"colspan="8">GIGI KANAN</th>
                                                                                            <th class="text-xs-center"colspan="8">GIGI KIRI</th>
                                                                                            <th></th>
                                                                                        </tr>
                                                                                    </table>
                                                                                </v-flex>
                                                                            </v-layout>
                                                                            <v-layout align-center pt-4 pl-2 row>
                                                                                <v-flex d-flex><h4>KETERANGAN KODE :</h4></v-flex>
                                                                            </v-layout>
                                                                            <v-layout align-center pt-3 pl-2 pb-3 row>
                                                                                <v-flex xs2>
                                                                                    <v-layout align-center row>
                                                                                        <v-flex xs4>
                                                                                            <v-btn small style="min-width:35px;margin:0" dark color="black">
                                                                                                X
                                                                                            </v-btn>
                                                                                        </v-flex>
                                                                                        <v-flex xs8>
                                                                                            <h5>: BERLUBANG</h5>
                                                                                        </v-flex>
                                                                                </v-flex>
                                                                                <v-flex xs2>
                                                                                    <v-layout align-center row>
                                                                                        <v-flex xs4>
                                                                                            <v-btn small style="min-width:35px;margin:0" dark color="teal">
                                                                                                C
                                                                                            </v-btn>
                                                                                        </v-flex>
                                                                                        <v-flex xs8>
                                                                                            <h5>: TAMBALAN</h5>
                                                                                        </v-flex>
                                                                                </v-flex>
                                                                                <v-flex xs2>
                                                                                    <v-layout align-center row>
                                                                                        <v-flex xs4>
                                                                                            <v-btn small style="min-width:35px;margin:0" dark color="red">
                                                                                                O
                                                                                            </v-btn>
                                                                                        </v-flex>
                                                                                        <v-flex xs8>
                                                                                            <h5>: TANGGAL</h5>
                                                                                        </v-flex>
                                                                                </v-flex>
                                                                                <v-flex xs2>
                                                                                    <v-layout align-center row>
                                                                                        <v-flex xs4>
                                                                                            <v-btn small style="min-width:35px;margin:0" dark color="brown">
                                                                                                R
                                                                                            </v-btn>
                                                                                        </v-flex>
                                                                                        <v-flex xs8>
                                                                                            <h5>: SISA AKAR</h5>
                                                                                        </v-flex>
                                                                                </v-flex>
                                                                                <v-flex xs2>
                                                                                    <v-layout align-center row>
                                                                                        <v-flex xs4>
                                                                                            <v-btn small style="min-width:35px;margin:0" dark color="yellow accent-4">
                                                                                                A
                                                                                            </v-btn>
                                                                                        </v-flex>
                                                                                        <v-flex xs8>
                                                                                            <h5>: GIGI PALSU</h5>
                                                                                        </v-flex>
                                                                                </v-flex>
                                                                                <v-flex xs2>
                                                                                    <v-layout align-center row>
                                                                                        <v-flex xs4>
                                                                                            <v-btn small style="min-width:35px;margin:0" dark color="info">
                                                                                                K
                                                                                            </v-btn>
                                                                                        </v-flex>
                                                                                        <v-flex xs8>
                                                                                            <h5>: KARANG GIGI</h5>
                                                                                        </v-flex>
                                                                                </v-flex>
                                                                            </v-layout>
                                                                        </v-flex>
                                                                    </v-layout>
                                                                </div>
                                                                <div v-if="fisik.type_form === 'XV'">
                                                                    <!--<v-layout v-if="riwayat.subtitle !== ''" class="pl-2 caption pb-2" row>{{riwayat.subtitle}}</v-layout>-->
                                                                    <v-layout pl-2  pb-1 pt-1 v-for="(f_detail,kdx_detail) in generate_rows(fisik.details)" v-if="fisik.show_all === 'Y'" wrap>
                                                                        <v-flex xs6 pa-1>
                                                                            <v-layout v-if="f_detail[0]" align-center row>
                                                                                <v-flex xs1>
                                                                                    <v-checkbox row
                                                                                        class="mt-0 pt-0"
                                                                                        v-model="f_detail[0].chx"
                                                                                        @change="changeXVChx(idx_f,f_detail[0])"
                                                                                        :disabled="cantedit"
                                                                                        color="red"
                                                                                        hide-details
                                                                                    ></v-checkbox>
                                                                                </v-flex>
                                                                                <v-flex xs7>
                                                                                    <span style="font-size:12px" >{{f_detail[0].label}}</span>
                                                                                </v-flex>
                                                                                <v-flex xs4 pl-1 pr-2>
                                                                                    <v-text-field
                                                                                        style="font-size:12px;margin-top:0;padding-top:0;line-height:25px!important"
                                                                                        outline
                                                                                        v-model="f_detail[0].value"
                                                                                        @change="changeXVChx(idx_f,f_detail[0])"
                                                                                        :disabled="cantedit"
                                                                                        single-line
                                                                                        placeholder="Keterangan"
                                                                                        hide-details
                                                                                    ></v-text-field>
                                                                                </v-flex>
                                                                            </v-layout>
                                                                        </v-flex>
                                                                        <v-flex xs6 pa-1>
                                                                            <v-layout  v-if="f_detail[1]" align-center  row>
                                                                                <v-flex xs1>
                                                                                    <v-checkbox row
                                                                                        class="mt-0 pt-0"
                                                                                        v-model="f_detail[1].chx"
                                                                                        @change="changeXVChx(idx_f,f_detail[1])"
                                                                                        :disabled="cantedit"
                                                                                        color="red"
                                                                                        hide-details
                                                                                        ></v-checkbox>
                                                                                </v-flex>
                                                                                <v-flex xs7>
                                                                                    <span style="font-size:12px" >{{f_detail[1].label}}</span>
                                                                                </v-flex>
                                                                                <v-flex xs4 pl-1 pr-2>
                                                                                    <v-text-field
                                                                                        style="font-size:12px;margin-top:0;padding-top:0;line-height:25px!important"
                                                                                        outline
                                                                                        v-model="f_detail[1].value"
                                                                                        @change="changeXVChx(idx_f,f_detail[1])"
                                                                                        :disabled="cantedit"
                                                                                        single-line
                                                                                        placeholder="Keterangan"
                                                                                        hide-details
                                                                                    ></v-text-field>
                                                                                </v-flex>
                                                                            </v-layout>
                                                                            
                                                                        </v-flex>
                                                                    </v-layout>
                                                                </div>

                                                                <div v-if="fisik.type_form === 'XVS'">
                                                                    <v-layout pl-2 v-for="(segment,idx_s) in fisik.details" wrap>
                                                                        <v-flex xs12>
                                                                            <v-layout v-if="fisik.show_all === 'Y'" row>{{segment.name}}</v-layout>
                                                                            <v-layout pl-2  pb-1 pt-1 v-for="(f_detail,kdx_detail) in generate_rows(segment.details)" v-if="fisik.show_all === 'Y'" wrap>
                                                                                <v-flex xs6 pa-1>
                                                                                    <v-layout v-if="f_detail[0]" align-center row>
                                                                                        <v-flex xs1>
                                                                                            <v-checkbox row
                                                                                                class="mt-0 pt-0"
                                                                                                v-model="f_detail[0].chx"
                                                                                                @change="changeXVSChx(idx_f,idx_s,f_detail[0])"
                                                                                                :disabled="cantedit"
                                                                                                color="red"
                                                                                                hide-details
                                                                                            ></v-checkbox>
                                                                                        </v-flex>
                                                                                        <v-flex xs7>
                                                                                            <span style="font-size:12px" >{{f_detail[0].label}}</span>
                                                                                        </v-flex>
                                                                                        <v-flex xs4 pl-1 pr-2>
                                                                                            <v-text-field
                                                                                                style="font-size:12px;margin-top:0;padding-top:0;line-height:25px!important"
                                                                                                outline
                                                                                                v-model="f_detail[0].value"
                                                                                                :disabled="cantedit"
                                                                                                single-line
                                                                                                placeholder="Keterangan"
                                                                                                hide-details
                                                                                            ></v-text-field>
                                                                                        </v-flex>
                                                                                    </v-layout>
                                                                                    
                                                                                </v-flex>
                                                                                <v-flex xs6 pa-1>
                                                                                    <v-layout  v-if="f_detail[1]" align-center  row>
                                                                                        <v-flex xs1>
                                                                                            <v-checkbox row
                                                                                                class="mt-0 pt-0"
                                                                                                v-model="f_detail[1].chx"
                                                                                                @change="changeXVSChx(idx_f,idx_s,f_detail[1])"
                                                                                                :disabled="cantedit"
                                                                                                color="red"
                                                                                                hide-details
                                                                                                ></v-checkbox>
                                                                                        </v-flex>
                                                                                        <v-flex xs7>
                                                                                            <span style="font-size:12px" >{{f_detail[1].label}}</span>
                                                                                        </v-flex>
                                                                                        <v-flex xs4 pl-1 pr-2>
                                                                                            <v-text-field
                                                                                                style="font-size:12px;margin-top:0;padding-top:0;line-height:25px!important"
                                                                                                outline
                                                                                                v-model="f_detail[1].value"
                                                                                                :disabled="cantedit"
                                                                                                single-line
                                                                                                placeholder="Keterangan"
                                                                                                hide-details
                                                                                            ></v-text-field>
                                                                                        </v-flex>
                                                                                    </v-layout>
                                                                                    
                                                                                </v-flex>
                                                                            </v-layout>
                                                                        </v-flex>
                                                                    </v-layout>
                                                                </div>
                                                                
                                                                <div v-if="fisik.type_form === 'VXX'" >
                                                                    <v-layout pl-2  pb-1 pt-1 v-for="(f_detail,kdx_detail) in generate_rows(fisik.details)" v-if="fisik.show_all === 'Y'" wrap>
                                                                        <v-flex v-for="f_cols in f_detail" xs6 pa-1>
                                                                            <v-layout v-if="f_cols.type === 'vxx-v'" align-center row>
                                                                                <v-flex xs4>
                                                                                    <span style="font-size:12px" >{{f_cols.label}}</span>
                                                                                </v-flex>
                                                                                <v-flex xs5>
                                                                                    <v-text-field
                                                                                        style="font-size:12px;margin-top:0;padding-top:0;line-height:25px!important"
                                                                                        v-model="f_cols.value"
                                                                                        outline
                                                                                         @change="changeVXXValue(idx_f,f_cols)"
                                                                                         :disabled="cantedit"
                                                                                        single-line
                                                                                        hide-details
                                                                                    ></v-text-field>
                                                                                </v-flex>
                                                                                <v-flex xs3 pl-1>
                                                                                    <span class="mono" style="font-size:12px" >{{f_cols.unit}}</span>
                                                                                </v-flex>
                                                                            </v-layout>
                                                                            <v-layout v-if="f_cols.type === 'vxx-xx'" align-center  row>
                                                                                <v-flex xs4><span style="font-size:12px" >{{f_cols.label}}</span></v-flex>
                                                                                <v-flex xs1>
                                                                                    <v-checkbox row
                                                                                        class="mt-0 pt-0"
                                                                                        v-model="f_cols.chx_y"
                                                                                        @change="changeVXXChx(idx_f,f_cols,'y')"
                                                                                        :disabled="cantedit"
                                                                                        color="red"
                                                                                        hide-details
                                                                                        ></v-checkbox>
                                                                                </v-flex>
                                                                                <v-flex xs3>
                                                                                    <span class="mono" style="font-size:12px" >{{f_cols.label_y}}</span>
                                                                                </v-flex>
                                                                                <v-flex xs1>
                                                                                    <v-checkbox row
                                                                                        class="mt-0 pt-0"
                                                                                        v-model="f_cols.chx_x"
                                                                                        @change="changeVXXChx(idx_f,f_cols,'x')"
                                                                                        :disabled="cantedit"
                                                                                        color="red"
                                                                                        hide-details
                                                                                        ></v-checkbox>
                                                                                </v-flex>
                                                                                <v-flex xs3>
                                                                                    <span class="mono" style="font-size:12px" >{{f_cols.label_x}}</span>
                                                                                </v-flex>
                                                                            </v-layout>
                                                                        </v-flex>
                                                                    </v-layout>
                                                                </div>
                                                                <div v-if="fisik.type_form === 'VXX+'" >
                                                                    <v-layout pl-2  pb-1 pt-1 v-for="(f_detail,kdx_detail) in generate_rows(fisik.details)" v-if="fisik.show_all === 'Y'" wrap>
                                                                        <v-flex v-for="f_cols in f_detail" xs6 pa-1>
                                                                            <v-layout v-if="f_cols.type === 'vxx-vv'" align-center row>
                                                                                <v-flex  xs4>
                                                                                    <span style="font-size:12px" >{{f_cols.label}}<br/>
                                                                                    <v-btn @click="changStandartTensi(idx_f,f_cols)" 
                                                                                        style="font-size:10px;height: 20px;width: auto;min-width: 5px;margin: 0;" 
                                                                                        small 
                                                                                        v-if="f_cols.standart !== ''" 
                                                                                        color="info">
                                                                                        {{f_cols.standart}} 
                                                                                    </v-btn>
                                                                                </v-flex>
                                                                                <v-flex xs4>
                                                                                    <v-text-field
                                                                                        style="font-size:12px;margin-top:0;padding-top:0;line-height:25px!important"
                                                                                        v-model="f_cols.value"
                                                                                        outline
                                                                                         @change="changeVXXValuePlus(idx_f,f_cols)"
                                                                                         :disabled="cantedit"
                                                                                        single-line
                                                                                        hide-details
                                                                                    ></v-text-field>
                                                                                   <span  v-if="f_cols.standart !==''" class='d-flex mt-1' 
                                                                                        style="font-size:10px;font-weight:600" 
                                                                                        :class="getcolortensi(f_cols)">{{f_cols.value_x}}</span> 
                                                                                </v-flex>
                                                                                <v-flex xs4 pl-1>
                                                                                    <span class="mono" style="font-size:12px" >{{f_cols.unit}}</span>
                                                                                </v-flex>
                                                                                
                                                                            </v-layout>
                                                                            <v-layout v-if="f_cols.type === 'vxx-xx'" align-center  row>
                                                                                <v-flex xs4><span style="font-size:12px" >{{f_cols.label}}</span></v-flex>
                                                                                <v-flex xs1>
                                                                                    <v-checkbox row
                                                                                        class="mt-0 pt-0"
                                                                                        v-model="f_cols.chx_y"
                                                                                        @change="changeVXXChx(idx_f,f_cols,'y')"
                                                                                        :disabled="cantedit"
                                                                                        color="red"
                                                                                        hide-details
                                                                                        ></v-checkbox>
                                                                                </v-flex>
                                                                                <v-flex xs3>
                                                                                    <span class="mono" style="font-size:12px" >{{f_cols.label_y}}</span>
                                                                                </v-flex>
                                                                                <v-flex xs1>
                                                                                    <v-checkbox row
                                                                                        class="mt-0 pt-0"
                                                                                        v-model="f_cols.chx_x"
                                                                                        @change="changeVXXChx(idx_f,f_cols,'x')"
                                                                                        :disabled="cantedit"
                                                                                        color="red"
                                                                                        hide-details
                                                                                        ></v-checkbox>
                                                                                </v-flex>
                                                                                <v-flex xs3>
                                                                                    <span class="mono" style="font-size:12px" >{{f_cols.label_x}}</span>
                                                                                </v-flex>
                                                                            </v-layout>
                                                                        </v-flex>
                                                                    </v-layout>
                                                                </div>
                                                                <div v-if="fisik.type_form === 'XXV'" >
                                                                    <v-layout pl-2  pb-1 pt-1 v-for="(f_detail,kdx_detail) in fisik.details" v-if="fisik.show_all === 'Y'" wrap>
                                                                        <v-flex xs12 pa-1>
                                                                            <v-layout align-center  row>
                                                                                <v-flex xs4><span style="font-size:12px" >{{f_detail.label}}</span></v-flex>
                                                                                <v-flex xs2>
                                                                                    <v-layout align-center>
                                                                                        <v-checkbox 
                                                                                            class="mt-0 pt-0 shrink mr-2"
                                                                                            style="width:15px"
                                                                                            v-model="f_detail.chx_y"
                                                                                            @change="changeXXVChx(idx_f,f_detail,'y')"
                                                                                            :disabled="cantedit"
                                                                                            color="red"
                                                                                            hide-details
                                                                                        ></v-checkbox>
                                                                                        <span class="mono pl-1" style="font-size:12px" >{{f_detail.label_y}}</span>
                                                                                    </v-layout>
                                                                                </v-flex>
                                                                                <v-flex xs2>
                                                                                    <v-layout align-center>
                                                                                        <v-checkbox 
                                                                                            class="mt-0 pt-0 shrink mr-2"
                                                                                            style="width:15px"
                                                                                            v-model="f_detail.chx_x"
                                                                                            @change="changeXXVChx(idx_f,f_detail,'x')"
                                                                                            :disabled="cantedit"
                                                                                            color="red"
                                                                                            hide-details
                                                                                        ></v-checkbox>
                                                                                        <span class="mono pl-1" style="font-size:12px" >{{f_detail.label_x}}</span>
                                                                                    </v-layout>
                                                                                </v-flex>
                                                                                <v-flex xs4 pr-2>
                                                                                    <v-text-field
                                                                                        style="font-size:12px;margin-top:0;padding-top:0;line-height:25px!important"
                                                                                        v-model="f_detail.value"
                                                                                        :disabled="f_detail.disable_value === 'Y' || cantedit"
                                                                                        outline
                                                                                        single-line
                                                                                        hide-details
                                                                                    ></v-text-field>
                                                                                </v-flex>
                                                                            </v-layout>
                                                                        </v-flex>
                                                                    </v-layout>
                                                                </div>
                                                            </v-flex>
                                                        </v-layout>    
                                                    </v-card>
                                                </div>
                                                <v-card>
                                                    <v-layout row>
                                                        <v-flex xs12>
                                                            <v-subheader red--text text--lighten-1> SARAN</v-subheader>
                                                            <v-divider></v-divider>
                                                            <v-layout row wrap>
                                                                <v-flex xs12 pa-2>
                                                                    <v-text-field
                                                                        v-model="umum_saran"
                                                                        label="Isikan saran ..."
                                                                        :disabled="cantedit"
                                                                        outline
                                                                    ></v-text-field>
                                                                </v-flex>
                                                            </v-layout>
                                                        </v-flex>
                                                    </v-layout>    
                                                </v-card>
                                            </v-stepper-content>

                                            <v-stepper-content class="x_form" step="3">
                                                <div v-if="patient.details[0].template_name === 'UMUM_K3'" v-for="(k3,idx_k) in k3s">
                                                    <v-card class="mb-2">
                                                        <v-layout pb-2 row>
                                                            <v-flex xs12>
                                                                <v-subheader red--text text--lighten-1> 
                                                                    <v-btn v-if="k3.show_all === 'N'" @click="toggleDetailK3(idx_k)" style="min-width:30px;" small flat color="#fa8072"><v-icon small>add</v-icon></v-btn> 
                                                                    <v-btn v-if="k3.show_all === 'Y'" @click="toggleDetailK3(idx_k)" style="min-width:30px;" small flat color="#fa8072"><v-icon small>remove</v-icon></v-btn> 
                                                                    {{k3.title}}
                                                                    
                                                                    <!--<v-flex text-md-right>
                                                                        <v-btn v-if="riwayat.flag_normal === 'N'" @click="changeFlagNormal(idx_r)" small color="error"><v-icon class="pr-1" small>close</v-icon> {{riwayat.label_flag_normal}}</v-btn>
                                                                        <v-btn v-if="riwayat.flag_normal === 'Y'" @click="changeFlagNormal(idx_r)"  small color="info"><v-icon class="pr-1" small>check</v-icon> {{riwayat.label_flag_normal}}</v-btn>
                                                                    </v-flex>-->
                                                                </v-subheader>
                                                                <v-divider class="mb-2" ></v-divider>
                                                                <div v-if="k3.type_form === 'XVV'">
                                                                    <!--<v-layout v-if="riwayat.subtitle !== ''" class="pl-2 caption pb-2" row>{{riwayat.subtitle}}</v-layout>-->
                                                                    <v-layout pl-2  pb-1 pt-1 v-for="(k_detail,idk_detail) in k3.details" v-if="k3.show_all === 'Y'" wrap>
                                                                        <v-flex xs12>
                                                                            <v-layout align-center row>
                                                                                <v-flex xs6>
                                                                                    <v-layout align-center>
                                                                                    <v-checkbox 
                                                                                        style="width:15px"
                                                                                        class="mt-0 pt-0 shrink mr-2"
                                                                                         :disabled="cantedit"
                                                                                        v-model="k_detail.chx"
                                                                                        color="red"
                                                                                        hide-details
                                                                                    ></v-checkbox>
                                                                                    <span class="pl-2" style="font-size:12px" >{{k_detail.label}}</span>
                                                                                    </v-layout>
                                                                                </v-flex>
                                                                                <v-flex xs3 pl-1 pr-2>
                                                                                    <v-text-field
                                                                                        style="font-size:12px;margin-top:0;padding-top:0;line-height:25px!important"
                                                                                        outline
                                                                                         :disabled="cantedit"
                                                                                        v-model="k_detail.value_sumber"
                                                                                        single-line
                                                                                        placeholder="Sumber"
                                                                                        hide-details
                                                                                    ></v-text-field>
                                                                                </v-flex>
                                                                                <v-flex xs3 pl-1 pr-2>
                                                                                    <v-text-field
                                                                                        style="font-size:12px;margin-top:0;padding-top:0;line-height:25px!important"
                                                                                        outline
                                                                                         :disabled="cantedit"
                                                                                        v-model="k_detail.value_lama"
                                                                                        single-line
                                                                                        placeholder="Lama Pajanan"
                                                                                        hide-details
                                                                                    ></v-text-field>
                                                                                </v-flex>
                                                                            </v-layout>
                                                                            
                                                                        </v-flex>
                                                                        
                                                                    </v-layout>
                                                                </div>
                                                                
                                                               
                                                                
                                                            </v-flex>
                                                        </v-layout>    
                                                    </v-card>
                                                </div> 

                                                <div v-if="patient.details[0].template_name === 'UMUM_KONSUL'" >
                                                    <v-card>
                                                        <v-layout row>
                                                            <v-flex xs12>
                                                                <v-subheader red--text text--lighten-1> KONSULTASI</v-subheader>
                                                                <v-divider></v-divider>
                                                                <v-layout row wrap>
                                                                    <v-flex xs12 pa-2>
                                                                        <v-text-field
                                                                            v-model="konsul"
                                                                            label="Isikan konsultasi ..."
                                                                             :disabled="cantedit"
                                                                            outline
                                                                        ></v-text-field>
                                                                    </v-flex>
                                                                </v-layout>
                                                            </v-flex>
                                                        </v-layout>    
                                                    </v-card>
                                                </div>   

                                            
                                            </v-stepper-content>
                                        </v-stepper-items>
                                        </v-stepper>
                               </v-flex>
                            </v-layout>
                        </v-flex>
                    </v-layout>          
                </v-card>
            </v-flex>
        </v-layout>
        <one-dialog-print :title="printtitle" :width="printwidth" :height="500" :status="openprint" :urlprint="urlprint" @close-dialog-print="closePrint"></one-dialog-print>
    </div>     
</template>

<style scoped>
    .divider.x_step{
        border-color:#fff;
    }
    .x_form .v-text-field--outline>.v-input__control>.v-input__slot {
        align-items: stretch;
        min-height: 20px!important;
        margin-top:0;
        line-height:25px;
    }

    .x_form .v-text-field--outline.v-text-field--single-line input {
        margin-top: 0px!important;
        font-size:14px;
    }
    table, td, th {  
    border: 1px solid #ddd;
    text-align: left;
    }

    table {
    border-collapse: collapse;
    width: 100%;
    }

    th, td {
    padding-top: 5px;
    padding-bottom: 5px;
    padding-left: 8px;
    padding-right: 5px;
    }

    .mini-input .v-input{
        margin-top: 0px; 
    }

    .mini-input .v-input, .mini-input .v-input--selection-controls,.mini-input .v-input__slot{
        margin-top: 0px; 
        margin-bottom:0px;
        margin-left:3px;
    }
    .mini-input .v-messages{
        min-height:0px;
    }
    input.fhm-input{
        border: 1px solid black; 
        border-radius: 2px;
        -webkit-box-shadow: 
        inset 0 0 2px  rgba(0,0,0,0.1),
                0 0 4px rgba(0,0,0,0.1); 
        -moz-box-shadow: 
        inset 0 0 2px  rgba(0,0,0,0.1),
                0 0 4px rgba(0,0,0,0.1); 
        box-shadow: 
        inset 0 0 2px  rgba(0,0,0,0.1),
                0 0 4px rgba(0,0,0,0.1); 
        padding: 2px 4px;
        background: rgba(255,255,255,0.5);
        margin: 0 0 1px 0;
        width:30px;
        text-align:center;
    }
    th, td {
        padding-left: 15px;
        padding-right: 15px;
        padding-top: 10px;
        padding-bottom: 10px;
        text-align: left;
    }
    table.tform tr:nth-child(even) {
        background-color: #eee;
    }
    table.tform tr:nth-child(odd) {
        background-color: #fff;
    }
    .thgigi{
        width:50px!important;
        padding:5px!important;
        text-align:center;
    }
    .input_gigi{
        width:100%;
        border:1px solid grey;
        font-size:14px;
        text-align:center;
        line-height: 2;
        text-transform: uppercase;
    }
    .bggrey{
        background:#eee!important;
    }
    .background-black{
        background:black;
        color:#fff;
    }
    .background-teal{
        background:#009688;
        color:#fff;
    }
    .background-red{
        background:#f44336;
        color:#fff;
    }
    .background-brown{
        background:#795548;
        color:#fff;
    }
    .background-yellow-accent-4{
        background:#ffeb3b;
        color:#fff;
    }
    .background-info{
        background:#64b5f6;
        color:#fff;
    }
</style>

<script>
module.exports = {
    components : {
        'one-dialog-print':httpVueLoader('../../common/oneDialogPrintX.vue')
    },
    data: () => ({
        openprint:false,
        urlprint:'',
        printtitle:'',
        printwidth:600,
        requiredoctor:false,
        tab:1,
        cbx_1:false
    }),
    computed: {
        standart_bmi(){
            return this.$store.state.sample.standart_bmi
        },
        selected_standart_bmi:{
            get() {
                return this.$store.state.sample.selected_standart_bmi
            },
            set(val) {
                this.$store.commit("sample/update_selected_standart_bmi",val)
            }
        },
        cantedit:{
            get() {
                return this.$store.state.sample.cantedit
            },
            set(val) {
                this.$store.commit("sample/update_cantedit",val)
            }
        },
        tabs_fisik:{
            get() {
                return this.$store.state.sample.tabs_fisik
            },
            set(val) {
                this.$store.commit("sample/update_tabs_fisik",val)
            }
        },
        umum_saran:{
            get() {
                return this.$store.state.sample.umum_saran
            },
            set(val) {
                this.$store.commit("sample/update_umum_saran",val)
            }
        },
        konsul:{
            get() {
                return this.$store.state.sample.konsul
            },
            set(val) {
                this.$store.commit("sample/update_konsul",val)
            }
        },
        rows_riwayat(){
            return this.$store.state.sample.rows_riwayat
        },
        riwayats:{
            get() {
                return this.$store.state.sample.riwayats
            },
            set(val) {
                this.$store.commit("sample/update_riwayats",val)
            }
        },
        fisiks:{
            get() {
                return this.$store.state.sample.fisiks
            },
            set(val) {
                this.$store.commit("sample/update_fisiks",val)
            }
        },
        k3s:{
            get() {
                return this.$store.state.sample.k3s
            },
            set(val) {
                this.$store.commit("sample/update_k3s",val)
            }
        },
        xdialogaction:{
            get() {
                return this.$store.state.sample.dialog_action
            },
            set(val) {
                this.$store.commit("sample/update_dialog_action",val)
            }
        },
        xmsgaction:{
            get() {
                return this.$store.state.sample.msg_action
            },
            set(val) {
                this.$store.commit("sample/update_msg_action",val)
            }
        },
        xtests(){
            return this.$store.state.sample.selected_transaction.details
        },
        xlangs(){
            return this.$store.state.sample.langs
        },
        patient(){
            return this.$store.state.sample.selected_transaction
        },
        xdialogimage:{
            get() {
                return this.$store.state.sample.dialog_image
            },
            set(val) {
                this.$store.commit("sample/update_dialog_image",val)
            }
        },
        ximage() {
            return this.$store.state.sample.image
        },
        xdoctors(){
            return this.$store.state.sample.doctors
        },
        xselecteddoctor:{
            get() {
                return this.$store.state.sample.selected_doctor
            },
            set(val) {
                this.$store.commit("sample/update_selected_doctor",val)
            }
        },
        xdialogdoctor:{
            get() {
                return this.$store.state.sample.dialog_doctor
            },
            set(val) {
                this.$store.commit("sample/update_dialog_doctor",val)
            }
        },
        dialogtemplates:{
            get() {
                return this.$store.state.sample.dialog_template
            },
            set(val) {
                this.$store.commit("sample/update_dialog_template",val)
            }
        },
        xtemplates(){
            return this.$store.state.sample.templates
        },
        xselectedtemplate:{
            get() {
                return this.$store.state.sample.selected_template
            },
            set(val) {
                this.$store.commit("sample/update_selected_template",val)
            }
        },
        dialoglangs:{
            get() {
                return this.$store.state.sample.langs
            },
            set(val) {
                this.$store.commit("sample/update_item_langs",val)
            }
        },
        xselectedlang:{
            get() {
                return this.$store.state.sample.selected_lang
            },
            set(val) {
                this.$store.commit("sample/update_selected_lang",val)
            }
        },
        dialogprintlang:{
            get() {
                return this.$store.state.sample.dialog_print_lang
            },
            set(val) {
                this.$store.commit("sample/update_dialog_print_lang",val)
            }
        },
    }, 
    methods : {
        getcolortensi(row){
            console.log(row)
            var result = 'grey--text'

            if(row.standart === 'JNC-VII'){
                if(row.value_x === 'NORMAL'){
                    result = 'info--text'
                }
                if(row.value_x === 'PREHIPERTENSI'){
                    result = 'warning--text'
                }
                if(row.value_x === 'HIPERTENSI STADIUM 1'){
                    result = 'amber--text'
                }
                if(row.value_x === 'HIPERTENSI STADIUM 2'){
                    result = 'red--text'
                }
            }

            if(row.standart === 'JNC-VIII'){
                if(row.value_x === 'NORMAL'){
                    result = 'info--text'
                }
                if(row.value_x === 'ELEVATED'){
                    result = 'warning--text'
                }
                if(row.value_x === 'HIPERTENSI STAGE 1'){
                    result = 'amber--text'
                }
                if(row.value_x === 'HIPERTENSI STAGE 2'){
                    result = 'red--text'
                }
                if(row.value_x === 'HIPERTENSI STAGE 3'){
                    result = 'brown--text'
                }
            }

            if(row.standart === 'ESC/ESH'){
                if(row.value_x === 'OPTIMAL' || row.value_x === 'NORMAL'){
                    result = 'info--text'
                }
                if(row.value_x === 'HIGH NORMAL' || row.value_x === 'GRADE 1 HYPERTENSION'){
                    result = 'warning--text'
                }
                if(row.value_x === 'HIGH NORMAL' || row.value_x === 'GRADE 1 HYPERTENSION'){
                    result = 'amber--text'
                }
                if(row.value_x === 'GRADE 2 HYPERTENSION' || row.value_x === 'GRADE 3 HYPERTENSION'){
                    result = 'red--text'
                }
                if(row.value_x === 'ISOLATED SYSTOLIC HYPERTENSION'){
                    result = 'brown--text'
                }
            }

            //console.log(result)
            return result
        },
        changeStandartBMI(idx_f){
            var fisiks = this.fisiks
            var val_now = fisiks[idx_f].standart_bmi === 'who' ? 'asia_pacific':'who'
            fisiks[idx_f].standart_bmi = val_now
           // console.log('jalan')
            var idx_bmi = _.findIndex(fisiks[idx_f].details, function(o) { return o.id_code == 'status_gizi_4'})    
            var bmi_value = fisiks[idx_f].details[idx_bmi].value

            if(bmi_value && !isNaN(bmi_value)){
                var classx = ''
                if(fisiks[idx_f].standart_bmi === 'asia_pacific'){
                    if(bmi_value < 18.5)
                    classx = 'Underweight'

                    if(bmi_value >= 18.5 && bmi_value < 23)
                        classx = 'Normal'

                    if(bmi_value >= 23 && bmi_value < 25)
                        classx = 'Overweight'

                    if(bmi_value >= 25 && bmi_value < 30)
                        classx = 'Obese I'

                    if(bmi_value >= 30)
                        classx = 'Obese II'
                }

                if(fisiks[idx_f].standart_bmi === 'who'){
                    //console.log(bmi_value)
                    if(bmi_value < 18.5)
                    classx = 'Underweight'

                    if(bmi_value >= 18.5 && bmi_value < 25){
                        classx = 'Normal'
                       // console.log("normal")
                    }
                        

                    if(bmi_value >= 25 && bmi_value < 30){
                        classx = 'Overweight'
                       // console.log("iyyaaa")
                    }

                    if(bmi_value >= 30)
                        classx = 'Obese'
                }

                var idx_xclass = _.findIndex(fisiks[idx_f].details, function(o) { return o.id_code == 'status_gizi_6'})   
                console.log(idx_xclass) 
                fisiks[idx_f].details[idx_xclass].value = classx
                this.$store.commit("sample/update_fisiks",fisiks)
            }
        },
        changeXVSChx(idx_f,idx_s,row){
            var fisiks = this.fisiks
            var isnormal = row.is_normal
            if(isnormal === 'Y' && row.chx){
                fisiks[idx_f].details[idx_s].details.forEach(function(entry,index) {
                    if(fisiks[idx_f].details[idx_s].details[index].is_normal === 'N'){
                        fisiks[idx_f].details[idx_s].details[index].chx = false 
                        fisiks[idx_f].details[idx_s].details[index].value = ''
                    }
                })
                this.$store.commit("sample/update_fisiks",fisiks)
            }

            if(isnormal === 'N' && row.chx){
                var n_idx = _.findIndex(fisiks[idx_f].details[idx_s].details, function(o) { return o.is_normal === 'Y'})
                //console.log(n_idx)
                fisiks[idx_f].details[idx_s].details[n_idx].chx = false 
                fisiks[idx_f].details[idx_s].details[n_idx].value = '' 
                this.$store.commit("sample/update_fisiks",fisiks)
            }
        },
        changeXVChx(idx_f,row){
            //console.log(idx_f)
            var fisiks = this.fisiks
            var isnormal = row.is_normal
            if(isnormal === 'Y' && row.chx){
                fisiks[idx_f].details.forEach(function(entry,index) {
                    if(fisiks[idx_f].details[index].is_normal === 'N'){
                        fisiks[idx_f].details[index].chx = false 
                        fisiks[idx_f].details[index].value = ''
                    }
                })
                this.$store.commit("sample/update_fisiks",fisiks)
            }

            if(isnormal === 'N' && row.chx){
                var n_idx = _.findIndex(fisiks[idx_f].details, function(o) { return o.is_normal === 'Y'})
                //console.log(n_idx)
                fisiks[idx_f].details[n_idx].chx = false 
                fisiks[idx_f].details[n_idx].value = '' 
                this.$store.commit("sample/update_fisiks",fisiks)
            }
            //console.log("detailss")
           // console.log(fisiks[idx_f])
            
        },
        changeToothValue(position,tooth,icx){
            var fisiks = this.fisiks
            var pos = -1
            if(position === 'atasketiga')
                pos = 0
            if(position === 'ataskedua')
                pos = 1
            if(position === 'atas')
                pos = 2
            if(position === 'bawah')
                pos = 3
            if(position === 'bawahkedua')
                pos = 4
            if(position === 'bawahketiga')
                pos = 5

            var idx = _.findIndex(fisiks[icx].details[pos].details, function(o) { return o.id_code == tooth.id_code})
            fisiks[icx].details[pos].details[idx].value = tooth.value.toUpperCase()
            console.log(fisiks[icx].details[pos].details[idx])
            this.$store.commit("sample/update_fisiks",fisiks)
        },
        changeXXVChx(idx_f,row,status){
            var fisiks = this.fisiks

            var idx = _.findIndex(fisiks[idx_f].details, function(o) { return o.id_code == row.id_code})
            if(status == 'y'){
                var now_y = fisiks[idx_f].details[idx].chx_y
                fisiks[idx_f].details[idx].chx_x = now_y === true ?false:true
                if(now_y)
                    fisiks[idx_f].details[idx].disable_value = 'Y'
                else
                    fisiks[idx_f].details[idx].disable_value = 'N'
            }
            if(status == 'x'){
                var now_x = fisiks[idx_f].details[idx].chx_x
                fisiks[idx_f].details[idx].chx_y = now_x === true ?false:true
                if(now_x)
                    fisiks[idx_f].details[idx].disable_value = 'N'
                else
                    fisiks[idx_f].details[idx].disable_value = 'Y'
            }
            
            this.$store.commit("sample/update_fisiks",fisiks)
        },
        changeVXXChx(idx_f,row,status){
            var fisiks = this.fisiks
            //console.log(row)
            var idx = _.findIndex(fisiks[idx_f].details, function(o) { return o.id_code == row.id_code})
           
            if(status == 'y'){
                var now_y = fisiks[idx_f].details[idx].chx_y
                fisiks[idx_f].details[idx].chx_x = now_y?false:true
            }

            if(status == 'x'){
                var now_x = fisiks[idx_f].details[idx].chx_x
                fisiks[idx_f].details[idx].chx_y = now_x?false:true
            }
            
            this.$store.commit("sample/update_fisiks",fisiks)
        },
        changeVXXValue(idx_f,row){
            var fisiks = this.fisiks
           // console.log(row)
            if(row.table_name === 'status_gizi'){
               // console.log(row)
                var idx_berat = _.findIndex(fisiks[idx_f].details, function(o) { return o.id_code == 'status_gizi_1'})
                var val_berat = parseFloat(fisiks[idx_f].details[idx_berat].value)
                //console.log(val_berat)
                var idx_tinggi = _.findIndex(fisiks[idx_f].details, function(o) { return o.id_code == 'status_gizi_2'})
                var val_tinggi = parseFloat(fisiks[idx_f].details[idx_tinggi].value)
                //console.log(val_tinggi)
                var idx_bmi = _.findIndex(fisiks[idx_f].details, function(o) { return o.id_code == 'status_gizi_4'})
                var val_bmi = (val_berat / ((val_tinggi/100)*(val_tinggi/100))).toFixed(2)
               // console.log(val_bmi)
                fisiks[idx_f].details[idx_bmi].value = val_bmi
                var bmi_value = val_bmi
                if(bmi_value && !isNaN(bmi_value)){
                    var classx = ''
                    if(fisiks[idx_f].standart_bmi === 'asia_pacific'){
                        if(bmi_value < 18.5)
                            classx = 'Underweight'

                        if(bmi_value >= 18.5 && bmi_value < 23)
                            classx = 'Normal'

                        if(bmi_value >= 23 && bmi_value < 25)
                            classx = 'Overweight'

                        if(bmi_value >= 25 && bmi_value < 30)
                            classx = 'Obese I'

                        if(bmi_value >= 30)
                            classx = 'Obese II'
                    }

                    if(fisiks[idx_f].standart_bmi === 'who'){
                        if(bmi_value < 18.5)
                            classx = 'Underweight'

                        if(bmi_value >= 18.5 && bmi_value < 25){
                            classx = 'Normal'
                            // console.log("normal")
                        }
                                

                        if(bmi_value >= 25 && bmi_value < 30){
                            classx = 'Overweight'
                            // console.log("iyyaaa")
                        }

                        if(bmi_value >= 30)
                            classx = 'Obese'
                    }

                    var idx_xclass = _.findIndex(fisiks[idx_f].details, function(o) { return o.id_code == 'status_gizi_6'})    
                    fisiks[idx_f].details[idx_xclass].value = classx
                        
                }

                this.$store.commit("sample/update_fisiks",fisiks)
            }
        },
        changeVXXValuePlus(idx_f,row){
            var fisiks = this.fisiks
            var idx_tensi = _.findIndex(fisiks[idx_f].details, function(o) { return o.id_code == 'tanda_vital_5'})
            var standart = fisiks[idx_f].details[idx_tensi].standart
            console.log(standart)
            if(row.table_name === 'tanda_vital'){
               var result = fisiks[idx_f].details[idx_tensi].value_x
               var xval = fisiks[idx_f].details[idx_tensi].value
               if(xval !== ''){
                    var arr_val = xval.split("/")
                    var sistolik = arr_val[0]
                    var diastolik = arr_val[1]
                    if(standart === 'JNC-VII'){
                        if(sistolik < 120 && diastolik < 80){
                            result = 'NORMAL'
                        }
                        if((sistolik >= 120 && sistolik <= 139) || (diastolik >= 80 && diastolik <= 89)){
                            result = 'PREHIPERTENSI'
                        }
                        if((sistolik >= 140 && sistolik <= 159) || (diastolik >= 90 && diastolik <= 99)){
                            result = 'HIPERTENSI STADIUM 1'
                        }
                        if((sistolik >= 160) || (diastolik >= 100)){
                            result = 'HIPERTENSI STADIUM 2'
                        }
                    }
                    if(standart === 'JNC-VIII'){
                        if(sistolik < 120 && diastolik < 80){
                            result = 'NORMAL'
                        }
                        if((sistolik >= 120 && sistolik <= 129) && (diastolik < 80)){
                            result = 'ELEVATED'
                        }
                        if((sistolik >= 130 && sistolik <= 139) || (diastolik >= 80 && diastolik <= 89)){
                            result = 'HIPERTENSI STAGE 1'
                        }
                        if(sistolik >= 140 || diastolik >= 90){
                            result = 'HIPERTENSI STAGE 2'
                        }
                        /*if((sistolik >= 180) || (diastolik >= 120)){
                            result = 'HIPERTENSI STAGE 3'
                        }*/
                    }
                    if(standart === 'ESC/ESH'){
                        if(sistolik < 120 && diastolik < 80){
                            result = 'OPTIMAL'
                        }
                        if((sistolik >= 120 && sistolik <= 129) || (diastolik >= 80 && diastolik <= 84)){
                            result = 'NORMAL'
                        }
                        if((sistolik >= 130 && sistolik <= 139) || (diastolik >= 85 && diastolik <= 89)){
                            result = 'HIGH NORMAL'
                        }
                        if((sistolik >= 140 && sistolik <= 159) || (diastolik >= 90 && diastolik <= 99)){
                            result = 'GRADE 1 HYPERTENSION'
                        }
                        if((sistolik >= 160 && sistolik <= 179) || (diastolik >= 100 && diastolik <= 109)){
                            result = 'GRADE 2 HYPERTENSION'
                        }
                        if(sistolik >= 180 || diastolik <= 110){
                            result = 'GRADE 3 HYPERTENSION'
                        }
                        if(sistolik >= 140 && diastolik >= 90){
                            result = 'ISOLATED SYSTOLIC HYPERTENSION'
                        }
                    }
               }
                fisiks[idx_f].details[idx_tensi].value_x = result
                this.$store.commit("sample/update_fisiks",fisiks)
            }
        },
        changeStatusTooth(idx_f){
            var fisiks = this.fisiks
            //var idx_tensi = _.findIndex(fisiks[idx_f].details, function(o) { return o.id_code == 'tanda_vital_5'})
            //console.log("tooth-status")
            //console.log(fisiks[idx_f])
            fisiks[idx_f].is_normal = fisiks[idx_f].is_normal === "Y" ?"N":"Y"
            if(fisiks[idx_f].is_normal === 'Y'){
                fisiks[idx_f].details.forEach(function(value,idx){
                    let details_x = value.details
                    details_x.forEach(function(item,index){
                        console.log('detail_x')
                        console.log(fisiks[idx_f].details[idx].details[index])
                        fisiks[idx_f].details[idx].details[index].value = ""
                    })
                })
            }
            
            this.$store.commit("sample/update_fisiks",fisiks)
        },
        changStandartTensi(idx_f,row){
            var fisiks = this.fisiks
            var idx_tensi = _.findIndex(fisiks[idx_f].details, function(o) { return o.id_code == 'tanda_vital_5'})
            var standart = fisiks[idx_f].details[idx_tensi].standart //=== 'JNC-VII' ? 'JNC-VIII':'JNC-VII'
            if(standart === 'JNC-VII'){
                standart = 'JNC-VIII'
                console.log(1)
            }else if(standart === 'JNC-VIII'){
                standart = 'ESC/ESH'
                console.log(2)
            }
            else{
                console.log(3)
                standart = 'JNC-VII'
            }
            console.log(standart)
            fisiks[idx_f].details[idx_tensi].standart = standart
            if(row.table_name === 'tanda_vital'){
               var result = fisiks[idx_f].details[idx_tensi].value_x
               var xval = fisiks[idx_f].details[idx_tensi].value
               if(xval !== ''){
                    var arr_val = xval.split("/")
                    var sistolik = arr_val[0]
                    var diastolik = arr_val[1]
                    if(standart === 'JNC-VII'){
                        if(sistolik < 120 && diastolik < 80){
                            result = 'NORMAL'
                        }
                        if((sistolik >= 120 && sistolik <= 139) || (diastolik >= 80 && diastolik <= 89)){
                            result = 'PREHIPERTENSI'
                        }
                        if((sistolik >= 140 && sistolik <= 159) || (diastolik >= 90 && diastolik <= 99)){
                            result = 'HIPERTENSI STADIUM 1'
                        }
                        if((sistolik >= 160) || (diastolik >= 100)){
                            result = 'HIPERTENSI STADIUM 2'
                        }
                    }
                    if(standart === 'JNC-VIII'){
                        if(sistolik < 120 && diastolik < 80){
                            result = 'NORMAL'
                        }
                        if((sistolik >= 120 && sistolik <= 129) && (diastolik < 80)){
                            result = 'ELEVATED'
                        }
                        if((sistolik >= 130 && sistolik <= 139) || (diastolik >= 80 && diastolik <= 89)){
                            result = 'HIPERTENSI STAGE 1'
                        }
                        if(sistolik >= 140 || diastolik >= 90){
                            result = 'HIPERTENSI STAGE 2'
                        }
                        /*if((sistolik >= 180) || (diastolik >= 120)){
                            result = 'HIPERTENSI STAGE 3'
                        }*/
                    }
                    if(standart === 'ESC/ESH'){
                        if(sistolik < 120 && diastolik < 80){
                            result = 'OPTIMAL'
                        }
                        if((sistolik >= 120 && sistolik <= 129) || (diastolik >= 80 && diastolik <= 84)){
                            result = 'NORMAL'
                        }
                        if((sistolik >= 130 && sistolik <= 139) || (diastolik >= 85 && diastolik <= 89)){
                            result = 'HIGH NORMAL'
                        }
                        if((sistolik >= 140 && sistolik <= 159) || (diastolik >= 90 && diastolik <= 99)){
                            result = 'GRADE 1 HYPERTENSION'
                        }
                        if((sistolik >= 160 && sistolik <= 179) || (diastolik >= 100 && diastolik <= 109)){
                            result = 'GRADE 2 HYPERTENSION'
                        }
                        if(sistolik >= 180 || diastolik <= 110){
                            result = 'GRADE 3 HYPERTENSION'
                        }
                        if(sistolik >= 140 && diastolik >= 90){
                            result = 'ISOLATED SYSTOLIC HYPERTENSION'
                        }
                    }
               }
                fisiks[idx_f].details[idx_tensi].value_x = result
                this.$store.commit("sample/update_fisiks",fisiks)
            }
        },  
        generate_rows(details){
            //console.log(details)
            var riwayats = details
            var row_riwayats = []
            var rows = []
            riwayats.forEach(function(item,index){
                rows.push(item)
                if(index%2 !== 0 || index === riwayats.length - 1 ){
                    row_riwayats.push(rows)
                    rows = []
                }
            })
            //console.log(row_riwayats)
            return row_riwayats
        },
        changeFlagNormal(idx){
            var riwayats = this.$store.state.sample.riwayats
            var old_val = riwayats[idx].flag_normal
            riwayats[idx].flag_normal = old_val === 'Y'?'N':'Y'
            if(riwayats[idx].flag_normal === 'Y'){
                riwayats[idx].details.forEach((item) => item.chx = false)
                riwayats[idx].details.forEach((item) => item.value = '')
            }
            this.$store.commit("sample/update_riwayats",riwayats)
        },
        toggleDetailRiwayat(idx){
            var riwayats = this.$store.state.sample.riwayats
            var old_val = riwayats[idx].show_all
            riwayats[idx].show_all = old_val === 'Y'?'N':'Y'
            this.$store.commit("sample/update_riwayats",riwayats)
        },
        toggleDetailFisik(idx){
            var fisiks = this.$store.state.sample.fisiks
            var old_val = fisiks[idx].show_all
            fisiks[idx].show_all = old_val === 'Y'?'N':'Y'
            this.$store.commit("sample/update_fisiks",fisiks)
        },
        toggleDetailK3(idx){
            var k3s = this.$store.state.sample.k3s
            var old_val = k3s[idx].show_all
            k3s[idx].show_all = old_val === 'Y'?'N':'Y'
            this.$store.commit("sample/update_k3s",k3s)
        },
        selectedLang(value){
            return {id:value.language_id,name:value.language_name}
        },
        selectedlangName(value){
            return value.language_name
        },
         check_saved(test){
            var trx = this.$store.state.sample.selected_transaction
            if(trx.details[0].template_name === 'UMUM' || trx.details[0].template_name === 'UMUM_K3' || trx.details[0].template_name === 'UMUM_KONSUL'){
                return this.$store.state.sample.show_print
            }
            else{
                var arrdetails = test.details
                var notempty = _.filter(arrdetails, function(o) { return o.result_value_before !== '' })
                //console.log(notempty)
                if(notempty.length  === 0)
                    return false
                else
                    return true
            }
            
        },
        selectLang(trx,lang){

            var arr = this.$store.state.sample.selected_transaction
            var arrdetails = arr.details
            let idx = _.findIndex(arrdetails, function(o) { return o.trx_id == trx.trx_id })

            this.$store.dispatch("sample/getrstbylang",{
                trx:trx,
                lang:lang,
                selected_trx:this.$store.state.sample.selected_transaction,
                idx:idx,
                detail:arrdetails[idx]})
        },
        changeResult(){
            this.$store.commit("sample/update_no_save",1)
        },
         changeFlagPrint(value,rst_idx,test_idx){
            var selected_patient = this.$store.state.sample.selected_transaction
            console.log(selected_patient)
            selected_patient.details[test_idx].details[rst_idx].flag_print = value === 'Y' ?'N':'Y'
            //console.log(selected_patient[test_idx][rst_idx])
            this.$store.dispatch("sample/save_flagprint",{selected_trx:selected_patient,row:selected_patient.details[test_idx].details[rst_idx]})
        },
        saveResult(trx,act){
            var ar = this.$store.state.sample.transactions
            var arr = this.$store.state.sample.selected_transaction
            let idx = _.findIndex(ar, function(o) { return o.trx_id == arr.trx_id })
            var template = arr.details[0].template_name 
            var error_msg = []
            if(template === 'UMUM' || template === 'UMUM_K3' || template === 'UMUM_KONSUL'){
                var go_action  = true
                var riwayats = this.riwayats
                riwayats.forEach(function(item,index){
                    //console.log(item.flag_normal)
                    if(item.flag_normal === 'N'){
                        var count_y = _.filter(item.details, function(o) { return o.chx }).length
                        if(item.type_form === 'XVS'){
                            count = 0
                            item.details.forEach(function(entry) {
                                count_y += _.filter(entry.details, function(o) { return o.chx }).length
                            })
                        }
                            
                        console.log(item)
                        console.log(count_y)
                        if(count_y === 0){
                            go_action = false
                            var x_msg = ''
                            if(item.title === 'KELUHAN SAAT INI')
                                var x_msg = "Menunggu pesan tanpa jawaban, mengharap balasan meski teracuhkan, isian <span style='color:red'>"+item.title+"</span> tolong diperhatikan, kalo ada keluhan silahkan dituliskan."
                            if(item.title === 'RIWAYAT POBIA')
                                var x_msg = "Wanita itu bernama via, cantik...riang dan jenaka, isian <span style='color:red'>"+item.title+"</span> tolong dibaca, kalo benar ada pobia harap dicentang saja."
                            if(item.title === 'RIWAYAT PENYAKIT')
                                var x_msg = "Ditinggalkan sendiri memang sakit, namun jangan menyerah untuk bangkit, isian <span style='color:red'>"+item.title+"</span> jangan dulu dirakit, kalo ada riwayat penyakit tolong disungkit."
                            if(item.title === 'RIWAYAT PENYAKIT KELUARGA')
                                var x_msg = "Bahagia itu sederhana, kalo tak sederhana namanya cinta, isian <span style='color:red'>"+item.title+"</span> mungkin ada yang lupa, belum ada yang dicentang, padahal maksudnya ada."
                            if(item.title === 'RIWAYAT KEBIASAAN HIDUP')
                                var x_msg = "Berkerja siang malam, untuk kelangsungan hidup, isian <span style='color:red'>"+item.title+"</span> salah satu minta dicakup."
                            if(item.title === 'RIWAYAT KONSUMSI OBAT TERATUR')
                                var x_msg = "Minum kopi, jangan sambil tidur, isian <span style='color:red'>"+item.title+"</span> silahkan diatur, barang kali lupa tertutur."
                            
                            
                            error_msg.push(x_msg)
                        }
                    }
                })

                if(go_action){
                    this.$store.dispatch("sample/savefisik",{
                        template:template,
                        startdate:this.$store.state.sample.start_date,
                        enddate: this.$store.state.sample.end_date,
                        search:this.$store.state.sample.name_lab,
                        stationid:this.$store.state.sample.selected_station.id,
                        groupid:this.$store.state.sample.select_item_group.id,
                        subgroupid:this.$store.state.sample.select_item_subgroup.id,
                        lastid:arr.trx_id,
                        trx:trx,
                        trx_numbering:arr.ordernumber,
                        riwayats:riwayats,
                        fisiks:this.fisiks,
                        umum_saran:this.umum_saran,
                        konsul:this.konsul,
                        k3s:this.k3s,
                        act:template,
                        action:act
                    })
                }
                else{
                    var msg = error_msg.join('</br></br>')
                    //var msg = "Menunggu pesan tanpa jawaban, mengharap balasan meski teracuhkan, isian <span style='color:red'>"+error_msg.join(",")+"</span> tolong diperhatikan, kalo ada keluhan tolong dituliskan"
                    this.$store.commit("sample/update_msg_info",msg)
                    this.$store.commit("sample/update_open_dialog_info",true)
                }
            }else{
                this.$store.dispatch("sample/saveresult",{
                    startdate:this.$store.state.sample.start_date,
                    enddate: this.$store.state.sample.end_date,
                    search:this.$store.state.sample.name_lab,
                    stationid:this.$store.state.sample.selected_station.id,
                    groupid:this.$store.state.sample.select_item_group.id,
                    subgroupid:this.$store.state.sample.select_item_subgroup.id,
                    lastid:arr.trx_id,
                    trx:trx,
                    trx_numbering:arr.ordernumber,
                    act:act
                })
            }
        },
        val1(trx,act){
            //console.log(act)
            if(parseInt(trx.doctor_id) === 0){
                var msg = "Orang sakit diperiksa dokter, kalau kosong tiada yang periksa"
                this.$store.commit("sample/update_msg_info",msg)
                this.$store.commit("sample/update_open_dialog_info",true)
            }
            else{
                this.$store.commit("sample/update_act",act)
                this.$store.commit("sample/update_last_trx",trx)
                var arr = this.$store.state.sample.selected_transaction
                var msg = "Anda yakin akan melakukan verifikasi untuk pemeriksaan "+trx.test_name+" dari pasien "+arr.patient_fullname+" ?"
                this.$store.commit("sample/update_msg_action",msg)
                this.$store.commit("sample/update_dialog_action",true)
            }
        },
        unval1(trx,act){
            console.log(act)
            this.$store.commit("sample/update_act",act)
            this.$store.commit("sample/update_last_trx",trx)
            var arr = this.$store.state.sample.selected_transaction
            var msg = "Anda yakin akan membatalkan verifikasi untuk pemeriksaan "+trx.test_name+" dari pasien "+arr.patient_fullname+" ?"
            this.$store.commit("sample/update_msg_action",msg)
            this.$store.commit("sample/update_dialog_action",true)
        },
        val2(trx,act){
            console.log(act)
            this.$store.commit("sample/update_act",act)
            this.$store.commit("sample/update_last_trx",trx)
            var arr = this.$store.state.sample.selected_transaction
            var msg = "Anda yakin akan melakukan validasi untuk pemeriksaan "+trx.test_name+" dari pasien "+arr.patient_fullname+" ?"
            this.$store.commit("sample/update_msg_action",msg)
            this.$store.commit("sample/update_dialog_action",true)
        },
        unval2(trx,act){
            console.log(act)
            this.$store.commit("sample/update_act",act)
            this.$store.commit("sample/update_last_trx",trx)
            var arr = this.$store.state.sample.selected_transaction
            var msg = "Anda yakin akan membatalkan validasi untuk pemeriksaan "+trx.test_name+" dari pasien "+arr.patient_fullname+" ?"
            this.$store.commit("sample/update_msg_action",msg)
            this.$store.commit("sample/update_dialog_action",true)
        },
        lama_print(trx,act){
            console.log(act)
            this.$store.commit("sample/update_act",act)
            this.$store.commit("sample/update_last_trx",trx)
            this.printwidth = 1028
            this.printtitle = ""
            let idx = trx.trx_id
            let user = one_user()
            var d = new Date();
            var n = d.getTime()
            var rptname = 'rpt_hasil_so'
            if(trx.language_name === 'EN')
                rptname = 'rpt_hasil_so_eng'

            this.urlprint = "/birt/run?__report=report/one/lab/"+rptname+".rptdesign&__format=pdf&username="+user.M_UserUsername+"&PID="+idx+'&PLang='+trx.language_id+'&tm='+n
            
            this.openprint = true
        },
        doPrintAfterLang(){
            this.dialogprintlang = false
            var trx =  this.$store.state.sample.selected_test
            var trx_selected =  this.$store.state.sample.selected_transaction
            console.log(trx)
            var idx_true = _.findIndex(this.dialoglangs, item => item.chex === 'Y')
            this.xselectedlang = this.dialoglangs[idx_true]
            this.printwidth = 1028
            this.printtitle = ""
            let idx = trx.re_id
            let user = one_user()
            var d = new Date();
            var n = d.getTime()
            var rptname = ''
            var folder = 'lab'
            var rptname = 'rpt_hasil_so_layanan'
            if(trx.test_name.toUpperCase() === 'MANTHOUX TEST')
                rptname = 'rpt_hasil_so_manthoux'
            
            if(trx.language_name === 'EN'){
                rptname = 'rpt_hasil_so_layanan_eng'
                if(trx.test_name.toUpperCase() === 'MANTHOUX TEST')
                    rptname = 'rpt_hasil_so_manthoux_eng'
            }


            console.log(trx.test_name)
            console.log(rptname)
            var xurl = ""

            var template = trx_selected.details[0].template_name
            console.log(template)
             if(template === 'UMUM' || template === 'UMUM_K3' || template === 'UMUM_KONSUL'){
                folder = 'mcu'
                var typemcu = 'riwayat'
                if(this.tab === 1 && trx.language_name !== 'EN' ){
                    rptname = "mcu_riwayat"
                }
                if(this.tab !== 1 && trx.language_name !== 'EN' ){
                    rptname = "mcu_fisik"
                    typemcu = "fisik"
                }
                console.log(this.tab)
                xurl = "/birt/run?__report=report/one/mcu/"+rptname+".rptdesign&__format=pdf&PID="+idx+"&PLang="+trx.language_id+"&PType="+typemcu+"&username="+user.M_UserUsername+"&tm="+n
                console.log(xurl)
             }
             else{
                xurl = "/birt/run?__report=report/one/"+folder+"/"+rptname+".rptdesign&__format=pdf&username="+user.M_UserUsername+"&PID="+idx+'&PLang='+trx.language_id+'&tm='+n
             
             }

            this.urlprint = xurl
            console.log(this.urlprint)
            
            this.openprint = true
        },
        print(trx,act){
           // console.log(trx)
            this.dialogprintlang = true
            var nowlang = trx.langs
            console.log(trx)
            _.forEach(nowlang, function(num) { num.chex = 'N' })
            var lang_idx = _.findIndex(nowlang, function(o) { return o.id == trx.language_id })
            nowlang[lang_idx].chex = 'Y'
            this.$store.commit("sample/update_item_langs",nowlang )
            this.xselectedlang = trx.langs[0]
            this.$store.commit("sample/update_selected_test",trx)
            this.$store.commit("sample/update_act",act)
            this.$store.commit("sample/update_last_trx",trx)
            
        },
        closePrint(){
            this.openprint = false
            var prm = this.$store.state.sample.last_trx
            this.$store.dispatch("sample/printcount",prm)
        },
        savedoctor(){
            var prm = {}
            prm.selected_detail = this.$store.state.sample.selected_detail
            prm.selected_doctor = this.xselecteddoctor
            this.$store.dispatch("sample/savedoctor",prm)
        },
        closeDialogAction(){
            var trx = this.$store.state.sample.last_trx
            var act = this.$store.state.sample.act
            this.saveResult(trx,act)
        },
        opendialogdoctor(test){
            this.$store.commit("sample/update_selected_detail",test)
            this.$store.commit("sample/update_doctors",test.doctors)
            this.xselecteddoctor = {}
            if(test.doctor_id !== 0 || test.doctor_id !== '0'){
                this.xselecteddoctor = {doctor_id:test.doctor_id,doctor_fullname:test.doctor_fullname}
            }
            this.xdialogdoctor = true
        },
        openImage(value){
            this.$store.commit("sample/update_selected_photo",value)
            this.$store.commit("sample/update_image",value.newname)
            this.$store.commit("sample/update_dialog_image",true)
        },
        pasteTemplate(rst,idx){
            this.idx_test = idx
            var seltrx = this.$store.state.sample.selected_transaction
            var datax = seltrx.details[idx] 
            if(datax.status === 'NEW'){
                var prm =   {
                                idx:idx,
                                template_id:datax.template_id,
                                doctor_id:datax.doctor_id,
                                language_id:datax.language_id,
                                test_id:datax.test_id}
                this.$store.dispatch("sample/gettemplate",prm)
            }
        },
        doPasteTemplate(){
            var seltrx = this.$store.state.sample.selected_transaction
            //console.log(seltrx)
            var temp_val = this.$store.state.sample.selected_template.details  
            var test_idx = this.idx_test
            
            seltrx.details[test_idx].details.forEach(function(temp,index) {
                var template_detail_id = seltrx.details[test_idx].details[index].template_detail_id
                var value_now = seltrx.details[test_idx].details[index].result_value
                var filter_temp = _.filter(temp_val, function(o) { return o.template_detail_id === template_detail_id })
                //console.log(filter_temp)
                if(filter_temp.length > 0 && ( !value_now || value_now === '')){
                    seltrx.details[test_idx].details[index].result_value = filter_temp[0].value
                }
                    
            })
            
            this.$store.commit("update_selected_transaction",seltrx)
            this.dialogtemplates = false
        }

    }
}
</script>
