File size: 826 Bytes
21c7db9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""Rule-only baseline."""

from __future__ import annotations

from app.common.enums import ActionType, DecisionMode, DoseBucket
from app.common.types import CandidateAction, PolyGuardAction


def choose_rules_only(candidates: list[CandidateAction]) -> PolyGuardAction:
    ranked = sorted(candidates, key=lambda c: (c.legality_precheck, c.estimated_safety_delta), reverse=True)
    top = ranked[0]
    return PolyGuardAction(
        mode=top.mode,
        action_type=top.action_type,
        target_drug=top.target_drug,
        replacement_drug=top.replacement_drug,
        dose_bucket=top.dose_bucket,
        taper_days=top.taper_days,
        monitoring_plan=top.monitoring_plan,
        candidate_id=top.candidate_id,
        confidence=0.75,
        rationale_brief="Rules-only selected top legal candidate.",
    )