Spaces:
Sleeping
Sleeping
Add detailed handling for HIV coinfection in treatment eligibility prompts
Browse files- core/assessment_chain.py +14 -6
core/assessment_chain.py
CHANGED
|
@@ -472,6 +472,14 @@ def assemble_llm_prompt(patient_data: Dict[str, Any]) -> Dict[str, Any]:
|
|
| 472 |
has_hcv = "HCV" in [c.upper() for c in coinfections] if coinfections else False
|
| 473 |
has_hdv = "HDV" in [c.upper() for c in coinfections] if coinfections else False
|
| 474 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 475 |
# Build analysis prompt with mandatory eligibility decision tree
|
| 476 |
analysis_prompt = f"""You are an expert hepatologist providing HBV treatment eligibility assessments based on SASLT 2021 guidelines.
|
| 477 |
|
|
@@ -594,13 +602,13 @@ Use \\n for line breaks (NOT literal newlines). Format as follows:
|
|
| 594 |
|
| 595 |
**Patient Summary**\\n
|
| 596 |
- Brief age, sex, key clinical parameters (3-5 bullets max)\\n
|
| 597 |
-
{
|
| 598 |
\\n
|
| 599 |
**Treatment Eligibility Analysis**\\n
|
| 600 |
\\n
|
| 601 |
*Absolute Indications Check (Priority):*\\n
|
| 602 |
-
{
|
| 603 |
-
{
|
| 604 |
- Cirrhosis (F4): [Check and mark β
or β]\\n
|
| 605 |
- Immunosuppression: [Check and mark β
or β]\\n
|
| 606 |
- Pregnancy with high viral load: [Check and mark β
or β]\\n
|
|
@@ -620,7 +628,7 @@ Use \\n for line breaks (NOT literal newlines). Format as follows:
|
|
| 620 |
\\n
|
| 621 |
*Rationale:*\\n
|
| 622 |
- Clearly state the PRIMARY reason for eligibility decision\\n
|
| 623 |
-
{
|
| 624 |
- Which specific SASLT criterion/criteria apply\\n
|
| 625 |
- Grade of recommendation (A, B, C, or D)\\n
|
| 626 |
\\n
|
|
@@ -629,7 +637,7 @@ Use \\n for line breaks (NOT literal newlines). Format as follows:
|
|
| 629 |
\\n
|
| 630 |
*Management Approach:*\\n
|
| 631 |
\\n
|
| 632 |
-
{
|
| 633 |
**If ELIGIBLE (Standard Criteria):**\\n
|
| 634 |
- Preferred agents: Entecavir (ETV), Tenofovir (TDF), or Tenofovir Alafenamide (TAF) [SASLT 2021, Page 8, Grade A]\\n
|
| 635 |
- Monitor HBV DNA and ALT at 3, 6, 12 months, then every 6-12 months\\n
|
|
@@ -640,7 +648,7 @@ Use \\n for line breaks (NOT literal newlines). Format as follows:
|
|
| 640 |
\\n
|
| 641 |
*Final Recommendation:*\\n
|
| 642 |
- Concise summary statement (2-3 sentences)\\n
|
| 643 |
-
{
|
| 644 |
- Emphasize key decision factors\\n
|
| 645 |
|
| 646 |
Return ONLY the JSON object, nothing else."""
|
|
|
|
| 472 |
has_hcv = "HCV" in [c.upper() for c in coinfections] if coinfections else False
|
| 473 |
has_hdv = "HDV" in [c.upper() for c in coinfections] if coinfections else False
|
| 474 |
|
| 475 |
+
# Define strings with backslashes for f-string compatibility
|
| 476 |
+
hiv_critical_line = "- **CRITICAL: HIV coinfection present - absolute treatment indication**\\n"
|
| 477 |
+
hiv_absolute_indication = "- β
**HBV-HIV coinfection: ABSOLUTE INDICATION** [SASLT 2021, Page 9, Grade A]\\n"
|
| 478 |
+
no_hiv_line = "- β No HIV coinfection\\n"
|
| 479 |
+
hiv_rationale_line = "- If HIV coinfection: State this is an absolute Grade A indication that overrides all other criteria\\n"
|
| 480 |
+
hiv_treatment_section = "**HBV-HIV Coinfection Treatment (Grade A):**\\n- All HIV-positive patients with HBV coinfection should start ART immediately, irrespective of CD4 count [SASLT 2021, Page 9]\\n- Regimen MUST include TDF or TAF (preferably TAF for better renal/bone safety) [SASLT 2021, Page 9]\\n- Include Emtricitabine or Lamivudine as part of ART regimen\\n- Monitor for immune reconstitution syndrome (may cause HBV flare in first 3-6 months)\\n- HBV DNA and ALT at 3, 6, 12 months, then every 6-12 months\\n- HIV viral load every 3-6 months\\n- Annual HCC surveillance (ultrasound Β± AFP)\\n\\n"
|
| 481 |
+
hiv_final_recommendation = "- **Emphasize that HIV coinfection makes treatment mandatory regardless of other parameters**\\n"
|
| 482 |
+
|
| 483 |
# Build analysis prompt with mandatory eligibility decision tree
|
| 484 |
analysis_prompt = f"""You are an expert hepatologist providing HBV treatment eligibility assessments based on SASLT 2021 guidelines.
|
| 485 |
|
|
|
|
| 602 |
|
| 603 |
**Patient Summary**\\n
|
| 604 |
- Brief age, sex, key clinical parameters (3-5 bullets max)\\n
|
| 605 |
+
{hiv_critical_line if has_hiv else ""}
|
| 606 |
\\n
|
| 607 |
**Treatment Eligibility Analysis**\\n
|
| 608 |
\\n
|
| 609 |
*Absolute Indications Check (Priority):*\\n
|
| 610 |
+
{hiv_absolute_indication if has_hiv else ""}
|
| 611 |
+
{no_hiv_line if not has_hiv else ""}
|
| 612 |
- Cirrhosis (F4): [Check and mark β
or β]\\n
|
| 613 |
- Immunosuppression: [Check and mark β
or β]\\n
|
| 614 |
- Pregnancy with high viral load: [Check and mark β
or β]\\n
|
|
|
|
| 628 |
\\n
|
| 629 |
*Rationale:*\\n
|
| 630 |
- Clearly state the PRIMARY reason for eligibility decision\\n
|
| 631 |
+
{hiv_rationale_line if has_hiv else ""}
|
| 632 |
- Which specific SASLT criterion/criteria apply\\n
|
| 633 |
- Grade of recommendation (A, B, C, or D)\\n
|
| 634 |
\\n
|
|
|
|
| 637 |
\\n
|
| 638 |
*Management Approach:*\\n
|
| 639 |
\\n
|
| 640 |
+
{hiv_treatment_section if has_hiv else ""}
|
| 641 |
**If ELIGIBLE (Standard Criteria):**\\n
|
| 642 |
- Preferred agents: Entecavir (ETV), Tenofovir (TDF), or Tenofovir Alafenamide (TAF) [SASLT 2021, Page 8, Grade A]\\n
|
| 643 |
- Monitor HBV DNA and ALT at 3, 6, 12 months, then every 6-12 months\\n
|
|
|
|
| 648 |
\\n
|
| 649 |
*Final Recommendation:*\\n
|
| 650 |
- Concise summary statement (2-3 sentences)\\n
|
| 651 |
+
{hiv_final_recommendation if has_hiv else ""}
|
| 652 |
- Emphasize key decision factors\\n
|
| 653 |
|
| 654 |
Return ONLY the JSON object, nothing else."""
|