Пример #1
0
    def get_it(self, doctor, sms_code, total_fee):
        """
        挂号
        """
        duty_source_id = str(doctor['dutySourceId'])
        hospital_id = self.config.hospital_id
        department_id = self.config.department_id
        patient_id = str(self.config.patient_id)
        hospital_card_id = self.config.hospital_card_id
        medicare_card_id = self.config.medicare_card_id
        reimbursement_type = self.config.reimbursement_type
        doctor_id = str(doctor['doctorId'])
        logging.info("doctor, sms_code, total_fee")
        logging.info(doctor)
        logging.info(sms_code)
        logging.info(total_fee)
        logging.info("开始挂号" + ", duty_source_id=" + duty_source_id +
                     ", hospital_id=" + hospital_id + ", department_id=" +
                     department_id + ", patient_id=" + patient_id +
                     ", hospital_card_id=" + hospital_card_id +
                     ", medicare_card_id=" + medicare_card_id +
                     ", reimbursement_type=" + reimbursement_type +
                     ", doctor_id=" + doctor_id)
        #新版可能不区分儿童与成人,需测试
        if self.config.children == 'true':
            cid_type = self.config.cid_type
            children_name = self.config.children_name
            children_idno = self.config.children_idno
            children_gender = GetInformation(children_idno).get_sex()
            children_birthday = GetInformation(children_idno).get_birthday()
            payload = {
                'phone': self.config.mobile_no,
                'dutySourceId': duty_source_id,
                'hospitalId': hospital_id,
                'departmentId': department_id,
                'doctorId': doctor_id,
                'patientId': patient_id,
                'hospitalCardId': hospital_card_id,
                'medicareCardId': medicare_card_id,
                "reimbursementType": reimbursement_type,  # 报销类型
                'smsVerifyCode': sms_code,  # TODO 获取验证码
                'childrenName': children_name,
                'childrenIdNo': children_idno,
                'cidType': cid_type,
                'childrenGender': children_gender,
                'childrenBirthday': children_birthday,
                'isAjax': 'true'
            }
        else:
            payload = {
                "hospitalId": hospital_id,
                "departmentId": department_id,
                "dutySourceId": duty_source_id,
                "doctorId": doctor_id,
                "patientId": patient_id,
                "dutyDate": doctor['dutyDate'],
                "dutyCode": doctor['dutyCode'],
                "totalFee": total_fee,
                "fcode": "",
                "period": "",
                "mapDepartmentId": "",
                "mapDoctorId": "",
                "planCode": "",
                "medicareCardId": medicare_card_id,
                "jytCardId": "",
                "hospitalCardId": hospital_card_id,
                "mapDutySourceId": "",
                "smsCode": sms_code,
                "mobileNo": self.config.mobile_no,
                "feeColor": "",
                "dutyImgType": ""
            }
        #save order
        response = self.browser.post(self.confirm_url, data=payload)
        logging.debug("payload:" + json.dumps(payload))
        logging.debug("response data:" + response.text)

        try:
            data = json.loads(response.text)
            if data["resCode"] == 0:
                #20181027,成功result:
                #{"msg":"成功","code":1,"orderId":"97465746","isLineUp":false}
                logging.info("挂号成功")
                return True
            if data["resCode"] == 8008:
                #重复订单,说明挂号成功
                #{"code":8008,"msg":"科室预约规则检查重复订单","data":null}
                logging.error(data["msg"])
                return True
            else:
                logging.error(data["msg"])
                return False

        except Exception as e:
            logging.error(repr(e))
            time.sleep(1)
