Ejemplo n.º 1
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)
Ejemplo n.º 2
0
 def getint(self, field, key):
     try:
         return self.conf.getint(field, key)
     except Exception as error:
         logcontent = "读取配置项发生了错误" + "," + field + "," + key
         mylog(logcontent)
         mylog_except(error)
Ejemplo n.º 3
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)
Ejemplo n.º 4
0
    def getValueInddds(self,
                       itemname,
                       zoneid,
                       docid,
                       startT,
                       endT,
                       productID=None):

        self.docddds = self.confR.getitems('doc_ddds')
        self.hospitalddds = self.confR.getitems('hospitalDoc_ddds')

        #获取qty计算方法配置项的值,根据配置项进行消耗克数的计算
        qtyvalue = self.configValue.getvalue('qty')
        qtyvalue_int = int(qtyvalue.encode('utf8'))
        if qtyvalue_int == 1:
            if itemname in self.docddds:
                self.sqlValue = self.calcddds.calcddds_1(
                    'doc_ddds', itemname, zoneid, docid, startT, endT)
            elif itemname in self.hospitalddds:
                self.sqlValue = self.calcddds.calcddds_1(
                    'hospitalDoc_ddds', itemname, zoneid, docid, startT, endT,
                    productID, zoneid, docid, startT, endT, productID)

        else:
            mylog('配置项错误')
        return self.sqlValue
Ejemplo n.º 5
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)
Ejemplo n.º 6
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)
Ejemplo n.º 7
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)
Ejemplo n.º 8
0
    def getSqlValue_analysis_Zone(self, itemname, zoneid, startT, endT,
                                  analysis_type):
        self.messgeItems = self.confR.getitems("message_zone")
        self.calc = self.confR.getitems('item_calc')

        if itemname in self.messgeItems:
            self.sql = self.confR.get("message_zone", itemname)
            sqlValue = self.conndb.executeSQL_zoneid_three(
                self.cur, self.sql, zoneid, startT, endT, analysis_type)
            return sqlValue

        else:
            mylog("没有该指标的配置")
Ejemplo n.º 9
0
    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)
Ejemplo n.º 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)
Ejemplo n.º 11
0
    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)
Ejemplo n.º 12
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)
Ejemplo n.º 13
0
    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)
Ejemplo n.º 14
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)
Ejemplo n.º 15
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)
Ejemplo n.º 16
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)
Ejemplo n.º 17
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)
Ejemplo n.º 18
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)