Пример #1
0
class AlterConfig:

    def __init__(self):
        self.conf = ReadConfig()
        self.request = HttpRequest()

    def alter_sys_config(self, id, value):
        url = self.conf.get('login', 'address') + '/syscenter/api/v1/config/updateConfig?id=' + str(id) + '&type=input'
        data = value
        response = self.request.put(url, data).json()
        print(response)

    def alter_default_setting(self, id, code, name, is_use, value):
        url = self.conf.get('login', 'address') + '/syscenter/api/v1/config/updateDefaultSetting'
        data = {
            "id": id,
            "settingCode": code,
            "settingName": name,
            "value": value,
            "valueType": None,
            "remark": None,
            "isUse": is_use,
            "systemCode": None,
            "zoneId": None,
            "typeData": "checkbox"
        }
        print('data', data)
        response = self.request.put(url, data).json()
        print('response', response)
Пример #2
0
class ConnectDB:
    def __init__(self):
        log.info('start connecting MySQL...')
        try:
            self.conf = ReadConfig()
            self.host = self.conf.get('mysql', 'host')
            self.port = int(self.conf.get('mysql', 'port'))
            self.username = self.conf.get('mysql', 'username')
            self.password = self.conf.get('mysql', 'password')
            self.db_sys = self.conf.get('mysql', 'db_sys')
            self.db_sf_full = self.conf.get('mysql', 'db_sf_full')
        except Exception as e:
            log.error('连接数据库失败\n错误信息如下\n'.format(e))
        else:
            log.info('连接数据库成功')

    def connect(self, dbname):
        return pymysql.Connect(host=self.host, port=self.port, user=self.username, passwd=self.password,
                               database=dbname, charset='utf8')

    def get_cur(self, conn):
        return conn.cursor()

    def execute(self, cur, sql):
        """
        执行没有变量的sql
        :param sql:
        """
        cur.execute(sql)
        return cur.fetchone()  # 返回的是元组

    def execute_pid(self, cur, sql, pid):
        """执行需要传入患者号patient_id的sql"""
        cur.execute(sql, (pid,))
        return cur.fetchone()[0]
Пример #3
0
 def __init__(self):
     self.tem = Template()
     cf = ReadConfig()
     self.audit_url = cf.get("auditcenter", "address")
     self.login_url = cf.get("login", "address")
     self.ts = self.tem.get_ts(0, 0) * 1000
     self.db = ConnectDB()
     self.conn = self.db.connect(self.db.db_sys)
     self.cur = self.db.get_cur(self.conn)
     sql = cf.get('sql', 'zoneid')
     self.zoneid = (self.db.execute(self.cur, sql))[0]
Пример #4
0
 def __init__(self):
     cf = ReadConfig()
     self.host = cf.get('db', 'host')
     self.port = cf.get('db', 'port')
     self.username = cf.get('db', 'username')
     self.passwd = cf.get('db', 'password')
     self.dbname = cf.get('db', 'dbname')
     self.connect = pymysql.Connect(host=self.host,
                                    port=int(self.port),
                                    user=self.username,
                                    passwd=self.passwd,
                                    db=self.dbname,
                                    charset='utf8')
     self.cur = self.connect.cursor()
Пример #5
0
class AddUser:
    def __init__(self):
        self.cf = ReadConfig()
        self.csv_path = os.path.join(
            os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
            'data', 'users.csv')
        url = self.cf.get('login', 'address') + '/syscenter/api/v1/currentUser'
        username = self.cf.get('login', 'username')
        passwd = self.cf.get('login', 'password')
        m = hashlib.md5()  # 创建md5对象
        m.update(passwd.encode())  # 生成加密字符串
        password = m.hexdigest()
        params = {"name": username, "password": password}
        self.headers = {'Content-Type': "application/json"}
        self.session = requests.session()
        res = self.session.post(url,
                                data=json.dumps(params),
                                headers=self.headers).json()
        print(res)

    def add_user(self, count):
        """
        添加多个用户
        :param count:  添加用户的数量
        """
        out = open(self.csv_path, 'w', newline='')  # 打开csv文件
        write_csv = csv.writer(out, dialect='excel')  # 定义文件类型为excel类型
        for i in range(1, (count + 1)):
            url = self.cf.get('login',
                              'address') + '/syscenter/api/v1/auth/addUser'
            user = [("cs" + str(i)), "123456"]  # 用户名和密码
            write_csv.writerow(user)
            params = {
                "dtoUser": {
                    "username": "******" + str(i),
                    "realname": "测试" + str(i),
                    "password": "******"
                },
                "drugIdList": [],
                "roleIdList": [88, 91, 89],
                "dtoUserDeptList": [],
                "resourceIdList": [],
                "dtoUserWorknumList": []
            }
            self.session.post(url,
                              data=json.dumps(params),
                              headers=self.headers).json()
Пример #6
0
class Login():
    def __init__(self):
        self.conf = ReadConfig()
        url = self.conf.get('login',
                            'address') + '/syscenter/api/v1/currentUser'
        username = self.conf.get('login', 'username')
        passwd = self.conf.get('login', 'password')
        m = hashlib.md5()  # 创建md5对象
        m.update(passwd.encode())  #  生成加密字符串
        password = m.hexdigest()
        params = {"name": username, "password": password}
        headers = {'Content-Type': "application/json"}
        self.session = requests.session()
        # res = self.session.post(url, data=json.dumps(params), headers=headers)
        res = self.session.post(url, data=json.dumps(params), headers=headers)
        print(res.json())
        start_sf_url = self.conf.get(
            'login',
            'address') + '/auditcenter/api/v1/startAuditWork'  # 获取开始审方url
        res2 = self.session.get(url=start_sf_url)  # 开始审方
        print(res2.json())

    def get_session(self):
        return self.session
