add QueryInPatientByWard

This commit is contained in:
Furen Xiao 2024-12-12 17:01:35 +08:00
parent 4ff7b97a93
commit d7c69765c6

View file

@ -1410,6 +1410,95 @@ def QueryInPatientByMonth(ID, year, month, SESSION=None):
ID, datetime.date(year, month, 1), datetime.date(year, month, number), SESSION ID, datetime.date(year, month, 1), datetime.date(year, month, number), SESSION
) )
def QueryInPatientByWard(ward, SESSION=None):
"""
病房作業
查詢條件輸入
病房查詢
"""
if not SESSION:
SESSION = Login()
url = (
"http://ihisaw.ntuh.gov.tw/WebApplication/InPatient/Ward/OpenWard.aspx?SESSION=%s"
% SESSION
)
driver.get(url)
elem = driver.find_element(By.CSS_SELECTOR,
"#NTUHWeb1_QueryInPatientPersonAccountControl1_DropListWard"
)
# print(elem.get_attribute('innerHTML'))
elem.send_keys(ward)
elem = driver.find_element(By.CSS_SELECTOR,
"#NTUHWeb1_QueryInPatientPersonAccountControl1_QueryAccountNoByWardInput"
)
elem.click()
elem = driver.find_element(By.CSS_SELECTOR,
"#NTUHWeb1_QueryInPatientPersonAccountControl1_CheckBoxShowDrMainColumn"
)
# if elem.get_attribute('checked'):
# elem.click()
# time.sleep(1)
while elem.get_attribute("checked"):
elem.click()
time.sleep(1)
elem = driver.find_element(By.CSS_SELECTOR,
"#NTUHWeb1_QueryInPatientPersonAccountControl1_CheckBoxShowDrMainColumn"
)
# driver.save_screenshot('/tmp/screenshot2.png')
# exit()
# browser.snapshot().save("webpage3.png")
html = driver.page_source
# print html
# browser.close()
d = pyquery.PyQuery(html)
PatientList = []
for tr in d(
"#NTUHWeb1_QueryInPatientPersonAccountControl1_DataGridAccountList > tbody"
)("tr")[1:]:
d2 = pyquery.PyQuery(tr)
# print d2.text()
# print d2('span')
# return
Pat = {}
for s in d2("span") + d2("a"):
if "id" in s.attrib:
key = s.attrib["id"].split("_")[-1]
Pat[key] = s.text
if "title" in s.attrib:
Pat[key + "Title"] = s.attrib["title"]
Pat["主治"] = d2("span")[7].text
Pat["住院"] = d2("span")[8].text
Pat[""] = d2("span")[9].text
Pat[""] = d2("span")[10].text
Pat["住院總天數"] = d2("span")[10].attrib["title"].split(":")[-1].strip()
Pat[""] = d2("span")[11].text
Pat["狀態"] = d2("span")[12].text
Pat["狀態2"] = d2("span")[13].text
Pat["id"] = "%s-%s" % (Pat[""], Pat["PatChartNo"])
# print Pat
PatientList.append(Pat)
return PatientList
def QueryDrIDInfoByID(ID, SESSION=None): def QueryDrIDInfoByID(ID, SESSION=None):
if not SESSION: if not SESSION:
@ -2214,7 +2303,7 @@ def QueryCaseByChartNo(ChartNo, NhiOrderCode='37029B', ApplySDate='2017/01/01',
if __name__ == "__main__": if __name__ == "__main__":
# a = Login() # a = Login()
a = OpenClinics('2024-12-10', AMPM='2', ClinicNo=9) # a = OpenClinics('2024-12-10', AMPM='2', ClinicNo=9)
# a = QueryModifyPatBase({'ChartNo': '3009684'}) # a = QueryModifyPatBase({'ChartNo': '3009684'})
# a = QueryModifyPatBase({'ChartNo': '8052734'}) # a = QueryModifyPatBase({'ChartNo': '8052734'})
# a = ElectronicMedicalReportViewer('3009684', startswith='T0', excluded=['T0_20181011630_T0186538260']) # a = ElectronicMedicalReportViewer('3009684', startswith='T0', excluded=['T0_20181011630_T0186538260'])
@ -2223,6 +2312,7 @@ if __name__ == "__main__":
# a = ReportPathology('2747688') # a = ReportPathology('2747688')
# a = ReportPathology('6369113') # a = ReportPathology('6369113')
# a = QueryInPatientByMonth('003160', 2017, 10) # a = QueryInPatientByMonth('003160', 2017, 10)
a = QueryInPatientByWard('08D')
# a = QueryDrIDInfoByID(settings.USER_ID) # a = QueryDrIDInfoByID(settings.USER_ID)
# a = WardQueryUncompletedChart() # a = WardQueryUncompletedChart()
# a = WardQueryUncompletedChartCost() # a = WardQueryUncompletedChartCost()