-
-
Notifications
You must be signed in to change notification settings - Fork 122
Fix/missing profile foreign keys #142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 5 commits
052d931
6532cc3
f9e0cc8
3135a2a
fd6db51
ac69792
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| .qodo | ||
| .qodo |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| FLASK_APP=app.py | ||
| FLASK_ENV=development | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,105 +1,84 @@ | ||
| { | ||
| "current_week": 40, | ||
| "location": "Updated City", | ||
| "age": 25, | ||
| "weight": 67, | ||
| "due_date": "2024-10-01", | ||
| "lmp": "2024-01-01", | ||
| "current_week": 10, | ||
| "location": "Angola", | ||
| "age": 28, | ||
| "weight": 68, | ||
| "due_date": "2026-09-09", | ||
| "lmp": "2025-12-03", | ||
| "cycle_length": 28, | ||
| "period_length": 5, | ||
| "period_length": 6, | ||
| "tracking_data": { | ||
| "weight": [ | ||
| { | ||
| "week": 34, | ||
| "weight": 72.0, | ||
| "note": "Test weight entry 14", | ||
| "date": "2025-09-10T06:41:08.439168" | ||
| "week": 10, | ||
| "weight": 61.3, | ||
| "note": "Started prenatal yoga, feeling good", | ||
| "date": "2026-02-11 08:53:56" | ||
| }, | ||
| { | ||
| "week": 33, | ||
| "weight": 71.5, | ||
| "note": "Test weight entry 13", | ||
| "date": "2025-09-10T06:41:08.439168" | ||
| "week": 9, | ||
| "weight": 60.9, | ||
| "note": "Appetite increasing slightly", | ||
| "date": "2026-02-11 08:53:56" | ||
| }, | ||
| { | ||
| "week": 32, | ||
| "weight": 71.0, | ||
| "note": "Test weight entry 12", | ||
| "date": "2025-09-10T06:41:08.439168" | ||
| }, | ||
| { | ||
| "week": 31, | ||
| "weight": 70.5, | ||
| "note": "Test weight entry 11", | ||
| "date": "2025-09-10T06:41:08.439168" | ||
| "week": 8, | ||
| "weight": 60.5, | ||
| "note": "Slight nausea, but overall feeling okay", | ||
| "date": "2026-02-11 08:53:56" | ||
| } | ||
| ], | ||
| "medicine": [ | ||
| { | ||
| "week": 34, | ||
| "name": "Medicine 14", | ||
| "dose": "114mg", | ||
| "time": "Morning", | ||
| "week": 10, | ||
| "name": "Prenatal Vitamin", | ||
| "dose": "1 tablet", | ||
| "time": "08:00", | ||
| "taken": 1, | ||
| "note": "Test medicine 14", | ||
| "date": "2025-09-10T06:41:08.440168" | ||
| "note": "No side effects, continuing as normal", | ||
| "date": "2026-02-11 08:53:56" | ||
| }, | ||
| { | ||
| "week": 33, | ||
| "name": "Medicine 13", | ||
| "dose": "113mg", | ||
| "time": "Morning", | ||
| "week": 9, | ||
| "name": "Iron Supplement", | ||
| "dose": "30mg", | ||
| "time": "13:00", | ||
| "taken": 1, | ||
| "note": "Test medicine 13", | ||
| "date": "2025-09-10T06:41:08.440168" | ||
| "note": "Taking to help with mild anemia", | ||
| "date": "2026-02-11 08:53:56" | ||
| }, | ||
| { | ||
| "week": 32, | ||
| "name": "Medicine 12", | ||
| "dose": "112mg", | ||
| "time": "Morning", | ||
| "week": 8, | ||
| "name": "Prenatal Vitamin", | ||
| "dose": "1 tablet", | ||
| "time": "08:00", | ||
| "taken": 1, | ||
| "note": "Test medicine 12", | ||
| "date": "2025-09-10T06:41:08.440168" | ||
| }, | ||
| { | ||
| "week": 31, | ||
| "name": "Medicine 11", | ||
| "dose": "111mg", | ||
| "time": "Morning", | ||
| "taken": 1, | ||
| "note": "Test medicine 11", | ||
| "date": "2025-09-10T06:41:08.440168" | ||
| "note": "Daily multivitamin with folic acid", | ||
| "date": "2026-02-11 08:53:56" | ||
| } | ||
| ], | ||
| "symptoms": [ | ||
| { | ||
| "week": 34, | ||
| "symptom": "Symptom 14", | ||
| "note": "Test symptom 14", | ||
| "date": "2025-09-10T06:41:08.440168" | ||
| }, | ||
| { | ||
| "week": 33, | ||
| "symptom": "Symptom 13", | ||
| "note": "Test symptom 13", | ||
| "date": "2025-09-10T06:41:08.440168" | ||
| "week": 10, | ||
| "symptom": "Frequent Urination", | ||
| "note": "Especially during the night", | ||
| "date": "2025-10-27 08:53:56" | ||
| }, | ||
| { | ||
| "week": 32, | ||
| "symptom": "Symptom 12", | ||
| "note": "Test symptom 12", | ||
| "date": "2025-09-10T06:41:08.440168" | ||
| "week": 9, | ||
| "symptom": "Breast Tenderness", | ||
| "note": "More sensitive than last week", | ||
| "date": "2025-10-27 08:53:56" | ||
| }, | ||
| { | ||
| "week": 31, | ||
| "symptom": "Symptom 11", | ||
| "note": "Test symptom 11", | ||
| "date": "2025-09-10T06:41:08.440168" | ||
| "week": 8, | ||
| "symptom": "Morning Sickness", | ||
| "note": "Worse after waking up", | ||
| "date": "2025-10-27 08:53:56" | ||
| } | ||
| ], | ||
| "blood_pressure": [], | ||
| "discharge": [] | ||
| }, | ||
| "last_updated": "2025-09-10T06:44:27.424436" | ||
| } | ||
| "last_updated": "2025-12-26T13:01:12.603340" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,45 +45,7 @@ CREATE TABLE IF NOT EXISTS discharge_logs ( | |
| ); | ||
|
|
||
| -- Insert mock data into appointments | ||
| INSERT INTO appointments (title, content, appointment_date, appointment_time, appointment_location, appointment_status) VALUES | ||
| ('Initial OB Appointment', 'Confirm pregnancy and general health.', '2025-06-22', '09:00 AM', 'City Clinic', 'completed'), | ||
| ('Blood Work', 'Routine prenatal blood tests.', '2025-06-29', '10:00 AM', 'LabCorp', 'completed'), | ||
| ('Nutritional Counseling', 'Discuss prenatal diet and supplements.', '2025-02-05', '11:00 AM', 'Wellness Center', 'pending'), | ||
| ('First Ultrasound', 'Early scan to check for heartbeat.', '2025-02-12', '10:30 AM', 'City Hospital', 'pending'), | ||
| ('Routine Check-up', 'Weekly monitoring and vitals.', '2025-02-19', '09:30 AM', 'OB-GYN Office', 'pending'), | ||
| ('NT Scan Appointment', 'Nuchal translucency scan scheduling.', '2025-02-26', '02:00 PM', 'Radiology Dept.', 'pending'), | ||
| ('Screening Lab Visit', 'Down syndrome blood screening.', '2025-06-05', '10:15 AM', 'Prenatal Lab', 'pending'), | ||
| ('Follow-up Visit', 'Review test results and progress.', '2025-06-12', '09:00 AM', 'HealthCare Clinic', 'pending'), | ||
| ('Anomaly Scan Prep', 'Discuss upcoming detailed scan.', '2025-06-19', '11:30 AM', 'OB-GYN Center', 'pending'), | ||
| ('Mid-pregnancy Checkup', 'Weight, BP, baby growth tracking.', '2025-06-26', '01:00 PM', 'Wellness Clinic', 'pending'), | ||
| ('Vaccination Discussion', 'Discuss vaccines for pregnancy.', '2025-06-02', '12:30 PM', 'OB-GYN Office', 'pending'), | ||
| ('Mood & Sleep Check-in', 'Mental health & fatigue talk.', '2025-06-09', '10:00 AM', 'Care Center', 'pending'); | ||
|
|
||
| -- Insert mock data into tasks | ||
| INSERT INTO tasks (title, content, starting_week, ending_week, task_priority, isOptional, isAppointmentMade ,task_status) VALUES | ||
| -- First Trimester | ||
| ('Initial Prenatal Visit', 'First doctor visit to confirm pregnancy and health check.', 4, 4, 'high', FALSE, FALSE,'pending'), | ||
| ('Early Ultrasound', 'Confirm pregnancy location and heartbeat.', 6, 8, 'high', FALSE,FALSE,'pending'), | ||
| ('Folic Acid Supplementation', 'Start folic acid for neural tube development.', 4, 12, 'high', FALSE,FALSE,'pending'), | ||
| ('Blood Tests', 'Check for blood type, hemoglobin, and infections.', 8, 10, 'high', FALSE,FALSE,'pending'), | ||
| ('Down Syndrome Screening', 'Non-invasive prenatal screening for chromosomal conditions.', 10, 12, 'medium', FALSE,FALSE,'pending'), | ||
|
|
||
| -- Second Trimester | ||
| ('NT Scan', 'Nuchal translucency scan for fetal abnormalities.', 12, 14, 'high', FALSE,FALSE,'pending'), | ||
| ('Gestational Diabetes Test', 'Glucose test to check blood sugar levels.', 14, 16, 'high', FALSE,FALSE,'pending'), | ||
| ('Detailed Anomaly Scan', '20-week scan to check fetal development.', 18, 20, 'high', FALSE,FALSE,'pending'), | ||
| ('Fetal Movement Monitoring', 'Track baby movements for health assessment.', 21, 24, 'medium', FALSE,FALSE,'pending'), | ||
| ('Iron and Calcium Supplements', 'Ensure proper bone and blood health for mother and baby.', 21, 28, 'medium', FALSE,FALSE,'pending'), | ||
|
|
||
| -- Third Trimester | ||
| ('Rh Factor Screening', 'Test if mother needs Rh immunoglobulin.', 26, 28, 'high', FALSE,FALSE,'pending'), | ||
| ('Glucose Tolerance Test', 'Second test if needed for gestational diabetes.', 28, 28, 'medium', FALSE,FALSE,'pending'), | ||
| ('Pre-Birth Vaccination', 'Tdap and flu shots for maternal and newborn protection.', 30, 32, 'high', FALSE,FALSE,'pending'), | ||
| ('Third-Trimester Ultrasound', 'Assess babyβs growth and position.', 30, 32, 'high', FALSE,FALSE,'pending'), | ||
| ('Birth Plan Discussion', 'Discuss delivery preferences with doctor.', 33, 34, 'medium', TRUE,FALSE,'pending'), | ||
| ('Hospital Tour', 'Visit maternity hospital to prepare for delivery.', 33, 34, 'low', TRUE,FALSE,'pending'), | ||
| ('Labor Signs Monitoring', 'Educate about labor contractions and when to go to hospital.', 36, 40, 'high', FALSE,FALSE,'pending'), | ||
| ('Final Checkups', 'Last medical assessments before labor.', 38, 40, 'high', FALSE,FALSE,'pending'); | ||
|
|
||
| DROP TABLE IF EXISTS profile; | ||
|
|
||
|
|
@@ -99,9 +61,7 @@ CREATE TABLE IF NOT EXISTS profile ( | |
| ); | ||
|
|
||
| INSERT INTO profile (lmp, cycleLength, periodLength, age, weight, user_location) VALUES | ||
| ('2025-01-01', 28, 5, 30, 65, 'New York'), | ||
| ('2025-01-15', 30, 6, 28, 70, 'Los Angeles'), | ||
| ('2025-02-01', 26, 4, 32, 60, 'Chicago'); | ||
| ('2025-01-01', 28, 5, 30, 65, 'New York'); | ||
|
|
||
|
|
||
| CREATE TABLE IF NOT EXISTS weekly_weight ( | ||
|
|
@@ -131,19 +91,87 @@ CREATE TABLE IF NOT EXISTS weekly_symptoms ( | |
| created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP | ||
| ); | ||
|
|
||
| INSERT INTO weekly_weight (week_number, weight, note) VALUES | ||
| (8, 60.5, 'Slight nausea, but overall feeling okay'), | ||
| (9, 60.9, 'Appetite increasing slightly'), | ||
| (10, 61.3, 'Started prenatal yoga, feeling good'); | ||
|
|
||
|
|
||
| INSERT INTO weekly_medicine (week_number, name, dose, time, taken, note) VALUES | ||
| (8, 'Prenatal Vitamin', '1 tablet', '08:00', 1, 'Daily multivitamin with folic acid'), | ||
| (9, 'Iron Supplement', '30mg', '13:00', 1, 'Taking to help with mild anemia'), | ||
| (10, 'Prenatal Vitamin', '1 tablet', '08:00', 1, 'No side effects, continuing as normal'); | ||
|
|
||
| INSERT INTO weekly_symptoms (week_number, symptom, note) VALUES | ||
| (8, 'Morning Sickness', 'Worse after waking up'), | ||
| (9, 'Breast Tenderness', 'More sensitive than last week'), | ||
| (10, 'Frequent Urination', 'Especially during the night'); | ||
| ALTER TABLE appointments | ||
| ADD COLUMN profile_id INTEGER NOT NULL DEFAULT 1 REFERENCES profile(id) ON DELETE CASCADE; | ||
|
|
||
| ALTER TABLE tasks | ||
| ADD COLUMN profile_id INTEGER NOT NULL DEFAULT 1 REFERENCES profile(id) ON DELETE CASCADE; | ||
|
|
||
| ALTER TABLE blood_pressure_logs | ||
| ADD COLUMN profile_id INTEGER NOT NULL DEFAULT 1 REFERENCES profile(id) ON DELETE CASCADE; | ||
|
|
||
| ALTER TABLE discharge_logs | ||
| ADD COLUMN profile_id INTEGER NOT NULL DEFAULT 1 REFERENCES profile(id) ON DELETE CASCADE; | ||
|
|
||
| ALTER TABLE weekly_weight | ||
| ADD COLUMN profile_id INTEGER NOT NULL DEFAULT 1 REFERENCES profile(id) ON DELETE CASCADE; | ||
|
|
||
| ALTER TABLE weekly_medicine | ||
| ADD COLUMN profile_id INTEGER NOT NULL DEFAULT 1 REFERENCES profile(id) ON DELETE CASCADE; | ||
|
|
||
| ALTER TABLE weekly_symptoms | ||
| ADD COLUMN profile_id INTEGER NOT NULL DEFAULT 1 REFERENCES profile(id) ON DELETE CASCADE; | ||
|
Comment on lines
+99
to
+118
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π§© Analysis chainπ Script executed: #!/bin/bash
# Check if foreign_keys pragma is set in db connection code
rg -n "foreign_keys" Backend/db/Repository: AOSSIE-Org/BabyNest Length of output: 45 π Script executed: #!/bin/bash
# Check if PRAGMA foreign_keys is already in the schema file
rg -n "PRAGMA foreign_keys" Backend/schema.sqlRepository: AOSSIE-Org/BabyNest Length of output: 45 π Script executed: #!/bin/bash
# Check the start of the schema.sql file
head -20 Backend/schema.sqlRepository: AOSSIE-Org/BabyNest Length of output: 675 π Script executed: #!/bin/bash
# Check what files exist in Backend/db/
find Backend/db/ -type f -name "*.py" 2>/dev/null | head -20Repository: AOSSIE-Org/BabyNest Length of output: 79 π Script executed: #!/bin/bash
# Check if there are any connection initialization files
ls -la Backend/db/ 2>/dev/null || ls -la Backend/ 2>/dev/null | head -30Repository: AOSSIE-Org/BabyNest Length of output: 282 π Script executed: #!/bin/bash
# Read the db.py file to check connection setup
cat -n Backend/db/db.pyRepository: AOSSIE-Org/BabyNest Length of output: 846 Enable foreign key enforcement with SQLite does not enforce foreign key constraints by default. The schema defines Add to the top of schema.sql: +PRAGMA foreign_keys = ON;
+
DROP TABLE IF EXISTS users;And in def open_db():
if "db" not in g:
first_time_setup()
g.db = sqlite3.connect(DATABASE)
+ g.db.execute("PRAGMA foreign_keys = ON")
g.db.row_factory = sqlite3.Row
return g.db
π€ Prompt for AI Agents |
||
|
|
||
| -- insert dummy data | ||
| INSERT INTO weekly_weight (week_number, weight, note, profile_id) VALUES | ||
| (8, 60.5, 'Slight nausea, but overall feeling okay', 1), | ||
| (9, 60.9, 'Appetite increasing slightly', 1), | ||
| (10, 61.3, 'Started prenatal yoga, feeling good', 1); | ||
|
|
||
|
|
||
| INSERT INTO weekly_medicine (week_number, name, dose, time, taken, note, profile_id) VALUES | ||
| (8, 'Prenatal Vitamin', '1 tablet', '08:00', 1, 'Daily multivitamin with folic acid', 1), | ||
| (9, 'Iron Supplement', '30mg', '13:00', 1, 'Taking to help with mild anemia', 1), | ||
| (10, 'Prenatal Vitamin', '1 tablet', '08:00', 1, 'No side effects, continuing as normal', 1); | ||
|
|
||
|
|
||
| INSERT INTO weekly_symptoms (week_number, symptom, note, profile_id) VALUES | ||
| (8, 'Morning Sickness', 'Worse after waking up', 1), | ||
| (9, 'Breast Tenderness', 'More sensitive than last week', 1), | ||
| (10, 'Frequent Urination', 'Especially during the night', 1); | ||
|
|
||
|
Comment on lines
121
to
137
|
||
| INSERT INTO appointments | ||
| (title, content, appointment_date, appointment_time, appointment_location, appointment_status, profile_id) | ||
| VALUES | ||
| ('Initial OB Appointment', 'Confirm pregnancy and general health.', '2025-06-22', '09:00 AM', 'City Clinic', 'completed', 1), | ||
| ('Blood Work', 'Routine prenatal blood tests.', '2025-06-29', '10:00 AM', 'LabCorp', 'completed', 1), | ||
| ('Nutritional Counseling', 'Discuss prenatal diet and supplements.', '2025-02-05', '11:00 AM', 'Wellness Center', 'pending', 1), | ||
| ('First Ultrasound', 'Early scan to check for heartbeat.', '2025-02-12', '10:30 AM', 'City Hospital', 'pending', 1), | ||
| ('Routine Check-up', 'Weekly monitoring and vitals.', '2025-02-19', '09:30 AM', 'OB-GYN Office', 'pending', 1), | ||
| ('NT Scan Appointment', 'Nuchal translucency scan scheduling.', '2025-02-26', '02:00 PM', 'Radiology Dept.', 'pending', 1), | ||
| ('Screening Lab Visit', 'Down syndrome blood screening.', '2025-06-05', '10:15 AM', 'Prenatal Lab', 'pending', 1), | ||
| ('Follow-up Visit', 'Review test results and progress.', '2025-06-12', '09:00 AM', 'HealthCare Clinic', 'pending', 1), | ||
| ('Anomaly Scan Prep', 'Discuss upcoming detailed scan.', '2025-06-19', '11:30 AM', 'OB-GYN Center', 'pending', 1), | ||
| ('Mid-pregnancy Checkup', 'Weight, BP, baby growth tracking.', '2025-06-26', '01:00 PM', 'Wellness Clinic', 'pending', 1), | ||
| ('Vaccination Discussion', 'Discuss vaccines for pregnancy.', '2025-06-02', '12:30 PM', 'OB-GYN Office', 'pending', 1), | ||
| ('Mood & Sleep Check-in', 'Mental health & fatigue talk.', '2025-06-09', '10:00 AM', 'Care Center', 'pending', 1); | ||
|
|
||
| INSERT INTO tasks | ||
| (title, content, starting_week, ending_week, task_priority, isOptional, isAppointmentMade, task_status, profile_id) | ||
| VALUES | ||
| -- First Trimester | ||
| ('Initial Prenatal Visit', 'First doctor visit to confirm pregnancy and health check.', 4, 4, 'high', FALSE, FALSE,'pending', 1), | ||
| ('Early Ultrasound', 'Confirm pregnancy location and heartbeat.', 6, 8, 'high', FALSE, FALSE,'pending', 1), | ||
| ('Folic Acid Supplementation', 'Start folic acid for neural tube development.', 4, 12, 'high', FALSE, FALSE,'pending', 1), | ||
| ('Blood Tests', 'Check for blood type, hemoglobin, and infections.', 8, 10, 'high', FALSE, FALSE,'pending', 1), | ||
| ('Down Syndrome Screening', 'Non-invasive prenatal screening for chromosomal conditions.', 10, 12, 'medium', FALSE, FALSE,'pending', 1), | ||
|
|
||
| -- Second Trimester | ||
| ('NT Scan', 'Nuchal translucency scan for fetal abnormalities.', 12, 14, 'high', FALSE, FALSE,'pending', 1), | ||
| ('Gestational Diabetes Test', 'Glucose test to check blood sugar levels.', 14, 16, 'high', FALSE, FALSE,'pending', 1), | ||
| ('Detailed Anomaly Scan', '20-week scan to check fetal development.', 18, 20, 'high', FALSE, FALSE,'pending', 1), | ||
| ('Fetal Movement Monitoring', 'Track baby movements for health assessment.', 21, 24, 'medium', FALSE, FALSE,'pending', 1), | ||
| ('Iron and Calcium Supplements', 'Ensure proper bone and blood health for mother and baby.', 21, 28, 'medium', FALSE, FALSE,'pending', 1), | ||
|
|
||
| -- Third Trimester | ||
| ('Rh Factor Screening', 'Test if mother needs Rh immunoglobulin.', 26, 28, 'high', FALSE, FALSE,'pending', 1), | ||
| ('Glucose Tolerance Test', 'Second test if needed for gestational diabetes.', 28, 28, 'medium', FALSE, FALSE,'pending', 1), | ||
| ('Pre-Birth Vaccination', 'Tdap and flu shots for maternal and newborn protection.', 30, 32, 'high', FALSE, FALSE,'pending', 1), | ||
| ('Third-Trimester Ultrasound', 'Assess babyβs growth and position.', 30, 32, 'high', FALSE, FALSE,'pending', 1), | ||
| ('Birth Plan Discussion', 'Discuss delivery preferences with doctor.', 33, 34, 'medium', TRUE, FALSE,'pending', 1), | ||
| ('Hospital Tour', 'Visit maternity hospital to prepare for delivery.', 33, 34, 'low', TRUE, FALSE,'pending', 1), | ||
| ('Labor Signs Monitoring', 'Educate about labor contractions and when to go to hospital.', 36, 40, 'high', FALSE, FALSE,'pending', 1), | ||
| ('Final Checkups', 'Last medical assessments before labor.', 38, 40, 'high', FALSE, FALSE,'pending', 1); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π§© Analysis chain
π Script executed:
Repository: AOSSIE-Org/BabyNest
Length of output: 446
Remove
Backend/.envfrom version control and add.envtoBackend/.gitignore.The
.envfile should not be committed to version control. CreateBackend/.env.examplewith the template content, add.envtoBackend/.gitignore(similar to the Frontend setup), and remove the committed.envfrom git history usinggit rm --cached Backend/.env.π€ Prompt for AI Agents