Пример #2
0
    def __init__(self, config_path):
        try:
            with open(config_path, "r", encoding="utf-8") as yaml_file:
                data = yaml.load(yaml_file)
                debug_level = data["DebugLevel"]
                if debug_level == "debug":
                    self.debug_level = logging.DEBUG
                elif debug_level == "info":
                    self.debug_level = logging.INFO
                elif debug_level == "warning":
                    self.debug_level = logging.WARNING
                elif debug_level == "error":
                    self.debug_level = logging.ERROR
                elif debug_level == "critical":
                    self.debug_level = logging.CRITICAL

                logging.basicConfig(
                    level=self.debug_level,
                    format=
                    '%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s',
                    datefmt='%a, %d %b %Y %H:%M:%S')

                self.mobile_no = data["username"]
                self.password = data["password"]
                self.date = data["date"]
                self.hospital_id = data["hospitalId"]
                self.department_id = data["departmentId"]
                self.duty_code = data["dutyCode"]
                self.patient_name = data["patientName"]
                self.hospital_card_id = data["hospitalCardId"]
                self.medicare_card_id = data["medicareCardId"]
                self.reimbursement_type = data["reimbursementType"]
                self.doctorName = data["doctorName"]
                self.children_name = data["childrenName"]
                self.children_idno = data["childrenIdNo"]
                self.cid_type = data["cidType"]
                self.children = data["children"]
                self.assign = data['assign']
                self.remaining = data['remaining']
                self.week = data['week']
                self.chooseBest = {
                    "yes": True,
                    "no": False
                }[data["chooseBest"]]
                self.patient_id = int()
                self.web_password = "******"
                try:
                    self.useIMessage = data["useIMessage"]
                except KeyError:
                    self.useIMessage = "false"
                try:
                    self.useQPython3 = data["useQPython3"]
                except KeyError:
                    self.useQPython3 = "false"
                try:
                    self.children = data["children"]
                except KeyError:
                    self.children = "false"
                #
                logging.info("配置加载完成")
                logging.debug("手机号:" + str(self.mobile_no))
                logging.debug("挂号日期:" + str(self.date))
                logging.debug("医院id:" + str(self.hospital_id))
                logging.debug("科室id:" + str(self.department_id))
                logging.debug("上午/下午:" + str(self.duty_code))
                logging.debug("就诊人姓名:" + str(self.patient_name))
                logging.debug("所选医生:" + str(self.doctorName))
                logging.debug("是否挂指定医生:" + str(self.assign))
                logging.debug("检索每天余票:" + str(self.remaining))
                logging.debug("检索周:" + str(self.week))
                logging.debug("是否挂儿童号:" + str(self.children))
                if self.children == "true":
                    logging.debug("患儿姓名:" + str(self.children_name))
                    logging.debug("患儿证件号" + str(self.children_idno))
                    logging.debug("患儿证件类型:" + str(self.cid_type))
                    logging.debug(
                        "患儿性别:" +
                        str(GetInformation(self.children_idno).get_sex()))
                    logging.debug(
                        "患儿生日:" +
                        str(GetInformation(self.children_idno).get_birthday()))
                logging.debug("使用mac电脑接收验证码:" + str(self.useIMessage))
                logging.debug("是否使用 QPython3 运行本脚本:" + str(self.useQPython3))

                if not self.date:
                    logging.error("请填写挂号时间")
                    exit(-1)

        except Exception as e:
            logging.error(repr(e))
            sys.exit()
Пример #3
0
    def get_it(self, doctor, sms_code):
        """
        挂号
        """
        duty_source_id = str(doctor['period'][0]['uniqProductKey'])
        hospital_id = self.config.hospital_id
        department_id = self.config.department_id
        date = self.config.date
        first_dept_code = self.config.first_dept_code
        second_dept_code = self.config.second_dept_code
        patient_id = str(self.config.patient_id)
        hospital_card_id = self.config.hospital_card_id
        medicare_card_id = self.config.medicare_card_id
        reimbursement_type = self.config.reimbursement_type
        doctor_id = str(doctor['uniqProductKey'])
        # 新版可能不区分儿童与成人,需测试
        if self.config.children == 'true':
            cid_type = self.config.cid_type
            children_name = self.config.children_name
            children_idno = self.config.children_idno
            children_gender = GetInformation(children_idno).get_sex()
            children_birthday = GetInformation(children_idno).get_birthday()
            payload = {
                'phone': self.config.mobile_no,
                'uniqProductKey': duty_source_id,
                'hosCode': hospital_id,
                'firstDeptCode': first_dept_code,
                'secondDeptCode': second_dept_code,
                'doctorId': doctor_id,
                'patientId': patient_id,
                'hospitalCardId': hospital_card_id,
                'medicareCardId': medicare_card_id,
                "reimbursementType": reimbursement_type,  # 报销类型
                'smsVerifyCode': sms_code,  # TODO 获取验证码
                'childrenName': children_name,
                'childrenIdNo': children_idno,
                'cidType': cid_type,
                'childrenGender': children_gender,
                'childrenBirthday': children_birthday,
                'isAjax': 'true'
            }
        else:
            payload = {
                "hosCode": hospital_id,
                "firstDeptCode": first_dept_code,
                "secondDeptCode": second_dept_code,
                # "departmentId": department_id,
                "uniqProductKey": duty_source_id,
                # "doctorId": doctor_id,
                # "patientId": patient_id,
                "treatmentDay": date,
                "dutyTime": doctor['period'][0]['dutyTime'],
                # "dutyCode": doctor['period'][0]['ncode'],
                # "totalFee": total_fee,
                # "fcode": "",
                # "period": "",
                # "mapDepartmentId": "",
                # "mapDoctorId": "",
                # "planCode": "",
                "cardNo": patient_id,
                # "jytCardId": "",
                "hospitalCardId": hospital_card_id,
                "cardType": "IDENTITY_CARD",
                # "mapDutySourceId": "",
                "orderFrom": "OTHER",
                "smsCode": sms_code,
                "phone": self.config.mobile_no,
                # "feeColor": "",
                # "dutyImgType": ""
            }
        # save order
        response = self.browser.post(self.confirm_url, data=payload)
        logging.debug("payload:" + json.dumps(payload))
        print('打印下单数据', json.loads(response.text))
        logging.debug("response data:" + response.text)

        try:
            data = json.loads(response.text)
            if data["resCode"] == 0:
                # 20181027,成功result:
                # {"msg":"成功","code":1,"orderId":"97465746","isLineUp":false}
                logging.info("挂号成功")
                return True
            if data["resCode"] == 8008:
                # 重复订单,说明挂号成功
                # {"code":8008,"msg":"科室预约规则检查重复订单","data":null}
                logging.error(data["msg"])
                return True
            else:
                logging.error(data["msg"])
                return False

        except Exception as e:
            logging.error(repr(e))
            time.sleep(1)
