Patient record reads its risk from GET /cacu/pacientes/<pac_id>/riesgo, by the id the follow-up list shows

This commit is contained in:
2026-11-11 23:25:08 -06:00
committed by Angel Capetillo Zavala
parent 2e0938628c
commit edb868f372
9 changed files with 53 additions and 27 deletions
@@ -1,8 +1,16 @@
import { InjectionToken } from '@angular/core';
import { of } from 'rxjs';
import { HttpClient, HttpErrorResponse } from '@angular/common/http';
import { inject, InjectionToken } from '@angular/core';
import { catchError, of, throwError } from 'rxjs';
import { PacienteRiesgoProvider } from './paciente-riesgo.models';
// No HTTP, fixtures or identity conversion. A real adapter requires separate authorization.
// The follow-up list identifies each patient by the `pac_id` of the risk batches; a 404 is a patient without risk data.
export const PACIENTE_RIESGO_PROVIDER = new InjectionToken<PacienteRiesgoProvider>('PacienteRiesgoProvider', {
providedIn: 'root', factory: () => ({ obtener: () => of(null) }),
providedIn: 'root', factory: () => {
const http = inject(HttpClient);
return {
obtener: (idSeudonimo: string) => http.get<unknown>(`/cacu/pacientes/${encodeURIComponent(idSeudonimo)}/riesgo`).pipe(
catchError(error => error instanceof HttpErrorResponse && error.status === 404 ? of(null) : throwError(() => error)),
),
};
},
});