def create_demographics(patient, facility, gender): ethnicity_codes = EthnicityCode.query.all() d = PatientDemographics() d.patient = patient d.facility = facility d.first_name = generate_first_name(gender) d.last_name = generate_last_name() d.gender = gender d.date_of_birth = generate_date_of_birth() d.ethnicity_code = random.choice(ethnicity_codes) # 10% chance of being dead :( if random.random() < 0.1: d.date_of_death = generate_date_of_death() d.home_number = generate_phone_number() d.mobile_number = generate_mobile_number() d.work_number = generate_phone_number() d.email_address = generate_email_address(d.first_name, d.last_name) r = random.random() if r > 0.9: d.nhs_no = generate_nhs_no() d.chi_no = generate_chi_no() elif r > 0.8: d.chi_no = generate_chi_no() elif r > 0.1: d.nhs_no = generate_nhs_no() db.session.add(d)
def create_users(n): for x in range(n): user = User() user.first_name = generate_first_name().capitalize() user.last_name = generate_last_name().capitalize() user.username = '******' % ( user.first_name.lower(), user.last_name.lower(), x + 1 ) user.email = '*****@*****.**' % user.username user.set_password('password') db.session.add(user)