public static PTLocalPatient CreatePatient(PTLocalPatient patient)
        {
            try
            {
                //TODO: if user does not yet exist, we add the user, but it probably shouldn't add with status as confirmed.
                // add the patient to the db, set patient.ID, and return the patient
                using (PTLinkDatabaseDataContext db = new PTLinkDatabaseDataContext())
                {
                    Person person = new Person();
                    User user = (from u in db.Users
                                 where u.Email == patient.email
                                 && u.Password == patient.password
                                 select u).SingleOrDefault();

                    person.FirstName = patient.firstName;
                    person.LastName = patient.lastName;
                    person.Permissions = "Patient";
                    person.PushToken = patient.pushtoken;
                    person.IsActive = true;

                    if (user == null)
                    {
                        user = new User();
                        user.Email = patient.email;
                        user.Password = patient.password;
                        user.RegistrationStatus = (from r in db.RegistrationStatus
                                                   where r.Status == "Confirmed"
                                                   select r
                                                   ).SingleOrDefault();
                        user.Persons.Add(person);
                        db.Users.InsertOnSubmit(user);
                        db.SubmitChanges();
                    }
                    else
                    {
                        user.Persons.Add(person);
                        db.SubmitChanges();
                    }

                    patient.ID = user.Persons.SingleOrDefault().Id;
                    return patient;
                }
            }
            catch
            {
                return null;
            }
        }
		private void detach_Persons(Person entity)
		{
			this.SendPropertyChanging();
			entity.Division = null;
		}
		private void attach_Persons(Person entity)
		{
			this.SendPropertyChanging();
			entity.Division = this;
		}
 partial void DeletePerson(Person instance);
 partial void UpdatePerson(Person instance);
 partial void InsertPerson(Person instance);