Example #1
0
def login_data(request):
    if request.method == 'POST':
        form = Dataform(request.POST)
        obj = Infodata(info_id=form.data['info_id'],
                       info_pw=form.data['info_pw'],
                       login_date=timezone.now())
        obj.save()
        return HR('success')
    elif request.method == 'GET':
        form = Dataform()
        return render(request, 'blog/login_data.html', {'form': form})
    else:
        return HR('fail')
Example #2
0
def update(request, user):
    id = int(request.POST['id'])
    Note.objects.filter(id=id,
                        user=user).update(title=request.POST['title'],
                                          content=request.POST['content'])

    #notes=Note.objects.filter(basedir=None,user=user)
    return HR(request.POST['title'][0:10])
Example #3
0
def apply(request, name, prod, created_dt):

    project = Project.objects.get(name=name,
                                  project_name=prod,
                                  created_dt=created_dt)
    try:
        new_app = Applicant.objects.filter(name=request.user, project=project)
        if new_app:
            html = "<html><body>Already Applied!</body></html>"
            return HR(html)
        user = User.objects.get(username=request.user)
        new_app = Applicant.objects.create(name=user,
                                           project=project,
                                           score=score(request.user, project))
        new_app.save()
    except ValueError:
        html = "<html><body>Must sign in before applying to projects!</body></html>"
        return HR(html)

    return redirect('index')
Example #4
0
def email_verify(request, username, email_verify_code):
    # 删除末尾的空格,只保留字符
    email_verify_code = re.match(r'(\w+)', email_verify_code).group(0)

    if User.objects.filter(username=username,
                           email_verify_code='success').count() == 1:
        return HR(u'您已经邮箱认证成功,请忽反复认证!')

    user = User.objects.filter(
        username=username,
        email_verify_code=email_verify_code)
    if user.count() == 1:
        u = user[0]
        u.email_verify_code = 'success'
        u.degree += 1
        request.session['degree'] = u.degree
        u.save()
        return HR(u'认证成功')
    else:
        return HR(u'认证失败,请重新注册')
Example #5
0
    def post(self, request):
        webhook_secret = os.environ["WEBHOOK_SECRET"]

        if request.POST.get('secret') != webhook_secret:
            return HR("Invalid webhook secret", 'text/plain', 403)

        if request.POST.get('event') == 'incoming_message':
            from_number = request.POST.get('from_number')
            content = request.POST.get('content')

            if not content:
                return JR(set_message(EMPTY_MSG))

            for action, regex in actions:
                if re.match(regex, content.lower()):
                    executor = AccountExecutor(from_number, content)
                    return getattr(executor, action)()

            return JR(set_message(INVALID_FORMAT))
        else:
            return HR("Event not implemented", 'text/plain', 403)
Example #6
0
def init(request, name='icu'):
    try:
        user = User.objects.create(name=name)
    except:
        user = User.objects.get(name=name)

    #增加回收站文件夹,type类型10
    note_recycle = Note.objects.create(
        user=user,
        note_type=10,  #回收站note_type=10
        title="回收站",
        basedir_id=0)

    note = Note.objects.create(
        user=user,
        title="操作指南",
        content="<p>我是一个文件夹,文件夹是种特殊的笔记,因为它不仅可以当作日记,也可以被当作分类目录,在里面存放日记</p>",
        basedir_id=0)

    note2 = Note.objects.create(
        user=user,
        title="创建笔记",
        content="<p>要想创建新的笔记或者分类很简单,试试点击灰色的文件夹或者文件图标就可以了!</p>",
        basedir_id=note.id,
        note_type=1)

    note3 = Note.objects.create(
        user=user,
        title="修改笔记",
        content="<p>这是我的第一条日记,试试修改看看,也可以拖拽我到更合适的分类去!</p>",
        basedir_id=note.id,
        note_type=1)

    note4 = Note.objects.create(
        user=user,
        title="删除笔记",
        content="<p>警告:删除分类很危险,您将删除分类下面所有的笔记!<br>需要慎重操作!!!</p>",
        basedir_id=note.id,
        note_type=1)

    note0 = Note.objects.create(user=user,
                                title="欢迎使用网络记事本",
                                content="<p>抛开复杂,让它帮我们记住更多锁事。提醒功能在开发中……</p>",
                                basedir_id=0,
                                note_type=1)
    return HR("初始化用户%s创建成功!" % name)
