Skip to content

Commit

Permalink
feat(CIT): Implementa mockups en historial y llamados
Browse files Browse the repository at this point in the history
  • Loading branch information
ma7payne committed May 24, 2024
1 parent e63e987 commit 52e815b
Show file tree
Hide file tree
Showing 3 changed files with 177 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,36 @@

import { Component, OnInit } from '@angular/core';
import { Auth } from '@andes/auth';
import { Plex } from '@andes/plex';
import { Component, OnInit, ViewChild } from '@angular/core';
import { NgForm } from '@angular/forms';
import { ILlamado } from 'src/app/interfaces/turnos/IListaEspera';
import { ListaEsperaService } from 'src/app/services/turnos/listaEspera.service';

import { TurnoService } from 'src/app/services/turnos/turno.service';

@Component({
selector: 'demanda-insatisfecha',
templateUrl: 'demanda-insatisfecha.html'
})

export class DemandaInsatisfechaComponent implements OnInit {
public listaEspera = [];
public listaLlamados = [];
public listaHistorial = [];
public itemSelected = null;
public filtros: any = {};
public selectorPrestacion;
public selectorMotivo;
public selectorEstadoLlamado;
public selectedPaciente;
public nuevoLlamado: ILlamado = {};
public estadosLlamado = [
{ id: 'turnoAsignado', nombre: 'Turno asignado' },
{ id: 'noContesta', nombre: 'No contesta' },
{ id: 'numeroEquivocado', nombre: 'Numero equivocado' },
{ id: 'otro', nombre: 'Otro' }
];

public verFormularioLlamado = false;

public motivos = [
{ id: 1, nombre: 'No existe la oferta en el efector' },
Expand Down Expand Up @@ -46,7 +63,13 @@ export class DemandaInsatisfechaComponent implements OnInit {
public tabIndex = 0;
public pacienteFields = ['sexo', 'fechaNacimiento', 'cuil', 'financiador', 'numeroAfiliado', 'direccion'];

constructor(private listaEsperaService: ListaEsperaService) { }
@ViewChild('formLlamados', { read: NgForm }) formLlamados: NgForm;

constructor(
private listaEsperaService: ListaEsperaService,
private plex: Plex,
private auth: Auth,
public serviceTurno: TurnoService) { }

ngOnInit(): void {
this.getDemandas({ estado: 'pendiente' });
Expand All @@ -62,7 +85,25 @@ export class DemandaInsatisfechaComponent implements OnInit {
});
}

public seleccionarDemanda(demanda) { this.itemSelected = demanda; }
public getHistorial(historial) {
if (historial) {
this.serviceTurno.getHistorial({ pacienteId: this.itemSelected.paciente.id }).subscribe(
historial => {
this.listaHistorial = historial;
});
}
}

public cambiarTab(value) {
this.tabIndex = value;
}

public seleccionarDemanda(demanda) {
this.itemSelected = demanda;
this.listaHistorial = null;
this.tabIndex = 0;
this.listaLlamados = !this.itemSelected.llamados ? [] : [...this.itemSelected.llamados];
}

public refreshSelection({ value }, tipo) {
if (tipo === 'paciente') {
Expand Down Expand Up @@ -90,5 +131,35 @@ export class DemandaInsatisfechaComponent implements OnInit {

public cerrar() { this.itemSelected = null; }

public cambiarTab(index) { }
public agregarLlamado() {
this.verFormularioLlamado = !this.verFormularioLlamado;
this.nuevoLlamado = {};
this.formLlamados?.reset({});
this.formLlamados?.form.markAsPristine();
}

public async guardarLlamado(id) {
this.formLlamados.control.markAllAsTouched();

if (this.formLlamados.form.valid) {
try {
this.listaLlamados.push({ ...this.nuevoLlamado, createdBy: this.auth.usuario, createdAt: moment() });

this.listaEsperaService.patch(id, 'llamados', this.listaLlamados).subscribe(() => {
this.plex.toast('success', 'Llamado registrado exitosamente');
this.agregarLlamado();
});
} catch (error) {
this.plex.toast('danger', 'Error al guardar el llamado');
}
}
}

public seleccionarEstadoLlamado() {
this.nuevoLlamado.estado = this.selectorEstadoLlamado?.nombre;

if (this.selectorEstadoLlamado?.id !== 'otro') {
this.nuevoLlamado.comentario = null;
}
}
}
96 changes: 95 additions & 1 deletion src/app/components/demandaInsatisfecha/demanda-insatisfecha.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</ng-container>
</plex-layout-main>
<plex-layout-sidebar *ngIf="itemSelected" type="invert">
<plex-tabs [activeIndex]="tabIndex" (change)="cambiarTab($event)">
<plex-tabs size="full" [activeIndex]="tabIndex" (change)="cambiarTab($event)">
<plex-tab label="DATOS">
<ng-container>
<plex-title titulo="Detalle paciente" size="md">
Expand All @@ -72,6 +72,100 @@
</plex-list>
</ng-container>
</plex-tab>
<plex-tab label="LLAMADOS">
<plex-title titulo="Llamados" size="md">
<plex-badge size="sm" type="warning" class="mr-1">
<plex-icon name="phone" size="md"></plex-icon>
{{ listaLlamados.length }}
</plex-badge>
<ng-container *ngIf="!verFormularioLlamado">
<plex-button size="sm" type="success" icon="plus" (click)="agregarLlamado()"
ariaLabel="Agregar llamado" class="mr-1">
</plex-button>
</ng-container>
<ng-container *ngIf="verFormularioLlamado">
<plex-button size="sm" type="success" icon="check" (click)="guardarLlamado(itemSelected.id)"
ariaLabel="Guardar llamado" class="mr-1">
</plex-button>
<plex-button size="sm" type="danger" icon="close" (click)="agregarLlamado()" ariaLabel="Cerrar">
</plex-button>
</ng-container>
</plex-title>
<ng-container>
<form #formLlamados="ngForm" *ngIf="verFormularioLlamado">
<plex-wrapper justify>
<plex-select grow="full" label="Seleccione una opción" [(ngModel)]="selectorEstadoLlamado"
name="estadoLlamado" [data]="estadosLlamado" [required]="true"
(change)="seleccionarEstadoLlamado()">
</plex-select>
<plex-text *ngIf="selectorEstadoLlamado?.id === 'otro'" grow="full" columns="6"
label="Ingrese comentario" [(ngModel)]="nuevoLlamado.comentario" name="nota"
multiline=true required="true">
</plex-text>
</plex-wrapper>
</form>
</ng-container>
<ng-container>
<plex-label *ngIf="!listaLlamados.length" class="flex-column" icon="informacion" type="warning"
size="lg" direction="column" titulo="No se encuentran llamados registrados"
subtitulo='Para agregar uno, presione el botón "+"'
class="d-flex justify-content-center mt-4">
</plex-label>
</ng-container>
<ng-container>
<plex-list *ngIf="listaLlamados.length">
<plex-item *ngFor="let llamado of listaLlamados">
<plex-badge size="sm" type="info">
{{ llamado?.createdAt | fecha }} {{ llamado?.createdAt | hora }}
</plex-badge>
<div class="d-flex align-items-center">
<span *ngIf="llamado?.estado === 'Otro' && llamado?.comentario"
hint="{{llamado.comentario}}" hintType="info" hintIcon="message" class="small"
style="width:'40px'">Otro
</span>
<span *ngIf="llamado?.estado === 'Otro' && !llamado?.comentario" class="small"
style="width:'40px'">
Otro
</span>
<span *ngIf="llamado?.estado !== 'Otro'" class="small">
{{llamado.estado}}
</span>
</div>
<plex-label size="sm" titulo="Registrado por"
subtitulo="{{llamado.createdBy?.nombreCompleto}}"></plex-label>
</plex-item>
</plex-list>
</ng-container>
</plex-tab>
<plex-tab label="HISTORIAL" (toggle)="getHistorial($event)">
<plex-title titulo="Historial de turnos" size="md">
<plex-button size="sm" type="danger" [icon]="'close'" (click)="cerrar()"></plex-button>
</plex-title>
<ng-container>
<plex-label *ngIf="!listaHistorial?.length" class="flex-column" icon="informacion" type="warning"
size="lg" direction="column" titulo="No hay resultados"
subtitulo="No se ha registrado ningún turno para el paciente"
class="d-flex justify-content-center mt-4">
</plex-label>
</ng-container>
<ng-container>
<plex-list *ngIf="listaHistorial?.length">
<plex-item *ngFor="let historial of listaHistorial">
<div class="align-items-center">
<plex-badge size="sm" type="success">
{{historial.estado}}
</plex-badge>
</div>
<plex-label size="md" titulo="Fecha"
subtitulo="{{historial.horaInicio | fecha}} {{historial.horaInicio | hora}}hs"></plex-label>
<plex-label size="md" titulo="Prestación"
subtitulo="{{historial.tipoPrestacion.term}}"></plex-label>
<plex-label size="md" titulo="Efector"
subtitulo="{{historial.organizacion.nombre}}"></plex-label>
</plex-item>
</plex-list>
</ng-container>
</plex-tab>
</plex-tabs>
</plex-layout-sidebar>
</plex-layout>
6 changes: 6 additions & 0 deletions src/app/interfaces/turnos/IListaEspera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,10 @@ export interface IListaEspera {
motivo: String;
observacion: String;
};
llamados?: ILlamado[];
}

export interface ILlamado {
estado?: string;
comentario?: string;
}

0 comments on commit 52e815b

Please sign in to comment.