def get_selNotAuditIptList(): req = HttpRequest() url = "http://10.1.1.71:9999/auditcenter/api/v1/ipt/selNotAuditIptList" headers = {'Content-Type': "application/json"} param = {} res = req.post_json(url, param) if res['data']['engineInfos']: engineids = [i['id'] for i in res['data']['engineInfos']] # print(engineids) random_engineid = random.choice(engineids) print(random_engineid) url = 'http://10.1.1.71:9999/auditcenter/api/v1/ipt/orderList' + '?id=' + str( random_engineid) orderlist = req.get(url) print(orderlist['data']) gps = list(orderlist['data'].keys()) gp = [ i for i in list(orderlist['data'].keys()) if orderlist['data'][i][0]['auditMarkStatus'] is None ] # for i in gps: # print(i) # print(orderlist['data'][i][0]) # print(orderlist['data'][i][0]['auditMarkStatus']) # print(type(orderlist['data'][i][0])) para = { "groupOrderList": [{ "auditBoList": [], "groupNo": gp[0], "auditInfo": "必须修改", "auditStatus": 0, "engineId": random_engineid, "orderType": 1 }] } aa = req.post_json( 'http://10.1.1.71:9999/auditcenter/api/v1/ipt/auditSingle', para) print(aa) print(gps[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)
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)
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)
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)