Skip to content

Commit f2aaf1b

Browse files
committed
REC-136: Efectores y cuil paciente
1 parent 8db1dad commit f2aaf1b

11 files changed

Lines changed: 60 additions & 14 deletions

src/controllers/prescription.controller.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ class PrescriptionController implements BaseController {
188188
profesion: pg.profesion,
189189
codigoProfesion: pg.codigoProfesion,
190190
numeroMatricula: pg.numeroMatricula
191-
})) : []
191+
})) : [],
192+
efector: myProfessional?.efectores[0] ? myProfessional.efectores[0] : undefined
192193
},
193194
date,
194195
supplies: [sup],
@@ -219,6 +220,12 @@ class PrescriptionController implements BaseController {
219220
businessName: myProfessional?.businessName,
220221
cuil: myProfessional?.cuil,
221222
enrollment: myProfessional?.enrollment,
223+
profesionGrado: myProfessional?.profesionGrado?.length ? myProfessional.profesionGrado.map((pg: any) => ({
224+
profesion: pg.profesion,
225+
codigoProfesion: pg.codigoProfesion,
226+
numeroMatricula: pg.numeroMatricula
227+
})) : [],
228+
efector: myProfessional?.efectores[0] ? myProfessional.efectores[0] : undefined
222229
},
223230
date: moment(date).add(30, 'days').toDate(),
224231
supplies: [sup],
@@ -234,6 +241,12 @@ class PrescriptionController implements BaseController {
234241
businessName: myProfessional?.businessName,
235242
cuil: myProfessional?.cuil,
236243
enrollment: myProfessional?.enrollment,
244+
profesionGrado: myProfessional?.profesionGrado?.length ? myProfessional.profesionGrado.map((pg: any) => ({
245+
profesion: pg.profesion,
246+
codigoProfesion: pg.codigoProfesion,
247+
numeroMatricula: pg.numeroMatricula
248+
})) : [],
249+
efector: myProfessional?.efectores[0] ? myProfessional.efectores[0] : undefined
237250
},
238251
date: moment(date).add(60, 'days').toDate(),
239252
supplies: [sup],

src/controllers/users.controller.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ class UsersController {
3232
}
3333

3434
const result = await User.findOneAndUpdate({ _id: req.body._id }, req.body, { new: true, projection: { password: 0, refreshToken: 0, authenticationToken: 0 } }).populate('roles', 'role');
35-
3635
if (oldEmail && req.body.email && oldEmail !== req.body.email && result) {
3736
// Ejecutar el envío de email de forma asíncrona para no bloquear la respuesta
3837
this.sendEmailChangeNotification(result, oldEmail, req.body.email).catch(error => {
38+
// eslint-disable-next-line no-console
3939
console.error('Error enviando notificación de cambio de email:', error);
4040
});
4141
}
@@ -103,7 +103,8 @@ class UsersController {
103103
createdAt: user.createdAt,
104104
updatedAt: user.updatedAt,
105105
lastLogin: user.lastLogin,
106-
isActive: user.isActive
106+
isActive: user.isActive,
107+
efectores: user.efectores
107108
});
108109

109110
} catch (err) {

src/interfaces/patient.interface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ export default interface IPatient extends Document {
1919
updatedAt?: Date;
2020
idLocalInMPI?: boolean; // Indica si el paciente tiene ID local en Array de identificadores de MPI
2121
findOrCreate(patientParam: IPatient): Promise<IPatient>;
22+
cuil?: string | null;
2223
}

src/interfaces/prescription.interface.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ export default interface IPrescription extends Document {
2525
enrollment: string;
2626
cuil: string;
2727
businessName: string;
28+
efector?: {
29+
nombre: string;
30+
direccion: string;
31+
};
2832
};
2933
dispensedBy?: {
3034
userId: string;

src/interfaces/prescriptionAndes.interface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ export default interface IPrescriptionAndes extends Document {
147147
valor: Number;
148148
unidad: String;
149149
};
150+
cuil: String;
150151
};
151152
createdAt: Date;
152153
createdBy: {

src/interfaces/user.interface.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ export default interface IUser extends Document{
1616
isActive: Boolean;
1717
lastLogin?: Date;
1818
profesionGrado?: IProfesionAutorizada[];
19+
efectores: [{
20+
_id: string;
21+
nombre: string;
22+
direccion: string;
23+
}];
1924
isValidPassword(thisUser: IUser, password: string): Promise<boolean>;
2025
idAndes?: string;
2126
}

src/models/patient.model.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ export const patientSchema = new Schema({
6565
idLocalInMPI: {
6666
type: Boolean,
6767
default: false
68+
},
69+
cuil: {
70+
type: String,
71+
default: null
6872
}
6973
});
7074

@@ -129,7 +133,8 @@ const mapAndesPatientToLocal = (andesPatient: any): Partial<IPatient> => {
129133
idMPI: andesPatient.id || andesPatient._id,
130134
tipoDocumentoExtranjero: andesPatient.tipoIdentificacion || '',
131135
nroDocumentoExtranjero: andesPatient.numeroIdentificacion || '',
132-
estado: andesPatient.estado
136+
estado: andesPatient.estado,
137+
cuil: andesPatient.cuil || null
133138
};
134139
};
135140

src/models/prescription.model.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ const prescriptionSchema = new Schema({
2020
profesion: { type: String },
2121
codigoProfesion: { type: String },
2222
numeroMatricula: { type: String }
23-
}]
23+
}],
24+
efector: {
25+
_id: { type: Schema.Types.ObjectId },
26+
nombre: { type: String },
27+
direccion: { type: String }
28+
}
2429
},
2530
dispensedBy: {
2631
userId: Schema.Types.ObjectId,

src/models/prescriptionAndes.model.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ const prescriptionAndesSchema = new Schema({
172172
edadReal: {
173173
valor: Number,
174174
unidad: String
175-
}
175+
},
176+
cuil: String
176177
},
177178
createdAt: Date,
178179
createdBy: {

src/models/user.model.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Schema, Model, model } from 'mongoose';
2+
import mongoose from 'mongoose';
23
import bcrypt from 'bcryptjs';
34
import IUser from '../interfaces/user.interface';
45
import IProfesionAutorizada from '../interfaces/profesionAutorizada.interface';
@@ -84,18 +85,28 @@ export const userSchema = new Schema({
8485
},
8586
profesionGrado: [{
8687
profesion: {
87-
type: String,
88-
required: '{PATH} is required'
88+
type: String,
89+
required: '{PATH} is required'
8990
},
9091
codigoProfesion: {
91-
type: String,
92-
required: '{PATH} is required'
92+
type: String,
93+
required: '{PATH} is required'
9394
},
9495
numeroMatricula: {
95-
type: String,
96-
required: '{PATH} is required'
96+
type: String,
97+
required: '{PATH} is required'
9798
},
98-
}]
99+
}],
100+
efectores: [
101+
{
102+
_id: {
103+
type: Schema.Types.ObjectId,
104+
default: () => new mongoose.Types.ObjectId()
105+
},
106+
nombre: String,
107+
direccion: String,
108+
}
109+
]
99110
});
100111

101112
// Model

0 commit comments

Comments
 (0)