Esempio n. 1
0
 def info(self):
     """活动详情"""
     args = request.args.to_dict()
     uaid = args.get('uaid')
     if uaid:
         ua = self._ua_filter(
             (UserActivity.UAid == uaid, ), ).first_('活动不存在')
         acid = ua.ACid
     else:
         parameter_required('acid', datafrom=args)
         acid = args.get('acid')
     activity = Activity.query.filter(
         Activity.isdelete == false(),
         Activity.ACid == acid).first_('未找到活动信息')
     if not is_admin():
         activity.hide('ACnumber')
     if is_user():
         activity.fill('signed_up',
                       bool(
                           self._ua_filter([
                               UserActivity.ACid == acid,
                               UserActivity.USid == getattr(
                                   request, 'user').id
                           ]).first()))  # 是否已报名
     activity.fill('acstatus_zh',
                   ActivityStatus(activity.ACstatus).zh_value)
     activity.fill('remain_people',
                   self._query_activity_remain_people(activity))
     return Success(data=activity)
Esempio n. 2
0
    def add_or_update_series(self):
        data = parameter_required()
        seid = data.get('seid')
        doid = getattr(request, 'user').id
        with db.auto_commit():
            if seid:
                series = Series.query.filter(
                    Series.SEid == seid, Series.isdelete == 0).first()
                current_app.logger.info('get series {} '.format(series))
                # 优先判断删除
                if data.get('delete'):
                    if not series:
                        raise ParamsError('剧集已删除')
                    current_app.logger.info('删除科室 {}'.format(doid))
                    series.isdelete = 1
                    db.session.add(series)
                    return Success('删除成功', data=seid)

                # 执行update
                if series:
                    update_dict = series.get_update_dict(data)
                    if update_dict.get('SEid'):
                        update_dict.pop('SEid')
                    if update_dict.get('DOid'):
                        update_dict.pop('DOid')
                    if update_dict.get('SEsort', 0):
                        try:
                            int(update_dict.get('SEsort'))
                        except:
                            raise ParamsError('排序请输入整数')

                    series.update(update_dict)
                    current_app.logger.info('更新系列 {}'.format(seid))
                    db.session.add(series)
                    return Success('更新成功', data=seid)
            # 添加
            data = parameter_required({'sename': '剧集名', })

            seid = str(uuid.uuid1())

            if data.get('sesort', 0):
                try:
                    int(data.get('sesort', 0))
                except:
                    raise ParamsError('排序请输入整数')
            doctor = Series.create({
                'DOid': doid,
                'SEid': seid,
                'SEname': data.get('sename'),
                'SEsort': data.get('sesort', 0),
            })
            current_app.logger.info('创建剧集 {}'.format(data.get('sename')))
            db.session.add(doctor)
        return Success('创建剧集成功', data=doid)
Esempio n. 3
0
    def get_video(self):
        data = parameter_required('viid')
        viid = data.get('viid')
        usid = getattr(request, 'user').id
        video = Video.query.filter(Video.VIid == viid, Video.isdelete == 0).first_('视频已删除')
        # 添加 评论
        reviews = Review.query.filter(
            Review.RVtype == 405, Review.RVtypeid == video.VIid, Review.isdelete == 0).order_by(
            Review.createtime.desc()).all()
        for review in reviews:
            review.add('createtime')
        reviesw_count = len(reviews)

        video.fill('reviesw_count', reviesw_count)
        video.fill('reviews', reviews)
        doctor = Doctor.query.filter(Doctor.DOid == video.DOid, Doctor.isdelete == 0).first()
        if doctor:
            video.fill('doname', doctor.DOname)
            video.fill('dotitle', doctor.DOtitle)
            video.fill('dotel', doctor.DOtel)

        if video.SEid:
            se_video_list = Video.query.filter(Video.SEid == video.SEid, Video.isdelete == 0).order_by(
                Video.VIsort.asc(), Video.createtime.desc()).all()
            sename_list = [{'viid': se_video.VIid, 'viname': '第{}期:{}'.format(i + 1, se_video.VIname)}
                           for i, se_video in enumerate(se_video_list)]
            video.fill('senamelist', sename_list)
            series = Series.query.filter(Series.SEid == video.SEid, Series.isdelete == 0).first()
            if series:
                video.fill('sename', series.SEname)
        # 添加积分获取
        from .CConfig import CConfig
        CConfig()._judge_point(PointTaskType.watch_video.value, 1, usid)

        return Success('获取成功', data=video)