Пример #7
0
class Ipt:
    def __init__(self):
        self.send = SendData()
        self.conf = ReadConfig()
        self.request = HttpRequest()
        self.db = ConnectDB()
        self.conn = self.db.connect(self.db.db_sys)
        self.cur = self.db.get_cur(self.conn)
        username = self.conf.get('login', 'username')
        sql = self.conf.get('sql', 'zoneid')
        self.zoneid = (self.db.execute(self.cur, sql))[0]
        # sql_uid = self.conf.get('sql', 'userid')
        # self.uid = (self.db.execute_pid(self.cur, sql_uid, username))[0]

    @wait
    def selNotAuditIptList(self):
        """
        待审住院列表根据患者号查询
        :return:   通过return结果可以获得以下数据:engineid res['data']['engineInfos'][0]['id']
        """
        url = self.conf.get('auditcenter',
                            'address') + '/api/v1/ipt/selNotAuditIptList'
        param = {"patientId": self.send.change_data['{{ts}}']}
        res = self.request.post_json(url, param)
        return res

    def get_engineid(self, n):
        """
        待审列表获取引擎id
        :param n: 如果某患者有多条待审任务则会有多个引擎id,n代表取第几个引擎id
        :return:
        """
        res = self.selNotAuditIptList()
        return res['data']['engineInfos'][n - 1]['id']

    def audit_multi(self, *ids):
        """
        待审住院任务列表批量通过
        :param ids:  引擎id
        """
        url = self.conf.get('auditcenter',
                            'address') + '/api/v1/auditBatchAgree'
        param = {
            "ids": ids,
            "auditType": 3,  # 3指住院
            "auditWay": 2
        }
        self.request.post_json(url, param)

    def ipt_audit(self, gp, engineid, audit_type):
        """
        医嘱详情审核任务
        :param gp:
        :param engineid:
        :param audit_type: 0 审核打回  1 审核打回(可双签) 2 审核通过
        orderType : 1:药物医嘱; 2:非药物医嘱;3:草药医嘱
        """
        url = self.conf.get('auditcenter',
                            'address') + '/api/v1/ipt/auditSingle'
        param = ''
        if audit_type == 0:
            param = {
                "groupOrderList": [{
                    "auditBoList": [],
                    "groupNo": gp,
                    "auditInfo": "必须修改",
                    "auditStatus": 0,
                    "engineId": engineid,
                    "orderType": 1
                }]
            }
        elif audit_type == 1:
            param = {
                "groupOrderList": [{
                    "auditBoList": [],
                    "groupNo": gp,
                    "auditInfo": "打回可双签",
                    "auditStatus": 0,
                    "engineId": engineid,
                    "orderType": 1,
                    "messageStatus": 1
                }]
            }
        elif audit_type == 2:
            param = {
                "groupOrderList": [{
                    "auditBoList": [],
                    "groupNo": gp,
                    "auditInfo": "审核通过",
                    "auditStatus": 1,
                    "engineId": engineid,
                    "orderType": 1
                }]
            }
        self.request.post_json(url, param)

    def orderList(self, engineid, type):
        """
        获取药嘱信息
        :param engineid:
        :param type: 0 待审页面 1 已审页面
        :return:
        """
        if type == 0:
            url = self.conf.get(
                'auditcenter',
                'address') + '/api/v1/ipt/orderList' + '?id=' + str(engineid)
        else:
            url = self.conf.get(
                'auditcenter', 'address'
            ) + '/api/v1/ipt/all/orderList' + '?id=' + str(engineid)
        return self.request.get(url)

    def herbOrderList(self, engineid, type):
        if type == 0:
            url = self.conf.get(
                'auditcenter', 'address'
            ) + '/api/v1/ipt/herbOrderList' + '?id=' + str(engineid)
        else:
            url = self.conf.get(
                'auditcenter', 'address'
            ) + '/api/v1/ipt/all/herbOrderList' + '?id=' + str(engineid)
        return self.request.get(url)

    # def mergeEngineMsgList(self, engineid, type, gno):
    #     """获取医嘱详情右侧的审核记录、警示信息等信息"""
    #     ol = self.orderList(engineid, type)
    #     hl = self.herbOrderList(engineid, type)
    #     medicalIds = []
    #     medicalHisIds = []
    #     herbMedicalIds = []
    #     herbMedicalHisIds = []
    #     if ol['data']:
    #         medicalIds = [i['id'] for i in ol['data'][gno]]
    #         medicalHisIds = [i['orderId'] for i in ol['data'][gno]]
    #     if hl['data']:
    #         herbMedicalIds = [i['drugId'] for i in hl['data'][0]['itemList']]
    #         herbMedicalHisIds = [i['herbMedicalId'] for i in hl['data'][0]['itemList']]
    #     if type == 0:
    #         url = self.conf.get('auditcenter', 'address') + '/api/v1/ipt/mergeEngineMsgList'
    #         param = {
    #             "auditWay": 2,
    #             "engineId": engineid,
    #             "zoneId": self.zoneid,
    #             "groupNo": gno,
    #             "medicalIds": medicalIds,
    #             "medicalHisIds": medicalHisIds,
    #             "herbMedicalIds": herbMedicalIds,
    #             "herbMedicalHisIds": herbMedicalHisIds
    #         }
    #     else:
    #         url = self.conf.get('auditcenter', 'address') + '/api/v1/ipt/all/mergeEngineMsgList'
    #         param = {
    #             "engineId": engineid,
    #             "zoneId": self.zoneid,
    #             "groupNo": gno,
    #             "medicalIds": medicalIds,
    #             "medicalHisIds": medicalHisIds,
    #             "herbMedicalIds": herbMedicalIds,
    #             "herbMedicalHisIds": herbMedicalHisIds
    #         }
    #     return self.request.post_json(url, param)
    @wait
    def waitIptList(self):
        """
        待审住院列表根据患者号查询 作用同函数selNotAuditIptList(),是其优化版本
        :return:   通过return结果可以获得以下等数据:engineid res['data']['engineInfos'][0]['id']
        """
        # self.send.send('ipt', '医嘱一', 1)
        # time.sleep(3)
        url = self.conf.get('auditcenter',
                            'address') + '/api/v1/ipt/selNotAuditIptList'
        param = {"patientId": self.send.change_data['{{ts}}']}
        res = self.request.post_json(url, param)
        engineInfos = res['data']['engineInfos']  # 待审列表的医嘱数据
        engineMsg = []
        engineids = []
        if engineInfos is not None:  # 待审列表有数据的时候执行下述语句
            engineMsg = res['data']['engineInfos'][0]['engineMsg']  # 医嘱对应的警示信息
            engineids = [i['id']
                         for i in res['data']['engineInfos']]  # 同一患者的所有引擎id
        return engineInfos, engineMsg, engineids

    @wait
    def mergeEngineMsgList(self, engineid, type, gno):
        """获取医嘱详情右侧的审核记录、警示信息等信息"""
        ol = self.orderList(engineid, type)
        # hl = self.herbOrderList(engineid, type)
        medicalIds = []
        medicalHisIds = []
        if ol['data']:
            medicalIds = [i['id'] for i in ol['data'][gno]]
            medicalHisIds = [i['orderId'] for i in ol['data'][gno]]
        if type == 0:
            url = self.conf.get('auditcenter',
                                'address') + '/api/v1/ipt/mergeEngineMsgList'
            param = {
                "auditWay": 2,
                "engineId": engineid,
                "zoneId": self.zoneid,
                "groupNo": gno,
                "medicalIds": medicalIds,
                "medicalHisIds": medicalHisIds,
                "herbMedicalIds": [],
                "herbMedicalHisIds": []
            }
        else:
            url = self.conf.get(
                'auditcenter',
                'address') + '/api/v1/ipt/all/mergeEngineMsgList'
            param = {
                "engineId": engineid,
                "zoneId": self.zoneid,
                "groupNo": gno,
                "medicalIds": medicalIds,
                "medicalHisIds": medicalHisIds,
                "herbMedicalIds": [],
                "herbMedicalHisIds": []
            }
        return self.request.post_json(url, param)

    def get_patient(self, engineid, type):
        """获取住院患者信息"""
        if type == 0:
            url = self.conf.get(
                'auditcenter',
                'address') + '/api/v1/ipt/iptPatient' + '?id=' + str(engineid)
        else:
            url = self.conf.get(
                'auditcenter', 'address'
            ) + '/api/v1/ipt/all/iptPatient' + '?id=' + str(engineid)
        return self.request.get(url)

    def get_operation(self, engineid, type):
        """获取住院手术信息"""
        if type == 0:
            url = self.conf.get(
                'auditcenter', 'address'
            ) + '/api/v1/ipt/operationList' + '?id=' + str(engineid)
        else:
            url = self.conf.get(
                'auditcenter', 'address'
            ) + '/api/v1/ipt/all/operationList' + '?id=' + str(engineid)
        return self.request.get(url)

    def isIptCollected(self, engineid, gno):
        ol = self.orderList(engineid, type)
        medicalIds = [i['id'] for i in ol['data'][gno]]
        medicalHisIds = [i['orderId'] for i in ol['data'][gno]]
        url = self.conf.get('auditcenter',
                            'address') + '/api/v1/collect/isIptCollected'
        param = {
            "collectPeopleId": self.uid,
            "engineId": engineid,
            "groupNo": gno,
            "herbMedicalIds": [],
            "medicalIds": medicalIds
        }
        return self.request.post_json(url, param)
