Skip to content
Open
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: 3 additions & 1 deletion src/app/modules/rup/components/core/rup.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { ElementosRUPService } from './../../services/elementosRUP.service';
import { PrestacionesService } from './../../services/prestaciones.service';
import { RecetaService } from '../../../../services/receta.service';
import { ECLQueriesService } from './../../../../services/eclqueries.service';
import { InternacionResumenHTTP } from '../../../../apps/rup/mapa-camas/services/resumen-internacion.http';

@Component({
selector: 'rup',
Expand Down Expand Up @@ -160,7 +161,8 @@ export class RUPComponent implements OnInit, AfterViewInit, OnDestroy, OnChanges
public constantesService: ConstantesService,
public recetasService: RecetaService,
@Optional() public ejecucionService: RupEjecucionService,
public eclqueriesServicies: ECLQueriesService
public eclqueriesServicies: ECLQueriesService,
public internacionResumenHTTP: InternacionResumenHTTP
) {
}

Expand Down
74 changes: 74 additions & 0 deletions src/app/modules/rup/components/ejecucion/historial.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { Component, OnInit } from '@angular/core';
import { PrestacionesService } from './../../services/prestaciones.service';
import { of, BehaviorSubject, Observable } from 'rxjs';
import { switchMap, map } from 'rxjs/operators';
import { get } from 'lodash';

@Component({
selector: 'rup-historial',
templateUrl: 'historial.html'
})
export class HistorialComponent implements OnInit {
private pacienteId$ = new BehaviorSubject<string>(null);
public historial$: Observable<any[]>;
public filteredHistorial: any[] = [];
public showFullHistory = false;
public isLoading = false;

// parámetros opcionales
public params: any = {
fechaDesde: null,
cantidad: null,
ecl: null
};

// estos vienen de RUP cuando se use en una prestación
public registro: any;
public prestacion: any;

constructor(
private prestacionesService: PrestacionesService
) { }

ngOnInit() {
const pacienteId = get(this.prestacion, 'paciente.id');
this.pacienteId$.next(pacienteId);

this.isLoading = true;
this.historial$ = this.pacienteId$.pipe(
switchMap(id => id ? this.prestacionesService.getConceptosByPaciente(id) : of([])),
map(registros => {
const registrosConcepto = registros.filter(r => r.concepto.conceptId === this.registro.concepto.conceptId);

// aplicar filtros
let filtered = registrosConcepto;
if (this.params.fechaDesde) {
const fechaDesde = new Date(this.params.fechaDesde);
filtered = filtered.filter(r => new Date(r.createdAt) >= fechaDesde);
}
if (this.params.ecl) {
// Placeholder: acá deberías resolver el ECL contra SNOMED si corresponde
}

// ordenar por fecha desc
const sorted = filtered.sort((a, b) =>
new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()
);

this.filteredHistorial = sorted;
this.isLoading = false;

// limitar por cantidad si está seteado
if (this.params.cantidad) {
return sorted.slice(0, this.params.cantidad);
}

return sorted;
})
);
}

toggleFullHistory() {
this.showFullHistory = !this.showFullHistory;
}
}
35 changes: 35 additions & 0 deletions src/app/modules/rup/components/ejecucion/historial.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<div class="historial-container">
<!-- Loader -->
<div *ngIf="isLoading" class="d-flex justify-content-center">
<div class="spinner-border text-primary" role="status">
<span class="sr-only">Cargando historial...</span>
</div>
</div>

<!-- Historial encontrado -->
<ng-container *ngIf="!isLoading && filteredHistorial.length > 0">
<p class="historial-title">Historial de Evoluciones</p>
<div class="historial-list">
<div *ngFor="let record of (showFullHistory ? filteredHistorial : (historial$ | async))" class="historial-item">
<div class="historial-date">
<span>{{ record.createdAt | date:'dd/MM/yyyy' }}</span>
</div>
<div class="historial-value" [innerHTML]="record.valor"></div>
</div>
</div>

<!-- Botón mostrar/ocultar -->
<div class="text-center mt-3" *ngIf="filteredHistorial.length > (params.cantidad || 0)">
<plex-button [label]="showFullHistory ? 'Ocultar historial' : 'Mostrar historial completo'"
(click)="toggleFullHistory()"
type="info"
size="sm">
</plex-button>
</div>
</ng-container>

<!-- Sin resultados -->
<ng-container *ngIf="!isLoading && filteredHistorial.length === 0">
<p class="text-muted text-center">No se encontraron evoluciones previas.</p>
</ng-container>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export class PrestacionEjecucionComponent implements OnInit, OnDestroy {
public alerta = 'Este registro no puede modificarse, si necesita cambiar una medicación prescripta puede suspender desde la HUDS y registrar una nueva.';

private soloValores = ['33633005'];
conceptoSeleccionadoId: string;

constructor(
public servicioPrestacion: PrestacionesService,
Expand Down Expand Up @@ -246,6 +247,7 @@ export class PrestacionEjecucionComponent implements OnInit, OnDestroy {
} else if (registoExiste.id && registoExiste.valor) {
// Expandir sólo si no tienen algún valor
this.itemsRegistros[registoExiste.id].collapse = false;

}
}
}
Expand Down Expand Up @@ -753,11 +755,10 @@ export class PrestacionEjecucionComponent implements OnInit, OnDestroy {
});
}

