"src/views/sections/src/views/sections/Patients.vue" did not exist on "4b445e305c4b6d15296d569bd586475bd4fd4aa8"
Patients.vue 16.1 KB
Newer Older
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1 2
<template>
  <div style="margin: 8px">
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
3 4 5 6 7 8 9 10
    <v-card>
      <v-card-title>
        <v-toolbar-title>Pacientes Registrados</v-toolbar-title>
        <v-divider
          vertical
          style="margin-left: 8px"
        />
        <v-spacer />
11 12 13 14 15 16 17 18 19 20 21
        <router-link :to="{name: 'Asignar'}">
          <v-btn
            text
            color="info"
            class="toolbar-btn"
            dark
          >
            <v-icon>mdi-hospital-building</v-icon> Asignar Pacientes
          </v-btn>
        </router-link>

Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
22 23 24 25 26 27
        <v-dialog
          v-model="dialog"
          max-width="800px"
          persistent
        >
          <template v-slot:activator="{ on, attrs }">
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
28 29 30
            <v-btn
              color="success"
              dark
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
31 32 33
              class="toolbar-btn"
              v-bind="attrs"
              v-on="on"
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
34
            >
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
35
              <v-icon>mdi-plus</v-icon>Registrar Paciente
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
36
            </v-btn>
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
37 38 39
          </template>
          <patient-form
            :title="formTitle"
Yoelvis Gonzalez's avatar
ok  
Yoelvis Gonzalez committed
40
            @refresh="closeSaved"
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
41 42 43 44 45 46 47 48 49
            @close-click="close"
          />
        </v-dialog>
      </v-card-title>
      <v-expansion-panels
        v-model="filterPanel"
      >
        <filter-tool
          :loading="loadingPatientsData"
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
50
          @close-click="closeFilter"
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
          @filter-click="filterData"
        />
      </v-expansion-panels>
      <v-data-table
        v-model="selectedItems"
        locale="es-es"
        style="margin-top: 8px"
        :headers="headers"
        :items="patients"
        :loading="loadingPatientsData"
        :footer-props="{
          'disable-items-per-page': true,
          'items-per-page-text': 'Pacientes por página'
        }"
        :server-items-length="totalPatientsItems"
        loading-text="Cargando Pacientes"
        class="elevation-1"
        @pagination="paginatePatients"
      >
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
70 71 72 73 74 75 76 77
        <template v-slot:item.estado_sistema="{ item }">
          <v-chip
            :color="getStatusColor(item.estado_sistema)"
            dark
          >
            {{ statusName(item.estado_sistema) }}
          </v-chip>
        </template>
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
78 79
        <template v-slot:item.actions="{ item }">
          <v-tooltip bottom>
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
80
            <template v-slot:activator="{ on, attrs }">
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
81 82 83
              <v-icon
                class="mr-2"
                color="orange"
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
84
                v-bind="attrs"
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
85
                :loading="loadingPatientData"
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
86
                v-on="on"
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
87
                @click="editItem(item)"
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
88
              >
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
89 90
                mdi-pencil
              </v-icon>
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
91
            </template>
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
92 93 94 95 96 97 98 99 100 101
            <span>Editar</span>
          </v-tooltip>
          <v-tooltip bottom>
            <template v-slot:activator="{ on, attrs }">
              <v-icon
                class="mr-2"
                color="error"
                v-bind="attrs"
                v-on="on"
                @click="deleteItem(item)"
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
102
              >
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
103 104 105 106 107 108 109 110 111 112 113 114
                mdi-delete
              </v-icon>
            </template>
            <span>Eliminar</span>
          </v-tooltip>
          <v-tooltip bottom>
            <template v-slot:activator="{ on, attrs }">
              <v-icon
                class="mr-2"
                color="info"
                v-bind="attrs"
                v-on="on"
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
115
                @click="detailsItem(item.id_paciente)"
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
116
              >
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
117 118 119 120 121
                mdi-dots-horizontal-circle
              </v-icon>
            </template>
            <span>Detalle Paciente</span>
          </v-tooltip>
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
122 123
          <v-tooltip
            v-if="canConfirm(item)"
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
124
            bottom
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
125
          >
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
126
            <template v-slot:activator="{ on, attrs }">
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
127 128
              <v-icon
                class="mr-2"
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
129 130 131
                color="success"
                v-bind="attrs"
                v-on="on"
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
132
                @click="admit(item)"
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
133
              >
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
134 135
                mdi-notebook-check
              </v-icon>
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
136
            </template>
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
137
            <span>Confirmar Ingreso</span>
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
138
          </v-tooltip>
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
139 140 141 142 143 144
        </template>
        <template v-slot:no-data>
          No hay datos disponibles
        </template>
      </v-data-table>
    </v-card>
