Preserve Temperature in Vitals Flow and Add Help Area
Issue: Preserve Temperature in Vitals Flow and Add Help Area
Summary
Temperature values submitted through the vitals API should be saved and returned consistently across vitals create, update, and history flows. The application should also support help as a designated area so users can be assigned to the help station.
Problem
The vitals model/schema supports temperature, but parts of the route and service layer do not consistently pass the field through. As a result, a temperature value submitted by the client can be dropped before persistence or omitted from responses.
The designated area enum also needs to include a help area so the area workflow can represent help desk assignments.
Expected Behavior
- When vitals are created with
temperature, the value is saved. - When vitals are updated with
temperature, the value is saved. - Vitals API responses include the saved
temperature. - Vitals history includes
temperature. - Missing temperature values are returned as
null. - The designated area list includes
help. - Area assignment/change logic accepts
helpas a valid area.
Scope
- Update patient vitals route mapping.
- Update patient vitals service create/update/history mapping.
- Include
temperaturein logging payloads for vitals updates. - Add
helpto the designated area enum. - Update focused tests for vitals temperature and designated areas.
Acceptance Criteria
-
PUT /patients/vitals/{book_no}acceptstemperature. -
Submitted temperatureis passed from the API route into the service layer. -
create_vitalstorestemperatureonPatientVisitDetails. -
update_vitalupdatestemperatureonPatientVisitDetails. -
Vitals response models return temperature. -
Vitals history returns temperature. -
Vitals history returns temperature=nullwhen no temperature is recorded. -
DesignatedAreaincludeshelp. -
Area list/order tests include help. -
Focused tests are added or updated for the above behavior.
Suggested Test Coverage
| Scenario | Expected Result |
|---|---|
| Update vitals API receives temperature | Service payload contains temperature
|
| Create vitals for existing visit | Response includes submitted temperature |
| Create vitals for new visit details | Constructor receives temperature |
| Vitals history includes temperature | History response maps stored value to float |
| Vitals history has no temperature | History response returns temperature=None
|
| Update existing vitals | Response includes updated temperature |
| Designated area enum values are checked |
help is present |
| Area list is returned |
help is included |
Validation Steps
-
Apply migrations:
alembic upgrade head -
Run focused tests:
uv run pytest tests/test_api/test_patient_routes.py tests/test_api/test_stations_routes.py tests/test_enums/test_designated_area.py tests/test_services/test_patient_service.py -q -
Manually validate vitals update:
curl -X PUT "http://localhost:8000/api/v1/patients/vitals/<book_no>" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer <token>" \ -d '{"bp_manual":"120/80","pulse":72,"heart_rate":72,"temperature":98.6}' -
Confirm the response includes:
{ "temperature": 98.6 } -
Confirm vitals history for the same patient includes the recorded temperature.
Related Files
app/api/v1/routes/patient_routes.pyapp/services/patient_service.pyapp/enums/designated_area.pyapp/api/v1/routes/areas_routes.pytests/test_api/test_patient_routes.pytests/test_api/test_stations_routes.pytests/test_enums/test_designated_area.pytests/test_services/test_patient_service.pyalembic/versions/c331978e5e64_add_temperature_column_to_vitals.py
Notes
- Temperature database support exists through the Alembic migration
c331978e5e64_add_temperature_column_to_vitals.py. - This issue should be implemented without changing existing vitals behavior for BP, RBS, SPO2, height, weight, pulse, heart rate, or extra notes.