feat: add reference values snapshot endpoints and data layer functions
Deploy Development / deploy (push) Successful in 1m3s
Build Test / pytest-backend (push) Successful in 5s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 17s

- Introduced `get_profile_reference_values_current_snapshot` and `get_profile_reference_values_recent_snapshot` functions to retrieve current and recent reference values for profiles.
- Updated the placeholder resolver to include new placeholders for current and recent reference values.
- Added new API endpoints for fetching current and recent reference values snapshots.
- Enhanced the frontend API utility to support the new snapshot endpoints.
- Improved unit tests to validate the new data layer functions and their behavior.
This commit is contained in:
Lars committed 2026-04-19 10:52:31 +02:00
1 parent df0165bee3
commit 42ae796448
7 files changed
+359 -1

No files matched your search

@@ -1,6 +1,9 @@
"""Unit tests for data_layer.reference_values (summary assembly, no DB)."""
from data_layer.reference_values import build_summary_tiles_from_ranked_rows
from datetime import date
from decimal import Decimal
from data_layer.reference_values import _entry_dict_from_ranked_row, build_summary_tiles_from_ranked_rows
def test_build_summary_tiles_single_type_two_rows():
@@ -46,3 +49,27 @@ def test_build_summary_tiles_multi_type_order():
]
tiles = build_summary_tiles_from_ranked_rows(raw)
assert [x["type_key"] for x in tiles] == ["a", "b"]
def test_entry_dict_from_ranked_row_normalizes_decimal():
row = {
"id": 1,
"profile_id": "p",
"reference_value_type_id": 9,
"effective_date": date(2026, 4, 1),
"value_numeric": Decimal("42.5"),
"value_text": None,
"unit": "bpm",
"source": "lab",
"confidence": "high",
"method": "spiro",
"notes": None,
"extra": None,
"created_at": date(2026, 4, 2),
"updated_at": date(2026, 4, 2),
"type_key": "hr_max",
"type_label": "HF max",
}
out = _entry_dict_from_ranked_row(row)
assert out["value_numeric"] == 42.5
assert out["effective_date"] == "2026-04-01"