Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(FEAT) Demanda Insatisfecha: pasar funcionalidad a API #3002

Merged
merged 2 commits into from
Jun 18, 2024
Merged
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
Expand Up @@ -190,7 +190,7 @@ export class DarTurnosComponent implements OnInit {
constructor(
public serviceProfesional: ProfesionalService,
public serviceAgenda: AgendaService,
public serviceListaEspera: ListaEsperaService,
public listaEsperaService: ListaEsperaService,
public serviceTurno: TurnoService,
public servicePaciente: PacienteService,
public servicioCarpetaPaciente: CarpetaPacienteService,
Expand Down Expand Up @@ -1247,7 +1247,7 @@ export class DarTurnosComponent implements OnInit {
const origen = 'citas';
const estado = 'pendiente';
const motivo = 'No hay turnos disponibles';
if (this.serviceListaEspera.guardar(this.paciente, this.opciones.tipoPrestacion, estado, this.opciones.profesional, this.organizacion, motivo, origen)) {
if (this.listaEsperaService.save(this.paciente, this.opciones.tipoPrestacion, estado, this.opciones.profesional, this.organizacion, motivo, origen)) {
this.plex.toast('success', 'Paciente agregado a Lista de Espera');
this.estadoT = 'noSeleccionada';
this.turnoTipoPrestacion = undefined; // blanquea el select de tipoprestacion en panel de confirma turno
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
label="Profesional" placeholder="Buscar un profesional" labelField="apellido+' '+nombre"
ngModelOptions="{standalone: true}">
</plex-select>
<plex-select label="Motivo" [(ngModel)]="motivo" [required]="true" [data]="motivos"
name="tipoPrestacion"></plex-select>
<plex-select label="Motivo" [(ngModel)]="motivo" [required]="true" [data]="motivos" name="motivos"></plex-select>
<br>
<div class="row">
<div class="col-6">
Expand Down
13 changes: 8 additions & 5 deletions src/app/components/turnos/dashboard/demandaInsatisfecha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class demandaInsatisfechaComponent {
public plex: Plex,
public conceptosTurneablesService: ConceptosTurneablesService,
public profesionalService: ProfesionalService,
public serviceListaEspera: ListaEsperaService,
public listaEsperaService: ListaEsperaService,
) { }

loadTipoPrestaciones(event) {
Expand All @@ -53,10 +53,13 @@ export class demandaInsatisfechaComponent {

guardar() {
if (this.motivo && this.tipoPrestacion) {
if (this.serviceListaEspera.guardar(this.paciente, this.tipoPrestacion, this.estado, this.profesional, this.organizacion, this.motivo.nombre, this.origen)) {
this.plex.toast('success', 'Demanda insatisfecha guardada exitosamente!');
this.cerrar();
}
this.listaEsperaService.save(this.paciente, this.tipoPrestacion, this.estado, this.profesional, this.organizacion, this.motivo.nombre, this.origen).subscribe({
complete: () => {
this.plex.toast('success', 'Demanda insatisfecha guardada exitosamente!');
this.cerrar();
},
error: (e) => this.plex.toast('danger', e.message, 'Ha ocurrido un error al guardar')
});
}
}

Expand Down
79 changes: 21 additions & 58 deletions src/app/services/turnos/listaEspera.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,7 @@ export class ListaEsperaService {
return this.server.patch(this.listaEsperaUrl + '/' + id + '/' + datoMod, cambios);
}

save(listaEspera: IListaEspera): Observable<IListaEspera> {
if (listaEspera.id) {
return this.server.put(this.listaEsperaUrl + '/' + listaEspera.id, listaEspera);
} else {
return this.server.post(this.listaEsperaUrl, listaEspera);
}
}

guardar(paciente, tipoPrestacion, estado: String, profesional, organizacion, motivo: String, origen: String) {
if (!paciente || !tipoPrestacion || !estado || !organizacion || !motivo || !origen) {
this.plex.toast('danger', 'Error en parámetros');
return false;
}
save(paciente, tipoPrestacion, estado: String, profesional, organizacion, motivo: String, origen: String) {
const datosProfesional = !profesional ? null : {
id: profesional.id,
nombre: profesional.nombre,
Expand All @@ -68,51 +56,26 @@ export class ListaEsperaService {
fecha: moment().toDate(),
origen
};
const params = {
'pacienteId': paciente.id,
'conceptId': tipoPrestacion.conceptId,
'estado': estado
const datosPaciente: IPacienteBasico = {
id: paciente.id,
nombre: paciente.nombre,
alias: paciente.alias,
apellido: paciente.apellido,
documento: paciente.documento,
numeroIdentificacion: paciente.numeroIdentificacion,
fechaNacimiento: paciente.fechaNacimiento,
sexo: paciente.sexo,
genero: paciente.genero
};
const listaEspera: IListaEspera = {
paciente: datosPaciente,
fecha: moment().toDate(),
vencimiento: null,
estado,
demandas: [demanda],
tipoPrestacion,
resolucion: null
};
const r = this.get(params).subscribe(resultado => {
if (resultado[0]?.demandas) {
resultado[0].demandas.push(demanda);
this.patch(resultado[0].id, 'demandas', resultado[0].demandas).subscribe(() => {
return true;
}, (error) => {
this.plex.toast('danger', error, 'Ha ocurrido un error al guardar');
return false;
});
} else {
const datosPaciente: IPacienteBasico = {
id: paciente.id,
nombre: paciente.nombre,
alias: paciente.alias,
apellido: paciente.apellido,
documento: paciente.documento,
numeroIdentificacion: paciente.numeroIdentificacion,
fechaNacimiento: paciente.fechaNacimiento,
sexo: paciente.sexo,
genero: paciente.genero
};
const listaEspera: IListaEspera = {
paciente: datosPaciente,
fecha: moment().toDate(),
vencimiento: null,
estado,
demandas: [demanda],
tipoPrestacion,
resolucion: null
};
if (listaEspera !== null) {
this.post(listaEspera).subscribe(() => {
return true;
}, (error) => {
this.plex.toast('danger', error, 'Ha ocurrido un error al guardar');
return false;
});
}
}
});
return r;
return this.post(listaEspera);
}
}
Loading