Skip to content

Conversation

@hoangsonww
Copy link
Member

This PR adjusts AI risk score display to correctly preserve the randomization logic (so ~50% of case actually has the risk score).

@hoangsonww hoangsonww requested a review from Copilot June 7, 2025 04:40
@hoangsonww hoangsonww self-assigned this Jun 7, 2025
Copy link

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 refines how the AI CRC risk score is surfaced by prioritizing a literal CSV-provided value, falling back to database observations, and removing default “N/A” when no reference exists.

  • Tracks whether CSV provided a literal CRC score or just toggled the section
  • Fetches and renames observations when only toggled
  • Omits the CRC score node entirely if CSV had no relevant entries
Comments suppressed due to low confidence (5)

src/cases/service/case_service.py:297

  • [nitpick] The variable name csv_crc_score_leaf could be clearer about its role as the literal score text. Consider renaming it to something like csv_literal_crc_score_text for better readability.
csv_crc_score_leaf: str | None = None

src/cases/service/case_service.py:298

  • [nitpick] Consider renaming old_crc_toggle to a more descriptive name such as crc_section_toggle or csv_crc_section_toggle to clarify that it represents whether the CSV toggled the CRC risk section.
old_crc_toggle = False

src/cases/service/case_service.py:370

  • Add unit tests covering the new branches: when a literal CSV score is provided (csv_crc_score_leaf), when only the toggle is set (old_crc_toggle), and when neither flag is present to confirm no CRC node is appended.
if csv_crc_score_leaf:

src/cases/service/case_service.py:377

  • Extract the magic number 45614722 into a named constant (e.g., CRC_CONCEPT_ID) to avoid hard-coded values and improve maintainability.
[45614722]

src/cases/service/case_service.py:409

  • [nitpick] The docstring lists six steps, but this inline comment labels step 7. Consider aligning the numbering between the docstring and inline comments to avoid confusion.
# --- 7) Return the assembled Case object ---

@hoangsonww hoangsonww merged commit c8338a9 into main Jun 7, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants