def get_list_by_birth(request): if 'logged' not in request.session: return {'ok': 0, 'msg': 'Please login.'} 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 = 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']) limit = int(stop) - int(start) babies = BabiesModel(request) person = PersonModel(request) rs = babies.get_list_by_birth(start_date, end_date, int(start), int(limit)) rows = [] if rs: for r in rs: p = person.get_person_detail(r['pid'], request.session['hospcode']) obj = { 'pid': r['pid'], 'cid': r['cid'], 'hospcode': r['hospcode'], 'gravida': r['gravida'], 'fullname': p['name'] + ' ' + p['lname'], 'cid': p['cid'], 'birth': h.to_thai_date(p['birth']), 'age': h.count_age(p['birth']), 'sex': p['sex'], 'bdate': h.to_thai_date(r['bdate']), 'bplace': r['bplace'], 'bhospcode': r['bhosp'], 'bhospname': h.get_hospital_name(request, r['bhosp']), 'btype': r['btype'], 'bweight': r['bweight'], 'mother': babies.get_mother(r['mpid'], r['hospcode']), 'care': babies.get_count_care(r['pid'], r['hospcode']) } 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_birth(request): if "logged" not in request.session: return {"ok": 0, "msg": "Please login."} 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 = 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"]) limit = int(stop) - int(start) babies = BabiesModel(request) person = PersonModel(request) rs = babies.get_list_by_birth(start_date, end_date, int(start), int(limit)) rows = [] if rs: for r in rs: p = person.get_person_detail(r["pid"], request.session["hospcode"]) obj = { "pid": r["pid"], "cid": r["cid"], "hospcode": r["hospcode"], "gravida": r["gravida"], "fullname": p["name"] + " " + p["lname"], "cid": p["cid"], "birth": h.to_thai_date(p["birth"]), "age": h.count_age(p["birth"]), "sex": p["sex"], "bdate": h.to_thai_date(r["bdate"]), "bplace": r["bplace"], "bhospcode": r["bhosp"], "bhospname": h.get_hospital_name(request, r["bhosp"]), "btype": r["btype"], "bweight": r["bweight"], "mother": babies.get_mother(r["mpid"], r["hospcode"]), "care": babies.get_count_care(r["pid"], r["hospcode"]), } 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_newborn(request): if 'logged' not in request.session: return {'ok': 0, 'msg': 'Please login.'} 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: pid = request.params['pid'] hospcode = request.params['hospcode'] babies = BabiesModel(request) rs = babies.get_newborn(pid, hospcode) if rs: obj = { 'mother': babies.get_mother(rs['mpid'], rs['hospcode']), 'ga': rs['ga'], 'gravida': rs['gravida'], 'bdate': h.to_thai_date(rs['bdate']), 'btime': rs['btime'], 'bhosp_code': rs['bhosp'], 'bhosp_name': h.get_hospital_name(request, rs['bhosp']), 'bplace': rs['bplace'], 'birthno': rs['birthno'], 'btype': rs['btype'], 'bdoctor': rs['bdoctor'], 'bweight': rs['bweight'], 'asphyxia': rs['asphyxia'], 'vitk': rs['vitk'], 'tsh': rs['tsh'], 'tshresult': rs['tshresult'], } return {'ok': 1, 'rows': [obj]} else: return {'ok': 0, 'msg': u'ไม่พบข้อมูล'} else: return {'ok': 0, 'msg': "No token found."} else: return {'ok': 0, 'msg': "No ajax."}
def get_newborn(request): if "logged" not in request.session: return {"ok": 0, "msg": "Please login."} 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: pid = request.params["pid"] hospcode = request.params["hospcode"] babies = BabiesModel(request) rs = babies.get_newborn(pid, hospcode) if rs: obj = { "mother": babies.get_mother(rs["mpid"], rs["hospcode"]), "ga": rs["ga"], "gravida": rs["gravida"], "bdate": h.to_thai_date(rs["bdate"]), "btime": rs["btime"], "bhosp_code": rs["bhosp"], "bhosp_name": h.get_hospital_name(request, rs["bhosp"]), "bplace": rs["bplace"], "birthno": rs["birthno"], "btype": rs["btype"], "bdoctor": rs["bdoctor"], "bweight": rs["bweight"], "asphyxia": rs["asphyxia"], "vitk": rs["vitk"], "tsh": rs["tsh"], "tshresult": rs["tshresult"], } return {"ok": 1, "rows": [obj]} else: return {"ok": 0, "msg": u"ไม่พบข้อมูล"} else: return {"ok": 0, "msg": "No token found."} else: return {"ok": 0, "msg": "No ajax."}