Implement US-10 selected-context insights and final rounding
This commit is contained in:
1 parent
d21005b6fe
commit
a0a9e2e9b9
11 files changed
+314
-18
No files matched your search
+31
-2
@@ -190,11 +190,40 @@ US-08 tests cover the original full numerical corrections and rejection scenario
|
||||
|
||||
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.
|
||||
|
||||
`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; averages retain fractional values without deliberate rounding. An empty period returns `404` problem details with title `Insufficient observation data for calculation.` Missing/malformed/reversed bounds return `400`.
|
||||
`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`.
|
||||
|
||||
The independent Insights Service follows the documented controller/application-service/calculator/client design. Its HTTP observation client retrieves history through the configured gateway; there are no production project references between services. Each request recalculates from current observations, so corrections/deletions are reflected immediately. Failed observation retrieval returns `502`, and timeouts return `504`, instead of indicating insufficient data. Gateway requests to an unavailable Insights Service likewise return `502`/`504`.
|
||||
|
||||
US-10 tests use all four HTTP hosts and the existing separate patient/observation test databases. They cover all five acceptance scenarios, fractional averages, patient and inclusive-period filtering, equal/offset bounds, corrections/deletions, restart, malformed/missing periods, and unavailable observation retrieval. Insights introduces no external dependencies. Trend calculation remains outside this story.
|
||||
US-10 supports the same optional `setting` and `activityCondition` selections as
|
||||
history, including explicit `Unknown` and combined matching. For example append
|
||||
`&setting=Home&activityCondition=AtRest`. Omitted/empty selections include all
|
||||
otherwise eligible observations. Unsupported categories return `400` validation
|
||||
details. Selection that leaves no observations returns the existing insufficient-
|
||||
data `404` response. Selection is forwarded through the gateway to the Observation
|
||||
Service; no service implementation is referenced directly.
|
||||
|
||||
Successful insights also include `appliedSelection` (nullable `setting` and
|
||||
`activityCondition` mean unrestricted), `contributingCount`, and
|
||||
`contextExplanation`. The explanation reports recorded setting/activity counts,
|
||||
mixed/unknown categories, missing optional context details and differences in
|
||||
recorded optional details. It describes numerical aggregation without certifying
|
||||
measurement technique, clinical comparability or completion of a diagnostic
|
||||
monitoring protocol. Legacy narrative text is retained by the observation contract
|
||||
but never used to invent categories. Preparation differences are reported as
|
||||
recorded differences, not a clinical classification.
|
||||
|
||||
The rounding contract applies to all three means: seven readings of 120 and one
|
||||
of 121 yield 120.13; 120, 120 and 121 yield 120.33. No intermediate rounding occurs.
|
||||
Single-observation means equal the recorded values, and blood-pressure minimum and
|
||||
maximum are equal. Numeric JSON need not retain trailing zeros. New requests always
|
||||
use current observations/context after corrections, clearing and deletion.
|
||||
|
||||
US-10 tests use all four HTTP hosts and the existing separate patient/observation
|
||||
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.
|
||||
|
||||
US-13 authentication and patient ownership are implemented as described in
|
||||
[AUTHENTICATION.md](AUTHENTICATION.md). The account-to-profile association is persisted
|
||||
|
||||
Reference in new issue
Block a user