From 09000d8e6411e53a146bde24b3f0c6d4851b1f04 Mon Sep 17 00:00:00 2001 From: Niek Otten Date: Tue, 14 Jul 2026 17:18:18 +0200 Subject: [PATCH] feat(domain): take a registration into behandeling; generalise decisions (refs #13) Adds InBehandeling + Afgewezen statuses and TakeIntoBehandeling(). Generalises the behandelaar decision: Approve() (requires a zaak) and new Reject() both act on an INGEDIEND or IN_BEHANDELING registration, moving it to Ingeschreven/Afgewezen. Co-Authored-By: Claude Opus 4.8 (1M context) --- services/domain/Big.Domain/Registration.cs | 51 ++++++++++++++++--- .../domain/Big.Domain/RegistrationStatus.cs | 15 ++++-- 2 files changed, 54 insertions(+), 12 deletions(-) diff --git a/services/domain/Big.Domain/Registration.cs b/services/domain/Big.Domain/Registration.cs index be1f1ea..3aa620d 100644 --- a/services/domain/Big.Domain/Registration.cs +++ b/services/domain/Big.Domain/Registration.cs @@ -66,10 +66,28 @@ public sealed class Registration } /// - /// Approve the registration — the behandelaar's decision to enter it in the register. Advances - /// . - /// Requires an opened zaak (the approval sets that zaak's status via the ACL), and only a - /// submitted registration can be approved: re-approving is rejected as an invalid transition. + /// A behandelaar picks the registration up for beoordeling. Advances + /// . + /// Re-taking one already is a no-op (the same or + /// another behandelaar re-opens it); a decided registration can no longer be taken into behandeling. + /// + public void TakeIntoBehandeling() + { + if (Status == RegistrationStatus.InBehandeling) + return; + + if (Status != RegistrationStatus.Ingediend) + throw new InvalidOperationException( + $"Registration {Id} is {Status}; only an INGEDIEND registration can be taken into behandeling."); + + Status = RegistrationStatus.InBehandeling; + } + + /// + /// Approve the registration — the behandelaar's decision to enter it in the register. Advances a + /// submitted or in-behandeling registration to . + /// Requires an opened zaak (the approval sets that zaak's status via the ACL); a registration that + /// has already been decided cannot be approved again. /// public void Approve() { @@ -77,10 +95,27 @@ public sealed class Registration throw new InvalidOperationException( $"Registration {Id} has no zaak yet; it cannot be approved before its zaak is opened."); - if (Status != RegistrationStatus.Ingediend) - throw new InvalidOperationException( - $"Registration {Id} is {Status}; only an INGEDIEND registration can be approved."); - + RequireOpenForDecision(nameof(Approve)); Status = RegistrationStatus.Ingeschreven; } + + /// + /// Reject the registration — the behandelaar's decision not to enter it in the register. Advances a + /// submitted or in-behandeling registration to . Unlike + /// approval this needs no zaak: a registration can be rejected before or after its zaak is opened. + /// A registration that has already been decided cannot be rejected again. + /// + public void Reject() + { + RequireOpenForDecision(nameof(Reject)); + Status = RegistrationStatus.Afgewezen; + } + + // A decision is only valid while the registration is still open (INGEDIEND or IN_BEHANDELING). + private void RequireOpenForDecision(string decision) + { + if (Status is not (RegistrationStatus.Ingediend or RegistrationStatus.InBehandeling)) + throw new InvalidOperationException( + $"Registration {Id} is {Status}; only an INGEDIEND or IN_BEHANDELING registration can be decided ({decision})."); + } } diff --git a/services/domain/Big.Domain/RegistrationStatus.cs b/services/domain/Big.Domain/RegistrationStatus.cs index 60bb171..edae5a9 100644 --- a/services/domain/Big.Domain/RegistrationStatus.cs +++ b/services/domain/Big.Domain/RegistrationStatus.cs @@ -1,13 +1,20 @@ namespace Big.Domain; -/// The lifecycle states a moves through. The walking -/// skeleton knows and the terminal ; withdrawal, -/// beoordeling and herregistratie states arrive in their own slices (Iteration 2+). +/// The lifecycle states a moves through. Submission starts in +/// ; a behandelaar takes it and decides it into one +/// of the terminal states (approved) or (rejected). +/// Withdrawal and herregistratie states arrive in their own slices (S-11+). public enum RegistrationStatus { /// Submitted by the zorgprofessional; the registratie process has been started. Ingediend, - /// Approved: entered in the register. Terminal in the walking skeleton (S-09b). + /// Picked up by a behandelaar for beoordeling (S-12). + InBehandeling, + + /// Approved: entered in the register. Terminal. Ingeschreven, + + /// Rejected by the behandelaar. Terminal. + Afgewezen, }