<template>
  <div>
    <!-- :title="printtitle" :width="printwidth" :height="500" :status="openprint"
    :urlprint="urlprint" @close-dialog-print="closePrint" -->
    <v-dialog v-model="openprint" width="80%">
      <v-card>
        <!-- <v-card-title class="headline grey lighten-2" primary-title>
          Cetak Label
        </v-card-title>
-->
        <v-card-text>
          <v-layout wrap align-center>
            <v-flex xs12>
              <v-select :items="LabelTypeList" v-model="selectedLabelType"></v-select>
            </v-flex>
            <v-flex xs12>
              <object :data="urlprint" width="100%" height="500"></object>
            </v-flex>
          </v-layout>
        </v-card-text>

        <v-divider></v-divider>

        <v-card-actions>
          <v-spacer></v-spacer>
          <v-btn color="primary" flat @click="closePrint"> Tutup </v-btn>
        </v-card-actions>
      </v-card>
    </v-dialog>

    <v-dialog v-model="dialogdata" width="80%">
      <v-card>
        <v-card-title class="headline grey lighten-2 pt-2 pb-2" primary-title>
          Form Data
        </v-card-title>
        <v-card-text class="pt-2 pb-2">
          <v-layout v-for="gluc in glucoses" align-center row pb-2>
            <v-flex xs2>
              {{ gluc[2] }}
            </v-flex>
            <v-flex xs4>
              <v-text-field v-model="gluc[3]"
                style="font-size:12px;margin-top:0;padding-top:0;line-height:25px!important" outline single-line
                hide-details></v-text-field>
            </v-flex>
          </v-layout>
          <v-layout align-center row pb-2>
            <v-flex xs2>
              <v-btn @click="changeStandartBMI()" small color="info">{{
                this.selectedPatient.T_SamplingAdditionalFisikBBTBStandart }}</v-btn>
            </v-flex>
          </v-layout>

          <v-layout align-center row pb-2>
            <v-flex xs2>
              <span style="font-size:12px">Berat Badan</span>
            </v-flex>
            <v-flex xs4>
              <v-text-field v-model="T_SamplingAdditionalFisikBBTBValueBB"
                style="font-size:12px;margin-top:0;padding-top:0;line-height:25px!important" outline single-line
                hide-details></v-text-field>
            </v-flex>
            <v-flex xs3 pl-1>
              <span class="mono" style="font-size:12px">kg</span>
            </v-flex>
            <v-flex xs2>
              <span style="font-size:12px">Tinggi Badan</span>
            </v-flex>
            <v-flex xs4>
              <v-text-field v-model="T_SamplingAdditionalFisikBBTBValueTB"
                style="font-size:12px;margin-top:0;padding-top:0;line-height:25px!important" outline single-line
                hide-details></v-text-field>
            </v-flex>
            <v-flex xs2 pl-1>
              <span class="mono" style="font-size:12px">cm</span>
            </v-flex>
          </v-layout>
          <v-layout align-center row pb-2>
            <v-flex xs2>
              <span style="font-size:12px">Body Fat</span>
            </v-flex>
            <v-flex xs4>
              <v-text-field v-model="T_SamplingAdditionalFisikBBTBBodyFat"
                style="font-size:12px;margin-top:0;padding-top:0;line-height:25px!important" outline single-line
                hide-details></v-text-field>
            </v-flex>
            <v-flex xs3 pl-1>
              <span class="mono" style="font-size:12px"></span>
            </v-flex>
            <v-flex xs2>
              <span style="font-size:12px">Klasifikasi</span>
            </v-flex>
            <v-flex xs4>
              <v-text-field v-model="T_SamplingAdditionalFisikBBTBValueClassification"
                style="font-size:12px;margin-top:0;padding-top:0;line-height:25px!important" outline single-line
                hide-details></v-text-field>
            </v-flex>
            <v-flex xs2 pl-1>
            </v-flex>
          </v-layout>

          <v-layout align-center row pb-2>
            <v-flex xs2>
              <span style="font-size:12px">Buta Warna</span>
            </v-flex>
            <v-flex xs4>
              <v-radio-group hide-details class="mb-2" v-model="T_SamplingAdditionalFisikBWPWValue" row>
                <v-radio label="Buta Warna" value="BW"></v-radio>
                <v-radio label="Tidak Buta Warna" value="N"></v-radio>
                <v-radio label="Tidak Dilakukan" value="X"></v-radio>
              </v-radio-group>
            </v-flex>
            <v-flex xs3 pl-1>
              <span class="mono" style="font-size:12px"></span>
            </v-flex>
            <v-flex xs2>
              <span v-if="this.T_SamplingAdditionalFisikBWPWValue === 'BW'" style="font-size:12px">Nilai</span>
            </v-flex>
            <v-flex xs4>
              <v-text-field v-if="this.T_SamplingAdditionalFisikBWPWValue === 'BW'"
                v-model="T_SamplingAdditionalFisikBWPWVAngka"
                style="font-size:12px;margin-top:0;padding-top:0;line-height:25px!important" outline single-line
                hide-details></v-text-field>
            </v-flex>
            <v-flex xs2 pl-1>
              <span class="mono" style="font-size:12px"></span>
            </v-flex>
          </v-layout>
          <v-layout align-center row pb-2>
            <v-flex xs2>
              <span style="font-size:12px">Keterangan</span>
            </v-flex>
            <v-flex xs10>
              <v-text-field v-model="T_SamplingAdditionalFisikBWPWKeterangan"
                style="font-size:12px;margin-top:0;padding-top:0;line-height:25px!important" outline single-line
                hide-details></v-text-field>
            </v-flex>
            <v-flex xs3 pl-1>
              <span class="mono" style="font-size:12px"></span>
            </v-flex>
            <v-flex xs2 pl-1>
            </v-flex>
          </v-layout>


          <v-layout align-center row pb-2>
            <v-flex xs2>
              <span style="font-size:12px">Tanpa Kacamata</span>
            </v-flex>
          </v-layout>
          <v-layout align-center row pb-2>
            <v-flex xs2>
              <span style="font-size:12px">OD</span>
            </v-flex>
            <v-flex xs4>
              <v-text-field v-model="T_SamplingAdditionalFisikVisusTKODV"
                style="font-size:12px;margin-top:0;padding-top:0;line-height:25px!important" outline single-line
                hide-details></v-text-field>
            </v-flex>
            <v-flex xs3 pl-1>
              <span class="mono" style="font-size:12px"></span>
            </v-flex>
            <v-flex xs2>
              <span style="font-size:12px">OS</span>
            </v-flex>
            <v-flex xs4>
              <v-text-field v-model="T_SamplingAdditionalFisikVisusTKOSV"
                style="font-size:12px;margin-top:0;padding-top:0;line-height:25px!important" outline single-line
                hide-details></v-text-field>
            </v-flex>
            <v-flex xs2 pl-1>
              <span class="mono" style="font-size:12px"></span>
            </v-flex>
          </v-layout>

          <v-layout align-center row pb-2>
            <v-flex xs2>
              <span style="font-size:12px">Dengan Kacamata</span>
            </v-flex>
          </v-layout>
          <v-layout align-center row pb-2>
            <v-flex xs2>
              <span style="font-size:12px">OD</span>
            </v-flex>
            <v-flex xs4>
              <v-text-field v-model="T_SamplingAdditionalFisikVisusDKODV"
                style="font-size:12px;margin-top:0;padding-top:0;line-height:25px!important" outline single-line
                hide-details></v-text-field>
            </v-flex>
            <v-flex xs3 pl-1>
              <span class="mono" style="font-size:12px"></span>
            </v-flex>
            <v-flex xs2>
              <span style="font-size:12px">OS</span>
            </v-flex>
            <v-flex xs4>
              <v-text-field v-model="T_SamplingAdditionalFisikVisusDKOSV"
                style="font-size:12px;margin-top:0;padding-top:0;line-height:25px!important" outline single-line
                hide-details></v-text-field>
            </v-flex>
            <v-flex xs2 pl-1>
              <span class="mono" style="font-size:12px"></span>
            </v-flex>
          </v-layout>

          <v-layout align-center row pb-2>
            <v-flex xs2>
              <span style="font-size:12px">Dengan Koreksi</span>
            </v-flex>
          </v-layout>
          <v-layout align-center row pb-2>
            <v-flex xs2>
              <span style="font-size:12px">OD Sph</span>
            </v-flex>
            <v-flex xs4>
              <v-text-field v-model="T_SamplingAdditionalFisikVisusODSPH"
                style="font-size:12px;margin-top:0;padding-top:0;line-height:25px!important" outline single-line
                hide-details></v-text-field>
            </v-flex>
            <v-flex xs3 pl-1>
              <span class="mono" style="font-size:12px"></span>
            </v-flex>
            <v-flex xs2>
              <span style="font-size:12px">OD Cyl</span>
            </v-flex>
            <v-flex xs4>
              <v-text-field v-model="T_SamplingAdditionalFisikVisusODCYL"
                style="font-size:12px;margin-top:0;padding-top:0;line-height:25px!important" outline single-line
                hide-details></v-text-field>
            </v-flex>
            <v-flex xs2 pl-1>
              <span class="mono" style="font-size:12px"></span>
            </v-flex>
          </v-layout>
          <v-layout align-center row pb-2>
            <v-flex xs2>
              <span style="font-size:12px">OD X</span>
            </v-flex>
            <v-flex xs4>
              <v-text-field v-model="T_SamplingAdditionalFisikVisusODX"
                style="font-size:12px;margin-top:0;padding-top:0;line-height:25px!important" outline single-line
                hide-details></v-text-field>
            </v-flex>
            <v-flex xs3 pl-1>
              <span class="mono" style="font-size:12px"></span>
            </v-flex>
            <v-flex xs2>
              <span style="font-size:12px">ADD</span>
            </v-flex>
            <v-flex xs4>
              <v-text-field v-model="T_SamplingAdditionalFisikVisusADD"
                style="font-size:12px;margin-top:0;padding-top:0;line-height:25px!important" outline single-line
                hide-details></v-text-field>
            </v-flex>
            <v-flex xs2 pl-1>
              <span class="mono" style="font-size:12px"></span>
            </v-flex>
          </v-layout>
          <v-layout align-center row pb-2>
            <v-flex xs2>
              <span style="font-size:12px">OS Sph</span>
            </v-flex>
            <v-flex xs4>
              <v-text-field v-model="T_SamplingAdditionalFisikVisusOSSPH"
                style="font-size:12px;margin-top:0;padding-top:0;line-height:25px!important" outline single-line
                hide-details></v-text-field>
            </v-flex>
            <v-flex xs3 pl-1>
              <span class="mono" style="font-size:12px"></span>
            </v-flex>
            <v-flex xs2>
              <span style="font-size:12px">OS Cyl</span>
            </v-flex>
            <v-flex xs4>
              <v-text-field v-model="T_SamplingAdditionalFisikVisusOSCYL"
                style="font-size:12px;margin-top:0;padding-top:0;line-height:25px!important" outline single-line
                hide-details></v-text-field>
            </v-flex>
            <v-flex xs2 pl-1>
              <span class="mono" style="font-size:12px"></span>
            </v-flex>
          </v-layout>
          <v-layout align-center row pb-2>
            <v-flex xs2>
              <span style="font-size:12px">OS X</span>
            </v-flex>
            <v-flex xs4>
              <v-text-field v-model="T_SamplingAdditionalFisikVisusOSX"
                style="font-size:12px;margin-top:0;padding-top:0;line-height:25px!important" outline single-line
                hide-details></v-text-field>
            </v-flex>
            <v-flex xs3 pl-1>
              <span class="mono" style="font-size:12px"></span>
            </v-flex>
            <v-flex xs2>
              <span style="font-size:12px"></span>
            </v-flex>
            <v-flex xs4>
            </v-flex>
            <v-flex xs2 pl-1>
              <span class="mono" style="font-size:12px"></span>
            </v-flex>
          </v-layout>
          <v-layout align-center row pb-2>
            <v-flex xs2>
              <span style="font-size:12px">Kiri</span>
            </v-flex>
            <v-flex xs4>
              <v-text-field v-model="T_SamplingAdditionalFisikVisusKiriKesimpulan"
                style="font-size:12px;margin-top:0;padding-top:0;line-height:25px!important" outline single-line
                hide-details></v-text-field>
            </v-flex>
            <v-flex xs3 pl-1>
              <span class="mono" style="font-size:12px"></span>
            </v-flex>
            <v-flex xs2>
              <span style="font-size:12px">Kanan</span>
            </v-flex>
            <v-flex xs4>
              <v-text-field v-model="T_SamplingAdditionalFisikVisusKananKesimpulan"
                style="font-size:12px;margin-top:0;padding-top:0;line-height:25px!important" outline single-line
                hide-details></v-text-field>
            </v-flex>
            <v-flex xs2 pl-1>
              <span class="mono" style="font-size:12px"></span>
            </v-flex>
          </v-layout>

        </v-card-text>
        <v-divider></v-divider>
        <v-card-actions>
          <v-spacer></v-spacer>
          <v-btn color="primary" flat @click="dialogdata = false">
            Tutup
          </v-btn>
          <v-btn color="primary" flat @click="saveData()">
            Simpan Perubahan
          </v-btn>
        </v-card-actions>
      </v-card>
    </v-dialog>

    <v-snackbar color="success" v-model="snackbarSuccess" right="right" :timeout="3000" top="top">
      {{ successMsg }}
      <v-btn color="white" flat @click="snackbarSuccess = false"> Close </v-btn>
    </v-snackbar>
    <v-snackbar color="error" v-model="snackbarError" right="right" :timeout="3000" top="top">
      {{ errorMsg }}
      <v-btn color="white" flat @click="snackbarError = false"> Close </v-btn>
    </v-snackbar>
    <v-layout class="fill-height" column>
      <v-card style="width: 100%" class="mb-2 pa-2">
        <v-layout row wrap>
          <v-flex xs12 class="mb-2">
            <v-autocomplete label="Pilih Proyek MCU" v-model="selectedSetup" :items="setupList" item-text="Mgm_McuLabel"
              outline hide-details return-object no-data-text="Pilih Proyek MCU">
              <template slot="item" slot-scope="{ item }">
                <v-list-tile-content>
                  <v-list-tile-title v-text="item.Mgm_McuLabel"></v-list-tile-title>
                </v-list-tile-content>
              </template>
            </v-autocomplete>
          </v-flex>
          <v-flex xs6 class="mb-2">
            <v-menu v-model="menuFormDateStart" :close-on-content-click="false" :nudge-right="40" lazy
              transition="scale-transition" offset-y full-width max-width="290px" min-width="290px">
              <template v-slot:activator="{ on }">
                <v-text-field class="mr-2" v-model="formatedStartDate" label="Tanggal Awal" outline hide-details
                  readonly v-on="on" @blur="deFormatedDate(formatedStartDate)"></v-text-field>
              </template>
              <v-date-picker v-model="startDate" no-title @input="menuFormDateStart = false"></v-date-picker>
            </v-menu>
          </v-flex>
          <v-flex xs6 class="mb-2">
            <v-menu v-model="menuFormDateEnd" :close-on-content-click="false" :nudge-right="40" lazy
              transition="scale-transition" offset-y full-width max-width="290px" min-width="290px">
              <template v-slot:activator="{ on }">
                <v-text-field class="ml-2" v-model="formatedEndDate" label="Tanggal Akhir" outline readonly hide-details
                  v-on="on" @blur="deFormatedDate(formatedEndDate)"></v-text-field>
              </template>
              <v-date-picker v-model="endDate" no-title @input="menuFormDateEnd = false"></v-date-picker>
            </v-menu>
          </v-flex>
          <v-flex xs12>
            <v-text-field label="Cari..." outline hide-details v-model="search"
              v-on:keyup.enter="searchData"></v-text-field>
          </v-flex>
        </v-layout>
      </v-card>
    </v-layout>
    <v-layout row wrap v-if="selectedSetup.Mgm_McuID !== null &&
      selectedSetup.Mgm_McuID !== undefined
    ">
      <v-card class="py-2 px-2" style="width: 100%">
        <!--  <div>
          <v-btn depressed small @click="print()" color="warning">Cetak Label</v-btn> 
        </div> -->
        <!-- <span
          
          class="icon-medium-fill-base-small xs1 white--text blue-grey icon-print"
        ></span> -->
      </v-card>
    </v-layout>
    <v-card style="overflow-y: scroll; height: 55vh" class="fill-height">
      <v-data-table :loading="loading" :items="patientList" :headers="headers" class="v-table elevation-1" hide-actions>
        <template v-slot:headers="props">
          <tr>
            <th v-for="header in props.headers" :width="header.width" :class="header.class">
              {{ header.text }}
            </th>
          </tr>
        </template>
        <v-progress-linear v-slot:progress="loading" color="blue" :indeterminate="true"></v-progress-linear>
        <template v-slot:items="props">
          <tr @click="selectMe(props.item)">
            <!-- 'deep-orange darken-1': props.item.status !== 'NEW', -->
            <td v-bind:class="{ 'yellow lighten-4': isSelected(props.item), 'py-2': true, }">
              <p class="body-2">{{ props.item.orderDate }}</p>
            </td>
            <td v-bind:class="{ 'yellow lighten-4': isSelected(props.item), 'py-2': true, }">
              <p class="body-2">{{ props.item.patientFullname }}</p>
              <p v-if="props.item.isactive === 'Y'" v-bind:class="{ 'green--text': props.item.status !== 'NEW', }"
                class="font-weight-bold body-2">
                {{ props.item.labNumber }}
              </p>
              <p v-if="props.item.isactive === 'N'"
                style="font-weight:bold;color:#800000;text-decoration: line-through;">{{ props.item.labNumber }}</p>
            </td>
            <td v-bind:class="{ 'yellow lighten-4': isSelected(props.item), 'py-2': true, }">
              <p class="body-2" v-if="props.item.glucoses" v-for="item in getGlucose(props.item)">
                <span style="color:#800000" class="mb-0 font-weight-bold caption">{{ item[2] }} </span> : {{
                  item[3] }}
              </p>
              <p class="body-2" v-if="!props.item.glucoses">-</p>
            </td>
            <td v-bind:class="{ 'yellow lighten-4': isSelected(props.item), 'py-2': true, }">
              <p class="mono"><span style="color:#800000" class="mb-0 font-weight-bold caption">TB : </span>{{
                props.item.T_SamplingAdditionalFisikBBTBValueTB }} (cm) <span style="color:#800000"
                  class="mb-0 font-weight-bold caption">Body Fat : </span> {{
                    props.item.T_SamplingAdditionalFisikBBTBBodyFat }}</p>
              <p class="mono"><span style="color:#800000" class="mb-0 font-weight-bold caption">BB : </span> {{
                props.item.T_SamplingAdditionalFisikBBTBValueBB }} (kg) <span style="color:#800000"
                  class="mb-0 font-weight-bold caption">Klasifikasi : </span> {{
                    props.item.T_SamplingAdditionalFisikBBTBValueClassification }}</p>
              <p class="body-2" v-if="props.item.T_SamplingAdditionalFisikBBTBStandart !== null"><v-btn small
                  color="info">{{ props.item.T_SamplingAdditionalFisikBBTBStandart }}</v-btn></p>
            </td>
            <td v-bind:class="{ 'yellow lighten-4': isSelected(props.item), 'py-2': true, }">
              <p class="mono" v-if="props.item.T_SamplingAdditionalFisikBWPWValue === 'BW'"><span style="color:#800000"
                  class="mb-0 font-weight-bold caption">Nilai : </span> {{
                    props.item.T_SamplingAdditionalFisikBWPWVAngka }} </p>
              <p class="mono"><span style="color:#800000" class="mb-0 font-weight-bold caption">Keterangan : </span> {{
                props.item.T_SamplingAdditionalFisikBWPWKeterangan }}</p>
              <p class="body-2" v-if="props.item.T_SamplingAdditionalFisikBWPWValue === 'N'"><v-btn small
                  color="info">Tidak Buta Warna</v-btn></p>
              <p class="body-2" v-if="props.item.T_SamplingAdditionalFisikBWPWValue === 'BW'"><v-btn small
                  color="info">Buta Warna</v-btn></p>
              <p class="body-2" v-if="props.item.T_SamplingAdditionalFisikBWPWValue === 'X'"><v-btn small
                  color="info">Tidak Dilakukan</v-btn></p>
            </td>
            <td v-bind:class="{ 'yellow lighten-4': isSelected(props.item), 'py-2': true, }">
              <p class="mono"> <span style="color:#800000" class="mb-0 font-weight-bold caption">Tanpa Kacamata </span>
                OD : {{ props.item.T_SamplingAdditionalFisikVisusTKOSV }}, OS : {{
                  props.item.T_SamplingAdditionalFisikBBTBBodyFat }}</p>
              <p class="mono"></p>
              <p class="mono"> <span style="color:#800000" class="mb-0 font-weight-bold caption">Dengan Kacamata </span>
                OD : {{ props.item.T_SamplingAdditionalFisikVisusDKODV }}, OS : {{
                  props.item.T_SamplingAdditionalFisikVisusDKOSV }}</p>
              <p class="mono"></p>
              <p class="mono"> <span style="color:#800000" class="mb-0 font-weight-bold caption">Dengan Koreksi</span>
                OD Sph: {{ props.item.T_SamplingAdditionalFisikVisusODSPH }}, OD Cyl : {{
                  props.item.T_SamplingAdditionalFisikVisusODCYL }}, OD X : {{
                  props.item.T_SamplingAdditionalFisikVisusODX
                }}, ADD : {{ props.item.T_SamplingAdditionalFisikVisusADD }}</p>
              <p class="mono">OS Sph: {{ props.item.T_SamplingAdditionalFisikVisusOSSPH }}, OS Cyl : {{
                props.item.T_SamplingAdditionalFisikVisusOSCYL }}, OS X : {{
                  props.item.T_SamplingAdditionalFisikVisusOSX
                }}</p>
            </td>
            <td v-bind:class="{ 'yellow lighten-4': isSelected(props.item), 'py-2': true, }">
              <v-icon v-if="props.item.isactive === 'Y'" style="color:blue" title="edit" @click="editData(props.item)"
                class="text-sm-right">edit</v-icon>
            </td>
          </tr>
        </template>
      </v-data-table>
    </v-card>
    <v-card class="pa-2">
      <div class="text-xs-left">
        <v-pagination v-model="page" :length="totalPage"></v-pagination>
      </div>
    </v-card>
    <!-- <one-dialog-print-label
      :title="printtitle"
      :width="printwidth"
      :height="500"
      :status="openprint"
      :urlprint="urlprint"
      @close-dialog-print="closePrint"
    ></one-dialog-print-label> -->
  </div>
