-
- {{ estadoDispensa.fecha | date: 'dd/MM/yyyy HH:mm' }}
+
+
+
+
+
+
+
+ | {{col.label}} |
+
+
+
+
+
+ |
+ {{ item.fechaRegistro | date:'dd/MM/yyyy' }}
|
-
- {{ estadoDispensa.sistema }}
+ |
+ {{ item.organizacion?.nombre }}
|
-
- {{ estadoDispensa.organizacion }}
+ |
+ {{ item.profesional?.nombre }} {{ item.profesional?.apellido }}
|
-
- {{ estadoDispensa.tipo }}
+ |
+ {{ item.diagnostico?.term || item.diagnostico?.descripcion }}
|
-
-
- dispensa duplicada
-
-
- dispensa cancelada {{(estadoDispensa.fechaCancelada | date: 'dd/MM/yyyy HH:mm')}}
-
+ |
+
+
+ {{ item.estadoActual?.tipo }}
+
+
+ {{ item.estadoDispensaActual?.tipo?.replace('-', ' ') }}
+
+
+ {{ checkDispensaAnticipada(item) }}
+
+
+
+
+ TRATAMIENTO PROLONGADO
+
+
+
|
-
-
-
-
-
-
- Motivo de suspensión
-
-
-
-
-
-
- Fecha
- {{recetaPrincipal.estadoActual.createdAt | date:'dd/MM/yyyy HH:mm'}}
-
-
-
- Profesional
-
- {{recetaPrincipal.estadoActual.profesional?.apellido}},
- {{recetaPrincipal.estadoActual.profesional?.nombre}}
- - Sin profesional -
-
-
-
- Motivo
- {{recetaPrincipal.estadoActual.motivo || '- Sin especificar -'}}
-
-
- Observación
- {{recetaPrincipal.estadoActual.observacion || "- Sin especificar -"}}
-
-
-
-
-
-
+
+
+
+
+
+
+ {{ receta.medicamento?.concepto?.term ||
+ receta.insumo?.nombre || receta.medicamento?.nombre }}
+ Orden {{ ((receta.medicamento?.ordenTratamiento ??
+ receta.insumo?.ordenTratamiento) || 0) + 1 }} de
+ {{ receta.medicamento?.tiempoTratamiento?.id ||
+ receta.insumo?.tiempoTratamiento?.id || '1' }}
+
+
+ |
+
+
+
+ {{ receta.estadoActual?.tipo }}
+
+
+ {{ receta.estadoDispensaActual?.tipo?.replace('-', ' ') }}
+
+
+ {{ checkDispensaAnticipada(receta) }}
+
+
+ |
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/app/modules/rup/components/huds/vistaReceta.scss b/src/app/modules/rup/components/huds/vistaReceta.scss
index 295b34fec1..0b753f3f39 100644
--- a/src/app/modules/rup/components/huds/vistaReceta.scss
+++ b/src/app/modules/rup/components/huds/vistaReceta.scss
@@ -85,7 +85,8 @@
.grid-dispensa {
display: grid;
- grid-template-columns: 1fr 2fr 3fr 1fr 1fr;
+ grid-template-columns: 1.2fr 3fr 1fr 2.5fr 1fr 1fr;
+ column-gap: 10px;
align-items: center;
}
@@ -93,28 +94,11 @@
margin-right: 1;
}
- plex-panel.lista-panel {
- display: block;
- margin-bottom: 0.2rem;
- cursor: pointer;
- overflow: hidden;
- transition: transform 0.2s ease, box-shadow 0.2s ease;
-
- .titulo {
- font-size: 1rem;
- color: $recetas;
- letter-spacing: 0.5px;
- display: flex;
- align-items: center;
- }
-
- &[active="true"] {
- border-left: 5px solid $recetas;
-
- .titulo {
- font-weight: 700;
- }
- }
+ .tratamiento-item {
+ display: flex;
+ padding: 10px 10px 10px 0px;
+ align-items: center;
+ border: 1px solid #999;
}
}
@@ -268,4 +252,84 @@
}
}
}
+}
+
+.table-historial {
+ border-collapse: collapse;
+
+ tr.grupo-header-expanded {
+ background-color: #f6fcff; // subtle blue background if needed
+
+ td {
+ border-top: 1px solid #00a8e0 !important;
+ box-shadow: inset 0 1px 0 0 #00a8e0;
+ border-bottom: none !important;
+
+ &:first-child {
+ border-left: 1px solid #00a8e0 !important;
+ box-shadow: inset 0 1px 0 0 #00a8e0, inset 1px 0 0 0 #00a8e0;
+ }
+
+ &:last-child {
+ border-right: 1px solid #00a8e0 !important;
+ box-shadow: inset 0 1px 0 0 #00a8e0, inset -1px 0 0 0 #00a8e0;
+ }
+ }
+ }
+
+ tr.grupo-detalle-expanded {
+ background-color: white;
+
+ td {
+ border-top: 1px solid #dee2e6 !important;
+ border-bottom: none !important;
+
+ &:first-child {
+ border-left: 1px solid #00a8e0 !important;
+ box-shadow: inset 1px 0 0 0 #00a8e0;
+ }
+
+ &:last-child {
+ border-right: 1px solid #00a8e0 !important;
+ box-shadow: inset -1px 0 0 0 #00a8e0;
+ }
+ }
+
+ &.ultimo-detalle td {
+ border-bottom: 1px solid #00a8e0 !important;
+ box-shadow: inset 0 -1px 0 0 #00a8e0;
+
+ &:first-child {
+ box-shadow: inset 1px -1px 0 0 #00a8e0;
+ }
+
+ &:last-child {
+ box-shadow: inset -1px -1px 0 0 #00a8e0;
+ }
+ }
+
+ /* ensure the first detail row does not have double top border since the header has a top border */
+ &.primer-detalle td {
+ border-top: none !important;
+ }
+ }
+}
+
+.icon-wrapper {
+ min-width: 80px;
+ display: flex;
+ justify-content: center;
+}
+
+.icon-info-detalle {
+ color: $recetas;
+ /* purple color mapped to $recetas */
+ padding: 8px;
+ border: 1px solid $recetas;
+ border-radius: 100%;
+ width: 45px;
+ height: 45px;
+ align-items: center;
+ display: flex;
+ justify-content: center;
}
\ No newline at end of file
diff --git a/src/app/modules/rup/components/huds/vistaReceta.ts b/src/app/modules/rup/components/huds/vistaReceta.ts
index 008d23fb05..78ebde0231 100644
--- a/src/app/modules/rup/components/huds/vistaReceta.ts
+++ b/src/app/modules/rup/components/huds/vistaReceta.ts
@@ -55,6 +55,12 @@ export class VistaRecetaComponent implements OnInit {
sorteable: false,
opcional: false
},
+ {
+ key: 'medicamento',
+ label: 'Medicamento',
+ sorteable: false,
+ opcional: false
+ },
{
key: 'sistema',
label: 'Sistema',
@@ -99,6 +105,7 @@ export class VistaRecetaComponent implements OnInit {
public recetas;
public recetaPrincipal: any;
public historialRecetas: any[];
+ public recetasRestantes: any[] = [];
constructor(
public huds: HUDSService,
@@ -107,28 +114,152 @@ export class VistaRecetaComponent implements OnInit {
) { }
ngOnInit() {
- this.recetaPrincipal = this.registro.recetas.length > 1 ? this.recetaService.getRecetaPrincipal(this.registro.recetas) : this.registro.recetas[0];
+ this.recetaPrincipal = this.registro.recetas?.length > 1 ? this.recetaService.getRecetaPrincipal(this.registro.recetas) : this.registro.recetas?.[0];
+ if (!this.recetaPrincipal) {
+ return;
+ }
this.combinarDispensas();
- this.historialRecetas = this.registro.recetas.filter(receta => receta.id !== this.recetaPrincipal.id && receta.fechaRegistro <= this.recetaPrincipal.fechaRegistro && receta.estadoActual?.tipo !== 'eliminada');
+
+ const historialBase = (this.registro.recetas || []).filter(receta => receta.id !== this.recetaPrincipal.id && receta.fechaRegistro <= this.recetaPrincipal.fechaRegistro && receta.estadoActual?.tipo !== 'eliminada');
+
+ this.recetasRestantes = (this.registro.recetas || []).filter(r =>
+ r.id !== this.recetaPrincipal.id &&
+ r.idRegistro === this.recetaPrincipal.idRegistro &&
+ (this.recetaPrincipal.medicamento?.tratamientoProlongado || this.recetaPrincipal.insumo?.tratamientoProlongado) &&
+ r.estadoActual?.tipo !== 'eliminada'
+ );
+ this.recetasRestantes.sort((a, b) => ((a.medicamento?.ordenTratamiento ?? a.insumo?.ordenTratamiento) || 0) - ((b.medicamento?.ordenTratamiento ?? b.insumo?.ordenTratamiento) || 0));
+
+ const historialExcluidoActual = historialBase.filter(r => {
+ if (this.recetaPrincipal.idRegistro && r.idRegistro === this.recetaPrincipal.idRegistro) {
+ return false;
+ }
+ return true;
+ });
+
+ const grupos = {};
+ const result = [];
+
+ historialExcluidoActual.forEach(receta => {
+ const esTP = receta.medicamento?.tratamientoProlongado || receta.insumo?.tratamientoProlongado;
+ if (esTP && receta.idRegistro) {
+ if (!grupos[receta.idRegistro]) {
+ grupos[receta.idRegistro] = [];
+ }
+ grupos[receta.idRegistro].push(receta);
+ } else {
+ result.push(receta);
+ }
+ });
+
+ Object.keys(grupos).forEach(key => {
+ const recetasGrupo = grupos[key];
+ const todasFinalizadas = recetasGrupo.every(r => r.estadoActual?.tipo !== 'vigente');
+ if (todasFinalizadas) {
+ recetasGrupo.sort((a, b) => ((a.medicamento?.ordenTratamiento ?? a.insumo?.ordenTratamiento) || 0) - ((b.medicamento?.ordenTratamiento ?? b.insumo?.ordenTratamiento) || 0));
+ result.push({
+ esGrupo: true,
+ expandido: false,
+ fechaRegistro: recetasGrupo[0].fechaRegistro,
+ organizacion: recetasGrupo[0].organizacion,
+ profesional: recetasGrupo[0].profesional,
+ diagnostico: recetasGrupo[0].diagnostico,
+ recetas: recetasGrupo
+ });
+ } else {
+ result.push(...recetasGrupo);
+ }
+ });
+
+ result.sort((a, b) => new Date(b.fechaRegistro).getTime() - new Date(a.fechaRegistro).getTime());
+ this.historialRecetas = result;
}
combinarDispensas() {
const organizacionNombre = this.recetaPrincipal.organizacion?.nombre;
let anteriorDispensada = false;
- this.listadoDispensas = this.recetaPrincipal.estadosDispensa
+ this.listadoDispensas = (this.recetaPrincipal.estadosDispensa || [])
.map(rec => {
let esDuplicada = false;
if (anteriorDispensada && rec.tipo === 'dispensada') {
esDuplicada = true;
}
anteriorDispensada = rec.tipo === 'dispensada';
+
+ let detalleMedicamento = '';
+ let organizacionDispensa = organizacionNombre;
+
+ if (this.recetaPrincipal.dispensa && this.recetaPrincipal.dispensa.length) {
+ const dispCoincidente = this.recetaPrincipal.dispensa.find(d => {
+ if (rec.idDispensaApp && d.idDispensaApp) {
+ return d.idDispensaApp === rec.idDispensaApp;
+ }
+ return moment(d.fecha).isSame(moment(rec.fecha), 'day');
+ }) || (rec.tipo === 'dispensada' ? this.recetaPrincipal.dispensa[0] : null);
+
+ if (dispCoincidente) {
+ if (dispCoincidente.organizacion?.nombre) {
+ organizacionDispensa = dispCoincidente.organizacion.nombre;
+ }
+
+ // 1. Medicamentos
+ if (dispCoincidente.medicamentos?.length) {
+ detalleMedicamento = dispCoincidente.medicamentos.map(m => {
+ const nombre = m.medicamento?.nombre || m.descripcion || m.medicamento?.concepto?.term || '';
+ const cant = m.cantidadEnvases ?? m.cantidad ?? m.unidades;
+ const pres = m.presentacion ? ` ${m.presentacion}` : '';
+ const cantStr = cant !== null && cant !== undefined ? ` - ${cant}${pres}` : (pres ? ` - ${pres}` : '');
+ return `${nombre}${cantStr}`.trim();
+ }).filter(Boolean).join(', ');
+ }
+
+ // 2. Insumos / Nutricion / Alimentacion
+ if (!detalleMedicamento && dispCoincidente.insumos?.length) {
+ detalleMedicamento = dispCoincidente.insumos.map(i => {
+ const nombre = i.insumo?.nombre || i.descripcion || '';
+ const cant = i.cantidadEnvases ?? i.cantidad ?? i.unidades;
+ const pres = i.presentacion ? ` ${i.presentacion}` : '';
+ const cantStr = cant !== null && cant !== undefined ? ` - ${cant}${pres}` : (pres ? ` - ${pres}` : '');
+ return `${nombre}${cantStr}`.trim();
+ }).filter(Boolean).join(', ');
+ }
+
+ // 3. Magistral o descripción general
+ if (!detalleMedicamento) {
+ if (typeof dispCoincidente.magistral === 'string') {
+ detalleMedicamento = dispCoincidente.magistral;
+ } else if (dispCoincidente.magistral?.nombre || dispCoincidente.magistral?.descripcion) {
+ detalleMedicamento = dispCoincidente.magistral?.nombre || dispCoincidente.magistral?.descripcion;
+ } else if (dispCoincidente.descripcion) {
+ detalleMedicamento = dispCoincidente.descripcion;
+ }
+ }
+ }
+ }
+
+ // Fallbacks if not present in dispensa items
+ if (!detalleMedicamento && rec.tipo === 'dispensada') {
+ if (this.recetaPrincipal.medicamento?.esMagistral || this.recetaPrincipal.medicamento?.tipoReceta === 'magistral') {
+ detalleMedicamento = this.recetaPrincipal.medicamento?.concepto?.term || this.recetaPrincipal.medicamento?.nombre || 'Preparado Magistral';
+ } else if (this.recetaPrincipal.insumo) {
+ const cant = this.recetaPrincipal.insumo.cantidad;
+ const cantStr = cant ? ` - ${cant} unidad(es)` : '';
+ detalleMedicamento = `${this.recetaPrincipal.insumo.nombre || ''}${cantStr}`.trim();
+ } else if (this.recetaPrincipal.medicamento) {
+ const cant = this.recetaPrincipal.medicamento.cantEnvases ?? this.recetaPrincipal.medicamento.cantidad;
+ const cantStr = cant ? ` - ${cant}` : '';
+ detalleMedicamento = `${this.recetaPrincipal.medicamento.concepto?.term || this.recetaPrincipal.medicamento.nombre || ''}${cantStr}`.trim();
+ }
+ }
+
return {
fecha: rec.fecha,
tipo: rec.tipo,
- organizacion: organizacionNombre || 'Sin especificar',
+ organizacion: organizacionDispensa || 'Sin especificar',
sistema: rec.sistema || 'Sin especificar',
dispensaDuplicada: esDuplicada,
- cancelada: rec.cancelada ?? false
+ cancelada: rec.cancelada ?? false,
+ detalleMedicamento: detalleMedicamento || '-'
};
});
@@ -144,14 +275,26 @@ export class VistaRecetaComponent implements OnInit {
return this.listadoDispensas.shift();
}
+ get esInsumo(): boolean {
+ return !!(this.recetaPrincipal?.insumo || this.recetaPrincipal?.esInsumo || this.recetaPrincipal?.medicamento?.tipoReceta === 'insumo');
+ }
+
+ get labelColumnaDispensa(): string {
+ return this.esInsumo ? 'INSUMO DISPENSADO' : 'MEDICAMENTO DISPENSADO';
+ }
+
+ get tituloSeccionHistorial(): string {
+ return this.esInsumo ? 'Registro de insumos' : 'Registro del medicamento';
+ }
+
checkDispensaAnticipada(receta) {
- if (receta.estadoDispensaActual && receta.estadoDispensaActual.fecha) {
+ if (receta?.estadoDispensaActual?.tipo && receta.estadoDispensaActual.tipo !== 'sin-dispensa' && receta.estadoDispensaActual.fecha) {
const fechaDispensa = moment(receta.estadoDispensaActual.fecha);
const fechaRegistro = moment(receta.fechaRegistro);
if (fechaDispensa.isBefore(fechaRegistro)) {
- if (receta.estadoActual.tipo === 'finalizada') {
+ if (receta.estadoActual?.tipo === 'finalizada') {
return 'dispensa anticipada';
- } else if (receta.estadoActual.tipo === 'pendiente') {
+ } else if (receta.estadoActual?.tipo === 'pendiente') {
return 'dispensa parcial anticipada';
}
}
|