Пример #1
0
def pin_code_generate():
    if request.method == 'GET':
        appid = request.args.get("appid")
        userid = request.args.get("userid")
        email = request.args.get("email")

        # generate pin code here
        while True:
            rand = np.random.randint(100000, 999999, 1)[0]
            pin_code = str(rand)

            rowkey = appid + "_" + pin_code
            data = manager.fetch(table_pin_code, rowkey)

            if data is None:
                break

        # save to profile data
        data1 = {}
        data1['profile'] = {'pin_code': pin_code,
                            'role': 'nurse', 'email': email}

        rowkey1 = userid + "_" + appid
        manager.save_batch(table_information, rowkey1, data1)

        # save to patient code data
        data2 = {}
        data2['pin_code'] = {'userid': userid, 'email': email}

        rowkey2 = appid + "_" + pin_code
        manager.save_batch(table_pin_code, rowkey2, data2)

        return jsonify(success="true", pin_code=pin_code)
Пример #2
0
def nutrientdata():
    if request.method == 'POST':
        obj = request.json
        print json.dumps(obj, indent=4, separators=(',', ': '))
        userid = obj.get("userid")
        appid = obj.get("appid")
        nutrients = obj.get("nutrients")
        date = obj.get("date")
        meal = obj.get("meal")

        rowkey = userid + "_" + appid + "_" + date + "_" + meal

        data = {}
        data['nutrient'] = nutrients

        manager.save_batch(table_nutrient, rowkey, data)

        # print json.dumps(obj, indent=4, separators=(',', ': '))
        return jsonify(success="true")

    if request.method == 'GET':
        userid = request.args.get("userid")
        appid = request.args.get("appid")
        date = request.args.get("date")
        meal = request.args.get("meal")

        rowkey = userid + "_" + appid + "_" + date + "_" + meal

        data = manager.fetch(table_nutrient, rowkey)

        # print data
    return jsonify(data=data)

    return jsonify(success="true")
Пример #3
0
def resultdata():
    if request.method == 'POST':
        obj = request.json

        userid = obj.get("userid")
        appid = obj.get("appid")
        date = obj.get("date")
        labresult = obj.get("result")

        title = labresult.get("title")
        value = labresult.get("value")
        limit = labresult.get("limit")

        rowkey = userid + "_" + appid + "_" + date
        _value = str(value) + ',' + str(limit)

        # print json.dumps(obj, indent=4, separators=(',', ': '))

        manager.insert_data(table_result, rowkey, 'testresults', title, _value)

        return jsonify(success="true")
    elif request.method == 'GET':
        # not use this condition
        # data = {}
        # column = base64.b64encode("{}:{}".format('activity', title))
        # result = manager.fetch_part(table_exercise, start_row, end_row, column)
        # data[title] = service.summary_by_date(result, 'activity', title)
        data = manager.fetch(table_result, 'lucksika_display01_2017-01-26')
        # print data
        # print type(data)
        title = 'BUN'
        value = 1.2
        limit = 1.5
        check_date = '2015-12-23'
        return jsonify(title=title, value=value, limit=limit, check_date=check_date)
Пример #4
0
def profile():
    if request.method == 'POST':
        obj = request.json

        userid = obj.get("userid")
        appid = obj.get("appid")
        profile = obj.get("profile")

        data = {}
        data['profile'] = profile

        # print data

        rowkey = userid + "_" + appid

        manager.save_batch(table_information, rowkey, data)

        return jsonify(success="true")

    elif request.method == 'GET':
        userid = request.args.get("userid")
        appid = request.args.get("appid")

        rowkey = userid + "_" + appid
        column = 'profile'

        data = manager.fetch(table_information, rowkey, column)

        return jsonify(data=data)
