From 7b841d6e628a31ccf00d7aef74571f77a3d67bb5 Mon Sep 17 00:00:00 2001 From: Niek Otten Date: Tue, 14 Jul 2026 14:46:40 +0200 Subject: [PATCH] feat(domain): pass the registrationId to the ACL as the zaak reference (refs #78) OpenZaakWorker forwards registration.Id to IAclClient.OpenZaakAsync so the zaak's identificatie equals the reference the citizen sees on the submit confirmation. Co-Authored-By: Claude Opus 4.8 (1M context) --- services/domain/Big.Application/OpenZaakWorker.cs | 2 +- services/domain/Big.Application/Ports.cs | 5 ++++- services/domain/Big.Infrastructure/AclHttpClient.cs | 8 +++++--- services/domain/Big.Tests/AclHttpClientTests.cs | 7 ++++--- services/domain/Big.Tests/Fakes.cs | 4 +++- services/domain/Big.Tests/OpenZaakWorkerTests.cs | 3 +++ tests/acceptance/Support/InMemoryDomainPorts.cs | 4 +++- 7 files changed, 23 insertions(+), 10 deletions(-) diff --git a/services/domain/Big.Application/OpenZaakWorker.cs b/services/domain/Big.Application/OpenZaakWorker.cs index be0688f..b488ef8 100644 --- a/services/domain/Big.Application/OpenZaakWorker.cs +++ b/services/domain/Big.Application/OpenZaakWorker.cs @@ -28,7 +28,7 @@ public sealed class OpenZaakWorker(IRegistrationStore store, IAclClient acl) if (registration.ZaakUrl is not null) return registration.ZaakUrl; - var zaakUrl = await acl.OpenZaakAsync(registration.Bsn, ct); + var zaakUrl = await acl.OpenZaakAsync(registration.Bsn, registration.Id.ToString(), ct); registration.AttachZaak(zaakUrl); await store.SaveAsync(registration, ct); return zaakUrl; diff --git a/services/domain/Big.Application/Ports.cs b/services/domain/Big.Application/Ports.cs index 044777d..12350c6 100644 --- a/services/domain/Big.Application/Ports.cs +++ b/services/domain/Big.Application/Ports.cs @@ -24,7 +24,10 @@ public interface IWorkflowClient /// public interface IAclClient { - Task OpenZaakAsync(string bsn, CancellationToken ct = default); + /// Open a zaak for the registration. is the registration's + /// own reference (its id); the ACL records it as the zaak's identificatie so the openbaar register + /// can show the same reference the zorgprofessional was given (S-09b follow-up, adr-proposal #78). + Task OpenZaakAsync(string bsn, string reference, CancellationToken ct = default); /// /// Record the approval on the given zaak. The ACL translates this to the ZGW concept — setting diff --git a/services/domain/Big.Infrastructure/AclHttpClient.cs b/services/domain/Big.Infrastructure/AclHttpClient.cs index c4b3129..217f9dc 100644 --- a/services/domain/Big.Infrastructure/AclHttpClient.cs +++ b/services/domain/Big.Infrastructure/AclHttpClient.cs @@ -11,10 +11,10 @@ namespace Big.Infrastructure; /// public sealed class AclHttpClient(HttpClient http, AclOptions options) : IAclClient { - public async Task OpenZaakAsync(string bsn, CancellationToken ct = default) + public async Task OpenZaakAsync(string bsn, string reference, CancellationToken ct = default) { using var response = await http.PostAsJsonAsync( - new Uri(options.BaseUrl, "zaken"), new OpenZaakRequest(bsn), ct); + new Uri(options.BaseUrl, "zaken"), new OpenZaakRequest(bsn, reference), ct); response.EnsureSuccessStatusCode(); var opened = await response.Content.ReadFromJsonAsync(ct) @@ -31,7 +31,9 @@ public sealed class AclHttpClient(HttpClient http, AclOptions options) : IAclCli response.EnsureSuccessStatusCode(); } - private sealed record OpenZaakRequest([property: JsonPropertyName("bsn")] string Bsn); + private sealed record OpenZaakRequest( + [property: JsonPropertyName("bsn")] string Bsn, + [property: JsonPropertyName("reference")] string Reference); private sealed record OpenZaakResponse([property: JsonPropertyName("zaakUrl")] string ZaakUrl); diff --git a/services/domain/Big.Tests/AclHttpClientTests.cs b/services/domain/Big.Tests/AclHttpClientTests.cs index 71311ea..1d093fb 100644 --- a/services/domain/Big.Tests/AclHttpClientTests.cs +++ b/services/domain/Big.Tests/AclHttpClientTests.cs @@ -15,12 +15,13 @@ public class AclHttpClientTests var client = Client(capture.Responds(HttpStatusCode.OK, """{"zaakUrl":"http://openzaak/zaken/api/v1/zaken/abc"}""")); - var url = await client.OpenZaakAsync("123456782"); + var url = await client.OpenZaakAsync("123456782", "reg-42"); Assert.Equal("http://openzaak/zaken/api/v1/zaken/abc", url.ToString()); Assert.Equal(HttpMethod.Post, capture.Seen!.Method); Assert.Equal("http://acl/zaken", capture.Seen.RequestUri!.ToString()); Assert.Contains("\"bsn\":\"123456782\"", capture.Body); + Assert.Contains("\"reference\":\"reg-42\"", capture.Body); } [Fact] @@ -29,7 +30,7 @@ public class AclHttpClientTests var capture = new RequestCapture(); var client = Client(capture.Responds(HttpStatusCode.BadGateway)); - await Assert.ThrowsAsync(() => client.OpenZaakAsync("123456782")); + await Assert.ThrowsAsync(() => client.OpenZaakAsync("123456782", "reg-1")); } [Fact] @@ -38,7 +39,7 @@ public class AclHttpClientTests var capture = new RequestCapture(); var client = Client(capture.Responds(HttpStatusCode.OK, "null")); - var ex = await Assert.ThrowsAsync(() => client.OpenZaakAsync("123456782")); + var ex = await Assert.ThrowsAsync(() => client.OpenZaakAsync("123456782", "reg-1")); Assert.Contains("empty", ex.Message, StringComparison.OrdinalIgnoreCase); } diff --git a/services/domain/Big.Tests/Fakes.cs b/services/domain/Big.Tests/Fakes.cs index 2377b7b..cf0a37d 100644 --- a/services/domain/Big.Tests/Fakes.cs +++ b/services/domain/Big.Tests/Fakes.cs @@ -50,15 +50,17 @@ internal sealed class FakeAclClient(Uri? zaakUrl = null) : IAclClient private readonly Uri _zaakUrl = zaakUrl ?? DefaultZaakUrl; public string? OpenedForBsn { get; private set; } + public string? OpenedWithReference { get; private set; } public int CallCount { get; private set; } public Uri? ApprovedZaakUrl { get; private set; } public int ApproveCallCount { get; private set; } - public Task OpenZaakAsync(string bsn, CancellationToken ct = default) + public Task OpenZaakAsync(string bsn, string reference, CancellationToken ct = default) { CallCount++; OpenedForBsn = bsn; + OpenedWithReference = reference; return Task.FromResult(_zaakUrl); } diff --git a/services/domain/Big.Tests/OpenZaakWorkerTests.cs b/services/domain/Big.Tests/OpenZaakWorkerTests.cs index a57af38..3ed2863 100644 --- a/services/domain/Big.Tests/OpenZaakWorkerTests.cs +++ b/services/domain/Big.Tests/OpenZaakWorkerTests.cs @@ -25,6 +25,9 @@ public class OpenZaakWorkerTests Assert.Equal(FakeAclClient.DefaultZaakUrl, zaakUrl); Assert.Equal("123456782", acl.OpenedForBsn); + // The registration's own id is handed to the ACL as the zaak reference (identificatie), + // so the openbaar register can show the reference the zorgprofessional received (#78). + Assert.Equal(registration.Id.ToString(), acl.OpenedWithReference); var saved = await store.GetAsync(registration.Id); Assert.Equal(FakeAclClient.DefaultZaakUrl, saved!.ZaakUrl); Assert.Equal(1, store.SaveCount); diff --git a/tests/acceptance/Support/InMemoryDomainPorts.cs b/tests/acceptance/Support/InMemoryDomainPorts.cs index 7cc171e..fefb2e9 100644 --- a/tests/acceptance/Support/InMemoryDomainPorts.cs +++ b/tests/acceptance/Support/InMemoryDomainPorts.cs @@ -26,11 +26,13 @@ public sealed class InMemoryAclClient : IAclClient public static readonly Uri OpenedZaakUrl = new("http://openzaak/zaken/api/v1/zaken/acc-zaak"); public string? OpenedForBsn { get; private set; } + public string? OpenedWithReference { get; private set; } public Uri? ApprovedZaakUrl { get; private set; } - public Task OpenZaakAsync(string bsn, CancellationToken ct = default) + public Task OpenZaakAsync(string bsn, string reference, CancellationToken ct = default) { OpenedForBsn = bsn; + OpenedWithReference = reference; return Task.FromResult(OpenedZaakUrl); }