Skip to content

Timeline instances#43

Merged
pendingintent merged 17 commits intomasterfrom
timeline-instances
Dec 19, 2025
Merged

Timeline instances#43
pendingintent merged 17 commits intomasterfrom
timeline-instances

Conversation

@pendingintent
Copy link
Owner

Added ScheduledActivityInstance
Changed database column from raw_header to label
Fixed all tests to remvoe references to visit.raw_header

Copilot AI review requested due to automatic review settings December 19, 2025 18:37
@pendingintent pendingintent self-assigned this Dec 19, 2025
@pendingintent pendingintent added bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request labels Dec 19, 2025
@pendingintent pendingintent added this to the v1.2-beta milestone Dec 19, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_header to label throughout all database schemas, API endpoints, and test fixtures
  • Added comprehensive instance management with CRUD operations, audit trails, and UI templates
  • Enhanced visit records with description and encounter_uid fields

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>
Copilot AI review requested due to automatic review settings December 19, 2025 18:41
pendingintent and others added 4 commits December 19, 2025 13:41
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>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"]
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
new_label = payload.label if payload.label is not None else before["label"]

Copilot uses AI. Check for mistakes.
Comment on lines +118 to +122
"""
next_n = 1
while next_n in used_nums:
next_n += 1
"""
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
"""
next_n = 1
while next_n in used_nums:
next_n += 1
"""

Copilot uses AI. Check for mistakes.
Comment on lines 3029 to 3030
'''@app.delete("/soa/{soa_id}/visits/{visit_id}")
def delete_visit(soa_id: int, visit_id: int):
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines 4014 to 4015
'''
"""Create a visit (UI form).
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +5737 to +5738
'''
def ui_delete_visit(request: Request, soa_id: int, visit_id: int):
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove commented-out duplicate function definition (lines 5737-5756). The active implementation exists above on lines 5718-5734.

Copilot uses AI. Check for mistakes.
spelling

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings December 19, 2025 18:43
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +4 to +6
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.
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation alignment is inconsistent. The continuation lines (3-6) should align with the opening quote, not be indented further with leading spaces.

Suggested change
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.

Copilot uses AI. Check for mistakes.


@app.delete("/soa/{soa_id}/visits/{visit_id}")
'''@app.delete("/soa/{soa_id}/visits/{visit_id}")
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines 4014 to 4015
'''
"""Create a visit (UI form).
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings December 19, 2025 18:45
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +3 to +4
- 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.
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'remvoe' to 'remove' in the PR description.

Copilot uses AI. Check for mistakes.
Comment on lines +88 to +89
# cur.execute("SELECT COUNT(*) FROM visit WHERE soa_id=?", (soa_id,))
# order_index = cur.fetchone()[0] + 1
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
# cur.execute("SELECT COUNT(*) FROM visit WHERE soa_id=?", (soa_id,))
# order_index = cur.fetchone()[0] + 1

Copilot uses AI. Check for mistakes.
@pendingintent pendingintent merged commit 6c05141 into master Dec 19, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants