Skip to content

Commit

Permalink
feat(IN): motivo suspension indicacion
Browse files Browse the repository at this point in the history
  • Loading branch information
plammel committed Jun 13, 2022
1 parent f3cf6f9 commit 2c81e2e
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
<plex-label size="md" case="capitalize" titulo="hora" subtitulo="{{ estado.fecha | hora }}"></plex-label>
<plex-label size="md" case="capitalize" titulo="equipo de salud" subtitulo="{{ estado.createdBy | nombre }}">
</plex-label>
<plex-label *ngIf="estado.motivo" size="md" case="capitalize" titulo="motivo" subtitulo="{{ estado.motivo }}">
</plex-label>
<plex-badge [color]="estado.tipo | indicacionColor">
{{ estado.tipo | indicacionLabel }}
</plex-badge>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export class PlanIndicacionesBotoneraComponent implements OnChanges {
@Input() indicacion;

@Output() refresh = new EventEmitter<any>();
@Output() cancelIndicacion = new EventEmitter<any>();

public items = [];

Expand Down Expand Up @@ -57,7 +58,9 @@ export class PlanIndicacionesBotoneraComponent implements OnChanges {
}

cambiarEstado(estado: string) {
if (estado === 'deleted') {
if (estado === 'cancelled') {
this.cancelIndicacion.emit(this.indicacion);
} else if (estado === 'deleted') {
this.planIndicacionesServices.delete(this.indicacion.id).subscribe(() => {
this.refresh.emit();
this.plex.toast('success', 'La indicación ha sido borrada');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<form #formMotivoSuspension="ngForm">
<plex-title titulo="Suspender indicación" size="md">
<plex-button label="CANCELAR" type="danger" (click)="cancelarSuspension()"></plex-button>
<plex-button [disabled]="!motivo" label="GUARDAR" type="success" (click)="guardarSuspension()">
</plex-button>
</plex-title>
<plex-text label="Ingrese motivo de suspensión" [(ngModel)]="motivo" name="motivo" grow="full" [required]="true"
multiline="true">
</plex-text>
</form>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Component, Input, Output, EventEmitter } from '@angular/core';

@Component({
selector: 'suspension-indicacion',
templateUrl: 'motivo-suspension.component.html'
})

export class SuspensionIndicacionComponent {

motivo;
@Output() cancelar = new EventEmitter<boolean>();
@Output() guardar = new EventEmitter<any>();

guardarSuspension() {
this.guardar.emit(this.motivo);
}

cancelarSuspension() {
this.cancelar.emit(false);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<plex-layout [main]="indicacionView || indicacionEventoSelected || nuevaIndicacion ? 8 : 12">
<plex-layout [main]="indicacionView || indicacionEventoSelected || nuevaIndicacion || suspenderIndicacion ? 8 : 12">
<plex-layout-main>
<plex-title titulo="Plan de indicaciones" main>
<plex-datetime [(ngModel)]="fecha" skipBy="day" type="date" (change)="onDateChange()" [max]="hoy">
Expand Down Expand Up @@ -147,7 +147,7 @@ <h3>

<div *ngIf="!indicacionEventoSelected && !nuevaIndicacion && !indicacion.readonly"
in-plan-indicacion-botonera [indicacion]="indicacion"
(refresh)="actualizar()">
(refresh)="actualizar()" (cancelIndicacion)="cancelIndicacion($event)">
</div>
</div>
</td>
Expand Down Expand Up @@ -188,5 +188,8 @@ <h3>
(events)="onEventos($event)">
</in-plan-indicacion-evento>
</ng-container>
<ng-container *ngIf="suspenderIndicacion && !indicacionView && !indicacionEventoSelected">
<suspension-indicacion (guardar)="guardarSuspension($event)" (cancelar)="cancelarSuspension()"></suspension-indicacion>
</ng-container>
</plex-layout-sidebar>
</plex-layout>
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export class PlanIndicacionesComponent implements OnInit {

private seccion = true;

public suspenderIndicacion: Boolean;
public showSecciones = {

};
Expand Down Expand Up @@ -216,6 +217,7 @@ export class PlanIndicacionesComponent implements OnInit {
}

onSelectedChange() {
this.suspenderIndicacion = false;
this.selectedBuffer.next(this.selectedIndicacion);
}

Expand All @@ -234,7 +236,7 @@ export class PlanIndicacionesComponent implements OnInit {
this.onSelectedChange();
}

cambiarEstado(estado: string) {
cambiarEstado(estado: string, motivo?: string) {
const indicaciones = Object.keys(this.selectedIndicacion).filter(k => this.selectedIndicacion[k]).map(k => this.indicaciones.find(i => i.id === k));
if (estado === 'deleted') {
const datos = indicaciones.map(ind => this.planIndicacionesServices.delete(ind.id));
Expand All @@ -247,6 +249,7 @@ export class PlanIndicacionesComponent implements OnInit {
} else {
const estadoParams = {
tipo: estado,
motivo,
fecha: new Date()
};
const datos = indicaciones.map(ind => this.planIndicacionesServices.updateEstado(ind.id, estadoParams));
Expand All @@ -267,8 +270,15 @@ export class PlanIndicacionesComponent implements OnInit {
this.cambiarEstado('on-hold');
}

cancelIndicacion(event) {
this.selectedIndicacion = { [event.id]: event };
this.selectedBuffer.next(this.selectedIndicacion);
this.onDetenerClick();
}

onDetenerClick() {
this.cambiarEstado('cancelled');
this.indicacionView = false;
this.suspenderIndicacion = true;
}

onContinuarClick() {
Expand All @@ -290,7 +300,6 @@ export class PlanIndicacionesComponent implements OnInit {
}
}


onIndicacionesCellClick(indicacion, hora) {
if (indicacion.estado.tipo !== 'draft') {
this.indicacionEventoSelected = indicacion;
Expand All @@ -307,7 +316,6 @@ export class PlanIndicacionesComponent implements OnInit {
}
}


onNuevaIndicacion(seccion) {
this.indicacionEventoSelected = null;
this.indicacionView = null;
Expand Down Expand Up @@ -341,6 +349,15 @@ export class PlanIndicacionesComponent implements OnInit {
}
}

guardarSuspension(event) {
this.suspenderIndicacion = false;
this.cambiarEstado('cancelled', event);
}

cancelarSuspension() {
this.suspenderIndicacion = false;
}

crearPrestacion(paciente, concepto, fecha: Date) {
const nuevaPrestacion = this.prestacionService.inicializarPrestacion(
paciente, concepto, 'ejecucion', this.ambito, fecha
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { PlanIndicacionEventoComponent } from './indicacion-eventos/indicacion-e
import { PlanIndicacionesBotoneraComponent } from './indicaciones-botonera/indicaciones-botonera.component';
import { PlanIndicacionesNuevaIndicacionComponent } from './nueva-indicacion/nueva-indicacion.component';
import { PlanIndicacionesComponent } from './plan-indicaciones.component';
import { SuspensionIndicacionComponent } from './motivo-suspension/motivo-suspension.component';

@NgModule({
imports: [
Expand All @@ -31,7 +32,8 @@ import { PlanIndicacionesComponent } from './plan-indicaciones.component';
IndicacionLabelPipe,
PlanIndicacionesResumenComponent,
PlanIndicacionesBotoneraComponent,
PlanIndicacionesNuevaIndicacionComponent
PlanIndicacionesNuevaIndicacionComponent,
SuspensionIndicacionComponent
],
exports: [
IndicacionColorPipe,
Expand Down

0 comments on commit 2c81e2e

Please sign in to comment.