Esempio n. 4
0
 def get_setmeal(self):
     """
     获取课时套餐
     """
     if is_admin() or is_hign_level_admin():
         setmeal = Setmeal.query.filter(
             Setmeal.isdelete == 0).all_with_page()
         return Success(message="获取课时套餐成功", data=setmeal)
     elif is_user():
         args = parameter_required(('clid', ))
         classes = Classes.query.filter(
             Classes.isdelete == 0,
             Classes.CLid == args.get('clid')).first_("未找到该课程信息")
         setmeal_list = []
         setmeal_list.append({
             "smid": "1",
             "clid": args.get('clid'),
             "clname": classes["CLname"],
             "smnum": 1,
             "smprice": classes["CLprice"]
         })
         setmeal = Setmeal.query.filter(
             Setmeal.isdelete == 0, Setmeal.CLid == args.get("clid")).all()
         setmeal.sort(key=lambda x: x["SMnum"])
         for setmeal_one in setmeal:
             setmeal_list.append(setmeal_one)
         return Success(message="获取课时套餐成功", data=setmeal_list)
Esempio n. 5
0
 def get_course_by_doctor_month(self):
     """
     基于医生id获取未来30天课程情况
     """
     args = parameter_required(('doid', 'clid'))
     filter_args = [
         Course.isdelete == 0, Course.DOid == args.get('doid'),
         Course.CLid == args.get('clid')
     ]
     year = int(datetime.datetime.now().year)
     month = int(datetime.datetime.now().month)
     day = int(datetime.datetime.now().day)
     start_time = datetime.datetime(year, month, day, 0, 0, 0)
     end_time = datetime.datetime(year, month, day, 23, 59,
                                  59) + datetime.timedelta(days=30)
     filter_args.append(Course.COstarttime > start_time)
     filter_args.append(Course.COendtime < end_time)
     course_list = Course.query.filter(*filter_args).all()
     time_dict = []
     for course in course_list:
         costarttime = course["COstarttime"]
         if "{0}-{1}-{2}".format(year, month,
                                 costarttime.day) not in time_dict:
             time_dict.append("{0}-{1}-{2}".format(year, month,
                                                   costarttime.day))
     return Success(message="获取日期成功", data=time_dict)
Esempio n. 6
0
 def set_evaluationanswer(self):
     """设置题目选项"""
     data = parameter_required((
         'eiid', 'eaname', 'eaindex',
         'eapoint') if not request.json.get('delete') else ('eaid', ))
     if not is_admin():
         return AuthorityError()
     ea_dict = {
         "EIid": data.get('eiid'),
         "EAname": data.get('eaname'),
         "EAindex": data.get('eaindex'),
         "EApoint": Decimal(str(data.get('eapoint') or 0))
     }
     eaid = data.get("eaid")
     with db.auto_commit():
         if not eaid:
             # 新增
             ea_dict["EAid"] = str(uuid.uuid1())
             ea_instance = EvaluationAnswer.create(ea_dict)
             msg = "新增成功"
         else:
             ea_instance = EvaluationAnswer.query.filter(
                 EvaluationAnswer.EAid == eaid).first_("未找到该选项")
             if data.get("delete"):
                 ea_instance.update({"isdelete": 1})
                 msg = "删除成功"
             else:
                 ea_instance.update(ea_dict)
                 msg = "修改成功"
         db.session.add(ea_instance)
     return Success(message=msg)
