def link_user_to_new_patient(self, appointment_details_form, user, booking): # user but no patient # create a patient and link it to existing user patient = Patient() # set the properties (just email) appointment_details_form.populate_obj(patient) self.set_gae_geography_from_headers(patient) # link to logged in user patient.user = user.key patient.email = user.get_email() # if it's a provider, copy over details like name, etc. provider = db.get_provider_from_user(user) if provider: patient.first_name = provider.first_name patient.last_name = provider.last_name patient.put() booking.patient = patient.key booking.put() # add patient role to user user.roles.append(auth.PATIENT_ROLE) user.put()
def create_test_patient(self): ''' Create a test patient (and linked user) in the datastore ''' user_created, new_user = User.create_user(self._TEST_PATIENT_EMAIL, password_raw=self._TEST_PATIENT_PASSWORD, roles=[auth.PATIENT_ROLE]) self.assertTrue(user_created) tp = Patient() tp.created_on = datetime.now() tp.user = new_user.key tp.first_name = 'Pat' tp.last_name = 'Patient' tp.email = "*****@*****.**" tp.telephone = '514-123-1234' tp.terms_agreement = True tp.put() new_user.language = 'fr' new_user.put()