Commit 974a53e9 authored by Gabriel's avatar Gabriel

Agrega verificacion de que exista el usuario

parent 763d924e
......@@ -74,6 +74,15 @@ module.exports =
console.log(error);
});
},
existeUsuario: async function(tipo_documento, numero_documento, fecha_nacimiento, sexo){
return await axios.get(`/watson/existe_persona?tipo_documento=${tipo_documento}&numero_documento=${numero_documento}&fecha_nacimiento=${fecha_nacimiento}&sexo=${sexo}`)
.then(async function (response) {
return response.data.existe;
})
.catch(function (error) {
console.log(error);
});
},
crearTurno: async function (tipoDocumento, numeroDocumento, fechaNacimiento, sexo, mail, telefono, idHorario, fechaHora) {
return await axios.post('/watson/confirmar_reserva', {
"tipo_documento": tipoDocumento,
......
......@@ -3,6 +3,8 @@ const utils = require('./utils.js');
const pasos = require('./pasos.js');
const is = require('./endpoints/is.js')
let LINK_SOLICITAR_ACCESO_POR_EMAIL = 'https://www.integrandosalud.com/es-ar/integrando-pacientes-solicitar-acceso-por-email/';
let OPTIONS = 4;
let VER_MAS_PROVINCIAS_ID = '99';
let MOSTRANDO_PROVINCIAS_HASTA_KEY = 'mostrando_provincias_hasta'
......@@ -237,6 +239,13 @@ module.exports =
},
resp_correo: async function(message, userData, website_id, session_id){
userData[CORREO] = message.content;
if(!await is.existeUsuario() === true){
await crisp.sendTextMessage(website_id, session_id,
'No se pudieron validar sus datos. Solicite por favor su acceso por email ingresando al siguiente link'
);
await crisp.sendTextMessage(website_id, session_id, LINK_SOLICITAR_ACCESO_POR_EMAIL);
return;
}
let turnoElegido = JSON.parse(userData[TURNO_ELEGIDO]);
let resp = await is.crearTurno(userData[TIPO_DOCUMENTO], userData[NUMERO_DOCUMENTO], toFechaUsa(userData[FECHA_NACIMIENTO]),
userData[SEXO], userData[CORREO], 0, turnoElegido.horarioId, turnoElegido.fechaHora);
......
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