Exemple #1
0
 def getSqlValue_product_Zone(self, itemname, zoneid, startT, endT,
                              productId):
     print productId
     if itemname in self.drugzone:
         self.sql = self.confR.get("drug_zone", itemname)
         self.sqlValue = self.conndb.executeSQL_zoneid_three(
             self.cur, self.sql, zoneid, startT, endT, productId)
     elif itemname in self.productInfor:
         self.sql = self.confR.get("drug_productInfor", itemname)
         self.sqlValue = self.conndb.executeSQL_drug_productinfor(
             self.cur, self.sql, productId)
     elif itemname in self.optcalc100:
         self.sqlValue = self.getValueInCalc100_drug(
             itemname, zoneid, startT, endT, productId)
     elif itemname == '全院患者使用频次' or itemname == '全院患者使用数量':
         self.sql = self.confR.get('hospital_ddds', itemname)
         self.sqlValue = self.conndb.executeSQL_drug(
             self.cur, self.sql, zoneid, startT, endT, productId)
     elif itemname == '消耗总克数':
         try:
             self.sqlValue = self.getValueInddds(itemname, zoneid, startT,
                                                 endT, productId)[1]
         except Exception, E:
             self.sqlValue = 0
             mylog_except(E)
Exemple #2
0
    def getValueInCalcminus(self, itemname, zoneid, deptid,startT, endT):

        try:
            self.sql = self.confR.get("item_calc_minus", itemname)
            self.itemnames = self.sql.split("-")
            self.itemnameTwoO, self.itemnameTwoT = self.itemnames[0], self.itemnames[1]
            if self.itemnameTwoO == '医疗药品总收入' and self.itemnameTwoT == '全院患者使用中药饮片费用':
                self.itemTwoOsql = self.confR.get("hospital_dept", self.itemnameTwoO)
                self.itemTwoTsql = self.confR.get("hospital_dept", self.itemnameTwoT)
                self.value_itemTwoO = self.conndb.executeSQL_deptid_two(self.cur, self.itemTwoOsql, zoneid,deptid, startT,
                                                                        endT)
                self.value_itemTwoT = self.conndb.executeSQL_deptid_two(self.cur, self.itemTwoTsql, zoneid,deptid, startT,
                                                                        endT)
            else:
                self.itemTwoOsql = self.confR.get("default_dept", self.itemnameTwoO)
                self.itemTwoTsql = self.confR.get("default_dept", self.itemnameTwoT)
                self.value_itemTwoO = self.conndb.executeSQL_deptid_one(self.cur, self.itemTwoOsql, zoneid,deptid, startT,
                                                                        endT)
                self.value_itemTwoT = self.conndb.executeSQL_deptid_one(self.cur, self.itemTwoTsql, zoneid,deptid, startT,
                                                                        endT)

            if self.value_itemTwoO == None:
                self.value_itemTwoO = 0
            if self.value_itemTwoT == None:
                self.value_itemTwoT = 0
            self.itemvalue_two = float(self.value_itemTwoO) - float(self.value_itemTwoT)

            return self.itemvalue_two

        except Exception, error:
            mylog("指标计算时出错")
            mylog_except(error)
Exemple #3
0
    def getCalc_Numerator_zone(self, itemnameOne, zoneid,deptid, startT, endT, optcalcminus):

        self.itemnameOne = itemnameOne
        if (self.itemnameOne == '全院抗菌药物使用金额' or self.itemnameOne == '国家基药目录品种使用金额'):
            self.itemOneSql = self.confR.get("hospital_dept", self.itemnameOne)
            self.itemvalue_one = self.conndb.executeSQL_deptid_two(self.cur, self.itemOneSql, zoneid,deptid, startT, endT)
            if self.itemvalue_one:
                self.itemvalue_one = float(self.itemvalue_one)
            else:
                self.itemvalue_one=0

        elif self.itemnameOne in optcalcminus:

            self.itemvalue_one = self.getValueInCalcminus(itemnameOne, zoneid,deptid, startT, endT)

        elif self.itemnameOne in self.itemname_config[0:4]:
            configValue = self.configValue.getvalue(self.itemnameOne)
            self.itemvalue_one = self.getValueInConfig(self.itemnameOne, zoneid,deptid, startT, endT, configValue,self.configKey)

        elif self.itemnameOne == self.itemname_config[4]:

            drugcodes = self.configValue.getDrugCode(self.itemnameOne)
            self.sql = self.confR.get(self.configKey, self.itemnameOne)
            self.itemvalue_one = self.conndb.executeSQL_deptid_three(self.cur, self.sql, zoneid,deptid, startT, endT, drugcodes)


        elif self.itemnameOne in self.deptddds or self.itemnameOne in self.hospitalddds:

            try:
                self.itemvalue_one = self.getValueInddds(self.itemnameOne, zoneid,deptid, startT, endT)[0]

            except Exception,E:
                self.itemvalue_one=0
                mylog_except(E)
