Esempio n. 1
0
def create_new_patient_account(form_data):
    """Add a patient to the database."""

    email = form_data.get("email")
    dietitian_id = form_data.get("dietitian_id")
    fname = form_data.get("fname")
    lname = form_data.get("lname")
    password = form_data.get("password")
    street_address = form_data.get("street-address")
    city = form_data.get("city")
    state = form_data.get("state")
    zipcode = form_data.get("zipcode")
    phone = form_data.get("phone")
    birthdate = form_data.get("birthdate")

    new_patient = Patient(dietitian_id=dietitian_id,
                          fname=fname,
                          lname=lname,
                          email=email,
                          street_address=street_address,
                          city=city,
                          state=state,
                          zipcode=zipcode,
                          phone=phone,
                          birthdate=birthdate)

    new_patient.set_password(password)

    db.session.add(new_patient)
    db.session.commit()

    return new_patient.patient_id
Esempio n. 2
0
def load_patients(patient_filename):
    """Load patients from u.patient into database."""

    for row in open(patient_filename):
        row = row.rstrip()
        dietitian_id, fname, lname, email, password, street_address, city, state, zipcode, phone, birthdate = row.split(
            "|")

        patient = Patient(dietitian_id=dietitian_id,
                          fname=fname,
                          lname=lname,
                          email=email,
                          street_address=street_address,
                          city=city,
                          state=state,
                          zipcode=zipcode,
                          phone=phone,
                          birthdate=birthdate)

        patient.set_password(password)

        db.session.add(patient)

    db.session.commit()