<template>
<div>
        <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()">OK</v-btn>
                    <v-btn color="error darken-1" flat @click="xdialogaction = false">Tutup</v-btn>
                </v-card-actions>
            </v-card>
        </v-dialog>
        <v-card>
            <v-layout  row>
                <v-flex xs12 pa-2>
                    <v-layout align-center>
                        <v-flex xs2>
                            <v-img
                                src="https://www.sgm-inc.com/wp-content/uploads/2014/06/no-profile-male-img.gif"
                                aspect-ratio="1"
                                class="grey lighten-2 elevation-2"
                            >
                        </v-flex>

                        <v-flex xs10 pl-2 pt-1>
                            <v-layout row wrap>
                                <v-flex xs4>
                                    <v-layout column>
                                        <v-flex>
                                            <h3 style="font-size:x-large" class="font-weight-bold">{{ xselected_patient.T_OrderHeaderLabNumber }}</h3>
                                        </v-flex>
                                        <v-flex pt-3>
                                            <v-text-field
                                                v-model=" xselected_patient.M_PatientNoReg"
                                                label="No RM"
                                                readonly
                                                hide-details
                                            >
                                            </v-text-field>
                                        </v-flex>
                                        <v-flex>
                                            <v-text-field
                                                v-model=" xselected_patient.M_PatientName"
                                                label="Nama"
                                                readonly
                                                hide-details
                                            >
                                            </v-text-field>
                                        </v-flex>
                                    </v-layout>
                                </v-flex>

                                <v-flex xs8 pl-2>
                                    <v-layout column>
                                        <v-flex >
                                            <v-layout row>
                                                <v-flex xs6>
                                                    <v-text-field
                                                        v-model="xselected_patient.patient_dob"
                                                        label="Tanggal lahir"
                                                        readonly
                                                        hide-details
                                                    >
                                                    </v-text-field>
                                                </v-flex>
                                                <v-flex xs6 pl-1>
                                                    <v-text-field
                                                        v-model=" xselected_patient.T_OrderHeaderM_PatientAge"
                                                        label="Umur"
                                                        readonly
                                                        hide-details
                                                    >
                                                    </v-text-field>
                                                </v-flex>
                                            </v-layout>
                                            
                                        </v-flex>

                                        <v-flex pt-1>
                                            <v-text-field
                                                v-model="xselected_patient.M_PatientHP"
                                                label="HP"
                                                readonly
                                                hide-details
                                            >
                                            </v-text-field>
                                        </v-flex>

                                        <v-flex  v-if="xselected_patient.statusid === '0' || xselected_patient.statusid === '2'">
                                            <v-btn
                                               
                                                color="primary"
                                                class="mt-3"
                                                @click="callPatient()"
                                                block
                                            >
                                               CALL
                                            </v-btn>
                                        </v-flex>
                                        
                                        <v-layout v-if="xselected_patient.statusid === '1'" row>
                                            <v-flex pl-2 pr-2 xs6>
                                                <v-btn
                                                    
                                                    color="warning"
                                                    class="mt-3"
                                                    @click="processNow()"
                                                    block
                                                >
                                                PROCESS
                                                </v-btn>
                                            </v-flex>
                                            <v-flex pl-2 pr-2  xs6>
                                                <v-btn
                                                    
                                                    color="error"
                                                    class="mt-3"
                                                    @click="skip()"
                                                    block
                                                >
                                                SKIP
                                                </v-btn>
                                            </v-flex>
                                        </v-layout>
                                    </v-layout>
                                </v-flex>
                            </v-layout>
                        </v-flex>

                    </v-layout>
                </v-flex>
            </v-flex>          
        </v-card>
    </v-layout>
    </div>
</template>

<style scoped>

</style>

<script>
module.exports = {
    data: () => ({
          
    }),
    computed: {
        xselected_patient:{
            get() {
                return this.$store.state.samplecall.selected_patient
            },
            set(val) {
                this.$store.commit("samplecall/update_selected_patient",val)
            }
        },
        xdialogaction:{
            get() {
                return this.$store.state.samplecall.dialog_action
            },
            set(val) {
                this.$store.commit("samplecall/update_dialog_action",val)
            }
        },
        xmsgaction:{
            get() {
                return this.$store.state.samplecall.msg_action
            },
            set(val) {
                this.$store.commit("samplecall/update_msg_action",val)
            }
        }
    },
    methods : {
        closeDialogAction(){
            var act = this.$store.state.samplecall.act
            var sample  = this.$store.state.samplecall.selected_sampletype
            var status = 1
            if(act === 'process'){
                status = 3
            }
            if(act === 'skip'){
                status = 2
            }
            if(act === 'samplingprocess'){
                status = 3
            }
            if(act === 'samplingdone'){
                status = 4
            }
            var patient = this.$store.state.samplecall.selected_patient
            this.$store.dispatch("samplecall/doaction",{
                act:act,
                id:patient.T_OrderHeaderID,
                name:this.name,
                nolab:this.nolab,
                stationid: patient.T_SampleStationID,
                statusid:this.$store.state.samplecall.selected_status.id,
                statusnextid : status,
                sample:sample
            })
            
        },
        callPatient(){
            var patient = this.$store.state.samplecall.selected_patient
            var msg = "Anda yakin akan melakukan panggilan kepada pasien "+patient.patient_fullname+" ? "
            this.$store.commit("samplecall/update_msg_action",msg)
            this.$store.commit("samplecall/update_act",'call')
            this.$store.commit("samplecall/update_dialog_action",true)
        },
        processNow(){
            var patient = this.$store.state.samplecall.selected_patient
            var msg = "Anda yakin akan merubah status <span style='color:ff5252;font-weight:bold'>PROCESS</span> untuk pasien "+patient.patient_fullname+" ? "
            this.$store.commit("samplecall/update_msg_action",msg)
            this.$store.commit("samplecall/update_act",'process')
            this.$store.commit("samplecall/update_dialog_action",true)
        },
        skip(){
            var patient = this.$store.state.samplecall.selected_patient
            var msg = "Anda yakin akan merubah status <span style='color:ff5252;font-weight:bold'>SKIP</span> untuk pasien "+patient.patient_fullname+" ? "
            this.$store.commit("samplecall/update_msg_action",msg)
            this.$store.commit("samplecall/update_act",'skip')
            this.$store.commit("samplecall/update_dialog_action",true)
        }
    }
}
</script>
