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

+22 -3
View File
@@ -1,6 +1,6 @@
# Patient profiles, observations, insights and authentication
# Patient profiles, observations, insights, overview and authentication
Implemented with .NET 10 LTS (see the [official download page](https://dotnet.microsoft.com/en-us/download/dotnet/10.0)), ASP.NET Core controllers, and PostgreSQL/EF Core. The API gateway, Patient/Profile service, Observation Service, and Insights Service are separate executables and can run on separate machines. Patient/Profile and Observation each own a database. Insights calculates on demand without persistence, following `Docs/Architecture/us10-insights-correction.md`.
Implemented with .NET 10 LTS (see the [official download page](https://dotnet.microsoft.com/en-us/download/dotnet/10.0)), ASP.NET Core controllers, and PostgreSQL/EF Core. The API gateway, Patient/Profile service, Observation Service, Insights Service, and Health Overview Service are separate executables and can run on separate machines. Patient/Profile and Observation each own a database. Insights calculates on demand without persistence, following `Docs/Architecture/us10-insights-correction.md`.
The controller calls `PatientApplicationService`, which uses `PatientRepository`, implemented by `SqlPatientRepository`. The service owns the `patient` table from the ER diagram, including creation/update timestamps stored as UTC in PostgreSQL `timestamp` columns.
@@ -28,7 +28,7 @@ dotnet run --project src/PatientProfileService -c Release --no-build -- --migrat
ASPNETCORE_URLS=http://127.0.0.1:5081 dotnet run --project src/PatientProfileService -c Release --no-build
# In a separate gateway terminal.
Services__PatientProfile__BaseUrl=http://127.0.0.1:5081/ Services__Observation__BaseUrl=http://127.0.0.1:5082/ Services__Insights__BaseUrl=http://127.0.0.1:5083/ ASPNETCORE_URLS=http://127.0.0.1:5080 dotnet run --project src/ApiGateway -c Release --no-build
Services__PatientProfile__BaseUrl=http://127.0.0.1:5081/ Services__Observation__BaseUrl=http://127.0.0.1:5082/ Services__Insights__BaseUrl=http://127.0.0.1:5083/ Services__HealthOverview__BaseUrl=http://127.0.0.1:5084/ ASPNETCORE_URLS=http://127.0.0.1:5080 dotnet run --project src/ApiGateway -c Release --no-build
# In a separate observation terminal, with its own provisioned database.
export ConnectionStrings__ObservationDatabase='Host=127.0.0.1;Database=observations;Username=observations;Password=YOUR_LOCAL_PASSWORD'
@@ -37,6 +37,9 @@ Services__ApiGateway__BaseUrl=http://127.0.0.1:5080/ ASPNETCORE_URLS=http://127.
# In a separate insights terminal; no database or migration is required.
Services__ApiGateway__BaseUrl=http://127.0.0.1:5080/ ASPNETCORE_URLS=http://127.0.0.1:5083 dotnet run --project src/InsightsService -c Release --no-build
# In a separate overview terminal; no database or migration is required.
Services__ApiGateway__BaseUrl=http://127.0.0.1:5080/ ASPNETCORE_URLS=http://127.0.0.1:5084 dotnet run --project src/HealthOverviewService -c Release --no-build
```
`--migrate` applies committed EF Core migrations and exits. Apply migrations as a deployment step before starting the service; normal startup does not modify the schema. Both services fail startup with a clear message if required configuration is absent. Configuration uses standard .NET JSON files, environment variables, and command-line arguments. Service endpoints and database hosts may be remote.
@@ -233,6 +236,14 @@ reproducible mathematical methods, reference sources and interpretation limits.
all US-11 acceptance criteria, current corrections/context/deletion, access controls and failures.
No persistence, service boundaries, dependencies or configuration changed.
`GET /api/patients/{patientId}/overview?from=...&to=...` implements US-12 in the
independently deployable Health Overview Service. It returns the current profile,
latest overall observation with its own recorded context, and selected-period numerical
insight. Setting/activity filters apply to insight only. Empty insight selections keep
the profile and latest reading and explain the missing insight. Context limitations,
applied selections and counts remain visible. See [OVERVIEW.md](OVERVIEW.md) for
response semantics, service credentials, deployment and consistency limits.
US-13 authentication and patient ownership are implemented as described in
[AUTHENTICATION.md](AUTHENTICATION.md). The account-to-profile association is persisted
in the patient service. US-14 professional reads require predefined gateway assignments; professional
@@ -293,6 +304,7 @@ dotnet publish src/PatientProfileService -c Release -o /tmp/healthapp-publish/pa
dotnet publish src/ApiGateway -c Release -o /tmp/healthapp-publish/api-gateway
dotnet publish src/ObservationService -c Release -o /tmp/healthapp-publish/observation
dotnet publish src/InsightsService -c Release -o /tmp/healthapp-publish/insights
dotnet publish src/HealthOverviewService -c Release -o /tmp/healthapp-publish/health-overview
```
Copy each output to its corresponding `/opt/healthapp/` directory on the intended host, install the ASP.NET Core 10 runtime, and create a `healthapp` service user/group. Adjust the paths/user in `deploy/systemd/*.service` for the host. Copy the environment examples to `/etc/healthapp/patient-profile.env` and `/etc/healthapp/api-gateway.env`, replace example values, and restrict their permissions to protect credentials. Configure the gateway certificate for the HTTPS client entry point. Its example uses a PFX certificate; standard Kestrel configuration also supports other certificate formats.
@@ -309,3 +321,10 @@ Install the corresponding unit on each host and enable/start it with systemd. Th
The Observation Service has its own `healthapp-observation.service` unit and environment example. Configure its `Services__ApiGateway__BaseUrl` and the gateway's `Services__Observation__BaseUrl` for the deployed hosts. Apply its migration with its own database configuration. Services need not be started in a fixed order; requests needing an unavailable upstream fail without saving observations.
The Insights Service has an independent `healthapp-insights.service` systemd unit and `deploy/insights.env.example`. Install its published output under `/opt/healthapp/insights`, configure `/etc/healthapp/insights.env`, and set `Services__ApiGateway__BaseUrl` to the deployed gateway. Configure the gateway's required `Services__Insights__BaseUrl` for the deployed Insights host. URLs may refer to separate machines. Insights requires no database, migration, startup ordering, or shared process state. Standard stdout/stderr logging, graceful shutdown, and restart follow the other service units.
The Health Overview Service has its own `healthapp-health-overview.service` unit and
`deploy/health-overview.env.example`. Publish to `/opt/healthapp/health-overview` and
configure `/etc/healthapp/health-overview.env`. Set its `Services__ApiGateway__BaseUrl`
and the gateway's `Services__HealthOverview__BaseUrl` to the deployed hosts. The
gateway now requires the Overview endpoint and both directions of service credentials.
Overview owns no database and requires no migrations or fixed startup order.