Skip to content

Commit

Permalink
feat(PER-77): cantidad de embarazos (#1746)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarianoCampetella committed Nov 22, 2022
1 parent cb90d91 commit 1b5aa28
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions modules/perinatal/controller/carnet-perinatal.events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ EventCore.on('perinatal:control:validacion', async ({ prestacion, registro }) =>
const primeriza = carnetYdatos.primeriza;
const fechaProximoControl = proximoCtrol(prestacion);
const datos = cargarDatos(prestacion);

if (carnetExistente) {
if (!carnetExistente.controles) {
carnetExistente.controles = [];
Expand Down Expand Up @@ -54,6 +53,7 @@ EventCore.on('perinatal:control:validacion', async ({ prestacion, registro }) =>
}
carnetExistente.fechaUltimoControl = carnetExistente.controles[carnetExistente.controles.length - 1].fechaControl;
await CarnetPerinatalCtr.update(carnetExistente.id, carnetExistente, userScheduler as any);

} else {
const carnet: any = {
fecha: moment(prestacion.ejecucion.fecha).startOf('day').toDate(),
Expand All @@ -67,8 +67,12 @@ EventCore.on('perinatal:control:validacion', async ({ prestacion, registro }) =>
}],
fechaUltimoControl: moment(prestacion.ejecucion.fecha).startOf('day').toDate(),
fechaProximoControl,
embarazo
embarazo,
};
const registros = prestacion.ejecucion.registros.find(reg => reg.concepto.conceptId === '364323006');
if (registros) {
carnet['cantidadEmbarazos'] = registros.valor;
}
carnet.primeriza = primeriza;
if (datos.fechaUltimaMenstruacion) {
carnet.fechaUltimaMenstruacion = moment(datos.fechaUltimaMenstruacion.valor).startOf('day').toDate();
Expand Down Expand Up @@ -163,6 +167,10 @@ export const obtenerCarnetYdatos = async (registro, prestacion) => {
if (primeriza) {
query['primeriza'] = primeriza;
} else {
if (embarazo.conceptId === '127374005') {
const registros = prestacion.ejecucion.registros.find(reg => reg.concepto.conceptId === '364323006');
query['cantidadEmbarazos'] = { $eq: registros.valor };
}
query['embarazo.conceptId'] = embarazo.conceptId;
}
const carnet: any = await CarnetPerinatal.findOne(query);
Expand Down
1 change: 1 addition & 0 deletions modules/perinatal/schemas/carnet-perinatal.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const CarnetPerinatalSchema = new Schema({
fsn: String,
semanticTag: String
},
cantidadEmbarazos: Number,
nota: String
});

Expand Down

0 comments on commit 1b5aa28

Please sign in to comment.