Пример #8
0
class Template:
    def __init__(self):
        self.conf = ReadConfig()
        url_yzm = "http://10.1.1.94:10000/api/v1/magicno"
        url = 'http://10.1.1.94:10000/api/v1/login'
        start_sf_url = "http://10.1.1.94:10000/api/v1/startAuditWork"  # 获取开始审方url
        # username = self.conf.get('login', 'username')
        headers = {'Content-Type': "application/json"}
        self.session = requests.session()
        res_yzm = self.get(url_yzm)  # 获取验证码
        salt = res_yzm['data']
        passwd = '123456'  # 密码加密方式为 明文密码md5加密后拼接salt再次md5加密
        m = hashlib.md5()  # 创建md5对象
        m.update(passwd.encode())  # 生成加密字符串
        password = m.hexdigest()
        password = password + salt
        m1 = hashlib.md5()
        m1.update(password.encode())
        password1 = m1.hexdigest()
        print(password)
        params = {"name": "wangmm", "password": password1}
        res = self.session.post(url, data=json.dumps(params), headers=headers).json()  # 登录用户中心
        print(res)
        res1 = self.session.get(url=start_sf_url)  # 开始审方
        group_no = random.randint(1, 1000000)
        cgroup_no = random.randint(1, 1000000)
        ggroup_no = random.randint(1, 1000000)
        self.change_data = {"{{ts}}": str(self.get_ts(0, 0)),  # 今天时间戳
                            "{{tf2}}": str(self.get_ts(-1, -2)),
                            "{{tf1}}": str(self.get_ts(-1, -1)),
                            "{{t}}": str(self.get_ts(-1, 0)),  # 昨天时间戳
                            "{{d}}": str(self.get_date(-1, 0)),  # 昨天时间
                            "{{tf3}}": str(self.get_ts(-1, -3)),
                            "{{df4}}": str(self.get_date(-1, -4)),
                            "{{tb1}}": str(self.get_ts(-1, +1)),
                            "{{db1}}": str(self.get_date(-1, +1)),
                            "{{dtb1}}": str(self.get_date(+1, 0)),
                            "{{gp}}": str(group_no),
                            "{{cgp}}": str(cgroup_no),
                            "{{ggp}}": str(ggroup_no),
                            "{{df6}}": str(self.get_date(-1, -6)),
                            "{{df3}}": str(self.get_date(-1, -3)),
                            "{{df2}}": str(self.get_date(-1, -1)),
                            "{{df1}}": str(self.get_date(-1, -1)),
                            "{{dt}}": str(self.get_date(0, 0)),  # 今天时间
                            "{{f5}}": str(self.get_date(-5, 0)),
                            "{{f4}}": str(self.get_date(-4, 0)),
                            "{{f3}}": str(self.get_date(-3, 0)),
                            "{{f2}}": str(self.get_date(-2, 0)),
                            }

    # 获取日期格式为%Y-%m-%d %H:%M:%S:,n可取0(表示当前日期),正(表示当前日期+n天),负(表示当前日期-n天)
    def get_ymd(self, d, h):
        date = ((datetime.datetime.now() + datetime.timedelta(days=d)) + datetime.timedelta(hours=h)).strftime(
            "%Y-%m-%d")
        return date

    def get_date(self, d, h):
        date = ((datetime.datetime.now() + datetime.timedelta(days=d)) + datetime.timedelta(hours=h)).strftime(
            "%Y-%m-%d %H:%M:%S")
        return date

    # 获取指定日期的时间戳
    def get_ts(self, d, h):
        date = ((datetime.datetime.now() + datetime.timedelta(days=d)) + datetime.timedelta(hours=h)).strftime(
            "%Y-%m-%d %H:%M:%S")
        ts = int(time.mktime(time.strptime(date, "%Y-%m-%d %H:%M:%S")))  # 获取10位时间戳
        # ts = int(time.mktime(time.strptime(date, "%Y-%m-%d %H:%M:%S"))) * 1000   # 获取13位时间戳
        return ts

    def post_json(self, url, para):
        data = para
        data = json.dumps(data)
        headers = {"Content-Type": "application/json"}
        return self.session.post(url, data=data.encode("utf-8"), headers=headers).json()

    def get(self, url):
        return self.session.get(url).json()

    def send_data(self, dir_name, xml_name, **change):
        time.sleep(1)  # 审方系统问题,每次发数据需要时间间隔
        # url = "http://10.1.1.89:9999/auditcenter/api/v1/auditcenter"
        xml_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'data', dir_name, xml_name)
        send_data_url = self.conf.get('auditcenter', 'address') + "/api/v1/auditcenter"
        # send_data_url = "http://192.168.1.193:8080/api/v1/auditcenter"
        # send_data_url = "http://10.1.1.172:9999/auditcenter/api/v1/auditcenter"
        headers = {"Content-Type": "text/plain"}
        print(xml_path)
        with open(xml_path, encoding="utf-8") as fp:
            body = fp.read()
        ss = body
        for k in change:
            ss = ss.replace(k, change[k])
        print(ss)
        return self.session.post(url=send_data_url, data=ss.encode("utf-8"), headers=headers)

    def send_delete_1(self, dir_name, xml_name, **change):
        time.sleep(1)  # 审方系统问题,每次发数据需要时间间隔
        # url = "http://10.1.1.89:9999/auditcenter/api/v1/auditcenter"
        xml_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'data', dir_name, xml_name)
        send_delete_url = self.conf.get('auditcenter', 'address') + "/api/v1/cancelgroupdrug"
        headers = {"Content-Type": "text/plain"}
        print(xml_path)
        with open(xml_path, encoding="utf-8") as fp:
            body = fp.read()
        ss = body
        for k in change:
            ss = ss.replace(k, change[k])
        print(ss)
        return self.session.post(url=send_delete_url, data=ss.encode("utf-8"), headers=headers)

    def send_delete_2(self, dir_name, xml_name, **change):
        time.sleep(1)  # 审方系统问题,每次发数据需要时间间隔
        # url = "http://10.1.1.89:9999/auditcenter/api/v1/auditcenter"
        xml_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'data', dir_name, xml_name)
        send_delete_url = self.conf.get('auditcenter', 'address') + "/api/v1/cancelRecipe"
        headers = {"Content-Type": "text/plain"}
        print(xml_path)
        with open(xml_path, encoding="utf-8") as fp:
            body = fp.read()
        ss = body
        for k in change:
            ss = ss.replace(k, change[k])
        print(ss)
        return self.session.post(url=send_delete_url, data=ss.encode("utf-8"), headers=headers)

    def doc(self, dir_name, xml_name, **change):
        xml_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'data', dir_name, xml_name)
        url = self.conf.get('auditcenter', 'address') + self.conf.get('api', '医生双签')
        headers = {"Content-Type": "text/plain"}
        print(xml_path)
        with open(xml_path, encoding="utf-8") as fp:
            body = fp.read()
        ss = body
        for k in change:
            ss = ss.replace(k, change[k])
        print(ss)
        return self.session.post(url=url, data=ss.encode("utf-8"), headers=headers)

    # 查询待审列表,获取引擎id(注意:右侧待审任务只能展示10条,所以10条之外的数据查询不到)
    def get_opt_engineid(self, dir_name, xml_name, num):
        self.send_data(dir_name, xml_name, **self.change_data)
        time.sleep(4)
        # num = re.findall('\d+', xml_name)  # 获取文件名中的数字
        recipeno = 'r' + ''.join(str(num)) + '_' + self.change_data['{{ts}}']
        param = {
            "recipeNo": recipeno
        }
        url = self.conf.get('auditcenter', 'address') + self.conf.get('api', '查询待审门诊任务列表')
        res = self.post_json(url, param)
        # print(res)
        # print(res['data']['optRecipeList'][0]['optRecipe']['id'])
        return res['data']['optRecipeList'][0]['optRecipe']['id']

    # type = 0代表待审页面,type = 1代表已审页面
    def get_opt_recipeInfo(self, engineid, type):
        if type == 0:
            url = self.conf.get('auditcenter', 'address') + self.conf.get('api', '待审门诊获取患者信息和处方信息') + str(engineid)
        else:
            url = self.conf.get('auditcenter', 'address') + self.conf.get('api', '已审门诊获取患者信息和处方信息') + str(engineid)
        return self.get(url)

    def get_ipt_patient(self, engineid, type):
        if type == 0:
            url = self.conf.get('auditcenter', 'address') + self.conf.get('api', '待审住院获取患者信息') + '?id=' + str(engineid)
        else:
            url = self.conf.get('auditcenter', 'address') + self.conf.get('api', '已审住院获取患者信息') + '?id=' + str(engineid)
        return self.get(url)

    @wait
    def get_opt_auditresult(self, engineid, type):
        # time.sleep(4)
        url = ''
        if type == 1:
            url = self.conf.get('auditcenter', 'address') + '/api/v1/opt/all/auditResultList/' + str(engineid)
        return self.get(url)

    @wait
    def get_ipt_auditresult(self, engineid, type):
        # time.sleep(4)
        url = ''
        if type == 1:
            url = self.conf.get('auditcenter', 'address') + '/api/v1/opt/all/auditResultList/' + str(engineid)
        return self.get(url)

    # 根据patient_id查询待审列表获取引擎id,count=1时,取该患者第二条数据的engineid,count=2时,取该患者第二条数据的engineid
    def get_ipt_engineid(self, dir_name, xml_name, count):
        self.send_data(dir_name, xml_name, **self.change_data)
        time.sleep(5)
        param = {
            "patientId": self.change_data['{{ts}}']
        }
        url = self.conf.get('auditcenter', 'address') + self.conf.get('api', '查询待审住院任务列表')
        res = self.post_json(url, param)
        print(res)
        engineid = ''
        if count == 1:
            engineid = res['data']['engineInfos'][0]['id']
        elif count == 2:
            engineid = res['data']['engineInfos'][1]['id']
        return engineid

    @wait
    def opt_audit(self, engineid, audit_type):
        """
        审核门诊任务
        :param engineid:  任务引擎id
        :param audit_type: 审核类型,2:审核通过 0:审核打回 1:审核打回(双签)
        """
        time.sleep(2)
        url = ''
        param = {}
        if audit_type == 2:
            url = self.conf.get('login', 'address') + self.conf.get('api', '处方详情审核通过')
            param = {
                "optRecipeId": engineid,
                "auditResult": ""
            }

        elif audit_type == 0:
            url = self.conf.get('login', 'address') + self.conf.get('api', '处方详情审核打回')
            param = {
                "optRecipeId": engineid,
                "auditResult": "打回必须修改",
                "operationRecordList": [],
                "messageStatus": 0
            }

        elif audit_type == 1:
            url = self.conf.get('login', 'address') + self.conf.get('api', '处方详情审核打回')
            param = {
                "optRecipeId": engineid,
                "auditResult": "打回可双签",
                "operationRecordList": [],
                "messageStatus": 1
            }
        self.post_json(url, param)

    # 待审列表批量通过,audit_type = 1指门急诊,audit_type = 3指住院
    def audit_multi(self, audit_type, *ids):
        url = self.conf.get('auditcenter', 'address') + self.conf.get('api', '待审列表批量通过')
        param = {
            "ids": ids,
            "auditType": audit_type,
            "auditWay": 2
        }
        self.post_json(url, param)

    def ipt_audit(self, gp, engineid, audit_type):
        url = self.conf.get('auditcenter', 'address') + self.conf.get('api', '医嘱详情审核')
        # 医嘱详情审核打回
        param = ''
        if audit_type == 0:
            param = {
                "groupOrderList": [{
                    "auditBoList": [],
                    "groupNo": gp,
                    "auditInfo": "必须修改",
                    "auditStatus": 0,
                    "engineId": engineid,
                    "orderType": 1
                }]
            }
        # 医嘱详情审核打回(可双签)
        elif audit_type == 1:
            param = {
                "groupOrderList": [{
                    "auditBoList": [],
                    "groupNo": gp,
                    "auditInfo": "打回可双签",
                    "auditStatus": 0,
                    "engineId": engineid,
                    "orderType": 1,
                    "messageStatus": 1
                }]
            }
        # 医嘱详情审核通过
        elif audit_type == 2:
            param = {
                "groupOrderList": [{
                    "auditBoList": [],
                    "groupNo": gp,
                    "auditInfo": "审核通过",
                    "auditStatus": 1,
                    "engineId": engineid,
                    "orderType": 1
                }]
            }
        self.post_json(url, param)

    @wait
    def get_ipt_orderlist(self, engineid, type):
        if type == 0:
            url = self.conf.get('auditcenter', 'address') + '/api/v1/ipt/orderList' + '?id=' + str(engineid)
        else:
            url = self.conf.get('auditcenter', 'address') + self.conf.get('api', '已审住院获取药嘱信息') + '?id=' + str(engineid)
        return self.get(url)

    @wait
    def get_ipt_result(self, engineid, gp):
        """待审页面查看合并任务的审核结果"""
        res = self.get_ipt_orderlist(engineid, 0)
        medicalIds = res['data'][gp][0]['id']
        medicalHisIds = res['data'][gp][0]['orderId']
        url = self.conf.get('auditcenter', 'address') + "/api/v1/ipt/engineMsgList"
        param = {
            "engineId": engineid,
            "zoneId": 1,
            "groupNo": gp,
            "medicalIds": [medicalIds],
            "medicalHisIds": [medicalHisIds],
            "herbMedicalIds": [],
            "herbMedicalHisIds": [],
            "auditWay": "2"
        }
        return self.post_json(url, param)

    def chat_ipt_doc(self, engineid):
        url = self.conf.get('auditcenter', 'address') + self.conf.get('api', '客户端发送理由')
        param = {
            "hospitalCode": "H0003",
            "userId": "09",
            "source": "住院",
            "attachKey": engineid,
            "message": "这是医生理由哦",
            "userRole": "医生"
        }
        self.post_json(url, param)

    # source = 1指门诊 source = 3 指住院
    def chat_pharm(self, source, engineid):
        url = self.conf.get('auditcenter', 'address') + self.conf.get('api', '审方端发送理由')
        param = {
            "zoneId": 1,
            "category": source,
            "attachKey": engineid,
            "message": "这是药师消息哦",
            "userRole": "药师"
        }
        self.post_json(url, param)

    def query_chat(self, source, zoneid, engineid):
        url = (self.conf.get('auditcenter', 'address') + self.conf.get('api', '已审查询记录')) % (source, zoneid, engineid)
        print(url)
        return self.get(url)
Пример #9
0
class SendData:
    def __init__(self):
        self.conf = ReadConfig()
        group_no = random.randint(1, 1000000)
        cgroup_no = random.randint(1, 1000000)
        ggroup_no = random.randint(1, 1000000)
        self.change_data = {
            "{{ts}}": str(self.get_ts(0, 0)),  # 今天时间戳
            "{{tf2}}": str(self.get_ts(-1, -2)),
            "{{tf1}}": str(self.get_ts(-1, -1)),
            "{{t}}": str(self.get_ts(-1, 0)),  # 昨天时间戳
            "{{d}}": str(self.get_date(-1, 0)),  # 昨天时间
            "{{tf3}}": str(self.get_ts(-1, -3)),
            "{{df4}}": str(self.get_date(-1, -4)),
            "{{tb1}}": str(self.get_ts(-1, +1)),
            "{{db1}}": str(self.get_date(-1, +1)),
            "{{dtb1}}": str(self.get_date(+1, 0)),  # 明天时间
            "{{gp}}": str(group_no),
            "{{cgp}}": str(cgroup_no),
            "{{ggp}}": str(ggroup_no),
            "{{df6}}": str(self.get_date(-1, -6)),
            "{{df3}}": str(self.get_date(-1, -3)),
            "{{df2}}": str(self.get_date(-1, -1)),
            "{{df1}}": str(self.get_date(-1, -1)),
            "{{dt}}": str(self.get_date(0, 0)),  # 今天时间
            "{{f5}}": str(self.get_date(-5, 0)),
            "{{f4}}": str(self.get_date(-4, 0)),
            "{{f3}}": str(self.get_date(-3, 0)),
            "{{f2}}": str(self.get_date(-2, 0)),
        }

    # 获取日期格式为%Y-%m-%d %H:%M:%S:,n可取0(表示当前日期),正(表示当前日期+n天),负(表示当前日期-n天)
    def get_ymd(self, d, h):
        date = ((datetime.datetime.now() + datetime.timedelta(days=d)) +
                datetime.timedelta(hours=h)).strftime("%Y-%m-%d")
        return date

    def get_date(self, d, h):
        date = ((datetime.datetime.now() + datetime.timedelta(days=d)) +
                datetime.timedelta(hours=h)).strftime("%Y-%m-%d %H:%M:%S")
        return date

    # 获取指定日期的时间戳
    def get_ts(self, d, h):
        date = ((datetime.datetime.now() + datetime.timedelta(days=d)) +
                datetime.timedelta(hours=h)).strftime("%Y-%m-%d %H:%M:%S")
        ts = int(time.mktime(time.strptime(date,
                                           "%Y-%m-%d %H:%M:%S")))  # 获取10位时间戳
        # ts = int(time.mktime(time.strptime(date, "%Y-%m-%d %H:%M:%S"))) * 1000   # 获取13位时间戳
        return ts

    def send_data(self, **change):
        xml_path = os.path.join(
            os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
            'data', '医嘱一')
        send_data_url = self.conf.get(
            'login', 'address') + '/auditcenter/api/v1/auditcenter'
        headers = {"Content-Type": "text/plain"}
        print(xml_path)
        with open(xml_path, encoding="utf-8") as fp:
            body = fp.read()
        ss = body
        for k in change:
            ss = ss.replace(k, change[k])
        print(ss)
        requests.post(url=send_data_url,
                      data=ss.encode("utf-8"),
                      headers=headers)
