Skip to content

Commit

Permalink
feat(IN-430): Permitir anular prestaciones de internacion
Browse files Browse the repository at this point in the history
  • Loading branch information
MarianoCampetella authored and martinebucarey committed Jul 5, 2022
1 parent b6e0a41 commit 7a3a56e
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ export class RegistrosHudsDetalleComponent implements OnInit {
public hasta: Date;
public tipoPrestacion;
public inProgress = true;
public prestacionesEliminadas = [];

public desde$ = new BehaviorSubject(new Date());
public hasta$ = new BehaviorSubject(new Date());
public tipoPrestacion$ = new BehaviorSubject(null);
public id$ = new BehaviorSubject(null);

public cama$ = this.mapaCamasService.selectedCama;
public estadoCama$: Observable<IMAQEstado>;
Expand Down Expand Up @@ -96,7 +98,6 @@ export class RegistrosHudsDetalleComponent implements OnInit {
})
);


this.max$ = this.mapaCamasService.historialInternacion$.pipe(
map(movimientos => {
const egreso = movimientos.find(m => m.extras && m.extras.egreso);
Expand All @@ -115,8 +116,12 @@ export class RegistrosHudsDetalleComponent implements OnInit {
this.hasta$,
this.tipoPrestacion$,
this.min$,
this.id$
).pipe(
map(([prestaciones, desde, hasta, tipoPrestacion, min]) => {
map(([prestaciones, desde, hasta, tipoPrestacion, min, idPrestacion]) => {
if (idPrestacion) {
this.prestacionesEliminadas.push(idPrestacion);
}
if (!desde) {
desde = moment().subtract(7, 'd').toDate();
}
Expand All @@ -128,7 +133,7 @@ export class RegistrosHudsDetalleComponent implements OnInit {
if (tipoPrestacion) {
return fecha.isSameOrBefore(hasta, 'd') && fecha.isSameOrAfter(desde, 'd') && tipoPrestacion.conceptId === prestacion.solicitud.tipoPrestacion.conceptId;
}
return fecha.isSameOrBefore(hasta, 'd') && fecha.isSameOrAfter(desde, 'd');
return fecha.isSameOrBefore(hasta, 'd') && fecha.isSameOrAfter(desde, 'd') && !this.prestacionesEliminadas.some(id => id === prestacion.id);
});
})
);
Expand Down Expand Up @@ -206,6 +211,10 @@ export class RegistrosHudsDetalleComponent implements OnInit {
this.ejecutar(prestacion);
});
break;
case 'anular-validacion':
this.prestacionService.invalidarPrestacion(prestacion).subscribe();
this.id$.next(prestacion.id);
break;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,22 @@
{{ prestacion.solicitud.profesional | nombre }}
</small>
</td>
<td justify="end">
<plex-button size="sm" icon="eye" type="info" (click)="emit('ver', $event)" tooltip="Ver" titlePosition="left"
*ngIf="!esEjecucion"></plex-button>
<td>
<div class="d-flex flex-rows align-items-center">
<plex-button size="sm" icon="eye" type="info" (click)="emit('ver', $event)" tooltip="Ver" titlePosition="left"
*ngIf="!esEjecucion"></plex-button>

<plex-dropdown *ngIf="!esEjecucion && esMiPrestacion" right="true" size="sm" icon="dots-vertical" [items]="items">
</plex-dropdown>
<plex-dropdown *ngIf="!esEjecucion && esMiPrestacion" right="true" size="sm" icon="dots-vertical"
[items]="items">
</plex-dropdown>
</div>

<plex-button size="sm" label="Continuar" (click)="emit('continuar', $event)" type="success"
tooltip="Continua registro" titlePosition="left" *ngIf="esEjecucion">
</plex-button>
<div>
<plex-button size="sm" label="Continuar" (click)="emit('continuar', $event)" type="success"
tooltip="Continua registro" titlePosition="left" *ngIf="esEjecucion">
</plex-button>
<plex-button size="sm" label="Anular" (click)="invalidarPrestacion('anular-validacion', $event)" type="danger"
tooltip="Anular registro" titlePosition="left" *ngIf="esEjecucion">
</plex-button>
</div>
</td>
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { Component, Input, Output, EventEmitter, HostBinding, HostListener } fro
import { IPrestacion } from '../../../../../../modules/rup/interfaces/prestacion.interface';
import { Auth } from '@andes/auth';
import { MapaCamasService } from '../../../services/mapa-camas.service';
import { Plex } from '@andes/plex';

export type RegistroHUDSItemAccion = 'ver' | 'continuar' | 'romper-validacion';
export type RegistroHUDSItemAccion = 'ver' | 'continuar' | 'romper-validacion' | 'anular-validacion';


@Component({
Expand Down Expand Up @@ -36,6 +37,7 @@ export class RegistroHUDSItemComponent {
}

constructor(
private plex: Plex,
private auth: Auth,
private mapaCamasService: MapaCamasService,
) { }
Expand All @@ -61,4 +63,15 @@ export class RegistroHUDSItemComponent {
this.accion.emit(accion);
}

invalidarPrestacion(accion: RegistroHUDSItemAccion, $event?: Event) {
if ($event) {
$event.stopPropagation();
}
this.plex.confirm('¿Está seguro que desea invalidar este registro?').then(confirmacion => {
if (confirmacion) {
this.accion.emit(accion);
}
});
}

}

0 comments on commit 7a3a56e

Please sign in to comment.