示例#1
0
def register_patient():
    if (request.method == "GET"):
        return render_template("Register/register_patient.html",
                               title="Patient")

    elif (request.method == "POST"):
        inpDict = {
            "patientID": str(request.form["patientID"]),
            "name": str(request.form["patientName"]),
            "email": str(request.form["email"]),
            "dob": str(request.form["dob"]),
            "address": str(request.form["address"]),
            "sex": str(request.form["sex"]),
            "phoneNO": str(request.form["phoneNo"]),
            "password": str(request.form["password"]),
        }
        if not models_common.isExistingUser(
                inpDict["patientID"], "Patient"):  # Insert if not existing
            res = models_common.insertNewUser(inpDict, "Patient")
            if (res == True):
                return redirect(url_for("home"))
            else:
                flash("Error")

    else:
        flash("Error")
def register_lab():
    if (request.method == "GET"):
        return render_template("Register/register_lab.html", title="Lab")

    elif (request.method == "POST"):
        inpDict = {
            "labID": str(request.form["labID"]),
            "labName": str(request.form["labName"]),
            "address": str(request.form["address"]),
            "email": str(request.form["email"]),
            "phoneNO": str(request.form["phoneNo"]),
            "password": str(request.form["password"]),
        }
        if not models_common.isExistingUser(inpDict["labID"], "Lab"):
            res = models_common.insertNewUser(inpDict, "Lab")
            if (res == True):
                return redirect(url_for("home"))
            else:
                flash("Error")

    else:
        flash("Error")