Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(mpi): quita la foto desde schema paciente #1042

Merged
merged 1 commit into from
Jul 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/mpi/controller/paciente.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export async function updateTurnosPaciente(pacienteModified) {
*/
export function buscarPaciente(id): Promise<{ db: String, paciente: any }> {
return new Promise((resolve, reject) => {
paciente.findById(id, (err, data) => {
paciente.findById(id, '+foto', (err, data) => {
if (err) {
reject(err);
} else {
Expand Down
48 changes: 14 additions & 34 deletions core/mpi/routes/paciente.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,7 @@ router.get('/pacientes/auditoria/', (req, res, next) => {
if (err) {
return next(err);
}
data = data.map(elto => {
delete elto.foto;
return elto;
});

res.json(data);
});

Expand Down Expand Up @@ -122,11 +119,6 @@ router.get('/pacientes/auditoria/vinculados/', async (req, res, next) => {
};
try {
let listado = await paciente.find(filtro);
listado = listado.map(elto => {
const item = JSON.parse(JSON.stringify(elto));
delete item.foto;
return item;
});
res.json(listado);
} catch (error) {
return next(error);
Expand All @@ -139,11 +131,6 @@ router.get('/pacientes/inactivos/', async (req, res, next) => {
};
try {
let listado = await paciente.find(filtro);
listado = listado.map(elto => {
const item = JSON.parse(JSON.stringify(elto));
delete item.foto;
return item;
});
res.json(listado);
} catch (error) {
return next(error);
Expand All @@ -152,29 +139,31 @@ router.get('/pacientes/inactivos/', async (req, res, next) => {
});

// Search using filters
router.get('/pacientes/search', (req, res, next) => {
router.get('/pacientes/search', async (req, res, next) => {
if (!Auth.check(req, 'mpi:paciente:getbyId')) {
return next(403);
}
controller.matching({ type: 'search', filtros: req.query }).then(result => {
try {
const result = await controller.matching({ type: 'search', filtros: req.query });
res.send(result);
}).catch(error => {
return next(error);
});
} catch (err) {
next(err);
}
});


// Search
router.get('/pacientes', (req, res, next) => {
router.get('/pacientes', async (req, res, next) => {
if (!Auth.check(req, 'mpi:paciente:getbyId')) {
return next(403);
}

controller.matching(req.query).then(result => {
try {
const result = await controller.matching(req.query);
res.send(result);
}).catch(error => {
} catch (error) {
return next(error);
});
}

});


Expand All @@ -189,16 +178,7 @@ router.get('/pacientes/:id', async (req, res, next) => {
try {
const idPaciente = req.params.id;
const { paciente: pacienteFound } = await controller.buscarPaciente(idPaciente);
const pacienteAux = JSON.parse(JSON.stringify(pacienteFound));

delete pacienteAux.foto;
if (pacienteAux.relaciones?.length) {
pacienteAux.relaciones.map(rel => {
delete rel.foto;
return rel;
});
}
const pacienteBuscado: any = new paciente(pacienteAux);
const pacienteBuscado: any = new paciente(pacienteFound);
if (pacienteBuscado && pacienteBuscado.documento) {
let pacienteConOS = pacienteBuscado.toObject({ virtuals: true });
pacienteConOS.id = pacienteConOS._id;
Expand Down
5 changes: 4 additions & 1 deletion core/mpi/schemas/paciente.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ export let pacienteSchema: mongoose.Schema = new mongoose.Schema({
},
fechaFallecimiento: Date,
estadoCivil: constantes.ESTADOCIVIL,
foto: String,
foto: {
type: String,
select: false
},
fotoMobile: String,
nacionalidad: String,
// ---------------------
Expand Down