"src/views/sections/src/views/sections/Patients.vue" did not exist on "3f9b6187164b52d52fa4cc94272c673ca9e92ac4"
Patients.vue 60 KB
Newer Older
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1 2
<template>
  <div style="margin: 8px">
krlsnvz93's avatar
krlsnvz93 committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
    <v-data-table
      locale="es-es"
      style="margin-top: 8px"
      :headers="headers"
      :items="patients"
      sort-by="ci"
      :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"
    >
      <template v-slot:top>
        <v-toolbar flat>
          <v-toolbar-title>Pacientes Registrados</v-toolbar-title>
          <v-divider
            class="mx-4"
            inset
            vertical
          />
          <v-spacer />
          <!--  <router-link
            :to="{name: Admit}"
            style="margin : 4px"
          >
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
32 33 34
            <v-btn
              color="success"
              dark
krlsnvz93's avatar
krlsnvz93 committed
35
              class="mb-2"
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
36
            >
krlsnvz93's avatar
krlsnvz93 committed
37
              <v-icon>mdi-notebook-check</v-icon>Ingresar Paciente(s)
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
38
            </v-btn>
krlsnvz93's avatar
krlsnvz93 committed
39 40 41 42 43
          </router-link> -->
          <v-dialog
            v-model="dialog"
            max-width="800px"
            persistent
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
44
          >
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
45
            <template v-slot:activator="{ on, attrs }">
krlsnvz93's avatar
krlsnvz93 committed
46 47 48 49
              <v-btn
                color="success"
                dark
                class="mb-2"
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
50 51
                v-bind="attrs"
                v-on="on"
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
52
              >
krlsnvz93's avatar
krlsnvz93 committed
53 54
                <v-icon>mdi-plus</v-icon>Registrar Paciente
              </v-btn>
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
55
            </template>
krlsnvz93's avatar
krlsnvz93 committed
56 57 58 59 60 61 62 63 64 65 66 67 68
            <v-card>
              <v-card-title class="fix-title">
                <span class="text-h5">{{ formTitle }}</span><v-spacer /> <v-btn
                  icon
                  @click="close"
                >
                  <v-icon>mdi-close</v-icon>
                </v-btn>
              </v-card-title>
              <v-form
                ref="form"
                v-model="valid"
                lazy-validation
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
69
              >
