Implement US-11 context-aware health trend assessments

This commit is contained in:
Steffen committed 2026-10-05 13:51:16 +02:00
1 parent a0a9e2e9b9
commit cc76c9bde4
9 files changed
+802 -7

No files matched your search

+13 -6
View File
@@ -181,14 +181,13 @@ retains its complete numerical-correction contract and rejects unsupported field
rather than silently ignoring context supplied on that route. Use `PATCH` for context
updates. Both routes use the same
Observation-owned update operation and save changes atomically. Subsequent reads,
latest observations and filtered history use current recorded context. US-11 trend
integration remains to be verified when that endpoint is implemented.
latest observations and filtered history use current recorded context. US-11 trend assessments also use current recorded context on each request.
US-08 tests cover the original full numerical corrections and rejection scenarios plus context-only/single-value patches, historical context additions, individual field corrections/clears, whole-context clearing, preservation of omitted data and creation time, persistence after restart, fresh filter membership, atomic rejection, missing observations and access restrictions. No new dependencies are introduced.
`DELETE /api/observations/{observationId}` removes the observation and returns `204 No Content`. A missing or previously deleted observation returns `404`. The Observation Service deletes the row from its own database in a single statement; deleted observations disappear from specific retrieval, history, and latest selection. Other observations and the patient profile are preserved.
US-09 tests cover the original deletion scenarios plus structured-context removal, filtered history after restart, current numerical summaries excluding deleted values, preservation of other observations and their context, empty filtered results, repeated deletion, and rejection of unauthenticated/other-patient/professional deletion. Context is stored in the observation row, so its existing atomic deletion needs no new production operation. US-11 trend-specific deletion checks remain to be added with that endpoint. No new dependencies or schema changes are required.
US-09 tests cover the original deletion scenarios plus structured-context removal, filtered history after restart, current numerical summaries excluding deleted values, preservation of other observations and their context, empty filtered results, repeated deletion, and rejection of unauthenticated/other-patient/professional deletion. Context is stored in the observation row, so its existing atomic deletion needs no new production operation. US-11 tests verify fresh trends after deletion. No new dependencies or schema changes are required.
`GET /api/patients/{patientId}/insights?from=2026-09-03T00:00:00&to=2026-09-08T23:59:59` returns `200` with `patientId`, `periodStart`, `periodEnd`, decimal `averageSystolic`, `averageDiastolic`, `averagePulse`, and integer `minSystolic`, `maxSystolic`, `minDiastolic`, `maxDiastolic`. Period validation, inclusive bounds, and timestamp normalization follow observation history. A single observation is sufficient. Arithmetic means use decimal calculations and round only the final result to two decimal places, half-up (away from zero for the positive recorded values); extrema retain their recorded integer values. An empty period returns `404` problem details with title `Insufficient observation data for calculation.` Missing/malformed/reversed bounds return `400`.
@@ -223,13 +222,21 @@ test databases. They cover original summaries, independent/combined/unknown
selections, applied selections and counts, context explanations, one-observation
results, halfway/repeating rounding for all three metrics, patient/inclusive/equal/
offset bounds, context corrections/clearing/deletions, restart, invalid requests,
professional assignments and unavailable observation retrieval. Insights introduces no external dependencies. Trend calculation remains outside this story.
professional assignments and unavailable observation retrieval. Insights introduces no external dependencies. US-11 adds the separate trend endpoint described in [TRENDS.md](TRENDS.md).
`GET /api/patients/{patientId}/trends?from=...&to=...` implements US-11 with independent
systolic, diastolic and pulse assessments, context selections/counts, recorded comparability,
full-period numerical direction, reversals and variation, sourced reference comparisons and
limited clinical interpretation. Empty/single/tied series report unavailable temporal direction;
numerical information remains where supported. See [TRENDS.md](TRENDS.md) for the response,
reproducible mathematical methods, reference sources and interpretation limits. Tests cover
all US-11 acceptance criteria, current corrections/context/deletion, access controls and failures.
No persistence, service boundaries, dependencies or configuration changed.
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
writes are rejected. Updated context, tie
and rounding requirements in other stories remain to be implemented incrementally.
writes are rejected. US-04 through US-11 include updated context, ordering, rounding and trend requirements.
## Automated acceptance tests