def get_list_total_by_vid(request): if 'logged' not in request.session: return HTTPFound(location='/signin') csrf_token = request.params['csrf_token'] is_token = (csrf_token == unicode(request.session.get_csrf_token())) if is_token: ncdscreen = NCDScreenModel(request) start_date = request.params['start_date'] end_date = request.params['end_date'] start_date = start_date.split('/') end_date = end_date.split('/') vid = request.params['vid'] sy = int(start_date[2]) - 543 ey = int(end_date[2]) - 543 # get date for calculate age yx = ey - 15 x = str(yx) + end_date[1] + end_date[0] #start_date = str(sy) + start_date[1] + start_date[0] #end_date = str(ey) + end_date[1] + end_date[0] hid = ncdscreen.get_hid_from_village(request.session['hospcode'], vid) total = ncdscreen.get_list_total_by_vid(request.session['hospcode'], x, hid) return { 'ok': 1, 'total': total } if total else { 'ok': 0, 'msg': u'ไม่พบข้อมูล' } else: return {'ok': 0, 'msg': 'Not ajax request'}
def get_list_total_by_vid(request): if 'logged' not in request.session: return HTTPFound(location='/signin') csrf_token = request.params['csrf_token'] is_token = (csrf_token == unicode(request.session.get_csrf_token())) if is_token: ncdscreen = NCDScreenModel(request) start_date = request.params['start_date'] end_date = request.params['end_date'] start_date = start_date.split('/') end_date = end_date.split('/') vid = request.params['vid'] sy = int(start_date[2]) - 543 ey = int(end_date[2]) - 543 # get date for calculate age yx = ey - 15 x = str(yx) + end_date[1] + end_date[0] #start_date = str(sy) + start_date[1] + start_date[0] #end_date = str(ey) + end_date[1] + end_date[0] hid = ncdscreen.get_hid_from_village(request.session['hospcode'], vid) total = ncdscreen.get_list_total_by_vid(request.session['hospcode'], x, hid) return {'ok': 1, 'total': total} if total else {'ok': 0, 'msg': u'ไม่พบข้อมูล'} else: return {'ok': 0, 'msg': 'Not ajax request'}
def get_list_by_vid(request): if 'logged' not in request.session: return HTTPFound(location='/signin') else: if request.is_xhr: # is ajax request csrf_token = request.params['csrf_token'] is_token = (csrf_token == unicode(request.session.get_csrf_token())) if is_token: start_date = request.params['start_date'] end_date = request.params['end_date'] vid = request.params['vid'] start_date = start_date.split('/') end_date = end_date.split('/') sy = int(start_date[2]) - 543 ey = int(end_date[2]) - 543 # get date for calculate age yx = ey - 15 x = str(yx) + end_date[1] + end_date[0] start_date = str(sy) + start_date[1] + start_date[0] end_date = str(ey) + end_date[1] + end_date[0] start = request.params['start'] stop = request.params['stop'] limit = int(stop) - int(start) ncdscreen = NCDScreenModel(request) hid = ncdscreen.get_hid_from_village(request.session['hospcode'], vid) rs = ncdscreen.get_list_by_vid(request.session['hospcode'], x, int(start), int(limit), hid) rows = [] if rs: for r in rs: obj = { 'pid': r['pid'], 'cid': r['cid'], 'hospcode': r['hospcode'], 'fullname': r['name'] + ' ' + r['lname'], 'birth': h.to_thai_date(r['birth']), 'age': h.count_age(r['birth']), 'sex': r['sex'], 'typearea': r['typearea'], 'address': h.get_short_address(request, r['hid'], request.session['hospcode']), 'date_serv_th': h.to_thai_date(ncdscreen.get_date_serv(r['hospcode'], r['pid'], start_date, end_date)), 'date_serv': ncdscreen.get_date_serv(r['hospcode'], r['pid'], start_date, end_date) } rows.append(obj) return {'ok': 1, 'rows': rows} else: return {'ok': 0, 'msg': u'ไม่พบข้อมูล'} else: return {'ok': 0, 'msg': 'Token not found.'} else: return {'ok': 0, 'msg': 'Not ajax request.'}
def get_list_by_vid(request): if 'logged' not in request.session: return HTTPFound(location='/signin') else: if request.is_xhr: # is ajax request csrf_token = request.params['csrf_token'] is_token = (csrf_token == unicode( request.session.get_csrf_token())) if is_token: start_date = request.params['start_date'] end_date = request.params['end_date'] vid = request.params['vid'] start_date = start_date.split('/') end_date = end_date.split('/') sy = int(start_date[2]) - 543 ey = int(end_date[2]) - 543 # get date for calculate age yx = ey - 15 x = str(yx) + end_date[1] + end_date[0] start_date = str(sy) + start_date[1] + start_date[0] end_date = str(ey) + end_date[1] + end_date[0] start = request.params['start'] stop = request.params['stop'] limit = int(stop) - int(start) ncdscreen = NCDScreenModel(request) hid = ncdscreen.get_hid_from_village( request.session['hospcode'], vid) rs = ncdscreen.get_list_by_vid(request.session['hospcode'], x, int(start), int(limit), hid) rows = [] if rs: for r in rs: obj = { 'pid': r['pid'], 'cid': r['cid'], 'hospcode': r['hospcode'], 'fullname': r['name'] + ' ' + r['lname'], 'birth': h.to_thai_date(r['birth']), 'age': h.count_age(r['birth']), 'sex': r['sex'], 'typearea': r['typearea'], 'address': h.get_short_address(request, r['hid'], request.session['hospcode']), 'date_serv_th': h.to_thai_date( ncdscreen.get_date_serv( r['hospcode'], r['pid'], start_date, end_date)), 'date_serv': ncdscreen.get_date_serv(r['hospcode'], r['pid'], start_date, end_date) } rows.append(obj) return {'ok': 1, 'rows': rows} else: return {'ok': 0, 'msg': u'ไม่พบข้อมูล'} else: return {'ok': 0, 'msg': 'Token not found.'} else: return {'ok': 0, 'msg': 'Not ajax request.'}