Files
HealthAppRepository/suggestions/us10-insights-persistence-clarification.md

22 lines
2.4 KiB
Markdown

# US-10 — Clarify Insights persistence
Resolved by `Docs/Requirements/US_10_Correction`: summaries are calculated on demand without persistence. The ER table is an inconsistency, not a deferred requirement. See `Docs/Architecture/us10-insights-correction.md`.
## Documents requiring reconciliation
- `Docs/Architecture/05_class_insights_service.jpg` shows `InsightsController`, `InsightsApplicationService`, `InsightCalculator`, and an HTTP observation client. It shows no summary repository or persistence path.
- `Docs/Architecture/02_microservice_architecture.jpg` assigns databases to Patient/Profile and Observation, but shows no Insights database.
- `Docs/Architecture/09_er_insights_service.jpg` defines a `HealthSummary` table with a primary key, patient identifier, period, calculated values, and generation timestamp.
- US-10 requires calculating averages and minimum/maximum values from observations in a selected period. It does not specify storing or retrieving generated summaries.
The diagrams do not establish whether the ER table must be implemented for US-10 or is intended for later work. Choosing persistence changes the service's deployment, dependencies, configuration, and component responsibilities, so this is not merely an endpoint implementation detail.
## Proposed options, pending user decision
1. Calculate summaries on demand without persistence for US-10. Implement an independent ASP.NET Core Insights Service following the class diagram, obtaining period observations over HTTP through the gateway and returning fresh calculations. The ER table is deferred. This is the smallest implementation satisfying US-10 and automatically reflects corrections/deletions.
2. Persist generated summaries in an Insights-owned PostgreSQL database using EF Core. This requires approval of the database ownership/deployment and persistence components missing from the other diagrams. Clarify whether each request records a fresh summary or reuses a stored one and how corrections/deletions affect stored results.
In either option, preserve service process boundaries, calculate decimal averages and integer extrema, reject invalid periods, indicate insufficient data for an empty observation set, and defer authentication as already authorized. Trend calculation belongs to US-11 and is outside US-10.
No authoritative documents or implementation files have been changed. This suggestion does not authorize either option.