vistassh-py/ext_discovery.py

37 lines
1.4 KiB
Python
Raw Normal View History

2024-03-02 00:34:29 -05:00
#!/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')
2025-01-14 21:56:51 -05:00
async for prompt, response in expect.promptmatches((
(re.compile(r' Press \'RETURN\' to continue, \'\^\' to stop: $'), None),
('Select Patient Information and OE/RR Option: ', None, True),
('Select Patient Information and OE/RR <TEST ACCOUNT> Option: ', None, True),
), throw=True):
if prompt.index == 0:
proc.sendline(response)
2024-03-02 00:34:29 -05:00
expect.clear()