Exemple #4
0
    def getValueInCalc100(self, itemname, zoneid, docid, startT, endT):

        self.sql = self.confR.get("item_calc100", itemname)
        self.itemnames = self.sql.split("/")
        self.itemnameOne, self.itemnameTwo = self.itemnames[0], self.itemnames[
            1]

        if self.itemnameOne in self.docddds:
            self.itemvalue_one = self.calcddds.calcddds_1(
                'dept_ddds', self.itemnameOne, zoneid, docid, startT, endT)[0]

        elif self.itemnameOne in self.hospitalddds:
            self.itemvalue_one = self.calcddds.calcddds_1(
                'hospitaldept_ddds', self.itemnameOne, zoneid, docid, startT,
                endT, zoneid, startT, endT)[0]
        else:
            self.itemOneSql = self.confR.get("default_doc", self.itemnameOne)
            self.itemvalue_one = self.conndb.executeSQL_docid_one(
                self.cur, self.itemOneSql, zoneid, docid, startT, endT)

        self.itemTwoSql = self.confR.get('default_doc', self.itemnameTwo)
        self.itemvalue_two = self.conndb.executeSQL_docid_one(
            self.cur, self.itemTwoSql, zoneid, docid, startT, endT)
        try:
            if self.itemvalue_one and self.itemvalue_two:
                sqlValue = float(self.itemvalue_one) / float(
                    self.itemvalue_two) * 100
                return sqlValue
            else:
                mylog("计算指标不成功,有指标值为空")

        except Exception, error:
            mylog("计算指标发生错误")
            mylog_except(error)
 def getint(self, field, key):
     try:
         return self.conf.getint(field, key)
     except Exception as error:
         logcontent = "读取配置项发生了错误" + "," + field + "," + key
         mylog(logcontent)
         mylog_except(error)
Exemple #6
0
    def getSqlValue_doc(self, itemname, zoneid, docid, startT, endT):

        try:

            if itemname in self.optitems:

                sqlValue = self.getValueInDoc(itemname, zoneid, docid, startT,
                                              endT)
                return sqlValue

            elif itemname in self.hospitalitems:

                sqlValue = self.getValueInHospital(itemname, zoneid, docid,
                                                   startT, endT)
                return sqlValue

            elif itemname in self.optcalc:

                sqlValue = self.getValueInCalc(itemname, zoneid, docid, startT,
                                               endT, self.optcalcminus)
                return sqlValue

            elif itemname in self.optcalcminus:

                sqlValue = self.getValueInCalcminus(itemname, zoneid, docid,
                                                    startT, endT)
                return sqlValue

            elif itemname in self.optcalc100:

                sqlValue = self.getValueInCalc100(itemname, zoneid, docid,
                                                  startT, endT)
                return sqlValue

            elif itemname in self.itemname_config[0:4]:
                configValue = self.configValue.getvalue(itemname)
                sqlValue = self.getValueInConfig(itemname, zoneid, docid,
                                                 startT, endT, configValue,
                                                 self.configKey)
                return sqlValue

            elif itemname == self.itemname_config[4]:

                drugcodes = self.configValue.getDrugCode(itemname)
                self.sql = self.confR.get(self.configKey, itemname)
                sqlValue = self.conndb.executeSQL_docid_three(
                    self.cur, self.sql, zoneid, docid, startT, endT, drugcodes)
                return sqlValue

            elif itemname in self.docddds or itemname in self.hospitalddds:
                try:
                    sqlValue = self.getValueInddds(itemname, zoneid, docid,
                                                   startT, endT)[0]
                except Exception, E:
                    sqlValue = 0
                    mylog_except(E)
                return sqlValue

            else:
