fix typo , major, fingers crossed
Browse files- utils/oneclick.py +6 -7
utils/oneclick.py
CHANGED
|
@@ -54,7 +54,6 @@ def generate_ai_discharge_summary(patient_dict: Dict[str, str], client) -> Tuple
|
|
| 54 |
discharge_summary = discharge_summary.strip()
|
| 55 |
logger.info("AI discharge summary generated successfully")
|
| 56 |
|
| 57 |
-
# Verify the summary for hallucinations
|
| 58 |
question = "Provide a complete discharge summary based on the patient information."
|
| 59 |
verified_summary = verifier.verify_discharge_summary(
|
| 60 |
context=formatted_summary,
|
|
@@ -68,7 +67,6 @@ def generate_ai_discharge_summary(patient_dict: Dict[str, str], client) -> Tuple
|
|
| 68 |
logger.error(f"Error generating AI discharge summary: {str(e)}", exc_info=True)
|
| 69 |
return None, None
|
| 70 |
|
| 71 |
-
# utils/oneclick.py
|
| 72 |
def generate_discharge_paper_one_click(
|
| 73 |
api: MeldRxAPI,
|
| 74 |
client,
|
|
@@ -100,7 +98,7 @@ def generate_discharge_paper_one_click(
|
|
| 100 |
for i in range(len(extractor.patients)):
|
| 101 |
extractor.set_patient_by_index(i)
|
| 102 |
patient_data = extractor.get_patient_dict()
|
| 103 |
-
logger.debug(f"Processing patient {i}: {patient_data}")
|
| 104 |
patient_id_from_data = str(patient_data.get('id', '')).strip().lower()
|
| 105 |
|
| 106 |
if patient_id_input and patient_id_from_data == patient_id_input:
|
|
@@ -150,15 +148,16 @@ def generate_discharge_paper_one_click(
|
|
| 150 |
except Exception as e:
|
| 151 |
logger.error(f"Error in one-click discharge generation: {str(e)}", exc_info=True)
|
| 152 |
return None, f"Error generating discharge summary: {str(e)}", None, None, None
|
| 153 |
-
|
| 154 |
def format_discharge_summary(patient_data: dict) -> str:
|
| 155 |
"""Format patient data into a discharge summary text."""
|
| 156 |
-
patient_data.setdefault('
|
| 157 |
patient_data.setdefault('first_name', '')
|
| 158 |
patient_data.setdefault('last_name', '')
|
| 159 |
patient_data.setdefault('dob', 'Unknown')
|
| 160 |
patient_data.setdefault('age', 'Unknown')
|
| 161 |
patient_data.setdefault('sex', 'Unknown')
|
|
|
|
| 162 |
patient_data.setdefault('address', 'Unknown')
|
| 163 |
patient_data.setdefault('city', 'Unknown')
|
| 164 |
patient_data.setdefault('state', 'Unknown')
|
|
@@ -180,11 +179,11 @@ def format_discharge_summary(patient_data: dict) -> str:
|
|
| 180 |
"DISCHARGE SUMMARY",
|
| 181 |
"",
|
| 182 |
"PATIENT INFORMATION",
|
| 183 |
-
f"Name: {patient_data['first_name']} {patient_data['last_name']}".strip(),
|
| 184 |
-
f"Patient ID: {patient_data['id']}",
|
| 185 |
f"Date of Birth: {patient_data['dob']}",
|
| 186 |
f"Age: {patient_data['age']}",
|
| 187 |
f"Gender: {patient_data['sex']}",
|
|
|
|
| 188 |
"",
|
| 189 |
"CONTACT INFORMATION",
|
| 190 |
f"Address: {patient_data['address']}",
|
|
|
|
| 54 |
discharge_summary = discharge_summary.strip()
|
| 55 |
logger.info("AI discharge summary generated successfully")
|
| 56 |
|
|
|
|
| 57 |
question = "Provide a complete discharge summary based on the patient information."
|
| 58 |
verified_summary = verifier.verify_discharge_summary(
|
| 59 |
context=formatted_summary,
|
|
|
|
| 67 |
logger.error(f"Error generating AI discharge summary: {str(e)}", exc_info=True)
|
| 68 |
return None, None
|
| 69 |
|
|
|
|
| 70 |
def generate_discharge_paper_one_click(
|
| 71 |
api: MeldRxAPI,
|
| 72 |
client,
|
|
|
|
| 98 |
for i in range(len(extractor.patients)):
|
| 99 |
extractor.set_patient_by_index(i)
|
| 100 |
patient_data = extractor.get_patient_dict()
|
| 101 |
+
logger.debug(f"Processing patient {i}: {patient_data}")
|
| 102 |
patient_id_from_data = str(patient_data.get('id', '')).strip().lower()
|
| 103 |
|
| 104 |
if patient_id_input and patient_id_from_data == patient_id_input:
|
|
|
|
| 148 |
except Exception as e:
|
| 149 |
logger.error(f"Error in one-click discharge generation: {str(e)}", exc_info=True)
|
| 150 |
return None, f"Error generating discharge summary: {str(e)}", None, None, None
|
| 151 |
+
|
| 152 |
def format_discharge_summary(patient_data: dict) -> str:
|
| 153 |
"""Format patient data into a discharge summary text."""
|
| 154 |
+
patient_data.setdefault('name_prefix', '')
|
| 155 |
patient_data.setdefault('first_name', '')
|
| 156 |
patient_data.setdefault('last_name', '')
|
| 157 |
patient_data.setdefault('dob', 'Unknown')
|
| 158 |
patient_data.setdefault('age', 'Unknown')
|
| 159 |
patient_data.setdefault('sex', 'Unknown')
|
| 160 |
+
patient_data.setdefault('id', 'Unknown')
|
| 161 |
patient_data.setdefault('address', 'Unknown')
|
| 162 |
patient_data.setdefault('city', 'Unknown')
|
| 163 |
patient_data.setdefault('state', 'Unknown')
|
|
|
|
| 179 |
"DISCHARGE SUMMARY",
|
| 180 |
"",
|
| 181 |
"PATIENT INFORMATION",
|
| 182 |
+
f"Name: {patient_data['name_prefix']} {patient_data['first_name']} {patient_data['last_name']}".strip(),
|
|
|
|
| 183 |
f"Date of Birth: {patient_data['dob']}",
|
| 184 |
f"Age: {patient_data['age']}",
|
| 185 |
f"Gender: {patient_data['sex']}",
|
| 186 |
+
f"Patient ID: {patient_data['id']}",
|
| 187 |
"",
|
| 188 |
"CONTACT INFORMATION",
|
| 189 |
f"Address: {patient_data['address']}",
|