updated script code ✅✅
Browse files- mediSync/app.py +39 -7
mediSync/app.py
CHANGED
|
@@ -1014,6 +1014,7 @@ def create_interface():
|
|
| 1014 |
if not appointment_id or appointment_id.strip() == "":
|
| 1015 |
return "<div style='color: red; padding: 10px; background-color: #ffe6e6; border-radius: 5px;'>Please enter your appointment ID first.</div>"
|
| 1016 |
|
|
|
|
| 1017 |
result = complete_appointment(appointment_id.strip())
|
| 1018 |
|
| 1019 |
if result["status"] == "success":
|
|
@@ -1037,13 +1038,44 @@ def create_interface():
|
|
| 1037 |
</div>
|
| 1038 |
"""
|
| 1039 |
else:
|
| 1040 |
-
|
| 1041 |
-
|
| 1042 |
-
|
| 1043 |
-
|
| 1044 |
-
<
|
| 1045 |
-
|
| 1046 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1047 |
|
| 1048 |
return html_response
|
| 1049 |
|
|
|
|
| 1014 |
if not appointment_id or appointment_id.strip() == "":
|
| 1015 |
return "<div style='color: red; padding: 10px; background-color: #ffe6e6; border-radius: 5px;'>Please enter your appointment ID first.</div>"
|
| 1016 |
|
| 1017 |
+
# Try to complete the appointment
|
| 1018 |
result = complete_appointment(appointment_id.strip())
|
| 1019 |
|
| 1020 |
if result["status"] == "success":
|
|
|
|
| 1038 |
</div>
|
| 1039 |
"""
|
| 1040 |
else:
|
| 1041 |
+
# Handle connection failure gracefully
|
| 1042 |
+
if "Cannot connect to Flask app" in result['message']:
|
| 1043 |
+
# Show a helpful message with manual completion instructions
|
| 1044 |
+
html_response = f"""
|
| 1045 |
+
<div style='color: orange; padding: 15px; background-color: #fff3cd; border-radius: 5px; margin: 10px 0;'>
|
| 1046 |
+
<h3>⚠️ Consultation Ready to Complete</h3>
|
| 1047 |
+
<p>Your consultation analysis is complete! However, we cannot automatically mark your appointment as completed because the Flask app is not accessible from this environment.</p>
|
| 1048 |
+
<p><strong>Appointment ID:</strong> {appointment_id.strip()}</p>
|
| 1049 |
+
<p><strong>Next Steps:</strong></p>
|
| 1050 |
+
<ol>
|
| 1051 |
+
<li>Copy your appointment ID: <code>{appointment_id.strip()}</code></li>
|
| 1052 |
+
<li>Return to your Flask app (doctors page)</li>
|
| 1053 |
+
<li>Manually complete the appointment using the appointment ID</li>
|
| 1054 |
+
</ol>
|
| 1055 |
+
<div style="margin-top: 15px;">
|
| 1056 |
+
<button onclick="window.open('http://127.0.0.1:600/complete_appointment_manual?appointment_id={appointment_id.strip()}', '_blank')"
|
| 1057 |
+
style="background-color: #007bff; color: white; padding: 10px 20px; border: none; border-radius: 5px; cursor: pointer; margin-right: 10px;">
|
| 1058 |
+
Complete Appointment
|
| 1059 |
+
</button>
|
| 1060 |
+
<button onclick="window.open('http://127.0.0.1:600/doctors', '_blank')"
|
| 1061 |
+
style="background-color: #28a745; color: white; padding: 10px 20px; border: none; border-radius: 5px; cursor: pointer; margin-right: 10px;">
|
| 1062 |
+
Return to Doctors Page
|
| 1063 |
+
</button>
|
| 1064 |
+
<button onclick="navigator.clipboard.writeText('{appointment_id.strip()}')"
|
| 1065 |
+
style="background-color: #6c757d; color: white; padding: 10px 20px; border: none; border-radius: 5px; cursor: pointer;">
|
| 1066 |
+
Copy Appointment ID
|
| 1067 |
+
</button>
|
| 1068 |
+
</div>
|
| 1069 |
+
</div>
|
| 1070 |
+
"""
|
| 1071 |
+
else:
|
| 1072 |
+
html_response = f"""
|
| 1073 |
+
<div style='color: red; padding: 15px; background-color: #ffe6e6; border-radius: 5px; margin: 10px 0;'>
|
| 1074 |
+
<h3>❌ Error Completing Consultation</h3>
|
| 1075 |
+
<p>{result['message']}</p>
|
| 1076 |
+
<p>Please try again or contact support if the problem persists.</p>
|
| 1077 |
+
</div>
|
| 1078 |
+
"""
|
| 1079 |
|
| 1080 |
return html_response
|
| 1081 |
|