Conversation
…d not use the first gap
There was a problem hiding this comment.
Pull request overview
This PR renames the database column from raw_header to label across the codebase and introduces a new "Scheduled Activity Instances" feature for managing timeline instances within the Schedule of Activities (SoA) builder.
Key Changes
- Renamed
raw_headertolabelthroughout all database schemas, API endpoints, and test fixtures - Added comprehensive instance management with CRUD operations, audit trails, and UI templates
- Enhanced visit records with
descriptionandencounter_uidfields
Reviewed changes
Copilot reviewed 29 out of 29 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| validate_soa.py | Updated derive_nominal_day to use 'label' instead of 'raw_header' |
| tests/test_web_api.py | Changed test fixture to use 'label' field |
| tests/test_ui_visit_create.py | Updated UI test to use 'label' parameter |
| tests/test_ui_set_visit_epoch.py | Updated visit creation test with 'label' |
| tests/test_instances_audit.py | New comprehensive test for instance CRUD and audit trail |
| tests/test_deletion.py | Renamed parameter from raw_header to label |
| tests/test_bulk_import.py | Updated bulk import payload to use 'label' |
| tests/conftest.py | Enhanced test isolation with database cleanup utilities |
| src/usdm/generate_scheduled_activity_instances.py | New module to generate USDM-compliant instance exports |
| src/soa_builder/web/utils.py | Added helper functions for encounter and epoch UID lookups |
| src/soa_builder/web/templates/instances.html | New UI template for instance management |
| src/soa_builder/web/templates/freeze_modal.html | Removed raw_header from visit display |
| src/soa_builder/web/templates/edit.html | Updated visit display to use 'label' field |
| src/soa_builder/web/templates/base.html | Added navigation link to instances page |
| src/soa_builder/web/schemas.py | Added InstanceCreate/Update schemas; updated Visit schemas |
| src/soa_builder/web/routers/visits.py | Extensive refactoring: renamed fields, added encounter_uid generation, added delete endpoint |
| src/soa_builder/web/routers/timings.py | Updated UID generation logic and error messages |
| src/soa_builder/web/routers/instances.py | New router with complete instance CRUD operations |
| src/soa_builder/web/migrate_database.py | Added migration for visit label/description columns |
| src/soa_builder/web/initialize_database.py | Updated schema with label, encounter_uid; added instances and related tables |
| src/soa_builder/web/db.py | Enhanced database connection logic with pytest detection |
| src/soa_builder/web/audit.py | Added instance audit recording function |
| src/soa_builder/web/app.py | Integrated instances router; updated all raw_header references to label |
| src/soa_builder/schedule.py | Updated VisitStub dataclass to use 'label' |
| src/soa_builder/normalization.py | Changed Visit dataclass and SQL schema to use 'label' |
| src/soa_builder/cli.py | Updated visit loading to use 'label' key |
| normalize_soa.py | Updated Visit dataclass and build logic for 'label' |
| README_endpoints.md | Updated API documentation to reflect 'label' parameter |
| README.md | Updated documentation describing 'label' column and test database setup |
Comments suppressed due to low confidence (3)
src/soa_builder/web/app.py:1
- Remove large block of commented-out code. This function has been moved to the visits router and is no longer needed here.
from __future__ import annotations
src/soa_builder/web/app.py:1
- Remove large block of commented-out code. This function logic has been replaced with a call to the visits router.
from __future__ import annotations
src/soa_builder/web/app.py:1
- Remove commented-out code. This function has been replaced with an active implementation above.
from __future__ import annotations
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Updated variable reference Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
spelling Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
removed commented-out code Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
removed commented-out code Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
removed commented-out code Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 29 out of 29 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ) | ||
| new_raw_header = new_raw_header.strip() | ||
|
|
||
| new_label = payload.label if payload.label is not None else before["label"] |
There was a problem hiding this comment.
Remove commented-out code. The variable new_name is assigned on line 178 but this commented line suggests there was refactoring. If the strip operation is no longer needed, remove this comment.
| new_label = payload.label if payload.label is not None else before["label"] |
| """ | ||
| next_n = 1 | ||
| while next_n in used_nums: | ||
| next_n += 1 | ||
| """ |
There was a problem hiding this comment.
Remove commented-out code. This appears to be old logic for filling gaps in ID sequences, which has been replaced by the max+1 approach on lines 123-124.
| """ | |
| next_n = 1 | |
| while next_n in used_nums: | |
| next_n += 1 | |
| """ |
src/soa_builder/web/app.py
Outdated
| '''@app.delete("/soa/{soa_id}/visits/{visit_id}") | ||
| def delete_visit(soa_id: int, visit_id: int): |
There was a problem hiding this comment.
Remove large blocks of commented-out code (lines 3029-3065). This delete_visit function has been moved to the visits router, so the old implementation should be removed rather than commented out.
src/soa_builder/web/app.py
Outdated
| ''' | ||
| """Create a visit (UI form). |
There was a problem hiding this comment.
Remove large blocks of commented-out code (lines 4014-4072). This old ui_add_visit implementation has been replaced by calls to the visits router, so the commented code should be deleted.
| ''' | ||
| def ui_delete_visit(request: Request, soa_id: int, visit_id: int): |
There was a problem hiding this comment.
Remove commented-out duplicate function definition (lines 5737-5756). The active implementation exists above on lines 5718-5734.
spelling Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 29 out of 29 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| value of ``SOA_BUILDER_DB`` if set) so local/prod data are never touched. | ||
| - Removes any stale WAL/SHM files at the start of the test session to avoid | ||
| "disk I/O" errors from interrupted runs. |
There was a problem hiding this comment.
The indentation alignment is inconsistent. The continuation lines (3-6) should align with the opening quote, not be indented further with leading spaces.
| value of ``SOA_BUILDER_DB`` if set) so local/prod data are never touched. | |
| - Removes any stale WAL/SHM files at the start of the test session to avoid | |
| "disk I/O" errors from interrupted runs. | |
| value of ``SOA_BUILDER_DB`` if set) so local/prod data are never touched. | |
| - Removes any stale WAL/SHM files at the start of the test session to avoid | |
| "disk I/O" errors from interrupted runs. |
src/soa_builder/web/app.py
Outdated
|
|
||
|
|
||
| @app.delete("/soa/{soa_id}/visits/{visit_id}") | ||
| '''@app.delete("/soa/{soa_id}/visits/{visit_id}") |
There was a problem hiding this comment.
This endpoint is commented out with triple quotes, creating a multi-line string literal instead of a comment. This leaves dead code in the module that will never execute but might confuse readers about whether it's active. Use proper comment syntax (#) or remove the code entirely if it's been replaced by the router implementation.
src/soa_builder/web/app.py
Outdated
| ''' | ||
| """Create a visit (UI form). |
There was a problem hiding this comment.
Similar to the previous issue, large blocks of code are commented out using triple quotes (lines 4014-4072). This creates inactive code that clutters the file. Remove this commented code since the functionality has been moved to the visits_router.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 29 out of 29 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - Forces tests to use a dedicated SQLite file: ``soa_builder_web_tests.db`` (or the | ||
| value of ``SOA_BUILDER_DB`` if set) so local/prod data are never touched. |
There was a problem hiding this comment.
Corrected spelling of 'remvoe' to 'remove' in the PR description.
| # cur.execute("SELECT COUNT(*) FROM visit WHERE soa_id=?", (soa_id,)) | ||
| # order_index = cur.fetchone()[0] + 1 |
There was a problem hiding this comment.
Remove commented-out code on lines 88-89. The old implementation should be removed rather than left as commented code, as the new implementation starting at line 92 is the active approach.
| # cur.execute("SELECT COUNT(*) FROM visit WHERE soa_id=?", (soa_id,)) | |
| # order_index = cur.fetchone()[0] + 1 |
Added ScheduledActivityInstance
Changed database column from raw_header to label
Fixed all tests to remvoe references to visit.raw_header