Exemple #7
0
    def getReportTime(self, record_id):

        try:
            self.sql = self.confR.get("reportsql", "reportDate")
            self.cur.execute(self.sql, (record_id, ))
            return self.cur.fetchone()

        except Exception, error:
            mylog("SQL执行错误")
            mylog_except(error)
Exemple #8
0
 def __init__(self, path):
     self.path = path
     try:
         # self.conf=ConfigParser()
         self.conf = SafeConfigParser()
         self.conf.read(self.path)
     except Exception, error:
         # print "初始化发生了错误",error
         mylog("初始化发生了错误")
         mylog_except(error)
    def getESvalue(self, reportDataName):

        try:
            self.sql = self.confR.get("reportsql", "esValue")
            self.cur.execute(
                self.sql.format(reportDataName))  # 参见获取报表存放ES数据的表名
            result = self.cur.fetchall()[-1]
            return result

        except Exception as error:
            print("未生成报表数据", error)
            mylog("SQL执行错误")
            mylog_except(error)
Exemple #10
0
    def getESvalue(self, reportDataName):

        try:
            self.sql = self.confR.get("reportsql", "esValue")
            self.cur.execute(self.sql.format(reportDataName))
            result = self.cur.fetchall()[-1]
            es_value = [i for i in result]
            return es_value

        except Exception, error:
            print "未生成报表数据", error
            mylog("SQL执行错误")
            mylog_except(error)
Exemple #11
0
    def getitems_new(self, field):
        try:
            dvalue = self.conf.items(field)
            sqlItemnames = []
            for key, value in dvalue:
                sqlItemnames.append(key)
            return sqlItemnames

        except Exception as error:
            # print "读取配置项发生了错误",field
            logcontent = "读取配置项发生了错误" + "," + field
            mylog(logcontent)
            mylog_except(error)
    def getProjectID(self, projectName):

        try:

            self.sql = self.confR.get("projectsql", "projectID")

            self.cur.execute(self.sql, (projectName, ))
            projectID = self.cur.fetchone()

            if projectID:
                return projectID
            else:
                mylog("项目名称不存在")

        except Exception as error:
            mylog("SQL执行错误")
            mylog_except(error)
    def getSqlValue_group(self, itemname, zoneid, groupname, startT, endT):

        try:

            if itemname in self.optitems:

                sqlValue = self.getValueInGroup(itemname, zoneid, groupname,
                                                startT, endT)
                return sqlValue

            else:
                logcontent = "该指标在指标库中不存在" + ',' + itemname
                mylog(logcontent)

        except Exception, error:
            mylog("执行过程中出错")
            mylog_except(error)
Exemple #14
0
    def getReportID(self, reportName):

        try:

            self.sql = self.confR.get("reportsql", "reportID")

            self.cur.execute(self.sql, (reportName, ))
            reportID = self.cur.fetchone()

            if reportID:
                return reportID
            else:
                mylog("报表名称不存在")

        except Exception, error:
            mylog("SQL执行错误")
            mylog_except(error)
Exemple #15
0
    def getitems(self, field):
        try:
            defaultvalue = self.conf.items('zone')
            defaultKey = [key for key, value in defaultvalue]
            result = self.conf.items(field)
            hospitalItemnames = []
            for key, value in result:
                if key not in defaultKey or key.startswith('i'):
                    hospitalItemnames.append(key.upper())
                else:
                    hospitalItemnames.append(key)
            return hospitalItemnames

        except Exception as error:
            # print "读取配置项发生了错误",field
            logcontent = "读取配置项发生了错误" + "," + field
            mylog(logcontent)
            mylog_except(error)