krlsnvz93's avatar
krlsnvz93 committed
145

Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
146 147 148 149 150 151
    <v-dialog
      v-model="infoPatient"
      persistent
      max-width="800px"
    >
      <patient-file
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
152
        @ok-click="loadPatientsData"
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
153
        @close-click="closeDetails"
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
154
        @edit-click="editFromDetails"
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
155 156
      />
    </v-dialog>
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
    <v-dialog
      v-model="dialogDelete"
      max-width="500px"
      persistent
    >
      <v-card>
        <v-card-title
          class="text-h5"
          style="word-break: normal"
        >
          ¿Está seguro que desea eliminar el elemento?
        </v-card-title>
        <v-card-actions>
          <v-spacer />
          <v-btn
            color="blue darken-1"
            text
            @click="closeDelete"
          >
            Cancelar
          </v-btn>
          <v-btn
            color="blue darken-1"
            text
            :loading="loadingPatientsData"
            @click="deleteItemConfirm"
          >
            Borrar
          </v-btn>
          <v-spacer />
        </v-card-actions>
      </v-card>
    </v-dialog>
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
190 191 192 193
  </div>
</template>

<script>
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
194

Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
195
  import PatientFile from '@/components/PatientFile.vue'
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
196
  import { mapMutations, mapGetters } from 'vuex'
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
197
  import PatientForm from '@/components/PatientForm.vue'
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
198
  import { getPatients, getPatient, deletePatient } from '@/axios/patients'
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
199
  import FilterTool from '@/components/FilterTool.vue'
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
200
  import errorHandler from '@/mixins/error-handler'
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
201
  export default {
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
202
    components: { PatientFile, FilterTool, PatientForm },
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
203
    data: () => ({
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
204 205 206
      filterPanel: false,
      selectedItems: [],
      assignOnePatient: false,
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
207
      antigensData: [],
Yoelvis Gonzalez's avatar
ok  
Yoelvis Gonzalez committed
208 209
      patientsFirstLoad: true,
      totalPatientsItems: 0,
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
210 211 212
      infoPatient: false,
      toDeleteId: -1,
      loadingPatientsData: false,
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
213
      loadingPatientData: false,
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
214 215
      valid: false,
      asymptomatic: true,
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
216 217 218 219
      modal: false,
      dialogDeleteUnavailable: false,
      dialog: false,
      dialogDelete: false,
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
220
      healthAreas: [],
Yoelvis Gonzalez's avatar
ok  
Yoelvis Gonzalez committed
221
      categories: [],
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
222 223 224 225
      headers: [
        {
          text: 'CI',
          align: 'start',
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
226
          sortable: false,
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
227 228
          value: 'ci',
        },
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
229 230
        { text: 'Nombre', value: 'nombre', sortable: false },
        { text: 'Apellidos', value: 'apellidos', sortable: false },
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
231
        { text: 'Estado en el Sistema', value: 'estado_sistema', sortable: false },
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
232 233 234 235
        { text: 'Acciones', value: 'actions', sortable: false },
      ],
      patients: [],
      defaultItem: {
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
236 237 238
        asymptomatic: true,
        isContact: false,
        arrived: false,
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
239 240
        nombre: '',
        apellidos: '',
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
241
        ci: '',
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
242
        edad: 0,
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
243
        noApp: true,
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
244 245 246 247
        sexo: '',
        direccion: '',
        municipio: '',
        provincia: '',
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
248
        cmf: '',
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
249 250 251
        area_salud: '',
        remite_caso: '',
        sintomas: [],
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
252
        app: [],
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
253 254 255 256 257
        estado_sistema: '',
        trabajador_salud: false,
        ninho: false,
        embarazada: false,
        vacunado: false,
Yoelvis Gonzalez's avatar
ok  
Yoelvis Gonzalez committed
258
        test_antigeno: 0,
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286

        // eslint-disable-next-line camelcase
        fecha_sintomas: null,
        fiebre: false,
        rinorrea: false,
        congestion_nasal: false,
        tos: false,
        expectoracion: false,
        dificultad_respiratoria: false,
        cefalea: false,
        dolor_garganta: false,
        otros_sint: '',

        hipertension: false,
        diabetes: false,
        asma: false,
        obesidad: false,
        insuficiencia_renal: false,
        oncologia: false,
        otros_apps: '',

        fecha_arribo: null,
        pais_procedencia: '',
        lugar_estancia: '',

        fecha_contacto: null,
        tipo_contacto: '',
        lugar_contacto: '',
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
287 288 289 290
      },
    }),

    computed: {
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
291
      ...mapGetters(['pIndex', 'patient', 'filters', 'editFromFile', 'patientId']),
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
292 293 294
      provinces () {
        return this.$store.getters.provinces
      },
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
295 296
      municipalities () {
        return this.$store.getters.municipalities
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
297
      },
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
298
      formTitle () {
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
299
        return this.pIndex === -1 ? 'Registrar Paciente' : 'Editar datos de paciente'
krlsnvz93's avatar
krlsnvz93 committed
300
      },
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
301
      disableRemissionCenterName () {
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
302
        return (this.patient.remissionCenter.type !== 'Hospital') && (this.patient.remissionCenter.type !== 'Otro')
krlsnvz93's avatar
krlsnvz93 committed
303
      },
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
304 305 306
      systemStatusesData () {
        return this.$store.getters.systemStatuses
      },
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
307 308 309
    },

    created () {
Yoelvis Gonzalez's avatar
fixes  
Yoelvis Gonzalez committed
310
      this.loadPatientsData()
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
311 312 313
    },

    methods: {
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
314
      ...mapMutations(['setPIndex', 'setPatient', 'clearPatient', 'setFiltersPage', 'setFilterStatus']),
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
315
      showMe () {
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
316
      },
317 318 319 320 321
      async admit (item) {
        const response = await getPatient(item.id_paciente)
        this.setPatient(response.data.paciente)
        this.$router.push({ name: 'Confirmar' })
      },
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
322
      canConfirm (item) {
323
        if ((item.id_asignado && localStorage.getItem('role') === 'CA') || localStorage.getItem('role') === 'SADM') {
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
324 325 326 327
          return true
        }
        return false
      },
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375
      getStatusColor (systemStatus) {
        switch (systemStatus) {
          case 1:
            return 'amber'
          case 2:
            return 'orange'
          case 3:
            return 'red'
          case 4:
            return 'pink'
          case 5:
            return 'yellow'
          case 6:
            return 'blue'
          case 7:
            return 'green'
          case 8:
            return 'lime'
          case 9:
            return 'brown'
          default:
            return 'black'
        }
      },
      statusName (systemStatus) {
        switch (systemStatus) {
          case 1:
            return 'ENCUESTADO'
          case 2:
            return 'PENDIENTE INGRESO'
          case 3:
            return 'REVISADO'
          case 4:
            return 'ASIGNADO UBICACION'
          case 5:
            return 'EN TRANSPORTACION'
          case 6:
            return 'INGRESADO'
          case 7:
            return 'RECUPERADO'
          case 8:
            return 'RECUPERADO SEGUIMIENTO'
          case 9:
            return 'TRASLADO'
          default:
            return 'SIN ESTADO'
        }
      },
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
376 377
      filterData () {
        this.loadPatientsData()
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
378
        this.closeFilter()
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
379
      },
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
380 381
      closeFilter () {
        this.filterPanel = false
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
382
      },
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
383 384 385
      editFromDetails () {
        this.closeDetails()
        this.editItem(this.patient)
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
386
      },
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
387
      async detailsItem (id) {
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
388 389 390 391 392 393 394 395 396 397 398 399
        console.log(id)
        if (id !== null && id !== undefined) {
          this.loadingPatientData = true
          try {
            const patientResponse = await getPatient(id)
            this.setPatient(patientResponse.data.paciente)
            this.setPIndex(1)
            this.infoPatient = true
          } catch (e) {
            errorHandler(e)
          }
          this.loadingPatientData = true
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
400
        }
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
401
      },
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
402
      async loadPatientsData () {
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
403 404
        this.loadingPatientsData = true
        try {
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
405
          const patientsResponse = await getPatients(this.filters)
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
406 407 408
          this.totalPatientsItems = patientsResponse.data.meta.total
          this.patients = patientsResponse.data.pacientes
          this.loadingPatientsData = false
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
409
        } catch (e) {
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
410
          errorHandler(e)
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
411
        }
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
412
        this.patientsFirstLoad = false
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
413 414
      },
      async editItem (item) {
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
415
        this.loadingPatientData = true
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
416
        try {
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
417 418 419 420 421 422 423 424 425
          let cache = {}
          if (this.editFromFile === true) {
            cache = this.patient
          } else {
            const patientResponse = await getPatient(item.id_paciente)
            cache = patientResponse.data.paciente
            this.setPIndex(this.patients.indexOf(item))
          }
          console.log(cache)
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
426 427 428 429 430 431 432 433 434 435
          if (cache.apps !== null) {
            cache.hipertension = cache.apps.hipertension
            cache.diabetes = cache.apps.diabetes
            cache.asma = cache.apps.asma
            cache.obesidad = cache.apps.obesidad
            cache.insuficiencia_renal = cache.apps.insuficiencia_renal
            cache.oncologia = cache.apps.oncologia
            cache.otros_apps = cache.apps.otros
            if (cache.hipertension || cache.diabetes || cache.asma || cache.obesidad || cache.insuficiencia_renal || cache.oncologia || cache.otros_apps) {
              cache.noApp = false
Yoelvis Gonzalez's avatar
fixes  
Yoelvis Gonzalez committed
436
            }
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
437
          }
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
438 439 440 441 442 443 444 445 446 447 448 449 450
          if (cache.sintomas !== null) {
            cache.fecha_sintomas = cache.sintomas.fecha_sintomas
            cache.fiebre = cache.sintomas.fiebre
            cache.rinorrea = cache.sintomas.rinorrea
            cache.congestion_nasal = cache.sintomas.congestion_nasal
            cache.tos = cache.sintomas.tos
            cache.expectoracion = cache.sintomas.expectoracion
            cache.dificultad_respiratoria = cache.sintomas.dificultad_respiratoria
            cache.cefalea = cache.sintomas.cefalea
            cache.dolor_garganta = cache.sintomas.dolor_garganta
            cache.otros_sint = cache.sintomas.otros
            if (cache.fecha_sintomas || cache.fiebre || cache.rinorrea || cache.congestion_nasal || cache.tos || cache.expectoracion || cache.dificultad_respiratoria || cache.cefalea || cache.dolor_garganta || cache.otros_sint) {
              cache.asymptomatic = false
Yoelvis Gonzalez's avatar
fixes  
Yoelvis Gonzalez committed
451
            }
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
452
          }
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
453 454 455 456 457 458
          if (cache.contacto !== null) {
            cache.fecha_contacto = cache.contacto.fecha_contacto
            cache.lugar_contacto = cache.contacto.lugar_contacto
            cache.tipo_contacto = cache.contacto.tipo_contacto
            if (cache.fecha_contacto || cache.lugar_contacto || cache.tipo_contacto) {
              cache.isContact = true
Yoelvis Gonzalez's avatar
fixes  
Yoelvis Gonzalez committed
459
            }
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
460
          }
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
461 462 463 464 465 466
          if (cache.arribo !== null) {
            cache.pais_procedencia = cache.arribo.pais_procedencia
            cache.lugar_estancia = cache.arribo.lugar_estancia
            cache.fecha_arribo = cache.arribo.fecha_arribo
            if (cache.pais_procedencia || cache.lugar_estancia || cache.fecha_arribo) {
              cache.arrived = true
Yoelvis Gonzalez's avatar
fixes  
Yoelvis Gonzalez committed
467
            }
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
468
          }
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
469
          this.setPatient(cache)
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
470
        } catch (e) {
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
471
          errorHandler(e)
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
472
        }
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
473
        this.loadingPatientData = false
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
474 475
        this.dialog = true
      },
Yoelvis Gonzalez's avatar
ok  
Yoelvis Gonzalez committed
476 477 478
      paginatePatients (pageInfo) {
        if (this.patientsFirstLoad) {
          this.patientsFirstLoad = false
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
479
        } else {
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
480 481
          if (this.filters.page !== pageInfo.page) {
            this.setFiltersPage(pageInfo.page)
Yoelvis Gonzalez's avatar
ok  
Yoelvis Gonzalez committed
482 483
            this.loadPatientsData()
          }
Yoelvis Gonzalez's avatar
ok  
Yoelvis Gonzalez committed
484 485
        }
      },
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
486 487

      deleteItem (item) {
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
488
        this.toDeleteId = item.id_paciente
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
489 490
        this.setPIndex(this.patients.indexOf(item))
        this.setPatient(item)
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
491
        this.dialogDelete = true
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
492
      },
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
493 494 495 496
      async deleteItemConfirm () {
        this.loadingPatientsData = true
        try {
          await deletePatient(this.toDeleteId)
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
497 498 499 500 501 502 503 504 505 506 507 508 509 510
          this.$toast.success('Registro eliminado correctamente', {
            position: 'bottom-center',
            timeout: 5000,
            closeOnClick: true,
            pauseOnFocusLoss: false,
            pauseOnHover: true,
            draggable: true,
            draggablePercent: 0.6,
            showCloseButtonOnHover: false,
            hideProgressBar: true,
            closeButton: 'button',
            icon: true,
            rtl: false,
          })
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
511 512
          this.loadPatientsData()
        } catch (e) {
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
513
          errorHandler(e)
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
514
        }
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
515
        this.closeDelete()
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
516
        this.loadingPatientsData = false
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
517
      },
Yoelvis Gonzalez's avatar
ok  
Yoelvis Gonzalez committed
518 519 520
      closeSaved () {
        this.dialog = false
        this.$nextTick(() => {
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
521 522
          this.clearPatient()
          this.setPIndex(-1)
Yoelvis Gonzalez's avatar
ok  
Yoelvis Gonzalez committed
523 524
        })
        this.loadPatientsData()
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
525 526 527
        if (this.patientId !== -1) {
          this.detailsItem(this.patientId)
        }
Yoelvis Gonzalez's avatar
ok  
Yoelvis Gonzalez committed
528
      },
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
529 530 531
      close () {
        this.dialog = false
        this.$nextTick(() => {
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
532 533
          this.clearPatient()
          this.setPIndex(-1)
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
534 535 536 537 538
        })
      },
      closeDelete () {
        this.dialogDelete = false
        this.$nextTick(() => {
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
539 540
          this.clearPatient()
          this.setPIndex(-1)
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
541 542
        })
      },
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
543
      closeDetails () {
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
544 545 546 547 548 549 550 551 552
        if (this.editFromFile) {
          this.infoPatient = false
        } else {
          this.infoPatient = false
          this.$nextTick(() => {
            this.clearPatient()
            this.setPIndex(-1)
          })
        }
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
553
      },
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
554 555 556 557 558 559 560 561
    },

  }
</script>
<style scoped>
.fix-title {
  word-break: normal;
}
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
562 563 564
.toolbar-btn {
  margin: 4px
}
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
565
</style>