def get_labor(request): if 'logged' not in request.session: return {'ok': 0, 'msg': 'Please login.'} else: if request.is_xhr: csrf_token = request.params['csrf_token'] is_token = (csrf_token == unicode( request.session.get_csrf_token())) if is_token: cid = request.params['cid'] gravida = request.params['gravida'] anc = AncModel(request) person = PersonModel(request) r = anc.get_labor_detail_by_cid(cid, gravida, request.session['hospcode']) p = person.get_person_detail(r['pid'], request.session['hospcode']) if r: obj = { 'pฟืแid': r['pid'], 'cid': p['cid'], 'fullname': p['name'] + ' ' + p['lname'], 'birth': h.to_thai_date(p['birth']), 'edc': h.to_thai_date(r['edc']), 'lmp': h.to_thai_date(r['lmp']), 'bdate': h.to_thai_date(r['bdate']), 'bresultcode': r['bresult'], 'bresultname': h.get_diag_name(request, r['bresult']), 'bplace': r['bplace'], 'bhospcode': r['bhosp'], 'bhospname': h.get_hospital_name(request, r['bhosp']), 'btype': r['btype'], 'bdoctor': r['bdoctor'], 'lborn': r['lborn'], 'sborn': r['sborn'], 'gravida': r['gravida'] } return {'ok': 1, 'rows': [obj]} else: return {'ok': 0, 'msg': u'ไม่พบรายการ'} else: return {'ok': 0, 'msg': 'Not authorized.'} else: return {'ok': 0, 'msg': 'Not Ajax.'}
def get_labor(request): if "logged" not in request.session: return {"ok": 0, "msg": "Please login."} else: if request.is_xhr: csrf_token = request.params["csrf_token"] is_token = csrf_token == unicode(request.session.get_csrf_token()) if is_token: cid = request.params["cid"] gravida = request.params["gravida"] anc = AncModel(request) person = PersonModel(request) r = anc.get_labor_detail_by_cid(cid, gravida, request.session["hospcode"]) p = person.get_person_detail(r["pid"], request.session["hospcode"]) if r: obj = { "pฟืแid": r["pid"], "cid": p["cid"], "fullname": p["name"] + " " + p["lname"], "birth": h.to_thai_date(p["birth"]), "edc": h.to_thai_date(r["edc"]), "lmp": h.to_thai_date(r["lmp"]), "bdate": h.to_thai_date(r["bdate"]), "bresultcode": r["bresult"], "bresultname": h.get_diag_name(request, r["bresult"]), "bplace": r["bplace"], "bhospcode": r["bhosp"], "bhospname": h.get_hospital_name(request, r["bhosp"]), "btype": r["btype"], "bdoctor": r["bdoctor"], "lborn": r["lborn"], "sborn": r["sborn"], "gravida": r["gravida"], } return {"ok": 1, "rows": [obj]} else: return {"ok": 0, "msg": u"ไม่พบรายการ"} else: return {"ok": 0, "msg": "Not authorized."} else: return {"ok": 0, "msg": "Not Ajax."}