Пример #4
0
    def get_it(self, doctor, sms_code):
        """
        挂号
        """
        duty_source_id = str(doctor['dutySourceId'])
        hospital_id = self.config.hospital_id
        department_id = self.config.department_id
        patient_id = self.config.patient_id
        hospital_card_id = self.config.hospital_card_id
        medicare_card_id = self.config.medicare_card_id
        reimbursement_type = self.config.reimbursement_type
        doctor_id = str(doctor['doctorId'])
        if self.config.children == 'true':
            cid_type = self.config.cid_type
            children_name = self.config.children_name
            children_idno = self.config.children_idno
            children_gender = GetInformation(children_idno).get_sex()
            children_birthday = GetInformation(children_idno).get_birthday()

            payload = {
                'dutySourceId': duty_source_id,
                'hospitalId': hospital_id,
                'departmentId': department_id,
                'doctorId': doctor_id,
                'patientId': patient_id,
                'hospitalCardId': hospital_card_id,
                'medicareCardId': medicare_card_id,
                "reimbursementType": reimbursement_type,  # 报销类型
                'smsVerifyCode': sms_code,  # TODO 获取验证码
                'childrenName': children_name,
                'childrenIdNo': children_idno,
                'cidType': cid_type,
                'childrenGender': children_gender,
                'childrenBirthday': children_birthday,
                'isAjax': True
            }
        else:
            payload = {
                'dutySourceId': duty_source_id,
                'hospitalId': hospital_id,
                'departmentId': department_id,
                'doctorId': doctor_id,
                'patientId': patient_id,
                'hospitalCardId': hospital_card_id,
                'medicareCardId': medicare_card_id,
                "reimbursementType": reimbursement_type,  # 报销类型
                'smsVerifyCode': sms_code,  # TODO 获取验证码
                'childrenBirthday': "",
                'isAjax': True
            }
        logging.debug("confirm_url payload:" + json.dumps(payload))
        response = self.browser.post(self.confirm_url, data=payload)
        logging.debug("confirm_url response data:" + response.text)

        try:
            data = json.loads(response.text)
            if data["msg"] == "成功" and data["code"] == 1:
                #20181027,成功result:
                #{"msg":"成功","code":1,"orderId":"97465746","isLineUp":false}
                logging.info("挂号成功")
                return True
            if data["code"] == 8008:
                #重复订单,说明挂号成功
                #{"code":8008,"msg":"科室预约规则检查重复订单","data":null}
                logging.error(data["msg"])
                return True
            else:
                logging.error(data["msg"])
                return False

        except Exception as e:
            logging.error(repr(e))
            time.sleep(1)
Пример #5
0
    def __init__(self, config_path):
        try:
            with open(config_path, "r", encoding="utf-8") as yaml_file:
                mysql_single = mysqlSingle()
                conn, cursor = mysql_single.get_conn()
                sql = "select * from guahao where `is_show` = '0'"
                argvs = sys.argv
                if len(argvs) > 1:
                    argvId = sys.argv[1]
                    if argvId:
                        sql += ' and id = ' + argvId
                sql += ' order by `id` desc limit 1;'
                data = mysql_single.execute_sql_one(sql)
                # data = yaml.load(yaml_file, Loader=yaml.FullLoader)
                debug_level = data["debug_level"]
                if debug_level == "debug":
                    self.debug_level = logging.DEBUG
                elif debug_level == "info":
                    self.debug_level = logging.INFO
                elif debug_level == "warning":
                    self.debug_level = logging.WARNING
                elif debug_level == "error":
                    self.debug_level = logging.ERROR
                elif debug_level == "critical":
                    self.debug_level = logging.CRITICAL

                logging.basicConfig(
                    level=self.debug_level,
                    format=
                    '%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s',
                    datefmt='%a, %d %b %Y %H:%M:%S')
                self.id = data["id"]
                self.mobile_no = data["username"]
                self.sms_code = data["code"]
                self.password = data["password"]
                self.date = str(data["date"])
                self.hospital_id = data["hospital_id"]
                self.department_id = data["department_id"]
                self.weekDescDict = {
                    '周五': 5,
                    '周六': 6,
                    '周日': 7,
                    '周一': 1,
                    '周二': 2,
                    '周三': 3,
                    '周四': 4,
                }
                self.first_dept_code = data["first_dept_code"]
                self.second_dept_code = data["second_dept_code"]
                self.duty_code = data["duty_code"]
                self.patient_name = data["patient_name"]
                self.hospital_card_id = data["hospital_card_id"]
                self.medicare_card_id = data["medicare_card_id"]
                self.reimbursement_type = data["reimbursement_type"]
                self.doctorName = data["doctor_name"]
                self.children_name = data["children_name"]
                self.children_idno = data["children_id_no"]
                self.cid_type = data["cid_type"]
                self.children = data["children"]
                self.assign = data['assign']
                self.remaining = data['remaining']
                self.week = data['week']
                self.chooseBest = {
                    "yes": True,
                    "no": False
                }[data["choose_best"]]
                self.patient_id = int()
                self.web_password = "******"
                try:
                    self.useIMessage = data["use_imessage"]
                except KeyError:
                    self.useIMessage = "false"
                try:
                    self.useQPython3 = data["use_qpython3"]
                except KeyError:
                    self.useQPython3 = "false"
                try:
                    self.children = data["children"]
                except KeyError:
                    self.children = "false"
                #
                logging.info("配置加载完成")
                logging.debug("手机号:" + str(self.mobile_no))
                logging.debug("挂号日期:" + str(self.date))
                logging.debug("医院id:" + str(self.hospital_id))
                logging.debug("科室id:" + str(self.department_id))
                logging.debug("一级id:" + str(self.first_dept_code))
                logging.debug("二级id:" + str(self.second_dept_code))
                logging.debug("上午/下午:" + str(self.duty_code))
                logging.debug("就诊人姓名:" + str(self.patient_name))
                logging.debug("所选医生:" + str(self.doctorName))
                logging.debug("是否挂指定医生:" + str(self.assign))
                logging.debug("检索每天余票:" + str(self.remaining))
                logging.debug("检索周:" + str(self.week))
                logging.debug("是否挂儿童号:" + str(self.children))
                if self.children == "true":
                    logging.debug("患儿姓名:" + str(self.children_name))
                    logging.debug("患儿证件号" + str(self.children_idno))
                    logging.debug("患儿证件类型:" + str(self.cid_type))
                    logging.debug(
                        "患儿性别:" +
                        str(GetInformation(self.children_idno).get_sex()))
                    logging.debug(
                        "患儿生日:" +
                        str(GetInformation(self.children_idno).get_birthday()))
                logging.debug("使用mac电脑接收验证码:" + str(self.useIMessage))
                logging.debug("是否使用 QPython3 运行本脚本:" + str(self.useQPython3))

                if not self.date:
                    logging.error("请填写挂号时间")
                    exit(-1)

        except Exception as e:
            print(traceback.format_exc())
            logging.error(repr(e))
            sys.exit()