Skip to content

Commit

Permalink
feat(MPI-424): Pacientes sin domicilio real
Browse files Browse the repository at this point in the history
  • Loading branch information
MarianoCampetella authored and negro89 committed Jun 3, 2024
1 parent 58a9bba commit c1aeaad
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core-v2/mpi/paciente/paciente.events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ EventCore.on('mpi:pacientes:create', async (paciente: IPacienteDoc) => {
},
body: paciente
};
if (paciente.direccion?.length) {
if (!paciente.direccion[0].situacionCalle && paciente.direccion?.length) {
await updateGeoreferencia(paciente);
}
await linkPacientesDuplicados(patientRequest, paciente);
Expand All @@ -45,7 +45,7 @@ EventCore.on('mpi:pacientes:update', async (paciente: any, changeFields: string[
const direccionOriginal = paciente._original.direccion?.[0] || null;
const direccionActual = paciente.direccion?.[0] || null;
// Verifica si hubo algun cambio en direccion, localidad y/o provincia
if (addressChanged(direccionOriginal, direccionActual)) {
if (!paciente.direccion[0].situacionCalle && addressChanged(direccionOriginal, direccionActual)) {
await updateGeoreferencia(paciente);
}
// Verifica si se realizó alguna operación de vinculación de pacientes
Expand Down
3 changes: 3 additions & 0 deletions core-v2/mpi/paciente/paciente.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@ export const patch = async (req: Request, res: Response) => {
await extractFoto(body, req);

paciente = set(paciente, body);
if (paciente.direccion[0].situacionCalle) {
paciente.direccion[0].geoReferencia = null;
}
const updated = await PacienteCtr.update(id, paciente, req);
return res.json(updated);
}
Expand Down
1 change: 1 addition & 0 deletions shared/interfaces/direccion.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface IDireccion {
ranking: Number;
activo: Boolean;
ultimaActualizacion: Date | Moment;
situacionCalle: Boolean;
}

export interface IDireccionDoc extends Document, IDireccion {
Expand Down
1 change: 1 addition & 0 deletions shared/schemas/direccion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const DireccionSchema = new mongoose.Schema({
default: true
},
ultimaActualizacion: Date,
situacionCalle: Boolean
});

DireccionSchema.methods.isCompleted = function () {
Expand Down

0 comments on commit c1aeaad

Please sign in to comment.