Esempio n. 7
0
    def get(self):
        data = parameter_required('doid')
        doid = data.get('doid')
        conid = data.get('conid')
        doctor = Doctor.query.filter(Doctor.DOid == doid,
                                     Doctor.isdelete == 0).first()
        if not doctor:
            raise ParamsError('医生已离开')

        doctor.fields = [
            'DEid', 'DOname', 'DOid', 'DOtitle', 'DOtel', 'DOdetails',
            'DOwxid', 'DOskilledIn', 'createtime', 'DOsort'
        ]
        self._fill_department(doctor)
        self._fill_doctor_mainpic(doctor)
        self._fill_doctor_listpic(doctor)
        self._fill_doctor_qrpic(doctor)
        if conid:
            # 填充会诊信息
            self._fill_consultation(doctor, conid)

        # doctor.fill('favorablerate', '100%')
        # doctor.fill('treatnum', '0')
        self._fill_doctor_review(doctor)
        return Success('获取成功', data=doctor)
Esempio n. 8
0
 def reset_password(self):
     """重置管理员密码"""
     data = parameter_required(('adid', 'adtype'))
     token = token_to_user_(request.args.get('token'))
     # 判断权限
     ad = Admin.query.filter(Admin.isdelete == 0, Admin.ADid == token.id).first()
     adid = ad.ADid
     if adid != "1":
         raise AuthorityError("无权限")
     else:
         with db.auto_commit():
             if data['adtype'] == 1:
                 ad_dict = {
                     'ADpassword': generate_password_hash('123456')
                 }
                 ad_instance = Admin.query.filter(Admin.ADid == data.get("adid"), Admin.isdelete == 0)\
                     .first_('未找到该账号信息')
                 ad_instance.update(ad_dict, null='not')
             elif data['adtype'] == 2:
                 ad_instance = Doctor.query.filter(Doctor.DOid == data.get('adid'), Doctor.isdelete == 0)\
                     .first_('未找到该账号信息')
                 ad_dict = {
                     'DOpassword': generate_password_hash(str(ad_instance.DOtel)[-6:])
                 }
                 ad_instance.update(ad_dict, null='not')
         db.session.add(ad_instance)
         msg = "重置密码成功"
     return Success(message=msg)
Esempio n. 9
0
    def userlist(self):
        """获取用户优惠券(前台)"""
        args = parameter_required(('ucalreadyuse', ))
        # 601已使用602未使用603已过期604可使用
        if not is_user():
            return AuthorityError()
        usid = request.user.id
        ucalreadyuse = int(args.get('ucalreadyuse'))
        if ucalreadyuse in [601, 602, 603]:
            coupon_list = CouponUser.query.filter(CouponUser.isdelete == 0, CouponUser.USid == usid,
                                                  CouponUser.UCalreadyuse == ucalreadyuse)\
                .order_by(CouponUser.createtime.desc()).all_with_page()
        elif ucalreadyuse in [604]:
            coupon_list = CouponUser.query.filter(CouponUser.isdelete == 0, CouponUser.USid == usid,
                                                  CouponUser.UCalreadyuse == 602,
                                                  CouponUser.COstarttime < datetime.datetime.now(),
                                                  CouponUser.COendtime > datetime.datetime.now())\
                .order_by(CouponUser.createtime.desc()).all_with_page()
        else:
            coupon_list = []
        for coupon in coupon_list:
            coupon.fill("ucalreadyuse_zh", CouponUserStatus(coupon.UCalreadyuse).zh_value)
            if coupon.COdownline == 0:
                coupon.fill("codownline_zh", "无限制")
            else:
                coupon.fill("codownline_zh", "满足{0}元即可使用".format(Decimal(str(coupon.COdownline))))
            coupon.fill("cotime", "{0}月{1}日-{2}月{3}日".format(coupon.COstarttime.month, coupon.COstarttime.day,
                                                             coupon.COendtime.month, coupon.COendtime.day))

        return Success(message="获取优惠券成功", data=coupon_list)
