async def text_execute_action(text, confidence): """ executes an action for the text. If no action matches, a not found action will be executed """ action = get_action(text, confidence) if action is not None: await action[1](text) else: send_post(settings.BRAIN_WEB_ORIGIN + "say", {"text": settings.SAY_DONT_UNDERSTAND})
def mdr_update_appraise(date): ''' 更新指定日期的再评价数据 ''' print u'开始更新%s的不良事件评价数据!' % date #删除指定日期的id列表 delete_sql = "delete from mdr_fullidlist where SendDate='%s'" % date mdrsql.mdr_delete_alone(delete_sql) #抓取当天所有有效记录的ID report_query_full.crawler_mdr_record_ids(date) #查询需要下载的记录 query_sql = "select * from mdr_fullidlist where sendDate='%s' and BackState<>'%s' " % ( date, u'已退回') download_rows = mdrsql.mdr_dict_query(query_sql) for qrow in download_rows: viewId = qrow["ViewID"] ReportUnitName = qrow["ReportUnitName"] backState = qrow["BackState"] AddSource = qrow["AddSource"] ReportDate = qrow["SendDate"] ReportID = qrow["ReportID"] ValueState = qrow["ValueState"] if not ValueState: print u'%s 未评价!' % ReportID continue mdr_Home_1 = 'http://www.adrs.org.cn/MDR/scripts/mdr/smdr/smdReportView.jsp' querydata_1 = { "action": "update", "FD_OBJECTID": viewId, "UNIT_NAME": ReportUnitName, "start": 1, "limit": 10 } smdrReportViewHtml = utils.send_post(mdr_Home_1, urllib.urlencode(querydata_1)) if not backState and smdrReportViewHtml: #获取关联性评价信息 utils.mdr_get_smd_appraise(smdrReportViewHtml, ReportID, viewId, ReportUnitName, ReportDate) mdr_data = mdr_parse.mdr_get_report_data(viewId, ReportID, ReportDate) if mdr_data and "reporter" in mdr_data: utils.get_smd_report(smdrReportViewHtml, ReportID, viewId, ReportUnitName, mdr_data["reporter"], mdr_data["reporter_class"], ReportDate) print u"%s的不良事件评价更新完成!" % (date)
def mdr_update_appraise(date): ''' 更新指定日期的再评价数据 ''' print u'开始更新%s的不良事件评价数据!' % date #删除指定日期的id列表 delete_sql = "delete from mdr_fullidlist where SendDate='%s'" % date mdrsql.mdr_delete_alone(delete_sql) #抓取当天所有有效记录的ID report_query_full.crawler_mdr_record_ids(date) #查询需要下载的记录 query_sql = "select * from mdr_fullidlist where sendDate='%s' and BackState<>'%s' " % (date,u'已退回') download_rows = mdrsql.mdr_dict_query(query_sql) for qrow in download_rows: viewId = qrow["ViewID"] ReportUnitName = qrow["ReportUnitName"] backState = qrow["BackState"] AddSource = qrow["AddSource"] ReportDate = qrow["SendDate"] ReportID = qrow["ReportID"] ValueState = qrow["ValueState"] if not ValueState: print u'%s 未评价!' % ReportID continue mdr_Home_1 = 'http://www.adrs.org.cn/MDR/scripts/mdr/smdr/smdReportView.jsp' querydata_1 = { "action" : "update", "FD_OBJECTID" : viewId, "UNIT_NAME" : ReportUnitName, "start" : 1, "limit" : 10 } smdrReportViewHtml = utils.send_post(mdr_Home_1, urllib.urlencode( querydata_1)) if not backState and smdrReportViewHtml: #获取关联性评价信息 utils.mdr_get_smd_appraise(smdrReportViewHtml, ReportID, viewId, ReportUnitName,ReportDate) mdr_data = mdr_parse.mdr_get_report_data(viewId,ReportID,ReportDate) if mdr_data and "reporter" in mdr_data: utils.get_smd_report(smdrReportViewHtml, ReportID, viewId,ReportUnitName,mdr_data["reporter"],mdr_data["reporter_class"],ReportDate) print u"%s的不良事件评价更新完成!" % (date)
def test_diary_delete_no_token(self): response = send_post(self.client, url_for('views.diary_delete')) assert response.status_code == 400
def test_user_register_no_args(self): response = send_post(self.client, url_for('views.users_register')) assert response.status_code == 400
def test_users_no_token(self): response = send_post(self.client, url_for('views.users')) assert response.status_code == 400
def test_user_authenticate_no_args(self): response = send_post(self.client, url_for('views.users_authenticate')) assert response.status_code == 400
def mdr_import_report(qrow): ''' 抓取指定的记录 ''' smdrReportViewHtml = None is_icd = None icd_setdata = None viewId = qrow['ViewID'] ValueState = qrow['ValueState'] #评价状态 backState = qrow['BackState'] #退回状态 StateReportDate = qrow['ReceiveDate'] #接收日期 AddSource = qrow['AddSource'] #补充材料 ReportID = qrow['ReportID'].strip() #报告id ReportUnitName = qrow['ReportUnitName'] #报告单位名称 SendDate = qrow['SendDate'] #上报日期 ReportID = utils.unicode_to_str(ReportID.strip()) ReportUnitName = utils.str_to_unicode(ReportUnitName) print u"报告编码(MDR):", ReportID appraise_status = 0 #评价状态 if ValueState: appraise_status = 1 #退回状态 elif backState: appraise_status = 2 mdr_data = mdr_get_report_data(viewId, ReportID, SendDate) qg_info = utils.getsmdrfda(viewId, ReportID, SendDate) sh_info = utils.getSmdrWhoArt(ReportID, SendDate, viewId) # 获取报告单位所在行政区信息 (County,District,ProvinceName) = utils.getReportUnitDistrictInfo(ReportUnitName) mdr_data["County"] = County mdr_data["District"] = District mdr_data["ProvinceName"] = ProvinceName mdr_data["ReportUnitName"] = ReportUnitName mdr_data["BianMa"] = ReportID mdr_data["StateReportDate"] = StateReportDate #获取报告状态 report_status = utils.getReportStatus(ReportID, viewId, SendDate) IsNotifyGov_value = u'已通知药监部门' if u'已通知药监部门' in report_status else '' IsNotifyFactory_value = u'已通知生产企业' if u'已通知生产企业' in report_status else '' IsNotifyUnit_value = u'已通知使用单位' if u'已通知使用单位' in report_status else '' IsNotifyShop_value = u'已通知经营企业' if u'已通知经营企业' in report_status else '' State = u','.join(report_status) mdr_data["State"] = State icd_ok = mdr_data["icd_ok"] if len(icd_ok) != 0: (is_icd, UnMatchAffect,icd_setdata) = get_icd_info(mdr_data, icd_ok) # #获取器械基础信息 # (UnMatchDevice,IsMatchingDevice,deviceInfo) = utils.getDeviceInstrumentInfo(mdr_data["DeviceStandard"]) # mdr_data["UnMatchDevice"] = UnMatchDevice # mdr_data["IsMatchingDevice"] = IsMatchingDevice IsMatchingFault = None IsADRorAccident_tag = None qg_setdata = None if qg_info: (IsMatchingFault, IsADRorAccident_tag, qg_setdata, sanlei) = mdr_falt_business(qg_info, mdr_data["DeviceStandard"]) else: IsMatchingFault = '否' is_adr = None adr_data_list = None if sh_info: (is_adr, adr_data_list, IsADRorAccident_tag) = get_sh_info(sh_info,mdr_data) else: is_adr = u'否' if qg_info and sh_info: IsADRorAccident_tag = "3" else: IsADRorAccident_tag = "4" mdr_Home_1 = 'http://www.adrs.org.cn/MDR/scripts/mdr/smdr/smdReportView.jsp' querydata_1 = { "action" : "update", "FD_OBJECTID" : viewId, "UNIT_NAME" : utils.unicode_to_str(ReportUnitName), "start" : "1", "limit" : "10" } smdrReportViewHtml = utils.send_post(mdr_Home_1, urllib.urlencode( querydata_1)) if not backState and smdrReportViewHtml: #获取关联性评价信息 utils.mdr_get_smd_appraise(smdrReportViewHtml, ReportID, viewId, ReportUnitName,mdr_data["ReportDate"]) #获取器械基础信息 (UnMatchDevice,IsMatchingDevice,deviceInfo) = utils.getDeviceInstrumentInfo(mdr_data["DeviceStandard"]) mdr_data["UnMatchDevice"] = UnMatchDevice mdr_data["IsMatchingDevice"] = IsMatchingDevice if mdr_data["company_name"] : #存在,先去查询GMP (IsMatchingFactory,UnMatchFactory) = import_GMP_Info(mdr_data,mdr_data["company_name"] ,deviceInfo) mdr_data["IsMatchingFactory"] = IsMatchingFactory mdr_data["UnMatchFactory"] = UnMatchFactory d_tag = "" main_data = [ mdr_data["BianMa"], mdr_data["ProvinceName"], mdr_data["District"], mdr_data["County"], mdr_data["ReportUnitName"], mdr_data["ReportUnitAddress"], mdr_data["ReportUnitTel"], mdr_data["Postalcode"], mdr_data["UnitType"], mdr_data["HappenDate"], mdr_data["KnowDate"], mdr_data["ReportDate"], mdr_data["ReportDate"], mdr_data["StateReportDate"], mdr_data["State"], mdr_data["patient_name"], mdr_data["patient_gender"], mdr_data["patient_birthday"], mdr_data["patient_age"], mdr_data["age_class"], mdr_data["patient_telephone"], mdr_data["event_memo"], mdr_data["event_consequence"], mdr_data["death_time"], appraise_status, d_tag, IsNotifyGov_value, IsNotifyFactory_value, IsNotifyUnit_value, IsNotifyShop_value, IsMatchingDevice, UnMatchDevice, is_icd, icd_setdata, IsMatchingFault, qg_setdata, None, is_adr, adr_data_list ] #信息插入 main_sql = ( u"""replace into mdr_business_gather( BianMa,ProvinceName,District,County, ReportUnitName, ReportUnitAddress,ReportUnitTel,Postalcode,UnitType,HappenDate,KnowDate,ReportDate,AcceptDate,StateReportDate,State,SuffererName,Sex,Birthday,Age,SuffererType,TelePhone,DepictDispose,Events,DeathDate,ReportInfo,DumplicateData, IsnotifyGov, IsnotifyFactory, IsnotifyUnit, IsnotifyShop,IsDeviceMatch,DeviceList,IsICDMatch,ICDList,IsFaultMatch,FaultList,IsADRorAccident,IsADRMatch,ADRList) values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)""" ) mdrsql.mdr_insert_alone(main_sql, main_data) #D.关联性评价 ,一定要在insert主表之后执行 if smdrReportViewHtml : utils.get_smd_report(smdrReportViewHtml, ReportID, viewId,ReportUnitName,mdr_data["reporter"],mdr_data["reporter_class"],mdr_data["ReportDate"]) #print u"本次下载任务已经结束" if qg_setdata: if len(sanlei) > 2: qg_data = ( mdr_data["BianMa"], mdr_data["ProvinceName"], mdr_data["District"], mdr_data["County"], mdr_data["ReportUnitName"], mdr_data["ReportUnitAddress"], mdr_data["ReportUnitTel"], mdr_data["Postalcode"], mdr_data["UnitType"], mdr_data["HappenDate"], mdr_data["KnowDate"], mdr_data["ReportDate"], mdr_data["ReportDate"], mdr_data["StateReportDate"], mdr_data["State"], IsMatchingFault, qg_setdata, sanlei[2], sanlei[1], sanlei[0], None) qg_sql = ( "replace into mdr_faultbusiness(BianMa,ProvinceName,District,County,ReportUnitName,ReportUnitAddress," "ReportUnitTel,Postalcode,UnitType,HappenDate,KnowDate,ReportDate,AcceptDate,StateReportDate,State," "IsMatchingFault,StandardFaultName,Name,SubName,SuperClassName,NonName)" "values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)" ) mdrsql.mdr_insert_alone(qg_sql, qg_data) else: qg_data = ( mdr_data["BianMa"], mdr_data["ProvinceName"], mdr_data["District"], mdr_data["County"], mdr_data["ReportUnitName"], mdr_data["ReportUnitAddress"], mdr_data["ReportUnitTel"], mdr_data["Postalcode"], mdr_data["UnitType"], mdr_data["HappenDate"], mdr_data["KnowDate"], mdr_data["ReportDate"], mdr_data["ReportDate"], mdr_data["StateReportDate"], mdr_data["State"], IsMatchingFault, qg_setdata, None, None, None, sanlei[0]) qg_sql = ( "replace into mdr_faultbusiness(BianMa,ProvinceName,District,County,ReportUnitName,ReportUnitAddress," "ReportUnitTel,Postalcode,UnitType,HappenDate,KnowDate,ReportDate,AcceptDate,StateReportDate,State," "IsMatchingFault,StandardFaultName,Name,SubName,SuperClassName,NonName)" "values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)" ) mdrsql.mdr_insert_alone(qg_sql, qg_data)