Ejemplo n.º 1
0
def test_pay_org(browser, cache):
    log.info('开始运行医技执行科室收费脚本')
    login.select_workstation(browser, '医技工作站', cache)  # 工作站是否打开
    #获取申请单及执行科室
    application_type_list = ['检验单', '治疗单', '病理类', '检查单']
    #对所有申请单进行归类整理,把执行科室相同的申请单归为一类
    for application_type in application_type_list:
        diction = cache.get(application_type)
        if diction:
            application = list(diction.keys())
            executive_department_list = list(diction.values())
            for t in list(set(executive_department_list)):
                on_click(browser, (By.XPATH, '//button[contains(text(),"【")]'))
                #选择工作站
                executive_department_name = HOSPITA_AREA + ': ' + t
                select_dept(browser, '选择工作台', executive_department_name,
                            (By.XPATH, select_window.选择工作站))
                on_click(browser,
                         (By.XPATH, "//button[contains(text(),'确定')]"))
                # is_refresh(browser,browser.find_element_by_xpath('//div[contains(text(),"门诊执行收退费")]'))
                element_wait(browser,
                             (By.XPATH, '//div[contains(text(),"门诊执行收退费")]'))
                on_click(browser,
                         (By.XPATH, '//div[contains(text(),"门诊执行收退费")]'))
                on_click(browser, (By.LINK_TEXT, '门诊执行科室收费'))
                # 刷卡
                date = time.strftime("%Y-%m-%d", time.localtime())
                send_value(browser, (By.XPATH, application_list.开单时间),
                           '2017-06-15')
                send_value(browser, (By.XPATH, patient_message.卡号),
                           cache.get('patient_card') + '\n')
                # 勾选是否打印
                on_click(browser,
                         (By.XPATH, '//label[contains(text(),"是否打印收费凭证")]'))
                first_pos = 0
                for i in range(executive_department_list.count(t)):
                    element_inexistence(
                        browser, (By.XPATH, "//div[contains(text(),'正在加载')]"))
                    new_list = executive_department_list[first_pos:]
                    next_pos = new_list.index(t) + 1
                    index = first_pos + new_list.index(t)
                    first_pos += next_pos
                    locator = (By.XPATH, '//div[contains(text(),"%s")]' %
                               application[index])
                    on_click(browser, locator)
                    # time.sleep(2)
                    element_inexistence(
                        browser, (By.XPATH, "//div[contains(text(),'正在加载')]"))
                    application_detail_text = browser.find_element_by_xpath(
                        application_detail.申请单计费明细列表).text
                    if application_detail_text.strip() != '':
                        on_click(browser,
                                 (By.XPATH,
                                  '//button[contains(text(),"收费(Enter)")]'))
                        on_click(browser,
                                 (By.XPATH, '//button[contains(text(),"是")]'))
                    else:
                        log.info('%s申请单已计费' % application[index])
                element_wait(browser, (By.XPATH, application_detail.申请单计费明细列表))
                browser.refresh()
Ejemplo n.º 2
0
def focus(driver, locator):
    """Sets focus to element identified by `locator`."""
    element_wait(driver,locator)
    target = driver.find_element(locator[0],locator[1])
    driver.execute_script("arguments[0].scrollIntoView();", target)  # 拖动到可见的元素去
    on_click(driver,locator)
    return
