Exemplo n.º 1
0
def cleaningBR_Diagnosis():

    # 初始化连接
    conntheo = connsql()
    # 初始化redis连接
    redis = RedisServer()

    print('****开始 BR_Diagnosis ****')

    numFirst=0
    numSecond=conntheo.perNum

    result_num=1

    # 如果数据为0了就不要再循环了
    while result_num>0:
        start_time1 = timeit.default_timer()

        all_results = conntheo.theo.session.query(formativetableprimarykey_fourthtry).slice(numFirst, numSecond).all()

        end_time1 = timeit.default_timer()
        elapsed1 = end_time1 - start_time1
        print('这是取数据的时间,花费了 %0.2fs...' % elapsed1)

        # 如果没有数据了 就不要再循环了
        if len(all_results)==0:
            break
        else:
            numFirst += conntheo.perNum
            numSecond += conntheo.perNum

        start_time=timeit.default_timer()

        for single_result in all_results:
            # pass
            # print(str(redis.getValue(int(single_result.Medical_record_no))))

            result=pyEOR(71593504,int(single_result.Medical_record_no))
            # print(result)
            single_result.Medical_record_no=result

            # 一定要flush(),否则会有语句丢失
            conntheo.theo.session.flush()


        end_time = timeit.default_timer()
        elapsed=end_time-start_time
        print('正在处理 {0}到{1}行的数据...'.format(str(numFirst-conntheo.perNum), str(numSecond-conntheo.perNum))+',花费了 %0.2fs...'%elapsed)

    # # 最后关闭
    conntheo.theo.session.commit()
    conntheo.theo.session.close()


    print('****结束 BR_Diagnosis ****')
Exemplo n.º 2
0
def cleaningBR_Diagnosis():

    # 初始化连接
    conntheo = connsql()

    print('****开始 BR_Diagnosis ****')

    numFirst = 0
    numSecond = conntheo.perNum

    result_num = 1

    # 如果数据为0了就不要再循环了
    while result_num < 100:

        start_time = timeit.default_timer()

        for single in range(1 + (result_num - 1) * 1000,
                            1000 * result_num + 1):
            # pass
            # print(str(redis.getValue(int(single_result.BR_EncounterID))))

            newdata = BR_Diagnosis_copy1(BR_EncounterID=str(single),
                                         BR_EncounterNewID=pyEOR(
                                             71593504, int(single)))
            conntheo.theo.session.add(newdata)

            # 一定要flush(),否则会有语句丢失
            conntheo.theo.session.flush()

        end_time = timeit.default_timer()
        elapsed = end_time - start_time
        print('正在处理 {0}到{1}行的数据...'.format(str(1 + (result_num - 1) * 1000),
                                           str(1000 * result_num + 1)) +
              ',花费了 %0.2fs...' % elapsed)

        result_num += 1

    # 最后关闭
    conntheo.theo.session.commit()
    conntheo.theo.session.close()

    print('****结束 BR_Diagnosis ****')
Exemplo n.º 3
0
def cleaningEncounter():

    # 初始化连接
    conntheo = connsql()

    print('****开始 Encounter ****')

    numFirst=0
    numSecond=conntheo.perNum

    result_num=1

    # 如果数据为0了就不要再循环了
    while result_num>0:
        all_results = conntheo.theo.session.query(BR_Encounter).order_by(BR_Encounter.BR_EncounterID).slice(numFirst, numSecond).all()

        # 如果没有数据了 就不要再循环了
        if len(all_results)==0:
            break
        else:
            numFirst += conntheo.perNum
            numSecond += conntheo.perNum

        print('正在处理 {0}到{1}行的数据...'.format(str(numFirst-conntheo.perNum), str(numSecond-conntheo.perNum)))
        start_time=timeit.default_timer()

        for single_result in all_results:
            single_result.EncounterIDEncrypt=pyhashlibMd5(single_result.BR_EncounterID)

            # 一定要flush(),否则会有语句丢失
            conntheo.theo.session.flush()


        end_time = timeit.default_timer()
        elapsed=end_time-start_time
        print('花费了 %0.2fs...'%elapsed)

    # 最后关闭
    conntheo.theo.session.commit()
    conntheo.theo.session.close()


    print('****结束 Encounter ****')
Exemplo n.º 4
0
def cleaningBR_Demographics():

    # 初始化连接
    conntheo = connsql()

    print('****开始 BR_Demographics ****')

    numFirst = 0
    numSecond = conntheo.perNum

    result_num = 1

    # 如果数据为0了就不要再循环了
    while result_num > 0:
        all_results = conntheo.theo.session.query(BR_Demographics).order_by(
            BR_Demographics.BR_Demographics_ID).slice(numFirst,
                                                      numSecond).all()

        # 如果没有数据了 就不要再循环了
        if len(all_results) == 0:
            break
        else:
            numFirst += conntheo.perNum
            numSecond += conntheo.perNum

        print('正在处理 {0}到{1}行的数据...'.format(str(numFirst - 5000),
                                           str(numSecond - 5000)))

        for single_result in all_results:
            single_result.BR_EncounterNewID = int(
                pyEOR(conntheo.key, int(single_result.BR_EncounterID)))
            # 一定要flush(),否则会有语句丢失
            conntheo.theo.session.flush()

    # 最后提交一下
    conntheo.theo.session.commit()
    # 最后关闭
    conntheo.theo.session.close()
    print('****结束 BR_Demographics ****')
Exemplo n.º 5
0
from qilucleaning.model import BR_Encounter
from qilucleaning.sqlconnnection import connsql
from redisPackage.ReServer import RedisServer
from utils.EncryptUtils import pyEOR


# 初始化sqlserver连接
conntheo = connsql()
# 初始化redis连接
redis=RedisServer()


print('****开始 转换encounterid ****')

numFirst=0
numSecond=conntheo.perNum

result_num=1

# 如果数据为0了就不要再循环了
while result_num>0:
    all_results = conntheo.theo.session.query(BR_Encounter).order_by(BR_Encounter.BR_EncounterID).slice(numFirst, numSecond).all()

    # 如果没有数据了 就不要再循环了
    if len(all_results)==0:
        break
    else:
        numFirst += conntheo.perNum
        numSecond += conntheo.perNum

    print('正在处理 {0}到{1}行的数据...'.format(str(numFirst-conntheo.perNum), str(numSecond-conntheo.perNum)))