cambiaValorCollapse(indice) {
cambiaValorCollapse(indice: string) {
if (this.itemsRegistros[indice]) {
this.itemsRegistros[indice].collapse = !this.itemsRegistros[indice].collapse;
}
// this.registrosColapsados();
}

toggleCollapse() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,14 @@
</div>
</ng-container>
</div>

</div>
<div class="actions"
*ngIf="!confirmarDesvincular[registro.id] && (!confirmarEliminar || (confirmarEliminar && indexEliminar != i) )">

<ng-container *ngIf="registro?.privacy?.scope !== 'public'">
<plex-badge type="info">Registro Privado</plex-badge>
</ng-container>

<ng-container
*ngIf="prestacion?.ejecucion?.registros !== null && prestacion?.ejecucion?.registros?.length > 1">
<plex-dropdown type="primary" class="dropdown-inline" [right]="true"
Expand Down Expand Up @@ -141,11 +141,11 @@

<plex-button *ngIf="!existe(registro.concepto);" size="sm" type="danger"
icon="delete"
(click)="confirmarEliminarRegistro(registro, 'card')" [disabled]="!puedeEliminar(registro)">
(click)="confirmarEliminarRegistro(registro, 'card')"
[disabled]="!puedeEliminar(registro)">
</plex-button>
</div>
</div>

<div class="rup-body" (click)="recuperaLosMasFrecuentes(registro.concepto)"
[hidden]="itemsRegistros[registro.id]?.collapse || confirmarEliminar || confirmarDesvincular[registro.id]">
<!-- ... Header -->
Expand All @@ -159,7 +159,6 @@
registro.concepto.semanticTag}}
</span>
</div>

<!-- ... Body -->
<div class="content"
*ngIf="paciente || (prestacion.solicitud.tipoPrestacion.noNominalizada)">
Expand All @@ -172,6 +171,7 @@
[conceptosAsociados]="conceptosAsociados" [alerta]="alerta">
</rup>
</div>

</div>

<!-- Footer del registro -->
Expand Down Expand Up @@ -216,8 +216,6 @@
</div>
</div>
</div>


</ng-container>

<!-- Drop area -->
Expand All @@ -229,6 +227,7 @@
Mover a esta posición
</div>
</div>

</plex-tab>

<plex-tab label="Resumen del Paciente" *ngIf="paciente && tieneAccesoHUDS">
Expand Down Expand Up @@ -265,7 +264,7 @@
<plex-tab [allowClose]="true" [label]="registro.data.concepto.term"
[class]="registro.data.class" [color]="registro.data.class"
*ngIf="registro.tipo === 'concepto'">
<detalle-registro *ngIf="registro.data.class === 'situación' ||
<detalle-registro *="registro.data.class === 'situación' ||
registro.data.class === 'hallazgo' || registro.data.class === 'trastorno'"
[registro]="registro.data" [paciente]="paciente">
</detalle-registro>
Expand Down Expand Up @@ -308,9 +307,9 @@
</plex-tab>

<plex-tab *ngIf="registro.tipo === 'laboratorio'" [allowClose]="true"
label="Informe de Laboratorio">
<vista-laboratorio [protocolo]="registro"></vista-laboratorio>
</plex-tab>
label="Informe de Laboratorio">
<vista-laboratorio [protocolo]="registro"></vista-laboratorio>
</plex-tab>

<plex-tab *ngIf="registro.tipo === 'receta'" color="receta" class="tab-receta"
[allowClose]="true" [label]="recetaService.getLabel(registro.data.recetas)">
Expand Down
65 changes: 65 additions & 0 deletions src/app/modules/rup/components/elementos/historial.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { Component, OnInit, Input } from '@angular/core';
import { map, switchMap } from 'rxjs/operators';
import { RUPComponent } from '../core/rup.component';
import { RupElement } from '.';
import { of } from 'rxjs';
import { PlexTextToolBar } from '@andes/plex';


@Component({
selector: 'rup-historial',
styleUrls: ['./historial.scss'],
templateUrl: './historial.html'
})
@RupElement('HistorialComponent')
export class HistorialComponent extends RUPComponent implements OnInit {

// Se usa por un bug en el quill-editor al ser cargado dinamicamente.
afterInit = false;
fullscreen = false;

public qlToolbar: PlexTextToolBar[] = [{
name: 'fullscreen',
handler: () => {
this.fullscreen = true;
}
}];

public historial: any[] = [];
public isLoading = false;
public verHistorial = false;
public fechaDesde = null;

decodeHtml(html: string) {
const txt = document.createElement('textarea');
txt.innerHTML = html;
return txt.value;
}
ngOnInit() {

const conceptId = this.registro?.concepto?.conceptId;

this.isLoading = true;

if (!this.soloValores) {
if (this.params.pacienteInternado && this.params.requiereFechaInicio) {

this.internacionResumenHTTP.search({ paciente: this.paciente.id }).subscribe(resumen => {

if (resumen.length && resumen[resumen.length - 1].fechaIngreso) {
this.fechaDesde = new Date(resumen[resumen.length - 1].fechaIngreso);
this.prestacionesService.getRegistrosHuds(this.paciente.id, conceptId, this.fechaDesde).subscribe(prestaciones => {
this.isLoading = false;
// Ver si tomamos el ultimo valor..
if (prestaciones.length) {
this.historial = prestaciones;
}

});
}
});
}
}
}

}
37 changes: 37 additions & 0 deletions src/app/modules/rup/components/elementos/historial.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<form #form="ngForm">
<div class="row flex-column">
<div class="col-12">
<ng-container *ngIf="!soloValores">
<plex-text [label]="params?.titulo" [html]="true" [(ngModel)]="registro.valor" name="observaciones"
[required]="params?.required" [qlToolbar]="qlToolbar"> </plex-text>
</ng-container>

<p *ngIf="soloValores" class="readonly">
<span [innerHTML]="registro.valor"></span>
</p>
</div>
</div>
</form>
<div *ngIf="!soloValores" class="boton-historial">
<plex-button (click)="verHistorial = !verHistorial"
size="sm" type="primary" class="collapse-card"
label="{{ !verHistorial ? 'Ver historial' : 'Ocultar historial' }}">
</plex-button>
</div>
<section *ngIf="!isLoading && verHistorial && historial.length > 0"
class="mx-4 d-flex flex-column justify-content-between h-100">
<div *ngFor="let item of historial" class="historial-item">
<div class="historial-fecha">
{{ item.fecha | date:'dd/MM/yyyy hh:mm a' }}
</div>

<div class="historial-texto" [innerHTML]="decodeHtml(item.registro.valor)">
</div>
</div>


</section>
<div *ngIf="isLoading && verHistorial">Cargando historial...</div>
<div *ngIf="!isLoading && verHistorial && historial.length === 0">
<em>No hay evoluciones previas registradas</em>
</div>
35 changes: 35 additions & 0 deletions src/app/modules/rup/components/elementos/historial.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.historial-item {
display: flex;
align-items: center;
gap: 10px;
padding: 8px 12px;
margin: 4px 0;
}

.historial-fecha {
border: 2px solid #000;
border-radius: 20px;
padding: 6px 12px;
font-weight: bold;
min-width: 130px;
text-align: center;
background-color: #fff;
flex-shrink: 0;
line-height: 1.2;
}

.historial-texto {
flex-grow: 1;
font-family: Arial, sans-serif;
font-weight: normal;
color: #444;
word-wrap: break-word;
margin-left: 5px;
}


.boton-historial {
text-align: center;
margin-top: 20px;
margin-bottom: 15px;
}
Loading