Ejemplo n.º 3
0
def test_arrearage_return_premium(browser, cache):
    log.info('开始运行欠费退费脚本')
    login.select_workstation(browser, '门诊挂号收费工作台', cache)  # 工作站是否打开
    on_click(browser, (By.XPATH, '//div[contains(text(),"欠费管理")]'))
    on_click(browser, (By.LINK_TEXT, '欠费结账/退费'))
    boolen = get_prompt(browser)
    if boolen:
        if re.sub('\D', '', boolen) == '0':
            log.info(boolen)
            return
        else:
            on_click(browser, (By.XPATH, "//button[contains(text(),'确定')]"))
    #刷卡
    send_value(browser, (By.XPATH, patient_message.刷卡),
               cache.get('patient_card') + '\n')
    end_time = time.time() + 1
    # arrearage_list_text = ''    #欠费记账列表信息
    while True:
        arrearage_list_text = get_text(browser,
                                       (By.XPATH, arrearage_list.欠费记账患者列表))
        if '暂无可显示的欠费病人信息' not in arrearage_list_text:
            break
        if time.time() > end_time:
            log.info('欠费记账患者列表加载超时')
            return
    lists = ['处方单', '毒麻单', '检查单', '检验单', '治疗单', '皮试单', '输液单', '草药', '病理类']
    applys = []  #所有申请单号
    for appply_type in lists:
        applycation = cache.get(appply_type)
        if applycation:
            applys = applys + list(applycation)
    for apply_id in applys:
        if is_selected(browser, ((By.XPATH, arrearage_list.全选))):
            on_click(browser, (By.XPATH, arrearage_list.全选))
        rek_no = find_rek_no(apply_id)
        if rek_no == []:
            log.info('%s申请单未计费或已退费' % rek_no)
            continue
        elif rek_no in arrearage_list_text:
            on_click(browser,
                     (By.XPATH, '//div[contains(text(),"%s")]' % rek_no))
            on_click(browser, (By.XPATH, '//div[contains(text(),"退 费")]'))
            element_wait(browser,
                         (By.XPATH, '//span[contains(text(),"欠费记账退费窗口")]'))
            if '正常' in get_text(browser,
                                (By.XPATH, arrearage_return_premium.退费列表)):
                webElement = browser.find_elements_by_xpath(
                    arrearage_return_premium.退费列表 +
                    '//label[contains(text(),"正常")]')
                for element in webElement:
                    element.click()
            on_click(browser, (By.XPATH, '//button[contains(text(),"确定退费")]'))
            on_click(browser, (By.XPATH, '//button[contains(text(),"是")]'))
            microsoft_xps_document_writer('欠费退费单')
Ejemplo n.º 4
0
def select_lists(browser,locator,list_message):
    element_wait(browser,locator)
    elements =  browser.find_elements(locator[0],locator[1])
    for i in range(0, len(elements)):
        message_elements = browser.find_elements(locator[0],locator[1])[i]
        texts = (message_elements.text).split()

        boolen = fun(list_message,texts)
        if boolen:
            locator = (locator[0], locator[1] + str([i + 1]) + '//div')
            print(locator)
            on_click(browser, locator)
            return texts
    return False
Ejemplo n.º 5
0
def invoice_record_query(browser, cache):
    login.select_workstation(browser, '门诊挂号收费工作台', cache)  # 工作站是否打开
    on_click(browser, (By.XPATH, '//div[contains(text(),"发票打印管理")]'))
    on_click(browser, (By.LINK_TEXT, '发票记录查询'))
    if element_wait(browser,
                    (By.XPATH, '//span[contains(text(),"验证最小票据号窗口")]')):
        usename = get_text(browser, (By.XPATH, head.用户)).split('(')[0]
        bill_num = find_min_ticket(usename, '门诊收费发票')
        send_value(browser, (By.XPATH, verify_bill_window.票据号),
                   bill_num)  #输入票据号
        on_click(browser, (By.XPATH, verify_bill_window.确定))
        send_value(browser, (By.XPATH, query_area.刷卡),
                   cache.get('patient_card') + '\n')
        end_time = time.time() + 1
        while True:
            consume_collection = get_text(
                browser, (By.XPATH, invoice_history_list.发票记录))
            if consume_collection != '暂无可显示票据记录...':
                break
            if time.time() > end_time:
                log.info('加载消费单失败')
                break
        return True
    else:
        log.info('验证最小票据号窗口弹出异常')
        return False
def choice_loss(browser, test_case, cache):
    login.select_workstation(browser, '门诊挂号收费工作台', cache)  #工作站是否打开
    browser.find_element(By.XPATH, '//div[contains(text(),"门诊挂号")]').click()
    browser.find_element(By.LINK_TEXT, '就诊卡挂失').click()
    browser.find_element(By.XPATH, InputLocator.name).clear()
    browser.find_element(By.XPATH,
                         InputLocator.name).send_keys(test_case[loss['name']])
    browser.find_element(By.XPATH, InputLocator.id_type).clear()
    browser.find_element(By.XPATH, InputLocator.id_type).send_keys('居民身份证')
    browser.find_element(By.XPATH, InputLocator.id_card).clear()
    browser.find_element(By.XPATH, InputLocator.id_card).send_keys(
        test_case[loss['id_card']])
    browser.find_element(By.XPATH, InputLocator.phone_num).clear()
    browser.find_element(By.XPATH, InputLocator.phone_num).send_keys(
        test_case[loss['phone_num']])
    browser.implicitly_wait(30)
    if element_wait(browser, (By.XPATH, '//button[contains(text(),"查询")]')):
        browser.find_element(By.XPATH,
                             '//button[contains(text(),"查询")]').click()
    locator = (By.XPATH, DivLocator.checkbox)
    if element_wait(browser, locator):
        browser.find_element(By.XPATH, DivLocator.checkbox).click()  #选择患者
    else:
        log.info('没查询到该患者信息!')
def test_cancel_loss_card(browser, test_case, cache):
    log.info('开始运行就诊卡取消挂失脚本')
    choice_loss(browser, test_case, cache)
    browser.find_element(By.XPATH, '//button[contains(text(),"取消挂失")]').click()
    # 判断患者卡列表窗口是否打开
    locators = (By.XPATH, DivLocator.pai_list)
    if is_text(browser, locators, '患者卡列表'):
        if element_wait(browser, (By.XPATH, DivLocator.checkbox_pai)):
            browser.find_element(By.XPATH, DivLocator.checkbox_pai).click()
            browser.find_element(By.XPATH, ButtonLocator.cancel_loss).click()
            browser.find_element(By.XPATH,
                                 '//button[contains(text(),"是")]').click()
        else:
            log.info('就诊未挂失,不能取消挂失')
    else:
        log.info('取消挂失窗口无法正常打开!')

    log.info('就诊卡取消挂失脚本运行结束')
def test_regist_button(browser, test_case, cache):
    login.select_workstation(browser, '门诊挂号收费工作台', cache)
    #验证取号按钮功能
    browser.find_element_by_xpath(
        '//button[contains(text(),"取        号(U)")]').click()
    locator = (By.XPATH, '//button[contains(text(),"取        号")]')
    if element_wait(browser, locator):
        log.info('取号按钮功能pass')
    else:
        log.info('取号按钮功能fail')
    browser.refresh()
    #验证退号按钮功能
    browser.find_element_by_xpath(
        '//button[contains(text(),"退        号(X)")]').click()
    locator = (By.XPATH, div[4]['key'])
    if is_text(browser, locator, '门诊退号'):
        log.info("退号按钮功能pass")
        browser.find_element_by_xpath(
            '//button[contains(text(),"关闭")]').click()
    else:
        log.info("退号按钮功能fail")
    #验证重置按钮功能
    dict = TestCaseCodeTable.patient_visit_card
    cardElement = \
    browser.find_element_by_xpath(form[0]['key']).find_elements_by_tag_name('input')[3]
    cardElement.clear()
    cardElement.send_keys(test_case[dict['patient_card']] + '\n')
    browser.find_element_by_xpath('//button[contains(text(),"否")]').click()
    browser.find_element_by_xpath('//button[contains(text(),"重置")]').click()
    text = browser.find_element_by_xpath(
        form[0]['key']).find_elements_by_tag_name('input')[0].get_attribute(
            'value')
    if text == '':
        log.info('重置按钮功能pass')
    else:
        log.info('重置按钮功能fail')

    #验证号别过滤及门诊时间过滤
    result = 1
    #全部
    all_boxs = browser.find_elements_by_xpath('//label[contains(text(),"全部")]')
    for box in all_boxs:
        box.click()
    lists = outp_message(browser)
    if len(list(set(lists[0]))) > 1 and len(list(set(lists[1]))) > 1:
        # log.info('全部按钮验证pass')
        pass
    elif len(list(set(lists[0]))) == 1 and ('急诊' in lists[0]):
        # log.info('全部按钮验证pass')
        pass
    else:
        # log.info('全部按钮验证fail')
        result = 0
    #全天,普通和急诊
    browser.find_element_by_xpath('//label[contains(text(),"全天")]').click()
    browser.find_element_by_xpath('//label[contains(text(),"普通和急诊")]').click()
    lists = outp_message(browser)
    for outp_type in lists[0]:
        if outp_type in ('普通', '急诊'):
            # log.info('普通急诊按钮验证pass')
            pass
        else:
            # log.info('普通急诊按钮验证fail')
            result = 0
    if list(set(lists[1])) in (['全天'], []):
        # log.info('全天按钮验证pass')
        pass
    else:
        # log.info('全天按钮验证fail')
        result = 0
    #上午,专家
    type_locator = '//label[contains(text(),"上午")]'
    date_locator = '//label[contains(text(),"专家")]'
    verify(browser, type_locator, date_locator, '上午', '专家', result)
    #下午,业余
    type_locator = '//label[contains(text(),"下午")]'
    date_locator = '//label[contains(text(),"业余")]'
    verify(browser, type_locator, date_locator, '下午', '业余', result)
    #晚上,保健
    type_locator = '//label[contains(text(),"晚上")]'
    date_locator = '//label[contains(text(),"保健")]'
    verify(browser, type_locator, date_locator, '晚上', '保健', result)

    if result:
        log.info('号源过滤按钮验证pass')
    else:
        log.info('号源过滤按钮验证fail')