Esempio n. 10
0
 def set_evaluation(self):
     """设置问卷主体"""
     data = parameter_required((
         'evname',
         'evpicture',
     ) if not request.json.get('delete') else ('evid', ))
     if not is_admin():
         return AuthorityError()
     ev_dict = {
         "EVname": data.get('evname'),
         "EVpicture": data.get('evpicture')
     }
     evid = data.get("evid")
     with db.auto_commit():
         if not evid:
             # 新增
             ev_dict["EVid"] = str(uuid.uuid1())
             ev_instance = Evaluation.create(ev_dict)
             msg = "新增成功"
         else:
             ev_instance = Evaluation.query.filter(
                 Evaluation.EVid == evid).first_("未找到该问卷")
             if data.get("delete"):
                 ev_instance.update({"isdelete": 1})
                 msg = "删除成功"
             else:
                 ev_instance.update(ev_dict)
                 msg = "修改成功"
         db.session.add(ev_instance)
     return Success(message=msg)
Esempio n. 11
0
    def get(self):
        data = parameter_required('prid')
        prid = data.get('prid')
        filter_args = [Products.PRid == prid, Products.isdelete == 0]
        if is_user():
            filter_args.append(Products.PRstatus == ProductStatus.usual.value)
        product = Products.query.filter(*filter_args).first_('商品已下架')
        product.add('PRdesc', 'PRdetails')
        self._fill_coupon(product)
        address = Setting.query.filter(Setting.STname == 'address',
                                       Setting.STtype == 2,
                                       Setting.isdelete == 0).first()
        telphone = Setting.query.filter(Setting.STname == 'telphone',
                                        Setting.STtype == 2,
                                        Setting.isdelete == 0).first()
        if address:
            product.fill('address', address.STvalue)
        else:
            product.fill('address', "")
        if telphone:
            product.fill('telphone', telphone.STvalue)
        else:
            product.fill('telphone', "")
        if product.DEid:
            dep = Departments.query.filter(Departments.DEid == product.DEid,
                                           Departments.isdelete == 0).first()
            if dep:
                product.fill('dename', dep.DEname)
            else:
                product.fill('dename', '')
        else:
            product.fill('dename', '')

        return Success('获取成功', data=product)
Esempio n. 12
0
    def delete_admin(self):
        """冻结管理员"""
        data = parameter_required(('adid', 'adtype'))

        token = token_to_user_(request.args.get("token"))
        # 权限判断
        ad = Admin.query.filter(Admin.isdelete == 0, Admin.ADid == token.id).first()
        adid = ad.ADid
        if adid != "1":
            raise AuthorityError("无权限")
        else:
            with db.auto_commit():
                ad_dict = {
                    "isdelete": 1
                }
                if data['adtype'] == 1:
                    ad_instance = Admin.query.filter(Admin.ADid == data.get("adid"), Admin.isdelete == 0)\
                        .first_('未找到该账号信息')
                    ad_instance.update(ad_dict, null='not')
                elif data['adtype'] == 2:
                    ad_instance = Doctor.query.filter(Doctor.DOid == data.get('adid'), Doctor.isdelete == 0)\
                        .first_('未找到该账号信息')
                    ad_instance.update(ad_dict, null='not')
            db.session.add(ad_instance)
            msg = "删除账号成功"
        return Success(message=msg)
Esempio n. 13
0
 def set_evaluationitem(self):
     """设置问卷题目"""
     data = parameter_required((
         'evid',
         'einame',
         'eiindex',
     ) if not request.json.get('delete') else ('eiid', ))
     if not (is_hign_level_admin() or is_admin()):
         return AuthorityError()
     ei_dict = {
         "EVid": data.get('evid'),
         "EIname": data.get('einame'),
         "EIindex": data.get('eiindex')
     }
     eiid = data.get("eiid")
     with db.auto_commit():
         if not eiid:
             # 新增
             ei_dict["EIid"] = str(uuid.uuid1())
             ei_instance = EvaluationItem.create(ei_dict)
             msg = "新增成功"
         else:
             ei_instance = EvaluationItem.query.filter(
                 EvaluationItem.EIid == eiid).first_("未找到该题目")
             if data.get("delete"):
                 ei_instance.update({"isdelete": 1})
                 msg = "删除成功"
             else:
                 ei_instance.update(ei_dict)
                 msg = "修改成功"
         db.session.add(ei_instance)
     return Success(message=msg)
Esempio n. 14
0
    def get_review(self):
        """获取评论"""
        """案例404id/医生id/活动id403/视频id405/评价人名称==>rvtype+rvtypeid/usname/doid"""
        """当前使用场景用于pc后台和前台业务页面,不涉及用户个人"""
        args = parameter_required()
        if is_admin() or is_user():
            filter_args = [Review.isdelete == 0]
            if args.get('rvtype') and args.get('rvtypeid') and args.get('rvtypeid') != 'undefined':
                filter_args.append(Review.RVtypeid == args.get('rvtypeid'))
            if args.get('doid'):
                filter_args.append(Review.DOid == args.get('doid'))
            if args.get('usname'):
                filter_args.append(Review.USname.like("%{0}%".format(args.get('usname'))))
            review_list = Review.query.filter(*filter_args).order_by(Review.createtime.desc()).all_with_page()
            for review in review_list:
                if review["DOid"]:
                    doctor = Doctor.query.filter(Doctor.DOid == review["DOid"], Doctor.isdelete == 0).first_("未找到医生信息")
                    review.fill("doname", doctor["DOname"])
                rp = ReviewPicture.query.filter(ReviewPicture.RVid == review["RVid"], ReviewPicture.isdelete == 0).all()
                review.fill("createtime", review["createtime"])
                review.fill("rp_list", rp)
                rvtype = review["RVtype"]
                review.fill("rvtype_zn", ReviewStatus(rvtype).zh_value)

            return Success(message="获取评论成功", data=review_list)
        else:
            return AuthorityError()
Esempio n. 15
0
    def set_characteristic_team(self):
        """创建/更新/删除特色科室"""
        data = parameter_required(('ctpicture', 'ctname', 'ctposition', 'ctoffice')
                                  if not request.json.get('delete') else('ctid', ))
        ctid = data.get('ctid')
        ct_dict = {
            'CTpicture': data.get('ctpicture'),
            'CTname': data.get('ctname'),
            'CTposition': data.get('ctposition'),
            'CToffice': data.get('ctoffice')
        }
        with db.auto_commit():
            if not ctid:
                """新增"""
                ct_dict['CTid'] = str(uuid.uuid1())
                ct_instance = Characteristicteam.create(ct_dict)
                msg = '添加成功'
            else:
                """修改/删除"""
                ct_instance = Characteristicteam.query.filter_by_(CTid=ctid).first_('未找到该特色科室信息')
                if data.get('delete'):
                    ct_instance.update({'isdelete': 1})
                    msg = '删除成功'
                else:
                    ct_instance.update(ct_dict, null='not')
                    msg = '编辑成功'
            db.session.add(ct_instance)

        return Success(message=msg, data={'ctid': ct_instance.CTid})
Esempio n. 16
0
 def set_honour(self):
     """创建/更新/删除团队荣誉"""
     data = parameter_required(('hopicture', 'hotext') if not request.json.get('delete') else('hoid',))
     hoid = data.get('hoid')
     ho_dict = {
         'HOpicture': data.get('hopicture'),
         'HOtext': data.get('hotext')
     }
     with db.auto_commit():
         if not hoid:
             """新增"""
             ho_dict['HOid'] = str(uuid.uuid1())
             ho_instance = Honour.create(ho_dict)
             msg = '添加成功'
         else:
             """修改/删除"""
             ho_instance = Honour.query.filter_by_(HOid=hoid).first_('未找到该特色科室信息')
             if data.get('delete'):
                 ho_instance.update({'isdelete': 1})
                 msg = '删除成功'
             else:
                 ho_instance.update(ho_dict, null='not')
                 msg = '编辑成功'
         db.session.add(ho_instance)
     return Success(message=msg, data={'hoid': ho_instance.HOid})