</template>
<style scoped>
.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;
}

.scroll-container {
  scroll-padding: 50px 0 0 50px;
}

::-webkit-scrollbar {
  width: 7px;
}

/* this targets the default scrollbar (compulsory) */

::-webkit-scrollbar-track {
  background-color: #73baf3;
}

/* the new scrollbar will have a flat appearance with the set background color */

::-webkit-scrollbar-thumb {
  background-color: #2196f3;
}

/* this will style the thumb, ignoring the track */

::-webkit-scrollbar-button {
  background-color: #0079da;
}

/* optionally, you can style the top and the bottom buttons (left and right for horizontal bars) */

::-webkit-scrollbar-corner {
  background-color: black;
}
</style>
<script>
// const { data } = require("./onePriceHeader.vue");

module.exports = {
  components: {
    "one-dialog-print-label": httpVueLoader("../../common/oneDialogPrintX.vue"),
  },
  mounted() {
    this.$store.dispatch("resume/getsetup");
  },
  methods: {
    getGlucose(order) {
      var arr_rtn = []
      let gluc = order.glucoses
      if (gluc) {
        let arr_gluc = gluc.split("*")
        arr_gluc.forEach(item => {
          let xgluc = item.split("^")
          arr_rtn.push(xgluc)
        })
      }

      return arr_rtn

    },
    searchData() {
      this.$store.dispatch("resume/search");
    },
    closePrint() {
      this.openprint = false;
    },
    print() {
      let user = one_user();
      var d = new Date();
      var n = d.getTime();
      // https://cpone.aplikasi.web.id/birt/run?__report=report/one/rekap/rpt_mcu_patient_label.rptdesign&__format=pdf&PStartDate=2024-07-15&PEndDate=2024-07-15&PMcuID=61&PType=divisi&username=joko@gmail.com&tm=1721657764454
      let rptname = "rpt_mcu_patient_label";
      this.urlprint =
        "/birt/run?__report=report/one/rekap/" +
        rptname +
        ".rptdesign&__format=pdf" +
        "&PStartDate=" +
        this.startDate +
        "&PEndDate=" +
        this.endDate +
        "&PMcuID=" +
        this.selectedSetup.Mgm_McuID +
        "&PType=" +
        this.selectedLabelType.toLowerCase() +
        "&username=" +
        user.M_StaffName +
        "&tm=" +
        n;
      this.openprint = true;
    },
    formatDate(date) {
      if (!date) return null;

      const [year, month, day] = date.split("-");
      return `${day}-${month}-${year}`;
    },
    deFormatedDate(date) {
      if (!date) return null;

      const [day, month, year] = date.split("-");
      return `${year}-${month.padStart(2, "0")}-${day.padStart(2, "0")}`;
    },
    selectMe(val) {
      this.$store.commit("resume/reset_input");
      this.selectedPatient = val;
      //this.bwvalue = val.T_SamplingAdditionalFisikBWPWValue;
      this.$store.dispatch("resume/getdetail");
    },
    isSelected(val) {
      return this.selectedPatient.orderID === val.orderID;
    },
    editData(val) {
      this.dialogdata = true
      this.T_SamplingAdditionalFisikBBTBValueBB = val.T_SamplingAdditionalFisikBBTBValueBB
      this.T_SamplingAdditionalFisikBBTBValueTB = val.T_SamplingAdditionalFisikBBTBValueTB
      this.T_SamplingAdditionalFisikBBTBValueClassification = val.T_SamplingAdditionalFisikBBTBValueClassification
      this.T_SamplingAdditionalFisikBBTBStandart = val.T_SamplingAdditionalFisikBBTBStandart
      this.T_SamplingAdditionalFisikBBTBBodyFat = val.T_SamplingAdditionalFisikBBTBBodyFat
      this.T_SamplingAdditionalFisikBWPWValue = val.T_SamplingAdditionalFisikBWPWValue
      this.T_SamplingAdditionalFisikBWPWVAngka = val.T_SamplingAdditionalFisikBWPWVAngka
      this.T_SamplingAdditionalFisikBWPWKeterangan = val.T_SamplingAdditionalFisikBWPWKeterangan
      this.T_SamplingAdditionalFisikVisusTKODV = val.T_SamplingAdditionalFisikVisusTKODV
      this.T_SamplingAdditionalFisikVisusTKOSV = val.T_SamplingAdditionalFisikVisusTKOSV
      this.T_SamplingAdditionalFisikVisusDKODV = val.T_SamplingAdditionalFisikVisusDKODV
      this.T_SamplingAdditionalFisikVisusDKOSV = val.T_SamplingAdditionalFisikVisusDKOSV
      this.T_SamplingAdditionalFisikVisusODSPH = val.T_SamplingAdditionalFisikVisusODSPH
      this.T_SamplingAdditionalFisikVisusODCYL = val.T_SamplingAdditionalFisikVisusODCYL
      this.T_SamplingAdditionalFisikVisusODX = val.T_SamplingAdditionalFisikVisusODX
      this.T_SamplingAdditionalFisikVisusOSSPH = val.T_SamplingAdditionalFisikVisusOSSPH
      this.T_SamplingAdditionalFisikVisusOSCYL = val.T_SamplingAdditionalFisikVisusOSCYL
      this.T_SamplingAdditionalFisikVisusOSX = val.T_SamplingAdditionalFisikVisusOSX
      this.T_SamplingAdditionalFisikVisusADD = val.T_SamplingAdditionalFisikVisusADD
      this.T_SamplingAdditionalFisikVisusKananKesimpulan = val.T_SamplingAdditionalFisikVisusKananKesimpulan
      this.T_SamplingAdditionalFisikVisusKiriKesimpulan = val.T_SamplingAdditionalFisikVisusKiriKesimpulan

      var arr_glucoses = []
      let gluc = val.glucoses
      if (gluc) {
        let arr_gluc = gluc.split("*")
        arr_gluc.forEach(item => {
          let xgluc = item.split("^")
          arr_glucoses.push(xgluc)
        })
      }
      this.glucoses = arr_glucoses

    },
    saveData() {
      var prm = {}
      console.log(this.T_SamplingAdditionalFisikBBTBValueBB)
      prm.orderID = this.selectedPatient.orderID
      prm.T_SamplingAdditionalFisikBBTBID = this.selectedPatient.T_SamplingAdditionalFisikBBTBID
      prm.T_SamplingAdditionalFisikBWID = this.selectedPatient.T_SamplingAdditionalFisikBWID
      prm.T_SamplingAdditionalFisikVisusID = this.selectedPatient.T_SamplingAdditionalFisikVisusID
      prm.T_SamplingAdditionalFisikBBTBValueBB = this.T_SamplingAdditionalFisikBBTBValueBB
      prm.T_SamplingAdditionalFisikBBTBValueTB = this.T_SamplingAdditionalFisikBBTBValueTB
      prm.T_SamplingAdditionalFisikBBTBValueClassification = this.T_SamplingAdditionalFisikBBTBValueClassification
      prm.T_SamplingAdditionalFisikBBTBStandart = this.T_SamplingAdditionalFisikBBTBStandart
      prm.T_SamplingAdditionalFisikBBTBBodyFat = this.T_SamplingAdditionalFisikBBTBBodyFat
      prm.T_SamplingAdditionalFisikBWPWValue = this.T_SamplingAdditionalFisikBWPWValue
      prm.T_SamplingAdditionalFisikBWPWVAngka = this.T_SamplingAdditionalFisikBWPWVAngka
      prm.T_SamplingAdditionalFisikBWPWKeterangan = this.T_SamplingAdditionalFisikBWPWKeterangan
      prm.T_SamplingAdditionalFisikVisusTKODV = this.T_SamplingAdditionalFisikVisusTKODV
      prm.T_SamplingAdditionalFisikVisusTKOSV = this.T_SamplingAdditionalFisikVisusTKOSV
      prm.T_SamplingAdditionalFisikVisusDKODV = this.T_SamplingAdditionalFisikVisusDKODV
      prm.T_SamplingAdditionalFisikVisusDKOSV = this.T_SamplingAdditionalFisikVisusDKOSV
      prm.T_SamplingAdditionalFisikVisusODSPH = this.T_SamplingAdditionalFisikVisusODSPH
      prm.T_SamplingAdditionalFisikVisusODCYL = this.T_SamplingAdditionalFisikVisusODCYL
      prm.T_SamplingAdditionalFisikVisusODX = this.T_SamplingAdditionalFisikVisusODX
      prm.T_SamplingAdditionalFisikVisusOSSPH = this.T_SamplingAdditionalFisikVisusOSSPH
      prm.T_SamplingAdditionalFisikVisusOSCYL = this.T_SamplingAdditionalFisikVisusOSCYL
      prm.T_SamplingAdditionalFisikVisusOSX = this.T_SamplingAdditionalFisikVisusOSX
      prm.T_SamplingAdditionalFisikVisusADD = this.T_SamplingAdditionalFisikVisusADD
      prm.T_SamplingAdditionalFisikVisusKananKesimpulan = this.T_SamplingAdditionalFisikVisusKananKesimpulan
      prm.T_SamplingAdditionalFisikVisusKiriKesimpulan = this.T_SamplingAdditionalFisikVisusKiriKesimpulan
      prm.glucoses = this.glucoses
      console.log(prm)
      this.$store.dispatch("resume/save", prm)

    }
  },
  computed: {
    glucoses: {
      get() {
        return this.$store.state.resume.glucoses;
      },
      set(val) {
        this.$store.commit("resume/update_glucoses", val);
      },
    },
    dialogdata: {
      get() {
        return this.$store.state.resume.dialogdata;
      },
      set(val) {
        this.$store.commit("resume/update_dialogdata", val);
      },
    },
    T_SamplingAdditionalFisikVisusKiriKesimpulan: {
      get() {
        return this.$store.state.resume.T_SamplingAdditionalFisikVisusKiriKesimpulan;
      },
      set(val) {
        this.$store.commit("resume/update_T_SamplingAdditionalFisikVisusKiriKesimpulan", val);
      },
    },
    T_SamplingAdditionalFisikVisusKananKesimpulan: {
      get() {
        return this.$store.state.resume.T_SamplingAdditionalFisikVisusKananKesimpulan;
      },
      set(val) {
        this.$store.commit("resume/update_T_SamplingAdditionalFisikVisusKananKesimpulan", val);
      },
    },
    T_SamplingAdditionalFisikVisusADD: {
      get() {
        return this.$store.state.resume.T_SamplingAdditionalFisikVisusADD;
      },
      set(val) {
        this.$store.commit("resume/update_T_SamplingAdditionalFisikVisusADD", val);
      },
    },
    T_SamplingAdditionalFisikVisusOSX: {
      get() {
        return this.$store.state.resume.T_SamplingAdditionalFisikVisusOSX;
      },
      set(val) {
        this.$store.commit("resume/update_T_SamplingAdditionalFisikVisusOSX", val);
      },
    },
    T_SamplingAdditionalFisikVisusOSCYL: {
      get() {
        return this.$store.state.resume.T_SamplingAdditionalFisikVisusOSCYL;
      },
      set(val) {
        this.$store.commit("resume/update_T_SamplingAdditionalFisikVisusOSCYL", val);
      },
    },
    T_SamplingAdditionalFisikVisusOSSPH: {
      get() {
        return this.$store.state.resume.T_SamplingAdditionalFisikVisusOSSPH;
      },
      set(val) {
        this.$store.commit("resume/update_T_SamplingAdditionalFisikVisusOSSPH", val);
      },
    },
    T_SamplingAdditionalFisikVisusODCYL: {
      get() {
        return this.$store.state.resume.T_SamplingAdditionalFisikVisusODCYL;
      },
      set(val) {
        this.$store.commit("resume/update_T_SamplingAdditionalFisikVisusODCYL", val);
      },
    },
    T_SamplingAdditionalFisikVisusODSPH: {
      get() {
        return this.$store.state.resume.T_SamplingAdditionalFisikVisusODSPH;
      },
      set(val) {
        this.$store.commit("resume/update_T_SamplingAdditionalFisikVisusODSPH", val);
      },
    },
    T_SamplingAdditionalFisikVisusDKOSV: {
      get() {
        return this.$store.state.resume.T_SamplingAdditionalFisikVisusDKOSV;
      },
      set(val) {
        this.$store.commit("resume/update_T_SamplingAdditionalFisikVisusDKOSV", val);
      },
    },
    T_SamplingAdditionalFisikVisusDKODV: {
      get() {
        return this.$store.state.resume.T_SamplingAdditionalFisikVisusDKODV;
      },
      set(val) {
        this.$store.commit("resume/update_T_SamplingAdditionalFisikVisusDKODV", val);
      },
    },
    T_SamplingAdditionalFisikVisusTKOSV: {
      get() {
        return this.$store.state.resume.T_SamplingAdditionalFisikVisusTKOSV;
      },
      set(val) {
        this.$store.commit("resume/update_T_SamplingAdditionalFisikVisusTKOSV", val);
      },
    },
    T_SamplingAdditionalFisikVisusTKODV: {
      get() {
        return this.$store.state.resume.T_SamplingAdditionalFisikVisusTKODV;
      },
      set(val) {
        this.$store.commit("resume/update_T_SamplingAdditionalFisikVisusTKODV", val);
      },
    },
    T_SamplingAdditionalFisikBWPWKeterangan: {
      get() {
        return this.$store.state.resume.T_SamplingAdditionalFisikBWPWKeterangan;
      },
      set(val) {
        this.$store.commit("resume/update_T_SamplingAdditionalFisikBWPWKeterangan", val);
      },
    },
    T_SamplingAdditionalFisikBWPWVAngka: {
      get() {
        return this.$store.state.resume.T_SamplingAdditionalFisikBWPWVAngka;
      },
      set(val) {
        this.$store.commit("resume/update_T_SamplingAdditionalFisikBWPWVAngka", val);
      },
    },
    T_SamplingAdditionalFisikBWPWValue: {
      get() {
        return this.$store.state.resume.T_SamplingAdditionalFisikBWPWValue;
      },
      set(val) {
        this.$store.commit("resume/update_T_SamplingAdditionalFisikBWPWValue", val);
      },
    },
    T_SamplingAdditionalFisikBBTBBodyFat: {
      get() {
        return this.$store.state.resume.T_SamplingAdditionalFisikBBTBBodyFat;
      },
      set(val) {
        this.$store.commit("resume/update_T_SamplingAdditionalFisikBBTBBodyFat", val);
      },
    },
    T_SamplingAdditionalFisikBBTBValueClassification: {
      get() {
        return this.$store.state.resume.T_SamplingAdditionalFisikBBTBValueClassification;
      },
      set(val) {
        this.$store.commit("resume/update_T_SamplingAdditionalFisikBBTBValueClassification", val);
      },
    },
    T_SamplingAdditionalFisikBBTBValueBB: {
      get() {
        return this.$store.state.resume.T_SamplingAdditionalFisikBBTBValueBB;
      },
      set(val) {
        this.$store.commit("resume/update_T_SamplingAdditionalFisikBBTBValueBB", val);
      },
    },
    T_SamplingAdditionalFisikBBTBValueTB: {
      get() {
        return this.$store.state.resume.T_SamplingAdditionalFisikBBTBValueTB;
      },
      set(val) {
        this.$store.commit("resume/update_T_SamplingAdditionalFisikBBTBValueTB", val);
      },
    },
    errorMsg: {
      get() {
        return this.$store.state.resume.errorMsg;
      },
      set(val) {
        this.$store.commit("resume/update_errorMsg", val);
      },
    },
    successMsg: {
      get() {
        return this.$store.state.resume.successMsg;
      },
      set(val) {
        this.$store.commit("resume/update_successMsg", val);
      },
    },
    snackbarError: {
      get() {
        return this.$store.state.resume.snackbarError;
      },
      set(val) {
        this.$store.commit("resume/update_snackbarError", val);
      },
    },
    snackbarSuccess: {
      get() {
        return this.$store.state.resume.snackbarSuccess;
      },
      set(val) {
        this.$store.commit("resume/update_snackbarSuccess", val);
      },
    },
    setupList: {
      get() {
        return this.$store.state.resume.setupList;
      },
      set(val) {
        this.$store.commit("resume/update_setupList", val);
      },
    },
    selectedSetup: {
      get() {
        return this.$store.state.resume.selectedSetup;
      },
      set(val) {
        this.$store.commit("resume/update_selectedSetup", val);
        this.selectedPatient = {};
        this.patientDetail = { detail: [] };
      },
    },
    startDate: {
      get() {
        return this.$store.state.resume.startDate;
      },
      set(val) {
        this.$store.commit("resume/update_startDate", val);
        this.selectedPatient = {};
        this.patientDetail = { detail: [] };
        this.page = 1;
        if (!this.changeSetup) this.$store.dispatch("resume/search");
      },
    },
    endDate: {
      get() {
        return this.$store.state.resume.endDate;
      },
      set(val) {
        this.selectedPatient = {};
        this.patientDetail = { detail: [] };
        this.page = 1;
        this.$store.commit("resume/update_endDate", val);
        if (!this.changeSetup) this.$store.dispatch("resume/search");
      },
    },
    patientDetail: {
      get() {
        return this.$store.state.resume.patientDetail;
      },
      set(val) {
        this.$store.commit("resume/update_patientDetail", val);
      },
    },
    search: {
      get() {
        return this.$store.state.resume.search;
      },
      set(val) {
        this.selectedPatient = {};
        this.patientDetail = { detail: [] };
        this.page = 1;
        this.$store.commit("resume/update_search", val);
        if (!this.changeSetup) this.$store.dispatch("resume/search");
      },
    },
    patientList: {
      get() {
        return this.$store.state.resume.patientList;
      },
      set(val) {
        this.$store.commit("resume/update_patientList", val);
      },
    },
    selectedPatient: {
      get() {
        return this.$store.state.resume.selectedPatient;
      },
      set(val) {
        this.$store.commit("resume/update_selectedPatient", val);
      },
    },
    bwvalue: {
      get() {
        return this.$store.state.resume.bwvalue;
      },
      set(val) {
        this.$store.commit("resume/update_bwvalue", val);
        console.log(val)
      },
    },
    totalPage: {
      get() {
        return this.$store.state.resume.totalPage;
      },
      set(val) {
        this.$store.commit("resume/update_totalPage", val);
      },
    },
    page: {
      get() {
        return this.$store.state.resume.page;
      },
      set(val) {
        this.selectedPatient = {};
        this.patientDetail = { detail: [] };
        this.$store.commit("resume/update_page", val);
        if (!this.changeSetup) this.$store.dispatch("resume/search");
      },
    },
    loading: {
      get() {
        return this.$store.state.resume.loading;
      },
      set(val) {
        this.$store.commit("resume/update_loading", val);
      },
    },
    formatedStartDate() {
      return this.formatDate(this.startDate);
    },
    formatedEndDate() {
      return this.formatDate(this.endDate);
    },
  },
  watch: {
    selectedSetup(val, old) {
      this.changeSetup = true;
      this.page = 1;
      this.endDate = val.Mgm_McuEndDate;
      this.startDate = val.Mgm_McuStartDate;
      this.$store.dispatch("resume/search");
      this.changeSetup = false;
    },
    selectedLabelType(val, old) {
      let user = one_user();
      var d = new Date();
      var n = d.getTime();
      // https://cpone.aplikasi.web.id/birt/run?__report=report/one/rekap/rpt_mcu_patient_label.rptdesign&__format=pdf&PStartDate=2024-07-15&PEndDate=2024-07-15&PMcuID=61&PType=divisi&username=joko@gmail.com&tm=1721657764454
      let rptname = "rpt_mcu_patient_label";
      this.urlprint =
        "/birt/run?__report=report/one/rekap/" +
        rptname +
        ".rptdesign&__format=pdf" +
        "&PStartDate=" +
        this.startDate +
        "&PEndDate=" +
        this.endDate +
        "&PMcuID=" +
        this.selectedSetup.Mgm_McuID +
        "&PType=" +
        val.toLowerCase() +
        "&username=" +
        user.M_StaffName +
        "&tm=" +
        n;
    },
  },
  data() {
    return {
      menuFormDateStart: false,
      menuFormDateEnd: false,
      changeSetup: false,
      printtitle: "",
      printwidth: "80%",
      openprint: false,
      //dialogdata: false,
      urlprint: "",
      selectedLabelType: "Departement",
      LabelTypeList: ["Departement", "Divisi"],
      headers: [{
        text: "TGL. ORDER",
        align: "left",
        sortable: false,
        value: "lab",
        width: "10%",
        class: "pa-2 blue lighten-3 white--text",
      },
      {
        text: "PASIEN",
        align: "left",
        sortable: false,
        value: "lab",
        width: "15%",
        class: "pa-2 blue lighten-3 white--text",
      },
      {
        text: "Gula Darah",
        align: "left",
        sortable: false,
        value: "lab",
        width: "10%",
        class: "pa-2 blue lighten-3 white--text",
      },
      {
        text: "TB / BB / BODY FAT",
        align: "left",
        sortable: false,
        value: "lab",
        width: "20%",
        class: "pa-2 blue lighten-3 white--text",
      },
      {
        text: "BUTA WARNA",
        align: "left",
        sortable: false,
        value: "lab",
        width: "20%",
        class: "pa-2 blue lighten-3 white--text",
      },
      {
        text: "VISUS",
        align: "left",
        sortable: false,
        value: "lab",
        width: "30%",
        class: "pa-2 blue lighten-3 white--text",
      },
      {
        text: "ACTION",
        align: "left",
        sortable: false,
        value: "lab",
        width: "10%",
        class: "pa-2 blue lighten-3 white--text",
      },
      ],
    };
  },
};
</script>
