using Big.Domain; namespace Big.Application; /// One row of the behandelaar's werkbak: a registration awaiting beoordeling, with the /// public-facing reference (its id) plus the bsn and status a behandelaar needs to triage it. public sealed record WerkbakItem(string RegistrationId, string Bsn, string Status); /// /// The werkbak query (S-12c): the registrations awaiting a behandelaar's beoordeling. It reads the /// open Beoordelen tasks from the workflow engine (§8.2, via ) — /// the authoritative set of work items — and enriches each with its aggregate (bsn + status). A task /// whose registration the domain doesn't know, or whose registration is no longer open for beoordeling /// (e.g. withdrawn — S-11 — while its task lingers until the workflow cancels it), is skipped. /// public sealed class Werkbak(IUserTaskClient tasks, IRegistrationStore store) { public async Task> GetAsync(CancellationToken ct = default) { var open = await tasks.GetOpenBeoordelingenAsync(ct); var items = new List(open.Count); foreach (var task in open) { var registration = await store.GetAsync(task.RegistrationId, ct); if (registration is null || !IsOpenForBeoordeling(registration.Status)) continue; items.Add(new WerkbakItem( registration.Id.ToString(), registration.Bsn, registration.Status.ToString())); } return items; } // Only registrations still open for a decision belong in the werkbak; a terminal one (decided or // withdrawn — S-11) whose Beoordelen task has not yet been cleared must not surface to a behandelaar. private static bool IsOpenForBeoordeling(RegistrationStatus status) => status is RegistrationStatus.Ingediend or RegistrationStatus.InBehandeling; }