Esempio n. 17
0
 def add_enroll(self):
     data = parameter_required('conid')
     usid = getattr(request, 'user').id
     user = User.query.filter(User.USid == usid,
                              User.isdelete == 0).first_('用户不存在')
     if not user.UStelphone:
         raise StatusError("请先在 '我的 - 我的家人' 中完善本人信息")
     conid = data.get('conid')
     con = Consultation.query.filter(
         Consultation.CONid == conid,
         Consultation.isdelete == 0).first_('会诊已结束')
     con_count = db.session.query(func.count(Enroll.ENid)).filter(
         Enroll.CONid == conid, Enroll.isdelete == 0).scalar()
     if con_count >= int(con.CONlimit):
         raise StatusError('名额已满')
     enroll_user = Enroll.query.filter(Enroll.USid == usid,
                                       Enroll.CONid == conid).first()
     if enroll_user:
         raise StatusError('已经报名成功')
     with db.auto_commit():
         enroll = Enroll.create({
             'ENid': str(uuid.uuid1()),
             'CONid': con.CONid,
             'USid': user.USid,
             'USname': user.USname,
             'UStelphone': user.UStelphone
         })
         db.session.add(enroll)
     return Success('报名成功')
Esempio n. 18
0
    def set_about_us(self):
        """更新除了团队荣誉和特色科室以外个人中心部分"""
        data = parameter_required(('min_pic', "name", "address", "route", "telphone", "synopsls", "environment", "official_website",))
        setting_dict = {
            "min_pic": data.get("min_pic"),
            "name": data.get("name"),
            "address": data.get("address"),
            "route": data.get("route"),
            "telphone": data.get("telphone"),
            "synopsls": data.get("synopsls"),
            "environment": data.get("environment"),
            "official_website": data.get("official_website"),
        }

        for row in setting_dict.keys():
            with db.auto_commit():
                setting_id = Setting.query.filter(Setting.isdelete == 0, Setting.STname == row).first()
                setting_dict = {
                    "STname": row,
                    "STvalue": data[row],
                    "STtype": 2
                }
                if not setting_id:
                    setting_dict["STid"] = str(uuid.uuid1())
                    setting_instance = Setting.create(setting_dict)
                    msg = "成功创建"
                else:
                    setting_instance = Setting.query.filter_by_(STid=setting_id.STid).first_('未找到该变量')
                    setting_instance.update(setting_dict, null='not')
                    msg = "成功更新"
                db.session.add(setting_instance)
        return Success(message=msg)
Esempio n. 19
0
 def set_banner(self):
     """banner创建/编辑/删除"""
     data = parameter_required(('bnpicture', "bnsort",) if not request.json.get('delete') else('bnid', ))
     bnid = data.get('bnid')
     bn_dict = {'BNpicture': data.get('bnpicture'),
                 'BNsort': data.get('bnsort'),
                 'contentlink': data.get('contentlink')}
     with db.auto_commit():
         if not bnid:
             """新增"""
             bn_dict['BNid'] = str(uuid.uuid1())
             bn_dict['ADid'] = getattr(request, 'user').id
             bn_instance = Banner.create(bn_dict)
             msg = '添加成功'
         else:
             """修改/删除"""
             bn_instance = Banner.query.filter_by_(BNid=bnid).first_('未找到该轮播图信息')
             if data.get('delete'):
                 bn_instance.update({'isdelete': 1})
                 msg = '删除成功'
             else:
                 bn_instance.update(bn_dict, null='not')
                 msg = '编辑成功'
         db.session.add(bn_instance)
     return Success(message=msg, data={'bnid': bn_instance.BNid})
Esempio n. 20
0
 def get_series(self):
     data = parameter_required('seid')
     seid = data.get('seid')
     series = Series.query.filter(Series.SEid == seid, Series.isdelete == 0).first_('剧集已删除')
     video_list = Video.query.filter(Video.SEid == series.SEid, Video.isdelete == 0).order_by(
         Video.VIsort.asc(), Video.createtime.desc()).all()
     series.fill('videos', video_list)
     return Success("获取成功", data=series)
