Ali2206 commited on
Commit
28e1ce8
·
verified ·
1 Parent(s): f6e551c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -22
app.py CHANGED
@@ -98,41 +98,44 @@ def process_patient_data(df: pd.DataFrame) -> Dict[str, Any]:
98
 
99
  def generate_analysis_prompt(patient_data: Dict[str, Any], bookings: List[str]) -> str:
100
  prompt_lines = [
101
- "**Comprehensive Patient Analysis**",
102
- f"Analyzing {len(bookings)} bookings",
103
  "",
104
- "**Key Analysis Points:**",
105
- "- Chronological progression of symptoms",
106
- "- Medication changes and interactions",
107
- "- Diagnostic consistency across providers",
108
- "- Missed diagnostic opportunities",
109
- "- Gaps in follow-up",
 
 
110
  "",
111
- "**Patient Timeline:**"
112
  ]
113
-
114
  for entry in patient_data['timeline']:
115
  if entry['booking'] in bookings:
116
  prompt_lines.append(
117
- f"- {entry['date']}: {entry['form']} - {entry['item']} = {entry['response']} (by {entry['doctor']})"
118
  )
119
-
 
 
 
 
 
 
 
 
 
 
120
  prompt_lines.extend([
121
- "",
122
- "**Medication History:**",
123
- *[f"- {med}: " + " → ".join(
124
- f"{e['date']}: {e['response']}"
125
- for e in entries if e['booking'] in bookings
126
- ) for med, entries in patient_data['medications'].items()],
127
- "",
128
- "**Required Analysis Format:**",
129
  "### Diagnostic Patterns",
130
  "### Medication Analysis",
131
- "### Provider Consistency",
132
  "### Missed Opportunities",
 
133
  "### Recommendations"
134
  ])
135
-
136
  return "\n".join(prompt_lines)
137
 
138
  def chunk_bookings(patient_data: Dict[str, Any]) -> List[List[str]]:
 
98
 
99
  def generate_analysis_prompt(patient_data: Dict[str, Any], bookings: List[str]) -> str:
100
  prompt_lines = [
101
+ "### Patient Clinical Reasoning Task",
 
102
  "",
103
+ "**Instructions for the AI model:**",
104
+ "You are a clinical assistant reviewing the complete timeline of a single patient.",
105
+ "Use the following structured timeline and medication history to identify:",
106
+ "- Missed diagnoses",
107
+ "- Medication errors or inconsistencies",
108
+ "- Lack of follow-up",
109
+ "- Inconsistencies between providers",
110
+ "- Any signs doctors may have overlooked",
111
  "",
112
+ "**Patient History Timeline:**"
113
  ]
114
+
115
  for entry in patient_data['timeline']:
116
  if entry['booking'] in bookings:
117
  prompt_lines.append(
118
+ f"- [{entry['date']}] {entry['form']}: {entry['item']} {entry['response']} ({entry['doctor']})"
119
  )
120
+
121
+ prompt_lines.append("\n**Medication History:**")
122
+ for med, entries in patient_data['medications'].items():
123
+ history = " → ".join(
124
+ f"[{e['date']}] {e['response']}" for e in entries if e['booking'] in bookings
125
+ )
126
+ prompt_lines.append(f"- {med}: {history}")
127
+
128
+ prompt_lines.append("\n**Instructions:**")
129
+ prompt_lines.append("Analyze this data to generate clinical insights.")
130
+ prompt_lines.append("Structure your response as follows:\n")
131
  prompt_lines.extend([
 
 
 
 
 
 
 
 
132
  "### Diagnostic Patterns",
133
  "### Medication Analysis",
 
134
  "### Missed Opportunities",
135
+ "### Inconsistencies",
136
  "### Recommendations"
137
  ])
138
+
139
  return "\n".join(prompt_lines)
140
 
141
  def chunk_bookings(patient_data: Dict[str, Any]) -> List[List[str]]: