Example #1
0
def format_province_hospital(success):
    '''格式化省市下面的所述医院以及所述部门'''
    province, province_count = get_province()
    hospital, hospital_count = get_hospital()
    department, department_count = get_department()
    position, position_count = get_position()

    success['total'] = []

    if is_list(province) and is_list(hospital) and is_list(department) and is_list(position):
        total_list = []
        for p in province:
            p_pic = flatten(p)
            p_pic['sub_hospital'] = []
            for h in hospital:
                if h.belong_province == p.id:
                    hospital_pic = flatten(h)
                    p_pic['sub_hospital'].append(hospital_pic)
                    hospital_pic['sub_department'] = []
                    for d in department:
                        if d.belong_hospital == h.id:
                            department_pic = flatten(d)
                            hospital_pic['sub_department'].append(department_pic)
                            department_pic['sub_position'] = []
                            for po in position:
                                if po.belong_department == d.id:
                                    position_pic = flatten(po)
                                    department_pic['sub_position'].append(position_pic)
            success['total'].append(p_pic)
Example #2
0
def div_data(success):
    """
    层级显示
    """
    court_list, court_count = get_court()
    brand_list, brand_count = get_brand()
    kind_list, kind_count = get_kind()

    total_list = []
    brand_pic = ''
    court_pic = ''
    for court in court_list:
        court_pic = flatten(court)
        total_list.append(court_pic)
        court_pic['sub_brand'] = []
        for brand in brand_list:
            if brand.court_id == court.id:
                brand_pic = flatten(brand)
                court_pic['sub_brand'].append(brand_pic)
            brand_pic['sub_kind'] = []
            for kind in kind_list:
                if brand.id == kind.brand_id:
                    kind_pic = flatten(kind)
                    brand_pic['sub_kind'].append(kind_pic)
        success['total'].append(court_pic)
def get_collect_abstract(doctor_id, page, success):
    """
    获取医生收藏文摘
    """
    success['academic'] = []
    abstract = AcademicAbstract.query.filter().all()
    collect_count = Collect.query.filter(Collect.doctor_id == doctor_id).count()
    temp_page = page
    page, per_page = page_utils(collect_count, page, per_page=3)
    if collect_count > 1:
        collect_result = Collect.query.filter(Collect.doctor_id == doctor_id, Collect.type == 'abstract')[per_page * (temp_page - 1): per_page * page]
        if collect_result:
            for collect in collect_result:
                for a in abstract:
                    if a.id == collect.type_id:
                        a.is_collect = True
                        a_pic = flatten(a)
                        success['academic'].append(a_pic)
            return True
        else:
            return False
    else:
        collect = Collect.query.filter(Collect.doctor_id == doctor_id, Collect.type == 'abstract').first()
        if collect:
            for a in abstract:
                if a.id == collect.type_id:
                    a.is_collect = True
                    a_pic = flatten(a)
                    success['academic'].append(a_pic)
            return True
        else:
            return False
Example #4
0
def check_is_type(result, remember, return_success):
    """
       判断登陆是baby还是doctor
    """
    if result:
        if type(result) is Baby:
            baby_picture = BabyPicture.query.filter(BabyPicture.baby_id == result.id).first()
            baby_pic = flatten(result)
            baby_pic['is_remember'] = int(remember)
            baby_pic.pop('id')
            baby_pic['user_id'] = result.id
            baby_pic['user_name'] = result.baby_name
            if result.born_birthday:
                baby_birthday = result.born_birthday
                baby_pic['time'] = time_diff(baby_birthday)
            if baby_picture:
                if baby_picture.rel_path and baby_picture.picture_name:
                    baby_pic['picture_path'] = baby_picture.rel_path + '/' + baby_picture.picture_name
            json_append(return_success, baby_pic)
            return True
        elif type(result) is Doctor:
            doctor_pic = flatten(result)
            doctor_pic['is_remember'] = int(remember)
            doctor_pic.pop('id')
            doctor_pic['user_name'] = result.real_name
            doctor_pic['user_id'] = result.id
            if result.rel_path and result.picture_name:
                doctor_pic['picture_path'] = result.rel_path + '/' + result.picture_name
            json_append(return_success, doctor_pic)
            return True
        else:
            return False
    else:
        return False
Example #5
0
def get_recent_modified():
    '''获取最近更新时间'''
    recent = RecentlyModified.query.filter().first()
    if recent:
        recent_pic = flatten(recent)
        return recent_pic
    return 'None'
Example #6
0
def doctor_pickler(doctor, resp_suc):
    doctor_pic = flatten(doctor)
    doctor_pic.pop('belong_hospital_id')
    doctor_pic.pop('belong_department')
    doctor_pic.pop('province_id')
    doctor_pic.pop('position')
    if doctor.rel_path and doctor.picture_name:
        doctor_pic['picture_path'] = doctor.rel_path + '/' + doctor.picture_name
    resp_suc['doctor_list'].append(doctor_pic)
Example #7
0
def change_to_flatten(model):
    """

    """
    if model:
        model_pic = flatten(model)
        return model_pic
    else:
        return ""
Example #8
0
def get_complication(success):
    """
    获取全部合并症数据
    """
    parent_list = []
    child_list = []
    parent_complication = Complication.query.filter(Complication.parent_id == 0).all() # 得到所有父级
    child_complication = Complication.query.filter(Complication.parent_id != 0).all() # 得到所有子级
    success['complication'] = []
    if parent_complication and type(parent_complication) is list:
        if child_complication and type(child_complication) is list:
            for parent in parent_complication:
                parent_pic = flatten(parent)
                parent_list.append(parent_pic)
                parent_pic['child'] = []
                for child in child_complication:
                    if child.parent_id == parent.id:
                        child_pic = flatten(child)
                        parent_pic['child'].append(child_pic)
        success['complication'].append(parent_list)
        return True
    else:
        return False
def get_abstract_by_id(id, doctor_id, success):
    """
    根据id获取文摘
    """
    abstract = AcademicAbstract.query.filter(AcademicAbstract.id == id).first()
    collect_result = Collect.query.filter(Collect.doctor_id == doctor_id, Collect.type_id == abstract.id).first()
    if abstract:
        if collect_result:
            abstract.is_collect = True
        else:
            abstract.is_collect = False
        abstract_pic = flatten(abstract)
        success['abstract'] = abstract_pic
        return True
    else:
        return False
Example #10
0
def check_is_type(result, remember, return_success):
    """
       判断登陆是baby还是doctor
    """
    if result:
        if type(result) is Baby:
            baby_picture = BabyPicture.query.filter(BabyPicture.baby_id == result.id).first()
            baby_pic = flatten(result)
            baby_pic['is_remember'] = int(remember)
            baby_pic.pop('id')
            baby_pic['user_id'] = result.id
            if result.born_birthday:
                baby_birthday = result.born_birthday
                baby_pic['time'] = time_diff(baby_birthday)
            if baby_picture:
                if baby_picture.rel_path and baby_picture.picture_name:
                    baby_pic['picture_path'] = baby_picture.rel_path + '/' + baby_picture.picture_name
            json_append(return_success, baby_pic)
            return True
        elif type(result) is Doctor:
            doctor_pic = flatten(result)
            doctor_pic['is_remember'] = int(remember)
            doctor_pic.pop('id')
            doctor_pic['user_id'] = result.id
            if result.rel_path and result.picture_name:
                doctor_pic['picture_path'] = result.rel_path + '/' + result.picture_name
            json_append(return_success, doctor_pic)
            return True
        else:
            return False
    else:
        return False

#def entering_who():
#    """
#       录入who标准数据
#    """
#    read_file = open('/Users/K/Documents/User Data/baby Data/lhfa_girls_p_exp.txt')
#    result = {}
#    count = 0
#    for line in read_file:
#        ''''''
#        result[str(count)] = []
#        result[str(count)].append(line.replace('\n','').replace('\r','').split('\t'))
#        count = count + 1
#    count = 1
#    length = result.__len__() - 1
#    result.pop('0')
#    for keys in result.keys():
#        #print result[str(count)][0].__len__()
#        weight_boy_standard = HeadSurroundGirlStandard(age=result[str(count)][0][0], L=result[str(count)][0][1],
#                                                M=result[str(count)][0][2], S=result[str(count)][0][3],
#                                                P01=result[str(count)][0][4], P1=result[str(count)][0][5],
#                                                P3=result[str(count)][0][6], P5=result[str(count)][0][7],
#                                                P10=result[str(count)][0][8], P15=result[str(count)][0][9],
#                                                P25=result[str(count)][0][10], P50=result[str(count)][0][11],
#                                                P75=result[str(count)][0][12], P85=result[str(count)][0][13],
#                                                P90=result[str(count)][0][14], P95=result[str(count)][0][15],
#                                                P97=result[str(count)][0][16], P99=result[str(count)][0][17],
#                                                P999=result[str(count)][0][18])
#        db.add(weight_boy_standard)
#        db.commit()
#        count = count + 1
def collect_abstract(academic_result, success):
    '''序列化json对象'''
    academic_pic = flatten(academic_result)
    success['academic_list'].append(academic_pic)