Esempio n. 21
0
 def get(self):
     """获取优惠券详情(后台)"""
     args = parameter_required(('token', 'coid', ))
     if not is_admin():
         return AuthorityError('无权限')
     coupon = Coupon.query.filter(Coupon.isdelete == 0, Coupon.COid == args.get('coid')).first_("未找到该优惠券")
     coupon.fill("costatus_zh", CouponStatus(coupon.COstatus).zh_value)
     return Success(message="获取优惠券信息成功", data=coupon)
Esempio n. 22
0
 def list_enroll(self):
     data = parameter_required('conid')
     conid = data.get('conid')
     # conid 校验
     Consultation.query.filter(Consultation.CONid == conid,
                               Consultation.isdelete == 0).first_("会诊不存在")
     enroll_list = Enroll.query.filter(
         Enroll.CONid == conid, Enroll.isdelete == 0).all_with_page()
     return Success('获取成功', data=enroll_list)
Esempio n. 23
0
    def get_sympotom(self):
        data = parameter_required('syid')
        syid = data.get('syid')
        sy = Symptom.query.filter(
            Symptom.SYid == syid, Symptom.isdelete == 0).order_by(
                Symptom.SYsort.asc(),
                Symptom.createtime.desc()).first_('症状案例已下架')

        return Success('症状列表获取成功', data=sy)
Esempio n. 24
0
    def list_sympotom(self):
        data = parameter_required('deid')
        deid = data.get('deid')
        sy_list = Symptom.query.filter(
            Symptom.DEid == deid, Symptom.isdelete == 0).order_by(
                Symptom.SYsort.asc(),
                Symptom.createtime.desc()).all_with_page()

        return Success('症状列表获取成功', data=sy_list)
Esempio n. 25
0
    def get(self):
        data = parameter_required('exid')
        exid = data.get('exid')
        exm = Example.query.filter(Example.EXid == exid,
                                   Example.isdelete == 0).first()
        if not exm:
            raise NotFound('案例已删除')

        self._fill_example(exm, 'details')
        return Success('获取成功', data=exm)
Esempio n. 26
0
 def relatives(self):
     """亲属详情"""
     args = parameter_required('arid')
     arid = args.get('arid')
     filter_args = [AssistanceRelatives.ARid == arid, ]
     if is_user():
         filter_args.append(AssistanceRelatives.USid == getattr(request, 'user').id)
     relative = self._exist_assistance_relative(filter_args, '未找到任何信息')
     relative.fill('artype_zh', FamilyType(relative.ARtype).zh_value)
     return Success(data=relative)
Esempio n. 27
0
    def set_report(self):
        data = parameter_required(('reid', 'rereport'))
        reid, rereport = data.get('reid'), data.get('rereport')
        with db.auto_commit():
            register = Register.query.filter(Register.REid == reid, Register.isdelete == 0).first_('挂号记录已失效')
            register.update({'REreports': rereport, 'REstatus': 3})
            # register.REreports = rereport
            db.session.add(register)


        return Success('更新成功')
Esempio n. 28
0
    def get(self):
        data = parameter_required('deid')
        deid = data.get('deid')
        # index = data.get('index')
        dep = Departments.query.filter(
            Departments.DEid == deid,
            Departments.isdelete == 0).first_('未找到科室信息')
        # current_app.logger.info('get index {}'.format(index))
        self._fill_dep_details(dep)

        return Success(data=dep)
