...@@ -3,4 +3,15 @@ export default { ...@@ -3,4 +3,15 @@ export default {
systemStatuses: state => state.systemStatuses, systemStatuses: state => state.systemStatuses,
provinces: state => state.provinces, provinces: state => state.provinces,
municipalities: state => state.municipalities, municipalities: state => state.municipalities,
categories: state => state.categories,
centers: state => state.centers,
clasifications: state => state.clasifications,
antigens: state => state.antigens,
healthAreas: state => state.healthAreas,
healthStatuses: state => state.healthStatuses,
pIndex: state => state.pIndex,
patient: state => state.patient,
user: state => state.user,
filters: state => state.filters,
filterStatus: state => state.filterStatus,
} }
import { DEFAULT_PATIENT } from '../utils/constants'
export default { export default {
setDrawer (state) { setDrawer (state) {
...@@ -12,4 +13,46 @@ export default { ...@@ -12,4 +13,46 @@ export default {
setMunicipalities (state, data) { setMunicipalities (state, data) {
state.municipalities = data state.municipalities = data
}, },
setCategories (state, data) {
state.categories = data
},
setCenters (state, data) {
state.centers = data
},
setClasifications (state, data) {
state.clasifications = data
},
setAntigens (state, data) {
state.antigens = data
},
setHealthAreas (state, data) {
state.healthAreas = data
},
setHealthStatuses (state, data) {
state.healthStatuses = data
},
setPIndex (state, data) {
state.pIndex = data
},
setPatient (state, data) {
state.patient = Object.assign({}, data)
},
clearPatient (state) {
state.patient = Object.assign({}, DEFAULT_PATIENT)
},
setUser (state, data) {
state.user = Object.assign({}, data)
},
setFilters (state, data) {
state.filters = Object.assign({}, data)
},
clearFilters (state) {
state.filters = Object.assign({}, [])
},
setFiltersPage (state, data) {
state.filters.page = data
},
setFilterStatus (state, data) {
state.filterStatus = data
},
} }
...@@ -9,4 +9,58 @@ export default { ...@@ -9,4 +9,58 @@ export default {
antigens: [], antigens: [],
healthAreas: [], healthAreas: [],
healthStatuses: [], healthStatuses: [],
pIndex: -1,
patient: {
asymptomatic: true,
isContact: false,
arrived: false,
nombre: '',
apellidos: '',
ci: '',
edad: 0,
sexo: '',
direccion: '',
municipio: '',
provincia: '',
cmf: '',
area_salud: '',
remite_caso: '',
noApp: true,
estado_sistema: '',
trabajador_salud: false,
ninho: false,
embarazada: false,
vacunado: false,
test_antigeno: 0,
sintomas: [],
app: [],
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: '',
},
user: null,
filters: {
page: 1,
},
filterStatus: false,
} }
...@@ -1459,3 +1459,53 @@ export const COUNTRIES = [{ ...@@ -1459,3 +1459,53 @@ export const COUNTRIES = [{
}, },
] ]
export const DECRYPT_KEY = 'xFr#s1r%K2' export const DECRYPT_KEY = 'xFr#s1r%K2'
export const DEFAULT_PATIENT = {
asymptomatic: true,
isContact: false,
arrived: false,
nombre: '',
apellidos: '',
ci: '',
edad: 0,
sexo: '',
direccion: '',
municipio: '',
provincia: '',
cmf: '',
area_salud: '',
remite_caso: '',
noApp: true,
estado_sistema: '',
trabajador_salud: false,
ninho: false,
embarazada: false,
vacunado: false,
test_antigeno: 0,
sintomas: [],
app: [],
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: '',
}
...@@ -4,20 +4,20 @@ ...@@ -4,20 +4,20 @@
no-gutters no-gutters
style="padding: 8px" style="padding: 8px"
> >
<!-- <info-box <info-box
:stats="monthlyStats" :stats="monthlyStats"
:more="true" :more="true"
/> --> />
</v-row> </v-row>
</section> </section>
</template> </template>
<script> <script>
// import InfoBox from '@/components/InfoBox' import InfoBox from '@/components/InfoBox'
export default { export default {
name: 'SectionDashboard', name: 'SectionDashboard',
// components: { InfoBox }, components: { InfoBox },
data: () => ({ data: () => ({
monthlyStats: [ monthlyStats: [
{ {
......
...@@ -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,6 +57,8 @@ ...@@ -57,6 +57,8 @@
<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"
...@@ -74,7 +76,7 @@ ...@@ -74,7 +76,7 @@
</template> </template>
<script> <script>
import { login } from '@/axios/auth' import { login } from '@/axios/auth'
import { encrypt, decrypt } from '@/utils/enc' import { mapMutations } from 'vuex'
export default { export default {
name: 'Login', name: 'Login',
data: () => ({ data: () => ({
...@@ -94,6 +96,7 @@ ...@@ -94,6 +96,7 @@
checkbox: false, checkbox: false,
}), }),
methods: { methods: {
...mapMutations(['setUser']),
async submit () { async submit () {
this.$refs.form.validate() this.$refs.form.validate()
if (this.$refs.form.validate(true)) { if (this.$refs.form.validate(true)) {
...@@ -101,26 +104,82 @@ ...@@ -101,26 +104,82 @@
try { try {
const loginResponse = await login(this.username, this.password) const loginResponse = await login(this.username, this.password)
const token = loginResponse.data.token const token = loginResponse.data.token
const role = loginResponse.data.user.role const user = loginResponse.data.user
localStorage.setItem('role', role) this.setUser(user)
const data = encrypt(token) localStorage.setItem('tkn', token)
localStorage.setItem('tkn', data)
this.$router.push({ name: 'Control' }) this.$router.push({ name: 'Control' })
} catch (e) { } catch (e) {
this.$toast.error('No autorizado', { console.log(e.toString())
position: 'bottom-center', if (e.toString() === 'Error: Network Error') {
timeout: 3000, console.log('ERROR DE RED')
closeOnClick: true, this.$toast.error('Error de Red, revise su conexión', {
pauseOnFocusLoss: false, position: 'bottom-center',
pauseOnHover: true, timeout: 3000,
draggable: true, closeOnClick: true,
draggablePercent: 0.6, pauseOnFocusLoss: false,
showCloseButtonOnHover: false, pauseOnHover: true,
hideProgressBar: true, draggable: true,
closeButton: 'button', draggablePercent: 0.6,
icon: true, showCloseButtonOnHover: false,
rtl: false, hideProgressBar: true,
}) closeButton: 'button',
icon: true,
rtl: false,
})
this.tryLogin = false
}
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', {
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
}
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,
})
}
}
this.tryLogin = false this.tryLogin = false
} }
} }
......
<template> <template>
<div style="margin: 8px"> <div style="margin: 8px">
<v-data-table <v-card>
locale="es-es" <v-card-title>
style="margin-top: 8px" <v-toolbar-title>Pacientes Registrados</v-toolbar-title>
:headers="headers" <v-divider
:items="patients" vertical
sort-by="ci" style="margin-left: 8px"
:loading="loadingPatientsData" />
:footer-props="{ <v-spacer />
'disable-items-per-page': true, <v-btn
'items-per-page-text': 'Pacientes por página' text
}" color="info"
:server-items-length="totalPatientsItems" class="toolbar-btn"
loading-text="Cargando Pacientes" dark
class="elevation-1" >
@pagination="paginatePatients" <v-icon>mdi-hospital-building</v-icon> Ingresar Pacientes
> </v-btn>
<template v-slot:top> <v-dialog
<v-toolbar flat> v-model="dialog"
<v-toolbar-title>Pacientes Registrados</v-toolbar-title> max-width="800px"
<v-divider persistent
class="mx-4" >
inset <template v-slot:activator="{ on, attrs }">
vertical
/>
<v-spacer />
<!-- <router-link
:to="{name: Admit}"
style="margin : 4px"
>
<v-btn <v-btn
color="success" color="success"
dark dark
class="mb-2" class="toolbar-btn"
v-bind="attrs"
v-on="on"
> >
<v-icon>mdi-notebook-check</v-icon>Ingresar Paciente(s) <v-icon>mdi-plus</v-icon>Registrar Paciente
</v-btn> </v-btn>
</template> </template>
<patient-form <patient-form
:title="formTitle" :title="formTitle"
:index="editedIndex"
:patient="editedItem"
@refresh="closeSaved" @refresh="closeSaved"
@close-click="close" @close-click="close"
/> />
...@@ -50,8 +43,8 @@ ...@@ -50,8 +43,8 @@
v-model="filterPanel" v-model="filterPanel"
> >
<filter-tool <filter-tool
:filters="patientsFilters"
:loading="loadingPatientsData" :loading="loadingPatientsData"
@close-click="closeFilter"
@filter-click="filterData" @filter-click="filterData"
/> />
</v-expansion-panels> </v-expansion-panels>
...@@ -120,1077 +113,121 @@ ...@@ -120,1077 +113,121 @@
bottom bottom
> >
<template v-slot:activator="{ on, attrs }"> <template v-slot:activator="{ on, attrs }">
<v-btn <v-icon
class="mr-2"
color="success" color="success"
dark
class="mb-2"
v-bind="attrs" v-bind="attrs"
v-on="on" v-on="on"
@click="admit(item)"
> >
<v-icon>mdi-plus</v-icon>Registrar Paciente mdi-notebook-check
</v-btn> </v-icon>
</template> </template>
<v-card> <span>Confirmar Ingreso</span>
<v-card-title class="fix-title"> </v-tooltip>
<span class="text-h5">{{ formTitle }}</span><v-spacer /> <v-btn </template>
icon <template v-slot:no-data>
@click="close" No hay datos disponibles
> </template>
<v-icon>mdi-close</v-icon> </v-data-table>
</v-btn> </v-card>
</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>
</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>
<v-dialog <v-dialog
v-model="infoPatient" v-model="infoPatient"
persistent persistent
max-width="800px" max-width="800px"
> >
<patient-file <patient-file
: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>
</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 { mapMutations, mapGetters } from 'vuex'
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 { getSystemStatus, getAntigens, getMunicipalities } from '@/axios/nomenclators'
import FilterTool from '@/components/FilterTool.vue' import FilterTool from '@/components/FilterTool.vue'
export default { export default {
components: { InfoBox, PatientFile }, components: { PatientFile, FilterTool, PatientForm },
data: () => ({ data: () => ({
remissionTypes: ['Policlínico', 'C.M.F.', 'Hospital'], filterPanel: false,
selectedItems: [],
assignOnePatient: false,
antigensData: [], antigensData: [],
patientsFilters: {
page: 1,
},
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: true, sortable: false,
value: 'ci', value: 'ci',
}, },
{ text: 'Nombre', value: 'nombre' }, { text: 'Nombre', value: 'nombre', sortable: false },
{ text: 'Apellidos', value: 'apellidos' }, { text: 'Apellidos', value: 'apellidos', sortable: false },
{ text: 'Acciones', value: 'actions', sortable: false }, { text: 'Acciones', value: 'actions', sortable: false },
], ],
patients: [], patients: [],
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: 0,
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: '',
},
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: '',
...@@ -1238,222 +275,55 @@ ...@@ -1238,222 +275,55 @@
}), }),
computed: { computed: {
...mapGetters(['pIndex', 'patient', 'filters']),
provinces () { provinces () {
return this.$store.getters.provinces return this.$store.getters.provinces
}, },
countriesD () { municipalities () {
return COUNTRIES return this.$store.getters.municipalities
}, },
formTitle () { formTitle () {
return this.editedIndex === -1 ? 'Registrar Paciente' : 'Editar datos de paciente' return this.pIndex === -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.patient.remissionCenter.type !== 'Hospital') && (this.patient.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: {
async loadMunicipalitiesData (id) { ...mapMutations(['setPIndex', 'setPatient', 'clearPatient', 'setFiltersPage', 'setFilterStatus']),
console.log(id) showMe () {
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,
})
}
}, },
async getCategoriesData () { filterData () {
try { this.loadPatientsData()
const categoriesResponse = await getCategories() this.closeFilter()
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 () { closeFilter () {
try { this.filterPanel = false
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,
})
}
}, },
async getAntigenData () { editFromDetails () {
try { this.closeDetails()
const antigenResponse = await getAntigenos() this.editItem(this.patient)
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,
})
}
}, },
async getHealthStatusData () { closeAssignate () {
try { this.assignOnePatient = false
const healthResponse = await getHealthStatus() this.$nextTick(() => {
this.healthData = healthResponse.data this.clearPatient()
} catch (e) { this.setPIndex(-1)
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 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,
})
}
}, },
async detailsItem (item) { async detailsItem (item) {
this.loadingPatientsData = true this.loadingPatientData = 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.setPatient(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
this.infoPatient = true this.infoPatient = true
} catch (e) { } catch (e) {
this.$toast.error(e.toString(), { this.$toast.error(e.toString(), {
...@@ -1471,14 +341,12 @@ ...@@ -1471,14 +341,12 @@
rtl: false, rtl: false,
}) })
} }
this.loadingPatientData = true
}, },
closeDeleteU () { async loadPatientsData () {
this.dialogDeleteUnavailable = false
},
async loadPatientsData (page = 1) {
this.loadingPatientsData = true this.loadingPatientsData = true
try { try {
const patientsResponse = await getPatients(page) const patientsResponse = await getPatients(this.filters)
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
...@@ -1498,56 +366,58 @@ ...@@ -1498,56 +366,58 @@
rtl: false, rtl: false,
}) })
} }
this.patientsFirstLoad = false
}, },
async editItem (item) { async editItem (item) {
this.loadingPatientsData = true this.loadingPatientData = true
try { try {
const patientResponse = await getPatient(item.id_paciente) const patientResponse = await getPatient(item.id_paciente)
this.editedItem = Object.assign({}, patientResponse.data.paciente) const cache = patientResponse.data.paciente
if (this.editedItem.apps !== null) { if (cache.apps !== null) {
this.editedItem.hipertension = this.editedItem.apps.hipertension cache.hipertension = cache.apps.hipertension
this.editedItem.diabetes = this.editedItem.apps.diabetes cache.diabetes = cache.apps.diabetes
this.editedItem.asma = this.editedItem.apps.asma cache.asma = cache.apps.asma
this.editedItem.obesidad = this.editedItem.apps.obesidad cache.obesidad = cache.apps.obesidad
this.editedItem.insuficiencia_renal = this.editedItem.apps.insuficiencia_renal cache.insuficiencia_renal = cache.apps.insuficiencia_renal
this.editedItem.oncologia = this.editedItem.apps.oncologia cache.oncologia = cache.apps.oncologia
this.editedItem.otros_apps = this.editedItem.apps.otros cache.otros_apps = cache.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 (cache.hipertension || cache.diabetes || cache.asma || cache.obesidad || cache.insuficiencia_renal || cache.oncologia || cache.otros_apps) {
this.noApp = false cache.noApp = false
} }
} }
if (this.editedItem.sintomas !== null) { if (cache.sintomas !== null) {
this.editedItem.fecha_sintomas = this.editedItem.sintomas.fecha_sintomas cache.fecha_sintomas = cache.sintomas.fecha_sintomas
this.editedItem.fiebre = this.editedItem.sintomas.fiebre cache.fiebre = cache.sintomas.fiebre
this.editedItem.rinorrea = this.editedItem.sintomas.rinorrea cache.rinorrea = cache.sintomas.rinorrea
this.editedItem.congestion_nasal = this.editedItem.sintomas.congestion_nasal cache.congestion_nasal = cache.sintomas.congestion_nasal
this.editedItem.tos = this.editedItem.sintomas.tos cache.tos = cache.sintomas.tos
this.editedItem.expectoracion = this.editedItem.sintomas.expectoracion cache.expectoracion = cache.sintomas.expectoracion
this.editedItem.dificultad_respiratoria = this.editedItem.sintomas.dificultad_respiratoria cache.dificultad_respiratoria = cache.sintomas.dificultad_respiratoria
this.editedItem.cefalea = this.editedItem.sintomas.cefalea cache.cefalea = cache.sintomas.cefalea
this.editedItem.dolor_garganta = this.editedItem.sintomas.dolor_garganta cache.dolor_garganta = cache.sintomas.dolor_garganta
this.editedItem.otros_sint = this.editedItem.sintomas.otros cache.otros_sint = cache.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 (cache.fecha_sintomas || cache.fiebre || cache.rinorrea || cache.congestion_nasal || cache.tos || cache.expectoracion || cache.dificultad_respiratoria || cache.cefalea || cache.dolor_garganta || cache.otros_sint) {
this.asymptomatic = false cache.asymptomatic = false
} }
} }
if (this.editedItem.contacto !== null) { if (cache.contacto !== null) {
this.editedItem.fecha_contacto = this.editedItem.contacto.fecha_contacto cache.fecha_contacto = cache.contacto.fecha_contacto
this.editedItem.lugar_contacto = this.editedItem.contacto.lugar_contacto cache.lugar_contacto = cache.contacto.lugar_contacto
this.editedItem.tipo_contacto = this.editedItem.contacto.tipo_contacto cache.tipo_contacto = cache.contacto.tipo_contacto
if (this.editedItem.fecha_contacto || this.editedItem.lugar_contacto || this.editedItem.tipo_contacto) { if (cache.fecha_contacto || cache.lugar_contacto || cache.tipo_contacto) {
this.isContact = true cache.isContact = true
} }
} }
if (this.editedItem.arribo !== null) { if (cache.arribo !== null) {
this.editedItem.pais_procedencia = this.editedItem.arribo.pais_procedencia cache.pais_procedencia = cache.arribo.pais_procedencia
this.editedItem.lugar_estancia = this.editedItem.arribo.lugar_estancia cache.lugar_estancia = cache.arribo.lugar_estancia
this.editedItem.fecha_arribo = this.editedItem.arribo.fecha_arribo cache.fecha_arribo = cache.arribo.fecha_arribo
if (this.editedItem.pais_procedencia || this.editedItem.lugar_estancia || this.editedItem.fecha_arribo) { if (cache.pais_procedencia || cache.lugar_estancia || cache.fecha_arribo) {
this.arrived = true cache.arrived = true
} }
} }
this.setPatient(cache)
} catch (e) { } catch (e) {
this.$toast.error(e.toString(), { this.$toast.error(e.toString(), {
position: 'bottom-center', position: 'bottom-center',
...@@ -1564,11 +434,9 @@ ...@@ -1564,11 +434,9 @@
rtl: false, rtl: false,
}) })
} }
this.editedIndex = this.patients.indexOf(item) this.loadingPatientData = false
this.setPIndex(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) {
...@@ -1576,24 +444,22 @@ ...@@ -1576,24 +444,22 @@
this.patientsFirstLoad = false this.patientsFirstLoad = false
} else { } else {
console.log('NEXT PAGE') console.log('NEXT PAGE')
if (this.patientsFilters.page !== pageInfo.page) { if (this.filters.page !== pageInfo.page) {
this.patientsFilters.page = pageInfo.page this.setFiltersPage(pageInfo.page)
this.loadPatientsData() this.loadPatientsData()
} }
} }
this.patientsFilters.page = pageInfo.page
this.loadPatientsData(pageInfo.page)
}, },
deleteItem (item) { deleteItem (item) {
this.toDeleteId = item.id_paciente this.toDeleteId = item.id_paciente
this.editedIndex = this.patients.indexOf(item) this.setPIndex(this.patients.indexOf(item))
this.editedItem = Object.assign({}, item) this.setPatient(item)
this.dialogDelete = true this.dialogDelete = true
}, },
async deleteItemConfirm () { async deleteItemConfirm () {
this.loadingPatientsData = true this.loadingPatientsData = true
this.patients.splice(this.editedIndex, 1) this.patients.splice(this.pIndex, 1)
try { try {
await deletePatient(this.toDeleteId) await deletePatient(this.toDeleteId)
this.$toast.success('Registro eliminado correctamente', { this.$toast.success('Registro eliminado correctamente', {
...@@ -1633,140 +499,32 @@ ...@@ -1633,140 +499,32 @@
closeSaved () { closeSaved () {
this.dialog = false this.dialog = false
this.$nextTick(() => { this.$nextTick(() => {
this.editedItem = Object.assign({}, this.defaultItem) this.clearPatient()
this.editedIndex = -1 this.setPIndex(-1)
}) })
this.loadPatientsData() this.loadPatientsData()
}, },
close () { close () {
this.dialog = false this.dialog = false
this.$refs.form.resetValidation()
this.$nextTick(() => { this.$nextTick(() => {
this.editedItem = Object.assign({}, this.defaultItem) this.clearPatient()
this.editedIndex = -1 this.setPIndex(-1)
}) })
}, },
closeDelete () { closeDelete () {
this.dialogDelete = false this.dialogDelete = false
this.$nextTick(() => { this.$nextTick(() => {
this.editedItem = Object.assign({}, this.defaultItem) this.clearPatient()
this.editedIndex = -1 this.setPIndex(-1)
}) })
}, },
closeDetails () { closeDetails () {
this.infoPatient = false this.infoPatient = false
this.$nextTick(() => { this.$nextTick(() => {
this.editedItem = Object.assign({}, this.defaultItem) this.clearPatient()
this.editedIndex = -1 this.setPIndex(-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,
})
}
},
}, },
} }
...@@ -1775,4 +533,7 @@ ...@@ -1775,4 +533,7 @@
.fix-title { .fix-title {
word-break: normal; word-break: normal;
} }
.toolbar-btn {
margin: 4px
}
</style> </style>