コード例 #1
0
ファイル: anc.py プロジェクト: siteslave/iCare
def anc_get_list_map(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']
            by = request.params['by']
            vid = request.params['vid'] if 'vid' in request.params else False

            limit = int(stop) - int(start)

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

            if vid:
                home = HomeModel(request)
                hids = home.get_hid_from_village(request.session['hospcode'],
                                                 vid)
                rs = anc.get_list_map_anc_by_vid(request.session['hospcode'],
                                                 hids, int(by), int(start),
                                                 int(limit))
            else:
                rs = anc.get_list_map_anc(request.session['hospcode'], int(by),
                                          int(start), int(limit))

            rows = []
            if rs:
                for r in rs:
                    p = person.get_person_detail(r['pid'],
                                                 request.session['hospcode'])

                    obj = {
                        'cid':
                        p['cid'],
                        'pid':
                        p['pid'],
                        'hid':
                        p['hid'],
                        'fullname':
                        '%s %s' % (p['name'], p['lname']),
                        'age':
                        h.count_age(p['birth']),
                        'gravida':
                        r['gravida'],
                        'hospcode':
                        r['hospcode'],
                        'latlng':
                        anc.get_latlng_from_pid(p['pid'],
                                                request.session['hospcode'])
                    }

                    rows.append(obj)

                return {'ok': 1, 'rows': rows}
            else:
                return {'ok': 0, 'msg': u'ไม่พบข้อมูล'}
        else:
            return {'ok': 0, 'msg': 'Not ajax request.'}
コード例 #2
0
ファイル: anc.py プロジェクト: siteslave/iCare
def anc_get_list_map(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"]
            by = request.params["by"]
            vid = request.params["vid"] if "vid" in request.params else False

            limit = int(stop) - int(start)

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

            if vid:
                home = HomeModel(request)
                hids = home.get_hid_from_village(request.session["hospcode"], vid)
                rs = anc.get_list_map_anc_by_vid(request.session["hospcode"], hids, int(by), int(start), int(limit))
            else:
                rs = anc.get_list_map_anc(request.session["hospcode"], int(by), int(start), int(limit))

            rows = []
            if rs:
                for r in rs:
                    p = person.get_person_detail(r["pid"], request.session["hospcode"])

                    obj = {
                        "cid": p["cid"],
                        "pid": p["pid"],
                        "hid": p["hid"],
                        "fullname": "%s %s" % (p["name"], p["lname"]),
                        "age": h.count_age(p["birth"]),
                        "gravida": r["gravida"],
                        "hospcode": r["hospcode"],
                        "latlng": anc.get_latlng_from_pid(p["pid"], request.session["hospcode"]),
                    }

                    rows.append(obj)

                return {"ok": 1, "rows": rows}
            else:
                return {"ok": 0, "msg": u"ไม่พบข้อมูล"}
        else:
            return {"ok": 0, "msg": "Not ajax request."}