Skip to content

Commit

Permalink
feat(CIT): Implementa mockups de demanda insatisfecha
Browse files Browse the repository at this point in the history
  • Loading branch information
ma7payne committed Aug 2, 2024
1 parent 3539695 commit 3aff8a7
Show file tree
Hide file tree
Showing 9 changed files with 397 additions and 10 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"dependencies": {
"@agm/core": "3.0.0-beta.0",
"@andes/icons": "^1.1.23",
"@andes/icons": "^1.1.24",
"@andes/match": "^1.1.12",
"@andes/plex": "^8.0.3",
"@angular-eslint/eslint-plugin": "12.3.1",
Expand Down
2 changes: 2 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ import { MPILibModule } from './modules/mpi/mpi-lib.module';
import { FormulaBaseService } from './modules/rup/components/formulas';
import { RiesgoCardiovascularService } from './modules/rup/components/formulas/riesgoCardiovascular.service';
import { demandaInsatisfechaComponent } from './components/turnos/dashboard/demandaInsatisfecha';

// INTERNACION
import { PuntoInicioInternacionComponent } from './modules/rup/components/internacion/puntoInicio-internacion.component';
import { RUPLibModule } from './modules/rup/rup-lib.module';
Expand Down Expand Up @@ -221,6 +222,7 @@ import { LogoSvgComponent } from './styles/logo.svg';
import { MapsComponent } from './utils/mapsComponent';
import { PermisosComponent } from './utils/permisos/permisos.component';


registerLocaleData(localeEs, 'es');

// Main module
Expand Down
2 changes: 2 additions & 0 deletions src/app/app.routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { PacienteComponent } from './core/mpi/components/paciente.component';
// Internacion
import { PuntoInicioInternacionComponent } from './modules/rup/components/internacion/puntoInicio-internacion.component';
import { ValidarCertificadoComponent } from './modules/epidemiologia/components/validar-certificado/validar-certificado.component';
import { DemandaInsatisfechaComponent } from './components/demandaInsatisfecha/demanda-insatisfecha.component';


const appRoutes: Routes = [
Expand Down Expand Up @@ -87,6 +88,7 @@ const appRoutes: Routes = [
{ path: 'citas/sobreturnos/:idAgenda', component: AgregarSobreturnoComponent, canActivate: [RoutingNavBar, RoutingGuard] },
{ path: 'citas/paciente/:idAgenda', component: AgregarPacienteComponent, canActivate: [RoutingNavBar, RoutingGuard] },
{ path: 'citas/prestaciones_habilitadas', component: PrestacionesHabilitadasComponent, canActivate: [RoutingNavBar, RoutingGuard] },
{ path: 'citas/demanda-insatisfecha', component: DemandaInsatisfechaComponent, canActivate: [RoutingNavBar, RoutingGuard] },

{
path: 'rup',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@

import { Auth } from '@andes/auth';
import { Plex } from '@andes/plex';
import { Component, OnInit, ViewChild } from '@angular/core';
import { NgForm } from '@angular/forms';
import { map } from 'rxjs/operators';
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 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' },
{ id: 2, nombre: 'No hay turnos disponibles' },
{ id: 3, nombre: 'Oferta rechazada por el paciente' }
];

public columns = [
{
key: 'paciente',
label: 'Paciente'
},
{
key: 'prestacion',
label: 'Prestación'
},
{
key: 'fecha',
label: 'Fecha'
},
{
key: 'motivo',
label: 'Motivo'
},
{
key: 'estado',
}
];

public tabIndex = 0;
public pacienteFields = ['sexo', 'fechaNacimiento', 'cuil', 'financiador', 'numeroAfiliado', 'direccion'];

@ViewChild('formLlamados', { read: NgForm }) formLlamados: NgForm;
@ViewChild('formFiltros', { static: false }) formFiltros: NgForm;

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

ngOnInit(): void {
const fechaDesdeInicial = moment().subtract(7, 'days');
this.filtros.fechaDesde = fechaDesdeInicial;

this.getDemandas({ fechaDesde: fechaDesdeInicial });
}

private getDemandas(filtros) {
this.listaEsperaService.get({ ...filtros, estado: 'pendiente' }).subscribe((listaEspera: any[]) => {
this.listaEspera = listaEspera;
this.listaEspera.forEach(item => {
item.motivos = [...new Set(item.demandas.map(({ motivo }) => motivo))];
});
});
}

public obtenerObjetoMasAntiguo() {
if (this.listaEspera.length === 0) {
return null;
}

return this.listaEspera.reduce((masAntiguo, item) => {
return item.fecha < masAntiguo.fecha ? item : masAntiguo;
});
}

public getHistorial(historial) {
const demandas = this.itemSelected.demandas;
const primerDemanda = demandas.reduce((masAntiguo, item) => {
return item.fecha < masAntiguo.fecha ? item : masAntiguo;
});

if (historial) {
this.serviceTurno.getHistorial({ pacienteId: this.itemSelected.paciente.id }).pipe(
map(historial => historial.filter(item => moment(item.horaInicio).isAfter(moment(primerDemanda.fecha))))
).subscribe(historialFiltrado => {
this.listaHistorial = historialFiltrado;
});
}
}

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 actualizarDemanda(demanda) {
const i = this.listaEspera.findIndex(item => item.id === demanda.id);
this.listaEspera[i] = demanda;
}

public actualizarFiltros({ value }, tipo) {
if (this.formFiltros.invalid) {
return null;
}

if (tipo === 'paciente') {
this.filtros = { ...this.filtros, paciente: value };
}

if (tipo === 'fechaDesde') {
this.filtros = { ...this.filtros, fechaDesde: value };
}

if (tipo === 'fechaHasta') {
this.filtros = { ...this.filtros, fechaHasta: value };
}

if (tipo === 'prestacion') {
this.filtros = { ...this.filtros, prestacion: value?.term };
}

if (tipo === 'motivo') {
this.filtros = { ...this.filtros, motivo: value?.nombre };
}

this.getDemandas(this.filtros);
}

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

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((demanda) => {
this.plex.toast('success', 'Llamado registrado exitosamente');
this.agregarLlamado();
this.actualizarDemanda(demanda);
});
} 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;
}
}
}
Loading

0 comments on commit 3aff8a7

Please sign in to comment.