Пример #5
0
def resultdata():
    if request.method == 'POST':
        obj = request.json

        userid = obj.get("userid")
        appid = obj.get("appid")
        date = obj.get("date")
        labresult = obj.get("result")

        title = labresult.get("title")
        value = labresult.get("value")
        limit = labresult.get("limit")

        rowkey = userid + "_" + appid + "_" + date
        _value = str(value) + ',' + str(limit)

        # print json.dumps(obj, indent=4, separators=(',', ': '))

        manager.insert_data(table_result, rowkey, 'testresults', title, _value)

        return jsonify(success="true")
    elif request.method == 'GET':
        data = manager.fetch(table_result, 'lucksika_display01_2017-01-26')
        # print data
        # print type(data)
        title = 'BUN'
        value = 1.2
        limit = 1.5
        check_date = '2015-12-23'
        return jsonify(title=title,
                       value=value,
                       limit=limit,
                       check_date=check_date)
Пример #6
0
def pin_code_check():
    if request.method == 'GET':
        appid = request.args.get("appid")
        pin_code = request.args.get("pin_code")

        rowkey = appid + "_" + pin_code
        data = manager.fetch(table_pin_code, rowkey)
        if data is None:
            return jsonify(success="false", data=data)

        return jsonify(success="true", data=data)
Пример #7
0
def hospital():
    if request.method == 'POST':
        obj = request.json
        hospitalid = obj.get("hospitalid")
        information = obj.get("information")
        data = {}
        data['information'] = information

        rowkey = hospitalid
        manager.save_batch(table_hospital, rowkey, data)

        return jsonify(success="true")

    elif request.method == 'GET':
        hospitalid = request.args.get("hospitalid")
        rowkey = hospitalid
        column = 'information'
        data = manager.fetch(table_hospital, rowkey, column)

        return jsonify(data=data)
Пример #8
0
def profile():
    if request.method == 'POST':
        obj = request.json

        userid = obj.get("userid")
        appid = obj.get("appid")
        profile = obj.get("profile")

        enc_profile = {str(k).encode('utf8'): str(v).encode('utf8')
                       for k, v in profile.items()}

        data = {
            "profile": enc_profile
        }

        rowkey = userid + "_" + appid
        manager.save_batch(table_information, rowkey, data)

        return jsonify(success="true")

    elif request.method == 'GET':
        userid = request.args.get("userid")
        appid = request.args.get("appid")

        rowkey = userid + "_" + appid
        column = 'profile'

        data = manager.fetch(table_information, rowkey, column)

        return jsonify(data=data)

    elif request.method == 'DELETE':
        userid = request.args.get("userid")
        appid = request.args.get("appid")

        rowkey = userid + "_" + appid

        manager.delete_row(table_information, rowkey)

        return jsonify(success="true")
Пример #9
0
def patient_code_generate():
    if request.method == 'GET':
        appid = request.args.get("appid")
        userid = request.args.get("userid")
        email = request.args.get("email")
        admit_date = request.args.get("admit_date")

        # generate patient code here
        while True:
            rand = np.random.randint(1000, 9999, 1)[0]
            patient_code = 'PATIENT' + str(rand)

            rowkey = appid + "_" + patient_code
            data = manager.fetch(table_patient_code, rowkey)

            if data is None:
                break

        # save to profile data
        data1 = {}
        data1['profile'] = {'patient_code': patient_code,
                            'role': 'patient', 'email': email, 'level': 0}

        rowkey1 = userid + "_" + appid
        manager.save_batch(table_information, rowkey1, data1)

        # save to patient code data
        data2 = {}
        data2['patient_code'] = {'userid': userid,
                                 'email': email, 'admit_date': admit_date}

        rowkey2 = appid + "_" + patient_code
        manager.save_batch(table_patient_code, rowkey2, data2)

        return jsonify(success="true", patient_code=patient_code)

    elif request.method == 'POST':
        obj = request.json
        appid = obj.get("appid")
        patient_code = obj.get("patient_code")
        profile = obj.get("profile")

        enc_profile = {k.encode('utf8'): v.encode('utf8')
                       for k, v in profile.items()}

        data = {}
        data['patient_code'] = enc_profile

        rowkey = appid + "_" + patient_code
        manager.save_batch(table_patient_code, rowkey, data)

        return jsonify(success="true")

    elif request.method == 'DELETE':
        appid = request.args.get("appid")
        patient_code = request.args.get('patient_code')

        rowkey = appid + "_" + patient_code

        manager.delete_row(table_patient_code, rowkey)

        return jsonify(success="true")
Пример #10
0
 def fetch(self):
     return fetch(self)