Spaces:
Running
on
Zero
Running
on
Zero
Refactor: Move clinical examples to external files in examples/ folder
Browse files- app.py +10 -35
- examples/ehr.txt +28 -0
- examples/progress_note.txt +7 -0
app.py
CHANGED
|
@@ -77,42 +77,17 @@ except Exception as e:
|
|
| 77 |
print("✅ Модель завантажена!")
|
| 78 |
|
| 79 |
# --- ПРИКЛАДИ ДОКУМЕНТІВ ---
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
**Chief Complaint:** Persistent cough and fatigue for 5 days
|
| 90 |
-
|
| 91 |
-
**Vitals:**
|
| 92 |
-
BP: 128/82 mmHg | HR: 76 bpm | Temp: 37.8°C | Weight: 68 kg
|
| 93 |
-
|
| 94 |
-
**Assessment:** Acute bronchitis
|
| 95 |
-
|
| 96 |
-
**Plan:**
|
| 97 |
-
- Azithromycin 500mg daily x 3 days
|
| 98 |
-
- Rest and increased fluid intake
|
| 99 |
-
- Follow-up if symptoms worsen
|
| 100 |
-
|
| 101 |
-
**Medical History:** Hypertension (controlled), Appendectomy 2015
|
| 102 |
-
|
| 103 |
-
**Current Medications:** Lisinopril 10mg daily
|
| 104 |
-
|
| 105 |
-
**Labs (Nov 10, 2023):** WBC 11.2, Glucose 5.4 mmol/L - normal range
|
| 106 |
-
|
| 107 |
-
Next appointment: November 29, 2023"""
|
| 108 |
-
|
| 109 |
-
EXAMPLE_PROGRESS_NOTE = """Progress Note - January 15, 2026 14:30
|
| 110 |
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
Started on Aspirin 81mg QD and Lisinopril 10mg QD.
|
| 114 |
-
History of hypertension and diabetes.
|
| 115 |
-
No known drug allergies."""
|
| 116 |
|
| 117 |
# --- ФУНКЦІЯ ЕКСТРАКЦІЇ ---
|
| 118 |
def extract_medical_data(clinical_text, image, max_tokens, enable_thinking=False, temperature=0.0, top_p=1.0, top_k=50):
|
|
|
|
| 77 |
print("✅ Модель завантажена!")
|
| 78 |
|
| 79 |
# --- ПРИКЛАДИ ДОКУМЕНТІВ ---
|
| 80 |
+
# --- ЗАВАНТАЖЕННЯ ПРИКЛАДІВ ---
|
| 81 |
+
def load_example(filename):
|
| 82 |
+
try:
|
| 83 |
+
with open(os.path.join("examples", filename), "r") as f:
|
| 84 |
+
return f.read()
|
| 85 |
+
except Exception as e:
|
| 86 |
+
print(f"⚠️ Помилка завантаження прикладу {filename}: {e}")
|
| 87 |
+
return ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
|
| 89 |
+
EXAMPLE_EHR = load_example("ehr.txt")
|
| 90 |
+
EXAMPLE_PROGRESS_NOTE = load_example("progress_note.txt")
|
|
|
|
|
|
|
|
|
|
| 91 |
|
| 92 |
# --- ФУНКЦІЯ ЕКСТРАКЦІЇ ---
|
| 93 |
def extract_medical_data(clinical_text, image, max_tokens, enable_thinking=False, temperature=0.0, top_p=1.0, top_k=50):
|
examples/ehr.txt
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
**ELECTRONIC HEALTH RECORD**
|
| 2 |
+
|
| 3 |
+
Patient: Sarah Johnson
|
| 4 |
+
DOB: 08/22/1978 | Female | MRN: 456789
|
| 5 |
+
Blood Type: O+ | Allergies: Penicillin
|
| 6 |
+
|
| 7 |
+
**Visit Date:** November 15, 2023
|
| 8 |
+
**Provider:** Dr. Michael Chen, Family Medicine
|
| 9 |
+
|
| 10 |
+
**Chief Complaint:** Persistent cough and fatigue for 5 days
|
| 11 |
+
|
| 12 |
+
**Vitals:**
|
| 13 |
+
BP: 128/82 mmHg | HR: 76 bpm | Temp: 37.8°C | Weight: 68 kg
|
| 14 |
+
|
| 15 |
+
**Assessment:** Acute bronchitis
|
| 16 |
+
|
| 17 |
+
**Plan:**
|
| 18 |
+
- Azithromycin 500mg daily x 3 days
|
| 19 |
+
- Rest and increased fluid intake
|
| 20 |
+
- Follow-up if symptoms worsen
|
| 21 |
+
|
| 22 |
+
**Medical History:** Hypertension (controlled), Appendectomy 2015
|
| 23 |
+
|
| 24 |
+
**Current Medications:** Lisinopril 10mg daily
|
| 25 |
+
|
| 26 |
+
**Labs (Nov 10, 2023):** WBC 11.2, Glucose 5.4 mmol/L - normal range
|
| 27 |
+
|
| 28 |
+
Next appointment: November 29, 2023
|
examples/progress_note.txt
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Progress Note - January 15, 2026 14:30
|
| 2 |
+
|
| 3 |
+
Patient admitted with fever and chest pain.
|
| 4 |
+
Temperature 38.5°C, Heart rate 92 bpm, BP 130/85.
|
| 5 |
+
Started on Aspirin 81mg QD and Lisinopril 10mg QD.
|
| 6 |
+
History of hypertension and diabetes.
|
| 7 |
+
No known drug allergies.
|