<template>
    <v-layout class="fill-height" column>
        <v-dialog
            v-model="search_patient"
            max-width="290" persistent
            >
            <v-card>
                <v-card-title class="headline">Sedang mengunduh... </v-card-title>

                <v-card-text class="text-xs-center">
                    <v-progress-circular
      :size="70"
      :width="7"
      color="red"
      indeterminate
    ></v-progress-circular>      </v-card-text>

                
            </v-card>
            </v-dialog>
        <v-dialog
        
            v-model="dialog_not_found.status"
            width="30%"
            >
            

            <v-card>
                <v-card-title
                dark
                class="title white--text red lighten-2"
                primary-title
                >
                Not Found
                </v-card-title>

                <v-card-text>
                {{dialog_not_found.message}}
                </v-card-text>

                <v-divider></v-divider>

                <v-card-actions>
                <v-spacer></v-spacer>
                <v-btn
                    color="grey"
                    flat
                    @click="dialog_not_found.status = false"
                >
                    Tutup
                </v-btn>
                </v-card-actions>
            </v-card>
            </v-dialog>
        <v-dialog v-model="dialogsuccess" persistent max-width="290">
            <v-card>
                <v-card-title color="success" class="headline">Berhasil !</v-card-title>
                <v-card-text>
                    {{msgsuccess}}
                </v-card-text>
                <v-card-actions>
                    <v-spacer></v-spacer>
                    <v-btn color="green darken-1" flat @click="closeDialogSuccess">OK</v-btn>
                </v-card-actions>
            </v-card>
        </v-dialog>
        <v-card>
            <v-card-title>
                DATA PASIEN NASIONAL
                <v-spacer></v-spacer>
                <v-btn color="blue ligthen-3" small dark v-if="selected_patient && !_.isEmpty(selected_patient)"  @click="editPasien()">EDIT DATA PASIEN CABANG [{{selected_patient.M_BranchCode}}]</v-btn>
            </v-card-title>
            <v-divider></v-divider>
            <v-card-text>
                <v-layout row>
                    <v-flex xs12 pl-2 pr-2 pt-0 pb-2>
                        <v-data-table :headers="headers" :items="patients" :loading="isLoading" hide-actions class="elevation-1">
                            <template slot="items" slot-scope="props">
                                <td class="text-xs-left pa-2" v-bind:class="{'amber lighten-4':isSelected(props.item)}" @click="selectMe(props.item)">
                                    <v-list-tile avatar>
                                        <v-list-tile-content>
                                        <v-list-tile-title class="font-weight-black"><v-icon v-if="check_different_name(props.item)" color="red lighten-2">fa-exclamation</v-icon> <span v-if="get_titlename(props.item.Nat_PatientM_TitleID) !== ''">{{ get_titlename(props.item.Nat_PatientM_TitleID) }}</span> <span v-if="props.item.Nat_PatientPrefix">{{ props.item.Nat_PatientPrefix }}</span> <span v-if="props.item.Nat_PatientName">{{ props.item.Nat_PatientName }}</span> <span v-if="props.item.Nat_PatientSuffix">{{ props.item.Nat_PatientSuffix }}</span></v-list-tile-title>
                                        <v-list-tile-sub-title class="mono"><kbd>{{get_identitycard(props.item.Nat_PatientM_IdTypeID)}} : {{props.item.Nat_PatientIDNumber}}</kbd></v-list-tile-sub-title>
                                        </v-list-tile-content>
                                    </v-list-tile>
                                </td>
                                <td class="text-xs-left pa-2" v-bind:class="{'amber lighten-4':isSelected(props.item)}" @click="selectMe(props.item)">
                                    <v-icon v-if="check_different_ttl(props.item)" color="red lighten-2">fa-exclamation</v-icon> <span v-if="props.item.Nat_PatientPOB" style="text-transform: capitalize;">{{capitalizeFirstLetter(props.item.Nat_PatientPOB)}}</span><span v-if="!props.item.Nat_PatientPOB">-</span>, {{ formatDate(props.item.Nat_PatientDOB)}}
                                </td>
                                <td class="text-xs-left pa-2" v-bind:class="{'amber lighten-4':isSelected(props.item)}" @click="selectMe(props.item)">
                                    <v-icon v-if="check_different_sex(props.item)" color="red lighten-2">fa-exclamation</v-icon> {{get_sex(props.item.Nat_PatientM_SexID)}}
                                </td>
                                <td class="text-xs-center pa-2" v-bind:class="{'amber lighten-4':isSelected(props.item)}" @click="selectMe(props.item)">
                                    <v-icon v-if="check_different_hp(props.item)" color="red lighten-2">fa-exclamation</v-icon> {{ props.item.Nat_PatientHP}}
                                </td>
                                <td class="text-xs-center pa-2" v-bind:class="{'amber lighten-4':isSelected(props.item)}" @click="selectMe(props.item)">
                                    <v-icon v-if="check_different_email(props.item)" color="red lighten-2">fa-exclamation</v-icon> {{ props.item.Nat_PatientEmail}}
                                </td>
                                <td class="text-xs-left pa-2" v-bind:class="{'amber lighten-4':isSelected(props.item)}" @click="selectMe(props.item)">
                                    <template v-if="props.item.address.length > 0" v-for="(address,keyaddress) in props.item.address" >
                                        <div :key="keyaddress">
                                            <p class="mb-0" >
                                                <v-icon v-if="check_different_address(address)" color="red lighten-2">fa-exclamation</v-icon> <span class="mono grey--text text--darken-1">{{address.Nat_PatientAddressNote}}</span> 
                                            </p>
                                            <p class="pb-1" >
                                            <span>{{address.Nat_PatientAddressDescription}}</span>
                                            </p>
                                        </div>
                                        
                                    </template>
                                    
                                </td>
                                <td class="text-xs-left pa-2" v-bind:class="{'amber lighten-4':isSelected(props.item)}" @click="selectMe(props.item)">
                                    {{ props.item.M_BranchCode}}
                                </td>
                                <td class="text-xs-left pa-2" v-bind:class="{'amber lighten-4':isSelected(props.item)}" @click="selectMe(props.item)">
                                   
                                    <v-chip  v-if="props.item.isConfirmed == 'Y'" color="teal" text-color="white">
                                    <v-avatar>   
                                    <v-icon>check_circle</v-icon>
                                    </v-avatar>
                                    Verified
                                    </v-chip>
                                    <v-btn @click="clickVerif(props.item)" v-if="props.item.isConfirmed == 'N' && props.item.status === 'N'" dark color="grey"  >verify</v-btn>
                                    <v-btn @click="clickVerif(props.item)" v-if="props.item.isConfirmed == 'N' && props.item.status === 'Y'" dark color="success"  >verify</v-btn>
                                </td>
                            </template>
                        </v-data-table>
                    </v-flex>
                </v-layout>
            </v-card-text>
        </v-card>

        <v-card class="mt-2">
            <v-card-title>
                DATA PASIEN TERPILIH (LOKAL)
            </v-card-title>
            <v-divider></v-divider>
            <v-card-text>
                <v-layout row>
                    <v-flex xs12 pl-2 pr-2 pt-0 pb-2>
                        <v-data-table :headers="single_headers" :items="patient_selected" :loading="isLoading" hide-actions class="elevation-1">
                            <template slot="items" slot-scope="props">
                                <td class="text-xs-left pa-2">
                                    <v-list-tile avatar>
                                        <v-list-tile-content>
                                        <v-list-tile-title class="font-weight-black"><span v-if="props.item.M_TitleName !== ''">{{ props.item.M_TitleName }}</span> <span v-if="props.item.M_PatientPrefix">{{ props.item.M_PatientPrefix }}</span>  <span v-if="props.item.M_PatientRealName">{{ props.item.M_PatientRealName }}</span> <span v-if="props.item.M_PatientSuffix">{{ props.item.M_PatientSuffix }}</span> <span v-if="props.item.Nat_PatientSuffix">{{ props.item.Nat_PatientSuffix }}</span></v-list-tile-title>
                                        <v-list-tile-sub-title class="mono"><kbd>{{get_identitycard(props.item.M_PatientM_IdTypeID)}} : {{props.item.M_PatientIDNumber}}</kbd></v-list-tile-sub-title>
                                        </v-list-tile-content>
                                    </v-list-tile>
                                </td>
                                <td class="text-xs-left pa-2">
                                    <span v-if="props.item.M_PatientPOB" style="text-transform: capitalize;">{{capitalizeFirstLetter(props.item.M_PatientPOB)}}</span><span v-if="!props.item.M_PatientPOB">-</span>, {{ formatDate(props.item.M_PatientDOB)}}
                                </td>
                                <td class="text-xs-left pa-2">
                                    {{props.item.M_SexName}}
                                </td>
                                <td class="text-xs-center pa-2">
                                    {{ props.item.M_PatientHP}}
                                </td>
                                <td class="text-xs-center pa-2">
                                    {{ props.item.M_PatientEmail}}
                                </td>
                                <td class="text-xs-left pa-2">
                                    <template v-for="(address,keyaddress) in props.item.address" >
                                        <div :key="keyaddress">
                                            <p class="mb-0" >
                                                <span class="mono grey--text text--darken-1">{{address.M_PatientAddressNote}}</span> 
                                            </p>
                                            <p class="pb-1" >
                                            <span>{{address.M_PatientAddressDescription}}</span>
                                            </p>
                                        </div>
                                        
                                    </template>
                                   
                                </td>
                            </template>
                        </v-data-table>
                    </v-flex>
                </v-layout>
            </v-card-text>
        </v-card>
        
        <one-dialog-alert :status="openalertconfirmation" :msg="msgalertconfirmation" @forget-dialog-alert="forgetAlertConfirmation()"
            @close-dialog-alert="closeAlertConfirmation()"></one-dialog-alert>
        </v-layout>
</template>

<style scoped>

.loading {
  font-family: "Arial Black", "Arial Bold", Gadget, sans-serif;
  text-transform:uppercase;
  
  width:150px;
  text-align:center;
  line-height:50px;
  
  position:absolute;
  left:0;right:0;top:50%;
  margin:auto;
  transform:translateY(-50%);
}

.loading span {
  position:relative;
  z-index:999;
  color:#fff;
}
.loading:before {
  content:'';
  background:#61bdb6;
  width:128px;
  height:36px;
  display:block;
  position:absolute;
  top:0;left:0;right:0;bottom:0;
  margin:auto;
  
  animation:2s loadingBefore infinite ease-in-out;
}

@keyframes loadingBefore {
  0%   {transform:translateX(-14px);}
  50%  {transform:translateX(14px);}
  100% {transform:translateX(-14px);}
}


.loading:after {
  content:'';
  background:#ff3600;
  width:14px;
  height:60px;
  display:block;
  position:absolute;
  top:0;left:0;right:0;bottom:0;
  margin:auto;
  opacity:.5;
  
  animation:2s loadingAfter infinite ease-in-out;
}

@keyframes loadingAfter {
  0%   {transform:translateX(-50px);}
  50%  {transform:translateX(50px);}
  100% {transform:translateX(-50px);}
}
p.more_spacing {
  letter-spacing: 1.8px;
}
    .view {

}