krlsnvz93's avatar
krlsnvz93 committed
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 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 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 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 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 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 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836
                <v-card-text>
                  <v-autocomplete
                    v-model="editedItem.categoria"
                    :items="categories"
                    item-text="nombre"
                    :rules="healthAreaRules"
                    item-value="id"
                    label="Categoría"
                  />
                  <v-container>
                    <v-card style="margin-bottom: 4px">
                      <v-card-title>Datos Personales</v-card-title>
                      <v-card-text>
                        <v-row>
                          <v-col
                            cols="12"
                            sm="6"
                            md="4"
                          >
                            <v-text-field
                              v-model="editedItem.nombre"
                              label="Nombre"
                              :rules="nameRules"
                            />
                          </v-col>
                          <v-col
                            cols="12"
                            sm="6"
                            md="8"
                          >
                            <v-text-field
                              v-model="editedItem.apellidos"
                              label="Apellidos"
                              :rules="lastNameRules"
                            />
                          </v-col>
                          <v-col
                            cols="12"
                            sm="6"
                            md="4"
                          >
                            <v-text-field
                              v-model="editedItem.ci"
                              label="Carné de Identidad"
                              :counter="11"
                              :rules="ciRules"
                            />
                          </v-col>
                          <v-col
                            cols="12"
                            sm="6"
                            md="4"
                          >
                            <v-text-field
                              v-model="editedItem.edad"
                              label="Edad"
                              :rules="numberRules"
                            />
                          </v-col>
                          <v-col
                            cols="12"
                            sm="6"
                            md="4"
                          >
                            <v-autocomplete
                              v-model="editedItem.sexo"
                              :items="sexes"
                              item-text="nombre"
                              item-value="id"
                              :rules="healthAreaRules"
                              label="Sexo"
                            />
                          </v-col>
                        </v-row>
                      </v-card-text>
                    </v-card>
                    <v-card>
                      <v-card-title>Dirección</v-card-title>
                      <v-card-text>
                        <v-row>
                          <v-col
                            cols="12"
                          >
                            <v-text-field
                              v-model="editedItem.direccion"
                              label="Dirección"
                              :rules="healthAreaRules"
                            />
                          </v-col>
                          <v-col
                            cols="12"
                            sm="6"
                            md="4"
                          >
                            <v-autocomplete
                              v-model="editedItem.provincia"
                              :items="provinces"
                              item-text="nombre"
                              no-data-text="No se pudo conectar con el servidor"
                              item-value="id"
                              :rules="healthAreaRules"
                              label="Provincia"
                              @change="loadMunicipalitiesData(editedItem.provincia)"
                            />
                          </v-col>
                          <v-col
                            cols="12"
                            sm="6"
                            md="4"
                          >
                            <v-autocomplete
                              v-model="editedItem.municipio"
                              :items="municipalities"
                              no-data-text="Debe seleccionar una provincia"
                              item-text="nombre"
                              item-value="id"
                              :rules="healthAreaRules"
                              label="Municipio"
                              @change="getHealthAreaData(editedItem.municipio)"
                            />
                          </v-col>
                        </v-row>
                      </v-card-text>
                    </v-card>
                    <v-card
                      style="margin-top: 4px"
                    >
                      <v-card-text>
                        <v-row>
                          <v-col
                            cols="12"
                            sm="6"
                            md="4"
                          >
                            <v-autocomplete
                              v-model="editedItem.area_salud"
                              :items="healthAreas"
                              :rules="healthAreaRules"
                              item-text="nombre"
                              item-value="id"
                              label="Área de Salud"
                              no-data-text="Debe seleccionar un municipio"
                            />
                          </v-col>
                          <v-col
                            cols="12"
                            sm="6"
                            md="4"
                          >
                            <v-text-field
                              v-model="editedItem.cmf"
                              label="C.M.F."
                            />
                          </v-col>
                          <v-col
                            cols="12"
                            sm="6"
                            md="4"
                          >
                            <v-tooltip bottom>
                              <template v-slot:activator="{ on, attrs }">
                                <v-combobox
                                  v-model="editedItem.remite_caso"
                                  v-bind="attrs"
                                  :items="remissionTypes"
                                  label="Remite el Caso"
                                  v-on="on"
                                />
                              </template>
                              <span>En caso de no estar escriba de donde lo remiten</span>
                            </v-tooltip>
                          </v-col>
                        <!-- <v-col
                          cols="12"
                          sm="6"
                          md="4"
                        >
                          <v-text-field
                            v-model="editedItem.remissionCenter.name"
                            :disabled="disableRemissionCenterName"
                            label="Nombre"
                          />
                        </v-col> -->
                        </v-row>
                      </v-card-text>
                    </v-card>
                    <v-card
                      style="margin-top: 4px"
                      fluid
                    >
                      <v-card-title>Sintomatología</v-card-title>
                      <v-card-text>
                        <v-row>
                          <v-col
                            cols="12"
                            sm="6"
                            md="4"
                          >
                            <v-checkbox
                              v-model="asymptomatic"
                              label="Asintomático(a)"
                            />
                          </v-col>
                          <v-col
                            v-if="!asymptomatic"
                            cols="12"
                            sm="6"
                            md="4"
                          >
                            <v-menu
                              ref="menu"
                              v-model="menu"
                              :close-on-content-click="false"
                              :return-value.sync="editedItem.fecha_sintomas"
                              transition="scale-transition"
                              offset-y
                              min-width="auto"
                            >
                              <template v-slot:activator="{ on, attrs }">
                                <v-text-field
                                  v-model="editedItem.fecha_sintomas"

                                  label="FIS"
                                  readonly
                                  v-bind="attrs"
                                  v-on="on"
                                />
                              </template>
                              <v-date-picker
                                v-model="editedItem.fecha_sintomas"

                                no-title
                                scrollable
                              >
                                <v-spacer />
                                <v-btn
                                  text
                                  color="primary"
                                  @click="menu = false"
                                >
                                  Cancelar
                                </v-btn>
                                <v-btn
                                  text
                                  color="primary"
                                  @click="$refs.menu.save(editedItem.fecha_sintomas)"
                                >
                                  OK
                                </v-btn>
                              </v-date-picker>
                            </v-menu>
                          </v-col>
                        </v-row>
                        <v-row
                          v-if="!asymptomatic"
                        >
                          <v-col
                            cols="12"
                            sm="6"
                            md="4"
                          >
                            <v-checkbox
                              v-model="editedItem.fiebre"
                              label="Fiebre >38ºC"
                            />
                          </v-col>
                          <v-col
                            cols="12"
                            sm="6"
                            md="4"
                          >
                            <v-checkbox
                              v-model="editedItem.rinorrea"
                              label="Rinorrea"
                            />
                          </v-col>
                          <v-col
                            cols="12"
                            sm="6"
                            md="4"
                          >
                            <v-checkbox
                              v-model="editedItem.congestion_nasal"
                              label="Congestión Nasal"
                            />
                          </v-col>
                          <v-col
                            cols="12"
                            sm="6"
                            md="4"
                          >
                            <v-checkbox
                              v-model="editedItem.tos"
                              label="Tos"
                            />
                          </v-col>
                          <v-col
                            cols="12"
                            sm="6"
                            md="4"
                          >
                            <v-checkbox
                              v-model="editedItem.expectoracion"
                              label="Expectoracion"
                            />
                          </v-col>
                          <v-col
                            cols="12"
                            sm="6"
                            md="4"
                          >
                            <v-checkbox
                              v-model="editedItem.dolor_garganta"
                              label="Dolor de garganta"
                            />
                          </v-col>
                          <v-col
                            cols="12"
                            sm="6"
                            md="4"
                          >
                            <v-checkbox
                              v-model="editedItem.cefalea"
                              label="Cefalea"
                            />
                          </v-col>
                          <v-col
                            cols="12"
                            sm="6"
                            md="4"
                          >
                            <v-checkbox
                              v-model="editedItem.dificultad_respiratoria"
                              label="Dificultad Respiratoria"
                            />
                          </v-col>
                          <v-col
                            cols="12"
                            sm="6"
                            md="4"
                          >
                            <v-checkbox
                              v-model="othersS"
                              label="Otros"
                            />
                          </v-col>
                          <v-col
                            cols="12"
                            sm="12"
                            md="12"
                          >
                            <v-text-field
                              v-model="editedItem.otros_sint"
                              :disabled="!othersS"
                              label="Otros Síntomas"
                            />
                          </v-col>
                        </v-row>
                      </v-card-text>
                    </v-card>
                    <v-card
                      style="margin-top: 4px"
                      fluid
                    >
                      <v-card-title>Antecedentes Patológicos Personales</v-card-title>
                      <v-card-text>
                        <v-row>
                          <v-col
                            cols="12"
                            sm="6"
                            md="4"
                          >
                            <v-checkbox
                              v-model="noApp"
                              label="No refiere"
                            />
                          </v-col>
                        </v-row>
                        <v-row
                          v-if="!noApp"
                        >
                          <v-col
                            cols="12"
                            sm="6"
                            md="4"
                          >
                            <v-checkbox
                              v-model="editedItem.hipertension"
                              label="HTA"
                            />
                          </v-col>
                          <v-col
                            cols="12"
                            sm="6"
                            md="4"
                          >
                            <v-checkbox
                              v-model="editedItem.diabetes"
                              label="Diabetes"
                            />
                          </v-col>
                          <!-- <v-col
                          cols="12"
                          sm="6"
                          md="4"
                        >
                          <v-checkbox
                            v-model="editedItem.apps."
                            label="DM Tipo II"
                            value="dm2"
                          />
                        </v-col> -->
                          <v-col
                            cols="12"
                            sm="6"
                            md="4"
                          >
                            <v-checkbox
                              v-model="editedItem.asma"
                              label="Asma"
                            />
                          </v-col>
                          <v-col
                            cols="12"
                            sm="6"
                            md="4"
                          >
                            <v-checkbox
                              v-model="editedItem.obesidad"
                              label="Obesidad"
                            />
                          </v-col>
                          <v-col
                            cols="12"
                            sm="6"
                            md="4"
                          >
                            <v-checkbox
                              v-model="editedItem.insuficiencia_renal"
                              label="Insuficiencia Renal"
                            />
                          </v-col>
                          <v-col
                            cols="12"
                            sm="6"
                            md="4"
                          >
                            <v-checkbox
                              v-model="editedItem.oncologia"
                              label="Oncología"
                            />
                          </v-col>
                          <v-col
                            cols="12"
                            sm="6"
                            md="4"
                          >
                            <v-checkbox
                              v-model="othersApp"
                              label="Otros"
                            />
                          </v-col>
                          <v-col
                            cols="12"
                            sm="12"
                            md="12"
                          >
                            <v-text-field
                              v-model="editedItem.otros_apps"
                              :disabled="!othersApp"
                              label="Otros APP de interés"
                            />
                          </v-col>
                        </v-row>
                      </v-card-text>
                    </v-card>
                    <v-card
                      style="margin-top: 4px"
                      fluid
                    >
                      <v-card-title>Contacto de Caso Positivo</v-card-title>
                      <v-card-text>
                        <v-row>
                          <v-col
                            cols="12"
                            sm="6"
                            md="6"
                          >
                            <v-checkbox
                              v-model="isContact"
                              label="Es contacto de Caso Positivo"
                            />
                          </v-col>
                          <v-col
                            cols="12"
                            sm="6"
                            md="6"
                          >
                            <v-menu
                              ref="menu2"
                              v-model="menu2"
                              :disabled="!isContact"
                              :close-on-content-click="false"
                              :return-value.sync="editedItem.fecha_contacto"
                              transition="scale-transition"
                              offset-y
                              min-width="auto"
                            >
                              <template v-slot:activator="{ on, attrs }">
                                <v-text-field
                                  v-model="editedItem.fecha_contacto"
                                  :disabled="!isContact"
                                  label="Fecha de Contacto"
                                  prepend-icon="mdi-calendar"
                                  readonly
                                  v-bind="attrs"
                                  v-on="on"
                                />
                              </template>
                              <v-date-picker
                                v-model="editedItem.fecha_contacto"
                                :disabled="!isContact"
                                no-title
                                scrollable
                              >
                                <v-spacer />
                                <v-btn
                                  text
                                  color="primary"
                                  @click="menu2 = false"
                                >
                                  Cancelar
                                </v-btn>
                                <v-btn
                                  text
                                  color="primary"
                                  @click="$refs.menu2.save(editedItem.fecha_contacto)"
                                >
                                  OK
                                </v-btn>
                              </v-date-picker>
                            </v-menu>
                          </v-col>
                          <v-col
                            cols="12"
                          >
                            <v-text-field
                              v-model="editedItem.tipo_contacto"
                              :disabled="!isContact"
                              label="Tipo de Contacto"
                            />
                          </v-col>
                          <v-col
                            cols="12"
                          >
                            <v-text-field
                              v-model="editedItem.lugar_contacto"
                              :disabled="!isContact"
                              label="Lugar de Contacto"
                            />
                          </v-col>
                        </v-row>
                      </v-card-text>
                    </v-card>
                    <v-card
                      style="margin-top: 4px"
                      fluid
                    >
                      <v-card-title>Arribado</v-card-title>
                      <v-card-text>
                        <v-row>
                          <v-col
                            cols="12"
                            sm="8"
                            md="8"
                          >
                            <v-checkbox
                              v-model="arrived"
                              label="¿Ha arribado del extranjero en los últimos 15 días?"
                            />
                          </v-col>
                          <v-col
                            cols="12"
                            sm="6"
                            md="4"
                          >
                            <v-autocomplete
                              v-model="editedItem.pais_procedencia"
                              :disabled="!arrived"
                              :items="countriesD"
                              item-text="name_es"
                              item-value="name_es"
                              label="País de procedencia"
                            />
                          </v-col>
                          <v-col
                            cols="12"
                            sm="12"
                            md="12"
                          >
                            <v-text-field
                              v-model="editedItem.lugar_estancia"
                              :disabled="!arrived"
                              label="Lugar de Residencia"
                            />
                          </v-col>
                          <v-col
                            cols="12"
                            sm="6"
                            md="6"
                          >
                            <v-menu
                              ref="menu3"
                              v-model="menu3"
                              :disabled="!arrived"
                              :close-on-content-click="false"
                              :return-value.sync="editedItem.fecha_arribo"
                              transition="scale-transition"
                              offset-y
                              min-width="auto"
                            >
                              <template v-slot:activator="{ on, attrs }">
                                <v-text-field
                                  v-model="editedItem.fecha_arribo"
                                  :disabled="!arrived"
                                  label="Fecha de Arribo"
                                  prepend-icon="mdi-calendar"
                                  readonly
                                  v-bind="attrs"
                                  v-on="on"
                                />
                              </template>
                              <v-date-picker
                                v-model="editedItem.fecha_arribo"
                                :disabled="!arrived"
                                no-title
                                scrollable
                              >
                                <v-spacer />
                                <v-btn
                                  text
                                  color="primary"
                                  @click="menu3 = false"
                                >
                                  Cancelar
                                </v-btn>
                                <v-btn
                                  text
                                  color="primary"
                                  @click="$refs.menu3.save(editedItem.fecha_arribo)"
                                >
                                  OK
                                </v-btn>
                              </v-date-picker>
                            </v-menu>
                          </v-col>
                        </v-row>
                      </v-card-text>
                    </v-card>
                    <v-card
                      style="margin-top: 4px"
                      fluid
                    >
                      <v-card-title>Otros Datos de Interés</v-card-title>
                      <v-card-text>
                        <v-row>
                          <v-col
                            cols="12"
                            sm="6"
                            md="4"
                          >
                            <v-autocomplete
                              v-model="editedItem.test_antigeno"
                              :items="antigensData"
                              item-text="nombre"
                              item-value="id"
                              no-data-text="No se pudo conectar con el servidor"
                              label="Test Antígeno"
                            />
                          </v-col>
                          <v-col
                            cols="12"
                            sm="6"
                            md="4"
                          >
                            <v-autocomplete
                              v-model="editedItem.estado_sistema"
                              :items="systemStatusesData"
                              item-text="nombre"
                              no-data-text="No se pudo conectar con el servidor"
                              item-value="id"
                              label="Estado de Salud"
                            />
                          </v-col>
                          <v-col
                            cols="12"
                            sm="6"
                            md="4"
                          >
                            <v-checkbox
                              v-model="editedItem.trabajador_salud"
                              label="ES TRABAJADOR DE SALUD"
                            />
                          </v-col>
                          <v-col
                            cols="12"
                            sm="6"
                            md="4"
                          >
                            <v-checkbox
                              v-model="editedItem.vacunado"
                              label="ESTÁ VACUNADO"
                            />
                          </v-col>
                          <v-col
                            cols="12"
                            sm="6"
                            md="4"
                          >
                            <v-checkbox
                              v-model="editedItem.embarazada"
                              :disabled="disablePregnant"
                              label="Embarazada"
                            />
                          </v-col>
                          <v-col
                            cols="12"
                            sm="6"
                            md="4"
                          >
                            <v-checkbox
                              v-model="editedItem.ninho"
                              :disabled="disableChild"
                              label="Niño"
                              value="child"
                            />
                          </v-col>
                        </v-row>
                      </v-card-text>
                    </v-card>
                  </v-container>
                </v-card-text>
              </v-form>

              <v-card-actions>
                <v-spacer />
                <v-btn
                  color="blue darken-1"
                  text
                  @click="close"
                >
                  Cancelar
                </v-btn>
                <v-btn
                  color="blue darken-1"
                  text
                  @click="save"
                >
                  Guardar
                </v-btn>
              </v-card-actions>
            </v-card>
          </v-dialog>
          <v-dialog
            v-model="dialogDelete"
            max-width="500px"
            persistent
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
837
          >
