adjust wait, add only_tag
This commit is contained in:
parent
f6f87ba351
commit
d070c38106
2 changed files with 62 additions and 77 deletions
135
src/pacs.py
135
src/pacs.py
|
@ -16,8 +16,9 @@ def mouse_click(ws):
|
||||||
r = ws.rectangle()
|
r = ws.rectangle()
|
||||||
coords = (r.left + r.right)//2, (r.top + r.bottom)//2
|
coords = (r.left + r.right)//2, (r.top + r.bottom)//2
|
||||||
mouse.move(coords=coords)
|
mouse.move(coords=coords)
|
||||||
time.sleep(1)
|
time.sleep(0.1)
|
||||||
mouse.click(coords=coords)
|
mouse.click(coords=coords)
|
||||||
|
time.sleep(0.2)
|
||||||
# mouse.press(coords=coords)
|
# mouse.press(coords=coords)
|
||||||
# mouse.release(coords=coords)
|
# mouse.release(coords=coords)
|
||||||
|
|
||||||
|
@ -79,35 +80,38 @@ def dump(pane):
|
||||||
|
|
||||||
|
|
||||||
def save_tag(window, outdir):
|
def save_tag(window, outdir):
|
||||||
mouse_click(window['註釋/標籤'])
|
mouse_click(window['註釋/標籤'])
|
||||||
TToolBar = window.child_window(class_name='TToolBar', found_index=2)
|
TToolBar = window.child_window(class_name='TToolBar', found_index=2)
|
||||||
|
|
||||||
Button5 = TToolBar.Button5
|
Button5 = TToolBar.Button5
|
||||||
Button5.wait('ready', 9)
|
Button5.wait('ready', 9)
|
||||||
# time.sleep(2)
|
# time.sleep(2)
|
||||||
mouse_click(Button5)
|
mouse_click(Button5)
|
||||||
|
|
||||||
export_to_file = window['輸出至檔案']
|
export_to_file = window['輸出至檔案']
|
||||||
export_to_file.wait('ready', 99)
|
export_to_file.wait('ready', 99)
|
||||||
export = export_to_file.wrapper_object()
|
export = export_to_file.wrapper_object()
|
||||||
export.click()
|
export.click()
|
||||||
|
|
||||||
TDicomTagListForm = window['DICOM 標籤清單Dialog']
|
TDicomTagListForm = window['DICOM 標籤清單Dialog']
|
||||||
|
|
||||||
dlg_save = Desktop(backend="uia").window(title='另存新檔')
|
dlg_save = Desktop(backend="uia").window(title='另存新檔')
|
||||||
NEdit = dlg_save['檔案名稱(N):Edit']
|
NEdit = dlg_save['檔案名稱(N):Edit']
|
||||||
NEdit.wait('ready', 99)
|
NEdit.wait('ready', 99)
|
||||||
edit = NEdit.wrapper_object()
|
edit = NEdit.wrapper_object()
|
||||||
pahtname = os.path.join(outdir, edit.get_value())
|
pahtname = os.path.join(outdir, edit.get_value())
|
||||||
for p in glob.glob(pahtname + '*'):
|
for p in glob.glob(pahtname + '*'):
|
||||||
os.remove(p)
|
os.remove(p)
|
||||||
edit.set_text(pahtname)
|
edit.set_text(pahtname)
|
||||||
dlg_save['存檔(S)Button'].wrapper_object().click()
|
dlg_save['存檔(S)Button'].wrapper_object().click()
|
||||||
|
|
||||||
TDicomTagListForm.close()
|
TDicomTagListForm.close()
|
||||||
|
TDicomTagListForm.wait_not('exists', 9)
|
||||||
|
|
||||||
|
return pahtname
|
||||||
|
|
||||||
|
|
||||||
def save_study(chartno, outdir):
|
def save_study(chartno, outdir, only_tag):
|
||||||
# TViewerForm
|
# TViewerForm
|
||||||
|
|
||||||
# while True:
|
# while True:
|
||||||
|
@ -149,67 +153,48 @@ def save_study(chartno, outdir):
|
||||||
|
|
||||||
logging.warning(str(c.element_info))
|
logging.warning(str(c.element_info))
|
||||||
c.set_focus()
|
c.set_focus()
|
||||||
|
|
||||||
mouse_click(c)
|
mouse_click(c)
|
||||||
|
|
||||||
keyboard.send_keys('^{HOME}')
|
keyboard.send_keys('^{HOME}')
|
||||||
save_tag(window, outdir)
|
time.sleep(1)
|
||||||
|
p = save_tag(window, outdir)
|
||||||
|
|
||||||
|
mouse_click(c)
|
||||||
keyboard.send_keys('^{END}')
|
keyboard.send_keys('^{END}')
|
||||||
save_tag(window, outdir)
|
time.sleep(1)
|
||||||
# exit()
|
p = save_tag(window, outdir)
|
||||||
|
|
||||||
# mouse_click(window['註釋/標籤'])
|
# mouse_click(c)
|
||||||
# TToolBar = window.child_window(class_name='TToolBar', found_index=2)
|
# keyboard.send_keys('^{HOME}')
|
||||||
|
# time.sleep(1)
|
||||||
|
# p = save_tag(window, outdir)
|
||||||
|
|
||||||
# Button5 = TToolBar.Button5
|
if not only_tag:
|
||||||
# Button5.wait('ready', 9)
|
|
||||||
# time.sleep(2)
|
|
||||||
# mouse_click(Button5)
|
|
||||||
|
|
||||||
# export_to_file = window['輸出至檔案']
|
keyboard.send_keys('^s')
|
||||||
# export_to_file.wait('ready', 99)
|
keyboard.send_keys('{DOWN}')
|
||||||
# export = export_to_file.wrapper_object()
|
keyboard.send_keys('{DOWN}')
|
||||||
# export.click()
|
|
||||||
|
|
||||||
# TDicomTagListForm = window['DICOM 標籤清單Dialog']
|
# time.sleep(9)
|
||||||
|
|
||||||
# dlg_save = Desktop(backend="uia").window(title='另存新檔')
|
# logging.warning(str(datetime.datetime.now()))
|
||||||
# NEdit = dlg_save['檔案名稱(N):Edit']
|
TFormSaveBitmap = window['選項']
|
||||||
# NEdit.wait('ready', 99)
|
# TFormSaveBitmap.dump_tree(filename='z-%s-TFormSaveBitmap.txt'%chartno)
|
||||||
# edit = NEdit.wrapper_object()
|
|
||||||
# pahtname = os.path.join(outdir, edit.get_value())
|
|
||||||
# for p in glob.glob(pahtname + '*'):
|
|
||||||
# os.remove(p)
|
|
||||||
# edit.set_text(pahtname)
|
|
||||||
# dlg_save['存檔(S)Button'].wrapper_object().click()
|
|
||||||
|
|
||||||
# TDicomTagListForm.close()
|
Edit5 = TFormSaveBitmap.Edit5
|
||||||
# break
|
Edit5.wait('ready')
|
||||||
|
Edit5.set_text(outdir)
|
||||||
|
|
||||||
|
# TFormSaveBitmap.Edit5.set_text(outdir)
|
||||||
|
TFormSaveBitmap.Button2.click()
|
||||||
|
|
||||||
keyboard.send_keys('^s')
|
logging.warning('button clicked')
|
||||||
keyboard.send_keys('{DOWN}')
|
time.sleep(1)
|
||||||
keyboard.send_keys('{DOWN}')
|
logging.warning('saving started')
|
||||||
|
saving = window.child_window(title_re='^另存新檔.*')
|
||||||
# time.sleep(9)
|
logging.warning('saving exists')
|
||||||
|
saving.wait_not("exists", timeout=999)
|
||||||
# logging.warning(str(datetime.datetime.now()))
|
logging.warning('saving not exists')
|
||||||
TFormSaveBitmap = window['選項']
|
|
||||||
# TFormSaveBitmap.dump_tree(filename='z-%s-TFormSaveBitmap.txt'%chartno)
|
|
||||||
|
|
||||||
Edit5 = TFormSaveBitmap.Edit5
|
|
||||||
Edit5.wait('ready')
|
|
||||||
Edit5.set_text(outdir)
|
|
||||||
|
|
||||||
# TFormSaveBitmap.Edit5.set_text(outdir)
|
|
||||||
TFormSaveBitmap.Button2.click()
|
|
||||||
|
|
||||||
logging.warning('button clicked')
|
|
||||||
time.sleep(1)
|
|
||||||
logging.warning('saving started')
|
|
||||||
saving = window.child_window(title_re='^另存新檔.*')
|
|
||||||
logging.warning('saving exists')
|
|
||||||
saving.wait_not("exists", timeout=999)
|
|
||||||
logging.warning('saving not exists')
|
|
||||||
|
|
||||||
c.set_focus()
|
c.set_focus()
|
||||||
mouse_click(c)
|
mouse_click(c)
|
||||||
|
@ -229,7 +214,7 @@ def save_study(chartno, outdir):
|
||||||
# time.sleep(9)
|
# time.sleep(9)
|
||||||
|
|
||||||
|
|
||||||
def save_patient(chartno, outdir, query = "CT,MR"):
|
def save_patient(chartno, outdir, query = "CT,MR", only_tag=False):
|
||||||
|
|
||||||
app = Application(backend="uia").connect(title_re='.* - Microsoft Edge$')
|
app = Application(backend="uia").connect(title_re='.* - Microsoft Edge$')
|
||||||
logging.warning(str(app))
|
logging.warning(str(app))
|
||||||
|
@ -297,7 +282,7 @@ def save_patient(chartno, outdir, query = "CT,MR"):
|
||||||
logging.warning(str(item.get_properties()))
|
logging.warning(str(item.get_properties()))
|
||||||
mouse_click(item)
|
mouse_click(item)
|
||||||
|
|
||||||
save_study(chartno, outdir)
|
save_study(chartno, outdir, only_tag)
|
||||||
logging.warning(chartno+" completed "+query)
|
logging.warning(chartno+" completed "+query)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import pandas as pd
|
||||||
|
|
||||||
import pacs
|
import pacs
|
||||||
|
|
||||||
def get_pacs(series, outdir, max_patients=10):
|
def get_pacs(series, outdir, max_patients=100):
|
||||||
app, window = pacs.login()
|
app, window = pacs.login()
|
||||||
num_patients = 0
|
num_patients = 0
|
||||||
for index, row in series.items():
|
for index, row in series.items():
|
||||||
|
@ -22,7 +22,7 @@ def get_pacs(series, outdir, max_patients=10):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
logging.warning('saving '+chartno)
|
logging.warning('saving '+chartno)
|
||||||
pacs.save_patient(chartno, f'{outdir}\\{chartno}', query="CT,MR")
|
pacs.save_patient(chartno, f'{outdir}\\{chartno}', query="CT,MR", only_tag=True)
|
||||||
|
|
||||||
complete_file.touch()
|
complete_file.touch()
|
||||||
num_patients += 1
|
num_patients += 1
|
||||||
|
|
Loading…
Reference in a new issue