using Big.Domain;
namespace Big.Application;
///
/// The port to the workflow engine. Implemented by the Workflow Client in Infrastructure — the
/// only code that talks to Flowable (CLAUDE.md §8.2). The application asks it to start the
/// registratie process; it never knows Flowable exists.
///
public interface IWorkflowClient
{
///
/// Start one registratie process instance for the given registration, carrying the
/// registration id so the OpenZaakAanmaken external task can be correlated back to its
/// aggregate. Returns the process instance id.
///
Task StartRegistrationProcessAsync(RegistrationId registrationId, CancellationToken ct = default);
}
///
/// The port to the Anti-Corruption Layer. Implemented in Infrastructure by an HTTP client to the
/// ACL service — the only code that talks to ZGW (CLAUDE.md §8.1). The domain hands over a
/// bsn; the ACL default-fills the ZGW-mandatory fields (ADR-0003) and returns the created zaak URL.
///
public interface IAclClient
{
/// 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
/// the zaak's final status — which OpenZaak notifies over NRC; the domain never names statustypen.
///
Task ApproveZaakAsync(Uri zaakUrl, CancellationToken ct = default);
}
///
/// The port to the behandelaar's user tasks in the workflow engine (S-12). Implemented by the
/// Workflow Client — the only code that talks to Flowable (§8.2). The application lists the open
/// Beoordelen tasks (the werkbak), claims one for a behandelaar, and completes it with the
/// decision; it never names Flowable's REST shapes.
///
public interface IUserTaskClient
{
/// The werkbak: the Beoordelen tasks awaiting a behandelaar, each with the
/// registration it belongs to.
Task> GetOpenBeoordelingenAsync(CancellationToken ct = default);
/// Claim a beoordeling task for a behandelaar (assigns it to them).
Task ClaimAsync(string taskId, string behandelaar, CancellationToken ct = default);
/// Complete a beoordeling task, carrying the decision into the process as the
/// besluit variable so the workflow can continue on the chosen branch.
Task CompleteBeoordelingAsync(string taskId, BeoordelingsBesluit besluit, CancellationToken ct = default);
}
/// A Beoordelen user task in the werkbak: the Flowable task id (needed to claim and
/// complete it) and the registration it carries as a process variable.
public sealed record BeoordelingTask(string TaskId, RegistrationId RegistrationId);
///
/// Persistence port for the aggregate. In-memory for the minimal slice
/// (ADR-0009); an EF-backed store is a documented follow-up, and this port keeps that change additive.
///
public interface IRegistrationStore
{
/// Insert or update the registration, keyed on its id.
Task SaveAsync(Registration registration, CancellationToken ct = default);
/// Load a registration by id, or null if none exists.
Task GetAsync(RegistrationId id, CancellationToken ct = default);
}
///
/// An acquired OpenZaakAanmaken external-worker job: the Flowable job id (needed to complete
/// it) and the registration id it carries as a process variable.
///
public sealed record OpenZaakJob(string JobId, RegistrationId RegistrationId);