## What & why S-10a, the **workflow/timeout spine** of the (split) document-upload slice: the registratie process now parks at a **`WachtOpDocumenten`** user task with an **interrupting `P30D` boundary timer**. When the documents arrive the task completes and the process continues into the diploma routing (S-13) → Beoordelen; if the 30 days lapse, the timer cancels the wait, runs a `RegistratieVerlopen` external-worker task, and the domain expires the aggregate to a new terminal status **`Verlopen`**. Backend only — the real upload trigger (portal → BFF → ACL → Documenten API) is S-10b (#103). Closes #102 Mechanism recorded in **ADR-0017**; opened as proposal #104. Mirrors the S-14 escalation (boundary-timer + external-worker) and S-11 withdrawal (interrupting cancel) patterns. ## Definition of Done - [x] Linked Gitea issue (above). - [x] Failing test committed before the implementation (red→green pairs per layer). - [x] Implementation makes the test pass. - [x] Conventional Commits referencing the issue (`refs #102`). - [ ] CI green — all Gitea Actions jobs (pending on this PR). - [x] `docker compose up` health unaffected (no new services; deploy path unchanged). - [x] Docs updated (ADR-0017, demo-script, BACKLOG split). - [x] ADR added (`docs/architecture/adr-0017-document-wait-timeout-cancellation.md`). - [x] Demo note in `docs/demo-script.md`. ## Notes for reviewers - **Domain** (`Registration.Expire()` + `Verlopen`), **application** (`ExpireRegistrationWorker`), **infra** (`RegistratieVerlopenProcessor`/`Pump`, `IRegistratieVerlopenClient`, Flowable acquire/complete + `CompleteDocumentWaitAsync`) — the timeout counterpart to the OpenZaak/escalation worker trios; idempotent per §8.6. - **BPMN** verified live against a `flowable-rest` probe: complete `WachtOpDocumenten` → routes to Beoordelen; fire the P30D timer → `RegistratieVerlopen` job (carrying `registrationId`) + the wait task cancelled. `verify-domain` exercises both branches in-stack (completes the wait in every existing block; fires the timer and asserts `Verlopen` in a new block). - **Scope boundary:** on expiry the aggregate goes `Verlopen` and the process ends, but the ZGW *zaak* is not yet set to a cancellation status — that needs a new ACL method + statustype seeding and is folded into S-10b (noted in ADR-0017). - `CompleteDocumentWaitAsync` is built and HTTP-tested here but not yet called from a domain endpoint; S-10b wires the upload trigger to it. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Reviewed-on: #105
161 lines
7.2 KiB
C#
161 lines
7.2 KiB
C#
namespace Big.Domain;
|
|
|
|
/// <summary>
|
|
/// The Registration aggregate root (CLAUDE.md §2.2): a zorgprofessional's submission to the BIG
|
|
/// register. It owns its lifecycle invariants — it starts <see cref="RegistrationStatus.Ingediend"/>
|
|
/// on submission, remembers the Flowable process that drives it, and records the zaak the ACL opens.
|
|
/// </summary>
|
|
public sealed class Registration
|
|
{
|
|
private Registration(RegistrationId id, string bsn, DiplomaOrigin diplomaOrigin)
|
|
{
|
|
Id = id;
|
|
Bsn = bsn;
|
|
DiplomaOrigin = diplomaOrigin;
|
|
Status = RegistrationStatus.Ingediend;
|
|
}
|
|
|
|
public RegistrationId Id { get; }
|
|
|
|
/// <summary>The citizen-service number of the submitting zorgprofessional. Handed to the ACL
|
|
/// as the domain payload; the domain never constructs ZGW concepts from it (§8.1).</summary>
|
|
public string Bsn { get; }
|
|
|
|
/// <summary>Where the diploma was issued. Rides along to the process as a start variable and
|
|
/// drives the diploma-eligibility DMN's foreign→CBGV-advies routing (S-13, ADR-0016).</summary>
|
|
public DiplomaOrigin DiplomaOrigin { get; }
|
|
|
|
public RegistrationStatus Status { get; private set; }
|
|
|
|
/// <summary>The Flowable process instance driving this registration, once started.</summary>
|
|
public string? ProcessInstanceId { get; private set; }
|
|
|
|
/// <summary>The zaak the ACL opened for this registration, once the external task has run.</summary>
|
|
public Uri? ZaakUrl { get; private set; }
|
|
|
|
/// <summary>Submit a new registration. It begins in <see cref="RegistrationStatus.Ingediend"/>.
|
|
/// The diploma origin defaults to <see cref="DiplomaOrigin.Binnenlands"/> — the common DigiD path;
|
|
/// a foreign (eIDAS) submission passes <see cref="DiplomaOrigin.Buitenlands"/>.</summary>
|
|
public static Registration Submit(string bsn, DiplomaOrigin diplomaOrigin = DiplomaOrigin.Binnenlands)
|
|
{
|
|
ArgumentException.ThrowIfNullOrWhiteSpace(bsn);
|
|
return new Registration(RegistrationId.New(), bsn, diplomaOrigin);
|
|
}
|
|
|
|
/// <summary>Record that the registratie workflow process has been started for this registration.</summary>
|
|
public void RecordProcessStarted(string processInstanceId)
|
|
{
|
|
ArgumentException.ThrowIfNullOrWhiteSpace(processInstanceId);
|
|
ProcessInstanceId = processInstanceId;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Attach the zaak the ACL opened. The external-task worker may deliver the same job more than
|
|
/// once (at-least-once), so re-attaching the identical URL is a no-op; a different URL signals a
|
|
/// genuine conflict and is rejected. The status stays <see cref="RegistrationStatus.Ingediend"/>:
|
|
/// opening the zaak does not advance the registration's lifecycle in this slice.
|
|
/// </summary>
|
|
public void AttachZaak(Uri zaakUrl)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(zaakUrl);
|
|
|
|
if (ZaakUrl is not null)
|
|
{
|
|
if (ZaakUrl != zaakUrl)
|
|
throw new InvalidOperationException(
|
|
$"Registration {Id} already has zaak {ZaakUrl}; cannot attach a different zaak {zaakUrl}.");
|
|
// Stryker disable once Statement : equivalent — re-assigning the identical URL below is a
|
|
// no-op, so removing this early return is behaviourally indistinguishable.
|
|
return;
|
|
}
|
|
|
|
ZaakUrl = zaakUrl;
|
|
}
|
|
|
|
/// <summary>
|
|
/// A behandelaar picks the registration up for beoordeling. Advances
|
|
/// <see cref="RegistrationStatus.Ingediend"/> → <see cref="RegistrationStatus.InBehandeling"/>.
|
|
/// Re-taking one already <see cref="RegistrationStatus.InBehandeling"/> is a no-op (the same or
|
|
/// another behandelaar re-opens it); a decided registration can no longer be taken into behandeling.
|
|
/// </summary>
|
|
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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Approve the registration — the behandelaar's decision to enter it in the register. Advances a
|
|
/// submitted or in-behandeling registration to <see cref="RegistrationStatus.Ingeschreven"/>.
|
|
/// 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.
|
|
/// </summary>
|
|
public void Approve()
|
|
{
|
|
if (ZaakUrl is null)
|
|
throw new InvalidOperationException(
|
|
$"Registration {Id} has no zaak yet; it cannot be approved before its zaak is opened.");
|
|
|
|
RequireOpenForDecision(nameof(Approve));
|
|
Status = RegistrationStatus.Ingeschreven;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Reject the registration — the behandelaar's decision not to enter it in the register. Advances a
|
|
/// submitted or in-behandeling registration to <see cref="RegistrationStatus.Afgewezen"/>. 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.
|
|
/// </summary>
|
|
public void Reject()
|
|
{
|
|
RequireOpenForDecision(nameof(Reject));
|
|
Status = RegistrationStatus.Afgewezen;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Withdraw the registration — the zorgprofessional pulls their own submission back (S-11). Allowed
|
|
/// while it is still open (INGEDIEND or IN_BEHANDELING) and needs no zaak; a registration that has
|
|
/// already been decided (INGESCHREVEN/AFGEWEZEN) can no longer be withdrawn. Re-withdrawing one
|
|
/// already <see cref="RegistrationStatus.Ingetrokken"/> is a no-op.
|
|
/// </summary>
|
|
public void Withdraw()
|
|
{
|
|
if (Status == RegistrationStatus.Ingetrokken)
|
|
return;
|
|
|
|
RequireOpenForDecision(nameof(Withdraw));
|
|
Status = RegistrationStatus.Ingetrokken;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Expire the registration — the 30-day document-wait timer fired before the required documents
|
|
/// were supplied, so the registratie process cancels the case (S-10a). Allowed while it is still
|
|
/// open (INGEDIEND or IN_BEHANDELING) and needs no zaak; a decided (INGESCHREVEN/AFGEWEZEN) or
|
|
/// withdrawn (INGETROKKEN) registration can no longer expire. Re-expiring one already
|
|
/// <see cref="RegistrationStatus.Verlopen"/> is a no-op — the worker job may be redelivered (§8.6).
|
|
/// </summary>
|
|
public void Expire()
|
|
{
|
|
if (Status == RegistrationStatus.Verlopen)
|
|
return;
|
|
|
|
RequireOpenForDecision(nameof(Expire));
|
|
Status = RegistrationStatus.Verlopen;
|
|
}
|
|
|
|
// A decision (or withdrawal, or expiry) 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}).");
|
|
}
|
|
}
|