krlsnvz93's avatar
krlsnvz93 committed
838 839 840 841
            <v-card>
              <v-card-title
                class="text-h5"
                style="word-break: normal"
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
842
              >
krlsnvz93's avatar
krlsnvz93 committed
843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971
                ¿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>
          <v-dialog
            v-model="dialogDeleteUnavailable"
            max-width="500px"
            persistent
          >
            <v-card>
              <v-card-title class="text-h5">
                Este Centro no se puede eliminar porque tiene camas en uso!!!!
              </v-card-title>
              <v-card-actions>
                <v-spacer />
                <v-btn
                  color="blue darken-1"
                  text
                  @click="closeDeleteU"
                >
                  OK
                </v-btn>
                <v-spacer />
              </v-card-actions>
            </v-card>
          </v-dialog>
        </v-toolbar>
      </template>
      <template v-slot:item.actions="{ item }">
        <v-tooltip bottom>
          <template v-slot:activator="{ on, attrs }">
            <v-icon
              class="mr-2"
              color="orange"
              v-bind="attrs"
              :loading="loadingPatientsData"
              v-on="on"
              @click="editItem(item)"
            >
              mdi-pencil
            </v-icon>
          </template>
          <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)"
            >
              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"
              @click="detailsItem(item)"
            >
              mdi-dots-horizontal-circle
            </v-icon>
          </template>
          <span>Detalle Paciente</span>
        </v-tooltip>
        <v-tooltip
          bottom
        >
          <template v-slot:activator="{ on, attrs }">
            <v-icon
              class="mr-2"
              color="grey"
              v-bind="attrs"
              v-on="on"
              @click="admit(item)"
            >
              mdi-clipboard-check
            </v-icon>
          </template>
          <span>Asignar Capacidad</span>
        </v-tooltip>
        <v-tooltip
          v-if="item.status !== 'Ingresado'"
          bottom
        >
          <template v-slot:activator="{ on, attrs }">
            <v-icon
              class="mr-2"
              color="success"
              v-bind="attrs"
              v-on="on"
              @click="admit(item)"
            >
              mdi-notebook-check
            </v-icon>
          </template>
          <span>Ingresar</span>
        </v-tooltip>
      </template>
      <template v-slot:no-data>
        No hay datos disponibles
      </template>
    </v-data-table>
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
972 973 974 975 976 977
    <v-dialog
      v-model="infoPatient"
      persistent
      max-width="800px"
    >
      <patient-file
