Files
WebApp/src/app/features/indicadores/paciente-detalle/paciente-riesgo.provider.ts
T
rockdrigo e74e3d8fd4 CaMa: a patient's risk in her record and a Supervivencia tab with the model's curves
The risk table takes a domain (CaCu by default); the CaMa record shows the mortality at 6, 12 and 18 months from the
model's index date. The Supervivencia tab draws the cohort's Kaplan-Meier with its band, the adjusted curve, the fractional
Weibull and the model's survival with its bootstrap interval; its wording comes from the model's settings.
2026-11-21 02:07:34 -06:00

21 lines
1.0 KiB
TypeScript

import { HttpClient, HttpErrorResponse, HttpParams } from '@angular/common/http';
import { inject, InjectionToken } from '@angular/core';
import { catchError, of, throwError } from 'rxjs';
import { PacienteRiesgoProvider } from './paciente-riesgo.models';
// The patient's risk is a FHIR `RiskAssessment` searched by `subject=Patient/<pac_id>`, the identifier a follow-up row
// carries as `pac_id`, in the domain's endpoint (`/cacu/fhir`, or `/cama/fhir`); an empty Bundle (or a 404) is a patient
// without risk data.
export const PACIENTE_RIESGO_PROVIDER = new InjectionToken<PacienteRiesgoProvider>('PacienteRiesgoProvider', {
providedIn: 'root', factory: () => {
const http = inject(HttpClient);
return {
obtener: (pacId: string, dominio = 'cacu') => http.get<unknown>(`/${dominio}/fhir/RiskAssessment`, {
params: new HttpParams().set('subject', `Patient/${pacId}`),
}).pipe(
catchError(error => error instanceof HttpErrorResponse && error.status === 404 ? of(null) : throwError(() => error)),
),
};
},
});