-
Notifications
You must be signed in to change notification settings - Fork 1
feat(api): fix csv parsing logic and ensure feature/ai randomization #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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 fixes the CSV parsing and display configuration logic for the API while introducing a new configuration generation script to support case assignment and randomization. Key changes include updates to type annotations and refactored CSV parsing in src/user/utils/csv_parser.py, the addition of load_omop.sh and generate_config.sh scripts for database initialization and config generation, and refactoring of the case service logic in src/cases/service/case_service.py for more robust tree handling.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/user/utils/csv_parser.py | Updates CSV parser with improved type hints and bucket-based processing. |
| src/load_omop.sh | Adds a new script for force-reloading OMOP vocabulary and clinical data. |
| src/cases/service/case_service.py | Refactors building and pruning of case detail tree nodes with enhanced docstrings. |
| script/assign_cases/generate_config.sh | Introduces a config generation script for case assignments with randomization. |
| page_config.json | Adds a JSON file for page configuration. |
| answer_config.json | Adds a JSON configuration for answer forms. |
Comments suppressed due to low confidence (1)
page_config.json:2
- The key 'Background' in page_config.json is inconsistent with the expected uppercase 'BACKGROUND' used in the code. Consider renaming it to 'BACKGROUND' to maintain consistency.
"Background": { "concept_ids": [] }
| # aimaheaddev \ | ||
| # aim_ahead \ | ||
| # 6 \ | ||
| # 20 10 \ |
Copilot
AI
Jun 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The example command line arguments for <cases_per_user> and <ai_per_user> ('20 10') are ambiguous. Please clarify the separation between these two parameters in the documentation.
There was a problem hiding this 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 updates CSV handling and case assignment logic, adds scripts for configuration and OMOP loading, and refactors case review to support randomized features and styles.
- Enhanced
CsvConfigurationParserto bucket rows by (user, case) and build style dictionaries. - Refactored
case_serviceto prune case details per display config and include AI CRC risk entries. - Added
generate_config.shfor CSV config generation andload_omop.shfor OMOP data loading.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/user/utils/csv_parser.py | Rewrote parser to group rows, validate headers, and apply styles |
| src/cases/service/case_service.py | Refactored case review workflow to prune tree and merge styles |
| script/assign_cases/generate_config.sh | New script to generate randomized CSV of user-case-feature rows |
| src/load_omop.sh | New script to load OMOP vocabulary and clinical data into PostgreSQL |
| page_config.json | Initial JSON stub for page configuration |
| answer_config.json | New JSON schema for answer form configuration |
Comments suppressed due to low confidence (4)
src/cases/service/case_service.py:350
- The code calls
itemgetterbut it is not imported. Please addfrom operator import itemgetterat the top.
important_infos.sort(key=itemgetter("weight"))
src/cases/service/case_service.py:269
- The code uses
defaultdictbut there is no import for it. Please addfrom collections import defaultdictat the top.
parent_to_entries: dict[str, list[dict]] = defaultdict(list)
page_config.json:2
- JSON keys like
"Background"do not match the uppercase section names (e.g.,"BACKGROUND") expected by the code. Update the keys to match exactly.
"Background": { "concept_ids": [] },
script/assign_cases/generate_config.sh:57
- The script assumes exactly eight positional arguments without checking
$#. Add a check for the required argument count and print usage on mismatch.
DB_HOST="$1"
PR #1 -
fix csv parsing logic and ensure feature/ai randomizationThis PR #1 does the following:
config.csvgeneration Shell script (underscript/assign_cases/generate_config.sh. Running this script will generate theconfig.csvcompatible with our new backend, which includes case feature randomization logic..csvfile structure and make sure that the randomization logic in the.csvfile is respected. (To achieve the requested feature where only certain case features, likeMEDICAL_HISTORY.Hypertension, are displayed. Each feature now has a ~50% chance of being selected for any particular case).load_omop.shscript that will automatically load OMOP files (not super important - but it'll help other developers get started with the platform and database real quick!)The app now looks like: