Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
a6532bc
feat(IN-658): Sacar formulario estadístico de coleccion- prestaciones
nicolasarana Oct 28, 2025
92f0c27
feat(IN):"Nuevos metodos para squema InformeEstadistica"
nicolasarana Oct 29, 2025
f7edab5
feat(IN):"Varios cambios en la app para la llamada de la api InformeE…
nicolasarana Oct 30, 2025
d144a34
feat(IN-665)="Modificar listado de internacion en base al nuevo squem…
nicolasarana Nov 3, 2025
b11a07b
feat(IN-663):"Modificar egreso estadistico en base al nuevo esquema u…
nicolasarana Nov 6, 2025
a2ff71f
feat(IN-666):"Corregir test de capa estadística"
nicolasarana Nov 11, 2025
ef29cb6
feat(IN-667)Modificar censos diario y mensual"
nicolasarana Nov 13, 2025
5859d13
IN(671)"Cambiar visualización de huds de la internación estadística y…
nicolasarana Nov 27, 2025
1b635c3
feat(IN-671):"Nueva vista en huds basados en el nuevos esquema y api"
nicolasarana Dec 8, 2025
9ecf3eb
feat(IN-671)"Versión mejorada usando la vista de huds"
nicolasarana Dec 12, 2025
dec2fa1
fix(egreso): corregir error de sintaxis
nicolasarana Dec 15, 2025
cdb1bee
feat(IN-671):"Arma en api la descarga en PDF de una internación estad…
nicolasarana Dec 16, 2025
430192c
fix(IN-675):"Se comenta donde se hicieron las modificaciones para los…
nicolasarana Dec 19, 2025
c6804b8
fix(IN):"Arreglos en la carga inicial de la Obra social"
nicolasarana Dec 19, 2025
c623a79
styles - se borran console log
nicolasarana May 13, 2026
0697d54
fix (IN-683): "Correccion error con periodos censables y datos de inter"
nicolasarana May 13, 2026
9dbca43
(IN-683): "Corrección al deshacer internación/cambio de cama/UO "
nicolasarana May 14, 2026
1268057
fix -(25) Corrección de código sug por Campe (25-09-26)
nicolasarana Sep 25, 2026
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/apps/rup/mapa-camas/mapa-camas.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ import { PeriodosCensablesComponent } from './sidebar/periodos-censables/periodo
import { ListadoMedicamentosCapasComponent } from './views/listado-internacion-capas/listado-medicamentos-capas.component';
import { CITASLibModule } from '../../../components/turnos/citas.module';
import { MapaCamasResumenComponent } from './views/mapa-camas-capa/mapa-camas-resumen.component';
import { InformeEstadisticaService } from 'src/app/modules/rup/services/informe-estadistica.service';

export const INTERNACION_COMPONENTS = [
MapaCamasMainComponent,
Expand Down Expand Up @@ -130,7 +131,8 @@ export const INTERNACION_PROVIDERS = [
IntegridadService,
PermisosMapaCamasService,
PlanIndicacionesEventosServices,
IngresoPacienteService
IngresoPacienteService,
InformeEstadisticaService
];

@NgModule({
Expand Down
6 changes: 4 additions & 2 deletions src/app/apps/rup/mapa-camas/services/mapa-camas.http.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable no-console */
import { Injectable } from '@angular/core';
import { Server } from '@andes/shared';
import { Observable } from 'rxjs';
import { Observable, tap } from 'rxjs';
import { ISnapshot } from '../interfaces/ISnapshot';
import { ICama } from '../interfaces/ICama';

Expand Down Expand Up @@ -118,6 +119,7 @@ export class MapaCamasHTTP {
}

censoDiario(fecha: Date, unidadOrganizativa: string): Observable<any[]> {

return this.server.get(`${this.url}/censo-diario`, {
params: { fecha, unidadOrganizativa },
showError: true
Expand All @@ -136,6 +138,6 @@ export class MapaCamasHTTP {
}

getPrestacionesInternacion(params: any): Observable<any[]> {
return this.server.get(`${this.url}/prestaciones`, { params: params, showError: true });
return this.server.get(`${this.url}/informe-estadistica`, { params: params, showError: true });
}
}
124 changes: 114 additions & 10 deletions src/app/apps/rup/mapa-camas/services/mapa-camas.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Auth } from '@andes/auth';
import { cache, notNull } from '@andes/shared';
import { Injectable } from '@angular/core';
import { BehaviorSubject, combineLatest, Observable, of, timer } from 'rxjs';
import { catchError, map, multicast, pluck, startWith, switchMap } from 'rxjs/operators';
import { catchError, map, multicast, pluck, startWith, switchMap, tap } from 'rxjs/operators';
import { IPaciente } from '../../../../core/mpi/interfaces/IPaciente';
import { PacienteService } from '../../../../core/mpi/services/paciente.service';
import { ISectores } from '../../../../interfaces/IOrganizacion';
Expand All @@ -18,6 +18,8 @@ import { MapaCamasHTTP } from './mapa-camas.http';
import { MaquinaEstadosHTTP } from './maquina-estados.http';
import { InternacionResumenHTTP, IResumenInternacion } from './resumen-internacion.http';
import { PermisosMapaCamasService } from '../services/permisos-mapa-camas.service';
import { InformeEstadisticaService } from 'src/app/modules/rup/services/informe-estadistica.service';
import { IInformeEstadistica } from 'src/app/modules/rup/interfaces/informe-estadistica.interface';
@Injectable()
export class MapaCamasService {
public timer$;
Expand Down Expand Up @@ -45,7 +47,11 @@ export class MapaCamasService {
public view = new BehaviorSubject<'mapa-camas' | 'listado-internacion' | 'mapa-recursos'>('mapa-camas');

public prestacion$: Observable<IPrestacion>;
public informeEstadistica$: Observable<IInformeEstadistica>;

public selectedPrestacion = new BehaviorSubject<IPrestacion>({ id: null } as any);
public selectedInformeEstadistica = new BehaviorSubject<IInformeEstadistica>({ id: null } as any);

public camaSelectedSegunView$: Observable<ISnapshot>;

public maquinaDeEstado$: Observable<IMaquinaEstados>;
Expand Down Expand Up @@ -80,6 +86,7 @@ export class MapaCamasService {
constructor(
private camasHTTP: MapaCamasHTTP,
private prestacionService: PrestacionesService,
private informeEstadisticaService: InformeEstadisticaService,
private pacienteService: PacienteService,
private maquinaEstadosHTTP: MaquinaEstadosHTTP,
private salaComunService: SalaComunService,
Expand Down Expand Up @@ -135,6 +142,11 @@ export class MapaCamasService {
snap.diaEstada = 0;
}
});
// 👉 Aquí detectamos los casos sin sectores
const sinSectores = snapshot.filter(s => !s.sectores || s.sectores.length === 0);
if (sinSectores.length > 0) {
console.warn('⚠️ Snapshots sin sectores:', sinSectores.map(s => s.id));
}
return snapshot.sort((a, b) => (a.unidadOrganizativa.term.localeCompare(b.unidadOrganizativa.term)) ||
(a.sectores[a.sectores.length - 1].nombre.localeCompare(b.sectores[b.sectores.length - 1].nombre + '')) ||
(a.nombre.localeCompare('' + b.nombre)));
Expand Down Expand Up @@ -188,7 +200,7 @@ export class MapaCamasService {
return of(null);
}
if (capa === 'estadistica') {
return this.prestacionService.getById(cama.idInternacion, { showError: false });
return of(null);
}
return this.internacionResumenHTTP.get(cama.idInternacion).pipe(
switchMap(internacionResumen => {
Expand All @@ -203,6 +215,7 @@ export class MapaCamasService {
cache()
);


this.resumenInternacion$ = combineLatest([
this.selectedCama,
this.ambito2,
Expand All @@ -223,6 +236,50 @@ export class MapaCamasService {
cache()
) as Observable<IResumenInternacion>;

this.informeEstadistica$ = combineLatest([
this.selectedInformeEstadistica,
this.selectedCama,
this.view,
this.capa2
]).pipe(
switchMap(([informe, cama, view, capa]) => {

if (view === 'listado-internacion') {
if (informe?.id) {
return of(informe);
}

const pacienteId = cama?.paciente?.id;
if (pacienteId) {
return this.informeEstadisticaService.get({ paciente: pacienteId }).pipe(
map(informes => informes?.[0] || null)
);
}

return of(null);
}

if (!cama?.idInternacion) {
return of(null);
}

if (capa === 'estadistica') {
const id = informe?.id || cama?.idInternacion;
if (!id) {
console.warn('⚠️ No hay ID válido para obtener el informe estadístico');
return of(null);
}
return this.informeEstadisticaService.getById(id, { showError: false });
}

return of(null);
}),
catchError(err => {
return of(null);
}),
cache()
);


this.camaSelectedSegunView$ = this.view.pipe(
switchMap(view => {
Expand All @@ -231,12 +288,12 @@ export class MapaCamasService {
}
// Para conseguir la cama de la internación desde el listado
return combineLatest([
this.selectedPrestacion,
this.selectedInformeEstadistica,
this.selectedResumen
]).pipe(
switchMap(([prestacion, resumen]) => {
const internacion = {
id: this.capa === 'estadistica' ? prestacion.id : (resumen.id || resumen._id),
id: this.capa === 'estadistica' ? (prestacion.id || resumen._id || resumen.id) : (resumen.id || resumen._id),
fecha: this.fecha
};
return this.camasHTTP.snapshot(this.ambito, this.capa, internacion.fecha, internacion.id).pipe(
Expand Down Expand Up @@ -379,6 +436,16 @@ export class MapaCamasService {
this.selectedPrestacion.next(prestacion);
}

selectInformeEstadistica(informe: IInformeEstadistica) {
if (!informe) {
return this.selectedInformeEstadistica.next({ id: null } as any);
}

this.selectedInformeEstadistica.next(informe);

}


selectResumen(resumen: IResumenInternacion) {
if (!resumen) {
return this.selectedResumen.next({ id: null } as any);
Expand Down Expand Up @@ -526,6 +593,38 @@ export class MapaCamasService {
return listaInternacionFiltrada;
}

filtrarInformesEstadistica(
listaInformes: IInformeEstadistica[],
documento?: string,
apellido?: string,
estado?: string
): IInformeEstadistica[] {
let listaFiltrada = listaInformes;

if (documento) {
const doc = documento.toLowerCase();
listaFiltrada = listaFiltrada.filter((informe: IInformeEstadistica) =>
informe.paciente?.documento?.toLowerCase().includes(doc) ||
informe.paciente?.numeroIdentificacion?.toLowerCase().includes(doc)
);
}

if (apellido) {
const ape = apellido.toLowerCase();
listaFiltrada = listaFiltrada.filter((informe: IInformeEstadistica) =>
informe.paciente?.apellido?.toLowerCase().includes(ape)
);
}

if (estado) {
listaFiltrada = listaFiltrada.filter((informe: IInformeEstadistica) =>
informe.estadoActual?.tipo === estado
);
}

return listaFiltrada;
}

snapshot(fecha, idInternacion = null, ambito: string = null, capa: string = null, estado: string = null): Observable<ISnapshot[]> {
ambito = ambito || this.ambito;
capa = capa || this.capa;
Expand All @@ -541,11 +640,11 @@ export class MapaCamasService {
this.ambito2,
this.capa2,
this.selectedCama,
this.selectedPrestacion,
this.selectedInformeEstadistica,
this.selectedResumen,
this.view
]).pipe(
switchMap(([ambito, capa, selectedCama, selectedPrestacion, selectedResumen, view]) => {
switchMap(([ambito, capa, selectedCama, selectedInformeEstadistica, selectedResumen, view]) => {
hasta = hasta || new Date();
if (type === 'cama') {
return this.camasHTTP.historial(ambito, capa, desde, hasta, { idCama: cama ? cama.idCama : selectedCama.idCama });
Expand All @@ -556,16 +655,21 @@ export class MapaCamasService {

} else if (view === 'listado-internacion') {
if (!desde) {
desde = selectedPrestacion ? selectedPrestacion.solicitud.fecha : selectedResumen.fechaIngreso;
desde = selectedInformeEstadistica ? selectedInformeEstadistica.informeIngreso.fechaIngreso : selectedResumen.fechaIngreso;

}
if (this.capa === 'estadistica' && selectedPrestacion.id) {
desde = [desde, selectedPrestacion.solicitud.fecha].sort((a, b) => moment(a).diff(moment(b)))[0];
return this.camasHTTP.historialInternacion(ambito, capa, desde, hasta, selectedPrestacion.id);
if ((this.capa === 'estadistica' || this.capa === 'estadistica-v2') && selectedInformeEstadistica.id) {
desde = [desde, selectedInformeEstadistica.informeIngreso.fechaIngreso].sort((a, b) => moment(a).diff(moment(b)))[0];

return this.camasHTTP.historialInternacion(ambito, capa, desde, hasta, selectedInformeEstadistica.id);
}
if (selectedResumen._id) {
desde = [desde, selectedResumen.fechaIngreso].sort((a, b) => moment(a).diff(moment(b)))[0];
return this.camasHTTP.historialInternacion(ambito, capa, desde, hasta, selectedResumen._id);
}
if (selectedCama.idInternacion) {
return this.camasHTTP.historialInternacion(ambito, capa, desde, hasta, selectedCama.idInternacion);
}
}
return of([]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import { PermisosMapaCamasService } from '../../services/permisos-mapa-camas.ser
import { InternacionResumenHTTP } from '../../services/resumen-internacion.http';
import { OrganizacionService } from 'src/app/services/organizacion.service';
import { Auth } from '@andes/auth';


import { IInformeEstadistica } from 'src/app/modules/rup/interfaces/informe-estadistica.interface';
import { InformeEstadisticaService } from 'src/app/modules/rup/services/informe-estadistica.service';
@Component({
selector: 'app-cama-detalle',
templateUrl: 'cama-detalle.component.html'
Expand Down Expand Up @@ -69,6 +69,7 @@ export class CamaDetalleComponent implements OnInit, AfterViewChecked, OnDestroy
public unicoMovimiento = false;
public subscripcion: Subscription;
public prestacion;
public InformeEstadistica;

items = [
{
Expand All @@ -93,6 +94,7 @@ export class CamaDetalleComponent implements OnInit, AfterViewChecked, OnDestroy
private mapaCamasService: MapaCamasService,
private mapaCamasHTTP: MapaCamasHTTP,
private prestacionesService: PrestacionesService,
public InformeEstadisticaService: InformeEstadisticaService,
public permisosMapaCamasService: PermisosMapaCamasService,
private turneroService: TurneroService,
private motivoAccesoService: ModalMotivoAccesoHudsService,
Expand All @@ -115,8 +117,7 @@ export class CamaDetalleComponent implements OnInit, AfterViewChecked, OnDestroy
this.relaciones$ = this.cama$.pipe(switchMap(cama => this.mapaCamasService.getRelacionesPosibles(cama)));
this.accionesEstado$ = this.mapaCamasService.prestacionesPermitidas(this.mapaCamasService.selectedCama);
this.organizacionV2$ = this.organizacionService.usaCapasUnificadas(this.auth.organizacion.id);
this.subscripcion = this.mapaCamasService.prestacion$.subscribe(p => this.prestacion = p);

this.subscripcion = this.mapaCamasService.informeEstadistica$.subscribe(p => this.InformeEstadistica = p);
this.paciente$ = this.cama$.pipe(
filter(cama => !!cama.paciente),
switchMap(cama => cama.paciente ? this.mapaCamasService.getPaciente(cama.paciente) : of(null))
Expand Down Expand Up @@ -225,7 +226,7 @@ export class CamaDetalleComponent implements OnInit, AfterViewChecked, OnDestroy

puedeDeshacer() {
const capaEstadistica = this.capa === 'estadistica';
const estadoInternacion = this.prestacion?.estadoActual.tipo || '';
const estadoInternacion = (capaEstadistica ? this.InformeEstadistica?.estadoActual?.tipo : this.prestacion?.estadoActual?.tipo) || '';
const esSala = this.cama?.sala;
return !esSala && !this.loadingDataEgreso && (!this.registraEgreso || capaEstadistica && estadoInternacion !== 'validada');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
<!-- ESTADISTICA -->
<ng-container *ngIf="capa === 'estadistica'">
<app-informe-ingreso (cancel)="activateOption('ingreso')">
<plex-button *ngIf="permisosMapaCamasService.ingreso" tooltip="Editar ingreso"
tooltipPosition="left" icon="pencil" type="warning" size="sm" (click)="toggleEdit()"
class="mr-1">
<plex-button *ngIf="permisosMapaCamasService.ingreso && estadoPrestacion !== 'validada'"
tooltip="Editar ingreso" tooltipPosition="left" icon="pencil" type="warning" size="sm"
(click)="toggleEdit()" class="mr-1">
</plex-button>
<ng-container *ngIf="anular$ | async">
<ng-container *ngIf="(anular$ | async) && estadoPrestacion !== 'validada'">
<plex-button size="sm" icon="account-off" type="danger" tooltip="Deshacer Internación"
tooltipPosition="left" (click)="onAnularInternacion()">
</plex-button>
Expand All @@ -43,16 +43,16 @@
<ng-container *ngIf="mostrar === 'movimientos'">
<app-movimientos-internacion>
<plex-button *ngIf="((view$ | async) === 'listado-internacion' && permisosMapaCamasService.movimientos) && capa !== 'medica'"
[disabled]="(mapaCamasService.prestacion$ | async)?.ejecucion?.registros[1]"
label="Cambiar cama" type="warning" size="sm" (click)="changeCama()">
[disabled]="existeEgreso || (registraEgreso$ | async)" label="Cambiar cama" type="warning"
size="sm" (click)="changeCama()">
</plex-button>
</app-movimientos-internacion>
</ng-container>

<ng-container *ngIf="mostrar === 'egreso'">
<!-- informe (Debe tener un egreso cargado) -->
<app-informe-egreso *ngIf="!editarEgreso && existeEgreso" (cancel)="activateOption('egreso')">
<plex-button *ngIf="puedeEditarEgreso()" tooltip="Editar egreso" tooltipPosition="left" icon="pencil"
<plex-button *ngIf="puedeEditarEgreso()" tooltip="fdsfsd" tooltipPosition="left" icon="pencil"
type="warning" size="sm" (click)="toggleEdit()">
</plex-button>
</app-informe-egreso>
Expand Down
Loading
Loading