Пример #10
0
class Template:
    def __init__(self):
        self.conf = ReadConfig()
        url = self.conf.get('login', 'address') + '/syscenter/api/v1/currentUser'
        username = self.conf.get('login', 'username')
        passwd = self.conf.get('login', 'password')
        m = hashlib.md5()  # 创建md5对象
        m.update(passwd.encode())  # 生成加密字符串
        password = m.hexdigest()
        params = {"name": username, "password": password}
        headers = {'Content-Type': "application/json"}
        self.session = requests.session()
        # self.session.post(url, data=json.dumps(params), headers=headers)
        res = self.session.post(url, data=json.dumps(params), headers=headers).json()  # 登录用户中心
        start_sf_url = self.conf.get('login', 'address') + '/auditcenter/api/v1/startAuditWork'  # 获取开始审方url
        self.session.get(url=start_sf_url)  # 开始审方
        group_no = random.randint(1, 1000000)
        cgroup_no = random.randint(1, 1000000)
        ggroup_no = random.randint(1, 1000000)
        self.change_data = {"{{ts}}": str(self.get_ts(0, 0)),  # 今天时间戳
                            "{{tf2}}": str(self.get_ts(-1, -2)),
                            "{{tf1}}": str(self.get_ts(-1, -1)),
                            "{{t}}": str(self.get_ts(-1, 0)),  # 昨天时间戳
                            "{{d}}": str(self.get_date(-1, 0)),  # 昨天时间
                            "{{tf3}}": str(self.get_ts(-1, -3)),
                            "{{df4}}": str(self.get_date(-1, -4)),
                            "{{tb1}}": str(self.get_ts(-1, +1)),
                            "{{db1}}": str(self.get_date(-1, +1)),
                            "{{dtb1}}": str(self.get_date(+1, 0)), # 明天时间
                            "{{gp}}": str(group_no),
                            "{{cgp}}": str(cgroup_no),
                            "{{ggp}}": str(ggroup_no),
                            "{{df6}}": str(self.get_date(-1, -6)),
                            "{{df3}}": str(self.get_date(-1, -3)),
                            "{{df2}}": str(self.get_date(-1, -1)),
                            "{{df1}}": str(self.get_date(-1, -1)),
                            "{{dt}}": str(self.get_date(0, 0)),  # 今天时间
                            "{{f5}}": str(self.get_date(-5, 0)),
                            "{{f4}}": str(self.get_date(-4, 0)),
                            "{{f3}}": str(self.get_date(-3, 0)),
                            "{{f2}}": str(self.get_date(-2, 0)),
                            }

    # 获取日期格式为%Y-%m-%d %H:%M:%S:,n可取0(表示当前日期),正(表示当前日期+n天),负(表示当前日期-n天)
    def get_ymd(self, d, h):
        date = ((datetime.datetime.now() + datetime.timedelta(days=d)) + datetime.timedelta(hours=h)).strftime(
            "%Y-%m-%d")
        return date

    def get_date(self, d, h):
        date = ((datetime.datetime.now() + datetime.timedelta(days=d)) + datetime.timedelta(hours=h)).strftime(
            "%Y-%m-%d %H:%M:%S")
        return date

    # 获取指定日期的时间戳
    def get_ts(self, d, h):
        date = ((datetime.datetime.now() + datetime.timedelta(days=d)) + datetime.timedelta(hours=h)).strftime(
            "%Y-%m-%d %H:%M:%S")
        ts = int(time.mktime(time.strptime(date, "%Y-%m-%d %H:%M:%S")))  # 获取10位时间戳
        # ts = int(time.mktime(time.strptime(date, "%Y-%m-%d %H:%M:%S"))) * 1000   # 获取13位时间戳
        return ts

    def post_json(self, url, para):
        data = para
        data = json.dumps(data)
        headers = {"Content-Type": "application/json"}
        return self.session.post(url, data=data.encode("utf-8"), headers=headers).json()

    def get(self, url):
        return self.session.get(url).json()

    def send_data(self, dir_name, xml_name, **change):
        time.sleep(2)  # 审方系统问题,每次发数据需要时间间隔
        # url = "http://10.1.1.89:9999/auditcenter/api/v1/auditcenter"
        xml_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'data', dir_name, xml_name)
        send_data_url = self.conf.get('login', 'address') + '/auditcenter/api/v1/auditcenter'
        headers = {"Content-Type": "text/plain"}
        print(xml_path)
        with open(xml_path, encoding="utf-8") as fp:
            body = fp.read()
        ss = body
        for k in change:
            ss = ss.replace(k, change[k])
        print(ss)
        return self.session.post(url=send_data_url, data=ss.encode("utf-8"), headers=headers)

    def doc(self, dir_name, xml_name, **change):
        xml_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'data', dir_name, xml_name)
        url = self.conf.get('auditcenter', 'address') + self.conf.get('api', '医生双签')
        headers = {"Content-Type": "text/plain"}
        print(xml_path)
        with open(xml_path, encoding="utf-8") as fp:
            body = fp.read()
        ss = body
        for k in change:
            ss = ss.replace(k, change[k])
        print(ss)
        return self.session.post(url=url, data=ss.encode("utf-8"), headers=headers)

    # 查询待审列表,获取引擎id(注意:右侧待审任务只能展示10条,所以10条之外的数据查询不到)
    def get_opt_engineid(self, dir_name, xml_name, num):
        self.send_data(dir_name, xml_name, **self.change_data)
        time.sleep(4)
        # num = re.findall('\d+', xml_name)  # 获取文件名中的数字
        recipeno = 'r' + ''.join(str(num)) + '_' + self.change_data['{{ts}}']
        param = {
            "recipeNo": recipeno
        }
        url = self.conf.get('auditcenter', 'address') + self.conf.get('api', '查询待审门诊任务列表')
        res = self.post_json(url, param)
        # print(res)
        # print(res['data']['optRecipeList'][0]['optRecipe']['id'])
        return res['data']['optRecipeList'][0]['optRecipe']['id']

    # 根据patient_id查询待审列表获取引擎id,count=1时,取该患者第二条数据的engineid,count=2时,取该患者第二条数据的engineid
    def get_ipt_engineid(self, dir_name, xml_name, count):
        self.send_data(dir_name, xml_name, **self.change_data)
        time.sleep(5)
        param = {
            "patientId": self.change_data['{{ts}}']
        }
        url = self.conf.get('auditcenter', 'address') + self.conf.get('api', '查询待审住院任务列表')
        res = self.post_json(url, param)
        print(res)
        engineid = ''
        if count == 1:
            engineid = res['data']['engineInfos'][0]['id']
        elif count == 2:
            engineid = res['data']['engineInfos'][1]['id']
        return engineid

    def opt_audit(self, engineid, audit_type):
        url = ''
        param = {}
        # 处方详情审核通过
        if audit_type == 2:
            url = self.conf.get('auditcenter','address') + self.conf.get('api', '处方详情审核通过')
            param = {
                "optRecipeId": engineid,
                "auditResult": ""
            }
        # 处方详情审核打回
        elif audit_type == 0:
            url = self.conf.get('login', 'address') + '/auditcenter' + self.conf.get('api', '处方详情审核打回')
            param = {
                "optRecipeId": engineid,
                "auditResult": "打回必须修改",
                "operationRecordList": [],
                "messageStatus": 0
            }
        # 处方详情审核打回(可双签)
        elif audit_type == 1:
            url = self.conf.get('login', 'address') + '/auditcenter' + self.conf.get('api', '处方详情审核打回')
            param = {
                "optRecipeId": engineid,
                "auditResult": "打回可双签",
                "operationRecordList": [],
                "messageStatus": 1
            }
        self.post_json(url, param)

    # 待审列表批量通过,audit_type = 1指门急诊,audit_type = 3指住院
    def audit_multi(self, audit_type, *ids):
        url = self.conf.get('auditcenter', 'address') + self.conf.get('api', '待审列表批量通过')
        param = {
            "ids": ids,
            "auditType": audit_type,
            "auditWay": 2
        }
        self.post_json(url, param)

    def ipt_audit(self, gp, engineid, audit_type):
        url = self.conf.get('auditcenter', 'address') + self.conf.get('api', '医嘱详情审核')
        param = ''
        # 医嘱详情审核打回
        if audit_type == 0:
            param = {
                "groupOrderList": [{
                    "auditBoList": [],
                    "groupNo": gp,
                    "auditInfo": "必须修改",
                    "auditStatus": 0,
                    "engineId": engineid,
                    "orderType": 1
                }]
            }
        # 医嘱详情审核打回(可双签)
        elif audit_type == 1:
            param = {
                "groupOrderList": [{
                    "auditBoList": [],
                    "groupNo": gp,
                    "auditInfo": "打回可双签",
                    "auditStatus": 0,
                    "engineId": engineid,
                    "orderType": 1,
                    "messageStatus": 1
                }]
            }
        # 医嘱详情审核通过
        elif audit_type == 2:
            param = {
                "groupOrderList": [{
                    "auditBoList": [],
                    "groupNo": gp,
                    "auditInfo": "审核通过",
                    "auditStatus": 1,
                    "engineId": engineid,
                    "orderType": 1
                }]
            }
        self.post_json(url, param)

    def get_ipt_patient(self,engineid,type):
        if type == 0:
            url = self.conf.get('auditcenter', 'address') + self.conf.get('api', '待审住院获取患者信息') + '?id='+ str(engineid)
        else:
            url = self.conf.get('auditcenter', 'address') + self.conf.get('api', '已审住院获取患者信息') + '?id=' + str(engineid)
        return self.get(url)

    def get_ipt_orderlist(self,engineid,type):
        if type == 0:
            url = self.conf.get('auditcenter', 'address') + self.conf.get('api', '待审住院获取药嘱信息') + '?id='+ str(engineid)
        else:
            url = self.conf.get('auditcenter', 'address') + self.conf.get('api', '已审住院获取药嘱信息') + '?id=' + str(engineid)
        return self.get(url)
