Governance: risk batches of CaMa beside CaCu's
This commit is contained in:
@@ -4,7 +4,7 @@ import { Observable } from 'rxjs';
|
||||
import { PendingRiskBatch } from './risk-batches.types';
|
||||
|
||||
/** `/<domain>/riesgos/lotes`: risk batches a model produced and nobody has reviewed yet (ADR-MD-008). Only `cacu`
|
||||
* is served today. */
|
||||
* and `cama` are served. */
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class RiskBatchesApi {
|
||||
private readonly http = inject(HttpClient);
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
<div class="batches">
|
||||
<div class="batches__toolbar">
|
||||
<mat-button-toggle-group hideSingleSelectionIndicator [value]="domain()" (change)="setDomain($event.value)" aria-label="Dominio">
|
||||
@for (option of domains; track option.id) {
|
||||
<mat-button-toggle [value]="option.id">{{ option.label }}</mat-button-toggle>
|
||||
}
|
||||
</mat-button-toggle-group>
|
||||
<span class="batches__spacer"></span>
|
||||
<button mat-icon-button type="button" (click)="reload()" aria-label="Recargar" matTooltip="Recargar">
|
||||
<mat-icon aria-hidden="true">refresh</mat-icon>
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Component, DestroyRef, OnInit, inject, signal } from '@angular/core';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { FormControl, ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatButtonToggleModule } from '@angular/material/button-toggle';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
@@ -10,21 +11,27 @@ import { MatProgressBarModule } from '@angular/material/progress-bar';
|
||||
import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar';
|
||||
import { MatTableModule } from '@angular/material/table';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { AuthService } from '../../../auth/auth.service';
|
||||
import { apiErrorMessage } from '../../../connect/api/api.types';
|
||||
import { RiskBatchesApi } from '../../api/risk-batches.api';
|
||||
import { PendingRiskBatch } from '../../api/risk-batches.types';
|
||||
|
||||
const DOMAIN = 'cacu';
|
||||
/** The domains with a model that estimates risks: each has its own batches under `/<domain>/riesgos/lotes`. */
|
||||
export const RISK_DOMAINS = [
|
||||
{ id: 'cacu', label: 'Cáncer cervicouterino' },
|
||||
{ id: 'cama', label: 'Cáncer de mama' },
|
||||
];
|
||||
|
||||
/**
|
||||
* Risk batches a model produced that nobody has confirmed or voided yet (ADR-MD-008): invisible to patient
|
||||
* records until someone decides, with a reason. Only CaCu has a model estimating risks today.
|
||||
* records until someone decides, with a reason. CaCu and CaMa have a model estimating risks.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'app-risk-batches-panel',
|
||||
imports: [
|
||||
DatePipe,
|
||||
MatButtonModule,
|
||||
MatButtonToggleModule,
|
||||
MatFormFieldModule,
|
||||
MatIconModule,
|
||||
MatInputModule,
|
||||
@@ -39,9 +46,13 @@ const DOMAIN = 'cacu';
|
||||
})
|
||||
export class RiskBatchesPanel implements OnInit {
|
||||
private readonly api = inject(RiskBatchesApi);
|
||||
private readonly auth = inject(AuthService);
|
||||
private readonly snackBar = inject(MatSnackBar);
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
/** Only the account's domains. */
|
||||
readonly domains = RISK_DOMAINS.filter((d) => this.auth.puedeVer(d.id));
|
||||
readonly domain = signal<string>(this.domains[0]?.id ?? RISK_DOMAINS[0].id);
|
||||
readonly batches = signal<PendingRiskBatch[]>([]);
|
||||
readonly loading = signal(false);
|
||||
readonly loadError = signal<string | null>(null);
|
||||
@@ -54,11 +65,16 @@ export class RiskBatchesPanel implements OnInit {
|
||||
this.reload();
|
||||
}
|
||||
|
||||
setDomain(domain: string): void {
|
||||
this.domain.set(domain);
|
||||
this.reload();
|
||||
}
|
||||
|
||||
reload(): void {
|
||||
this.loading.set(true);
|
||||
this.loadError.set(null);
|
||||
this.api
|
||||
.listPending(DOMAIN)
|
||||
.listPending(this.domain())
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe({
|
||||
next: (batches) => {
|
||||
@@ -82,11 +98,11 @@ export class RiskBatchesPanel implements OnInit {
|
||||
}
|
||||
|
||||
confirm(batch: PendingRiskBatch): void {
|
||||
this.decide(batch, (reason) => this.api.confirm(DOMAIN, batch.lote_id, reason), 'confirmado');
|
||||
this.decide(batch, (reason) => this.api.confirm(this.domain(), batch.lote_id, reason), 'confirmado');
|
||||
}
|
||||
|
||||
void(batch: PendingRiskBatch): void {
|
||||
this.decide(batch, (reason) => this.api.void(DOMAIN, batch.lote_id, reason), 'anulado');
|
||||
this.decide(batch, (reason) => this.api.void(this.domain(), batch.lote_id, reason), 'anulado');
|
||||
}
|
||||
|
||||
private decide(
|
||||
|
||||
Reference in New Issue
Block a user