Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
|
2 |
import os
|
3 |
os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0'
|
4 |
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
|
@@ -475,16 +475,16 @@ def save_patient_data(name, age, sex, weight, height, complaint, medical_history
|
|
475 |
global patient_data
|
476 |
|
477 |
patient_data = {
|
478 |
-
'name': name,
|
479 |
-
'age': age,
|
480 |
-
'sex': sex,
|
481 |
-
'weight': weight,
|
482 |
-
'height': height,
|
483 |
-
'complaint': complaint,
|
484 |
-
'medical_history': medical_history,
|
485 |
-
'examination': examination,
|
486 |
-
'heartbeat_analysis': heartbeat_results,
|
487 |
-
'investigation_analysis': investigation_analysis,
|
488 |
'timestamp': datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
489 |
}
|
490 |
|
@@ -499,17 +499,16 @@ def process_complete_consultation(name, age, sex, weight, height, complaint,
|
|
499 |
heartbeat_results = ""
|
500 |
waveform_plot = None
|
501 |
if audio_file is not None:
|
502 |
-
|
503 |
-
heartbeat_results =
|
504 |
waveform_plot = plot_path
|
505 |
|
506 |
-
|
507 |
# Analyze investigation image if provided
|
508 |
investigation_analysis = ""
|
509 |
if investigation_image is not None:
|
510 |
investigation_analysis = analyze_medical_image(investigation_image)
|
511 |
-
|
512 |
-
|
513 |
patient_data_dict = {
|
514 |
'name': name if name else 'Not provided',
|
515 |
'age': age if age else 'Not provided',
|
@@ -523,14 +522,13 @@ def process_complete_consultation(name, age, sex, weight, height, complaint,
|
|
523 |
'investigation_analysis': investigation_analysis if investigation_analysis else 'Not provided'
|
524 |
}
|
525 |
|
526 |
-
|
527 |
-
# Save patient data
|
528 |
global patient_data
|
529 |
patient_data = patient_data_dict.copy()
|
530 |
patient_data['timestamp'] = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
531 |
|
532 |
# Generate comprehensive assessment
|
533 |
-
comprehensive_assessment = generate_comprehensive_assessment(
|
534 |
|
535 |
return comprehensive_assessment, waveform_plot, heartbeat_results, investigation_analysis
|
536 |
|
|
|
1 |
+
# Suppress TensorFlow warnings
|
2 |
import os
|
3 |
os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0'
|
4 |
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
|
|
|
475 |
global patient_data
|
476 |
|
477 |
patient_data = {
|
478 |
+
'name': name if name else 'Not provided',
|
479 |
+
'age': age if age else 'Not provided',
|
480 |
+
'sex': sex if sex else 'Not provided',
|
481 |
+
'weight': weight if weight else 'Not provided',
|
482 |
+
'height': height if height else 'Not provided',
|
483 |
+
'complaint': complaint if complaint else 'Not provided',
|
484 |
+
'medical_history': medical_history if medical_history else 'Not provided',
|
485 |
+
'examination': examination if examination else 'Not provided',
|
486 |
+
'heartbeat_analysis': heartbeat_results if heartbeat_results else 'Not performed',
|
487 |
+
'investigation_analysis': investigation_analysis if investigation_analysis else 'Not provided',
|
488 |
'timestamp': datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
489 |
}
|
490 |
|
|
|
499 |
heartbeat_results = ""
|
500 |
waveform_plot = None
|
501 |
if audio_file is not None:
|
502 |
+
heartbeat_analysis, plot_path = analyze_heartbeat(audio_file)
|
503 |
+
heartbeat_results = heartbeat_analysis if heartbeat_analysis else ""
|
504 |
waveform_plot = plot_path
|
505 |
|
|
|
506 |
# Analyze investigation image if provided
|
507 |
investigation_analysis = ""
|
508 |
if investigation_image is not None:
|
509 |
investigation_analysis = analyze_medical_image(investigation_image)
|
510 |
+
|
511 |
+
# Create patient data dictionary with proper handling
|
512 |
patient_data_dict = {
|
513 |
'name': name if name else 'Not provided',
|
514 |
'age': age if age else 'Not provided',
|
|
|
522 |
'investigation_analysis': investigation_analysis if investigation_analysis else 'Not provided'
|
523 |
}
|
524 |
|
525 |
+
# Save patient data to global variable
|
|
|
526 |
global patient_data
|
527 |
patient_data = patient_data_dict.copy()
|
528 |
patient_data['timestamp'] = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
529 |
|
530 |
# Generate comprehensive assessment
|
531 |
+
comprehensive_assessment = generate_comprehensive_assessment(patient_data_dict)
|
532 |
|
533 |
return comprehensive_assessment, waveform_plot, heartbeat_results, investigation_analysis
|
534 |
|