Vrda commited on
Commit
18e134e
·
verified ·
1 Parent(s): d6be372

Upload backend.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. backend.py +18 -7
backend.py CHANGED
@@ -77,15 +77,22 @@ SUGGESTIONS are general quality improvements that are NOT necessarily errors, su
77
  - Patient safety enhancements
78
  - Follow-up care suggestions
79
 
 
 
 
 
 
 
80
  CRITICAL RULES:
81
  - Only report genuine errors you are confident about. Do NOT fabricate errors.
82
  - Do NOT force yourself to find 3 errors.
83
  - If you find fewer than 3 errors, report only what you find.
84
- - It is acceptable to find 0 errors. If no clear error is present, return `"errors": []`.
85
  - When uncertain, prefer returning no error rather than a speculative one.
86
- - You may still provide 0-2 useful improvement suggestions even when `errors` is empty.
87
- - Be specific: quote the relevant part of the letter for each error.
88
  - Categorize each error and suggestion precisely.
 
89
 
90
  You MUST respond in the following JSON format and NOTHING else:
91
 
@@ -101,7 +108,9 @@ You MUST respond in the following JSON format and NOTHING else:
101
  "suggestions": [
102
  {
103
  "description": "Clear description of the improvement suggestion",
104
- "category": "documentation_quality|clinical_workflow|patient_safety|completeness|other"
 
 
105
  }
106
  ],
107
  "summary": "One-sentence overall assessment of the discharge letter quality"
@@ -112,11 +121,13 @@ Valid zero-error example:
112
  "errors": [],
113
  "suggestions": [
114
  {
115
- "description": "Document the follow-up plan more explicitly.",
116
- "category": "documentation_quality"
 
 
117
  }
118
  ],
119
- "summary": "No clear clinical or documentation errors were identified, but the discharge letter could be improved."
120
  }"""
121
 
122
  ERROR_CHECK_USER_PROMPT = """Analyze the following internal medicine emergency department discharge letter for errors and quality issues.
 
77
  - Patient safety enhancements
78
  - Follow-up care suggestions
79
 
80
+ For every suggestion you MUST:
81
+ - Identify the specific part of the letter that could be improved
82
+ - Quote the relevant original text (or note what is missing)
83
+ - Provide the exact rewritten version or additional text you would use instead
84
+ This makes every suggestion concrete and immediately usable rather than vague or generic.
85
+
86
  CRITICAL RULES:
87
  - Only report genuine errors you are confident about. Do NOT fabricate errors.
88
  - Do NOT force yourself to find 3 errors.
89
  - If you find fewer than 3 errors, report only what you find.
90
+ - It is acceptable to find 0 errors. If no clear error is present, return "errors": [].
91
  - When uncertain, prefer returning no error rather than a speculative one.
92
+ - You may still provide 0-2 useful improvement suggestions even when errors is empty.
93
+ - Be specific: quote the relevant part of the letter for each error and suggestion.
94
  - Categorize each error and suggestion precisely.
95
+ - For every suggestion, always include both the original quote and your exact suggested rewrite.
96
 
97
  You MUST respond in the following JSON format and NOTHING else:
98
 
 
108
  "suggestions": [
109
  {
110
  "description": "Clear description of the improvement suggestion",
111
+ "category": "documentation_quality|clinical_workflow|patient_safety|completeness|other",
112
+ "quote": "Exact quote from the letter (or 'N/A' if adding entirely new content)",
113
+ "suggested_rewrite": "Exactly how you would have written it differently - the full improved text you recommend"
114
  }
115
  ],
116
  "summary": "One-sentence overall assessment of the discharge letter quality"
 
121
  "errors": [],
122
  "suggestions": [
123
  {
124
+ "description": "Make the follow-up plan more explicit and actionable for the patient and primary care provider.",
125
+ "category": "documentation_quality",
126
+ "quote": "Follow up with primary care in 1 week.",
127
+ "suggested_rewrite": "Please follow up with your primary care physician within 7 days for repeat labs and clinical reassessment. If you experience worsening shortness of breath, chest pain, or fever, return to the emergency department immediately or call the 24-hour advice line at (555) 123-4567."
128
  }
129
  ],
130
+ "summary": "No clear clinical or documentation errors were identified, but the discharge letter could be improved with more specific follow-up instructions."
131
  }"""
132
 
133
  ERROR_CHECK_USER_PROMPT = """Analyze the following internal medicine emergency department discharge letter for errors and quality issues.