feat: AI chatbot preauth intent, UnitedDH pre-auth improvements
- Add preauth intent to AI chatbot (classifier, workflow, frontend UI card) - Auto-prefill preauth form with CDT codes, service date, and mapped prices - Auto-trigger preauth Selenium handler by insurance siteKey (MH/Tufts/CCA/UnitedDH) - Default tentative service date to today+3 for preauth (user didn't pick a date) - Fix #number always means tooth number, distributes to all procedures in comma list - Fix bare "post"/"pos" → D2954 (was matching D2955 via keyword scorer) - UnitedDH pre-auth: fill procedure date with Ctrl+A to overwrite prefilled value - UnitedDH pre-auth: select Location "Summit Dental Care" in step1 (same as billing entity) - UnitedDH pre-auth: remove page refresh in step9 to preserve pre-auth number - UnitedDH pre-auth: wait for table rows before extracting pre-auth number - UnitedDH pre-auth/claim: explicit wait for Submit button after file upload (no sleep) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -550,13 +550,28 @@ class AutomationUnitedDHPreAuth:
|
||||
self.driver.execute_script("arguments[0].scrollIntoView({block:'center'});", location_ng)
|
||||
arrow = location_ng.find_element(By.CSS_SELECTOR, ".ng-arrow-wrapper")
|
||||
arrow.click()
|
||||
first_option = WebDriverWait(self.driver, 5).until(
|
||||
EC.element_to_be_clickable((By.CSS_SELECTOR, ".ng-dropdown-panel .ng-option"))
|
||||
)
|
||||
option_text = first_option.text.strip()
|
||||
first_option.click()
|
||||
print(f"[UnitedDH PreAuth] step1: Selected Treatment Location: {option_text}")
|
||||
location_selected = True
|
||||
time.sleep(1)
|
||||
try:
|
||||
summit_option = WebDriverWait(self.driver, 5).until(
|
||||
EC.element_to_be_clickable((By.XPATH,
|
||||
"//ng-dropdown-panel//div[contains(@class,'ng-option') and contains(.,'Summit Dental Care')]"
|
||||
))
|
||||
)
|
||||
summit_option.click()
|
||||
print("[UnitedDH PreAuth] step1: Selected Treatment Location: Summit Dental Care")
|
||||
location_selected = True
|
||||
except TimeoutException:
|
||||
try:
|
||||
first_option = self.driver.find_element(By.XPATH,
|
||||
"//ng-dropdown-panel//div[contains(@class,'ng-option')]"
|
||||
)
|
||||
option_text = first_option.text.strip()
|
||||
first_option.click()
|
||||
print(f"[UnitedDH PreAuth] step1: Selected Treatment Location (fallback): {option_text}")
|
||||
location_selected = True
|
||||
except Exception:
|
||||
print("[UnitedDH PreAuth] step1: No options available in Treatment Location dropdown")
|
||||
time.sleep(1)
|
||||
except Exception as e:
|
||||
print(f"[UnitedDH PreAuth] step1: Treatment Location selection failed: {e}")
|
||||
|
||||
@@ -693,6 +708,24 @@ class AutomationUnitedDHPreAuth:
|
||||
))
|
||||
)
|
||||
|
||||
# Fill procedure date from tentative service date.
|
||||
# If tentative date == today, user did not change it — use today + 3 days instead.
|
||||
if self.serviceDate:
|
||||
try:
|
||||
from datetime import date, timedelta
|
||||
service_date = date.fromisoformat(self.serviceDate[:10])
|
||||
if service_date == date.today():
|
||||
service_date = service_date + timedelta(days=3)
|
||||
print("[UnitedDH PreAuth] step3: Tentative date is today — using today + 3 days")
|
||||
proc_date_str = service_date.strftime("%m/%d/%Y")
|
||||
proc_input = self.driver.find_element(By.ID, "procedureDate_Back")
|
||||
proc_input.click()
|
||||
proc_input.send_keys(Keys.CONTROL, "a")
|
||||
proc_input.send_keys(proc_date_str)
|
||||
print(f"[UnitedDH PreAuth] step3: Procedure date entered: {proc_date_str}")
|
||||
except Exception as e:
|
||||
print(f"[UnitedDH PreAuth] step3: WARNING - Could not fill procedure date: {e}")
|
||||
|
||||
payer_selected = False
|
||||
try:
|
||||
payer_selectors = [
|
||||
@@ -1019,7 +1052,15 @@ class AutomationUnitedDHPreAuth:
|
||||
)
|
||||
self.driver.execute_script("arguments[0].removeAttribute('class');", file_input)
|
||||
file_input.send_keys(abs_path)
|
||||
time.sleep(1.5)
|
||||
WebDriverWait(self.driver, 60).until(
|
||||
EC.element_to_be_clickable((By.XPATH,
|
||||
"//button[contains(normalize-space(.),'Submit Authorization') or "
|
||||
"contains(normalize-space(.),'Submit Pre-Auth') or "
|
||||
"contains(normalize-space(.),'Submit Pre Authorization') or "
|
||||
"contains(normalize-space(.),'Submit Pre-Authorization') or "
|
||||
"contains(normalize-space(.),'Submit Claim')]"
|
||||
))
|
||||
)
|
||||
print(f"[UnitedDH PreAuth] step7: Attached: {os.path.basename(abs_path)}")
|
||||
attached += 1
|
||||
except Exception as e:
|
||||
@@ -1085,15 +1126,17 @@ class AutomationUnitedDHPreAuth:
|
||||
lambda d: "status" in d.current_url.lower() or "history" in d.current_url.lower()
|
||||
or d.find_elements(By.XPATH, "//td | //th[contains(text(),'Reference')]")
|
||||
)
|
||||
time.sleep(4)
|
||||
time.sleep(3)
|
||||
print(f"[UnitedDH PreAuth] step9: Status & History URL: {self.driver.current_url}")
|
||||
|
||||
self.driver.refresh()
|
||||
print("[UnitedDH PreAuth] step9: Page refreshed — waiting for table to reload")
|
||||
WebDriverWait(self.driver, 30).until(
|
||||
EC.presence_of_element_located((By.XPATH, "//table//tr[td]"))
|
||||
)
|
||||
time.sleep(4)
|
||||
# Wait for table rows with actual data (not just headers)
|
||||
try:
|
||||
WebDriverWait(self.driver, 20).until(
|
||||
EC.presence_of_element_located((By.XPATH, "//table//tr[td]"))
|
||||
)
|
||||
time.sleep(2)
|
||||
except Exception:
|
||||
print("[UnitedDH PreAuth] step9: Table rows did not appear — proceeding with body scan")
|
||||
|
||||
preauth_number = None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user