feat(stamdata): profession↔diploma map as validated config-as-code
Extract the profession↔diploma table out of DiplomaRules into a dedicated Stamdata.Professions module (business-editable data, separated from the rules that consume it) and add StamdataValidationTests as the build-time gate: every seeded diploma program must resolve to a real profession, no blank entries. A bad edit now fails the build instead of silently rendering "Onbekend". Rules and behaviour unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1,29 +1,23 @@
|
||||
using BigRegister.Stamdata;
|
||||
|
||||
namespace BigRegister.Domain.Diplomas;
|
||||
|
||||
/// <summary>
|
||||
/// SERVER-OWNED business rules for diplomas. This is the single place a policy
|
||||
/// changes: which profession a study program maps to, and which policy questions
|
||||
/// (geldigheidsvragen) apply to a diploma. The frontend renders these; it never
|
||||
/// derives them.
|
||||
/// SERVER-OWNED business rules for diplomas: which profession a study program maps to,
|
||||
/// and which policy questions (geldigheidsvragen) apply to a diploma. The frontend
|
||||
/// renders these; it never derives them.
|
||||
///
|
||||
/// The profession↔program *data* is business-editable stamdata in
|
||||
/// <see cref="Professions"/> (config-as-code, ADR-0004); the *rules* below consume it.
|
||||
/// </summary>
|
||||
public static class DiplomaRules
|
||||
{
|
||||
// RULE: study program → BIG profession.
|
||||
private static readonly Dictionary<string, string> ProfessionByProgram = new(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
["geneeskunde"] = "Arts",
|
||||
["verpleegkunde"] = "Verpleegkundige",
|
||||
["fysiotherapie"] = "Fysiotherapeut",
|
||||
["farmacie"] = "Apotheker",
|
||||
["tandheelkunde"] = "Tandarts",
|
||||
};
|
||||
|
||||
// RULE: study program → BIG profession (data lives in Stamdata.Professions).
|
||||
public static string ProfessionFor(Diploma d) =>
|
||||
ProfessionByProgram.TryGetValue(d.Opleiding, out var beroep) ? beroep : "Onbekend";
|
||||
Professions.ByProgram.TryGetValue(d.Opleiding, out var beroep) ? beroep : "Onbekend";
|
||||
|
||||
/// <summary>Professions a user may declare for a manual (unlisted) diploma.</summary>
|
||||
public static IReadOnlyList<string> ManualProfessions() =>
|
||||
ProfessionByProgram.Values.Distinct().ToList();
|
||||
public static IReadOnlyList<string> ManualProfessions() => Professions.All();
|
||||
|
||||
// --- Policy questions (geldigheidsvragen) ---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user