def labor_other_get_list(request): if 'logged' not in request.session: return {'ok': 0, 'msg': 'Please login.'} else: if request.is_xhr: # is ajax request start = request.params['start'] stop = request.params['stop'] start_date = h.jsdate_to_string(request.params['start_date']) end_date = h.jsdate_to_string(request.params['end_date']) start = int(start) limit = int(stop) - int(start) hospcode = request.params['hospcode'] person = PersonModel(request) labor_other = LaborOtherModel(request) rs = labor_other.get_list(hospcode, start_date, end_date, start, limit) rows = [] if rs: for r in rs: p = person.get_person_detail(r['pid'], hospcode) labor = labor_other.get_labor_detail(r['pid'], r['gravida'], r['hospcode']) obj = { 'cid': p['cid'], 'pid': p['pid'], 'fullname': '%s %s' % (p['name'], p['lname']), 'age': h.count_age(p['birth']), 'birth': h.to_thai_date(p['birth']), 'bdate': h.to_thai_date(r['bdate']), #'bresult': labor['bresult'], #'btype': labor['btype'], 'bhospname': h.get_hospital_name(request, labor['bhosp']), 'bhospcode': labor['bhosp'], 'gravida': r['gravida'], 'hospcode': r['hospcode'], 'hospname': h.get_hospital_name(request, r['hospcode']), 'address': h.get_address_from_catm(request, r['address']['vid']), 'house': r['address']['house'] if 'house' in r['address'] else '00' } rows.append(obj) return {'ok': 1, 'rows': rows} else: return {'ok': 0, 'msg': u'ไม่พบข้อมูล'} else: return {'ok': 0, 'msg': 'Not ajax request.'}
def labor_other_get_list(request): if 'logged' not in request.session: return {'ok': 0, 'msg': 'Please login.'} else: if request.is_xhr: # is ajax request start = request.params['start'] stop = request.params['stop'] start_date = h.jsdate_to_string(request.params['start_date']) end_date = h.jsdate_to_string(request.params['end_date']) start = int(start) limit = int(stop) - int(start) hospcode = request.params['hospcode'] person = PersonModel(request) labor_other = LaborOtherModel(request) rs = labor_other.get_list(hospcode, start_date, end_date, start, limit) rows = [] if rs: for r in rs: p = person.get_person_detail(r['pid'], hospcode) labor = labor_other.get_labor_detail( r['pid'], r['gravida'], r['hospcode']) obj = { 'cid': p['cid'], 'pid': p['pid'], 'fullname': '%s %s' % (p['name'], p['lname']), 'age': h.count_age(p['birth']), 'birth': h.to_thai_date(p['birth']), 'bdate': h.to_thai_date(r['bdate']), #'bresult': labor['bresult'], #'btype': labor['btype'], 'bhospname': h.get_hospital_name(request, labor['bhosp']), 'bhospcode': labor['bhosp'], 'gravida': r['gravida'], 'hospcode': r['hospcode'], 'hospname': h.get_hospital_name(request, r['hospcode']), 'address': h.get_address_from_catm(request, r['address']['vid']), 'house': r['address']['house'] if 'house' in r['address'] else '00' } rows.append(obj) return {'ok': 1, 'rows': rows} else: return {'ok': 0, 'msg': u'ไม่พบข้อมูล'} else: return {'ok': 0, 'msg': 'Not ajax request.'}