Cardiosense-AG commited on
Commit
2746cd5
·
verified ·
1 Parent(s): 928de46

Update src/prompt_builder.py

Browse files
Files changed (1) hide show
  1. src/prompt_builder.py +3 -5
src/prompt_builder.py CHANGED
@@ -1,4 +1,3 @@
1
- # src/prompt_builder.py
2
  from __future__ import annotations
3
  import json
4
  import re
@@ -36,7 +35,7 @@ def _safe_json_extract(text: str) -> Dict[str, Any]:
36
  def build_referral_summary(intake: Dict[str, Any]) -> str:
37
  """
38
  Canonical, MedGemma-friendly referral summary used for all generations.
39
- This ensures consistent input formatting between PCP and Specialist.
40
  """
41
  c = (intake or {}).get("consult", {}) or {}
42
  p = (intake or {}).get("patient", {}) or {}
@@ -48,7 +47,7 @@ def build_referral_summary(intake: Dict[str, Any]) -> str:
48
  if isinstance(meds, str):
49
  meds = [m.strip() for m in meds.split(",") if m.strip()]
50
 
51
- lines = [
52
  patient_header = f"Patient: {p.get('name','')}"
53
  age_val = str(p.get("age_years", "")).strip()
54
  if age_val != "":
@@ -65,13 +64,12 @@ def build_referral_summary(intake: Dict[str, Any]) -> str:
65
  f"Medications: {', '.join(meds)}",
66
  ]
67
 
68
- return "\n".join(lines).strip()
69
 
70
 
71
  def chat_to_structured(chat_msgs: List[Dict[str, str]]) -> Dict[str, Any]:
72
  """
73
  Convert a PCP chat thread into structured fields suitable for intake.
74
-
75
  🚧 For stability (avoids meta-tensor / GPU initialization errors),
76
  LLM summarization via generate_chat() is currently disabled.
77
  This uses a deterministic heuristic to capture the last message
 
 
1
  from __future__ import annotations
2
  import json
3
  import re
 
35
  def build_referral_summary(intake: Dict[str, Any]) -> str:
36
  """
37
  Canonical, MedGemma-friendly referral summary used for all generations.
38
+ Ensures consistent input formatting between PCP and Specialist.
39
  """
40
  c = (intake or {}).get("consult", {}) or {}
41
  p = (intake or {}).get("patient", {}) or {}
 
47
  if isinstance(meds, str):
48
  meds = [m.strip() for m in meds.split(",") if m.strip()]
49
 
50
+ # ---- Header (Age preferred, MRN/DOB removed) ----
51
  patient_header = f"Patient: {p.get('name','')}"
52
  age_val = str(p.get("age_years", "")).strip()
53
  if age_val != "":
 
64
  f"Medications: {', '.join(meds)}",
65
  ]
66
 
67
+ return "\n".join(lines).strip()
68
 
69
 
70
  def chat_to_structured(chat_msgs: List[Dict[str, str]]) -> Dict[str, Any]:
71
  """
72
  Convert a PCP chat thread into structured fields suitable for intake.
 
73
  🚧 For stability (avoids meta-tensor / GPU initialization errors),
74
  LLM summarization via generate_chat() is currently disabled.
75
  This uses a deterministic heuristic to capture the last message