Пример #11
0
 def __init__(self):
     conf = ReadConfig()
     self.auditcenter_url = conf.get('auditcenter', 'address')
     self.request = HttpRequest()
Пример #12
0
class Ipt:
    def __init__(self):
        self.send = SendData()
        self.conf = ReadConfig()
        self.request = HttpRequest()

    @wait
    def selNotAuditIptList(self):
        """
        待审住院列表根据患者号查询
        :return:   通过return结果可以获得以下数据:engineid res['data']['engineInfos'][0]['id']
        """
        # self.send.send('ipt', '医嘱一', 1)
        # time.sleep(3)
        url = self.conf.get('auditcenter', 'address') + '/api/v1/ipt/selNotAuditIptList'
        param = {
            "patientId": self.send.change_data['{{ts}}']
        }
        res = self.request.post_json(url, param)
        return res

    def get_engineid(self, n):
        """
        待审列表获取引擎id
        :param n: 如果某患者有多条待审任务则会有多个引擎id,n代表取第几个引擎id
        :return:
        """
        res = self.selNotAuditIptList()
        return res['data']['engineInfos'][n - 1]['id']

    def audit_multi(self, *ids):
        """
        待审住院任务列表批量通过
        :param ids:  引擎id
        """
        url = self.conf.get('auditcenter', 'address') + '/api/v1/auditBatchAgree'
        param = {
            "ids": ids,
            "auditType": 3,  # 3指住院
            "auditWay": 2
        }
        self.request.post_json(url, param)

    def ipt_audit(self, gp, engineid, audit_type):
        """
        医嘱详情审核任务
        :param gp:
        :param engineid:
        :param audit_type: 0 审核打回  1 审核打回(可双签) 2 审核通过
        orderType : 1:药物医嘱; 2:非药物医嘱;3:草药医嘱
        """
        url = self.conf.get('auditcenter', 'address') + '/api/v1/ipt/auditSingle'
        param = ''
        if audit_type == 0:
            param = {
                "groupOrderList": [{
                    "auditBoList": [],
                    "groupNo": gp,
                    "auditInfo": "必须修改",
                    "auditStatus": 0,
                    "engineId": engineid,
                    "orderType": 1
                }]
            }
        elif audit_type == 1:
            param = {
                "groupOrderList": [{
                    "auditBoList": [],
                    "groupNo": gp,
                    "auditInfo": "打回可双签",
                    "auditStatus": 0,
                    "engineId": engineid,
                    "orderType": 1,
                    "messageStatus": 1
                }]
            }
        elif audit_type == 2:
            param = {
                "groupOrderList": [{
                    "auditBoList": [],
                    "groupNo": gp,
                    "auditInfo": "审核通过",
                    "auditStatus": 1,
                    "engineId": engineid,
                    "orderType": 1
                }]
            }
        self.request.post_json(url, param)

    def orderList(self, engineid, type):
        """
        获取药嘱信息
        :param engineid:
        :param type: 0 待审页面 1 已审页面
        :return:
        """
        if type == 0:
            url = self.conf.get('auditcenter', 'address') + '/api/v1/ipt/orderList' + '?id=' + str(engineid)
        else:
            url = self.conf.get('auditcenter', 'address') + '/api/v1/ipt/all/orderList' + '?id=' + str(engineid)
        return self.request.get(url)

    def herbOrderList(self, engineid, type):
        if type == 0:
            url = self.conf.get('auditcenter', 'address') + '/api/v1/ipt/herbOrderList' + '?id=' + str(engineid)
        else:
            url = self.conf.get('auditcenter', 'address') + '/api/v1/ipt/all/herbOrderList' + '?id=' + str(engineid)
        return self.request.get(url)

    def get_patient(self, engineid, type):
        """获取住院患者信息"""
        if type == 0:
            url = self.conf.get('auditcenter', 'address') + '/api/v1/ipt/iptPatient' + '?id=' + str(engineid)
        else:
            url = self.conf.get('auditcenter', 'address') + '/api/v1/ipt/all/iptPatient' + '?id=' + str(engineid)
        return self.request.get(url)

    def get_operation(self, engineid, type):
        """获取住院手术信息"""
        if type == 0:
            url = self.conf.get('auditcenter', 'address') + '/api/v1/ipt/operationList' + '?id=' + str(engineid)
        else:
            url = self.conf.get('auditcenter', 'address') + '/api/v1/ipt/all/operationList' + '?id=' + str(engineid)
        return self.request.get(url)
