import { HttpClient } from '@angular/common/http'; import { Injectable, inject } from '@angular/core'; import { Observable } from 'rxjs'; import { PendingRiskBatch } from './risk-batches.types'; /** `//riesgos/lotes`: risk batches a model produced and nobody has reviewed yet (ADR-MD-008). Only `cacu` * is served today. */ @Injectable({ providedIn: 'root' }) export class RiskBatchesApi { private readonly http = inject(HttpClient); listPending(domain: string): Observable { return this.http.get(`/${domain}/riesgos/lotes`); } /** Moves every current evaluation of the batch to `final`: it becomes the one patient records read. */ confirm(domain: string, loteId: number, reason: string): Observable<{ lote_id: number; evaluaciones_cambiadas: number }> { return this.http.post<{ lote_id: number; evaluaciones_cambiadas: number }>( `/${domain}/riesgos/lotes/${loteId}/confirmar`, { reason }, ); } /** Moves every current evaluation of the batch to `entered-in-error` instead. */ void(domain: string, loteId: number, reason: string): Observable<{ lote_id: number; evaluaciones_cambiadas: number }> { return this.http.post<{ lote_id: number; evaluaciones_cambiadas: number }>( `/${domain}/riesgos/lotes/${loteId}/anular`, { reason }, ); } }