Commit ·
e5c33cd
1
Parent(s): cb3b2ec
Fix report structure: require all sections (biopsy, findings, diagnostics, management) with explicit formatting
Browse files- backend/app.py +66 -10
backend/app.py
CHANGED
|
@@ -298,24 +298,80 @@ async def generate_report_endpoint(request: ReportGenerationRequest):
|
|
| 298 |
try:
|
| 299 |
# Use system prompt or default
|
| 300 |
system_prompt = request.system_prompt or """You are an expert colposcopy AI assistant acting as a specialist gynaecologist.
|
| 301 |
-
|
| 302 |
|
| 303 |
-
# Build prompt with
|
| 304 |
prompt_parts = []
|
| 305 |
|
| 306 |
-
# Add patient data
|
| 307 |
prompt_parts.append("PATIENT DATA:")
|
| 308 |
prompt_parts.append(json.dumps(request.patient_data, indent=2))
|
| 309 |
|
| 310 |
-
|
| 311 |
-
prompt_parts.append("\nEXAMINATION FINDINGS:")
|
| 312 |
prompt_parts.append(json.dumps(request.exam_findings, indent=2))
|
| 313 |
|
| 314 |
-
|
| 315 |
-
prompt_parts.append("
|
| 316 |
-
prompt_parts.append("
|
| 317 |
-
|
| 318 |
-
prompt_parts.append("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 319 |
|
| 320 |
full_prompt = "\n".join(prompt_parts)
|
| 321 |
|
|
|
|
| 298 |
try:
|
| 299 |
# Use system prompt or default
|
| 300 |
system_prompt = request.system_prompt or """You are an expert colposcopy AI assistant acting as a specialist gynaecologist.
|
| 301 |
+
Generate comprehensive, structured colposcopy reports with ALL provided clinical data and examination findings."""
|
| 302 |
|
| 303 |
+
# Build comprehensive structured prompt with all required sections
|
| 304 |
prompt_parts = []
|
| 305 |
|
|
|
|
| 306 |
prompt_parts.append("PATIENT DATA:")
|
| 307 |
prompt_parts.append(json.dumps(request.patient_data, indent=2))
|
| 308 |
|
| 309 |
+
prompt_parts.append("\n\nEXAMINATION FINDINGS & OBSERVATIONS:")
|
|
|
|
| 310 |
prompt_parts.append(json.dumps(request.exam_findings, indent=2))
|
| 311 |
|
| 312 |
+
prompt_parts.append("\n\n" + "="*80)
|
| 313 |
+
prompt_parts.append("GENERATE A COMPLETE STRUCTURED COLPOSCOPY REPORT WITH ALL SECTIONS:")
|
| 314 |
+
prompt_parts.append("="*80)
|
| 315 |
+
|
| 316 |
+
prompt_parts.append("""
|
| 317 |
+
|
| 318 |
+
## 1. PATIENT DEMOGRAPHICS & CLINICAL HISTORY
|
| 319 |
+
- Patient age, indication for colposcopy, relevant risk factors, HPV status, Pap smear results
|
| 320 |
+
- Medical history including immunosuppression, smoking, sexual history
|
| 321 |
+
|
| 322 |
+
## 2. COLPOSCOPY ADEQUACY ASSESSMENT
|
| 323 |
+
- Transformation zone type (Type 1, 2, or 3)
|
| 324 |
+
- Visibility of squamocolumnar junction (SCJ)
|
| 325 |
+
- Any visual obstructions or examination limitations
|
| 326 |
+
|
| 327 |
+
## 3. NATIVE VIEW FINDINGS
|
| 328 |
+
- Cervical appearance, growths, contact bleeding, surface characteristics
|
| 329 |
+
- Grossly visible lesions or abnormalities
|
| 330 |
+
- General cervical health assessment
|
| 331 |
+
|
| 332 |
+
## 4. ACETIC ACID APPLICATION FINDINGS
|
| 333 |
+
- Acetowhite lesions (location, size, extent, characteristics)
|
| 334 |
+
- Abnormal vascular patterns (punctuation, mosaicism, atypical vessels)
|
| 335 |
+
- Size and distribution of acetowhite areas
|
| 336 |
+
- Extent of disease if present
|
| 337 |
+
|
| 338 |
+
## 5. LUGOL'S IODINE APPLICATION FINDINGS
|
| 339 |
+
- Iodine non-staining areas and their locations
|
| 340 |
+
- Staining patterns and significance
|
| 341 |
+
- Areas not staining indicating possible dysplasia
|
| 342 |
+
|
| 343 |
+
## 6. BIOPSY MARKING & FINDINGS
|
| 344 |
+
- Specific locations of biopsies taken (if any)
|
| 345 |
+
- Detailed descriptions of biopsied areas
|
| 346 |
+
- Number of biopsies taken
|
| 347 |
+
- Expected histologic findings or impression
|
| 348 |
+
|
| 349 |
+
## 7. SWEDE SCORE (if applicable)
|
| 350 |
+
- Major findings score
|
| 351 |
+
- Minor findings assessment
|
| 352 |
+
- Overall risk stratification
|
| 353 |
+
|
| 354 |
+
## 8. DIAGNOSTIC IMPRESSION
|
| 355 |
+
- Overall colposcopic impression (normal/CIN1/CIN2/3/cancer/other)
|
| 356 |
+
- Adequacy of examination
|
| 357 |
+
- Severity assessment if lesions present
|
| 358 |
+
- Correlation with cytology and HPV status
|
| 359 |
+
|
| 360 |
+
## 9. MANAGEMENT PLAN & RECOMMENDATIONS
|
| 361 |
+
- Treatment recommendations (observation/colposcopy/LEEP/other)
|
| 362 |
+
- Follow-up testing schedule (colposcopy timing, repeat cytology, HPV testing)
|
| 363 |
+
- Biopsy management and expected next steps
|
| 364 |
+
- Surveillance intervals based on findings
|
| 365 |
+
- Patient counseling points
|
| 366 |
+
|
| 367 |
+
CRITICAL INSTRUCTIONS:
|
| 368 |
+
- MUST include ALL 9 sections above
|
| 369 |
+
- USE ALL patient data provided
|
| 370 |
+
- INCLUDE ALL examination findings from the data
|
| 371 |
+
- DO NOT consolidate or omit sections
|
| 372 |
+
- DO NOT drop information to "recommendations only"
|
| 373 |
+
- Provide detailed, clinical, evidence-based assessments
|
| 374 |
+
- Format clearly with headers for each section""")
|
| 375 |
|
| 376 |
full_prompt = "\n".join(prompt_parts)
|
| 377 |
|