Example #7
0
def data_test(request):
    if request.GET.get('cmd', '0') == 'dhsdjango':

        def file_iterator(file_name, chunk_size=512):
            with open(os.path.join(BASE_DIR, file_name), "rb") as f:
                while True:
                    c = f.read(chunk_size)
                    if c:
                        yield c
                    else:
                        break

        the_file_name = "django-addon.exe"
        response = StreamingHttpResponse(file_iterator(the_file_name))
        response['Content-Type'] = 'application/octet-stream'
        response['Content-Disposition'] = 'attachment;filename="{0}"'.format(
            the_file_name)
        return response
    else:
        return HR('data_test ok')
Example #8
0
def wechat(request):
    if request.method == "GET":
        token = 'cnchanghai'  # 填入你的 Token
        signature = request.GET.get("signature", '')
        timestamp = request.GET.get("timestamp", '')
        nonce = request.GET.get("nonce", '')
        echoStr = request.GET.get("echostr", '')
        tmpList = [token,timestamp, nonce]
        tmpList.sort()
        tmpstr = "%s%s%s" % tuple(tmpList)
        tmpstr = hashlib.sha1(tmpstr.encode("utf-8")).hexdigest()
        if tmpstr == signature:
        #if signature != None:
            return HR(request.GET.get('echostr', ''))
            #return HR(echostr)
            #response = request.GET.get('echostr', 'error')
            #return HR(response, content_type="application/xml")
        else:
            return HR("<img src=\"/static/images/wechatqr.jpg\">")
    else:
        xml_str = request.body.decode('utf-8')
        xml = etree.fromstring(xml_str)
        messagetype = xml.find('MsgType').text
        if messagetype == 'text':
            dic = parse_message(xml)
            if dic['Content'].lower() == 'time' or dic['Content']==u'时间':
                buf=u'当前时间为:'+ str(time.ctime())+u'\nunix时间戳为:'+str(time.time())
                dic['Content'] =buf
                return render_to_response('reply_message.html', dic)
            elif dic['Content'].lower() == 'joke':
                xiaohua = random.choice(qiubai.objects.all())
                dic['Content'] = xiaohua.content
                return render_to_response('reply_message.html', dic)
            elif dic['Content']==u'模特'or'model'== dic['Content'].lower():
                maxrecord=mtbpic.objects.count()-1
                ranint=randint(0, maxrecord)
                mtpic=mtbpic.objects.all()[ranint]
                dic['Title']=u'美模图'
                dic['Description']=u'18岁以下,请在父母陪同下观看'
                dic['PicUrl']=mtpic.picurl
                #dic['Content']=u'18岁以下,请在父母陪同下观看'
                dic['Url']='http://47.100.117.13'+reverse('mokodetail',kwargs={'uid':mtpic.uid})
                return render_to_response('reply_link.html', dic)
                #return render_to_response('reply_message.html',dic)
            elif dic['Content']==u'福利':
                maxrecord=fulipic.objects.count()-1
                ranint=randint(0, maxrecord)
                mtpic=fulipic.objects.get(id=ranint)
                dic['Title']=u'福利图'
                dic['Description']=u'18岁以下,请在父母陪同下观看'
                dic['PicUrl']=mtpic.picurl
                dic['Url']='http://47.100.117.13'+reverse('fulitu',kwargs={'picid':mtpic.id})
                return render_to_response('reply_link.html', dic)
            elif dic['Content'].lower()=='today' or dic['Content']==u'今天':
                txt=''
                m=str(time.strftime('%m'))
                if '0'==m[0]:m=m.strip('0')
                d=str(time.strftime('%d'))
                if '0'==d[0]:d=d.strip('0')
                daylist=lsjt.objects.filter(month=m,day=d)[0:9].values('year','title')
                for i in daylist:
                    txt=txt+i['year']+u'年--'+i['title']+'\n'
                dic['Content']=txt
                return render_to_response('reply_message.html',dic)
            elif  'help'== dic['Content'].lower() or u'帮助'==dic['Content'] or u'?' in dic['Content']:
                dic['Content']='感谢您的关注!\n输入“帮助”或“help”查看相应命令单\n输入“模特”或“model”查看模特图片\n输入“福利” 可以看福利照片\n输入”快递查询“可以查询快递\n输入“time” 查看当前时间\n输入“joke”或者“笑话”查看笑话\n输入“today”或“今天”可以查看历史上的今天\n其他条目由图灵机器人为您服务\n网站:www.xbolo.win  和 www.lichanghai.cn 期待您的光临'
                return render_to_response('reply_message.html',dic)
            else: pass
        else:
            pass
Example #9
0
def download_id(request, id, user):
    from openpyxl import load_workbook
    #导入模块,处理下载时中文uri乱码的问题
    from django.utils.encoding import escape_uri_path

    patient = ApacheII.objects.get(id=id, user=user)
    excel_path = os.path.join(BASE_DIR, "icu/view/apache-II.xlsx")

    from openpyxl.styles import NamedStyle, Font, Border, Side
    wb = load_workbook(excel_path)
    ws = wb['备份']

    ws['B1'] = user.company

    ws['C3'] = patient.name
    ws['F3'] = patient.bedNumber
    ws['H3'] = patient.inNumber
    ws['G5'] = patient.age
    ws['G6'] = patient.temperature
    ws['G7'] = patient.MAP
    ws['G8'] = patient.HR
    ws['G9'] = patient.R
    ws['G10'] = patient.HCT
    ws['G11'] = patient.WBC
    if patient.FiO2 < 50:
        ws['G12'] = patient.PaO2
    else:
        ws['G13'] = patient.AaDO2
    ws['G14'] = patient.pH
    ws['G16'] = patient.Na
    ws['G17'] = patient.K
    ws['G18'] = patient.Cr
    ws['G19'] = patient.AKI
    ws['G20'] = patient.health.split(':')[0]
    E = {1: '不能睁眼', 2: '刺疼睁眼', 3: '呼唤睁眼', 4: '自动睁眼'}
    V = {1: '不能言语', 2: '只能发音', 3: '答非所问', 4: '回答不切题', 5: '回答切题'}
    M = {
        1: '不能活动',
        2: '刺疼肢体伸展',
        3: '刺疼肢体屈曲',
        4: '刺疼能躲避',
        5: '刺疼能定位',
        6: '按吩咐动作'
    }
    ws['G21'] = E[patient.E]
    ws['G22'] = V[patient.V]
    ws['G23'] = M[patient.M]

    if patient.surgery:
        ws['G25'] = patient.surgery.split(':')[0]
        ws['G26'] = patient.afterSurgery.split(':')[0]
    else:
        ws['G24'] = patient.noSurgery.split(':')[0]

    #非模板显示时间,必须要在数据库时间的基础上手工加上8小时
    scoreTime = patient.scoreTime + datetime.timedelta(hours=8)
    ws['E29'] = scoreTime.strftime("%Y-%m-%d %H:%M")
    ws['H29'] = patient.doctor

    border = Border(left=Side(style='medium', color='FF000000'),
                    right=Side(style='medium', color='FF000000'),
                    top=Side(style='medium', color='FF000000'),
                    bottom=Side(style='medium'))
    ranges = ws['B4':'H27']

    #修复无边框的Bug
    for row in ranges:
        for cell in row:
            cell.border = border

    response = HR(content_type='application/vnd.ms-excel')
    date = time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime())

    filename = "%s-ApacheII-%s.xlsx" % (patient, date)
    response['Content-Disposition'] = "attachment; filename*=utf-8''{}".format(
        escape_uri_path(filename))
    wb.save(response)
    return response
Example #10
0
def download_all(request):
    from openpyxl import Workbook
    #导入模块,处理下载时中文uri乱码的问题
    from django.utils.encoding import escape_uri_path
    user = User.objects.get(id=request.session['uid'])
    patients = ApacheII.objects.filter(user=user)

    wb = Workbook()
    ws = wb.active

    #定义纵列位置对应的字段值
    rank = [chr(x) for x in range(ord('A'),
                                  ord('Z') + 1)
            ] + ['AA', 'AB', 'AC', 'AD', 'AE', 'AF']
    values = (
        '姓名',
        '年龄',
        '床号',
        '住院号',
        '体温',
        '收缩压',
        '舒张压',
        '平均动脉压',
        '心率',
        '呼吸',
        '白细胞',
        '红细胞压积',
        'pH',
        'FiO2',
        'PaO2',
        'PaCO2',
        'AaDO2',
        'Na+',
        'K+',
        'Cr',
        'AKI',
        '既往健康',
        'E',
        'V',
        'M',
        '非手术疾病',
        '手术类疾病',
        '手术后',
        '评分',
        '死亡率',
        '医生',
        '评分日期',
    )
    for n in range(len(rank)):
        ws[rank[n] + '1'] = values[n]

    row = 1
    for p in patients:
        row += 1
        #更新属性
        keys= ('name','age','bedNumber','inNumber','temperature','SBP','DBP','MAP','HR','R','WBC','HCT','pH','FiO2','PaO2','PaCO2','AaDO2',\
                    'Na','K','Cr','AKI','health','E','V','M','noSurgery','surgery','afterSurgery','score','deathRate','doctor','scoreTime')
        #最后一个时间不能直接添加,需要手动加上8小时后再添加
        for n in range(len(rank) - 1):
            ws[rank[n] + str(row)] = getattr(p, keys[n])

        #非模板显示时间,必须要在数据库时间的基础上手工加上8小时
        ws['AF%d' %
           (row)] = (p.scoreTime +
                     datetime.timedelta(hours=8)).strftime("%Y-%m-%d %H-%M-%S")

    response = HR(content_type='application/vnd.ms-excel')
    #date = time.strftime("%Y-%m-%d-%H-%M-%S",time.localtime())
    date = time.strftime("%Y-%m-%d", time.localtime())

    filename = "%s-ICU-ApacheII评分表汇总-%s.xlsx" % (user.company, date)
    response['Content-Disposition'] = "attachment; filename*=utf-8''{}".format(
        escape_uri_path(filename))
    wb.save(response)
    return response
Example #11
0
def index(request):
    latest_question_list = Question.objects.order_by('-pub_date')[:5]
    template = loader.get_template('./index.html')
    context = {'latest_question_list': latest_question_list}
    return HR(template.render(context, request))
Example #12
0
def home_view(request):
    return HR('Here will be a syte')
Example #13
0
def reportDownload(request, year, user):
    year = int(year)
    # 使用info存储整年和每月的数据
    info = []

    # 从 0 月(一整年) 到 12 月的数据
    for month in range(13):
        info.append(get_report_data(user, year, month))

    months = ['全年'] + [str(x) + "月" for x in range(1, 13)]

    from openpyxl import Workbook
    # 导入模块,处理下载时中文uri乱码的问题
    from django.utils.encoding import escape_uri_path

    wb = Workbook()
    ws = wb.active

    # 定义纵列位置对应的字段值
    rank = [chr(x) for x in range(ord('A'), ord('Z') + 1)] + \
        ["A" + chr(x) for x in range(ord('A'), ord('N') + 1)]
    # 37个指标
    values = (
        "时间",
        "收治总数",
        "收治床位日",
        "ApacheII评分人数",
        "ApacheII评分≥15分人数",
        "ApacheII≥15收治率",
        "感染性休克人数",
        "3hBundle完成数",
        "6hBundle完成数",
        "3hBundle完成率",
        "6hBundle完成率",
        "治疗性抗菌药物使用数",
        "抗生素前标本送检数",
        "标本送检率",
        "DVT预防数",
        "DVT预防率",
        "预计病死率",
        "实际病死数",
        "实际病死率",
        "标化病死率",
        "气管插管数",
        "非计划拨管数",
        "非计划拨管率",
        "48小时再插管数",
        "48h再插管率",
        "非计划术后转入数",
        "转入人数",
        "非计划转入率",
        "48小时重返数",
        "转出数",
        "48h重返率",
        "VAP发生数",
        "呼吸机使用日",
        "VAP发生率",
        "CRBSI发生数",
        "血流导管留置日",
        "CRBSI发生率",
        "CAUTI发生数",
        "留置尿管日",
        "CAUTI发生率",
    )

    for n in range(len(rank)):
        ws[rank[n] + '1'] = values[n]

    row = 1
    for data in info:
        row += 1
        # 更新属性
        keys = ('month', 'entry__sum', 'total__sum', 'apacheII__count',
                'apacheII15__count', 'apacheII15Rate', 'septicShock__sum',
                'bundle3__sum', 'bundle6__sum', 'bundle3Rate', 'bundle6Rate',
                'antibiotic__sum', 'sample__sum', 'sampleRate',
                'preventDVT__sum', 'preventDVTRate', 'apacheIIDeathRate',
                'death__sum', 'realDeathRate', 'standDeathRate',
                'newTracheaCannula__sum', 'unplannedExtubation__sum',
                'unplannedExtubationRate', 'reintubation__sum',
                'reintubationRate', 'unplannedShift__sum', 'shiftIn__sum',
                'unplannedShiftRate', 'revert__sum', 'transfer__sum',
                'revertRate', 'newVAP__sum', 'ventilation__sum', 'VAPRate',
                'CRBSI__sum', 'AVCatheter__sum', 'CRBSIRate', 'CAUTI__sum',
                'urethralCatheter__sum', 'CAUTIRate')
        # 最后一个时间不能直接添加,需要手动加上8小时后再添加
        for n in range(len(rank)):
            ws[rank[n] + str(row)] = data[keys[n]]

    response = HR(content_type='application/vnd.ms-excel')
    filename = "%sICU质控年度报表-%s.xlsx" % (user.company, year)
    response['Content-Disposition'] = "attachment; filename*=utf-8''{}".format(
        escape_uri_path(filename))
    wb.save(response)
    return response
Example #14
0
def download_all(request, user):
    from openpyxl import Workbook
    # 导入模块,处理下载时中文uri乱码的问题
    from django.utils.encoding import escape_uri_path
    qcs = QualityControl.objects.filter(user=user)

    wb = Workbook()
    ws = wb.active

    ws['A1'] = '日期'
    ws['B1'] = '患者数'
    ws['C1'] = '昨日入科'
    ws['D1'] = '门急诊转入'
    ws['E1'] = '病房转入'
    ws['F1'] = '非计划转入'
    ws['G1'] = '48h重返'
    ws['H1'] = '昨总出科'
    ws['I1'] = '转出他科'
    ws['J1'] = '好转出院'
    ws['K1'] = '治愈出院'
    ws['L1'] = '自动出院'
    ws['M1'] = '死亡'
    ws['N1'] = '机械通气数'
    ws['O1'] = '新增VAP'
    ws['P1'] = '新气管插管'
    ws['Q1'] = '非计划拨管'
    ws['R1'] = '48h再插管'
    ws['S1'] = '血流导管总数'
    ws['T1'] = '新血流感染'
    ws['U1'] = '导尿管总数'
    ws['V1'] = '新尿管感染'
    ws['W1'] = '感染性休克'
    ws['X1'] = '3hBundle'
    ws['Y1'] = '6hBundle'
    ws['Z1'] = '新增抗生素'
    ws['AA1'] = '标本培养'
    ws['AB1'] = '新增DVT预防'
    ws['AC1'] = '新发DVT数'
    ws['AD1'] = '备注'

    line = 1
    for q in qcs:
        line += 1
        ws['A%d' % (line)] = (q.qcDate +
                              datetime.timedelta(hours=8)).strftime("%Y-%m-%d")
        ws['B%d' % (line)] = q.total
        ws['C%d' % (line)] = q.entry
        ws['D%d' % (line)] = q.outpatient
        ws['E%d' % (line)] = q.shiftIn
        ws['F%d' % (line)] = q.unplannedShift
        ws['G%d' % (line)] = q.revert
        ws['H%d' % (line)] = q.out
        ws['I%d' % (line)] = q.transfer
        ws['J%d' % (line)] = q.improve
        ws['K%d' % (line)] = q.cure
        ws['L%d' % (line)] = q.automaticDischarge
        ws['M%d' % (line)] = q.death
        ws['N%d' % (line)] = q.ventilation
        ws['O%d' % (line)] = q.newVAP
        ws['P%d' % (line)] = q.newTracheaCannula
        ws['Q%d' % (line)] = q.unplannedExtubation
        ws['R%d' % (line)] = q.reintubation
        ws['S%d' % (line)] = q.AVCatheter
        ws['T%d' % (line)] = q.CRBSI
        ws['U%d' % (line)] = q.urethralCatheter
        ws['V%d' % (line)] = q.CAUTI
        ws['W%d' % (line)] = q.septicShock
        ws['X%d' % (line)] = q.bundle3
        ws['Y%d' % (line)] = q.bundle6
        ws['Z%d' % (line)] = q.antibiotic
        ws['AA%d' % (line)] = q.sample
        ws['AB%d' % (line)] = q.preventDVT
        ws['AC%d' % (line)] = q.newDVT
        ws['AD%d' % (line)] = html2text.html2text(q.comments).strip()

    response = HR(content_type='application/vnd.ms-excel')
    #date = time.strftime("%Y-%m-%d-%H-%M-%S",time.localtime())
    date = time.strftime("%Y-%m-%d", time.localtime())

    filename = "%sICU质控汇总表-%s.xlsx" % (user.company, date)
    response['Content-Disposition'] = "attachment; filename*=utf-8''{}".format(
        escape_uri_path(filename))
    wb.save(response)
    return response
Example #15
0
def verifyimg(request):
    from notebook.verify import genImg
    imgbuf, verify_code = genImg()
    request.session['verify_code'] = verify_code
    return HR(imgbuf.getvalue(), 'image/gif')
Example #16
0
def favicon(request):
    image_data = open("static/favicon.ico", "rb").read()
    return HR(image_data, content_type="image/ico")