예제 #1
0
파일: epidem.py 프로젝트: siteslave/iCare
def get_info(request):
    if 'logged' not in request.session:
        return HTTPFound(location='/signin')
    else:
        if request.is_xhr:
            csrf_token = request.params['csrf_token']
            is_token = (csrf_token == unicode(request.session.get_csrf_token()))

            if is_token:

                hospcode = request.params['hospcode']
                pid = request.params['pid']
                seq = request.params['seq']
                diagcode = request.params['diagcode']

                epidem = EpidemModel(request)
                person = PersonModel(request)

                rs = epidem.get_info(hospcode, pid, seq, diagcode)
                p = person.get_person_detail(pid, hospcode)

                if rs:
                    if p:
                        village = '0%s' % rs['illvillage'] if len(rs['illvillage']) < 2 else rs['illvillage']
                        catm = '%s%s%s%s' % (rs['illchanwat'], rs['illampur'], rs['illtambon'], village)

                        obj = {
                            'an': rs['an'],
                            'cid': rs['cid'],
                            'pid': rs['pid'],
                            'fullname': '%s %s' % (p['name'], p['lname']),
                            'sex': p['sex'],
                            'birth': h.to_thai_date(p['birth']),
                            'age': h.count_age(p['birth']),
                            'code506': '[%s] %s' % (rs['code506'], h.get_code506_name(request, rs['code506'])),
                            'diag': '[%s] %s' % (rs['diagcode'], h.get_diag_name(request, rs['diagcode'])),
                            'date_death': h.to_thai_date(rs['date_death']),
                            'date_serv': h.to_thai_date(rs['date_serv']),
                            'illdate': h.to_thai_date(rs['illdate']),
                            'ill_address': '%s %s' % (rs['illhouse'], h.get_address_from_catm(request, catm)),
                            'latLng': '%s, %s' % (rs['latitude'], rs['longitude']),
                            'ptstatus': rs['ptstatus'],
                            'complication': h.get_complication_name(request, rs['complication']),
                        }
                        return {
                            'ok': 1, 'rows': obj
                        }
                    else:
                        return {
                            'ok': 0, 'msg': u'ไม่พบข้อมูลบุคคล'
                        }
                else:
                    return {'ok': 0, 'msg': u'ไม่พบข้อมูล'}
            else:
                return {'ok': 0, 'msg': 'Invalid token.'}
예제 #2
0
파일: epidem.py 프로젝트: siteslave/iCare
def get_info(request):
    if 'logged' not in request.session:
        return HTTPFound(location='/signin')
    else:
        if request.is_xhr:
            csrf_token = request.params['csrf_token']
            is_token = (csrf_token == unicode(
                request.session.get_csrf_token()))

            if is_token:

                hospcode = request.params['hospcode']
                pid = request.params['pid']
                seq = request.params['seq']
                diagcode = request.params['diagcode']

                epidem = EpidemModel(request)
                person = PersonModel(request)

                rs = epidem.get_info(hospcode, pid, seq, diagcode)
                p = person.get_person_detail(pid, hospcode)

                if rs:
                    if p:
                        village = '0%s' % rs['illvillage'] if len(
                            rs['illvillage']) < 2 else rs['illvillage']
                        catm = '%s%s%s%s' % (rs['illchanwat'], rs['illampur'],
                                             rs['illtambon'], village)

                        obj = {
                            'an':
                            rs['an'],
                            'cid':
                            rs['cid'],
                            'pid':
                            rs['pid'],
                            'fullname':
                            '%s %s' % (p['name'], p['lname']),
                            'sex':
                            p['sex'],
                            'birth':
                            h.to_thai_date(p['birth']),
                            'age':
                            h.count_age(p['birth']),
                            'code506':
                            '[%s] %s' %
                            (rs['code506'],
                             h.get_code506_name(request, rs['code506'])),
                            'diag':
                            '[%s] %s' %
                            (rs['diagcode'],
                             h.get_diag_name(request, rs['diagcode'])),
                            'date_death':
                            h.to_thai_date(rs['date_death']),
                            'date_serv':
                            h.to_thai_date(rs['date_serv']),
                            'illdate':
                            h.to_thai_date(rs['illdate']),
                            'ill_address':
                            '%s %s' % (rs['illhouse'],
                                       h.get_address_from_catm(request, catm)),
                            'latLng':
                            '%s, %s' % (rs['latitude'], rs['longitude']),
                            'ptstatus':
                            rs['ptstatus'],
                            'complication':
                            h.get_complication_name(request,
                                                    rs['complication']),
                        }
                        return {'ok': 1, 'rows': obj}
                    else:
                        return {'ok': 0, 'msg': u'ไม่พบข้อมูลบุคคล'}
                else:
                    return {'ok': 0, 'msg': u'ไม่พบข้อมูล'}
            else:
                return {'ok': 0, 'msg': 'Invalid token.'}