From 7939c1477cbeba4a2aec4904acde6da1355f51b5 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Thu, 13 Jun 2024 23:23:30 +0000 Subject: [PATCH 1/7] Restyled by autopep8 --- fake_data/config.py | 11 +- fake_data/connect.py | 2 + fake_data/insurances.py | 6 +- fake_data/insurances_patients_join.py | 94 +++--- fake_data/offices.py | 12 +- fake_data/offices_staff_join.py | 45 +-- fake_data/patients.py | 399 ++++++++++++++------------ fake_data/patients_staff_join.py | 42 +-- fake_data/staff.py | 94 +++--- 9 files changed, 375 insertions(+), 330 deletions(-) diff --git a/fake_data/config.py b/fake_data/config.py index 21828b2..f5f9fae 100644 --- a/fake_data/config.py +++ b/fake_data/config.py @@ -1,11 +1,12 @@ from configparser import ConfigParser import os + def load_config(filename='database.ini', section='postgresql'): if not os.path.exists(filename): - raise FileNotFoundError(f"{filename} does not exist. Please request access to database.ini from the administrator.") + raise FileNotFoundError( + f"{filename} does not exist. Please request access to database.ini from the administrator.") - parser = ConfigParser() parser.read(filename) @@ -16,10 +17,12 @@ def load_config(filename='database.ini', section='postgresql'): for param in params: config[param[0]] = param[1] else: - raise Exception('Section {0} not found in the {1} file'.format(section, filename)) + raise Exception( + 'Section {0} not found in the {1} file'.format(section, filename)) return config + if __name__ == '__main__': config = load_config() - print(config) \ No newline at end of file + print(config) diff --git a/fake_data/connect.py b/fake_data/connect.py index fcd9fc6..603f252 100644 --- a/fake_data/connect.py +++ b/fake_data/connect.py @@ -3,6 +3,7 @@ from tabulate import tabulate import csv + def connect(config): """ Connect to the PostgreSQL database server """ try: @@ -13,6 +14,7 @@ def connect(config): except (psycopg2.DatabaseError, Exception) as error: print(error) + def query(operation): '''Fetch data from the PostgreSQL database server''' try: diff --git a/fake_data/insurances.py b/fake_data/insurances.py index ee476f4..c323453 100644 --- a/fake_data/insurances.py +++ b/fake_data/insurances.py @@ -7,7 +7,8 @@ phone VARCHAR ''' -insurances_list = ['Aetna', 'Blue Cross Blue Shield', 'Cigna', 'UnitedHealth Group', 'Centene Corp.', 'Kaiser Permanente', 'Humana', 'Health Care Services Corporation'] +insurances_list = ['Aetna', 'Blue Cross Blue Shield', 'Cigna', 'UnitedHealth Group', + 'Centene Corp.', 'Kaiser Permanente', 'Humana', 'Health Care Services Corporation'] header = ['name', 'phone'] @@ -15,4 +16,5 @@ writer = csv.writer(file) writer.writerow(header) for item in insurances_list: - writer.writerow([item, fake.random_int(min=1000000000, max=9999999999)]) \ No newline at end of file + writer.writerow([item, fake.random_int( + min=1000000000, max=9999999999)]) diff --git a/fake_data/insurances_patients_join.py b/fake_data/insurances_patients_join.py index c7bce67..ca41594 100644 --- a/fake_data/insurances_patients_join.py +++ b/fake_data/insurances_patients_join.py @@ -6,7 +6,7 @@ fake = Faker() -#Assign patient a random insurance. +# Assign patient a random insurance. ''' insurance_id uuid patient_id uuid @@ -18,56 +18,64 @@ group_number varchar ''' -#save insurance_ids in a list +# save insurance_ids in a list + + def list_insurances(): - insurances = [] - with open('insurance_ids.csv') as file: - reader_obj = csv.reader(file) - for row in reader_obj: - insurances.append(row[0]) - insurances.pop(0) #remove the header - print("insurance 1:", insurances[0]) #test - num_insurances = len(insurances) - return insurances, num_insurances + insurances = [] + with open('insurance_ids.csv') as file: + reader_obj = csv.reader(file) + for row in reader_obj: + insurances.append(row[0]) + insurances.pop(0) # remove the header + print("insurance 1:", insurances[0]) # test + num_insurances = len(insurances) + return insurances, num_insurances + +# pair each patient with a random insurance + -#pair each patient with a random insurance def loop_through_patients(insurances, num_insurances): - insurances_patients_join = [] - with open('patient_ids.csv') as file_obj: - reader_obj = csv.reader(file_obj) - for row in reader_obj: - join = { "patient_id": row[0], - "insurance_id": insurances[randrange(0,num_insurances)], - # "primary_insured_name": fake.name(), - # "primary_insured_birthdate": fake.date_of_birth(), - # "primary_insured_SSN": fake.random_int(min=100000000, max=999999999), - # "primary_insured_relationship": fake.word() - } - insurances_patients_join.append(join) - insurances_patients_join.pop(0) #remove the header - print("join 1:", insurances_patients_join[0]) #test - return insurances_patients_join + insurances_patients_join = [] + with open('patient_ids.csv') as file_obj: + reader_obj = csv.reader(file_obj) + for row in reader_obj: + join = {"patient_id": row[0], + "insurance_id": insurances[randrange(0, num_insurances)], + # "primary_insured_name": fake.name(), + # "primary_insured_birthdate": fake.date_of_birth(), + # "primary_insured_SSN": fake.random_int(min=100000000, max=999999999), + # "primary_insured_relationship": fake.word() + } + insurances_patients_join.append(join) + insurances_patients_join.pop(0) # remove the header + print("join 1:", insurances_patients_join[0]) # test + return insurances_patients_join # write offices_patient_join to a new csv file + + def write_to_join_csv(insurances_patients_join): - with open('insurances_patients_join.csv', 'w', newline='') as csvfile: - writer = csv.writer(csvfile) - writer.writerow(["insurance_id", "patient_id", 'primary_insured_name', 'primary_insured_birthdate', 'primary_insured_SSN', 'primary_insured_relationship', 'member_number', 'group_number']) - for join in insurances_patients_join: - writer.writerow([join["insurance_id"], join["patient_id"]]) + with open('insurances_patients_join.csv', 'w', newline='') as csvfile: + writer = csv.writer(csvfile) + writer.writerow(["insurance_id", "patient_id", 'primary_insured_name', 'primary_insured_birthdate', + 'primary_insured_SSN', 'primary_insured_relationship', 'member_number', 'group_number']) + for join in insurances_patients_join: + writer.writerow([join["insurance_id"], join["patient_id"]]) def query_patient_data(): - config = load_config() - with psycopg2.connect(**config) as conn: - with conn.cursor() as cur: - cur.execute("SELECT * FROM patients") - patients = cur.fetchall() - print(type(patients)) - return patients + config = load_config() + with psycopg2.connect(**config) as conn: + with conn.cursor() as cur: + cur.execute("SELECT * FROM patients") + patients = cur.fetchall() + print(type(patients)) + return patients + if __name__ == '__main__': - # insurances, num_insurances = list_insurances() - # insurances_patients_join = loop_through_patients(insurances, num_insurances) - # write_to_join_csv(insurances_patients_join) - query_patient_data() \ No newline at end of file + # insurances, num_insurances = list_insurances() + # insurances_patients_join = loop_through_patients(insurances, num_insurances) + # write_to_join_csv(insurances_patients_join) + query_patient_data() diff --git a/fake_data/offices.py b/fake_data/offices.py index b5e7ab9..fc0cfd3 100644 --- a/fake_data/offices.py +++ b/fake_data/offices.py @@ -18,7 +18,9 @@ Mo - Fr :00 - :00 Sa - Su :00 - :00 or closed ''' -offices_types = ['Medical', 'Health', 'Group', 'Clinic', 'Memorial Hospital', 'University Medical Group', 'Medical Center', 'Medical Clinic', 'Health Center'] +offices_types = ['Medical', 'Health', 'Group', 'Clinic', 'Memorial Hospital', + 'University Medical Group', 'Medical Center', 'Medical Clinic', 'Health Center'] + def generate_office_data(): nameA = fake.city() @@ -52,15 +54,11 @@ def generate_office_data(): # print(hours) - - -header = ['name', 'address_line_1', 'city', 'state', 'zipcode', 'phone', 'email', 'website', 'hours'] +header = ['name', 'address_line_1', 'city', 'state', + 'zipcode', 'phone', 'email', 'website', 'hours'] with open('offices.csv', 'w', newline='') as file: writer = csv.writer(file) writer.writerow(header) for i in range(1000): data = generate_office_data() writer.writerow(data) - - - diff --git a/fake_data/offices_staff_join.py b/fake_data/offices_staff_join.py index be09e59..6e1dc9f 100644 --- a/fake_data/offices_staff_join.py +++ b/fake_data/offices_staff_join.py @@ -4,33 +4,34 @@ fake = Faker() -#Assign each staff member to a random office. Give them a 5% chance of being an admin. +# Assign each staff member to a random office. Give them a 5% chance of being an admin. -#save office_ids in a list +# save office_ids in a list offices = [] with open('office_ids.csv') as file: - reader_obj = csv.reader(file) - for row in reader_obj: - offices.append(row[0]) -offices.pop(0) #remove the header -print("office 1:", offices[0]) #test + reader_obj = csv.reader(file) + for row in reader_obj: + offices.append(row[0]) +offices.pop(0) # remove the header +print("office 1:", offices[0]) # test -#pair each staff member with a random office +# pair each staff member with a random office offices_staff_join = [] -with open('staff_ids.csv') as file_obj: - reader_obj = csv.reader(file_obj) - for row in reader_obj: - join = { "staff_id": row[0], - "office_id": offices[randrange(1000)], - "is_admin": fake.boolean(chance_of_getting_true=5) - } - offices_staff_join.append(join) -offices_staff_join.pop(0) #remove the header -print("join 1:", offices_staff_join[0]) #test +with open('staff_ids.csv') as file_obj: + reader_obj = csv.reader(file_obj) + for row in reader_obj: + join = {"staff_id": row[0], + "office_id": offices[randrange(1000)], + "is_admin": fake.boolean(chance_of_getting_true=5) + } + offices_staff_join.append(join) +offices_staff_join.pop(0) # remove the header +print("join 1:", offices_staff_join[0]) # test # write offices_staff_join to a new csv file with open('offices_staff_join.csv', 'w', newline='') as csvfile: - writer = csv.writer(csvfile) - writer.writerow(["office_id", "staff_id", "is_admin"]) - for join in offices_staff_join: - writer.writerow([join["office_id"], join["staff_id"], join["is_admin"]]) \ No newline at end of file + writer = csv.writer(csvfile) + writer.writerow(["office_id", "staff_id", "is_admin"]) + for join in offices_staff_join: + writer.writerow( + [join["office_id"], join["staff_id"], join["is_admin"]]) diff --git a/fake_data/patients.py b/fake_data/patients.py index 370d3aa..1d9a66a 100644 --- a/fake_data/patients.py +++ b/fake_data/patients.py @@ -51,212 +51,239 @@ ''' emails = [] -possible_allergens = ['Peanuts', 'Penicillin', 'NSAIDs', 'Iodinated contrast', 'Gadolinium contrast', 'Ester local anesthetics', 'Latex', 'Soy', 'Dairy', 'Eggs', 'Shellfish', 'Gluten', 'Fish', 'Tree nuts', 'Wheat', 'Sesame', 'Sulfites', 'Corn', 'Kiwi', 'Mango', 'Pineapple'] -possible_reactions = ['Anaphylaxis', 'Hives', 'Rash', 'Itching', 'Swelling', 'Coughing', 'Wheezing', 'Shortness of breath', 'Nausea', 'Vomiting', 'Diarrhea', 'Abdominal pain', 'Dizziness', 'Fainting', 'Low blood pressure', 'Fast heart rate', 'Confusion', 'Loss of consciousness'] -possible_vaccines = ['COVID-19', 'Influenza', 'Hepatitis A', 'Hepatitis B', 'HPV', 'Measles, Mumps, Rubella', 'Pneumococcal', 'Polio', 'Tetanus, Diphtheria, Pertussis', 'Varicella', 'Zoster'] -possible_surgeries = ['Appendectomy', 'Cholecystectomy', 'Hernia repair', 'Mastectomy', 'Tonsillectomy', 'Adenoidectomy', 'Cataract surgery', 'Coronary artery bypass', 'Heart valve repair', 'Hip replacement', 'Knee replacement', 'Spinal fusion', 'Laminectomy', 'Lobectomy', 'Lung transplant', 'Wisdom Teeth Removal', 'ACL repair', 'Rotator cuff repair'] -possible_conditions = ['Heart disease', 'Stroke', 'Diabetes', 'Cancer', 'High blood pressure', 'High cholesterol', 'Asthma', 'Arthritis', 'Osteoporosis', 'Alzheimer\'s', 'Dementia', 'Depression', 'Anxiety', 'Bipolar disorder', 'Schizophrenia', 'ADHD', 'Autism', 'Epilepsy', 'Migraines', 'Thyroid disease', 'Kidney disease', 'Liver disease', 'Lung disease', 'COPD', 'Crohn\'s disease', 'Ulcerative colitis', 'Celiac disease', 'Multiple sclerosis', 'Lupus', 'Rheumatoid arthritis', 'Psoriasis', 'HIV/AIDS', 'Hepatitis', 'Tuberculosis'] -medical_conditions = ['Asthma', 'Diabetes', 'High blood pressure', 'High cholesterol', 'Heart disease', 'Stroke', 'Cancer', 'Arthritis', 'Osteoporosis', 'Alzheimer\'s', 'Dementia', 'Depression', 'Anxiety', 'Bipolar disorder', 'Schizophrenia', 'ADHD', 'Autism', 'Epilepsy', 'Migraines', 'Thyroid disease', 'Kidney disease', 'Liver disease', 'Lung disease', 'COPD', 'Crohn\'s disease', 'Ulcerative colitis', 'Celiac disease', 'Multiple sclerosis', 'Lupus', 'Rheumatoid arthritis', 'Psoriasis', 'HIV/AIDS', 'Hepatitis', 'Tuberculosis'] +possible_allergens = ['Peanuts', 'Penicillin', 'NSAIDs', 'Iodinated contrast', 'Gadolinium contrast', 'Ester local anesthetics', 'Latex', + 'Soy', 'Dairy', 'Eggs', 'Shellfish', 'Gluten', 'Fish', 'Tree nuts', 'Wheat', 'Sesame', 'Sulfites', 'Corn', 'Kiwi', 'Mango', 'Pineapple'] +possible_reactions = ['Anaphylaxis', 'Hives', 'Rash', 'Itching', 'Swelling', 'Coughing', 'Wheezing', 'Shortness of breath', 'Nausea', 'Vomiting', + 'Diarrhea', 'Abdominal pain', 'Dizziness', 'Fainting', 'Low blood pressure', 'Fast heart rate', 'Confusion', 'Loss of consciousness'] +possible_vaccines = ['COVID-19', 'Influenza', 'Hepatitis A', 'Hepatitis B', 'HPV', 'Measles, Mumps, Rubella', + 'Pneumococcal', 'Polio', 'Tetanus, Diphtheria, Pertussis', 'Varicella', 'Zoster'] +possible_surgeries = ['Appendectomy', 'Cholecystectomy', 'Hernia repair', 'Mastectomy', 'Tonsillectomy', 'Adenoidectomy', 'Cataract surgery', 'Coronary artery bypass', + 'Heart valve repair', 'Hip replacement', 'Knee replacement', 'Spinal fusion', 'Laminectomy', 'Lobectomy', 'Lung transplant', 'Wisdom Teeth Removal', 'ACL repair', 'Rotator cuff repair'] +possible_conditions = ['Heart disease', 'Stroke', 'Diabetes', 'Cancer', 'High blood pressure', 'High cholesterol', 'Asthma', 'Arthritis', 'Osteoporosis', 'Alzheimer\'s', 'Dementia', 'Depression', 'Anxiety', 'Bipolar disorder', 'Schizophrenia', 'ADHD', 'Autism', + 'Epilepsy', 'Migraines', 'Thyroid disease', 'Kidney disease', 'Liver disease', 'Lung disease', 'COPD', 'Crohn\'s disease', 'Ulcerative colitis', 'Celiac disease', 'Multiple sclerosis', 'Lupus', 'Rheumatoid arthritis', 'Psoriasis', 'HIV/AIDS', 'Hepatitis', 'Tuberculosis'] +medical_conditions = ['Asthma', 'Diabetes', 'High blood pressure', 'High cholesterol', 'Heart disease', 'Stroke', 'Cancer', 'Arthritis', 'Osteoporosis', 'Alzheimer\'s', 'Dementia', 'Depression', 'Anxiety', 'Bipolar disorder', 'Schizophrenia', 'ADHD', 'Autism', 'Epilepsy', + 'Migraines', 'Thyroid disease', 'Kidney disease', 'Liver disease', 'Lung disease', 'COPD', 'Crohn\'s disease', 'Ulcerative colitis', 'Celiac disease', 'Multiple sclerosis', 'Lupus', 'Rheumatoid arthritis', 'Psoriasis', 'HIV/AIDS', 'Hepatitis', 'Tuberculosis'] + def generate_patient_data(): - password = fake.password() - SSN = fake.random_int(min=100000000, max=999999999) - phone = fake.random_int(min=1000000000, max=9999999999) - religion = fake.random_element(elements=('Christian', 'Muslim', 'Jewish', 'Buddhist', 'Hindu', 'Atheist', 'Agnostic', 'Other')) - eyesight = fake.random_element(elements=('20/20', '20/40', '20/60', '20/80', '20/100', 'blind')) - hearing = fake.random_element(elements=('hearing', 'hard of hearing', 'deaf')) - mobility = fake.random_element(elements=('able', 'wheelchair', 'walker', 'cane', 'crutches')) - height = fake.pyfloat(min_value=48, max_value=84, right_digits=2) - weight = fake.pyfloat(min_value=110, max_value=270, right_digits=2) - blood_type = fake.random_element(elements=('A+', 'A-', 'B+', 'B-', 'AB+', 'AB-', 'O+', 'O-')) + password = fake.password() + SSN = fake.random_int(min=100000000, max=999999999) + phone = fake.random_int(min=1000000000, max=9999999999) + religion = fake.random_element(elements=( + 'Christian', 'Muslim', 'Jewish', 'Buddhist', 'Hindu', 'Atheist', 'Agnostic', 'Other')) + eyesight = fake.random_element( + elements=('20/20', '20/40', '20/60', '20/80', '20/100', 'blind')) + hearing = fake.random_element( + elements=('hearing', 'hard of hearing', 'deaf')) + mobility = fake.random_element( + elements=('able', 'wheelchair', 'walker', 'cane', 'crutches')) + height = fake.pyfloat(min_value=48, max_value=84, right_digits=2) + weight = fake.pyfloat(min_value=110, max_value=270, right_digits=2) + blood_type = fake.random_element( + elements=('A+', 'A-', 'B+', 'B-', 'AB+', 'AB-', 'O+', 'O-')) - date_of_birth = fake.date_of_birth(minimum_age=18, maximum_age=90) - days_in_year = 365.2425 - age = int((date.today() - date_of_birth).days / days_in_year) + date_of_birth = fake.date_of_birth(minimum_age=18, maximum_age=90) + days_in_year = 365.2425 + age = int((date.today() - date_of_birth).days / days_in_year) - last_reviewed_timestamp = fake.date_time_this_year(before_now=True, after_now=False, tzinfo=tz.gettz('America/Chicago')) - # reviewer_staff_id = fake.uuid4() + last_reviewed_timestamp = fake.date_time_this_year( + before_now=True, after_now=False, tzinfo=tz.gettz('America/Chicago')) + # reviewer_staff_id = fake.uuid4() - #determine sex and gender (transgender, nonbinary, intersex, cisgender) - preferred_name = 'NULL' #reset later if needed - is_transgender = fake.boolean(chance_of_getting_true=1) - if is_transgender: - sex = fake.random_element(elements=('FtM male', 'MtF female')) - changed_name = fake.boolean(chance_of_getting_true=30) - #if trans male - if (sex == 'FtM male'): - gender = 'male' - pronouns = 'he/him' - if changed_name: - first_name = fake.first_name_male() - else: - first_name = fake.first_name_female() - preferred_name = fake.first_name_male() - #if trans female + # determine sex and gender (transgender, nonbinary, intersex, cisgender) + preferred_name = 'NULL' # reset later if needed + is_transgender = fake.boolean(chance_of_getting_true=1) + if is_transgender: + sex = fake.random_element(elements=('FtM male', 'MtF female')) + changed_name = fake.boolean(chance_of_getting_true=30) + # if trans male + if (sex == 'FtM male'): + gender = 'male' + pronouns = 'he/him' + if changed_name: + first_name = fake.first_name_male() + else: + first_name = fake.first_name_female() + preferred_name = fake.first_name_male() + # if trans female + else: + gender = 'female' + pronouns = 'she/her' + if changed_name: + first_name = fake.first_name_female() + else: + first_name = fake.first_name_male() + preferred_name = fake.first_name_female() + if changed_name and sex == 'FtM Male': + first_name = fake.first_name() + # if cisgendered else: - gender = 'female' - pronouns = 'she/her' - if changed_name: - first_name = fake.first_name_female() - else: - first_name = fake.first_name_male() - preferred_name = fake.first_name_female() - if changed_name and sex == 'FtM Male': - first_name = fake.first_name() - #if cisgendered - else: - sex = fake.random_element(elements=('female', 'male')) - if sex == 'female': - first_name = fake.first_name_female() - gender = 'female' - pronouns = 'she/her' - else: - first_name = fake.first_name_male() - gender = 'male' - pronouns = 'he/him' + sex = fake.random_element(elements=('female', 'male')) + if sex == 'female': + first_name = fake.first_name_female() + gender = 'female' + pronouns = 'she/her' + else: + first_name = fake.first_name_male() + gender = 'male' + pronouns = 'he/him' - is_nonbinary = fake.boolean(chance_of_getting_true=2) - if is_nonbinary: - gender = 'nonbinary' - pronouns = fake.random_element(elements=('they/them', 'she/her', 'he/him', 'she/they', 'he/they', 'she/they/he', 'he/they/she', 'they/she/he', 'they/he/she', 'they/she', 'they/he', 'she/he')) + is_nonbinary = fake.boolean(chance_of_getting_true=2) + if is_nonbinary: + gender = 'nonbinary' + pronouns = fake.random_element(elements=('they/them', 'she/her', 'he/him', 'she/they', 'he/they', + 'she/they/he', 'he/they/she', 'they/she/he', 'they/he/she', 'they/she', 'they/he', 'she/he')) - is_intersex = fake.boolean(chance_of_getting_true=2) - if is_intersex: - sex = 'intersex' + is_intersex = fake.boolean(chance_of_getting_true=2) + if is_intersex: + sex = 'intersex' - #if female anatomy - if sex == 'FtM male' or sex == 'female' or sex == 'intersex': - is_pregnant = fake.boolean(chance_of_getting_true=5) - if is_pregnant: - last_menstrual = fake.date_between(start_date='-280d', end_date='today') + # if female anatomy + if sex == 'FtM male' or sex == 'female' or sex == 'intersex': + is_pregnant = fake.boolean(chance_of_getting_true=5) + if is_pregnant: + last_menstrual = fake.date_between( + start_date='-280d', end_date='today') + else: + last_menstrual = fake.date_between( + start_date='-28d', end_date='today') + # if male anatomy else: - last_menstrual = fake.date_between(start_date='-28d', end_date='today') - #if male anatomy - else: - is_pregnant = False - last_menstrual = 'NULL' + is_pregnant = False + last_menstrual = 'NULL' + + last_name = fake.last_name() + email = first_name[0].lower() + last_name.lower() + \ + '@' + fake.domain_name() + while email in emails: + digits = 2 + email = first_name[slice(digits)].lower() + \ + last_name.lower() + '@' + fake.domain_name() + digits += 1 + emails.append(email) - last_name = fake.last_name() - email = first_name[0].lower() + last_name.lower() + '@' + fake.domain_name() - while email in emails: - digits = 2 - email = first_name[slice(digits)].lower() + last_name.lower() + '@' + fake.domain_name() - digits += 1 - emails.append(email) + # allergies JSON object (allergen: [reactions]) + allergies = {} + num_allergies = fake.random_int(min=0, max=2) + their_allergens = set() + while len(their_allergens) < num_allergies: + allergy = fake.random_element(elements=possible_allergens) + their_allergens.add(allergy) + for allergen in their_allergens: + num_reactions = fake.random_int(min=2, max=4) + their_reactions = set() + while len(their_reactions) < num_reactions: + reaction = fake.random_element(elements=possible_reactions) + their_reactions.add(reaction) + allergies.update({allergen: list(their_reactions)}) + allergies = json.dumps(allergies) + # print(allergies) - #allergies JSON object (allergen: [reactions]) - allergies = {} - num_allergies = fake.random_int(min=0, max=2) - their_allergens = set() - while len(their_allergens) < num_allergies: - allergy = fake.random_element(elements=possible_allergens) - their_allergens.add(allergy) - for allergen in their_allergens: - num_reactions = fake.random_int(min=2, max=4) - their_reactions = set() - while len(their_reactions) < num_reactions: - reaction = fake.random_element(elements=possible_reactions) - their_reactions.add(reaction) - allergies.update({allergen: list(their_reactions)}) - allergies = json.dumps(allergies) - # print(allergies) + # vaccines JSON object (vaccine: date) + vaccines = {} + num_vaccines = fake.random_int(min=5, max=11) + their_vaccines = set() + while len(their_vaccines) < num_vaccines: + vaccine = fake.random_element(elements=possible_vaccines) + their_vaccines.add(vaccine) + for vaccine in their_vaccines: + vaccines.update({vaccine: str(fake.date_between( + start_date='-'+str(age)+'y', end_date='today'))}) + vaccines = json.dumps(vaccines) + # print(vaccines) - #vaccines JSON object (vaccine: date) - vaccines = {} - num_vaccines = fake.random_int(min=5, max=11) - their_vaccines = set() - while len(their_vaccines) < num_vaccines: - vaccine = fake.random_element(elements=possible_vaccines) - their_vaccines.add(vaccine) - for vaccine in their_vaccines: - vaccines.update({vaccine: str(fake.date_between(start_date='-'+str(age)+'y', end_date='today'))}) - vaccines = json.dumps(vaccines) - # print(vaccines) + # surgeries JSON object (surgery: date) + surgeries = {} + num_surgeries = fake.random_int(min=0, max=4) + their_surgeries = set() + while len(their_surgeries) < num_surgeries: + surgery = fake.random_element(elements=possible_surgeries) + their_surgeries.add(surgery) + for surgery in their_surgeries: + surgeries.update({surgery: str(fake.date_between( + start_date='-'+str(age-15)+'y', end_date='today'))}) + surgeries = json.dumps(surgeries) + # print(surgeries) - #surgeries JSON object (surgery: date) - surgeries = {} - num_surgeries = fake.random_int(min=0, max=4) - their_surgeries = set() - while len(their_surgeries) < num_surgeries: - surgery = fake.random_element(elements=possible_surgeries) - their_surgeries.add(surgery) - for surgery in their_surgeries: - surgeries.update({surgery: str(fake.date_between(start_date='-'+str(age-15)+'y', end_date='today'))}) - surgeries = json.dumps(surgeries) - # print(surgeries) + # family_history JSON object (condition: [relatives]) + family_history = {} + num_conditions = fake.random_int(min=0, max=5) + their_conditions = set() + while len(their_conditions) < num_conditions: + condition = fake.random_element(elements=possible_conditions) + their_conditions.add(condition) + for condition in their_conditions: + num_relatives = fake.random_int(min=1, max=3) + their_relatives = set() + while len(their_relatives) < num_relatives: + relative = fake.random_element(elements=( + 'mother', 'father', 'sister', 'brother', 'grandmother', 'grandfather', 'aunt', 'uncle', 'cousin')) + their_relatives.add(relative) + family_history.update({condition: list(their_relatives)}) + family_history = json.dumps(family_history) + # print(family_history) - #family_history JSON object (condition: [relatives]) - family_history = {} - num_conditions = fake.random_int(min=0, max=5) - their_conditions = set() - while len(their_conditions) < num_conditions: - condition = fake.random_element(elements=possible_conditions) - their_conditions.add(condition) - for condition in their_conditions: - num_relatives = fake.random_int(min=1, max=3) - their_relatives = set() - while len(their_relatives) < num_relatives: - relative = fake.random_element(elements=('mother', 'father', 'sister', 'brother', 'grandmother', 'grandfather', 'aunt', 'uncle', 'cousin')) - their_relatives.add(relative) - family_history.update({condition: list(their_relatives)}) - family_history = json.dumps(family_history) - # print(family_history) + # emergency_contacts JSON object (name: [phones]) + emergency_contacts = {} + num_contacts = fake.random_int(min=1, max=2) + their_contacts = set() + while len(their_contacts) < num_contacts: + contact = fake.name() + their_contacts.add(contact) + for contact in their_contacts: + num_phones = fake.random_int(min=1, max=2) + their_phones = set() + while len(their_phones) < num_phones: + phone = fake.random_int(min=1000000000, max=9999999999) + their_phones.add(phone) + emergency_contacts.update({contact: list(their_phones)}) + emergency_contacts = json.dumps(emergency_contacts) + # print(emergency_contacts) - #emergency_contacts JSON object (name: [phones]) - emergency_contacts = {} - num_contacts = fake.random_int(min=1, max=2) - their_contacts = set() - while len(their_contacts) < num_contacts: - contact = fake.name() - their_contacts.add(contact) - for contact in their_contacts: - num_phones = fake.random_int(min=1, max=2) - their_phones = set() - while len(their_phones) < num_phones: - phone = fake.random_int(min=1000000000, max=9999999999) - their_phones.add(phone) - emergency_contacts.update({contact: list(their_phones)}) - emergency_contacts = json.dumps(emergency_contacts) - # print(emergency_contacts) + # medical_history JSON array [conditions] + num_conditions = fake.random_int(min=0, max=5) + their_conditions = set() + while len(their_conditions) < num_conditions: + condition = fake.random_element(elements=medical_conditions) + their_conditions.add(condition) + medical_history = json.dumps(list(their_conditions)) + # print(medical_history) - #medical_history JSON array [conditions] - num_conditions = fake.random_int(min=0, max=5) - their_conditions = set() - while len(their_conditions) < num_conditions: - condition = fake.random_element(elements=medical_conditions) - their_conditions.add(condition) - medical_history = json.dumps(list(their_conditions)) - # print(medical_history) + # legal_guardians JSON array [{name, relationship to patient, phones: [], emails: []}] + legal_guardians = [] + num_guardians = fake.random_int(min=1, max=2) + while len(legal_guardians) < num_guardians: + guardian_gender = fake.random_element(elements=('Male', 'Female')) + if guardian_gender == 'Male': + first_name = fake.first_name_male() + relationship = fake.random_element( + elements=('father', 'grandfather', 'uncle', 'cousin', 'brother')) + else: + first_name = fake.first_name_female() + relationship = fake.random_element( + elements=('mother', 'grandmother', 'aunt', 'cousin', 'sister')) + last_name = fake.last_name() + email = first_name[0].lower() + last_name.lower() + \ + '@' + fake.domain_name() + phone = fake.random_int(min=1000000000, max=9999999999) + legal_guardians.append({'first_name': first_name, 'last_name': last_name, + 'relationship': relationship, 'phones': [phone], 'emails': [email]}) + legal_guardians = json.dumps(list(legal_guardians)) - #legal_guardians JSON array [{name, relationship to patient, phones: [], emails: []}] - legal_guardians = [] - num_guardians = fake.random_int(min=1, max=2) - while len(legal_guardians) < num_guardians: - guardian_gender = fake.random_element(elements=('Male','Female')) - if guardian_gender == 'Male': - first_name = fake.first_name_male() - relationship = fake.random_element(elements=('father', 'grandfather', 'uncle', 'cousin', 'brother')) - else: - first_name = fake.first_name_female() - relationship = fake.random_element(elements=('mother', 'grandmother', 'aunt', 'cousin', 'sister')) - last_name = fake.last_name() - email = first_name[0].lower() + last_name.lower() + '@' + fake.domain_name() - phone = fake.random_int(min=1000000000, max=9999999999) - legal_guardians.append({'first_name': first_name, 'last_name': last_name, 'relationship': relationship, 'phones': [phone], 'emails': [email]}) - legal_guardians = json.dumps(list(legal_guardians)) + pharmacy_name = fake.company() + pharmacy_address = fake.address() + pharmacy_phone = fake.random_int(min=1000000000, max=9999999999) - pharmacy_name = fake.company() - pharmacy_address = fake.address() - pharmacy_phone = fake.random_int(min=1000000000, max=9999999999) + # fake_patient = {'email':email, 'password':password, 'name_title':'NULL', 'first_name':first_name, 'middle_name':'NULL', 'last_name':last_name, 'name_suffix':'NULL', 'date_of_birth':date_of_birth, 'sex':sex, 'gender':gender, 'pronouns':pronouns, 'religion':religion, 'eyesight':eyesight, 'hearing':hearing, 'mobility':mobility, 'is_pregnant':str(is_pregnant).lower(), 'last_menstrual':last_menstrual, 'SSN':SSN, 'height':height, 'weight':weight, 'vaccines':vaccines, 'allergies':allergies, 'surgeries':surgeries, 'family_history':family_history, 'last_reviewed_timestamp':last_reviewed_timestamp, 'emergency_contacts':emergency_contacts, 'last_reviewer_staff_id':'NULL', 'preferred_name':preferred_name, 'blood_type':blood_type, 'phone':phone, 'medical_history':medical_history, 'pharmacy_name':pharmacy_name, 'pharmacy_address':pharmacy_address, 'pharmacy_phone':pharmacy_phone} + return [email, password, 'NULL', first_name, 'NULL', last_name, 'NULL', date_of_birth, sex, gender, pronouns, religion, eyesight, hearing, mobility, str(is_pregnant).lower(), last_menstrual, preferred_name, SSN, height, weight, vaccines, allergies, surgeries, family_history, last_reviewed_timestamp, emergency_contacts, 'NULL', blood_type, phone, medical_history, pharmacy_name, pharmacy_address, pharmacy_phone] - # fake_patient = {'email':email, 'password':password, 'name_title':'NULL', 'first_name':first_name, 'middle_name':'NULL', 'last_name':last_name, 'name_suffix':'NULL', 'date_of_birth':date_of_birth, 'sex':sex, 'gender':gender, 'pronouns':pronouns, 'religion':religion, 'eyesight':eyesight, 'hearing':hearing, 'mobility':mobility, 'is_pregnant':str(is_pregnant).lower(), 'last_menstrual':last_menstrual, 'SSN':SSN, 'height':height, 'weight':weight, 'vaccines':vaccines, 'allergies':allergies, 'surgeries':surgeries, 'family_history':family_history, 'last_reviewed_timestamp':last_reviewed_timestamp, 'emergency_contacts':emergency_contacts, 'last_reviewer_staff_id':'NULL', 'preferred_name':preferred_name, 'blood_type':blood_type, 'phone':phone, 'medical_history':medical_history, 'pharmacy_name':pharmacy_name, 'pharmacy_address':pharmacy_address, 'pharmacy_phone':pharmacy_phone} - return [email, password, 'NULL', first_name, 'NULL', last_name, 'NULL', date_of_birth, sex, gender, pronouns, religion, eyesight, hearing, mobility, str(is_pregnant).lower(), last_menstrual, preferred_name, SSN, height, weight, vaccines, allergies, surgeries, family_history, last_reviewed_timestamp, emergency_contacts, 'NULL', blood_type, phone, medical_history, pharmacy_name, pharmacy_address, pharmacy_phone] -headers = ['email', 'password', 'name_title', 'first_name', 'middle_name', 'last_name', 'name_suffix', 'date_of_birth', 'sex', 'gender', 'pronouns', 'religion', 'eyesight', 'hearing', 'mobility', 'is_pregnant', 'last_menstrual', 'preferred_name', 'SSN', 'height', 'weight', 'vaccines', 'allergies', 'surgeries', 'family_history', 'last_reviewed_timestamp', 'emergency_contacts', 'last_reviewer_staff_id', 'blood_type', 'phone', 'medical_history', 'pharmacy_name', 'pharmacy_address', 'pharmacy_phone'] +headers = ['email', 'password', 'name_title', 'first_name', 'middle_name', 'last_name', 'name_suffix', 'date_of_birth', 'sex', 'gender', 'pronouns', 'religion', 'eyesight', 'hearing', 'mobility', 'is_pregnant', 'last_menstrual', 'preferred_name', 'SSN', + 'height', 'weight', 'vaccines', 'allergies', 'surgeries', 'family_history', 'last_reviewed_timestamp', 'emergency_contacts', 'last_reviewer_staff_id', 'blood_type', 'phone', 'medical_history', 'pharmacy_name', 'pharmacy_address', 'pharmacy_phone'] with open('patients.csv', 'w', newline='') as file: - writer = csv.writer(file) - # writer.writerow(headers) - for i in range(1000): - data = generate_patient_data() - writer.writerow(data) \ No newline at end of file + writer = csv.writer(file) + # writer.writerow(headers) + for i in range(1000): + data = generate_patient_data() + writer.writerow(data) diff --git a/fake_data/patients_staff_join.py b/fake_data/patients_staff_join.py index 7e6e9eb..535239d 100644 --- a/fake_data/patients_staff_join.py +++ b/fake_data/patients_staff_join.py @@ -4,33 +4,33 @@ fake = Faker() -#Assign each patient to a random staff member +# Assign each patient to a random staff member -#save staff_ids in a list +# save staff_ids in a list staff = [] with open('staff_ids.csv') as file: - reader_obj = csv.reader(file) - for row in reader_obj: - staff.append(row[0]) -staff.pop(0) #remove the header -print("staff 1:", staff[0]) #test + reader_obj = csv.reader(file) + for row in reader_obj: + staff.append(row[0]) +staff.pop(0) # remove the header +print("staff 1:", staff[0]) # test num_staff = len(staff) -#pair each patient with a random staff member +# pair each patient with a random staff member patients_staff_join = [] -with open('patient_ids.csv') as file_obj: - reader_obj = csv.reader(file_obj) - for row in reader_obj: - join = { "patient_id": row[0], - "staff_id": staff[randrange(0,num_staff)] - } - patients_staff_join.append(join) -patients_staff_join.pop(0) #remove the header -print("join 1:", patients_staff_join[0]) #test +with open('patient_ids.csv') as file_obj: + reader_obj = csv.reader(file_obj) + for row in reader_obj: + join = {"patient_id": row[0], + "staff_id": staff[randrange(0, num_staff)] + } + patients_staff_join.append(join) +patients_staff_join.pop(0) # remove the header +print("join 1:", patients_staff_join[0]) # test # write patients_staff_join to a new csv file with open('patients_staff_join.csv', 'w', newline='') as csvfile: - writer = csv.writer(csvfile) - writer.writerow(["patient_id", "staff_id"]) - for join in patients_staff_join: - writer.writerow([join["patient_id"], join["staff_id"]]) \ No newline at end of file + writer = csv.writer(csvfile) + writer.writerow(["patient_id", "staff_id"]) + for join in patients_staff_join: + writer.writerow([join["patient_id"], join["staff_id"]]) diff --git a/fake_data/staff.py b/fake_data/staff.py index ab66140..14e8166 100644 --- a/fake_data/staff.py +++ b/fake_data/staff.py @@ -23,46 +23,46 @@ ''' -specialties = [ 'Family Medicine', - 'Internal Medicine', - 'Pediatrics', - 'OB/GYN', - 'Surgery', - 'Neurology', - 'Psychiatry', - 'Plastic Surgery', - 'Otolaryngology', - 'Urology', - 'Anesthesiology', - 'Radiology', - 'Pathology', - 'Emergency Medicine', - 'Critical Care', - 'Preventive Medicine', - 'Physical Medicine and Rehabilitation', - 'Orthopedics', - 'Ophthalmology', - 'Dermatology', - 'Cardiology', - 'Gastroenterology', - 'Pulmonology', - 'Hematology', - 'Oncology', - 'Rheumatology', - 'Endocrinology', - 'Nephrology', - 'Infectious Diseases', - 'Allergy/Immunology', - 'Trauma Surgery', - 'Cardiothoracic Surgery', - 'Vascular Surgery', - 'Gender Surgery', - 'Interventional Cardiology', - 'Reproductive Endocrinology', - 'Neonatology', - 'Pediatric Intensivist', - 'Podiatry', - 'Sports Medicine Doctor'] +specialties = ['Family Medicine', + 'Internal Medicine', + 'Pediatrics', + 'OB/GYN', + 'Surgery', + 'Neurology', + 'Psychiatry', + 'Plastic Surgery', + 'Otolaryngology', + 'Urology', + 'Anesthesiology', + 'Radiology', + 'Pathology', + 'Emergency Medicine', + 'Critical Care', + 'Preventive Medicine', + 'Physical Medicine and Rehabilitation', + 'Orthopedics', + 'Ophthalmology', + 'Dermatology', + 'Cardiology', + 'Gastroenterology', + 'Pulmonology', + 'Hematology', + 'Oncology', + 'Rheumatology', + 'Endocrinology', + 'Nephrology', + 'Infectious Diseases', + 'Allergy/Immunology', + 'Trauma Surgery', + 'Cardiothoracic Surgery', + 'Vascular Surgery', + 'Gender Surgery', + 'Interventional Cardiology', + 'Reproductive Endocrinology', + 'Neonatology', + 'Pediatric Intensivist', + 'Podiatry', + 'Sports Medicine Doctor'] passwords = [] emails = [] @@ -78,10 +78,12 @@ def generate_staff_data(): # name_suffix = fake.suffix() # else: # name_suffix = '' - email = first_name[0].lower() + last_name.lower() + '@' + fake.domain_name() + email = first_name[0].lower() + last_name.lower() + \ + '@' + fake.domain_name() while email in emails: digits = 2 - email = first_name[slice(digits)].lower() + last_name.lower() + '@' + fake.domain_name() + email = first_name[slice(digits)].lower() + \ + last_name.lower() + '@' + fake.domain_name() digits += 1 emails.append(email) phone = fake.random_int(min=1000000000, max=9999999999) @@ -92,13 +94,15 @@ def generate_staff_data(): extra_languages = fake.random_int(min=1, max=2) else: extra_languages = 0 - languages = ["English"] + fake.random_elements(unique="true",length=extra_languages, elements=['Spanish', 'French', 'German', 'Italian', 'Russian', 'Chinese', 'Japanese', 'Korean', 'Arabic', 'Hindi', 'Portuguese']) + languages = ["English"] + fake.random_elements(unique="true", length=extra_languages, elements=[ + 'Spanish', 'French', 'German', 'Italian', 'Russian', 'Chinese', 'Japanese', 'Korean', 'Arabic', 'Hindi', 'Portuguese']) languages = ', '.join(languages) accepting_new = fake.boolean(chance_of_getting_true=70) return [email, password, first_name, last_name, specialty, biography, languages, accepting_new, phone] -header = ['email', 'password', 'first_name', 'last_name', 'specialty', 'biography', 'languages', 'accepting_new', 'phone'] +header = ['email', 'password', 'first_name', 'last_name', + 'specialty', 'biography', 'languages', 'accepting_new', 'phone'] with open('staff.csv', 'w', newline='') as file: writer = csv.writer(file) @@ -107,4 +111,4 @@ def generate_staff_data(): data = generate_staff_data() writer.writerow(data) # print(passwords) - # print(emails) \ No newline at end of file + # print(emails) From 48d5d3f18e36b3918954be96fd2b0e19eca11510 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Thu, 13 Jun 2024 23:23:43 +0000 Subject: [PATCH 2/7] Restyled by black --- fake_data/config.py | 10 +- fake_data/connect.py | 12 +- fake_data/insurances.py | 24 +- fake_data/insurances_patients_join.py | 43 ++- fake_data/offices.py | 51 +++- fake_data/offices_staff_join.py | 18 +- fake_data/patients.py | 400 +++++++++++++++++++++----- fake_data/patients_staff_join.py | 10 +- fake_data/staff.py | 146 ++++++---- 9 files changed, 534 insertions(+), 180 deletions(-) diff --git a/fake_data/config.py b/fake_data/config.py index f5f9fae..4e0eba4 100644 --- a/fake_data/config.py +++ b/fake_data/config.py @@ -2,10 +2,11 @@ import os -def load_config(filename='database.ini', section='postgresql'): +def load_config(filename="database.ini", section="postgresql"): if not os.path.exists(filename): raise FileNotFoundError( - f"{filename} does not exist. Please request access to database.ini from the administrator.") + f"{filename} does not exist. Please request access to database.ini from the administrator." + ) parser = ConfigParser() parser.read(filename) @@ -18,11 +19,12 @@ def load_config(filename='database.ini', section='postgresql'): config[param[0]] = param[1] else: raise Exception( - 'Section {0} not found in the {1} file'.format(section, filename)) + "Section {0} not found in the {1} file".format(section, filename) + ) return config -if __name__ == '__main__': +if __name__ == "__main__": config = load_config() print(config) diff --git a/fake_data/connect.py b/fake_data/connect.py index 603f252..b5d2c55 100644 --- a/fake_data/connect.py +++ b/fake_data/connect.py @@ -5,18 +5,18 @@ def connect(config): - """ Connect to the PostgreSQL database server """ + """Connect to the PostgreSQL database server""" try: # connecting to the PostgreSQL server with psycopg2.connect(**config) as conn: - print('Connected to the PostgreSQL server.') + print("Connected to the PostgreSQL server.") return conn except (psycopg2.DatabaseError, Exception) as error: print(error) def query(operation): - '''Fetch data from the PostgreSQL database server''' + """Fetch data from the PostgreSQL database server""" try: config = load_config() with psycopg2.connect(**config) as conn: @@ -24,7 +24,7 @@ def query(operation): cur.execute(operation) headers = [desc[0] for desc in cur.description] results = cur.fetchall() - with open('query.csv', 'w', newline='') as file: + with open("query.csv", "w", newline="") as file: writer = csv.writer(file) writer.writerow(headers) for item in results: @@ -34,11 +34,11 @@ def query(operation): print(error) -if __name__ == '__main__': +if __name__ == "__main__": # config = load_config() # connect(config) - headers, staff = query('SELECT * FROM staff LIMIT 2;') + headers, staff = query("SELECT * FROM staff LIMIT 2;") # staff = query('SELECT * FROM staff;') # print(headers) # print(staff) diff --git a/fake_data/insurances.py b/fake_data/insurances.py index c323453..03d0874 100644 --- a/fake_data/insurances.py +++ b/fake_data/insurances.py @@ -1,20 +1,28 @@ from faker import Faker import csv + fake = Faker() -''' +""" name VARCHAR UNIQUE phone VARCHAR -''' +""" -insurances_list = ['Aetna', 'Blue Cross Blue Shield', 'Cigna', 'UnitedHealth Group', - 'Centene Corp.', 'Kaiser Permanente', 'Humana', 'Health Care Services Corporation'] +insurances_list = [ + "Aetna", + "Blue Cross Blue Shield", + "Cigna", + "UnitedHealth Group", + "Centene Corp.", + "Kaiser Permanente", + "Humana", + "Health Care Services Corporation", +] -header = ['name', 'phone'] +header = ["name", "phone"] -with open('insurances.csv', 'w', newline='') as file: +with open("insurances.csv", "w", newline="") as file: writer = csv.writer(file) writer.writerow(header) for item in insurances_list: - writer.writerow([item, fake.random_int( - min=1000000000, max=9999999999)]) + writer.writerow([item, fake.random_int(min=1000000000, max=9999999999)]) diff --git a/fake_data/insurances_patients_join.py b/fake_data/insurances_patients_join.py index ca41594..ea3cfa1 100644 --- a/fake_data/insurances_patients_join.py +++ b/fake_data/insurances_patients_join.py @@ -7,7 +7,7 @@ fake = Faker() # Assign patient a random insurance. -''' +""" insurance_id uuid patient_id uuid primary_insured_name varchar @@ -16,14 +16,14 @@ primary_insured_relationship varchar member_number varchar group_number varchar -''' +""" # save insurance_ids in a list def list_insurances(): insurances = [] - with open('insurance_ids.csv') as file: + with open("insurance_ids.csv") as file: reader_obj = csv.reader(file) for row in reader_obj: insurances.append(row[0]) @@ -32,34 +32,47 @@ def list_insurances(): num_insurances = len(insurances) return insurances, num_insurances + # pair each patient with a random insurance def loop_through_patients(insurances, num_insurances): insurances_patients_join = [] - with open('patient_ids.csv') as file_obj: + with open("patient_ids.csv") as file_obj: reader_obj = csv.reader(file_obj) for row in reader_obj: - join = {"patient_id": row[0], - "insurance_id": insurances[randrange(0, num_insurances)], - # "primary_insured_name": fake.name(), - # "primary_insured_birthdate": fake.date_of_birth(), - # "primary_insured_SSN": fake.random_int(min=100000000, max=999999999), - # "primary_insured_relationship": fake.word() - } + join = { + "patient_id": row[0], + "insurance_id": insurances[randrange(0, num_insurances)], + # "primary_insured_name": fake.name(), + # "primary_insured_birthdate": fake.date_of_birth(), + # "primary_insured_SSN": fake.random_int(min=100000000, max=999999999), + # "primary_insured_relationship": fake.word() + } insurances_patients_join.append(join) insurances_patients_join.pop(0) # remove the header print("join 1:", insurances_patients_join[0]) # test return insurances_patients_join + # write offices_patient_join to a new csv file def write_to_join_csv(insurances_patients_join): - with open('insurances_patients_join.csv', 'w', newline='') as csvfile: + with open("insurances_patients_join.csv", "w", newline="") as csvfile: writer = csv.writer(csvfile) - writer.writerow(["insurance_id", "patient_id", 'primary_insured_name', 'primary_insured_birthdate', - 'primary_insured_SSN', 'primary_insured_relationship', 'member_number', 'group_number']) + writer.writerow( + [ + "insurance_id", + "patient_id", + "primary_insured_name", + "primary_insured_birthdate", + "primary_insured_SSN", + "primary_insured_relationship", + "member_number", + "group_number", + ] + ) for join in insurances_patients_join: writer.writerow([join["insurance_id"], join["patient_id"]]) @@ -74,7 +87,7 @@ def query_patient_data(): return patients -if __name__ == '__main__': +if __name__ == "__main__": # insurances, num_insurances = list_insurances() # insurances_patients_join = loop_through_patients(insurances, num_insurances) # write_to_join_csv(insurances_patients_join) diff --git a/fake_data/offices.py b/fake_data/offices.py index fc0cfd3..0321865 100644 --- a/fake_data/offices.py +++ b/fake_data/offices.py @@ -1,8 +1,9 @@ from faker import Faker import csv + fake = Faker() -''' +""" name VARCHAR address_line_1 VARCHAR @@ -17,15 +18,24 @@ hours VARCHAR //there's a syntax for making hours into a string Mo - Fr :00 - :00 Sa - Su :00 - :00 or closed -''' -offices_types = ['Medical', 'Health', 'Group', 'Clinic', 'Memorial Hospital', - 'University Medical Group', 'Medical Center', 'Medical Clinic', 'Health Center'] +""" +offices_types = [ + "Medical", + "Health", + "Group", + "Clinic", + "Memorial Hospital", + "University Medical Group", + "Medical Center", + "Medical Clinic", + "Health Center", +] def generate_office_data(): nameA = fake.city() nameB = fake.random_element(offices_types) - office_name = nameA + ' ' + nameB + office_name = nameA + " " + nameB address_line_1 = fake.street_address() city = nameA state = fake.state_abbr() @@ -38,10 +48,20 @@ def generate_office_data(): end = str(fake.random_int(min=16, max=19)) coin_flip = fake.random_int(min=0, max=1) if coin_flip == 0: - hours = 'Mo - Fr ' + start + ':00 - ' + end + ':00, Sa - Su Closed' + hours = "Mo - Fr " + start + ":00 - " + end + ":00, Sa - Su Closed" else: - hours = 'Mo - Su ' + start + ':00 - ' + end + ':00' - return [office_name, address_line_1, city, state, zipcode, phone, email, website, hours] + hours = "Mo - Su " + start + ":00 - " + end + ":00" + return [ + office_name, + address_line_1, + city, + state, + zipcode, + phone, + email, + website, + hours, + ] # print(office_name) # print(address_line_1) @@ -54,9 +74,18 @@ def generate_office_data(): # print(hours) -header = ['name', 'address_line_1', 'city', 'state', - 'zipcode', 'phone', 'email', 'website', 'hours'] -with open('offices.csv', 'w', newline='') as file: +header = [ + "name", + "address_line_1", + "city", + "state", + "zipcode", + "phone", + "email", + "website", + "hours", +] +with open("offices.csv", "w", newline="") as file: writer = csv.writer(file) writer.writerow(header) for i in range(1000): diff --git a/fake_data/offices_staff_join.py b/fake_data/offices_staff_join.py index 6e1dc9f..6534dbc 100644 --- a/fake_data/offices_staff_join.py +++ b/fake_data/offices_staff_join.py @@ -8,7 +8,7 @@ # save office_ids in a list offices = [] -with open('office_ids.csv') as file: +with open("office_ids.csv") as file: reader_obj = csv.reader(file) for row in reader_obj: offices.append(row[0]) @@ -17,21 +17,21 @@ # pair each staff member with a random office offices_staff_join = [] -with open('staff_ids.csv') as file_obj: +with open("staff_ids.csv") as file_obj: reader_obj = csv.reader(file_obj) for row in reader_obj: - join = {"staff_id": row[0], - "office_id": offices[randrange(1000)], - "is_admin": fake.boolean(chance_of_getting_true=5) - } + join = { + "staff_id": row[0], + "office_id": offices[randrange(1000)], + "is_admin": fake.boolean(chance_of_getting_true=5), + } offices_staff_join.append(join) offices_staff_join.pop(0) # remove the header print("join 1:", offices_staff_join[0]) # test # write offices_staff_join to a new csv file -with open('offices_staff_join.csv', 'w', newline='') as csvfile: +with open("offices_staff_join.csv", "w", newline="") as csvfile: writer = csv.writer(csvfile) writer.writerow(["office_id", "staff_id", "is_admin"]) for join in offices_staff_join: - writer.writerow( - [join["office_id"], join["staff_id"], join["is_admin"]]) + writer.writerow([join["office_id"], join["staff_id"], join["is_admin"]]) diff --git a/fake_data/patients.py b/fake_data/patients.py index 1d9a66a..4775af5 100644 --- a/fake_data/patients.py +++ b/fake_data/patients.py @@ -6,7 +6,7 @@ fake = Faker() -''' +""" email VARCHAR UNIQUE password VARCHAR @@ -48,58 +48,207 @@ pharmacy_name pharmacy_address pharmacy_phone -''' +""" emails = [] -possible_allergens = ['Peanuts', 'Penicillin', 'NSAIDs', 'Iodinated contrast', 'Gadolinium contrast', 'Ester local anesthetics', 'Latex', - 'Soy', 'Dairy', 'Eggs', 'Shellfish', 'Gluten', 'Fish', 'Tree nuts', 'Wheat', 'Sesame', 'Sulfites', 'Corn', 'Kiwi', 'Mango', 'Pineapple'] -possible_reactions = ['Anaphylaxis', 'Hives', 'Rash', 'Itching', 'Swelling', 'Coughing', 'Wheezing', 'Shortness of breath', 'Nausea', 'Vomiting', - 'Diarrhea', 'Abdominal pain', 'Dizziness', 'Fainting', 'Low blood pressure', 'Fast heart rate', 'Confusion', 'Loss of consciousness'] -possible_vaccines = ['COVID-19', 'Influenza', 'Hepatitis A', 'Hepatitis B', 'HPV', 'Measles, Mumps, Rubella', - 'Pneumococcal', 'Polio', 'Tetanus, Diphtheria, Pertussis', 'Varicella', 'Zoster'] -possible_surgeries = ['Appendectomy', 'Cholecystectomy', 'Hernia repair', 'Mastectomy', 'Tonsillectomy', 'Adenoidectomy', 'Cataract surgery', 'Coronary artery bypass', - 'Heart valve repair', 'Hip replacement', 'Knee replacement', 'Spinal fusion', 'Laminectomy', 'Lobectomy', 'Lung transplant', 'Wisdom Teeth Removal', 'ACL repair', 'Rotator cuff repair'] -possible_conditions = ['Heart disease', 'Stroke', 'Diabetes', 'Cancer', 'High blood pressure', 'High cholesterol', 'Asthma', 'Arthritis', 'Osteoporosis', 'Alzheimer\'s', 'Dementia', 'Depression', 'Anxiety', 'Bipolar disorder', 'Schizophrenia', 'ADHD', 'Autism', - 'Epilepsy', 'Migraines', 'Thyroid disease', 'Kidney disease', 'Liver disease', 'Lung disease', 'COPD', 'Crohn\'s disease', 'Ulcerative colitis', 'Celiac disease', 'Multiple sclerosis', 'Lupus', 'Rheumatoid arthritis', 'Psoriasis', 'HIV/AIDS', 'Hepatitis', 'Tuberculosis'] -medical_conditions = ['Asthma', 'Diabetes', 'High blood pressure', 'High cholesterol', 'Heart disease', 'Stroke', 'Cancer', 'Arthritis', 'Osteoporosis', 'Alzheimer\'s', 'Dementia', 'Depression', 'Anxiety', 'Bipolar disorder', 'Schizophrenia', 'ADHD', 'Autism', 'Epilepsy', - 'Migraines', 'Thyroid disease', 'Kidney disease', 'Liver disease', 'Lung disease', 'COPD', 'Crohn\'s disease', 'Ulcerative colitis', 'Celiac disease', 'Multiple sclerosis', 'Lupus', 'Rheumatoid arthritis', 'Psoriasis', 'HIV/AIDS', 'Hepatitis', 'Tuberculosis'] +possible_allergens = [ + "Peanuts", + "Penicillin", + "NSAIDs", + "Iodinated contrast", + "Gadolinium contrast", + "Ester local anesthetics", + "Latex", + "Soy", + "Dairy", + "Eggs", + "Shellfish", + "Gluten", + "Fish", + "Tree nuts", + "Wheat", + "Sesame", + "Sulfites", + "Corn", + "Kiwi", + "Mango", + "Pineapple", +] +possible_reactions = [ + "Anaphylaxis", + "Hives", + "Rash", + "Itching", + "Swelling", + "Coughing", + "Wheezing", + "Shortness of breath", + "Nausea", + "Vomiting", + "Diarrhea", + "Abdominal pain", + "Dizziness", + "Fainting", + "Low blood pressure", + "Fast heart rate", + "Confusion", + "Loss of consciousness", +] +possible_vaccines = [ + "COVID-19", + "Influenza", + "Hepatitis A", + "Hepatitis B", + "HPV", + "Measles, Mumps, Rubella", + "Pneumococcal", + "Polio", + "Tetanus, Diphtheria, Pertussis", + "Varicella", + "Zoster", +] +possible_surgeries = [ + "Appendectomy", + "Cholecystectomy", + "Hernia repair", + "Mastectomy", + "Tonsillectomy", + "Adenoidectomy", + "Cataract surgery", + "Coronary artery bypass", + "Heart valve repair", + "Hip replacement", + "Knee replacement", + "Spinal fusion", + "Laminectomy", + "Lobectomy", + "Lung transplant", + "Wisdom Teeth Removal", + "ACL repair", + "Rotator cuff repair", +] +possible_conditions = [ + "Heart disease", + "Stroke", + "Diabetes", + "Cancer", + "High blood pressure", + "High cholesterol", + "Asthma", + "Arthritis", + "Osteoporosis", + "Alzheimer's", + "Dementia", + "Depression", + "Anxiety", + "Bipolar disorder", + "Schizophrenia", + "ADHD", + "Autism", + "Epilepsy", + "Migraines", + "Thyroid disease", + "Kidney disease", + "Liver disease", + "Lung disease", + "COPD", + "Crohn's disease", + "Ulcerative colitis", + "Celiac disease", + "Multiple sclerosis", + "Lupus", + "Rheumatoid arthritis", + "Psoriasis", + "HIV/AIDS", + "Hepatitis", + "Tuberculosis", +] +medical_conditions = [ + "Asthma", + "Diabetes", + "High blood pressure", + "High cholesterol", + "Heart disease", + "Stroke", + "Cancer", + "Arthritis", + "Osteoporosis", + "Alzheimer's", + "Dementia", + "Depression", + "Anxiety", + "Bipolar disorder", + "Schizophrenia", + "ADHD", + "Autism", + "Epilepsy", + "Migraines", + "Thyroid disease", + "Kidney disease", + "Liver disease", + "Lung disease", + "COPD", + "Crohn's disease", + "Ulcerative colitis", + "Celiac disease", + "Multiple sclerosis", + "Lupus", + "Rheumatoid arthritis", + "Psoriasis", + "HIV/AIDS", + "Hepatitis", + "Tuberculosis", +] def generate_patient_data(): password = fake.password() SSN = fake.random_int(min=100000000, max=999999999) phone = fake.random_int(min=1000000000, max=9999999999) - religion = fake.random_element(elements=( - 'Christian', 'Muslim', 'Jewish', 'Buddhist', 'Hindu', 'Atheist', 'Agnostic', 'Other')) + religion = fake.random_element( + elements=( + "Christian", + "Muslim", + "Jewish", + "Buddhist", + "Hindu", + "Atheist", + "Agnostic", + "Other", + ) + ) eyesight = fake.random_element( - elements=('20/20', '20/40', '20/60', '20/80', '20/100', 'blind')) - hearing = fake.random_element( - elements=('hearing', 'hard of hearing', 'deaf')) + elements=("20/20", "20/40", "20/60", "20/80", "20/100", "blind") + ) + hearing = fake.random_element(elements=("hearing", "hard of hearing", "deaf")) mobility = fake.random_element( - elements=('able', 'wheelchair', 'walker', 'cane', 'crutches')) + elements=("able", "wheelchair", "walker", "cane", "crutches") + ) height = fake.pyfloat(min_value=48, max_value=84, right_digits=2) weight = fake.pyfloat(min_value=110, max_value=270, right_digits=2) blood_type = fake.random_element( - elements=('A+', 'A-', 'B+', 'B-', 'AB+', 'AB-', 'O+', 'O-')) + elements=("A+", "A-", "B+", "B-", "AB+", "AB-", "O+", "O-") + ) date_of_birth = fake.date_of_birth(minimum_age=18, maximum_age=90) days_in_year = 365.2425 age = int((date.today() - date_of_birth).days / days_in_year) last_reviewed_timestamp = fake.date_time_this_year( - before_now=True, after_now=False, tzinfo=tz.gettz('America/Chicago')) + before_now=True, after_now=False, tzinfo=tz.gettz("America/Chicago") + ) # reviewer_staff_id = fake.uuid4() # determine sex and gender (transgender, nonbinary, intersex, cisgender) - preferred_name = 'NULL' # reset later if needed + preferred_name = "NULL" # reset later if needed is_transgender = fake.boolean(chance_of_getting_true=1) if is_transgender: - sex = fake.random_element(elements=('FtM male', 'MtF female')) + sex = fake.random_element(elements=("FtM male", "MtF female")) changed_name = fake.boolean(chance_of_getting_true=30) # if trans male - if (sex == 'FtM male'): - gender = 'male' - pronouns = 'he/him' + if sex == "FtM male": + gender = "male" + pronouns = "he/him" if changed_name: first_name = fake.first_name_male() else: @@ -107,58 +256,73 @@ def generate_patient_data(): preferred_name = fake.first_name_male() # if trans female else: - gender = 'female' - pronouns = 'she/her' + gender = "female" + pronouns = "she/her" if changed_name: first_name = fake.first_name_female() else: first_name = fake.first_name_male() preferred_name = fake.first_name_female() - if changed_name and sex == 'FtM Male': + if changed_name and sex == "FtM Male": first_name = fake.first_name() # if cisgendered else: - sex = fake.random_element(elements=('female', 'male')) - if sex == 'female': + sex = fake.random_element(elements=("female", "male")) + if sex == "female": first_name = fake.first_name_female() - gender = 'female' - pronouns = 'she/her' + gender = "female" + pronouns = "she/her" else: first_name = fake.first_name_male() - gender = 'male' - pronouns = 'he/him' + gender = "male" + pronouns = "he/him" is_nonbinary = fake.boolean(chance_of_getting_true=2) if is_nonbinary: - gender = 'nonbinary' - pronouns = fake.random_element(elements=('they/them', 'she/her', 'he/him', 'she/they', 'he/they', - 'she/they/he', 'he/they/she', 'they/she/he', 'they/he/she', 'they/she', 'they/he', 'she/he')) + gender = "nonbinary" + pronouns = fake.random_element( + elements=( + "they/them", + "she/her", + "he/him", + "she/they", + "he/they", + "she/they/he", + "he/they/she", + "they/she/he", + "they/he/she", + "they/she", + "they/he", + "she/he", + ) + ) is_intersex = fake.boolean(chance_of_getting_true=2) if is_intersex: - sex = 'intersex' + sex = "intersex" # if female anatomy - if sex == 'FtM male' or sex == 'female' or sex == 'intersex': + if sex == "FtM male" or sex == "female" or sex == "intersex": is_pregnant = fake.boolean(chance_of_getting_true=5) if is_pregnant: - last_menstrual = fake.date_between( - start_date='-280d', end_date='today') + last_menstrual = fake.date_between(start_date="-280d", end_date="today") else: - last_menstrual = fake.date_between( - start_date='-28d', end_date='today') + last_menstrual = fake.date_between(start_date="-28d", end_date="today") # if male anatomy else: is_pregnant = False - last_menstrual = 'NULL' + last_menstrual = "NULL" last_name = fake.last_name() - email = first_name[0].lower() + last_name.lower() + \ - '@' + fake.domain_name() + email = first_name[0].lower() + last_name.lower() + "@" + fake.domain_name() while email in emails: digits = 2 - email = first_name[slice(digits)].lower() + \ - last_name.lower() + '@' + fake.domain_name() + email = ( + first_name[slice(digits)].lower() + + last_name.lower() + + "@" + + fake.domain_name() + ) digits += 1 emails.append(email) @@ -187,8 +351,13 @@ def generate_patient_data(): vaccine = fake.random_element(elements=possible_vaccines) their_vaccines.add(vaccine) for vaccine in their_vaccines: - vaccines.update({vaccine: str(fake.date_between( - start_date='-'+str(age)+'y', end_date='today'))}) + vaccines.update( + { + vaccine: str( + fake.date_between(start_date="-" + str(age) + "y", end_date="today") + ) + } + ) vaccines = json.dumps(vaccines) # print(vaccines) @@ -200,8 +369,15 @@ def generate_patient_data(): surgery = fake.random_element(elements=possible_surgeries) their_surgeries.add(surgery) for surgery in their_surgeries: - surgeries.update({surgery: str(fake.date_between( - start_date='-'+str(age-15)+'y', end_date='today'))}) + surgeries.update( + { + surgery: str( + fake.date_between( + start_date="-" + str(age - 15) + "y", end_date="today" + ) + ) + } + ) surgeries = json.dumps(surgeries) # print(surgeries) @@ -216,8 +392,19 @@ def generate_patient_data(): num_relatives = fake.random_int(min=1, max=3) their_relatives = set() while len(their_relatives) < num_relatives: - relative = fake.random_element(elements=( - 'mother', 'father', 'sister', 'brother', 'grandmother', 'grandfather', 'aunt', 'uncle', 'cousin')) + relative = fake.random_element( + elements=( + "mother", + "father", + "sister", + "brother", + "grandmother", + "grandfather", + "aunt", + "uncle", + "cousin", + ) + ) their_relatives.add(relative) family_history.update({condition: list(their_relatives)}) family_history = json.dumps(family_history) @@ -253,21 +440,29 @@ def generate_patient_data(): legal_guardians = [] num_guardians = fake.random_int(min=1, max=2) while len(legal_guardians) < num_guardians: - guardian_gender = fake.random_element(elements=('Male', 'Female')) - if guardian_gender == 'Male': + guardian_gender = fake.random_element(elements=("Male", "Female")) + if guardian_gender == "Male": first_name = fake.first_name_male() relationship = fake.random_element( - elements=('father', 'grandfather', 'uncle', 'cousin', 'brother')) + elements=("father", "grandfather", "uncle", "cousin", "brother") + ) else: first_name = fake.first_name_female() relationship = fake.random_element( - elements=('mother', 'grandmother', 'aunt', 'cousin', 'sister')) + elements=("mother", "grandmother", "aunt", "cousin", "sister") + ) last_name = fake.last_name() - email = first_name[0].lower() + last_name.lower() + \ - '@' + fake.domain_name() + email = first_name[0].lower() + last_name.lower() + "@" + fake.domain_name() phone = fake.random_int(min=1000000000, max=9999999999) - legal_guardians.append({'first_name': first_name, 'last_name': last_name, - 'relationship': relationship, 'phones': [phone], 'emails': [email]}) + legal_guardians.append( + { + "first_name": first_name, + "last_name": last_name, + "relationship": relationship, + "phones": [phone], + "emails": [email], + } + ) legal_guardians = json.dumps(list(legal_guardians)) pharmacy_name = fake.company() @@ -275,13 +470,82 @@ def generate_patient_data(): pharmacy_phone = fake.random_int(min=1000000000, max=9999999999) # fake_patient = {'email':email, 'password':password, 'name_title':'NULL', 'first_name':first_name, 'middle_name':'NULL', 'last_name':last_name, 'name_suffix':'NULL', 'date_of_birth':date_of_birth, 'sex':sex, 'gender':gender, 'pronouns':pronouns, 'religion':religion, 'eyesight':eyesight, 'hearing':hearing, 'mobility':mobility, 'is_pregnant':str(is_pregnant).lower(), 'last_menstrual':last_menstrual, 'SSN':SSN, 'height':height, 'weight':weight, 'vaccines':vaccines, 'allergies':allergies, 'surgeries':surgeries, 'family_history':family_history, 'last_reviewed_timestamp':last_reviewed_timestamp, 'emergency_contacts':emergency_contacts, 'last_reviewer_staff_id':'NULL', 'preferred_name':preferred_name, 'blood_type':blood_type, 'phone':phone, 'medical_history':medical_history, 'pharmacy_name':pharmacy_name, 'pharmacy_address':pharmacy_address, 'pharmacy_phone':pharmacy_phone} - return [email, password, 'NULL', first_name, 'NULL', last_name, 'NULL', date_of_birth, sex, gender, pronouns, religion, eyesight, hearing, mobility, str(is_pregnant).lower(), last_menstrual, preferred_name, SSN, height, weight, vaccines, allergies, surgeries, family_history, last_reviewed_timestamp, emergency_contacts, 'NULL', blood_type, phone, medical_history, pharmacy_name, pharmacy_address, pharmacy_phone] + return [ + email, + password, + "NULL", + first_name, + "NULL", + last_name, + "NULL", + date_of_birth, + sex, + gender, + pronouns, + religion, + eyesight, + hearing, + mobility, + str(is_pregnant).lower(), + last_menstrual, + preferred_name, + SSN, + height, + weight, + vaccines, + allergies, + surgeries, + family_history, + last_reviewed_timestamp, + emergency_contacts, + "NULL", + blood_type, + phone, + medical_history, + pharmacy_name, + pharmacy_address, + pharmacy_phone, + ] -headers = ['email', 'password', 'name_title', 'first_name', 'middle_name', 'last_name', 'name_suffix', 'date_of_birth', 'sex', 'gender', 'pronouns', 'religion', 'eyesight', 'hearing', 'mobility', 'is_pregnant', 'last_menstrual', 'preferred_name', 'SSN', - 'height', 'weight', 'vaccines', 'allergies', 'surgeries', 'family_history', 'last_reviewed_timestamp', 'emergency_contacts', 'last_reviewer_staff_id', 'blood_type', 'phone', 'medical_history', 'pharmacy_name', 'pharmacy_address', 'pharmacy_phone'] +headers = [ + "email", + "password", + "name_title", + "first_name", + "middle_name", + "last_name", + "name_suffix", + "date_of_birth", + "sex", + "gender", + "pronouns", + "religion", + "eyesight", + "hearing", + "mobility", + "is_pregnant", + "last_menstrual", + "preferred_name", + "SSN", + "height", + "weight", + "vaccines", + "allergies", + "surgeries", + "family_history", + "last_reviewed_timestamp", + "emergency_contacts", + "last_reviewer_staff_id", + "blood_type", + "phone", + "medical_history", + "pharmacy_name", + "pharmacy_address", + "pharmacy_phone", +] -with open('patients.csv', 'w', newline='') as file: +with open("patients.csv", "w", newline="") as file: writer = csv.writer(file) # writer.writerow(headers) for i in range(1000): diff --git a/fake_data/patients_staff_join.py b/fake_data/patients_staff_join.py index 535239d..623a71a 100644 --- a/fake_data/patients_staff_join.py +++ b/fake_data/patients_staff_join.py @@ -8,7 +8,7 @@ # save staff_ids in a list staff = [] -with open('staff_ids.csv') as file: +with open("staff_ids.csv") as file: reader_obj = csv.reader(file) for row in reader_obj: staff.append(row[0]) @@ -18,18 +18,16 @@ # pair each patient with a random staff member patients_staff_join = [] -with open('patient_ids.csv') as file_obj: +with open("patient_ids.csv") as file_obj: reader_obj = csv.reader(file_obj) for row in reader_obj: - join = {"patient_id": row[0], - "staff_id": staff[randrange(0, num_staff)] - } + join = {"patient_id": row[0], "staff_id": staff[randrange(0, num_staff)]} patients_staff_join.append(join) patients_staff_join.pop(0) # remove the header print("join 1:", patients_staff_join[0]) # test # write patients_staff_join to a new csv file -with open('patients_staff_join.csv', 'w', newline='') as csvfile: +with open("patients_staff_join.csv", "w", newline="") as csvfile: writer = csv.writer(csvfile) writer.writerow(["patient_id", "staff_id"]) for join in patients_staff_join: diff --git a/fake_data/staff.py b/fake_data/staff.py index 14e8166..e728bfa 100644 --- a/fake_data/staff.py +++ b/fake_data/staff.py @@ -1,8 +1,9 @@ from faker import Faker import csv + fake = Faker() -''' +""" email VARCHAR UNIQUE password VARCHAR @@ -21,48 +22,50 @@ services VARCHAR licenses VARCHAR -''' +""" -specialties = ['Family Medicine', - 'Internal Medicine', - 'Pediatrics', - 'OB/GYN', - 'Surgery', - 'Neurology', - 'Psychiatry', - 'Plastic Surgery', - 'Otolaryngology', - 'Urology', - 'Anesthesiology', - 'Radiology', - 'Pathology', - 'Emergency Medicine', - 'Critical Care', - 'Preventive Medicine', - 'Physical Medicine and Rehabilitation', - 'Orthopedics', - 'Ophthalmology', - 'Dermatology', - 'Cardiology', - 'Gastroenterology', - 'Pulmonology', - 'Hematology', - 'Oncology', - 'Rheumatology', - 'Endocrinology', - 'Nephrology', - 'Infectious Diseases', - 'Allergy/Immunology', - 'Trauma Surgery', - 'Cardiothoracic Surgery', - 'Vascular Surgery', - 'Gender Surgery', - 'Interventional Cardiology', - 'Reproductive Endocrinology', - 'Neonatology', - 'Pediatric Intensivist', - 'Podiatry', - 'Sports Medicine Doctor'] +specialties = [ + "Family Medicine", + "Internal Medicine", + "Pediatrics", + "OB/GYN", + "Surgery", + "Neurology", + "Psychiatry", + "Plastic Surgery", + "Otolaryngology", + "Urology", + "Anesthesiology", + "Radiology", + "Pathology", + "Emergency Medicine", + "Critical Care", + "Preventive Medicine", + "Physical Medicine and Rehabilitation", + "Orthopedics", + "Ophthalmology", + "Dermatology", + "Cardiology", + "Gastroenterology", + "Pulmonology", + "Hematology", + "Oncology", + "Rheumatology", + "Endocrinology", + "Nephrology", + "Infectious Diseases", + "Allergy/Immunology", + "Trauma Surgery", + "Cardiothoracic Surgery", + "Vascular Surgery", + "Gender Surgery", + "Interventional Cardiology", + "Reproductive Endocrinology", + "Neonatology", + "Pediatric Intensivist", + "Podiatry", + "Sports Medicine Doctor", +] passwords = [] emails = [] @@ -78,12 +81,15 @@ def generate_staff_data(): # name_suffix = fake.suffix() # else: # name_suffix = '' - email = first_name[0].lower() + last_name.lower() + \ - '@' + fake.domain_name() + email = first_name[0].lower() + last_name.lower() + "@" + fake.domain_name() while email in emails: digits = 2 - email = first_name[slice(digits)].lower() + \ - last_name.lower() + '@' + fake.domain_name() + email = ( + first_name[slice(digits)].lower() + + last_name.lower() + + "@" + + fake.domain_name() + ) digits += 1 emails.append(email) phone = fake.random_int(min=1000000000, max=9999999999) @@ -94,17 +100,51 @@ def generate_staff_data(): extra_languages = fake.random_int(min=1, max=2) else: extra_languages = 0 - languages = ["English"] + fake.random_elements(unique="true", length=extra_languages, elements=[ - 'Spanish', 'French', 'German', 'Italian', 'Russian', 'Chinese', 'Japanese', 'Korean', 'Arabic', 'Hindi', 'Portuguese']) - languages = ', '.join(languages) + languages = ["English"] + fake.random_elements( + unique="true", + length=extra_languages, + elements=[ + "Spanish", + "French", + "German", + "Italian", + "Russian", + "Chinese", + "Japanese", + "Korean", + "Arabic", + "Hindi", + "Portuguese", + ], + ) + languages = ", ".join(languages) accepting_new = fake.boolean(chance_of_getting_true=70) - return [email, password, first_name, last_name, specialty, biography, languages, accepting_new, phone] + return [ + email, + password, + first_name, + last_name, + specialty, + biography, + languages, + accepting_new, + phone, + ] -header = ['email', 'password', 'first_name', 'last_name', - 'specialty', 'biography', 'languages', 'accepting_new', 'phone'] +header = [ + "email", + "password", + "first_name", + "last_name", + "specialty", + "biography", + "languages", + "accepting_new", + "phone", +] -with open('staff.csv', 'w', newline='') as file: +with open("staff.csv", "w", newline="") as file: writer = csv.writer(file) writer.writerow(header) for i in range(1000): From 6bc47a7a656e9187849da316b227dd82ef137e4a Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Thu, 13 Jun 2024 23:23:51 +0000 Subject: [PATCH 3/7] Restyled by isort --- fake_data/config.py | 2 +- fake_data/connect.py | 3 ++- fake_data/insurances.py | 3 ++- fake_data/insurances_patients_join.py | 5 +++-- fake_data/offices.py | 3 ++- fake_data/offices_staff_join.py | 3 ++- fake_data/patients.py | 5 +++-- fake_data/patients_staff_join.py | 3 ++- fake_data/staff.py | 3 ++- 9 files changed, 19 insertions(+), 11 deletions(-) diff --git a/fake_data/config.py b/fake_data/config.py index 4e0eba4..addd826 100644 --- a/fake_data/config.py +++ b/fake_data/config.py @@ -1,5 +1,5 @@ -from configparser import ConfigParser import os +from configparser import ConfigParser def load_config(filename="database.ini", section="postgresql"): diff --git a/fake_data/connect.py b/fake_data/connect.py index b5d2c55..92ac444 100644 --- a/fake_data/connect.py +++ b/fake_data/connect.py @@ -1,7 +1,8 @@ +import csv + import psycopg2 from config import load_config from tabulate import tabulate -import csv def connect(config): diff --git a/fake_data/insurances.py b/fake_data/insurances.py index 03d0874..74ee9f5 100644 --- a/fake_data/insurances.py +++ b/fake_data/insurances.py @@ -1,6 +1,7 @@ -from faker import Faker import csv +from faker import Faker + fake = Faker() """ diff --git a/fake_data/insurances_patients_join.py b/fake_data/insurances_patients_join.py index ea3cfa1..36b4921 100644 --- a/fake_data/insurances_patients_join.py +++ b/fake_data/insurances_patients_join.py @@ -1,8 +1,9 @@ -from random import randrange import csv -from faker import Faker +from random import randrange + import psycopg2 from config import load_config +from faker import Faker fake = Faker() diff --git a/fake_data/offices.py b/fake_data/offices.py index 0321865..e5c11f9 100644 --- a/fake_data/offices.py +++ b/fake_data/offices.py @@ -1,6 +1,7 @@ -from faker import Faker import csv +from faker import Faker + fake = Faker() """ diff --git a/fake_data/offices_staff_join.py b/fake_data/offices_staff_join.py index 6534dbc..e01b141 100644 --- a/fake_data/offices_staff_join.py +++ b/fake_data/offices_staff_join.py @@ -1,5 +1,6 @@ -from random import randrange import csv +from random import randrange + from faker import Faker fake = Faker() diff --git a/fake_data/patients.py b/fake_data/patients.py index 4775af5..2ffcfa5 100644 --- a/fake_data/patients.py +++ b/fake_data/patients.py @@ -1,8 +1,9 @@ -from faker import Faker import csv +import json from datetime import date + from dateutil import tz -import json +from faker import Faker fake = Faker() diff --git a/fake_data/patients_staff_join.py b/fake_data/patients_staff_join.py index 623a71a..4a405b9 100644 --- a/fake_data/patients_staff_join.py +++ b/fake_data/patients_staff_join.py @@ -1,5 +1,6 @@ -from random import randrange import csv +from random import randrange + from faker import Faker fake = Faker() diff --git a/fake_data/staff.py b/fake_data/staff.py index e728bfa..d193c8e 100644 --- a/fake_data/staff.py +++ b/fake_data/staff.py @@ -1,6 +1,7 @@ -from faker import Faker import csv +from faker import Faker + fake = Faker() """ From 9f0bcd830ad9b57cfd264da7d029471377d2ee28 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Thu, 13 Jun 2024 23:23:53 +0000 Subject: [PATCH 4/7] Restyled by prettier-markdown --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index b206fa5..c33b884 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,9 @@ # MediMemo-DevWeek2024 - This application is currently in development. Our goal is to create a health app that prevents the loss of patient data during data entry due to network loss and seamlessly updates patient files once the connection is restored. +This application is currently in development. Our goal is to create a health app that prevents the loss of patient data during data entry due to network loss and seamlessly updates patient files once the connection is restored. ## Anticipated Features: + - Scheduling Tool - Data Entry Tool - Patient History Viewer @@ -31,9 +32,8 @@ - To query the database with SQL commands, you must be given the login credientials by an administrator. - Then you can use the **query** function defined in **fake_data/connect.py**: - - from fake_data.connect import query - - query("SELECT * FROM patients LIMIT 5") - - results will populate in query.csv + - from fake_data.connect import query + - query("SELECT \* FROM patients LIMIT 5") + - results will populate in query.csv ### Thank you!! - From 2cce6ef1debde729e1f077467c3bfe5a6619ecad Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Thu, 13 Jun 2024 23:24:03 +0000 Subject: [PATCH 5/7] Restyled by pyment --- fake_data/config.py | 6 ++++++ fake_data/connect.py | 12 ++++++++++-- fake_data/insurances_patients_join.py | 13 +++++++++++++ fake_data/offices.py | 1 + fake_data/patients.py | 1 + fake_data/staff.py | 1 + 6 files changed, 32 insertions(+), 2 deletions(-) diff --git a/fake_data/config.py b/fake_data/config.py index addd826..1f71a38 100644 --- a/fake_data/config.py +++ b/fake_data/config.py @@ -3,6 +3,12 @@ def load_config(filename="database.ini", section="postgresql"): + """ + + :param filename: (Default value = "database.ini") + :param section: (Default value = "postgresql") + + """ if not os.path.exists(filename): raise FileNotFoundError( f"{filename} does not exist. Please request access to database.ini from the administrator." diff --git a/fake_data/connect.py b/fake_data/connect.py index 92ac444..1cb6ac7 100644 --- a/fake_data/connect.py +++ b/fake_data/connect.py @@ -6,7 +6,11 @@ def connect(config): - """Connect to the PostgreSQL database server""" + """Connect to the PostgreSQL database server + + :param config: + + """ try: # connecting to the PostgreSQL server with psycopg2.connect(**config) as conn: @@ -17,7 +21,11 @@ def connect(config): def query(operation): - """Fetch data from the PostgreSQL database server""" + """Fetch data from the PostgreSQL database server + + :param operation: + + """ try: config = load_config() with psycopg2.connect(**config) as conn: diff --git a/fake_data/insurances_patients_join.py b/fake_data/insurances_patients_join.py index 36b4921..3c46cde 100644 --- a/fake_data/insurances_patients_join.py +++ b/fake_data/insurances_patients_join.py @@ -23,6 +23,7 @@ def list_insurances(): + """ """ insurances = [] with open("insurance_ids.csv") as file: reader_obj = csv.reader(file) @@ -38,6 +39,12 @@ def list_insurances(): def loop_through_patients(insurances, num_insurances): + """ + + :param insurances: + :param num_insurances: + + """ insurances_patients_join = [] with open("patient_ids.csv") as file_obj: reader_obj = csv.reader(file_obj) @@ -60,6 +67,11 @@ def loop_through_patients(insurances, num_insurances): def write_to_join_csv(insurances_patients_join): + """ + + :param insurances_patients_join: + + """ with open("insurances_patients_join.csv", "w", newline="") as csvfile: writer = csv.writer(csvfile) writer.writerow( @@ -79,6 +91,7 @@ def write_to_join_csv(insurances_patients_join): def query_patient_data(): + """ """ config = load_config() with psycopg2.connect(**config) as conn: with conn.cursor() as cur: diff --git a/fake_data/offices.py b/fake_data/offices.py index e5c11f9..5213503 100644 --- a/fake_data/offices.py +++ b/fake_data/offices.py @@ -34,6 +34,7 @@ def generate_office_data(): + """ """ nameA = fake.city() nameB = fake.random_element(offices_types) office_name = nameA + " " + nameB diff --git a/fake_data/patients.py b/fake_data/patients.py index 2ffcfa5..b0d34ae 100644 --- a/fake_data/patients.py +++ b/fake_data/patients.py @@ -203,6 +203,7 @@ def generate_patient_data(): + """ """ password = fake.password() SSN = fake.random_int(min=100000000, max=999999999) phone = fake.random_int(min=1000000000, max=9999999999) diff --git a/fake_data/staff.py b/fake_data/staff.py index d193c8e..7e7878b 100644 --- a/fake_data/staff.py +++ b/fake_data/staff.py @@ -73,6 +73,7 @@ def generate_staff_data(): + """ """ password = fake.password() # name_title = fake.prefix() first_name = fake.first_name() From f8949a455fb04128a933d9d423b1e67363a1f4e9 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Thu, 13 Jun 2024 23:24:07 +0000 Subject: [PATCH 6/7] Restyled by whitespace --- fake_data/connect.py | 4 ++-- fake_data/insurances_patients_join.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fake_data/connect.py b/fake_data/connect.py index 1cb6ac7..0c8e52c 100644 --- a/fake_data/connect.py +++ b/fake_data/connect.py @@ -8,7 +8,7 @@ def connect(config): """Connect to the PostgreSQL database server - :param config: + :param config: """ try: @@ -23,7 +23,7 @@ def connect(config): def query(operation): """Fetch data from the PostgreSQL database server - :param operation: + :param operation: """ try: diff --git a/fake_data/insurances_patients_join.py b/fake_data/insurances_patients_join.py index 3c46cde..54ed846 100644 --- a/fake_data/insurances_patients_join.py +++ b/fake_data/insurances_patients_join.py @@ -41,8 +41,8 @@ def list_insurances(): def loop_through_patients(insurances, num_insurances): """ - :param insurances: - :param num_insurances: + :param insurances: + :param num_insurances: """ insurances_patients_join = [] @@ -69,7 +69,7 @@ def loop_through_patients(insurances, num_insurances): def write_to_join_csv(insurances_patients_join): """ - :param insurances_patients_join: + :param insurances_patients_join: """ with open("insurances_patients_join.csv", "w", newline="") as csvfile: From 5f505e397ac0a3bb3a2548c454a8708ffbf06a8e Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Thu, 13 Jun 2024 23:24:12 +0000 Subject: [PATCH 7/7] Restyled by yapf --- fake_data/config.py | 5 +- fake_data/insurances.py | 4 +- fake_data/insurances_patients_join.py | 22 ++-- fake_data/offices.py | 1 - fake_data/offices_staff_join.py | 3 +- fake_data/patients.py | 175 ++++++++++++-------------- fake_data/patients_staff_join.py | 5 +- fake_data/staff.py | 12 +- 8 files changed, 104 insertions(+), 123 deletions(-) diff --git a/fake_data/config.py b/fake_data/config.py index 1f71a38..eb74c61 100644 --- a/fake_data/config.py +++ b/fake_data/config.py @@ -24,9 +24,8 @@ def load_config(filename="database.ini", section="postgresql"): for param in params: config[param[0]] = param[1] else: - raise Exception( - "Section {0} not found in the {1} file".format(section, filename) - ) + raise Exception("Section {0} not found in the {1} file".format( + section, filename)) return config diff --git a/fake_data/insurances.py b/fake_data/insurances.py index 74ee9f5..b244447 100644 --- a/fake_data/insurances.py +++ b/fake_data/insurances.py @@ -3,7 +3,6 @@ from faker import Faker fake = Faker() - """ name VARCHAR UNIQUE phone VARCHAR @@ -26,4 +25,5 @@ writer = csv.writer(file) writer.writerow(header) for item in insurances_list: - writer.writerow([item, fake.random_int(min=1000000000, max=9999999999)]) + writer.writerow( + [item, fake.random_int(min=1000000000, max=9999999999)]) diff --git a/fake_data/insurances_patients_join.py b/fake_data/insurances_patients_join.py index 54ed846..6460d8f 100644 --- a/fake_data/insurances_patients_join.py +++ b/fake_data/insurances_patients_join.py @@ -74,18 +74,16 @@ def write_to_join_csv(insurances_patients_join): """ with open("insurances_patients_join.csv", "w", newline="") as csvfile: writer = csv.writer(csvfile) - writer.writerow( - [ - "insurance_id", - "patient_id", - "primary_insured_name", - "primary_insured_birthdate", - "primary_insured_SSN", - "primary_insured_relationship", - "member_number", - "group_number", - ] - ) + writer.writerow([ + "insurance_id", + "patient_id", + "primary_insured_name", + "primary_insured_birthdate", + "primary_insured_SSN", + "primary_insured_relationship", + "member_number", + "group_number", + ]) for join in insurances_patients_join: writer.writerow([join["insurance_id"], join["patient_id"]]) diff --git a/fake_data/offices.py b/fake_data/offices.py index 5213503..8e71dc1 100644 --- a/fake_data/offices.py +++ b/fake_data/offices.py @@ -3,7 +3,6 @@ from faker import Faker fake = Faker() - """ name VARCHAR diff --git a/fake_data/offices_staff_join.py b/fake_data/offices_staff_join.py index e01b141..ff691d9 100644 --- a/fake_data/offices_staff_join.py +++ b/fake_data/offices_staff_join.py @@ -35,4 +35,5 @@ writer = csv.writer(csvfile) writer.writerow(["office_id", "staff_id", "is_admin"]) for join in offices_staff_join: - writer.writerow([join["office_id"], join["staff_id"], join["is_admin"]]) + writer.writerow( + [join["office_id"], join["staff_id"], join["is_admin"]]) diff --git a/fake_data/patients.py b/fake_data/patients.py index b0d34ae..dcff0a4 100644 --- a/fake_data/patients.py +++ b/fake_data/patients.py @@ -6,7 +6,6 @@ from faker import Faker fake = Faker() - """ email VARCHAR UNIQUE password VARCHAR @@ -207,38 +206,33 @@ def generate_patient_data(): password = fake.password() SSN = fake.random_int(min=100000000, max=999999999) phone = fake.random_int(min=1000000000, max=9999999999) - religion = fake.random_element( - elements=( - "Christian", - "Muslim", - "Jewish", - "Buddhist", - "Hindu", - "Atheist", - "Agnostic", - "Other", - ) - ) - eyesight = fake.random_element( - elements=("20/20", "20/40", "20/60", "20/80", "20/100", "blind") - ) - hearing = fake.random_element(elements=("hearing", "hard of hearing", "deaf")) - mobility = fake.random_element( - elements=("able", "wheelchair", "walker", "cane", "crutches") - ) + religion = fake.random_element(elements=( + "Christian", + "Muslim", + "Jewish", + "Buddhist", + "Hindu", + "Atheist", + "Agnostic", + "Other", + )) + eyesight = fake.random_element(elements=("20/20", "20/40", "20/60", + "20/80", "20/100", "blind")) + hearing = fake.random_element(elements=("hearing", "hard of hearing", + "deaf")) + mobility = fake.random_element(elements=("able", "wheelchair", "walker", + "cane", "crutches")) height = fake.pyfloat(min_value=48, max_value=84, right_digits=2) weight = fake.pyfloat(min_value=110, max_value=270, right_digits=2) - blood_type = fake.random_element( - elements=("A+", "A-", "B+", "B-", "AB+", "AB-", "O+", "O-") - ) + blood_type = fake.random_element(elements=("A+", "A-", "B+", "B-", "AB+", + "AB-", "O+", "O-")) date_of_birth = fake.date_of_birth(minimum_age=18, maximum_age=90) days_in_year = 365.2425 age = int((date.today() - date_of_birth).days / days_in_year) last_reviewed_timestamp = fake.date_time_this_year( - before_now=True, after_now=False, tzinfo=tz.gettz("America/Chicago") - ) + before_now=True, after_now=False, tzinfo=tz.gettz("America/Chicago")) # reviewer_staff_id = fake.uuid4() # determine sex and gender (transgender, nonbinary, intersex, cisgender) @@ -282,22 +276,20 @@ def generate_patient_data(): is_nonbinary = fake.boolean(chance_of_getting_true=2) if is_nonbinary: gender = "nonbinary" - pronouns = fake.random_element( - elements=( - "they/them", - "she/her", - "he/him", - "she/they", - "he/they", - "she/they/he", - "he/they/she", - "they/she/he", - "they/he/she", - "they/she", - "they/he", - "she/he", - ) - ) + pronouns = fake.random_element(elements=( + "they/them", + "she/her", + "he/him", + "she/they", + "he/they", + "she/they/he", + "he/they/she", + "they/she/he", + "they/he/she", + "they/she", + "they/he", + "she/he", + )) is_intersex = fake.boolean(chance_of_getting_true=2) if is_intersex: @@ -307,24 +299,23 @@ def generate_patient_data(): if sex == "FtM male" or sex == "female" or sex == "intersex": is_pregnant = fake.boolean(chance_of_getting_true=5) if is_pregnant: - last_menstrual = fake.date_between(start_date="-280d", end_date="today") + last_menstrual = fake.date_between(start_date="-280d", + end_date="today") else: - last_menstrual = fake.date_between(start_date="-28d", end_date="today") + last_menstrual = fake.date_between(start_date="-28d", + end_date="today") # if male anatomy else: is_pregnant = False last_menstrual = "NULL" last_name = fake.last_name() - email = first_name[0].lower() + last_name.lower() + "@" + fake.domain_name() + email = first_name[0].lower() + last_name.lower() + "@" + fake.domain_name( + ) while email in emails: digits = 2 - email = ( - first_name[slice(digits)].lower() - + last_name.lower() - + "@" - + fake.domain_name() - ) + email = (first_name[slice(digits)].lower() + last_name.lower() + "@" + + fake.domain_name()) digits += 1 emails.append(email) @@ -353,13 +344,12 @@ def generate_patient_data(): vaccine = fake.random_element(elements=possible_vaccines) their_vaccines.add(vaccine) for vaccine in their_vaccines: - vaccines.update( - { - vaccine: str( - fake.date_between(start_date="-" + str(age) + "y", end_date="today") - ) - } - ) + vaccines.update({ + vaccine: + str( + fake.date_between(start_date="-" + str(age) + "y", + end_date="today")) + }) vaccines = json.dumps(vaccines) # print(vaccines) @@ -371,15 +361,12 @@ def generate_patient_data(): surgery = fake.random_element(elements=possible_surgeries) their_surgeries.add(surgery) for surgery in their_surgeries: - surgeries.update( - { - surgery: str( - fake.date_between( - start_date="-" + str(age - 15) + "y", end_date="today" - ) - ) - } - ) + surgeries.update({ + surgery: + str( + fake.date_between(start_date="-" + str(age - 15) + "y", + end_date="today")) + }) surgeries = json.dumps(surgeries) # print(surgeries) @@ -394,19 +381,17 @@ def generate_patient_data(): num_relatives = fake.random_int(min=1, max=3) their_relatives = set() while len(their_relatives) < num_relatives: - relative = fake.random_element( - elements=( - "mother", - "father", - "sister", - "brother", - "grandmother", - "grandfather", - "aunt", - "uncle", - "cousin", - ) - ) + relative = fake.random_element(elements=( + "mother", + "father", + "sister", + "brother", + "grandmother", + "grandfather", + "aunt", + "uncle", + "cousin", + )) their_relatives.add(relative) family_history.update({condition: list(their_relatives)}) family_history = json.dumps(family_history) @@ -445,26 +430,26 @@ def generate_patient_data(): guardian_gender = fake.random_element(elements=("Male", "Female")) if guardian_gender == "Male": first_name = fake.first_name_male() - relationship = fake.random_element( - elements=("father", "grandfather", "uncle", "cousin", "brother") - ) + relationship = fake.random_element(elements=("father", + "grandfather", + "uncle", "cousin", + "brother")) else: first_name = fake.first_name_female() - relationship = fake.random_element( - elements=("mother", "grandmother", "aunt", "cousin", "sister") - ) + relationship = fake.random_element(elements=("mother", + "grandmother", "aunt", + "cousin", "sister")) last_name = fake.last_name() - email = first_name[0].lower() + last_name.lower() + "@" + fake.domain_name() + email = first_name[0].lower() + last_name.lower( + ) + "@" + fake.domain_name() phone = fake.random_int(min=1000000000, max=9999999999) - legal_guardians.append( - { - "first_name": first_name, - "last_name": last_name, - "relationship": relationship, - "phones": [phone], - "emails": [email], - } - ) + legal_guardians.append({ + "first_name": first_name, + "last_name": last_name, + "relationship": relationship, + "phones": [phone], + "emails": [email], + }) legal_guardians = json.dumps(list(legal_guardians)) pharmacy_name = fake.company() diff --git a/fake_data/patients_staff_join.py b/fake_data/patients_staff_join.py index 4a405b9..d03e313 100644 --- a/fake_data/patients_staff_join.py +++ b/fake_data/patients_staff_join.py @@ -22,7 +22,10 @@ with open("patient_ids.csv") as file_obj: reader_obj = csv.reader(file_obj) for row in reader_obj: - join = {"patient_id": row[0], "staff_id": staff[randrange(0, num_staff)]} + join = { + "patient_id": row[0], + "staff_id": staff[randrange(0, num_staff)] + } patients_staff_join.append(join) patients_staff_join.pop(0) # remove the header print("join 1:", patients_staff_join[0]) # test diff --git a/fake_data/staff.py b/fake_data/staff.py index 7e7878b..a9c6c89 100644 --- a/fake_data/staff.py +++ b/fake_data/staff.py @@ -3,7 +3,6 @@ from faker import Faker fake = Faker() - """ email VARCHAR UNIQUE password VARCHAR @@ -83,15 +82,12 @@ def generate_staff_data(): # name_suffix = fake.suffix() # else: # name_suffix = '' - email = first_name[0].lower() + last_name.lower() + "@" + fake.domain_name() + email = first_name[0].lower() + last_name.lower() + "@" + fake.domain_name( + ) while email in emails: digits = 2 - email = ( - first_name[slice(digits)].lower() - + last_name.lower() - + "@" - + fake.domain_name() - ) + email = (first_name[slice(digits)].lower() + last_name.lower() + "@" + + fake.domain_name()) digits += 1 emails.append(email) phone = fake.random_int(min=1000000000, max=9999999999)