diff --git a/modules/descargas/com/derivacion-body.ts b/modules/descargas/com/derivacion-body.ts
index 5017e06a19..074435795f 100644
--- a/modules/descargas/com/derivacion-body.ts
+++ b/modules/descargas/com/derivacion-body.ts
@@ -201,6 +201,45 @@ export class DerivacionBody extends HTMLComponent {
{{/if}}
+ {{#if historial}}
+
+
+
+ HISTORIAL DE DERIVACIÓN
+
+
+
+ {{#each historial}}
+
+
+ FECHA: {{ fechaCreacion }} hs
+ {{#if estado}}
+ Pasa a {{ estado }} por {{ createdBy.nombreCompleto }}{{#if createdBy.organizacion.nombre}} de {{ createdBy.organizacion.nombre }}{{/if}}
+ {{else}}
+ Actualizado por {{ createdBy.nombreCompleto }}{{#if createdBy.organizacion.nombre}} de {{ createdBy.organizacion.nombre }}{{/if}}
+ {{/if}}
+ {{#if observacion}}
+ Observaciones: {{ observacion }}
+ {{/if}}
+ {{#if dispositivo}}
+ Dispositivo de soporte de oxígeno: {{ dispositivo.nombre }}: {{ dispositivo.descripcion }}
+ {{/if}}
+ {{#if prioridad}}
+ {{#if reporteCOM}}
+ Nueva prioridad: {{ prioridad }}
+ {{/if}}
+ {{/if}}
+ {{#if organizacionDestino}}
+ Destino: {{ organizacionDestino.nombre }}
+ {{/if}}
+ {{#if unidadDestino}}
+ Unidad Destino: {{ unidadDestino.term }}
+ {{/if}}
+
+
+ {{/each}}
+ {{/if}}
+
{{#if firmaHTML}}
{{{ firmaHTML }}}
{{/if}}
@@ -259,7 +298,7 @@ export class DerivacionBody extends HTMLComponent {
datosSolicitud,
firmaHTML,
historial,
- reporteCOM: organizacion?.esCOM
+ reporteCOM: organizacion ? Boolean(organizacion.esCOM) : true
};
}
@@ -274,15 +313,18 @@ export class DerivacionBody extends HTMLComponent {
}
async getHistorialDerivacion(organizacion, derivacion) {
- derivacion.historial.shift();
- let historial = organizacion.esCOM ? derivacion.historial : derivacion.historial.filter((h) => h.createdBy.organizacion.id === organizacion.id);
+ const copyHistorial = [...(derivacion.historial || [])];
+ const esCOM = organizacion ? Boolean(organizacion.esCOM) : true;
+ let historial = esCOM
+ ? copyHistorial
+ : copyHistorial.filter((h) => h.createdBy?.organizacion?.id?.toString() === organizacion?.id?.toString());
historial = historial.filter(h => !h.eliminado);
historial.forEach(h => {
h.fechaCreacion = moment(h.createdAt).locale('es').format('DD/MM/YYYY HH:mm');
- h.reporteCOM = organizacion.esCOM;
+ h.reporteCOM = esCOM;
h.esActualizacion = !h?.estado;
});
- return historial.sort((a, b) => b.createdAt - a.createdAt);
+ return historial.sort((a, b) => moment(b.createdAt).diff(moment(a.createdAt)));
}
async getDatosSolicitud(derivacion) {