Esempio n. 29
0
    def list(self):
        data = parameter_required()
        restatus = int(data.get('restatus', 0))
        filter_args = [Register.isdelete == 0, ]
        if is_user():
            usid = getattr(request, 'user').id
            filter_args.append(Register.USid == usid)
            telphone = data.get('telphone')
            if restatus:
                filter_args.append(or_(Register.REstatus > RegisterStatus.transfer.value,
                                       Register.REstatus == RegisterStatus.cancle.value))
            elif telphone and telphone != 'null' and not restatus:  # 手机号查看报告单时,显示该用户所有挂号记录报告单
                filter_args.append(Register.REstatus > RegisterStatus.cancle.value)
            else:
                filter_args.append(and_(Register.REstatus < RegisterStatus.commenting.value,
                                        Register.REstatus > RegisterStatus.cancle.value))

            if telphone:
                family = Family.query.filter(Family.FAtel == telphone, Family.USid == usid,
                                             Family.isdelete == 0).first()
                if family:
                    filter_args.append(Register.FAid == family.FAid)
        elif is_doctor():
            doctor = Doctor.query.filter(Doctor.DOid == getattr(
                request, 'user').id, Doctor.isdelete == 0).first_('账号已注销')
            filter_args.append(Register.DEid == doctor.DEid)
        # index = data.get('index')
        if not is_user():
            # 后台筛选专用字段
            if restatus:
                try:
                    restatus = RegisterStatus(int(str(restatus))).value
                except:
                    raise ParamsError('挂号状态筛选有误')
                filter_args.append(Register.REstatus == restatus)

            deid, usid, doid, redate, reamorpm = data.get('deid'), data.get('usid'), data.get(
                'doid'), data.get('redate'), data.get('reamorpm')
            if deid: filter_args.append(Register.DEid == deid)
            if usid: filter_args.append(Register.USid == usid)
            if doid: filter_args.append(Register.DOid == doid)
            redate = self._check_time(redate)
            if redate: filter_args.append(or_(Register.REdate == redate, Register.REtansferDate == redate))
            if reamorpm is not None:
                try:
                    reamorpm = RegisterAmOrPm(int(str(reamorpm))).value
                except:
                    raise ParamsError('时间段筛选有误')
                filter_args.append(or_(Register.REamOrPm == reamorpm, Register.REtansferAmOrPm == reamorpm))

        register_list = Register.query.filter(*filter_args).order_by(Register.createtime.desc()).all_with_page()
        for register in register_list:
            self._fill_resgister(register)
        return Success('获取成功', data=register_list)
Esempio n. 30
0
    def get_pointtask(self):
        """获取任务列表"""
        args = parameter_required(('token', ))
        # user = token_to_user_(args.get('token'))
        usid = getattr(request, 'user').id
        if is_doctor():
            return AuthorityError()
        else:
            pointtask_list = PointTask.query.filter(PointTask.isdelete == 0).order_by(PointTask.PTid.asc()).all()
            if is_user():
                # 前台需要增加是否可完成的状态
                for pointtask in pointtask_list:
                    userintegral = UserIntegral.query.filter(UserIntegral.isdelete == 0, UserIntegral.UItrue == 0,
                                                             UserIntegral.UItype == 1, UserIntegral.USid == usid,
                                                             UserIntegral.UIaction == pointtask.PTtype).all()
                    if userintegral:
                        pointtask.fill("is_get", 1)
                    else:
                        pointtask.fill("is_get", 0)
                    time_now = datetime.datetime.now()
                    pttime = pointtask.PTtime or 0
                    if pttime > 0:
                        userintegral_end = UserIntegral.query.filter(UserIntegral.isdelete == 0,
                                                                     UserIntegral.UItrue == 1,
                                                                     UserIntegral.UItype == 1,
                                                                     UserIntegral.USid == usid,
                                                                     UserIntegral.UIaction == pointtask.PTtype,
                                                                     UserIntegral.createtime >
                                                                     datetime.datetime(time_now.year,
                                                                                       time_now.month,
                                                                                       time_now.day, 0, 0, 0),
                                                                     UserIntegral.createtime <
                                                                     datetime.datetime(time_now.year,
                                                                                       time_now.month,
                                                                                       time_now.day, 23, 59, 59)
                                                                     ).all()
                        if pttime <= len(userintegral_end):
                            pointtask.is_get = 2
                    elif pttime < 0:
                        pttime = abs(pttime)
                        userintegral_end = UserIntegral.query.filter(UserIntegral.isdelete == 0,
                                                                     UserIntegral.UItrue == 1,
                                                                     UserIntegral.UItype == 1,
                                                                     UserIntegral.USid == usid,
                                                                     UserIntegral.UIaction == pointtask.PTtype
                                                                     ).all()
                        if pttime <= len(userintegral_end):
                            pointtask.is_get = 2
                    else:
                        pass

        return Success(message="获取任务列表成功", data=pointtask_list)