00f773dd75
The record asks GET /cacu/fhir/RiskAssessment?subject=Patient/<pac_id> and validates the searchset Bundle at the boundary (simulado tag, the patient asked for, one index date, probabilities and intervals); it shows the model, the risk's index date, the outcome, the evaluation and one row per horizon from each prediction's whenPeriod. The cohort's definition and the PIMM variables are no longer shown; an empty Bundle is a patient without a confirmed risk. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HmQxVJVNR5FYkPAregGEQ7
20 lines
978 B
TypeScript
20 lines
978 B
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`; 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) => http.get<unknown>('/cacu/fhir/RiskAssessment', {
|
|
params: new HttpParams().set('subject', `Patient/${pacId}`),
|
|
}).pipe(
|
|
catchError(error => error instanceof HttpErrorResponse && error.status === 404 ? of(null) : throwError(() => error)),
|
|
),
|
|
};
|
|
},
|
|
});
|