krlsnvz93's avatar
krlsnvz93 committed
978
        :patient="editedItem"
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
979
        @close-click="closeDetails"
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
980 981
      />
    </v-dialog>
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
982 983 984 985
  </div>
</template>

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

krlsnvz93's avatar
krlsnvz93 committed
987 988
  import InfoBox from '@/components/InfoBox.vue'
  import { COUNTRIES } from '@/utils/constants'
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
989
  import PatientFile from '@/components/PatientFile.vue'
krlsnvz93's avatar
krlsnvz93 committed
990 991 992
  import { isLastName, isId, isPositiveNumber, isCmf } from '@/utils/regex'
  import { getPatients, getPatient, postPatient, deletePatient, putPatient } from '@/axios/patients'
  import { getCategories, getHealthStatus, getSystemStatus, getAntigenos, getProvinces, getMunicipalities, getHealthAreas } from '@/axios/nomenclators'
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
993
  export default {
krlsnvz93's avatar
krlsnvz93 committed
994
    components: { InfoBox, PatientFile },
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
995
    data: () => ({
krlsnvz93's avatar
krlsnvz93 committed
996
      remissionTypes: ['Policlínico', 'C.M.F.', 'Hospital'],
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
997
      antigensData: [],
krlsnvz93's avatar
krlsnvz93 committed
998 999 1000
      patientsFilters: {
        page: 1,
      },
Yoelvis Gonzalez's avatar
ok  
Yoelvis Gonzalez committed
1001 1002
      patientsFirstLoad: true,
      totalPatientsItems: 0,
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1003 1004 1005 1006
      infoPatient: false,
      toDeleteId: -1,
      loadingPatientsData: false,
      valid: false,
krlsnvz93's avatar
krlsnvz93 committed
1007 1008 1009 1010 1011
      arrived: false,
      isContact: false,
      noApp: true,
      othersS: false,
      othersApp: false,
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1012
      asymptomatic: true,
krlsnvz93's avatar
krlsnvz93 committed
1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035
      healthAreaRules: [
        v => !!v || 'Este campo es requerido',
      ],
      cmfRules: [
        v => isCmf(v) || 'Este campo es requerido',
      ],
      numberRules: [
        v => !!v || 'Este campo es requerido',
        v => isPositiveNumber(v) || 'Debe chequear la edad',
      ],
      ciRules: [
        v => !!v || 'El Carné es requerido',
        v => isId(v) || 'Debe chequear el carné',
      ],
      nameRules: [
        v => !!v || 'Este campo es requerido',
        v => isLastName(v) || 'Debe chequear el nombre',
      ],
      lastNameRules: [
        v => !!v || 'Este campo es requerido',
        v => isLastName(v) || 'Debe chequear el nombre',
      ],
      menu: false,
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1036
      modal: false,
krlsnvz93's avatar
krlsnvz93 committed
1037 1038
      menu2: false,
      menu3: false,
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1039 1040 1041
      dialogDeleteUnavailable: false,
      dialog: false,
      dialogDelete: false,
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1042
      healthAreas: [],
krlsnvz93's avatar
krlsnvz93 committed
1043 1044 1045 1046
      sexes: [
        { nombre: 'Masculino', id: 'M' }, { nombre: 'Femenino', id: 'F' },
      ],
      municipalities: [],
Yoelvis Gonzalez's avatar
ok  
Yoelvis Gonzalez committed
1047
      categories: [],
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1048 1049 1050 1051
      headers: [
        {
          text: 'CI',
          align: 'start',
krlsnvz93's avatar
krlsnvz93 committed
1052
          sortable: true,
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1053 1054
          value: 'ci',
        },
krlsnvz93's avatar
krlsnvz93 committed
1055 1056
        { text: 'Nombre', value: 'nombre' },
        { text: 'Apellidos', value: 'apellidos' },
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1057 1058 1059
        { text: 'Acciones', value: 'actions', sortable: false },
      ],
      patients: [],
krlsnvz93's avatar
krlsnvz93 committed
1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110
      editedIndex: -1,
      editedItem: {
        nombre: '',
        apellidos: '',
        ci: '',
        edad: 0,
        sexo: '',
        direccion: '',
        municipio: '',
        provincia: '',
        cmf: '',
        area_salud: '',
        remite_caso: '',
        estado_sistema: '',
        trabajador_salud: false,
        ninho: false,
        embarazada: false,
        vacunado: false,
        test_antigeno: 2,
        sintomas: [],
        app: [],

        // 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
1111
      defaultItem: {
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1112 1113
        nombre: '',
        apellidos: '',
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1114
        ci: '',
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1115 1116 1117 1118 1119
        edad: 0,
        sexo: '',
        direccion: '',
        municipio: '',
        provincia: '',
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1120
        cmf: '',
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1121 1122 1123
        area_salud: '',
        remite_caso: '',
        sintomas: [],
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1124
        app: [],
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1125 1126 1127 1128 1129
        estado_sistema: '',
        trabajador_salud: false,
        ninho: false,
        embarazada: false,
        vacunado: false,
krlsnvz93's avatar
krlsnvz93 committed
1130
        test_antigeno: 2,
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158

        // 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
1159 1160 1161 1162
      },
    }),

    computed: {
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1163 1164 1165
      provinces () {
        return this.$store.getters.provinces
      },
krlsnvz93's avatar
krlsnvz93 committed
1166 1167
      countriesD () {
        return COUNTRIES
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1168
      },
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1169
      formTitle () {
krlsnvz93's avatar
krlsnvz93 committed
1170 1171 1172 1173 1174 1175 1176
        return this.editedIndex === -1 ? 'Registrar Paciente' : 'Editar datos de paciente'
      },
      disablePregnant () {
        return this.editedItem.ninho
      },
      disableChild () {
        return this.editedItem.embarazada
krlsnvz93's avatar
krlsnvz93 committed
1177
      },
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1178
      disableRemissionCenterName () {
krlsnvz93's avatar
krlsnvz93 committed
1179 1180 1181 1182
        return (this.editedItem.remissionCenter.type !== 'Hospital') && (this.editedItem.remissionCenter.type !== 'Otro')
      },
      patientIsAsymptomatic () {
        return this.editedItem.sintomas.fecha_sintomas !== null
krlsnvz93's avatar
krlsnvz93 committed
1183
      },
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1184 1185 1186
      systemStatusesData () {
        return this.$store.getters.systemStatuses
      },
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1187 1188
    },

krlsnvz93's avatar
krlsnvz93 committed
1189 1190 1191 1192 1193 1194 1195 1196 1197
    watch: {
      dialog (val) {
        val || this.close()
      },
      dialogDelete (val) {
        val || this.closeDelete()
      },
    },

Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1198
    created () {
Yoelvis Gonzalez's avatar
fixes  
Yoelvis Gonzalez committed
1199
      this.loadPatientsData()
krlsnvz93's avatar
krlsnvz93 committed
1200 1201 1202 1203 1204
      this.getCategoriesData()
      this.getSystemStatusData()
      this.getHealthStatusData()
      getProvinces()
      this.getAntigenData()
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1205 1206 1207
    },

    methods: {
krlsnvz93's avatar
krlsnvz93 committed
1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227
      async loadMunicipalitiesData (id) {
        console.log(id)
        try {
          const municipalitiesRes = await getMunicipalities(id)
          this.municipalities = municipalitiesRes.data
        } catch (e) {
          this.$toast.error(e.toString(), {
            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
1228 1229
        }
      },
krlsnvz93's avatar
krlsnvz93 committed
1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248
      async getCategoriesData () {
        try {
          const categoriesResponse = await getCategories()
          this.categories = categoriesResponse.data
        } catch (e) {
          this.$toast.error(e.toString(), {
            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
1249 1250
        }
      },
krlsnvz93's avatar
krlsnvz93 committed
1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269
      async getSystemStatusData () {
        try {
          const systemResponse = await getSystemStatus()
          this.$store.commit('setSystemStatuses', systemResponse.data)
        } catch (e) {
          this.$toast.error(e.toString(), {
            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
1270 1271
        }
      },
krlsnvz93's avatar
krlsnvz93 committed
1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291
      async getAntigenData () {
        try {
          const antigenResponse = await getAntigenos()
          this.antigensData = antigenResponse.data
        } catch (e) {
          this.$toast.error(e.toString(), {
            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
1292
      },
krlsnvz93's avatar
krlsnvz93 committed
1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312
      async getHealthStatusData () {
        try {
          const healthResponse = await getHealthStatus()
          this.healthData = healthResponse.data
        } catch (e) {
          this.$toast.error(e.toString(), {
            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
1313
      },
krlsnvz93's avatar
krlsnvz93 committed
1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333
      async getHealthAreaData (id) {
        try {
          const healthAreaResponse = await getHealthAreas(id)
          this.healthAreas = healthAreaResponse.data
        } catch (e) {
          this.$toast.error(e.toString(), {
            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
1334
      },
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1335
      async detailsItem (item) {
krlsnvz93's avatar
krlsnvz93 committed
1336
        this.loadingPatientsData = true
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1337 1338
        try {
          const patientResponse = await getPatient(item.id_paciente)
krlsnvz93's avatar
krlsnvz93 committed
1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383
          this.editedItem = Object.assign({}, patientResponse.data.paciente)
          if (this.editedItem.apps !== null) {
            this.editedItem.hipertension = this.editedItem.apps.hipertension
            this.editedItem.diabetes = this.editedItem.apps.diabetes
            this.editedItem.asma = this.editedItem.apps.asma
            this.editedItem.obesidad = this.editedItem.apps.obesidad
            this.editedItem.insuficiencia_renal = this.editedItem.apps.insuficiencia_renal
            this.editedItem.oncologia = this.editedItem.apps.oncologia
            this.editedItem.otros_apps = this.editedItem.apps.otros
            if (this.editedItem.hipertension || this.editedItem.diabetes || this.editedItem.asma || this.editedItem.obesidad || this.editedItem.insuficiencia_renal || this.editedItem.oncologia || this.editedItem.otros_apps) {
              this.noApp = false
            }
          }
          if (this.editedItem.sintomas !== null) {
            this.editedItem.fecha_sintomas = this.editedItem.sintomas.fecha_sintomas
            this.editedItem.fiebre = this.editedItem.sintomas.fiebre
            this.editedItem.rinorrea = this.editedItem.sintomas.rinorrea
            this.editedItem.congestion_nasal = this.editedItem.sintomas.congestion_nasal
            this.editedItem.tos = this.editedItem.sintomas.tos
            this.editedItem.expectoracion = this.editedItem.sintomas.expectoracion
            this.editedItem.dificultad_respiratoria = this.editedItem.sintomas.dificultad_respiratoria
            this.editedItem.cefalea = this.editedItem.sintomas.cefalea
            this.editedItem.dolor_garganta = this.editedItem.sintomas.dolor_garganta
            this.editedItem.otros_sint = this.editedItem.sintomas.otros
            if (this.editedItem.fecha_sintomas || this.editedItem.fiebre || this.editedItem.rinorrea || this.editedItem.congestion_nasal || this.editedItem.tos || this.editedItem.expectoracion || this.editedItem.dificultad_respiratoria || this.editedItem.cefalea || this.editedItem.dolor_garganta || this.editedItem.otros_sint) {
              this.asymptomatic = false
            }
          }
          if (this.editedItem.contacto !== null) {
            this.editedItem.fecha_contacto = this.editedItem.contacto.fecha_contacto
            this.editedItem.lugar_contacto = this.editedItem.contacto.lugar_contacto
            this.editedItem.tipo_contacto = this.editedItem.contacto.tipo_contacto
            if (this.editedItem.fecha_contacto || this.editedItem.lugar_contacto || this.editedItem.tipo_contacto) {
              this.isContact = true
            }
          }
          if (this.editedItem.arribo !== null) {
            this.editedItem.pais_procedencia = this.editedItem.arribo.pais_procedencia
            this.editedItem.lugar_estancia = this.editedItem.arribo.lugar_estancia
            this.editedItem.fecha_arribo = this.editedItem.arribo.fecha_arribo
            if (this.editedItem.pais_procedencia || this.editedItem.lugar_estancia || this.editedItem.fecha_arribo) {
              this.arrived = true
            }
          }
          this.loadingPatientsData = false
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1384 1385
          this.infoPatient = true
        } catch (e) {
krlsnvz93's avatar
krlsnvz93 committed
1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399
          this.$toast.error(e.toString(), {
            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
1400
        }
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1401
      },
krlsnvz93's avatar
krlsnvz93 committed
1402 1403 1404 1405
      closeDeleteU () {
        this.dialogDeleteUnavailable = false
      },
      async loadPatientsData (page = 1) {
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1406 1407
        this.loadingPatientsData = true
        try {
krlsnvz93's avatar
krlsnvz93 committed
1408
          const patientsResponse = await getPatients(page)
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1409 1410 1411
          this.totalPatientsItems = patientsResponse.data.meta.total
          this.patients = patientsResponse.data.pacientes
          this.loadingPatientsData = false
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1412
        } catch (e) {
krlsnvz93's avatar
krlsnvz93 committed
1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426
          this.$toast.error(e.toString(), {
            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
1427 1428
        }
      },
krlsnvz93's avatar
krlsnvz93 committed
1429

Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1430
      async editItem (item) {
krlsnvz93's avatar
krlsnvz93 committed
1431
        this.loadingPatientsData = true
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1432
        try {
krlsnvz93's avatar
krlsnvz93 committed
1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444
          const patientResponse = await getPatient(item.id_paciente)
          this.editedItem = Object.assign({}, patientResponse.data.paciente)
          if (this.editedItem.apps !== null) {
            this.editedItem.hipertension = this.editedItem.apps.hipertension
            this.editedItem.diabetes = this.editedItem.apps.diabetes
            this.editedItem.asma = this.editedItem.apps.asma
            this.editedItem.obesidad = this.editedItem.apps.obesidad
            this.editedItem.insuficiencia_renal = this.editedItem.apps.insuficiencia_renal
            this.editedItem.oncologia = this.editedItem.apps.oncologia
            this.editedItem.otros_apps = this.editedItem.apps.otros
            if (this.editedItem.hipertension || this.editedItem.diabetes || this.editedItem.asma || this.editedItem.obesidad || this.editedItem.insuficiencia_renal || this.editedItem.oncologia || this.editedItem.otros_apps) {
              this.noApp = false
Yoelvis Gonzalez's avatar
fixes  
Yoelvis Gonzalez committed
1445
            }
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1446
          }
krlsnvz93's avatar
krlsnvz93 committed
1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459
          if (this.editedItem.sintomas !== null) {
            this.editedItem.fecha_sintomas = this.editedItem.sintomas.fecha_sintomas
            this.editedItem.fiebre = this.editedItem.sintomas.fiebre
            this.editedItem.rinorrea = this.editedItem.sintomas.rinorrea
            this.editedItem.congestion_nasal = this.editedItem.sintomas.congestion_nasal
            this.editedItem.tos = this.editedItem.sintomas.tos
            this.editedItem.expectoracion = this.editedItem.sintomas.expectoracion
            this.editedItem.dificultad_respiratoria = this.editedItem.sintomas.dificultad_respiratoria
            this.editedItem.cefalea = this.editedItem.sintomas.cefalea
            this.editedItem.dolor_garganta = this.editedItem.sintomas.dolor_garganta
            this.editedItem.otros_sint = this.editedItem.sintomas.otros
            if (this.editedItem.fecha_sintomas || this.editedItem.fiebre || this.editedItem.rinorrea || this.editedItem.congestion_nasal || this.editedItem.tos || this.editedItem.expectoracion || this.editedItem.dificultad_respiratoria || this.editedItem.cefalea || this.editedItem.dolor_garganta || this.editedItem.otros_sint) {
              this.asymptomatic = false
Yoelvis Gonzalez's avatar
fixes  
Yoelvis Gonzalez committed
1460
            }
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1461
          }
krlsnvz93's avatar
krlsnvz93 committed
1462 1463 1464 1465 1466 1467
          if (this.editedItem.contacto !== null) {
            this.editedItem.fecha_contacto = this.editedItem.contacto.fecha_contacto
            this.editedItem.lugar_contacto = this.editedItem.contacto.lugar_contacto
            this.editedItem.tipo_contacto = this.editedItem.contacto.tipo_contacto
            if (this.editedItem.fecha_contacto || this.editedItem.lugar_contacto || this.editedItem.tipo_contacto) {
              this.isContact = true
Yoelvis Gonzalez's avatar
fixes  
Yoelvis Gonzalez committed
1468
            }
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1469
          }
krlsnvz93's avatar
krlsnvz93 committed
1470 1471 1472 1473 1474 1475
          if (this.editedItem.arribo !== null) {
            this.editedItem.pais_procedencia = this.editedItem.arribo.pais_procedencia
            this.editedItem.lugar_estancia = this.editedItem.arribo.lugar_estancia
            this.editedItem.fecha_arribo = this.editedItem.arribo.fecha_arribo
            if (this.editedItem.pais_procedencia || this.editedItem.lugar_estancia || this.editedItem.fecha_arribo) {
              this.arrived = true
Yoelvis Gonzalez's avatar
fixes  
Yoelvis Gonzalez committed
1476
            }
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1477 1478
          }
        } catch (e) {
krlsnvz93's avatar
krlsnvz93 committed
1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492
          this.$toast.error(e.toString(), {
            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
1493
        }
krlsnvz93's avatar
krlsnvz93 committed
1494
        this.editedIndex = this.patients.indexOf(item)
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1495
        this.dialog = true
krlsnvz93's avatar
krlsnvz93 committed
1496 1497 1498
        this.$refs.form.resetValidation()

        this.loadingPatientsData = false
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1499
      },
Yoelvis Gonzalez's avatar
ok  
Yoelvis Gonzalez committed
1500 1501 1502
      paginatePatients (pageInfo) {
        if (this.patientsFirstLoad) {
          this.patientsFirstLoad = false
krlsnvz93's avatar
krlsnvz93 committed
1503
          return
Yoelvis Gonzalez's avatar
ok  
Yoelvis Gonzalez committed
1504
        }
krlsnvz93's avatar
krlsnvz93 committed
1505 1506
        this.patientsFilters.page = pageInfo.page
        this.loadPatientsData(pageInfo.page)
Yoelvis Gonzalez's avatar
ok  
Yoelvis Gonzalez committed
1507
      },
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1508 1509

      deleteItem (item) {
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1510
        this.toDeleteId = item.id_paciente
krlsnvz93's avatar
krlsnvz93 committed
1511 1512
        this.editedIndex = this.patients.indexOf(item)
        this.editedItem = Object.assign({}, item)
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1513
        this.dialogDelete = true
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1514
      },
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1515 1516
      async deleteItemConfirm () {
        this.loadingPatientsData = true
krlsnvz93's avatar
krlsnvz93 committed
1517
        this.patients.splice(this.editedIndex, 1)
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1518 1519
        try {
          await deletePatient(this.toDeleteId)
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533
          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
1534 1535
          this.loadPatientsData()
        } catch (e) {
krlsnvz93's avatar
krlsnvz93 committed
1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549
          this.$toast.error(e.toString(), {
            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
1550
        }
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1551
        this.closeDelete()
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1552
        this.loadingPatientsData = false
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1553
      },
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1554

Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1555 1556
      close () {
        this.dialog = false
krlsnvz93's avatar
krlsnvz93 committed
1557 1558
        this.$refs.form.resetValidation()

Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1559
        this.$nextTick(() => {
krlsnvz93's avatar
krlsnvz93 committed
1560 1561
          this.editedItem = Object.assign({}, this.defaultItem)
          this.editedIndex = -1
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1562 1563 1564 1565 1566
        })
      },
      closeDelete () {
        this.dialogDelete = false
        this.$nextTick(() => {
krlsnvz93's avatar
krlsnvz93 committed
1567 1568
          this.editedItem = Object.assign({}, this.defaultItem)
          this.editedIndex = -1
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1569 1570
        })
      },
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1571
      closeDetails () {
krlsnvz93's avatar
krlsnvz93 committed
1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666
        this.infoPatient = false
        this.$nextTick(() => {
          this.editedItem = Object.assign({}, this.defaultItem)
          this.editedIndex = -1
        })
      },

      clearData () {
        this.editedItem = Object.assign({}, this.defaultItem)
      },

      async save () {
        if (this.$refs.form.validate()) {
          if (this.editedIndex > -1) {
            this.patientsLoading = true
            // Actualizar
            try {
              await putPatient(this.editedItem)
              this.$toast.success('Datos actualizados 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,
              })
              this.$refs.form.reset()

              this.$refs.form.resetValidation()
              this.clearData()
              this.loadPatientsData()
              this.close()
            } catch (e) {
              this.$toast.error(e.toString(), {
                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,
              })
            }
          } else {
            // Añadir
            try {
              await postPatient(this.editedItem)
              this.$toast.success('Registro exitoso', {
                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,
              })
              this.$refs.form.reset()

              this.$refs.form.resetValidation()
              this.clearData()
              this.loadPatientsData()
              this.close()
            } catch (e) {
              this.$toast.error(e.toString(), {
                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
1667
        } else {
krlsnvz93's avatar
krlsnvz93 committed
1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680
          this.$toast.error('Chequee los datos incorrectos', {
            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
1681 1682
          })
        }
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1683
      },
Yoelvis Gonzalez's avatar
Yoelvis Gonzalez committed
1684 1685 1686 1687 1688 1689 1690 1691 1692
    },

  }
</script>
<style scoped>
.fix-title {
  word-break: normal;
}
</style>