Implement US-12 consolidated health overview service

This commit is contained in:
Steffen committed 2026-10-05 14:36:28 +02:00
1 parent cc76c9bde4
commit 076e675c81
26 files changed
+804 -16

No files matched your search

@@ -21,9 +21,17 @@ public sealed class PatientAccessMiddleware(RequestDelegate next)
if (context.User.IsInRole("Service"))
{
var service = context.User.FindFirstValue(ClaimTypes.NameIdentifier);
var allowed = context.Request.Method == "GET" && segments.Length == (service == "Observation" ? 3 : 4)
&& segments[0] == "api" && segments[1] == "patients" && Guid.TryParse(segments[2], out _)
&& (service == "Observation" || segments[3] == "observations");
var patientRoute = segments.Length >= 3 && segments[0] == "api" && segments[1] == "patients"
&& Guid.TryParse(segments[2], out _);
var allowed = context.Request.Method == "GET" && patientRoute && (service switch
{
"Observation" => segments.Length == 3,
"Insights" => segments.Length == 4 && segments[3] == "observations",
"HealthOverview" => segments.Length == 3 ||
(segments.Length == 4 && segments[3] == "insights") ||
(segments.Length == 5 && segments[3] == "observations" && segments[4] == "latest"),
_ => false
});
if (!allowed) { context.Response.StatusCode = 403; return; }
await next(context);
return;