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
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
<form #form="ngForm">
<plex-title titulo="Registrar evento" size="md">
<plex-button *ngIf="editando || !evento" class="mr-1" type="success" size="sm" icon="check" tooltip="Guardar"
[disabled]="!estado || labelEstado=='Motivo' && !observaciones" (click)="onGuardar()">
<plex-button *ngIf="editando || addEvent" class="mr-1" type="success" size="sm" icon="check"
[validateForm]="form"
[disabled]="!estado || (labelEstado==='Motivo' && !observaciones) || !form.valid"
(click)="onGuardar()" tooltip="Guardar">
</plex-button>
<plex-button *ngIf="!editando && evento && capa === 'enfermeria'" class="mr-1" type="warning" size="sm"
icon="pencil" (click)="onEdit()">
<plex-button *ngIf="!evento || !agregarEditarEvento || evento[0].estado === 'on-hold'" type="danger" size="sm"
icon="close" (click)="onCancelar()" tooltip="Cancelar">
</plex-button>
<plex-button type="danger" size="sm" icon="close" (click)="onCancelar()">
<plex-button *ngIf="agregarEditarEvento && evento && evento[0].estado !== 'on-hold'" type="danger" size="sm"
icon="flecha-izquierda" (click)="onVolver()" tooltip="Volver">
</plex-button>
</plex-title>

Expand All @@ -33,32 +36,46 @@
</div>
</plex-detail>

<ng-container *ngIf="editando || !evento">
<plex-datetime type="time" name="hora" label="Horario de inicio" [(ngModel)]="fechaHora" [min]="horaMin"
[max]="horaMax" [required]="true" span="2">
<ng-container *ngIf="editando || addEvent">
<plex-datetime label="Fecha y Hora" [(ngModel)]="fechaHora" name="fechaHora" [min]="horaMin" [max]="horaMax"
[required]="true">
</plex-datetime>
<plex-select [data]="estadoItems" [(ngModel)]="estado" (change)="onInputChange($event)" name="estado"
label="Estado" [required]="true">
</plex-select>
<plex-label class="font-weight-bold"> {{labelEstado}} <h3 *ngIf="labelEstado=='Motivo'" class="asteriscoRojo"> *
</h3>
</plex-label>
<div class="fondoBlancoText">
<plex-text [(ngModel)]="observaciones" name="observaciones" [required]="labelEstado==='Motivo'"
[html]="true">
</plex-text>
</div>
<plex-text [(ngModel)]="observaciones" name="observaciones" [required]="labelEstado==='Motivo'">
</plex-text>
</ng-container>
</form>

<ng-container *ngIf="!editando && evento">
<plex-badge [type]="estadoType">{{ evento.estado }} a las {{ horarioEjecucion | date:'HH:mm' }}
</plex-badge>
<plex-label *ngIf="evento.createdBy" titulo="Creado por"
subtitulo="{{ evento.createdBy.nombreCompleto || 'Automáticamente por prescripción'}}">
</plex-label>
<plex-label *ngIf="evento.updatedBy" titulo="Actualizado por" subtitulo="{{ evento.updatedBy?.nombreCompleto }}">
</plex-label>
<b>Observaciones</b><br>
<div [innerHtml]="observaciones"></div>
<ng-container *ngIf="!editando && !addEvent && evento">
<plex-title titulo="Historial de eventos" size="md">
<plex-button class="mr-1" type="success" size="sm" icon="plus" tooltip="Agregar evento" tooltipPosition="left"
(click)="agregarEvento()"></plex-button>
<plex-button *ngIf="eventSelected" type="warning" size="sm" icon="pencil" tooltip="Editar"
tooltipPosition="left" (click)="onEdit()"></plex-button>
</plex-title>
<plex-table [columns]="eventos" #table="plTable" class="tabla-eventos">
<plex-table-columns>
</plex-table-columns>
<tr *ngFor="let event of evento; let i = index" [class.selectable]="true"
[class.selected]="eventSelected === event" (click)="selectedEvent(event, i)">
<td>
<plex-badge [type]="getTipoEstado(event.estado)">{{ event.estado }} a las {{event.fecha |
date:'HH:mm'}}</plex-badge>
</td>
<td>
<plex-label>{{ event.createdBy.nombreCompleto || 'Automát. por prescripción'}}</plex-label>
</td>
<td>
<plex-label>{{ event.updatedBy?.nombreCompleto }}</plex-label>
</td>
<td>
<plex-label>{{event.observaciones}}</plex-label>
</td>
</tr>
</plex-table>
</ng-container>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { tap } from 'rxjs/operators';
import { MapaCamasService } from '../../../services/mapa-camas.service';
import * as moment from 'moment';
import { Plex } from '@andes/plex';
import { PlanIndicacionesServices } from '../../../services/plan-indicaciones.service';

