31 lines
1.2 KiB
Python
31 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
|
|
import re
|
|
import autoproc
|
|
|
|
async def cmd_listclinics(proc):
|
|
"""Fetch list of clinics"""
|
|
async with proc.sendline, autoproc.expect_async(proc) as expect:
|
|
proc.sendline('^Appointment List')
|
|
assert await expect.endswith('\r\nSelect division: ALL// ')
|
|
proc.sendline() # default ALL
|
|
assert await expect.endswith('\r\nCount, Non Count, or Both: C//')
|
|
proc.sendline('Both')
|
|
assert await expect.endswith('\r\nSelect clinic: ALL// ')
|
|
proc.sendline('??')
|
|
assert await expect.earliest('\r\n Choose from:')
|
|
while m_delimiter := await expect.endswith('\r\n Type <Enter> to continue or \'^\' to exit: ', '\r\nSelect clinic: ALL// '):
|
|
for line in m_delimiter.before.splitlines():
|
|
line = line.strip()
|
|
if len(line) > 0:
|
|
assert (m := re.match(r'^(\d+)\s{2,}(.*?)(?:\s{2,}(.*?))?$', line))
|
|
yield { 'uid': int(m.group(1)), 'name': m.group(2).upper(), 'provider': m.group(3).upper() if m.group(3) else None }
|
|
if m_delimiter.index == 0:
|
|
proc.sendline()
|
|
else:
|
|
proc.sendline('^')
|
|
break
|
|
proc.sendline('^Patient information AND OE/RR')
|
|
assert await expect.endswith('\r\nSelect Patient Information and OE/RR Option: ', '\r\nSelect Patient Information and OE/RR <TEST ACCOUNT> Option: ')
|
|
expect.clear()
|