.wrapper {
  position: relative;
  overflow: auto;
  border: 1px solid black;
  white-space: nowrap;
}

.another-col{
    background-color: white !important;
}
.sticky-col {
  position: -webkit-sticky;
  position: sticky;
  background-color: white !important;
}

.first-col {
  width: 100px;
  min-width: 100px;
  max-width: 100px;
  left: 0px;
}

.second-col {
  width: 150px;
  min-width: 150px;
  max-width: 150px;
  left: 100px;
}

    .searchbox .v-input.v-text-field .v-input__slot {
        min-height: 60px;
    }

    .searchbox .v-btn {
        min-height: 60px;
    }

    table.v-table tbody td,
    table.v-table tbody th {
        height: 40px;
    }

    table.v-table thead tr {
        height: 40px;
    }
</style>

    <script>
  
        module.exports = {
            components: {
                'one-dialog-info': httpVueLoader('../../common/oneDialogInfo.vue'),
                'one-dialog-alert': httpVueLoader('../../common/oneDialogAlert.vue')
            },
            mounted() {
                this.$store.dispatch("patient/getsexreg")
                var patientData = JSON.parse(localStorage.getItem('selpatient'))
                this.patient_selected = [patientData]
                this.$store.dispatch("patient/search", patientData)
                
            },
            methods: {
                editPasien(){
                    this.$store.commit("patient/update_dialog_form", true)
                },
                check_different_address(seladdress){
                    var rtn  = false
                    var patient = this.patient_selected[0]
                    if(patient){
                        patient.address.forEach(pataddress => {
                            //console.log(seladdress.Nat_PatientAddressDescription+" - "+pataddress.M_PatientAddressDescription)
                            let seldescription = seladdress.Nat_PatientAddressDescription.replace(/\s+/g, '')
                            let patdescription = pataddress.M_PatientAddressDescription.replace(/\s+/g, '')

                            if(seldescription.length !== patdescription.length){
                                rtn = true
                            }
                            //console.log(seladdress.Nat_PatientAddressM_KelurahanID+" - "+pataddress.M_PatientAddressM_KelurahanID)
                            if(seladdress.Nat_PatientAddressM_KelurahanID !== pataddress.M_PatientAddressM_KelurahanID){
                                rtn = true
                            }
                        })
                    }
                    
                    return rtn
                },
                check_different_email(selected){
                    var rtn  = false
                    var patient = this.patient_selected[0]
                    if(patient){
                        if(selected.Nat_PatientEmail !== patient.M_PatientEmail)
                        rtn = true

                    }
                    
                    return rtn
                },
                check_different_hp(selected){
                    var rtn  = false
                    var patient = this.patient_selected[0]
                    if(patient){
                        if(selected.Nat_PatientHP !== patient.M_PatientHP)
                        rtn = true
                    }
                    

                    return rtn
                },
                check_different_sex(selected){
                    var rtn  = false
                    var patient = this.patient_selected[0]
                    if(patient){
                        if(selected.Nat_PatientM_SexID !== patient.M_SexID)
                        rtn = true
                    }
                    

                    return rtn
                },
                check_different_ttl(selected){
                    var rtn  = false
                    var patient = this.patient_selected[0]
                    if(patient){
                        if(selected.Nat_PatientPOB && patient.M_PatientPOB){
                            if(selected.Nat_PatientPOB.toLowerCase() !== patient.M_PatientPOB.toLowerCase())
                            rtn = true
                        }
                        else{
                            if(selected.Nat_PatientPOB !== patient.M_PatientPOB)
                            rtn = true
                        }
                        

                        if(selected.Nat_PatientDOB !== patient.M_PatientDOB)
                        rtn = true
                    }
                    

                    

                    return rtn
                },
                blankForNull(s) {
    return s.toUpperCase() === "NULL" ? "" : s;
},
                check_different_name(selected){
                    var rtn  = false
                    var patient = this.patient_selected[0]
                    //console.log(patient)
                    if(patient){
                        if(selected.Nat_PatientM_TitleID !== patient.M_TitleID)
                        rtn = true

                        let prefix = !selected.Nat_PatientPrefix?"":selected.Nat_PatientPrefix
                        let prefix_selected = !patient.M_PatientPrefix?"":patient.M_PatientPrefix

                        if(prefix !== prefix_selected)
                        rtn = true

                        let suffix = !selected.Nat_PatientSuffix?"":selected.Nat_PatientSuffix
                        let suffix_selected = !patient.M_PatientSuffix?"":patient.M_PatientSuffix

                        if(suffix !== suffix_selected)
                        rtn = true

                        let realname = !selected.Nat_PatientName?"":selected.Nat_PatientName
                        let realname_selected = !patient.M_PatientRealName?"":patient.M_PatientRealName

                        if(realname !== realname_selected)
                        rtn = true
                    }
                    

                    return rtn
                },
                get_sex(id){
                    var rtn = ''
                    let sexes = this.sexes
                    if(parseInt(id) > 0 && sexes.length > 0){
                        let selected_sex = _.filter(sexes, function(o) { return parseInt(o.M_SexID) === parseInt(id) })
                        rtn = selected_sex[0].m_sexname
                    }   
                    
                    return rtn
                },
                capitalizeFirstLetter(str) {
                    str = str.toLowerCase()
                    return str[0].toUpperCase() + str.slice(1);
                },
                get_titlename(titleid){
                    var rtn = ''
                    let titles = this.titles
                    if(parseInt(titleid) > 0 && titles.length > 0){
                        let selected_title = _.filter(titles, function(o) { return parseInt(o.M_TitleID) === parseInt(titleid) })
                        rtn = selected_title[0].M_TitleName
                    }   
                    
                    return rtn
                },
                get_identitycard(id){
                    var rtn = ''
                    let kartuidentitass = this.idstype
                    if(parseInt(id) > 0 && kartuidentitass.length > 0){
                        let selected_id = _.filter(kartuidentitass, function(o) { return parseInt(o.M_IdTypeID) === parseInt(id) })
                        rtn = selected_id[0].M_IdTypeName
                    }   
                    
                    return rtn
                },
                formatDate (date) {
                    if (!date) return null

                    const [year, month, day] = date.split('-')
                    return `${day}-${month}-${year}`
                },
                clickVerif(data){
                    var xval = data.status == 'Y'?'N':'Y';
                    console.log(xval)
                    var patients = this.patients
                    console.log(patients)
                    var idx = _.findIndex(patients, item => item.M_PatientID === data.M_PatientID && item.M_BranchID === data.M_BranchID)
                    console.log(idx)
                    patients[idx]['status'] = xval
                    this.$store.commit("patient/update_patients", patients)
                },
                isSelected(p) {
                    var patient = this.$store.state.patient.selected_patient
                    return p.M_PatientID == patient.M_PatientID && patient.M_BranchID === p.M_BranchID
                },
                searchPatient() {
                    this.$store.dispatch("patient/search", {
                        name: this.name,
                        snorm: this.snorm,
                        current_page: 1,
                        lastid: -1
                    })
                    this.$store.commit("patient/update_current_page", 1)
                },
                selectMe(pat) {
                    
                        this.$store.commit("patient/update_selected_patient", pat)
                        this.$store.commit("patient/update_norm", pat.Nat_PatientNoReg)
                        this.$store.commit("patient/update_patient_prefix", pat.Nat_PatientPrefix)
                        this.$store.commit("patient/update_patient_name", pat.Nat_PatientName)
                        this.$store.commit("patient/update_patient_suffix", pat.Nat_PatientSuffix)
                        this.$store.commit("patient/update_selected_title", {
                            M_TitleID: pat.Nat_PatientM_TitleID,
                            M_TitleName: this.get_titlename(pat.Nat_PatientM_TitleID)
                        })
                        this.$store.commit("patient/update_selected_sex", {
                            M_SexID: pat.Nat_PatientM_SexID,
                            m_sexname: this.get_sex(pat.Nat_PatientM_SexID)
                        })
                        /*this.$store.commit("patient/update_selected_religion", {
                            M_ReligionID: pat.M_PatientM_ReligionID,
                            M_ReligionName: pat.M_ReligionName
                        })*/
                        var aDOB = this.formatDate(pat.Nat_PatientDOB)

                        this.$store.commit("patient/update_dob", aDOB)
                        this.$store.commit("patient/update_hp", pat.Nat_PatientHP)
                        //this.$store.commit("patient/update_phone", pat.Nat_PatientPhone)
                        this.$store.commit("patient/update_email", pat.Nat_PatientEmail)
                        this.$store.commit("patient/update_pob", pat.Nat_PatientPOB)
                        this.$store.commit("patient/update_selected_kartuidentitas", {
                            M_IdTypeID: pat.Nat_PatientM_IdTypeID,
                            M_IdTypeName: this.get_identitycard(pat.Nat_PatientM_IdTypeID)
                        })
                        this.$store.commit("patient/update_noidentitas", pat.Nat_PatientIDNumber)
                        //this.$store.commit("patient/update_note", pat.Nat_PatientNote)
                        //this.$store.commit("patient/update_nik", pat.Nat_PatientNIK)
                        //this.$store.commit("patient/update_jabatan", pat.Nat_PatientJabatan)
                        //this.$store.commit("patient/update_kedudukan", pat.Nat_PatientKedudukan)
                        //this.$store.commit("patient/update_pj", pat.Nat_PatientPJ)
                        //this.$store.commit("patient/update_location", pat.Nat_PatientLocation)
                        //this.$store.commit("patient/update_job", pat.Nat_PatientJob)

                        this.$store.commit("patient/update_addresses", pat.address)
                        
                        this.$store.commit("patient/update_act", 'edit')
                    

                },
                closeAlertConfirmation() {
                    this.$store.commit("patient/update_open_alert_confirmation", false)
                },
                forgetAlertConfirmation() {
                    this.$store.commit("patient/update_no_save", 0)
                    this.$store.commit("patient/update_open_alert_confirmation", false)
                },
                updateAlert_success(val) {
                    this.$store.commit("patient/update_alert_success", val)
                },
                setNewPatient() {
                    this.$store.commit("patient/update_selected_patient", {})
                    this.$store.commit("patient/update_norm", '')
                    this.$store.commit("patient/update_patient_name", '')
                    this.$store.commit("patient/update_selected_title", {})
                    this.$store.commit("patient/update_selected_sex", {})
                    this.$store.commit("patient/update_selected_religion", {})
                    this.$store.commit("patient/update_dob", '')
                    this.$store.commit("patient/update_hp", '')
                    this.$store.commit("patient/update_phone", '')
                    this.$store.commit("patient/update_email", '')
                    this.$store.commit("patient/update_pob", '')
                    this.$store.commit("patient/update_selected_kartuidentitas", {})
                    this.$store.commit("patient/update_noidentitas", '')
                    this.$store.commit("patient/update_note", '')
                    this.$store.commit("patient/update_nik", '')
                        this.$store.commit("patient/update_jabatan", '')
                        this.$store.commit("patient/update_kedudukan", '')
                        this.$store.commit("patient/update_pj", '')
                        this.$store.commit("patient/update_location", '')
                        this.$store.commit("patient/update_job", '')
                    this.$store.commit("patient/update_addresses", [])

                    this.$store.commit("patient/update_act", 'new')
                },
                closeDialogSuccess() {
                    /*let arrpatient = this.$store.state.patient.patients
                    var idx = _.findIndex(arrpatient, item => item.M_PatientID === this.$store.state.patient.last_id)
                    console.log(idx)
                    this.$store.dispatch("patient/search", {
                        name: this.name,
                        snorm: this.snorm,
                        current_page: this.curr_page,
                        lastid: idx
                    })*/
                    this.$store.commit("patient/update_dialog_success", false)
                    if(this.$store.state.patient.verify_data_status){
                        this.$store.commit("patient/update_verify_data_status", false)
                        window.close();
                    }
                    
                }
            },
            computed: {
                selected_patient:{
                    get() {
                        return this.$store.state.patient.selected_patient
                    },
                    set(val) {
                        this.$store.commit("patient/update_selected_patient", val)
                    }
                },
                addresses:{
                    get() {
                        return this.$store.state.patient.addresses
                    },
                    set(val) {
                        this.$store.commit("patient/update_addresses", val)
                    }
                },
                patient_selected:{
                    get() {
                        return this.$store.state.patient.patient_selected
                    },
                    set(val) {
                        this.$store.commit("patient/update_patient_selected", val)
                    }
                },
                onsearch(){
                    return this.$store.state.patient.onsearch
                },
                dialog_not_found:{
                    get() {
                        return this.$store.state.patient.dialog_not_found
                    },
                    set(val) {
                        this.$store.commit("patient/update_dialog_not_found", val)
                    }
                },
                dialogsuccess: {
                    get() {
                        return this.$store.state.patient.dialog_success
                    },
                    set(val) {
                        this.$store.commit("patient/update_dialog_success", val)
                    }
                },
                msgsuccess() {
                    return this.$store.state.patient.msg_success
                },
                snackbar: {
                    get() {
                        return this.$store.state.patient.alert_success
                    },
                    set(val) {
                        this.$store.commit("patient/update_alert_success", val)
                    }
                },
                isLoading() {
                    return this.$store.state.patient.search_status == 1
                },
                patients() {
                    return this.$store.state.patient.patients
                },
                totalpatient() {
                    return this.$store.state.patient.total_patient
                },
                sexes() {
                    return this.$store.state.patient.sexes
                },
                idstype() {
                    return this.$store.state.patient.kartuidentitass
                },
                titles() {
                    return this.$store.state.patient.titles
                },
                curr_page: {
                    get() {
                        return this.$store.state.patient.current_page
                    },
                    set(val) {
                        this.$store.commit("patient/update_current_page", val)
                        this.$store.dispatch("patient/search", {
                            name: this.name,
                            snorm: this.snorm,
                            current_page: val,
                            lastid: -1
                        })
                    }
                },
                xtotal_page: {
                    get() {
                        return this.$store.state.patient.total_patient
                    },
                    set(val) {
                        this.$store.commit("patient/update_total_patient", val)
                    }
                },
                openalertconfirmation: {
                    get() {
                        return this.$store.state.patient.open_alert_confirmation
                    },
                    set(val) {
                        this.$store.commit("patient/update_open_alert_confirmation", val)
                    }
                },
                search_patient(){
                    return this.$store.state.patient.search_patient === 1
                }

            },
            data() {
                return {
                    width_screen:screen.width+'px',
                    msgalertconfirmation: "Perubahan yang telah dilakukan belum disimpan dong !",
                    items: [],
                    name: '',
                    snorm: '',
                    page: 1,
                    trx_patients: [
                        {
                            "M_BranchCode" : "LB",
                            "M_BranchID" : "15",
                            "M_PatientID" : "878043",
                            "Nat_PatientCreated" : "2021-07-26 11:14:51",
                            "Nat_PatientDOB" : "1970-03-01",
                            "Nat_PatientEmail" : "",
                            "Nat_PatientHP" : "+6287852318407",
                            "Nat_PatientID" : "184059",
                            "Nat_PatientIDNumber" : "3517044103700003",
                            "Nat_PatientInitialVisit" : "0",
                            "Nat_PatientIsActive" : "Y",
                            "Nat_PatientJabatan" : null,
                            "Nat_PatientJob" : "",
                            "Nat_PatientKedudukan" : null,
                            "Nat_PatientLastUpdated" : "2023-01-02 03:12:18",
                            "Nat_PatientLastVisit" : null,
                            "Nat_PatientLocation" : null,
                            "Nat_PatientM_CompanyStaffPositionID" : null,
                            "Nat_PatientM_IdTypeID" : "1",
                            "Nat_PatientM_ReligionID" : null,
                            "Nat_PatientM_SexID" : "2",
                            "Nat_PatientM_TitleID" : "5",
                            "Nat_PatientNIK" : null,
                            "Nat_PatientName" : "RIATUN",
                            "Nat_PatientNoReg" : "LAB0073695",
                            "Nat_PatientNote" : "",
                            "Nat_PatientOldID" : "",
                            "Nat_PatientPJ" : null,
                            "Nat_PatientPOB" : "Jombang",
                            "Nat_PatientPhone" : null,
                            "Nat_PatientPhoto" : null,
                            "Nat_PatientPhotoCounter" : "0",
                            "Nat_PatientPhotoThumb" : null,
                            "Nat_PatientPrefix" : "",
                            "Nat_PatientSuffix" : "",
                            "Nat_PatientUserID" : "360",
                            "address" : [
                                {
                                "M_BranchCode" : "LA",
                                "M_BranchID" : "14",
                                "M_PatientAddressID" : "898142",
                                "Nat_PatientAddressCreated" : null,
                                "Nat_PatientAddressDescription" : "DSN. SUMBERAGUNG RT 03 RW 01",
                                "Nat_PatientAddressEmail" : null,
                                "Nat_PatientAddressFax" : null,
                                "Nat_PatientAddressID" : "152041",
                                "Nat_PatientAddressIsActive" : "Y",
                                "Nat_PatientAddressLastUpdated" : null,
                                "Nat_PatientAddressLat" : "0.00000000",
                                "Nat_PatientAddressLng" : "0.00000000",
                                "Nat_PatientAddressLocation" : null,
                                "Nat_PatientAddressM_KelurahanID" : "23542",
                                "Nat_PatientAddressM_PatientID" : "878043",
                                "Nat_PatientAddressNote" : "Utama",
                                "Nat_PatientAddressOldAddressLocation" : null,
                                "Nat_PatientAddressOldAddressName" : null,
                                "Nat_PatientAddressOldCityID" : null,
                                "Nat_PatientAddressPhone" : null,
                                "Nat_PatientAddressPostCodeID" : null,
                                "Nat_PatientAddressUserID" : "360"
                                }
                            ],
                            
                        },
                        {
                            "M_BranchCode" : "LA",
                            "M_BranchID" : "14",
                            "M_PatientID" : "878043",
                            "Nat_PatientCreated" : "2021-07-26 11:14:51",
                            "Nat_PatientDOB" : "1970-03-01",
                            "Nat_PatientEmail" : "",
                            "Nat_PatientHP" : "+6287852318407",
                            "Nat_PatientID" : "184059",
                            "Nat_PatientIDNumber" : "3517044103700003",
                            "Nat_PatientInitialVisit" : "0",
                            "Nat_PatientIsActive" : "Y",
                            "Nat_PatientJabatan" : null,
                            "Nat_PatientJob" : "",
                            "Nat_PatientKedudukan" : null,
                            "Nat_PatientLastUpdated" : "2023-01-02 03:12:18",
                            "Nat_PatientLastVisit" : null,
                            "Nat_PatientLocation" : null,
                            "Nat_PatientM_CompanyStaffPositionID" : null,
                            "Nat_PatientM_IdTypeID" : "1",
                            "Nat_PatientM_ReligionID" : null,
                            "Nat_PatientM_SexID" : "2",
                            "Nat_PatientM_TitleID" : "5",
                            "Nat_PatientNIK" : null,
                            "Nat_PatientName" : "RIATUN",
                            "Nat_PatientNoReg" : "LAB0073695",
                            "Nat_PatientNote" : "",
                            "Nat_PatientOldID" : "",
                            "Nat_PatientPJ" : null,
                            "Nat_PatientPOB" : "JOMBANG",
                            "Nat_PatientPhone" : null,
                            "Nat_PatientPhoto" : null,
                            "Nat_PatientPhotoCounter" : "0",
                            "Nat_PatientPhotoThumb" : null,
                            "Nat_PatientPrefix" : "",
                            "Nat_PatientSuffix" : "",
                            "Nat_PatientUserID" : "360",
                            "address" : [
                                {
                                "M_BranchCode" : "LA",
                                "M_BranchID" : "14",
                                "M_PatientAddressID" : "898142",
                                "Nat_PatientAddressCreated" : null,
                                "Nat_PatientAddressDescription" : "DSN. SUMBERAGUNG RT 03 RW 01",
                                "Nat_PatientAddressEmail" : null,
                                "Nat_PatientAddressFax" : null,
                                "Nat_PatientAddressID" : "152041",
                                "Nat_PatientAddressIsActive" : "Y",
                                "Nat_PatientAddressLastUpdated" : null,
                                "Nat_PatientAddressLat" : "0.00000000",
                                "Nat_PatientAddressLng" : "0.00000000",
                                "Nat_PatientAddressLocation" : null,
                                "Nat_PatientAddressM_KelurahanID" : "23542",
                                "Nat_PatientAddressM_PatientID" : "878043",
                                "Nat_PatientAddressNote" : "Utama",
                                "Nat_PatientAddressOldAddressLocation" : null,
                                "Nat_PatientAddressOldAddressName" : null,
                                "Nat_PatientAddressOldCityID" : null,
                                "Nat_PatientAddressPhone" : null,
                                "Nat_PatientAddressPostCodeID" : null,
                                "Nat_PatientAddressUserID" : "360"
                                }
                            ],
                            
                        }
                    ],
                    headers: [
                        {
                            text: "NAMA",
                            align: "left",
                            sortable: false,
                            value: "mr",
                            width: "15%",
                            class: "pa-2 blue lighten-3 white--text"
                        },
                        {
                            text: "TTL",
                            align: "left",
                            sortable: false,
                            value: "lab",
                            width: "12%",
                            class: "pa-2 blue lighten-3 white--text"
                        },
                        {
                            text: "J. KELAMIN",
                            align: "left",
                            sortable: false,
                            value: "lab",
                            width: "10%",
                            class: "pa-2 blue lighten-3 white--text"
                        },
                        {
                            text: "NO HP",
                            align: "center",
                            sortable: false,
                            value: "name",
                            width: "10%",
                            class: "pa-2 blue lighten-3 white--text"
                        },
                        {
                            text: "EMAIL",
                            align: "center",
                            sortable: false,
                            value: "name",
                            width: "15%",
                            class: "pa-2 blue lighten-3 white--text"
                        },
                        {
                            text: "ALAMAT",
                            align: "left",
                            sortable: false,
                            value: "status",
                            width: "25%",
                            class: "pa-2 blue lighten-3 white--text"
                        },
                        {
                            text: "CABANG",
                            align: "left",
                            sortable: false,
                            value: "status",
                            width: "10%",
                            class: "pa-2 blue lighten-3 white--text"
                        },
                        {
                            text: "AKSI",
                            align: "center",
                            sortable: false,
                            value: "status",
                            width: "20%",
                            class: "pa-2 blue lighten-3 white--text"
                        }
                    ],
                    single_headers: [
                        {
                            text: "NAMA",
                            align: "left",
                            sortable: false,
                            value: "mr",
                            width: "15%",
                            class: "pa-2 teal lighten-3 white--text"
                        },
                        {
                            text: "TTL",
                            align: "left",
                            sortable: false,
                            value: "lab",
                            width: "12%",
                            class: "pa-2 teal lighten-3 white--text"
                        },
                        {
                            text: "J. KELAMIN",
                            align: "left",
                            sortable: false,
                            value: "lab",
                            width: "10%",
                            class: "pa-2 teal lighten-3 white--text"
                        },
                        {
                            text: "NO HP",
                            align: "center",
                            sortable: false,
                            value: "name",
                            width: "10%",
                            class: "pa-2 teal lighten-3 white--text"
                        },
                        {
                            text: "EMAIL",
                            align: "center",
                            sortable: false,
                            value: "name",
                            width: "15%",
                            class: "pa-2 teal lighten-3 white--text"
                        },
                        {
                            text: "ALAMAT",
                            align: "left",
                            sortable: false,
                            value: "status",
                            width: "55%",
                            class: "pa-2 teal lighten-3 white--text"
                        }
                    ],
                    pagination: {
                        descending: false,
                        page: 1,
                        rowsPerPage: 5,
                        sortBy: 'M_PatientName',
                        totalItems: this.$store.state.patient.total_patients
                    }
                };
            }
        }
    </script>