Exemple #16
0
    def getCalc_denominator_zone(self, itemnameTwo, zoneid,deptid, startT, endT, optcalcminus):
        self.itemnameTwo = itemnameTwo
        self.optcalcminus = optcalcminus

        if self.itemnameTwo in self.optcalcminus:

            self.itemvalue_two = self.getValueInCalcminus(self.itemnameTwo, zoneid,deptid, startT, endT)

        elif self.itemnameTwo in self.itemname_config[0:4]:
            configValue = self.configValue.getvalue(self.itemnameTwo)
            self.itemvalue_two = self.getValueInConfig(self.itemnameTwo, zoneid, deptid,startT, endT, configValue,
                                                       self.configKey)
        elif self.itemnameTwo in self.deptddds or self.itemnameTwo in self.hospitalddds:
            try:
                self.itemvalue_two = self.getValueInddds(self.itemnameOne, zoneid, deptid,startT, endT)[0]

            except Exception,E:
                self.itemvalue_two=0
                mylog_except(E)
Exemple #17
0
    def getValueInCalc(self, itemname, zoneid,deptid, startT, endT, optcalcminus):

        self.sql = self.confR.get("item_calc", itemname)
        self.itemnames = self.sql.split("/")
        self.itemnameOne, self.itemnameTwo = self.itemnames[0], self.itemnames[1]
        self.itemvalue_one = self.getCalc_Numerator_zone(self.itemnameOne, zoneid,deptid, startT, endT, optcalcminus)
        self.itemvalue_two = self.getCalc_denominator_zone(self.itemnameTwo, zoneid,deptid, startT, endT, optcalcminus)

        try:

            if self.itemvalue_one and self.itemvalue_two:
                sqlValue = self.itemvalue_one / self.itemvalue_two
                return sqlValue
            else:
                mylog("计算指标不成功,有指标值为空")

        except Exception, error:

            mylog("计算指标发生错误")
            mylog_except(error)
Exemple #18
0
    def getValueInCalc100_drug(self, itemname, zoneid, startT, endT,
                               productID):

        self.sql = self.confR.get("item_calc100", itemname)
        self.itemnames = self.sql.split("/")
        self.itemnameOne, self.itemnameTwo = self.itemnames[0], self.itemnames[
            1]
        self.itemOneSql = self.confR.get("drug_zone", self.itemnameOne)
        self.itemvalue_one = self.conndb.executeSQL_zoneid_three(
            self.cur, self.itemOneSql, zoneid, startT, endT, productID)
        self.itemTwoSql = self.confR.get('drug_zone', self.itemnameTwo)
        self.itemvalue_two = self.conndb.executeSQL_zoneid_three(
            self.cur, self.itemTwoSql, zoneid, startT, endT, productID)
        try:
            if self.itemvalue_one and self.itemvalue_two:
                sqlValue = float(self.itemvalue_one) / float(
                    self.itemvalue_two) * 100
                return sqlValue
            else:
                mylog("计算指标不成功,有指标值为空")

        except Exception, error:
            mylog("计算指标发生错误")
            mylog_except(error)
Exemple #19
0
                configValue = self.configValue.getvalue(itemname)
                sqlValue = self.getValueInConfig(itemname, zoneid, docid,
                                                 startT, endT, configValue,
                                                 self.configKey)
                return sqlValue

            elif itemname == self.itemname_config[4]:

                drugcodes = self.configValue.getDrugCode(itemname)
                self.sql = self.confR.get(self.configKey, itemname)
                sqlValue = self.conndb.executeSQL_docid_three(
                    self.cur, self.sql, zoneid, docid, startT, endT, drugcodes)
                return sqlValue

            elif itemname in self.docddds or itemname in self.hospitalddds:
                try:
                    sqlValue = self.getValueInddds(itemname, zoneid, docid,
                                                   startT, endT)[0]
                except Exception, E:
                    sqlValue = 0
                    mylog_except(E)
                return sqlValue

            else:
                logcontent = "该指标在指标库中不存在" + ',' + itemname
                mylog(logcontent)

        except Exception, error:
            mylog("执行过程中出错")
            mylog_except(error)
Exemple #20
0
 def connect(self,dbname):
     try:
         return MySQLdb.Connect(host=self.host,port=self.port,user=self.username,passwd=self.passwd,db=dbname,charset=self.charset)
     except Exception,error:
         mylog("数据库连接出错")
         mylog_except(error)