Commit 3f9b6187 authored by krlsnvz93's avatar krlsnvz93
Browse files

Fixes in put in patients v2

parent 07486b3b
import { DEFAULT_PATIENT } from '../utils/constants'
export default { export default {
setDrawer (state) { setDrawer (state) {
...@@ -13,49 +12,4 @@ export default { ...@@ -13,49 +12,4 @@ 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
},
setEditFromFile (state, data) {
state.editFromFile = data
},
} }
export default { export default {
drawer: true, drawer: true,
systemStatuses: [], systemStatuses: null,
provinces: [], provinces: null,
municipalities: [], municipalities: null,
categories: [],
centers: [],
clasifications: [],
antigens: [],
healthAreas: [],
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,
editFromFile: false,
} }
...@@ -1459,53 +1459,3 @@ export const COUNTRIES = [{ ...@@ -1459,53 +1459,3 @@ 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: '',
}
...@@ -3,29 +3,19 @@ const idRegex = /^[0-9]{11}$/ ...@@ -3,29 +3,19 @@ const idRegex = /^[0-9]{11}$/
const emailRegex = /^([a-zA-Z0-9_\-.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/ const emailRegex = /^([a-zA-Z0-9_\-.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/
const phoneRegex = /\(?([0-9]{3})\)?([ .-]?)([0-9]{3})\2([0-9]{4})/ const phoneRegex = /\(?([0-9]{3})\)?([ .-]?)([0-9]{3})\2([0-9]{4})/
const lettersBlankSpacesRegex = /^([á-úÁ-Úa-zA-Z ])+$/ const lettersBlankSpacesRegex = /^([á-úÁ-Úa-zA-Z ])+$/
const cmfRegex = /^([0-9-.])$/ const cmfRegex = /^([0-9-.])+$/
const lastNameRegex = /^([á-úÁ-Úa-zA-Z])+( [á-úÁ-Úa-zA-Z]+)?$/ const lastNameRegex = /^([á-úÁ-Úa-zA-Z])+( [á-úÁ-Úa-zA-Z]+)?$/
const positiveNumberRegex = /^[0-9]+$/ const positiveNumberRegex = /^[0-9]+$/
const numbersRegex = /^(?!-0(\.0+)?$)-?(0|[1-9]\d*)(\.\d+)?$/ const numbersRegex = /^(?!-0(\.0+)?$)-?(0|[1-9]\d*)(\.\d+)?$/
const passwordRegex = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*]).{8,}$/
const lowerCaseLetter = /^(?=.*[a-z])/
const isNumber = string => { const isNumber = string => {
return numberRegex.test(string) return numberRegex.test(string)
} }
const isTest = string => {
return lowerCaseLetter.test(string)
}
const isId = string => { const isId = string => {
return idRegex.test(string) return idRegex.test(string)
} }
const isPass = string => {
return passwordRegex.test(string)
}
const isCmf = string => { const isCmf = string => {
return cmfRegex.test(string) return cmfRegex.test(string)
} }
...@@ -47,19 +37,13 @@ const isLastName = string => { ...@@ -47,19 +37,13 @@ const isLastName = string => {
} }
const isPositiveNumber = string => { const isPositiveNumber = string => {
const pepe = positiveNumberRegex.test(string) return positiveNumberRegex.test(string)
const armando = string < 200
return pepe && armando
} }
const isGpsCoordinate = string => { const isGpsCoordinate = string => {
return numbersRegex.test(string) return numbersRegex.test(string)
} }
const isAge = string => {
return string > 200
}
export { export {
isNumber, isNumber,
isId, isId,
......
/* eslint-disable */
<template> <template>
<div style="padding: 8px"> <div style="padding: 8px">
<div v-if="init"> <div
v-if="init"
>
<v-data-table <v-data-table
:headers="headers" :headers="headers"
:items="centers" :items="centers"
...@@ -16,7 +19,9 @@ ...@@ -16,7 +19,9 @@
@pagination="paginateCenters" @pagination="paginateCenters"
> >
<template v-slot:top> <template v-slot:top>
<v-toolbar flat> <v-toolbar
flat
>
<v-toolbar-title>Centros de aislamiento</v-toolbar-title> <v-toolbar-title>Centros de aislamiento</v-toolbar-title>
<v-divider <v-divider
class="mx-4" class="mx-4"
...@@ -155,9 +160,7 @@ ...@@ -155,9 +160,7 @@
max-width="500px" max-width="500px"
> >
<v-card> <v-card>
<v-card-title <v-card-title class="text-h5">
class="text-h5"
>
Este Centro no se puede eliminar porque tiene camas en uso!!!! Este Centro no se puede eliminar porque tiene camas en uso!!!!
</v-card-title> </v-card-title>
<v-card-actions> <v-card-actions>
...@@ -228,16 +231,22 @@ ...@@ -228,16 +231,22 @@
</template> </template>
</v-data-table> </v-data-table>
</div> </div>
<div v-else-if="area"> <div
v-else-if="area"
>
<v-card> <v-card>
<v-btn <v-btn
style="margin: 12px" style="margin: 12px"
@click="init= true" @click="init= true"
> >
<v-icon>mdi-arrow-left</v-icon>Atras <v-icon>
mdi-arrow-left
</v-icon> Atras
</v-btn> </v-btn>
<v-card-title> <v-card-title>
<v-icon large> <v-icon
large
>
mdi-hospital-building mdi-hospital-building
</v-icon> </v-icon>
<v-card-title class="text-h5"> <v-card-title class="text-h5">
...@@ -267,7 +276,9 @@ ...@@ -267,7 +276,9 @@
@pagination="paginateAreas" @pagination="paginateAreas"
> >
<template v-slot:top> <template v-slot:top>
<v-toolbar flat> <v-toolbar
flat
>
<v-toolbar-title>Areas</v-toolbar-title> <v-toolbar-title>Areas</v-toolbar-title>
<v-divider <v-divider
class="mx-4" class="mx-4"
...@@ -317,7 +328,7 @@ ...@@ -317,7 +328,7 @@
v-model="editedAreaItem.categoria" v-model="editedAreaItem.categoria"
:items="categories" :items="categories"
color="white" color="white"
item-text="nombre" item-text="name"
label="Categoria" label="Categoria"
/> />
</v-col> </v-col>
...@@ -380,9 +391,7 @@ ...@@ -380,9 +391,7 @@
max-width="500px" max-width="500px"
> >
<v-card> <v-card>
<v-card-title <v-card-title class="text-h5">
class="text-h5"
>
Esta Area no se puede eliminar porque tiene camas en uso!!!! Esta Area no se puede eliminar porque tiene camas en uso!!!!
</v-card-title> </v-card-title>
<v-card-actions> <v-card-actions>
...@@ -429,7 +438,7 @@ ...@@ -429,7 +438,7 @@
</template> </template>
<span>Eliminar</span> <span>Eliminar</span>
</v-tooltip> </v-tooltip>
<v-tooltip bottom> <!-- <v-tooltip bottom>
<template v-slot:activator="{ on, attrs }"> <template v-slot:activator="{ on, attrs }">
<v-icon <v-icon
color="info" color="info"
...@@ -441,7 +450,7 @@ ...@@ -441,7 +450,7 @@
</v-icon> </v-icon>
</template> </template>
<span>Detalles</span> <span>Detalles</span>
</v-tooltip> </v-tooltip> -->
</template> </template>
<template v-slot:no-data> <template v-slot:no-data>
<v-btn <v-btn
...@@ -455,16 +464,22 @@ ...@@ -455,16 +464,22 @@
</v-card-text> </v-card-text>
</v-card> </v-card>
</div> </div>
<div v-else-if="room"> <div
v-else-if="room"
>
<v-card> <v-card>
<v-btn <v-btn
style="margin: 12px" style="margin: 12px"
@click="area = true" @click="area = true"
> >
<v-icon>mdi-arrow-left</v-icon>Atras <v-icon>
mdi-arrow-left
</v-icon> Atras
</v-btn> </v-btn>
<v-card-title> <v-card-title>
<v-icon large> <v-icon
large
>
mdi-hospital-building mdi-hospital-building
</v-icon> </v-icon>
<v-card-title class="text-h5"> <v-card-title class="text-h5">
...@@ -475,8 +490,9 @@ ...@@ -475,8 +490,9 @@
<v-card-text> <v-card-text>
<v-card> <v-card>
<v-card-title> <v-card-title>
<v-icon>mdi-domain</v-icon> <v-icon>
{{ editedAreaItem.nombre }} mdi-domain
</v-icon>{{ editedAreaItem.nombre }}
</v-card-title> </v-card-title>
<v-card-subtitle>{{ editedAreaItem.categoria }}</v-card-subtitle> <v-card-subtitle>{{ editedAreaItem.categoria }}</v-card-subtitle>
<info-box <info-box
...@@ -493,7 +509,9 @@ ...@@ -493,7 +509,9 @@
class="elevation-1" class="elevation-1"
> >
<template v-slot:top> <template v-slot:top>
<v-toolbar flat> <v-toolbar
flat
>
<v-toolbar-title>Habitaciones</v-toolbar-title> <v-toolbar-title>Habitaciones</v-toolbar-title>
<v-divider <v-divider
class="mx-4" class="mx-4"
...@@ -604,9 +622,7 @@ ...@@ -604,9 +622,7 @@
max-width="500px" max-width="500px"
> >
<v-card> <v-card>
<v-card-title <v-card-title class="text-h5">
class="text-h5"
>
Esta Habitacion no se puede eliminar porque tiene camas en uso!!!! Esta Habitacion no se puede eliminar porque tiene camas en uso!!!!
</v-card-title> </v-card-title>
<v-card-actions> <v-card-actions>
...@@ -672,23 +688,9 @@ ...@@ -672,23 +688,9 @@
<script> <script>
import InfoBox from '@/components/InfoBox.vue' import InfoBox from '@/components/InfoBox.vue'
import { import { getCenters, postCenter, putCenter, deleteCenter } from '@/axios/centers'
getCenters, import { getAreas, postArea, putArea, deleteArea } from '@/axios/areas'
postCenter, import { getMunicipalities, getProvinces } from '@/axios/nomenclators'
putCenter,
deleteCenter,
} from '@/axios/centers'
import {
getAreas,
postArea,
putArea,
deleteArea,
} from '@/axios/areas'
import {
getMunicipalities,
getProvinces,
getClasifications,
} from '@/axios/nomenclators'
export default { export default {
components: { InfoBox }, components: { InfoBox },
data: () => ({ data: () => ({
...@@ -704,8 +706,76 @@ ...@@ -704,8 +706,76 @@
loadingCentersData: true, loadingCentersData: true,
totalCentersItems: 0, totalCentersItems: 0,
totalAreasItems: 0, totalAreasItems: 0,
myStats: [], myStats: [
myAreaStats: [], {
bgColor: 'success ligthen-1',
iconClass: 'blue lighten-3 white--text',
icon: 'mdi-bunk-bed-outline',
title: 'Camas Totales',
data: '450',
action: {
label: 'more',
link: '',
},
},
{
bgColor: 'success ligthen-1',
iconClass: 'blue lighten-3 white--text',
icon: 'mdi-bed',
title: 'Camas Usadas',
data: '200',
action: {
label: 'more',
link: '',
},
},
{
bgColor: 'success ligthen-1',
iconClass: 'blue lighten-3 white--text',
icon: 'mdi-bed-empty',
title: 'Camas Disponibles',
data: '250',
action: {
label: 'more',
link: '',
},
},
],
myAreaStats: [
{
bgColor: 'success ligthen-1',
iconClass: 'blue lighten-3 white--text',
icon: 'mdi-bunk-bed-outline',
title: 'Camas Totales',
data: '200',
action: {
label: 'more',
link: '',
},
},
{
bgColor: 'success ligthen-1',
iconClass: 'blue lighten-3 white--text',
icon: 'mdi-bed',
title: 'Camas Usadas',
data: '150',
action: {
label: 'more',
link: '',
},
},
{
bgColor: 'success ligthen-1',
iconClass: 'blue lighten-3 white--text',
icon: 'mdi-bed-empty',
title: 'Camas Disponibles',
data: '50',
action: {
label: 'more',
link: '',
},
},
],
area: false, area: false,
init: true, init: true,
room: false, room: false,
...@@ -720,7 +790,11 @@ ...@@ -720,7 +790,11 @@
dialogRoomDelete: false, dialogRoomDelete: false,
provinces: [], provinces: [],
municipalities: [], municipalities: [],
categories: [], categories: [
{ name: 'Sospechoso', id: 1 },
{ name: 'Positivo', id: 2 },
{ name: 'Contacto', id: 3 },
],
headers: [ headers: [
{ {
text: 'Nombre', text: 'Nombre',
...@@ -805,9 +879,7 @@ ...@@ -805,9 +879,7 @@
return this.editedAreaIndex === -1 ? 'Nueva Area' : 'Editar Area' return this.editedAreaIndex === -1 ? 'Nueva Area' : 'Editar Area'
}, },
roomsFormTitle () { roomsFormTitle () {
return this.editedRoomIndex === -1 return this.editedRoomIndex === -1 ? 'Nueva Habitación' : 'Editar Habitación'
? 'Nueva Habitación'
: 'Editar Habitación'
}, },
}, },
watch: { watch: {
...@@ -834,7 +906,6 @@ ...@@ -834,7 +906,6 @@
this.initialize() this.initialize()
this.getProvincesData() this.getProvincesData()
this.loadMunicipalitiesData() this.loadMunicipalitiesData()
this.loadClasificationsData()
}, },
async mounted () { async mounted () {
this.initialize() this.initialize()
...@@ -862,27 +933,6 @@ ...@@ -862,27 +933,6 @@
}) })
} }
}, },
async loadClasificationsData () {
try {
const categoriesResponse = await getClasifications()
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 getProvincesData () { async getProvincesData () {
try { try {
const provincesResponse = await getProvinces() const provincesResponse = await getProvinces()
...@@ -949,8 +999,72 @@ ...@@ -949,8 +999,72 @@
this.dialogRoomDeleteUnavailable = false this.dialogRoomDeleteUnavailable = false
}, },
initialize () { initialize () {
this.centers = [] this.centers = [
this.areas = [] {
nombre_centro: 'EIA',
municipio: 'Santa Clara',
organismo: 'MINED',
cap_positivos: 100,
cap_sospechosos: 67,
cap_contactos: 67,
dis_positivos: 80,
dis_sospechosos: 25,
dis_contactos: 50,
},
{
nombre_centro: 'UCLV',
municipio: 'Santa Clara',
organismo: 'MES',
cap_positivos: 100,
cap_sospechosos: 67,
cap_contactos: 67,
dis_positivos: 80,
dis_sospechosos: 25,
dis_contactos: 50,
},
{
nombre_centro: 'Pedagogico',
municipio: 'Santa Clara',
organismo: 'MES',
cap_positivos: 100,
cap_sospechosos: 67,
cap_contactos: 67,
dis_positivos: 80,
dis_sospechosos: 25,
dis_contactos: 50,
},
{
nombre_centro: 'Perez Quintosa',
municipio: 'Santa Clara',
organismo: 'MINED',
cap_positivos: 100,
cap_sospechosos: 67,
cap_contactos: 67,
dis_positivos: 80,
dis_sospechosos: 25,
dis_contactos: 50,
},
]
this.areas = [
{
name: '900-A',
category: 'Sospechosos',
capacity: 45,
availability: 20,
},
{
name: '900-B',
category: 'Sospechosos',
capacity: 45,
availability: 15,
},
{
name: '900-C',
category: 'Sospechosos',
capacity: 53,
availability: 20,
},
]
this.rooms = [ this.rooms = [
{ {
number: 101, number: 101,
...@@ -999,20 +1113,6 @@ ...@@ -999,20 +1113,6 @@
async deleteItemConfirm () { async deleteItemConfirm () {
try { try {
await deleteCenter(this.editedItem.id_centro) await deleteCenter(this.editedItem.id_centro)
this.$toast.success('Centro eliminado correctamente', {
position: 'bottom-center',
timeout: 5000,
closeOnClick: true,
pauseOnFocusLoss: false,
pauseOnHover: true,
draggable: true,
draggablePercent: 0.6,
showCloseButtonOnHover: false,
hideProgressBar: true,
closeButton: 'button',
icon: true,
rtl: false,
})
this.loadCentersData() this.loadCentersData()
} catch (err) { } catch (err) {
console.log(err) console.log(err)
...@@ -1023,20 +1123,6 @@ ...@@ -1023,20 +1123,6 @@
async deleteAreaItemConfirm () { async deleteAreaItemConfirm () {
try { try {
await deleteArea(this.editedAreaItem.id_area) await deleteArea(this.editedAreaItem.id_area)
this.$toast.success('Área eliminada 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.loadAreasData() this.loadAreasData()
} catch (err) { } catch (err) {
console.log(err) console.log(err)
...@@ -1094,56 +1180,13 @@ ...@@ -1094,56 +1180,13 @@
if (this.editedIndex > -1) { if (this.editedIndex > -1) {
await putCenter(this.editedItem) await putCenter(this.editedItem)
this.loadCentersData() this.loadCentersData()
// TODO: DELETE THIS !!
Object.assign(this.centers[this.editedIndex], this.editedItem) Object.assign(this.centers[this.editedIndex], this.editedItem)
this.$toast.success('Centro editado 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,
})
} else { } else {
try { await postCenter(this.editedItem)
await postCenter(this.editedItem) this.loadCentersData()
this.loadCentersData() // TODO: DELETE THIS !!
this.centers.push(this.editedItem) this.centers.push(this.editedItem)
this.$toast.success('Centro insertado 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,
})
} 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,
})
}
} }
this.close() this.close()
}, },
...@@ -1152,38 +1195,10 @@ ...@@ -1152,38 +1195,10 @@
await putArea(this.editedAreaItem) await putArea(this.editedAreaItem)
this.loadAreasData() this.loadAreasData()
Object.assign(this.areas[this.editedAreaIndex], this.editedAreaItem) Object.assign(this.areas[this.editedAreaIndex], this.editedAreaItem)
this.$toast.success('Área editada 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,
})
} else { } else {
await postArea(this.editedItem.id_centro, this.editedAreaItem) await postArea(this.editedItem.id_centro, this.editedAreaItem)
this.loadAreasData() this.loadAreasData()
this.areas.push(this.editedAreaItem) this.areas.push(this.editedAreaItem)
this.$toast.success('Área insertada 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.closeArea() this.closeArea()
}, },
...@@ -1217,6 +1232,6 @@ ...@@ -1217,6 +1232,6 @@
</script> </script>
<style scoped> <style scoped>
.fix-title { .fix-title {
word-break: normal; word-break: normal;
} }
</style> </style>
...@@ -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: [
{ {
......
...@@ -27,10 +27,10 @@ ...@@ -27,10 +27,10 @@
<div class="col-md-5" id="add-patients"> <div class="col-md-5" id="add-patients">
<v-btn <v-btn
depressed depressed
@click="addPatients" @click="procesar_ingreso"
color="primary" color="primary"
> >
Agregar Paciente Ingresar Pacientes
</v-btn> </v-btn>
</div> </div>
...@@ -98,6 +98,68 @@ ...@@ -98,6 +98,68 @@
></v-select> ></v-select>
</div> </div>
</div> </div>
<p id="selected-area" v-if="selected_area.length" class="text-justify">
Area seleccionada: {{ selected_area }}
</p>
<!-- modal-->
<v-row justify="center">
<v-dialog
v-model="dialog"
scrollable
max-width="300px"
>
<template v-slot:activator="{ on, attrs }">
<v-btn
color="primary"
dark
v-bind:disabled="selected_centers.length===0"
v-bind="attrs"
v-on="on"
>
Seleccionar area
</v-btn>
</template>
<v-card>
<v-card-title>Seleccione un area</v-card-title>
<v-divider></v-divider>
<v-card-text style="height: 200px;">
<v-radio-group
v-model="dialogm1"
column
>
<div v-if="selected_centers.length">
<v-radio v-for="item in selected_centers[0].areas"
v-bind:label="item.nombre"
v-bind:value="item.id_area"
@change="update_selected_area(item)"
></v-radio>
</div>
</v-radio-group>
</v-card-text>
<v-divider></v-divider>
<v-card-actions>
<v-btn
color="blue darken-1"
text
@click="dialog = false"
>
Cancelar
</v-btn>
<v-btn
color="blue darken-1"
text
@click="dialog = false"
>
Seleccionar
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</v-row>
</template> </template>
</v-data-table> </v-data-table>
</div> </div>
...@@ -107,7 +169,7 @@ ...@@ -107,7 +169,7 @@
<script> <script>
import {getPatients, getPatient, postPatient, deletePatient, putPatient} from '@/axios/patients' import {getPatients, getPatient, postPatient, deletePatient, putPatient, ingresarPacientes} from '@/axios/patients'
import {getCategories, getClasifications} from '@/axios/nomenclators' import {getCategories, getClasifications} from '@/axios/nomenclators'
import {deleteCenter, getCenters} from '@/axios/centers' import {deleteCenter, getCenters} from '@/axios/centers'
import {forInRight} from 'lodash' import {forInRight} from 'lodash'
...@@ -129,7 +191,7 @@ export default { ...@@ -129,7 +191,7 @@ export default {
{text: 'Edad', value: 'edad'}, {text: 'Edad', value: 'edad'},
{text: 'Sexo', value: 'sexo'}, {text: 'Sexo', value: 'sexo'},
{text: 'Categoría', value: 'categoria'}, {text: 'Categoría', value: 'categoria'},
{text: 'Clasificación', value: 'clasificacion'}, {text: 'Clasificación', value: 'riesgo'},
], ],
patients: [], patients: [],
singleSelectCenters: true, singleSelectCenters: true,
...@@ -155,6 +217,9 @@ export default { ...@@ -155,6 +217,9 @@ export default {
selected_patients: [], selected_patients: [],
selected_centers: [], selected_centers: [],
text_field: "", text_field: "",
dialog: false,
selected_area: "",
selected_area_id: -1,
} }
}, },
created() { created() {
...@@ -163,6 +228,82 @@ export default { ...@@ -163,6 +228,82 @@ export default {
this.getCentersCategoriesData() this.getCentersCategoriesData()
}, },
methods: { methods: {
async procesar_ingreso() {
if (this.selected_patients.length > 0) {
if (this.selected_centers.length > 0) {
if (this.selected_area_id !== -1) {
console.log("SELECTED PATIENTS: " + this.selected_patients + "SELECTED AREA: " + this.selected_area);
// const response = await this.ingresarPacientes(this.selected_patients, this.selected_area);
// console.log("REsponse", response);
this.$toast.success("Paciente ingresado con éxito", {
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("Debe seleccionar un area", {
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("Debe seleccionar un centro", {
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("Debe seleccionar al menos un paciente", {
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,
})
}
},
update_selected_area(item) {
this.selected_area = item.nombre;
this.selected_area_id = item.id_area;
console.log("Selected Area: ", this.selected_area);
console.log("Selected Area ID: ", this.selected_area_id);
},
update_selected_patients(values) { update_selected_patients(values) {
console.log("SELECTED ITEMS: entre ", values); console.log("SELECTED ITEMS: entre ", values);
if (values.value) { if (values.value) {
...@@ -225,6 +366,8 @@ export default { ...@@ -225,6 +366,8 @@ export default {
this.selected_centers = neo_selected_list; this.selected_centers = neo_selected_list;
} }
} }
this.selected_area = "";
this.selected_area_id = -1;
console.log("SELECTED ITEMS CENTERS: ", this.selected_centers); console.log("SELECTED ITEMS CENTERS: ", this.selected_centers);
}, },
async filterByOrganismos(val) { async filterByOrganismos(val) {
...@@ -337,22 +480,37 @@ export default { ...@@ -337,22 +480,37 @@ export default {
try { try {
const patientsResponse = await getPatients() const patientsResponse = await getPatients()
this.patients = await patientsResponse.data.pacientes; this.patients = await patientsResponse.data.pacientes;
const data = await getClasifications();
let clasications = await data.data;
for (let i = 0; i < this.patients.length; i++) {
let patient = this.patients[i];
for (const c of clasications) {
if (c.id === patient.riesgo) {
patient.riesgo = c.nombre;
}
}
this.patients[i] = patient;
}
await this.getCategoriesData(); await this.getCategoriesData();
/*let i = 0; /*let i = 0;
for (const p in pacientes) { for (const p in pacientes) {
console.log("Entre aqui"); console.log("Entre aqui");
const p = pacientes[i]; const p = pacientes[i];
let classification = 'niño' let classification = 'niño'
if(p.embarazada!=0){ if(p.embarazada!=0){
classification = 'embarazada'; classification = 'embarazada';
} }
if(p.trabajador_salud!=0){ if(p.trabajador_salud!=0){
classification = 'trabajador de la salud'; classification = 'trabajador de la salud';
} }
p.clasificacion = classification; p.clasificacion = classification;
pacientes[i] = p; pacientes[i] = p;
i+=1; i+=1;
}*/ }*/
// this.patients = pacientes; // this.patients = pacientes;
// console.log('Patientsss', pacientes); // console.log('Patientsss', pacientes);
} catch (e) { } catch (e) {
...@@ -466,9 +624,8 @@ export default { ...@@ -466,9 +624,8 @@ export default {
} }
} }
}, },
} }
</script> </script>
<style> <style>
#centers-table { #centers-table {
...@@ -479,7 +636,7 @@ export default { ...@@ -479,7 +636,7 @@ export default {
margin-top: 20px; margin-top: 20px;
} }
#filter-organism, #filter-categorie, #filter-categorie-patients, #patients-name { #filter-organism, #filter-categorie, #filter-categorie-patients, #patients-name, #selected-area {
margin-left: 10px; margin-left: 10px;
} }
......
...@@ -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>
...@@ -36,10 +36,10 @@ ...@@ -36,10 +36,10 @@
:rules="usernameRules" :rules="usernameRules"
prepend-icon="mdi-account" prepend-icon="mdi-account"
name="login" name="login"
label="Coreo Electrónico" label="Usuario"
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"
...@@ -76,7 +74,7 @@ ...@@ -76,7 +74,7 @@
</template> </template>
<script> <script>
import { login } from '@/axios/auth' import { login } from '@/axios/auth'
import { mapMutations } from 'vuex' import { encrypt } from '@/utils/enc'
export default { export default {
name: 'Login', name: 'Login',
data: () => ({ data: () => ({
...@@ -96,7 +94,6 @@ ...@@ -96,7 +94,6 @@
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)) {
...@@ -104,82 +101,27 @@ ...@@ -104,82 +101,27 @@
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 user = loginResponse.data.user const role = loginResponse.data.user.role
this.setUser(user) localStorage.setItem('role', role)
localStorage.setItem('tkn', token) const data = encrypt(token)
localStorage.setItem('userData', user.name + ' (' + user.email + ')') localStorage.setItem('tkn', data)
localStorage.setItem('role', user.role)
this.$router.push({ name: 'Control' }) this.$router.push({ name: 'Control' })
this.tryLogin = false
} catch (e) { } catch (e) {
if (e.toString() === 'Error: Network Error') { this.$toast.error('No autorizado', {
this.$toast.error('Error de Red, revise su conexión', { position: 'bottom-center',
position: 'bottom-center', timeout: 3000,
timeout: 3000, closeOnClick: true,
closeOnClick: true, pauseOnFocusLoss: false,
pauseOnFocusLoss: false, pauseOnHover: true,
pauseOnHover: true, draggable: true,
draggable: true, draggablePercent: 0.6,
draggablePercent: 0.6, showCloseButtonOnHover: false,
showCloseButtonOnHover: false, hideProgressBar: true,
hideProgressBar: true, closeButton: 'button',
closeButton: 'button', icon: true,
icon: true, rtl: false,
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('Credenciales Incorrectas', {
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
} }
} }
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment