コード例 #1
0
ファイル: anc.py プロジェクト: siteslave/iCare
def anc_get_risk_list_by_type(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:

                start_date = h.jsdate_to_string(request.params['start_date'])
                end_date = h.jsdate_to_string(request.params['end_date'])
                choice = request.params['choice']

                hospcode = request.params[
                    'hospcode'] if 'hospcode' in request.params else request.session[
                        'hospcode']

                anc = AncModel(request)
                person = PersonModel(request)

                rs = anc.get_risk_list_by_type(hospcode, choice, start_date,
                                               end_date)

                if rs:
                    rows = []
                    for r in rs:
                        p = person.get_person_detail(
                            r['pid'], request.session['hospcode'])
                        obj = {
                            'pid': r['pid'],
                            'cid': p['cid'],
                            'fullname': p['name'] + ' ' + p['lname'],
                            'birth': h.to_thai_date(p['birth']),
                            'age': h.count_age(p['birth'])
                        }

                        rows.append(obj)

                    return {'ok': 1, 'rows': rows}

                else:
                    return {'ok': 0, 'msg': u'ไม่พบรายการ'}
            else:
                return {'ok': 0, 'msg': 'Not authorized.'}

        else:
            return {'ok': 0, 'msg': 'Not ajax.'}
コード例 #2
0
ファイル: anc.py プロジェクト: siteslave/iCare
def anc_get_risk_list_by_type(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:

                start_date = h.jsdate_to_string(request.params["start_date"])
                end_date = h.jsdate_to_string(request.params["end_date"])
                choice = request.params["choice"]

                hospcode = request.params["hospcode"] if "hospcode" in request.params else request.session["hospcode"]

                anc = AncModel(request)
                person = PersonModel(request)

                rs = anc.get_risk_list_by_type(hospcode, choice, start_date, end_date)

                if rs:
                    rows = []
                    for r in rs:
                        p = person.get_person_detail(r["pid"], request.session["hospcode"])
                        obj = {
                            "pid": r["pid"],
                            "cid": p["cid"],
                            "fullname": p["name"] + " " + p["lname"],
                            "birth": h.to_thai_date(p["birth"]),
                            "age": h.count_age(p["birth"]),
                        }

                        rows.append(obj)

                    return {"ok": 1, "rows": rows}

                else:
                    return {"ok": 0, "msg": u"ไม่พบรายการ"}
            else:
                return {"ok": 0, "msg": "Not authorized."}

        else:
            return {"ok": 0, "msg": "Not ajax."}