Пример #13
0
class Opt:
    def __init__(self):
        self.send = SendData()
        self.conf = ReadConfig()
        self.request = HttpRequest()

    @wait
    def selNotAuditOptList(self, num):
        """
        待审门诊列表根据处方号查询
        :return:   通过return结果可以获得以下数据:engineid res['data']['engineInfos'][0]['id']
        """
        # self.send.send('ipt', '医嘱一', 1)
        # time.sleep(3)
        url = self.conf.get('auditcenter',
                            'address') + '/api/v1/opt/selNotAuditOptList'
        recipeno = 'r' + ''.join(
            str(num)) + '_' + self.send.change_data['{{ts}}']
        param = {"recipeNo": recipeno}
        res = self.request.post_json(url, param)
        return res

    def get_engineid(self, num):
        """
        待审列表获取引擎id
        :param n: 如果某患者有多条待审任务则会有多个引擎id,n代表取第几个引擎id
        :return:
        """
        res = self.selNotAuditOptList(num)
        return res['data']['optRecipeList'][0]['optRecipe']['id']

    def audit_multi(self, *ids):
        """
        待审门诊任务列表批量通过
        :param ids:  引擎id
        """
        url = self.conf.get('auditcenter',
                            'address') + '/api/v1/auditBatchAgree'
        param = {
            "ids": ids,
            "auditType": 1,  # 1指门急诊
            "auditWay": 2
        }
        self.request.post_json(url, param)

    def opt_audit(self, engineid, audit_type):
        """
        处方详情审核任务
        :param engineid:
        :param audit_type: 0 审核打回  1 审核打回(可双签) 2 审核通过
        """
        url = self.conf.get('auditcenter',
                            'address') + '/api/v1/ipt/auditSingle'
        param = ''
        if audit_type == 0:
            param = {
                "optRecipeId": engineid,
                "auditResult": "打回必须修改",
                "operationRecordList": [],
                "messageStatus": 0
            }
        elif audit_type == 1:
            param = {
                "optRecipeId": engineid,
                "auditResult": "打回可双签",
                "operationRecordList": [],
                "messageStatus": 1
            }
        elif audit_type == 2:
            param = {"optRecipeId": engineid, "auditResult": "审核通过"}
        self.request.post_json(url, param)

    def get_recipeInfo(self, engineid, type):
        """
        获取处方(包括处方头与处方明细)信息与患者信息
        :param engineid:
        :param type: 0 待审页面 1 已审页面
        :return:
        """
        if type == 0:
            url = self.conf.get(
                'auditcenter',
                'address') + '/api/v1/opt/recipeInfo/' + str(engineid)
        else:
            url = self.conf.get(
                'auditcenter',
                'address') + '/api/v1/opt/all/recipeInfo/' + str(engineid)
        return self.request.get(url)

    def get_operation(self, engineid, type):
        """获取门诊手术信息"""
        if type == 0:
            url = self.conf.get(
                'auditcenter',
                'address') + '/api/v1/opt/optOperationList/' + str(engineid)
        else:
            url = self.conf.get(
                'auditcenter', 'address'
            ) + '/api/v1/opt/all/optOperationList/' + str(engineid)
        return self.request.get(url)
Пример #14
0
class Opt:
    def __init__(self):
        self.send = SendData()
        self.conf = ReadConfig()
        self.auditcenter_url = self.conf.get('auditcenter', 'address')
        self.request = HttpRequest()

    @wait
    def selNotAuditOptList(self, num):
        """
        待审门诊列表根据处方号查询
        :return:   通过return结果可以获得以下数据:engineid res['data']['optRecipeList'][0]['id']
        """
        url = self.conf.get('auditcenter',
                            'address') + '/api/v1/opt/selNotAuditOptList'
        recipeno = 'r' + ''.join(
            str(num)) + '_' + self.send.change_data['{{ts}}']
        param = {"recipeNo": recipeno}
        res = self.request.post_json(url, param)
        return res

    @wait
    def waitOptList(self, num):
        """
        待审门诊列表根据处方号查询
        :return:   通过return结果可以获得以下数据:engineid res['data']['optRecipeList'][0]['id']
        """
        # self.send.send('ipt', '医嘱一', 1)
        # time.sleep(3)
        url = self.conf.get('auditcenter',
                            'address') + '/api/v1/opt/selNotAuditOptList'
        recipeno = 'r' + ''.join(
            str(num)) + '_' + self.send.change_data['{{ts}}']
        param = {"recipeNo": recipeno}
        res = self.request.post_json(url, param)
        optRecipeList = res['data']['optRecipeList']  # 待审列表的处方数据
        infos = []
        engineid = ''
        if optRecipeList is not None:  # 待审列表的处方不为空的时候执行下述语句
            infos = res['data']['optRecipeList'][0]['infos']
            engineid = res['data']['optRecipeList'][0]['optRecipe']['id']
        return optRecipeList, infos, engineid

    def get_engineid(self, num):
        """
        待审列表获取引擎id
        :param num: 根据处方号获取引擎id,注意看xml中处方号r后拼接的是1还是2
        :return:
        """
        res = self.selNotAuditOptList(num)
        return res['data']['optRecipeList'][0]['optRecipe']['id']

    def audit_multi(self, *ids):
        """
        待审门诊任务列表批量通过
        :param ids:  引擎id
        """
        url = self.conf.get('auditcenter',
                            'address') + '/api/v1/auditBatchAgree'
        param = {
            "ids": ids,
            "auditType": 1,  # 1指门急诊
            "auditWay": 2
        }
        self.request.post_json(url, param)

    def opt_audit(self, engineid, audit_type):
        """
        处方详情审核任务
        :param engineid:
        :param audit_type: 0 审核打回  1 审核打回(可双签) 2 审核通过
        """
        url = ''
        param = ''
        if audit_type == 0:
            url = self.conf.get(
                'auditcenter',
                'address') + '/api/v1/detailPageAuditRefuse?auditWay=2'
            param = {
                "optRecipeId": engineid,
                "auditResult": "打回必须修改",
                "operationRecordList": [],
                "messageStatus": 0
            }
        elif audit_type == 1:
            url = self.conf.get(
                'auditcenter',
                'address') + '/api/v1/detailPageAuditRefuse?auditWay=2'
            param = {
                "optRecipeId": engineid,
                "auditResult": "打回可双签",
                "operationRecordList": [],
                "messageStatus": 1
            }
        elif audit_type == 2:
            url = self.conf.get(
                'auditcenter',
                'address') + '/api/v1/detailPageAuditAgree?auditWay=2'
            param = {"optRecipeId": engineid, "auditResult": "审核通过"}
        self.request.post_json(url, param)

    def get_recipeInfo(self, engineid, type):
        """
        获取处方(包括处方头与处方明细)信息与患者信息
        :param engineid:
        :param type: 0 待审页面 1 已审页面
        :return:
        """
        if type == 0:
            url = self.conf.get(
                'auditcenter',
                'address') + '/api/v1/opt/recipeInfo/' + str(engineid)
        else:
            url = self.conf.get(
                'auditcenter',
                'address') + '/api/v1/opt/all/recipeInfo/' + str(engineid)
        return self.request.get(url)

    def get_operation(self, engineid, type):
        """获取门诊手术信息"""
        if type == 0:
            url = self.conf.get(
                'auditcenter',
                'address') + '/api/v1/opt/optOperationList/' + str(engineid)
        else:
            url = self.conf.get(
                'auditcenter', 'address'
            ) + '/api/v1/opt/all/optOperationList/' + str(engineid)
        return self.request.get(url)

    def mergeAuditResult(self, recipeId, id, type):
        """
        获取处方的操作(干预理由、药师、医生等)记录
        :param recipeId:  第一次跑引擎的engineid
        :param id:  第二次跑引擎的engineid
        :param type: type = 0代表待审页面,type = 1代表已审页面
        :return:
        """
        if type == 0:
            url = (self.auditcenter_url +
                   "/api/v1/opt/mergeAuditResult?recipeId=%s&id=%s") % (
                       recipeId, id)
        else:
            url = (self.auditcenter_url +
                   "/api/v1/opt/all/mergeAuditResult?recipeId=%s&id=%s") % (
                       recipeId, id)
        return self.request.get(url)
Пример #15
0
# -*- coding: utf-8 -*-
# @Time : 2019/12/12 15:05
# @Author : wangmengmeng
import pytest
from common.alter_config import AlterConfig
from common.request import HttpRequest
from config.read_config import ReadConfig
import time

sc = AlterConfig()
hq = HttpRequest()
rc = ReadConfig()
url = rc.get('auditcenter', 'address')