Ejemplo n.º 9
0
def test_invoice_print(browser, cache):
    log.info('开始运行发票打印脚本')
    login.select_workstation(browser, '门诊挂号收费工作台', cache)  # 工作站是否打开
    on_click(browser, (By.XPATH, '//div[contains(text(),"发票打印管理")]'))
    on_click(browser, (By.LINK_TEXT, '发票打印'))
    if element_wait(browser,
                    (By.XPATH, '//span[contains(text(),"验证最小票据号窗口")]')):
        usename = get_text(browser, (By.XPATH, head.用户)).split('(')[0]
        bill_num = find_min_ticket(usename, '门诊收费发票')
        send_value(browser, (By.XPATH, verify_bill_window.票据号),
                   bill_num)  #输入票据号
        on_click(browser, (By.XPATH, verify_bill_window.确定))
        send_value(browser, (By.XPATH, query_area.刷卡),
                   cache.get('patient_card') + '\n')
        lists = ['处方单', '毒麻单', '检查单', '检验单', '治疗单', '皮试单', '输液单', '草药', '病理类']
        rek_no_list = []
        for list_type in lists:
            applys = cache.get(list_type)
            if applys == None:
                continue
            for apply_id in list(applys.keys()):
                result = find_rek_no(apply_id)
                if result != []:
                    rek_no_list.append(result.Rek.rek_no)
                else:
                    log.info('%s申请单未收费或已退费' % apply_id)
        end_time = time.time() + 1
        while True:
            consume_collection = get_text(browser,
                                          (By.XPATH, consume_list.消费记录))
            if consume_collection != '查询暂无结算消费记录':
                break
            if time.time() > end_time:
                log.info('加载消费单失败')
                break
        # print(rek_no_list)
        if rek_no_list == []:
            log.info('没有需要打印的单据')
            return
        status = False
        reks = []
        for rek_no in rek_no_list:
            if rek_no in consume_collection:
                focus(browser,
                      (By.XPATH, '//div[contains(text(),"%s")]' % rek_no))
                reks.append(rek_no)
                status = True
            else:
                log.info('%s消费单不存在或已作废' % rek_no)
        cache.set('rek_no_list', reks)
        if status:
            for rek_no in rek_no_list:
                end_time = time.time() + 1
                while True:
                    if rek_no in get_text(
                            browser, (By.XPATH, application_detail_list.费用明细)):
                        break
                    if time.time() > end_time:
                        log.info('加载消费明细失败')
                        break
            on_click(browser, (By.XPATH, '//button[contains(text(),"打印")]'))
            on_click(browser, (By.XPATH, '//button[contains(text(),"确 定")]'))
            on_click(browser, (By.XPATH, '//button[contains(text(),"是")]'))
            microsoft_xps_document_writer('发票单')
    else:
        log.info('验证最小票据号窗口弹出异常')
    log.info('发票打印脚本运行结束')