@Component({
selector: 'in-plan-indicacion-evento',
Expand All @@ -25,17 +24,35 @@ export class PlanIndicacionEventoComponent implements OnChanges {
public horarioPlanificado: any = null;
horaMin;
horaMax;
estadoItems = [
{ id: 'realizado', nombre: 'Realizado' },
{ id: 'no-realizado', nombre: 'No realizado' },
{ id: 'incompleto', nombre: 'Incompleto' },
];
estadoItems = [];
estado = null;
observaciones = '';
horarioEjecucion;
estadoType;
puedeEditar = false;
agregarEditarEvento = false;
public eventSelected;
capa;
public addEvent;
public indice;
public eventos = [
{
key: 'estado',
label: 'ESTADO'
},
{
key: 'creado',
label: 'CREADO'
},
{
key: 'actualizado',
label: 'ACTUALIZADO'
},
{
key: 'observaciones',
label: 'OBSERVACIONES'
}
];

@Output() events = new EventEmitter();
@Output() save = new EventEmitter<any>();
Expand All @@ -48,7 +65,6 @@ export class PlanIndicacionEventoComponent implements OnChanges {
private organizacionService: OrganizacionService,
private auth: Auth,
private mapaCamasService: MapaCamasService,
private planIndicacionesServices: PlanIndicacionesServices,
private plex: Plex
) { }

Expand Down Expand Up @@ -84,31 +100,66 @@ export class PlanIndicacionEventoComponent implements OnChanges {
this.horarioEjecucion = this.evento.updatedAt ? this.evento.updatedAt : this.evento.createdAt;
this.estadoType = this.evento.estado === 'realizado' ? 'info' : this.evento.estado === 'no-realizado' ? 'danger' : 'warning';
}
this.estadoItems = [];

this.estadoItems = [
{ id: 'realizado', nombre: 'Realizado' },
{ id: 'no-realizado', nombre: 'No realizado' },
{ id: 'incompleto', nombre: 'Incompleto' }
];
if (!this.evento || (this.evento[0].estado === 'on-hold')) {
this.agregarEvento();
};
}

onCancelar() {
this.events.emit(false);
this.addEvent = false;
}

onEdit() {
this.agregarEditarEvento = true;
this.editando = true;
if (this.indice < this.evento.length - 1) {
this.horaMax = moment(this.evento[this.evento.length - 1].fecha);
}
this.fechaHora = moment(this.evento[this.indice].fecha).toDate();
this.estado = this.evento[this.indice].estado;
this.observaciones = this.evento[this.indice].observaciones;
}

onInputChange(value) {
(value.value?.id === 'realizado') ? this.labelEstado = 'Observaciones' : this.labelEstado = 'Motivo';
}
onGuardar() {
if (this.evento) {
this.indicacionEventosService.update(
this.evento.id,
{
if (this.evento[this.evento.length - 1].estado === 'on-hold' || this.editando) {
this.indicacionEventosService.update(
(this.indice) ? this.evento[this.indice].id : this.evento[this.evento.length - 1].id,
{
estado: this.estado.id,
observaciones: this.observaciones,
fecha: this.fechaHora
}
).subscribe(() => {
(this.editando) ? this.plex.toast('success', 'Evento modificado correctamente') : this.plex.toast('success', 'Evento registrado correctamente');
this.events.emit(true);
this.editando = false;
});
} else {
const evento = {
idInternacion: this.indicacion.idInternacion,
idIndicacion: this.indicacion.id,
fecha: this.fechaHora,
estado: this.estado.id,
observaciones: this.observaciones
}
).subscribe(() => {
this.events.emit(true);
this.editando = false;
});
};
this.indicacionEventosService.create(evento).subscribe(() => {
this.plex.toast('success', 'Evento registrado correctamente');
this.events.emit(true);
this.addEvent = false;
});
}
} else {
const evento = {
idInternacion: this.indicacion.idInternacion,
Expand Down Expand Up @@ -145,4 +196,37 @@ export class PlanIndicacionEventoComponent implements OnChanges {
}
}

agregarEvento() {
if (this.evento) {
this.horaMin = this.evento[this.evento.length - 1].fecha;
this.agregarEditarEvento = true;
}
this.fechaHora = this.horaMin;
this.addEvent = true;
this.estado = null;
this.observaciones = '';
}

selectedEvent(event, i) {
this.indice = i;
this.eventSelected = event;
}

getTipoEstado(estado: string) {
switch (estado) {
case 'realizado':
return 'success';
case 'no-realizado':
return 'danger';
case 'incompleto':
return 'warning';
}
}

onVolver() {
this.agregarEditarEvento = false;
this.addEvent = false;
this.editando = false;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,16 @@ <h3>
</td>
<td *ngFor="let hora of horas" class="pointer"
[class.selected]="indicacionEventoSelected?.id === indicacion.id && hora === horaSelected"
[ngClass]="eventos[indicacion.id] && eventos[indicacion.id][hora] ? eventos[indicacion.id][hora][eventos[indicacion.id][hora].length -1].estado : ''"
(click)="onIndicacionesCellClick(indicacion, hora)">
<span *ngIf="eventos[indicacion.id] && eventos[indicacion.id][hora]"
class="punto"
[ngClass]="eventos[indicacion.id][hora].estado"></span>
[ngClass]="eventos[indicacion.id][hora][eventos[indicacion.id][hora].length -1].estado">
</span>
<plex-icon *ngIf="eventos[indicacion.id] && eventos[indicacion.id][hora] && eventos[indicacion.id][hora][eventos[indicacion.id][hora].length -1].estado !== 'on-hold'"
[name]="getTipoIcono(eventos[indicacion.id][hora][eventos[indicacion.id][hora].length -1].estado)"
size="xl" class="icon-alerta-celda"
[type]="getColorIcono(eventos[indicacion.id][hora][eventos[indicacion.id][hora].length -1].estado)"></plex-icon>
</td>
</tr>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ export class PlanIndicacionesComponent implements OnInit {
eventos.forEach(evento => {
eventosMap[evento.idIndicacion] = eventosMap[evento.idIndicacion] || {};
const hora = moment(evento.fecha).hour();
eventosMap[evento.idIndicacion][hora] = evento;
eventosMap[evento.idIndicacion][hora] = eventosMap[evento.idIndicacion][hora] || [];
eventosMap[evento.idIndicacion][hora].push(evento);
});
this.eventos = eventosMap;
this.borradores = this.indicaciones.filter(i => i.estado.tipo === 'draft');
Expand Down Expand Up @@ -608,4 +609,26 @@ export class PlanIndicacionesComponent implements OnInit {
this.suspenderIndicacion = false;
}

getTipoIcono(estado: string): string {
switch (estado) {
case 'realizado':
return 'check-circle';
default:
return 'alert-circle';
}
}

getColorIcono(estado: string): string {
switch (estado) {
case 'realizado':
return 'success';
case 'incompleto':
return 'warning';
case 'no-realizado':
return 'danger';
default:
return 'info';
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,42 @@ plex-badge.circle>span {
height: 100%;
}

td.pointer.realizado {
background-color: #8cc63f12 !important;
border: 2px solid #8cc63f !important;
}

td.pointer.no-realizado {
background-color: #dd4b3912 !important;
border: 2px solid #dd4b39 !important;
}

td.pointer.incompleto {
background-color: #ff8d2212 !important;
border: 2px solid #ff8d22 !important;
}

td.pointer {
position: relative;

.icon-alerta-celda {
position: absolute;
top: -15px;
left: 100%;
transform: translateX(-50%);
z-index: 10;
pointer-events: none;
background-color: #fff;
border-radius: 50%;
padding: 2px;
width: 24px;
height: 24px;
display: flex;
align-items: center;
justify-content: center;
}
}

// PUNTO
.punto {
width: 16px;
Expand Down Expand Up @@ -120,11 +156,13 @@ table.plan-indicaciones {
text-align: center;
font-weight: bolder;
}
td.item-indicacion.pointer.selected {
border: 0.5px solid #5bc0de !important;
background-color: #5bc0de15 !important;
transition: 0.2s ease all;
}

td.item-indicacion.pointer.selected {
border: 0.5px solid #5bc0de !important;
background-color: #5bc0de15 !important;
transition: 0.2s ease all;
}

tr {

td.pointer {
Expand Down Expand Up @@ -158,6 +196,14 @@ td.item-indicacion.pointer.selected {
}
}

.tabla-eventos {
tr {
&.selected {
background-color: #edf8fd !important;
}
}
}

.estilo-suspendido {
background-color: #dd4b3912;
border: 2px solid #dd4b39;
Expand Down