class TestSysconfig:
    """测试审方系统在用户中心的配置项是否正确"""
    @pytest.mark.parametrize("value,expected", [(0, 0), (1, 1), (2, 2),
                                                (3, 3)])
    def test_40009(self, value, expected):
        """新任务提醒(是否有提示音)"""
        sc.alter_sys_config(40009, value)
        res = hq.get(url + '/api/v1/newTaskHint')
        actual = res['data']['taskHint']
        assert actual == str(expected)

    def test_40011(self):
        """是否显示住院任务剩余时间"""
        pass

    @pytest.mark.parametrize("value,expected_ipt,expected_opt",
class SendData:
    def __init__(self):
        self.conf = ReadConfig()
        self.tool = Tool()
        self.change_data = {
            "{{ts}}": str(self.tool.get_ts(0, 0)),  # 今天时间戳
            "{{tf2}}": str(self.tool.get_ts(-1, -2)),
            "{{tf1}}": str(self.tool.get_ts(-1, -1)),
            "{{t}}": str(self.tool.get_ts(-1, 0)),  # 昨天时间戳
            "{{d}}": str(self.tool.get_date(-1, 0)),  # 昨天时间
            "{{tf3}}": str(self.tool.get_ts(-1, -3)),
            "{{df4}}": str(self.tool.get_date(-1, -4)),
            "{{tb1}}": str(self.tool.get_ts(-1, +1)),
            "{{db1}}": str(self.tool.get_date(-1, +1)),
            "{{tsb1}}": str(self.tool.get_ts(+1, 0)),  # 明天时间戳
            "{{dtb1}}": str(self.tool.get_date(+1, 0)),  # 明天时间
            "{{gp}}": str(self.tool.get_random(1, 10000)),
            "{{cgp}}": str(self.tool.get_random(1, 100000)),
            "{{ggp}}": str(self.tool.get_random(1, 1000000)),
            "{{df6}}": str(self.tool.get_date(-1, -6)),
            "{{df3}}": str(self.tool.get_date(-1, -3)),
            "{{df2}}": str(self.tool.get_date(-1, -1)),
            "{{df1}}": str(self.tool.get_date(-1, -1)),
            "{{dt}}": str(self.tool.get_date(0, 0)),  # 今天时间
            "{{f5}}": str(self.tool.get_date(-5, 0)),  # 5天前
            "{{f4}}": str(self.tool.get_date(-4, 0)),  # 4天前
            "{{f3}}": str(self.tool.get_date(-3, 0)),  # 3天前
            "{{f2}}": str(self.tool.get_date(-2, 0)),  # 2天前
            "{{f1}}": str(self.tool.get_date(-1, 0)),  # 5天前
            "{{f6}}": str(self.tool.get_date(-6, 0)),  # 4天前
            "{{f7}}": str(self.tool.get_date(-7, 0)),  # 3天前
            "{{f8}}": str(self.tool.get_date(-8, 0)),  # 2天前
            "{{endtoday}}": str(self.tool.get_endtoday())
        }

    @wait
    def send(self, dir_name, xml_name, type):
        """
        审方发数据的接口
        :param dir_name:
        :param xml_name:
        :param type: 1:开具医嘱或处方 2:撤销医嘱或删除处方 3:医生双签医嘱或双签处方 4:删除处方的另外一个接口
        :return:
        """
        xml_path = os.path.join(
            os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
            'data', dir_name, xml_name)
        url = ''
        if type == 1:
            url = self.conf.get('auditcenter',
                                'address') + '/api/v1/auditcenter'
        elif type == 2:
            url = self.conf.get('auditcenter',
                                'address') + "/api/v1/cancelgroupdrug"
        elif type == 3:
            url = self.conf.get('auditcenter',
                                'address') + "/api/v1/doublesign"
        else:
            url = self.conf.get('auditcenter',
                                'address') + "/api/v1/cancelRecipe"

        with open(xml_path, encoding="utf-8") as fp:
            body = fp.read()
        ss = body
        for k in self.change_data:
            ss = ss.replace(k, self.change_data[k])
        print(ss)
        return HttpRequest.post_xml(url, ss)
Пример #17
0
class SendData:
    def __init__(self):
        self.conf = ReadConfig()
        self.tool = Tool()
        self.change_data = {"{{ts}}": str(self.tool.get_ts(0, 0)),  # 今天时间戳
                            "{{tf2}}": str(self.tool.get_ts(-1, -2)),
                            "{{tf1}}": str(self.tool.get_ts(-1, -1)),
                            "{{t}}": str(self.tool.get_ts(-1, 0)),  # 昨天时间戳
                            "{{d}}": str(self.tool.get_date(-1, 0)),  # 昨天时间
                            "{{tf3}}": str(self.tool.get_ts(-1, -3)),
                            "{{df4}}": str(self.tool.get_date(-1, -4)),
                            "{{tb1}}": str(self.tool.get_ts(-1, +1)),
                            "{{db1}}": str(self.tool.get_date(-1, +1)),
                            "{{db180}}": str(self.tool.get_date(0, 3)),  # 今天当前时间+180分钟
                            "{{db240}}": str(self.tool.get_date(0, 4)),  # 今天当前时间+240分钟
                            "{{tb180}}": str(self.tool.get_ts(0, 3)),  # 今天当前时间戳+180分钟
                            "{{db60}}": str(self.tool.get_date(0, 1)),  # 今天当前时间+60分钟
                            "{{tb60}}": str(self.tool.get_ts(0, 1)),  # 今天当前时间戳+60分钟
                            "{{df60}}": str(self.tool.get_date(0, -1)),  # 今天当前时间-60分钟
                            "{{tf60}}": str(self.tool.get_ts(0, -1)),  # 今天当前时间戳-60分钟
                            "{{tsb1}}": str(self.tool.get_ts(+1, 0)),  # 明天时间戳
                            "{{dtb1}}": str(self.tool.get_date(+1, 0)),  # 明天时间
                            "{{gp}}": str(self.tool.get_random(1, 10000)),
                            "{{cgp}}": str(self.tool.get_random(1, 100000)),
                            "{{ggp}}": str(self.tool.get_random(1, 1000000)),
                            "{{df6}}": str(self.tool.get_date(-1, -6)),
                            "{{df3}}": str(self.tool.get_date(-1, -3)),
                            "{{df2}}": str(self.tool.get_date(-1, -1)),
                            "{{df1}}": str(self.tool.get_date(-1, -1)),
                            "{{dt}}": str(self.tool.get_date(0, 0)),  # 今天时间
                            "{{f5}}": str(self.tool.get_date(-5, 0)),
                            "{{f4}}": str(self.tool.get_date(-4, 0)),
                            "{{f3}}": str(self.tool.get_date(-3, 0)),
                            "{{f2}}": str(self.tool.get_date(-2, 0)),
                            "{{endtoday}}":str(self.tool.get_endtoday()),
                            "{{zyhzh}}": str(self.tool.get_ts(0, 0)),  # 同ts(今天时间戳),以下增加的都是用来兼容postman数据
                            "{{mzhzh}}": str(self.tool.get_ts(0, 0)),  # 同ts(今天时间戳),以下增加的都是用来兼容postman数据
                            "{{d2}}": str(self.tool.get_date(0, 0)),  # 同dt(今天时间)
                            "{{d1}}": str(self.tool.get_date(-1, 0)),  # 同d(昨天时间)
                            "{{d4}}": str(self.tool.get_date(-2, 0)), # 同f2(前天时间)
                            "{{bno}}": "6666",  # 床号
                            "{{docId}}": 'wangdoc',  # 医生工号
                            "{{docName}}": '王医生',  # 医生姓名
                            }
    @wait
    def send(self, dir_name, xml_name, type):
        """
        审方发数据的接口
        :param dir_name:
        :param xml_name:
        :param type: 1:开具医嘱或处方 2:撤销医嘱或删除处方 3:医生双签医嘱或双签处方 4:删除处方的另外一个接口
        :return:
        """
        xml_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'data', dir_name, xml_name)
        url = ''
        if type == 1:
            url = self.conf.get('auditcenter', 'address') + '/api/v1/auditcenter'
            # url = 'http://10.1.1.120:2002/face?charset=UTF-8&serviceCode=SF_V4_AUDIT_CENTER&post_type=1'
        elif type == 2:
            # url = self.conf.get('auditcenter', 'address') + "/api/v1/cancelgroupdrug"
            url = 'http://10.1.1.120:2002/face?charset=UTF-8&serviceCode=CANCEL_GROUP_DRUG_V4&post_type=1'
        elif type == 3:
            url = self.conf.get('auditcenter', 'address') + "/api/v1/doublesign"
        else:
            url = self.conf.get('auditcenter', 'address') + "/api/v1/cancelRecipe"

        with open(xml_path, encoding="utf-8") as fp:
            body = fp.read()
        ss = body
        for k in self.change_data:
            ss = ss.replace(k, self.change_data[k])
        print(ss)
        return HttpRequest.post_xml(url, ss)