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

IN - Registro de uso de respirador en colección internacionPacienteResumen #1615

Merged
merged 3 commits into from
Jan 10, 2022
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
4 changes: 4 additions & 0 deletions modules/rup/internacion/cama-estados.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,12 @@ export async function snapshotEstados({ fecha, organizacion, ambito, capa }, fil
fechaIngreso: '$estado_internacion.fechaIngreso',
fechaAtencion: '$estado_internacion.fechaAtencion',
prioridad: '$estado_internacion.prioridad',
registros: '$estado_internacion.registros',
}
});
aggregate.push({
$unset: 'estado_internacion'
});
}

return await CamaEstados.aggregate(aggregate);
Expand Down
48 changes: 40 additions & 8 deletions modules/rup/internacion/resumen/internacion-resumen.hook.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { EventCore } from '@andes/event-bus';
import { Types } from 'mongoose';
import { InternacionResumen } from './internacion-resumen.schema';

EventCore.on('mapa-camas:paciente:undo', async movimiento => {
if (movimiento.capa && movimiento.capa === 'estadistica') { return; }


await InternacionResumen.updateOne(
{ _id: Types.ObjectId(movimiento.idInternacion) },
{
Expand All @@ -18,10 +16,8 @@ EventCore.on('mapa-camas:paciente:undo', async movimiento => {

EventCore.on('mapa-camas:paciente:triage', async ({ prestacion, registro }) => {
if (prestacion.trackId && prestacion.solicitud.ambitoOrigen === 'guardia') {

const resumen = await InternacionResumen.findById(prestacion.trackId);


switch (registro.valor.conceptId) {
case '394848005':
resumen.prioridad = { id: 1, label: 'BAJA', type: 'success' };
Expand All @@ -33,11 +29,47 @@ EventCore.on('mapa-camas:paciente:triage', async ({ prestacion, registro }) => {
resumen.prioridad = { id: 100, label: 'ALTA', type: 'danger' };
break;
}

resumen.fechaAtencion = prestacion.ejecucion.fecha;

await resumen.save();
}
});

EventCore.on('internacion:respirador:registro', async ({ prestacion, registro }) => {
if (prestacion.trackId && prestacion.solicitud.ambitoOrigen === 'internacion') {
const registroDispositivo = prestacion.ejecucion.registros.find(c => c.concepto.conceptId === '266700009');
await InternacionResumen.updateOne(
{ _id: Types.ObjectId(prestacion.trackId) },
{
$push: {
registros: {
concepto: registro.concepto,
tipo: 'respirador',
valor: {
fechaDesde: new Date(),
fechaHasta: null
}
}
}
}
);
}
});

EventCore.on('internacion:respirador:destete', async ({ prestacion, registro }) => {
if (prestacion.trackId && prestacion.solicitud.ambitoOrigen === 'internacion') {
const r = await InternacionResumen.updateOne(
{ _id: Types.ObjectId(prestacion.trackId) },
{
$set: {
'registros.$[registro].valor.fechaHasta': new Date()
}
},
{
arrayFilters: [{
'registro.valor.fechaHasta': { $eq: null }
}]
}
);
}
});

Expand All @@ -49,7 +81,7 @@ EventCore.on('rup:internacion:valoracion-inicial', async (prestacion) => {
const resumen = await InternacionResumen.findOne(query);

if (registrosDiagnostico.registros.length) {
resumen.registros = resumen.registros || [];
(resumen.registros as any) = resumen.registros || [];

const registros = registrosDiagnostico.registros.map(r => {
return {
Expand All @@ -74,7 +106,7 @@ EventCore.on('rup:internacion:epicrisis', async (prestacion) => {
const resumen = await InternacionResumen.findOne(query);
if (registrosDiagnostico.registros.length) {

resumen.registros = resumen.registros || [];
(resumen.registros as any) = resumen.registros || [];

const registros = registrosDiagnostico.registros.map(r => {
return {
Expand Down
16 changes: 7 additions & 9 deletions modules/rup/internacion/resumen/internacion-resumen.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export interface IInternacionResumen {
fechaAtencion?: Date;
tipo_egreso?: string;
deletedAt?: Date;

ingreso: {
elementoRUP?: ObjectId;
registros?: [any];
Expand All @@ -33,13 +32,13 @@ export interface IInternacionResumen {
label: string;
type: string;
};
registros: {
tipo: string;
idPrestacion: Types.ObjectId;
registros: [{
tipo?: string;
idPrestacion?: Types.ObjectId;
concepto: ISnomedConcept;
valor: any;
esDiagnosticoPrincipal: boolean;
}[];
valor: Object;
esDiagnosticoPrincipal?: boolean;
}];
}

export type IInternacionResumenDoc = AndesDoc<IInternacionResumen>;
Expand All @@ -64,7 +63,6 @@ export const InternacionResumenSchema = new Schema({
fechaAtencion: Date,
tipo_egreso: { type: String, required: false },
deletedAt: { type: Date, required: false },

prioridad: new Schema({
id: Number,
label: String,
Expand All @@ -84,7 +82,7 @@ export const InternacionResumenSchema = new Schema({
concepto: SnomedConcept,
valor: SchemaTypes.Mixed,
esDiagnosticoPrincipal: Boolean
}],
}]

});

Expand Down
1 change: 1 addition & 0 deletions modules/rup/routes/prestacion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { IPrestacionDoc } from '../prestaciones.interface';
import { Prestacion } from '../schemas/prestacion';
import { Auth } from './../../../auth/auth.class';
import { parseDate } from './../../../shared/parse';
import { IInternacionResumen } from '../internacion/resumen/internacion-resumen.schema';

const router = express.Router();

Expand Down