<template>
<div>
<div class="row">
<div class="col-md-7">
<v-data-table
v-model="selected"
:headers="headers"
:items="patients"
@item-selected="update_selected_patients"
@toggle-select-all="update_selected_patients"
:single-select="singleSelect"
item-key="id_paciente"
show-select
class="elevation-1"
>
<template v-slot:top>
<div class="row">
<div class="col-md-5" id="selection">
<v-switch
v-model="singleSelect"
label="Selección Única"
class="pa-3"
></v-switch>
</div>
<div class="col-md-5" id="add-patients">
<v-btn
depressed
@click="addPatients"
color="primary"
>
Agregar Paciente
</v-btn>
</div>
</div>
<div class="row">
<div class="col-md-5" id="patients-name">
<v-text-field
v-model="text_field"
label="Nombre Paciente"
outlined
clearable
@input="getPatientsByName"
></v-text-field>
</div>
<div class="col-md-5" id="filter-categorie-patients">
<v-select
:label="`Categoria`"
:items="categorias_name"
chips
small-chips
multiple
@change="filterByCategoriesPatients"
></v-select>
</div>
</div>
</template>
</v-data-table>
</div>
<div class="col-md-5" id="centers-table">
<v-data-table
v-model="selectedCenters"
:headers="headers_cat"
@item-selected="update_selected_center"
:single-select="singleSelectCenters"
:items="centers"
item-key="nombre_centro"
show-select
class="elevation-1"
>
<template v-slot:top>
<div class="row">
<div class="col-md-5" id="filter-organism">
<v-autocomplete
:label="`Organismo`"
:items="centers_name"
chips
small-chips
multiple
@change="filterByOrganismos"
></v-autocomplete>
</div>
<div class="col-md-5" id="filter-categorie">
<v-select
:label="`Categoria`"
:items="categorias_name"
chips
small-chips
multiple
@change="filterByCategories"
></v-select>
</div>
</div>
</template>
</v-data-table>
</div>
</div>
</div>
</template>
<script>
import {getPatients, getPatient, postPatient, deletePatient, putPatient} from '@/axios/patients'
import {getCategories, getClasifications} from '@/axios/nomenclators'
import {deleteCenter, getCenters} from '@/axios/centers'
import {forInRight} from 'lodash'
export default {
// eslint-disabled
data() {
return {
singleSelect: false,
selected: [],
headers: [
{
text: 'Nombre',
align: 'start',
sortable: true,
value: 'nombre',
},
{text: 'Apellidos', value: 'apellidos'},
{text: 'Edad', value: 'edad'},
{text: 'Sexo', value: 'sexo'},
{text: 'Categoría', value: 'categoria'},
{text: 'Clasificación', value: 'clasificacion'},
],
patients: [],
singleSelectCenters: true,
selectedCenters: [],
headers_cat: [
{
text: 'Nombre',
align: 'start',
sortable: true,
value: 'nombre_centro',
},
{text: 'Municipio', value: 'municipio'},
{text: 'Organismo', value: 'organismo'},
/* { text: 'Sexo', value: 'sexo' },
{ text: 'Categoría', value: 'categoria' },
{ text: 'Clasificación', value: 'clasificacion' },*/
],
search: '',
centers: [],
categorias: [],
categorias_name: [],
centers_name: [],
selected_patients: [],
selected_centers: [],
text_field: "",
}
},
created() {
this.getPatientsData(),
this.getCentersData(),
this.getCentersCategoriesData()
},
methods: {
update_selected_patients(values) {
console.log("SELECTED ITEMS: entre ", values);
if (values.value) {
if (values.items !== undefined) {
for (let val of values.items) {
this.selected_patients.push(val);
}
} else {
this.selected_patients.push(values.item);
}
} else {
if (values.items !== undefined) {
const neo_selected_list = [];
for (const p of this.selected_patients) {
if (p.id_paciente !== val.id_paciente) {
neo_selected_list.push(values);
}
}
this.selected_patients = neo_selected_list;
} else {
const neo_selected_list = [];
for (const p of this.selected_patients) {
if (p.id_paciente !== values.item.id_paciente) {
neo_selected_list.push(values.item);
}
}
this.selected_patients = [];
this.selected_patients = neo_selected_list;
}
}
console.log("SELECTED ITEMS: ", this.selected_patients);
},
update_selected_center(values) {
console.log("SELECTED ITEMS: entre ", values);
if (values.value) {
if (values.items !== undefined) {
for (let val of values.items) {
this.selected_centers.push(val);
}
} else {
this.selected_centers.push(values.item);
}
} else {
if (values.items !== undefined) {
const neo_selected_list = [];
for (const p of this.selected_centers) {
if (p.id_centro !== val.id_centro) {
neo_selected_list.push(values);
}
}
this.selected_centers = neo_selected_list;
} else {
const neo_selected_list = [];
for (const p of this.selected_centers) {
if (p.id_centro !== values.item.id_centro) {
neo_selected_list.push(values.item);
}
}
this.selected_centers = [];
this.selected_centers = neo_selected_list;
}
}
console.log("SELECTED ITEMS CENTERS: ", this.selected_centers);
},
async filterByOrganismos(val) {
console.log("VALUE", val);
await this.getCentersData();
if (val.length > 0) {
const neo_centers = [];
for (const organismo of val) {
for (const cen of this.centers) {
console.log("CEN org ", this.centers);
if (cen.organismo === organismo) {
neo_centers.push(cen);
}
}
}
this.centers = neo_centers;
console.log("Neo centers", neo_centers);
}
}, async filterByCategories(val) {
console.log("VALUE", val);
await this.getCentersData();
if (val.length > 0) {
const neo_centers = [];
for (const categorie of val) {
for (const cen of this.centers) {
console.log("CEN CAT ", this.centers);
if (cen.categoria === this.translateCategorie(categorie)) {
neo_centers.push(cen);
}
}
}
this.centers = neo_centers;
console.log("Neo centers", neo_centers);
}
},
async filterByCategoriesPatients(val) {
console.log("VALUE", val);
await this.getPatientsData();
if (val.length > 0) {
const neo_centers = [];
for (const categorie of val) {
for (const cen of this.patients) {
// console.log("CEN CAT ", cen.categoria);
// console.log("CATEGORIE ", this.translateCategorie(categorie));
if (cen.categoria === categorie) {
neo_centers.push(cen);
}
}
}
this.patients = neo_centers;
console.log("Neo patients", neo_centers);
}
}, async getPatientsByName() {
console.log("VALUE", this.text_field);
// await this.getPatientsData();
await this.getPatientsData();
const neo_centers = [];
console.log("Patients list size ", this.patients.length)
for (let i = 0; i < this.patients.length; i++) {
const cen = this.patients[i];
console.log("CEN CAT ", cen.id_paciente);
// console.log("CATEGORIE ", this.translateCategorie(categorie));
if (cen.nombre.includes(this.text_field)) {
neo_centers.push(cen);
}
}
this.patients = neo_centers;
console.log("Neo patients", neo_centers);
},
translateCategorie(categorie) {
let id = -1;
for (const cat of this.categorias) {
if (cat.nombre === categorie) {
console.log("Cat nombre ", cat.nombre, " categoria ", categorie);
id = cat.id;
}
}
return id;
},
async printValue(val) {
console.log("VALUE: ", val);
},
async getCentersCategoriesData() {
try {
const catResponse = await getClasifications();
this.categorias = await catResponse.data;
for (const cat of this.categorias) {
this.categorias_name.push(cat.nombre);
}
console.log('cent categorias', this.categorias);
console.log('categorias name', this.categorias_name);
} 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,
})
}
}, async getPatientsData() {
try {
const patientsResponse = await getPatients()
this.patients = await patientsResponse.data.pacientes;
await this.getCategoriesData();
/*let i = 0;
for (const p in pacientes) {
console.log("Entre aqui");
const p = pacientes[i];
let classification = 'niño'
if(p.embarazada!=0){
classification = 'embarazada';
}
if(p.trabajador_salud!=0){
classification = 'trabajador de la salud';
}
p.clasificacion = classification;
pacientes[i] = p;
i+=1;
}*/
// this.patients = pacientes;
// console.log('Patientsss', pacientes);
} 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,
})
}
},
async getCategoriesData() {
try {
const categoriesResponse = await getCategories()
const categories = await categoriesResponse.data;
this.categorias = categories;
this.categorias_name = [];
let i = 0;
// console.log("MOCK CAT ", categories);
let has_run = false;
for (const p of this.patients) {
categories.forEach(element => {
if (!has_run) {
this.categorias_name.push(element.nombre);
}
if (element.id == p.categoria) {
p.categoria = element.nombre;
}
});
has_run = true;
this.patients[i] = p;
i += 1;
}
// this.patients = pacientes;
// console.log('Fix patients categorie', pacientes);
// console.log('categorias_name', this.categorias_name);
// console.log('categorias', this.categorias);
} 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,
})
}
},
async getCentersData(pacientes) {
try {
const centersResponse = await getCenters();
const centers = await centersResponse.data.centros;
let i = 0;
for (const c of centers) {
this.centers_name.push(c.organismo);
}
this.centers = centers;
console.log('Centers', centers);
} 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,
})
}
},
async addPatients() {
try {
console.log("Selected Patients", this.selected_patients);
console.log("Selected Centers", this.selected_centers);
} 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,
})
}
}
},
}
</script>
<style>
#centers-table {
margin-top: 30px;
}
#add-patients {
margin-top: 20px;
}
#filter-organism, #filter-categorie, #filter-categorie-patients, #patients-name {
margin-left: 10px;
}
</style>
<template>
<div>
<div class="row">
<div class="col-md-7">
<v-data-table
v-model="selected"
:headers="headers"
:items="patients"
:single-select="singleSelect"
item-key="id_paciente"
show-select
class="elevation-1"
>
<template v-slot:top>
<v-switch
v-model="singleSelect"
label="Selección Única"
class="pa-3"
></v-switch>
</template>
</v-data-table>
</div>
<div class="col-md-5" id="centers-table">
<v-data-table
v-model="selectedCenters"
:headers="headers_cat"
:single-select="singleSelectCenters"
:items="centers"
item-key="nombre_centro"
show-select
class="elevation-1"
:search="search"
:custom-filter="customFilter"
>
<template v-slot:top>
<div class="row">
<div class="col-md-5" id="filter-organism">
<v-autocomplete
:label="`Organismo`"
:items="items"
chips
small-chips
multiple
></v-autocomplete>
</div>
<div class="col-md-5" id="filter-categorie">
<v-select
:label="`Categoria`"
:items="categorias_name"
chips
small-chips
multiple
v-model="search"
></v-select>
</div>
</div>
</template>
</v-data-table>
</div>
</div>
</div>
</template>
<script>
import {getPatients, getPatient, postPatient, deletePatient, putPatient} from '@/axios/patients'
import {getCategories} from '@/axios/nomenclators'
import {getCenters} from '@/axios/centers'
import {forInRight} from 'lodash'
export default {
// eslint-disabled
data() {
return {
singleSelect: false,
selected: [],
headers: [
{
text: 'Nombre',
align: 'start',
sortable: true,
value: 'nombre',
},
{text: 'Apellidos', value: 'apellidos'},
{text: 'Edad', value: 'edad'},
{text: 'Sexo', value: 'sexo'},
{text: 'Categoría', value: 'categoria'},
{text: 'Clasificación', value: 'clasificacion'},
],
patients: [],
singleSelectCenters: true,
selectedCenters: [],
headers_cat: [
{
text: 'Nombre',
align: 'start',
sortable: true,
value: 'nombre_centro',
},
{text: 'Municipio', value: 'municipio'},
{text: 'Organismo', value: 'organismo'},
/* { text: 'Sexo', value: 'sexo' },
{ text: 'Categoría', value: 'categoria' },
{ text: 'Clasificación', value: 'clasificacion' },*/
],
search: '',
centers: [],
categorias: [],
categorias_name: [],
}
},
created() {
this.getPatientsData(),
this.getCentersData()
},
methods: {
customFilter(items, search, filter) {
console.log("bdkwbdkjwkjwjwjjjjjjjjjjjjjjjjjjjjjjjjj");
search = search.toString().toLowerCase()
return items.filter(row => filter(row["type"], search));
},
async printValue(val) {
console.log("VALUE: ", val);
},
async getPatientsData() {
try {
const patientsResponse = await getPatients()
const pacientes = await patientsResponse.data.pacientes;
this.getCategoriesData(pacientes);
/*let i = 0;
for (const p in pacientes) {
console.log("Entre aqui");
const p = pacientes[i];
let classification = 'niño'
if(p.embarazada!=0){
classification = 'embarazada';
}
if(p.trabajador_salud!=0){
classification = 'trabajador de la salud';
}
p.clasificacion = classification;
pacientes[i] = p;
i+=1;
}*/
this.patients = pacientes;
console.log('Patientsss', pacientes);
} 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,
})
}
},
async getCategoriesData(pacientes) {
try {
const categoriesResponse = await getCategories()
const categories = await categoriesResponse.data;
let i = 0;
console.log("MOCK CAT ", categories);
let has_run = false;
for (const p in pacientes) {
const p = pacientes[i];
categories.forEach(element => {
if (!has_run) {
this.categorias_name.push(element.nombre);
}
if (element.id == p.categoria) {
p.categoria = element.nombre;
}
});
has_run = true;
pacientes[i] = p;
i += 1;
}
// this.patients = pacientes;
console.log('Fix patients categorie', pacientes);
console.log('categorias_name', this.categorias_name);
console.log('categorias', this.categorias);
} 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,
})
}
},
async getCentersData(pacientes) {
try {
const centersResponse = await getCenters();
const centers = await centersResponse.data.centros;
let i = 0;
/* for (const p in pacientes) {
const p = pacientes[i];
categories.forEach(element => {
if(element.id == p.categoria){
p.categoria = element.nombre;
}
});
pacientes[i] = p;
i+=1;
}*/
this.centers = centers;
console.log('Centers', centers);
} 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,
})
}
}
},
}
</script>
<style>
#centers-table {
margin-top: 30px;
}
#filter-organism, #filter-categorie {
margin-left: 10px;
}
</style>
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
:src="require('@/assets/icon.png')" :src="require('@/assets/icon.png')"
alt="SIGI" alt="SIGI"
> >
</v-avatar> SIGI / Inicio de sesión </v-avatar>SIGI / Inicio de sesión
</v-toolbar-title> </v-toolbar-title>
</v-toolbar> </v-toolbar>
<v-card-text> <v-card-text>
...@@ -38,8 +38,8 @@ ...@@ -38,8 +38,8 @@
name="login" name="login"
label="Coreo Electrónico" label="Coreo Electrónico"
required required
type="text" type="text"
@keydown.native.enter="submit"
/> />
<v-text-field <v-text-field
id="password" id="password"
...@@ -57,8 +57,6 @@ ...@@ -57,8 +57,6 @@
<v-card-actions> <v-card-actions>
<v-spacer /> <v-spacer />
<v-btn <v-btn
color="green"
dark
:disabled="!valid" :disabled="!valid"
submit submit
:loading="tryLogin" :loading="tryLogin"
...@@ -105,28 +103,10 @@ ...@@ -105,28 +103,10 @@
const token = loginResponse.data.token const token = loginResponse.data.token
const role = loginResponse.data.user.role const role = loginResponse.data.user.role
localStorage.setItem('role', role) localStorage.setItem('role', role)
localStorage.setItem('tkn', token) const data = encrypt(token)
localStorage.setItem('tkn', data)
this.$router.push({ name: 'Control' }) this.$router.push({ name: 'Control' })
} catch (e) { } catch (e) {
switch (e.response.status) {
case 500: {
this.$toast.error('Error interno del servidor, inténtelo más tarde', {
position: 'bottom-center',
timeout: 3000,
closeOnClick: true,
pauseOnFocusLoss: false,
pauseOnHover: true,
draggable: true,
draggablePercent: 0.6,
showCloseButtonOnHover: false,
hideProgressBar: true,
closeButton: 'button',
icon: true,
rtl: false,
})
break
}
case 401: {
this.$toast.error('No autorizado', { this.$toast.error('No autorizado', {
position: 'bottom-center', position: 'bottom-center',
timeout: 3000, timeout: 3000,
...@@ -141,26 +121,6 @@ ...@@ -141,26 +121,6 @@
icon: true, icon: true,
rtl: false, rtl: false,
}) })
break
}
default: {
this.$toast.error('No autorizado', {
position: 'bottom-center',
timeout: 3000,
closeOnClick: true,
pauseOnFocusLoss: false,
pauseOnHover: true,
draggable: true,
draggablePercent: 0.6,
showCloseButtonOnHover: false,
hideProgressBar: true,
closeButton: 'button',
icon: true,
rtl: false,
})
}
}
console.log(e.response)
this.tryLogin = false this.tryLogin = false
} }
} }
......
<template> <template>
<div style="margin: 8px"> <div style="margin: 8px">
<v-card> <v-data-table
<v-card-title> 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-toolbar-title>Pacientes Registrados</v-toolbar-title>
<v-divider <v-divider
class="mx-4"
inset
vertical vertical
style="margin-left: 8px"
/> />
<v-spacer /> <v-spacer />
<v-btn <!-- <router-link
text :to="{name: Admit}"
color="info" style="margin : 4px"
class="toolbar-btn"
dark
> >
<v-icon>mdi-hospital-building</v-icon> Ingresar Pacientes
</v-btn>
<v-dialog
v-model="dialog"
max-width="800px"
persistent
>
<template v-slot:activator="{ on, attrs }">
<v-btn <v-btn
color="success" color="success"
dark dark
class="toolbar-btn" class="mb-2"
v-bind="attrs"
v-on="on"
> >
<v-icon>mdi-plus</v-icon>Registrar Paciente <v-icon>mdi-notebook-check</v-icon>Ingresar Paciente(s)
</v-btn> </v-btn>
</template> </template>
<patient-form <patient-form
...@@ -105,10 +110,919 @@ ...@@ -105,10 +110,919 @@
v-on="on" v-on="on"
@click="detailsItem(item)" @click="detailsItem(item)"
> >
mdi-dots-horizontal-circle mdi-dots-horizontal-circle
</v-icon>
</template>
<span>Detalle Paciente</span>
</v-tooltip>
<v-tooltip
v-if="item.status !== 'Ingresado'"
bottom
>
<template v-slot:activator="{ on, attrs }">
<v-btn
color="success"
dark
class="mb-2"
v-bind="attrs"
v-on="on"
>
<v-icon>mdi-plus</v-icon>Registrar Paciente
</v-btn>
</template>
<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
>
<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
>
<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>
<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> </v-icon>
</template> </template>
<span>Detalle Paciente</span> <span>Asignar Capacidad</span>
</v-tooltip> </v-tooltip>
<v-tooltip <v-tooltip
v-if="item.status !== 'Ingresado'" v-if="item.status !== 'Ingresado'"
...@@ -125,15 +1039,13 @@ ...@@ -125,15 +1039,13 @@
mdi-notebook-check mdi-notebook-check
</v-icon> </v-icon>
</template> </template>
<span>Confirmar Ingreso</span> <span>Ingresar</span>
</v-tooltip> </v-tooltip>
</template> </template>
<template v-slot:no-data> <template v-slot:no-data>
No hay datos disponibles No hay datos disponibles
</template> </template>
</v-data-table> </v-data-table>
</v-card>
<v-dialog <v-dialog
v-model="infoPatient" v-model="infoPatient"
persistent persistent
...@@ -142,121 +1054,89 @@ ...@@ -142,121 +1054,89 @@
<patient-file <patient-file
:patient="editedItem" :patient="editedItem"
@close-click="closeDetails" @close-click="closeDetails"
@edit-click="editFromDetails"
/> />
</v-dialog> </v-dialog>
<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>
<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>
</div> </div>
</template> </template>
<script> <script>
import InfoBox from '@/components/InfoBox.vue'
import { COUNTRIES } from '@/utils/constants'
import PatientFile from '@/components/PatientFile.vue' import PatientFile from '@/components/PatientFile.vue'
import PatientForm from '@/components/PatientForm.vue' import PatientForm from '@/components/PatientForm.vue'
import { getPatients, getPatient, deletePatient } from '@/axios/patients' import { getPatients, getPatient, deletePatient } from '@/axios/patients'
import { getHealthStatus, getSystemStatus, getAntigenos, getProvinces, getMunicipalities, getCategories } from '@/axios/nomenclators' import { getHealthStatus, getSystemStatus, getAntigenos, getProvinces, getMunicipalities, getCategories } from '@/axios/nomenclators'
import FilterTool from '@/components/FilterTool.vue' import FilterTool from '@/components/FilterTool.vue'
export default { export default {
components: { PatientFile, FilterTool, PatientForm }, components: { InfoBox, PatientFile },
data: () => ({ data: () => ({
filterPanel: false, remissionTypes: ['Policlínico', 'C.M.F.', 'Hospital'],
selectedItems: [],
assignOnePatient: false,
antigensData: [], antigensData: [],
patientsFilters: { patientsFilters: {
page: 1, page: 1,
categoria: null,
estado_sistema: null,
nombre: null,
apellidos: null,
ci: null,
centro: null,
}, },
patientsFirstLoad: true, patientsFirstLoad: true,
totalPatientsItems: 0, totalPatientsItems: 0,
infoPatient: false, infoPatient: false,
toDeleteId: -1, toDeleteId: -1,
loadingPatientsData: false, loadingPatientsData: false,
loadingPatientData: false,
valid: false, valid: false,
arrived: false,
isContact: false,
noApp: true,
othersS: false,
othersApp: false,
asymptomatic: true, asymptomatic: true,
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,
modal: false, modal: false,
menu2: false,
menu3: false,
dialogDeleteUnavailable: false, dialogDeleteUnavailable: false,
dialog: false, dialog: false,
dialogDelete: false, dialogDelete: false,
healthAreas: [], healthAreas: [],
sexes: [
{ nombre: 'Masculino', id: 'M' }, { nombre: 'Femenino', id: 'F' },
],
municipalities: [],
categories: [], categories: [],
headers: [ headers: [
{ {
text: 'CI', text: 'CI',
align: 'start', align: 'start',
sortable: false, sortable: true,
value: 'ci', value: 'ci',
}, },
{ text: 'Nombre', value: 'nombre', sortable: false }, { text: 'Nombre', value: 'nombre' },
{ text: 'Apellidos', value: 'apellidos', sortable: false }, { text: 'Apellidos', value: 'apellidos' },
{ text: 'Acciones', value: 'actions', sortable: false }, { text: 'Acciones', value: 'actions', sortable: false },
], ],
patients: [], patients: [],
editedIndex: -1, editedIndex: -1,
editedItem: { editedItem: {
asymptomatic: true,
isContact: false,
arrived: false,
nombre: '', nombre: '',
apellidos: '', apellidos: '',
ci: '', ci: '',
...@@ -268,7 +1148,6 @@ ...@@ -268,7 +1148,6 @@
cmf: '', cmf: '',
area_salud: '', area_salud: '',
remite_caso: '', remite_caso: '',
noApp: true,
estado_sistema: '', estado_sistema: '',
trabajador_salud: false, trabajador_salud: false,
ninho: false, ninho: false,
...@@ -308,14 +1187,10 @@ ...@@ -308,14 +1187,10 @@
}, },
defaultItem: { defaultItem: {
asymptomatic: true,
isContact: false,
arrived: false,
nombre: '', nombre: '',
apellidos: '', apellidos: '',
ci: '', ci: '',
edad: 0, edad: 0,
noApp: true,
sexo: '', sexo: '',
direccion: '', direccion: '',
municipio: '', municipio: '',
...@@ -366,35 +1241,90 @@ ...@@ -366,35 +1241,90 @@
provinces () { provinces () {
return this.$store.getters.provinces return this.$store.getters.provinces
}, },
municipalities () { countriesD () {
return this.$store.getters.municipalities return COUNTRIES
}, },
formTitle () { formTitle () {
return this.editedIndex === -1 ? 'Registrar Paciente' : 'Editar datos de paciente' return this.editedIndex === -1 ? 'Registrar Paciente' : 'Editar datos de paciente'
}, },
disablePregnant () {
return this.editedItem.ninho
},
disableChild () {
return this.editedItem.embarazada
},
disableRemissionCenterName () { disableRemissionCenterName () {
return (this.editedItem.remissionCenter.type !== 'Hospital') && (this.editedItem.remissionCenter.type !== 'Otro') return (this.editedItem.remissionCenter.type !== 'Hospital') && (this.editedItem.remissionCenter.type !== 'Otro')
}, },
patientIsAsymptomatic () {
return this.editedItem.sintomas.fecha_sintomas !== null
},
systemStatusesData () { systemStatusesData () {
return this.$store.getters.systemStatuses return this.$store.getters.systemStatuses
}, },
}, },
watch: {
dialog (val) {
val || this.close()
},
dialogDelete (val) {
val || this.closeDelete()
},
},
created () { created () {
this.loadPatientsData() this.loadPatientsData()
}, },
methods: { methods: {
showMe () { async loadMunicipalitiesData (id) {
console.log(this.patientsFilters) 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,
})
}
}, },
filterData () { async getCategoriesData () {
this.loadPatientsData() try {
this.filterPanel = false 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,
})
}
}, },
async getSystemStatusData () { async getSystemStatusData () {
try { try {
await getSystemStatus() const systemResponse = await getSystemStatus()
this.$store.commit('setSystemStatuses', systemResponse.data)
} catch (e) { } catch (e) {
this.$toast.error(e.toString(), { this.$toast.error(e.toString(), {
position: 'bottom-center', position: 'bottom-center',
...@@ -433,23 +1363,54 @@ ...@@ -433,23 +1363,54 @@
}) })
} }
}, },
editFromDetails () { async getHealthStatusData () {
this.closeDetails() try {
this.editItem(this.editedItem) 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,
})
}
}, },
closeAssignate () { async getHealthAreaData (id) {
this.assignOnePatient = false try {
this.$nextTick(() => { const healthAreaResponse = await getHealthAreas(id)
this.editedItem = Object.assign({}, this.defaultItem) this.healthAreas = healthAreaResponse.data
this.editedIndex = -1 } 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,
}) })
}
}, },
async detailsItem (item) { async detailsItem (item) {
this.loadingPatientData = true this.loadingPatientsData = true
try { try {
const patientResponse = await getPatient(item.id_paciente) const patientResponse = await getPatient(item.id_paciente)
this.editedItem = Object.assign({}, patientResponse.data.paciente) this.editedItem = Object.assign({}, patientResponse.data.paciente)
/* if (this.editedItem.apps !== null) { if (this.editedItem.apps !== null) {
this.editedItem.hipertension = this.editedItem.apps.hipertension this.editedItem.hipertension = this.editedItem.apps.hipertension
this.editedItem.diabetes = this.editedItem.apps.diabetes this.editedItem.diabetes = this.editedItem.apps.diabetes
this.editedItem.asma = this.editedItem.apps.asma this.editedItem.asma = this.editedItem.apps.asma
...@@ -491,7 +1452,8 @@ ...@@ -491,7 +1452,8 @@
if (this.editedItem.pais_procedencia || this.editedItem.lugar_estancia || this.editedItem.fecha_arribo) { if (this.editedItem.pais_procedencia || this.editedItem.lugar_estancia || this.editedItem.fecha_arribo) {
this.arrived = true this.arrived = true
} }
} */ }
this.loadingPatientsData = false
this.infoPatient = true this.infoPatient = true
} catch (e) { } catch (e) {
this.$toast.error(e.toString(), { this.$toast.error(e.toString(), {
...@@ -509,15 +1471,14 @@ ...@@ -509,15 +1471,14 @@
rtl: false, rtl: false,
}) })
} }
this.loadingPatientData = true
}, },
closeDeleteU () { closeDeleteU () {
this.dialogDeleteUnavailable = false this.dialogDeleteUnavailable = false
}, },
async loadPatientsData () { async loadPatientsData (page = 1) {
this.loadingPatientsData = true this.loadingPatientsData = true
try { try {
const patientsResponse = await getPatients(this.patientsFilters) const patientsResponse = await getPatients(page)
this.totalPatientsItems = patientsResponse.data.meta.total this.totalPatientsItems = patientsResponse.data.meta.total
this.patients = patientsResponse.data.pacientes this.patients = patientsResponse.data.pacientes
this.loadingPatientsData = false this.loadingPatientsData = false
...@@ -537,15 +1498,13 @@ ...@@ -537,15 +1498,13 @@
rtl: false, rtl: false,
}) })
} }
this.patientsFirstLoad = false
}, },
async editItem (item) { async editItem (item) {
this.loadingPatientData = true this.loadingPatientsData = true
try { try {
const patientResponse = await getPatient(item.id_paciente) const patientResponse = await getPatient(item.id_paciente)
this.editedItem = Object.assign({}, patientResponse.data.paciente) this.editedItem = Object.assign({}, patientResponse.data.paciente)
getMunicipalities(this.editedItem.provincia)
if (this.editedItem.apps !== null) { if (this.editedItem.apps !== null) {
this.editedItem.hipertension = this.editedItem.apps.hipertension this.editedItem.hipertension = this.editedItem.apps.hipertension
this.editedItem.diabetes = this.editedItem.apps.diabetes this.editedItem.diabetes = this.editedItem.apps.diabetes
...@@ -555,7 +1514,7 @@ ...@@ -555,7 +1514,7 @@
this.editedItem.oncologia = this.editedItem.apps.oncologia this.editedItem.oncologia = this.editedItem.apps.oncologia
this.editedItem.otros_apps = this.editedItem.apps.otros 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) { 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.editedItem.noApp = false this.noApp = false
} }
} }
if (this.editedItem.sintomas !== null) { if (this.editedItem.sintomas !== null) {
...@@ -570,7 +1529,7 @@ ...@@ -570,7 +1529,7 @@
this.editedItem.dolor_garganta = this.editedItem.sintomas.dolor_garganta this.editedItem.dolor_garganta = this.editedItem.sintomas.dolor_garganta
this.editedItem.otros_sint = this.editedItem.sintomas.otros 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) { 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.editedItem.asymptomatic = false this.asymptomatic = false
} }
} }
if (this.editedItem.contacto !== null) { if (this.editedItem.contacto !== null) {
...@@ -578,7 +1537,7 @@ ...@@ -578,7 +1537,7 @@
this.editedItem.lugar_contacto = this.editedItem.contacto.lugar_contacto this.editedItem.lugar_contacto = this.editedItem.contacto.lugar_contacto
this.editedItem.tipo_contacto = this.editedItem.contacto.tipo_contacto this.editedItem.tipo_contacto = this.editedItem.contacto.tipo_contacto
if (this.editedItem.fecha_contacto || this.editedItem.lugar_contacto || this.editedItem.tipo_contacto) { if (this.editedItem.fecha_contacto || this.editedItem.lugar_contacto || this.editedItem.tipo_contacto) {
this.editedItem.isContact = true this.isContact = true
} }
} }
if (this.editedItem.arribo !== null) { if (this.editedItem.arribo !== null) {
...@@ -586,7 +1545,7 @@ ...@@ -586,7 +1545,7 @@
this.editedItem.lugar_estancia = this.editedItem.arribo.lugar_estancia this.editedItem.lugar_estancia = this.editedItem.arribo.lugar_estancia
this.editedItem.fecha_arribo = this.editedItem.arribo.fecha_arribo this.editedItem.fecha_arribo = this.editedItem.arribo.fecha_arribo
if (this.editedItem.pais_procedencia || this.editedItem.lugar_estancia || this.editedItem.fecha_arribo) { if (this.editedItem.pais_procedencia || this.editedItem.lugar_estancia || this.editedItem.fecha_arribo) {
this.editedItem.arrived = true this.arrived = true
} }
} }
} catch (e) { } catch (e) {
...@@ -605,9 +1564,11 @@ ...@@ -605,9 +1564,11 @@
rtl: false, rtl: false,
}) })
} }
this.loadingPatientData = false
this.editedIndex = this.patients.indexOf(item) this.editedIndex = this.patients.indexOf(item)
this.dialog = true this.dialog = true
this.$refs.form.resetValidation()
this.loadingPatientsData = false
}, },
paginatePatients (pageInfo) { paginatePatients (pageInfo) {
if (this.patientsFirstLoad) { if (this.patientsFirstLoad) {
...@@ -620,6 +1581,8 @@ ...@@ -620,6 +1581,8 @@
this.loadPatientsData() this.loadPatientsData()
} }
} }
this.patientsFilters.page = pageInfo.page
this.loadPatientsData(pageInfo.page)
}, },
deleteItem (item) { deleteItem (item) {
...@@ -677,6 +1640,8 @@ ...@@ -677,6 +1640,8 @@
}, },
close () { close () {
this.dialog = false this.dialog = false
this.$refs.form.resetValidation()
this.$nextTick(() => { this.$nextTick(() => {
this.editedItem = Object.assign({}, this.defaultItem) this.editedItem = Object.assign({}, this.defaultItem)
this.editedIndex = -1 this.editedIndex = -1
...@@ -696,6 +1661,112 @@ ...@@ -696,6 +1661,112 @@
this.editedIndex = -1 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,
})
}
}
} else {
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,
})
}
},
}, },
} }
...@@ -704,7 +1775,4 @@ ...@@ -704,7 +1775,4 @@
.fix-title { .fix-title {
word-break: normal; word-break: normal;
} }
.toolbar-btn {
margin: 4px
}
</style> </style>
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
</template> </template>
<template v-else> <template v-else>
{{ one }} ttrgrg {{ one }}
</template> </template>
</td> </td>
......