updated the script code ✅✅
Browse files- mediSync/app.py +72 -29
mediSync/app.py
CHANGED
|
@@ -1083,49 +1083,92 @@ def create_interface():
|
|
| 1083 |
console.log('Found appointment ID:', appointmentId);
|
| 1084 |
|
| 1085 |
if (appointmentId) {
|
| 1086 |
-
// Try multiple
|
| 1087 |
-
var
|
| 1088 |
-
'input[placeholder*="appointment ID"]',
|
| 1089 |
-
'input[placeholder*="appointment_id"]',
|
| 1090 |
-
'input[placeholder*="Appointment ID"]',
|
| 1091 |
-
'textarea[placeholder*="appointment ID"]',
|
| 1092 |
-
'textarea[placeholder*="appointment_id"]',
|
| 1093 |
-
'textarea[placeholder*="Appointment ID"]'
|
| 1094 |
-
];
|
| 1095 |
|
| 1096 |
-
|
| 1097 |
-
|
| 1098 |
-
|
| 1099 |
-
|
| 1100 |
-
|
| 1101 |
-
|
| 1102 |
-
|
| 1103 |
-
|
| 1104 |
-
|
| 1105 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1106 |
}
|
| 1107 |
}
|
| 1108 |
|
| 1109 |
-
//
|
| 1110 |
-
|
| 1111 |
-
|
| 1112 |
-
|
| 1113 |
-
|
| 1114 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1115 |
input.value = appointmentId;
|
| 1116 |
var event = new Event('input', { bubbles: true });
|
| 1117 |
input.dispatchEvent(event);
|
| 1118 |
-
console.log('Set appointment ID by
|
| 1119 |
-
|
|
|
|
| 1120 |
}
|
| 1121 |
}
|
| 1122 |
}
|
| 1123 |
|
| 1124 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1125 |
} else {
|
| 1126 |
console.log('No appointment ID found in URL');
|
| 1127 |
}
|
| 1128 |
-
return
|
| 1129 |
}
|
| 1130 |
|
| 1131 |
// Function to wait for Gradio to be ready
|
|
|
|
| 1083 |
console.log('Found appointment ID:', appointmentId);
|
| 1084 |
|
| 1085 |
if (appointmentId) {
|
| 1086 |
+
// Try multiple methods to find and populate the appointment ID input
|
| 1087 |
+
var success = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1088 |
|
| 1089 |
+
// Method 1: Try by specific element ID
|
| 1090 |
+
var elementById = document.getElementById('appointment_id_input');
|
| 1091 |
+
if (elementById) {
|
| 1092 |
+
elementById.value = appointmentId;
|
| 1093 |
+
var event = new Event('input', { bubbles: true });
|
| 1094 |
+
elementById.dispatchEvent(event);
|
| 1095 |
+
console.log('Set appointment ID by ID to:', appointmentId);
|
| 1096 |
+
success = true;
|
| 1097 |
+
}
|
| 1098 |
+
|
| 1099 |
+
// Method 2: Try by placeholder text
|
| 1100 |
+
if (!success) {
|
| 1101 |
+
var selectors = [
|
| 1102 |
+
'input[placeholder*="appointment ID"]',
|
| 1103 |
+
'input[placeholder*="appointment_id"]',
|
| 1104 |
+
'input[placeholder*="Appointment ID"]',
|
| 1105 |
+
'textarea[placeholder*="appointment ID"]',
|
| 1106 |
+
'textarea[placeholder*="appointment_id"]',
|
| 1107 |
+
'textarea[placeholder*="Appointment ID"]'
|
| 1108 |
+
];
|
| 1109 |
+
|
| 1110 |
+
for (var selector of selectors) {
|
| 1111 |
+
var elements = document.querySelectorAll(selector);
|
| 1112 |
+
for (var element of elements) {
|
| 1113 |
+
console.log('Found element by placeholder:', element);
|
| 1114 |
+
element.value = appointmentId;
|
| 1115 |
+
var event = new Event('input', { bubbles: true });
|
| 1116 |
+
element.dispatchEvent(event);
|
| 1117 |
+
console.log('Set appointment ID by placeholder to:', appointmentId);
|
| 1118 |
+
success = true;
|
| 1119 |
+
break;
|
| 1120 |
+
}
|
| 1121 |
+
if (success) break;
|
| 1122 |
}
|
| 1123 |
}
|
| 1124 |
|
| 1125 |
+
// Method 3: Try by label text
|
| 1126 |
+
if (!success) {
|
| 1127 |
+
var labels = document.querySelectorAll('label');
|
| 1128 |
+
for (var label of labels) {
|
| 1129 |
+
if (label.textContent && label.textContent.toLowerCase().includes('appointment id')) {
|
| 1130 |
+
var input = label.nextElementSibling;
|
| 1131 |
+
if (input && (input.tagName === 'INPUT' || input.tagName === 'TEXTAREA')) {
|
| 1132 |
+
input.value = appointmentId;
|
| 1133 |
+
var event = new Event('input', { bubbles: true });
|
| 1134 |
+
input.dispatchEvent(event);
|
| 1135 |
+
console.log('Set appointment ID by label to:', appointmentId);
|
| 1136 |
+
success = true;
|
| 1137 |
+
break;
|
| 1138 |
+
}
|
| 1139 |
+
}
|
| 1140 |
+
}
|
| 1141 |
+
}
|
| 1142 |
+
|
| 1143 |
+
// Method 4: Try by Gradio component attributes
|
| 1144 |
+
if (!success) {
|
| 1145 |
+
var gradioInputs = document.querySelectorAll('[data-testid="textbox"]');
|
| 1146 |
+
for (var input of gradioInputs) {
|
| 1147 |
+
var label = input.closest('.form').querySelector('label');
|
| 1148 |
+
if (label && label.textContent.toLowerCase().includes('appointment id')) {
|
| 1149 |
input.value = appointmentId;
|
| 1150 |
var event = new Event('input', { bubbles: true });
|
| 1151 |
input.dispatchEvent(event);
|
| 1152 |
+
console.log('Set appointment ID by Gradio component to:', appointmentId);
|
| 1153 |
+
success = true;
|
| 1154 |
+
break;
|
| 1155 |
}
|
| 1156 |
}
|
| 1157 |
}
|
| 1158 |
|
| 1159 |
+
if (!success) {
|
| 1160 |
+
console.log('Could not find appointment ID input field');
|
| 1161 |
+
// Log all input elements for debugging
|
| 1162 |
+
var allInputs = document.querySelectorAll('input, textarea');
|
| 1163 |
+
console.log('All input elements found:', allInputs.length);
|
| 1164 |
+
for (var i = 0; i < allInputs.length; i++) {
|
| 1165 |
+
console.log('Input', i, ':', allInputs[i].placeholder, allInputs[i].id, allInputs[i].className);
|
| 1166 |
+
}
|
| 1167 |
+
}
|
| 1168 |
} else {
|
| 1169 |
console.log('No appointment ID found in URL');
|
| 1170 |
}
|
| 1171 |
+
return success;
|
| 1172 |
}
|
| 1173 |
|
| 1174 |
// Function to wait for Gradio to be ready
|