Notes
Notes - notes.io |
But one important thing first:
⚠️ This CSV is NOT one single table
It is a merged extract of 12 different tables, combined into one file using a column called:
✅ source_table
So the correct way is:
Split this CSV into 12 tables
Then create SQL CREATE TABLE code for each one
✅ What’s inside your file (Summary)
Your file has:
710 rows
60 columns
Data from 12 tables
These tables are:
assign_patients
manage_appointments
chief_complaints
clinic_policy_acknowledgements
consent_to_treatments
hipaa_consents
family_history_answers
patient_medical_histories
patient_surgical_histories
patient_allergies
patient_social_histories
patient_habits
✅ How the data works (Proper Explanation)
Each row belongs to one table only, identified by:
source_table
Example:
If source_table = manage_appointments, then that row contains appointment data.
If source_table = patient_allergies, then that row contains allergy data.
So your dataset is like:
📌 One CSV = many tables mixed together
✅ SQL Database Table Code (MySQL)
Below is clean SQL code you can use directly.
1) assign_patients
CREATE TABLE assign_patients (
id BIGINT PRIMARY KEY,
specialist_id BIGINT,
patient_id BIGINT NOT NULL,
assigned_by BIGINT,
status VARCHAR(50),
assigned_at DATETIME,
ended_at DATETIME,
notes TEXT,
created_at DATETIME,
updated_at DATETIME
);
2) manage_appointments
CREATE TABLE manage_appointments (
id BIGINT PRIMARY KEY,
specialist_id BIGINT,
patient_id BIGINT NOT NULL,
assign_patient_id BIGINT,
appointment_title VARCHAR(255),
appointment_notes TEXT,
appointment_date DATETIME,
duration_minutes BIGINT,
status VARCHAR(50),
checked_in_at DATETIME,
created_by BIGINT,
updated_by BIGINT,
created_at DATETIME,
updated_at DATETIME
);
3) chief_complaints
CREATE TABLE chief_complaints (
id BIGINT PRIMARY KEY,
patient_id BIGINT NOT NULL,
appointment_id BIGINT,
complaint_text TEXT,
created_at DATETIME,
updated_at DATETIME
);
4) clinic_policy_acknowledgements
CREATE TABLE clinic_policy_acknowledgements (
id BIGINT PRIMARY KEY,
patient_id BIGINT NOT NULL,
appointment_id BIGINT,
missed_appointment_policy_agreed TINYINT,
patient_signature TEXT,
signature_date DATETIME,
created_at DATETIME,
updated_at DATETIME
);
5) consent_to_treatments
CREATE TABLE consent_to_treatments (
id BIGINT PRIMARY KEY,
patient_id BIGINT NOT NULL,
appointment_id BIGINT,
patient_signature TEXT,
signature_date DATETIME,
printed_name VARCHAR(255),
agreed TINYINT,
created_at DATETIME,
updated_at DATETIME
);
6) hipaa_consents
CREATE TABLE hipaa_consents (
id BIGINT PRIMARY KEY,
patient_id BIGINT NOT NULL,
appointment_id BIGINT,
patient_signature TEXT,
signature_date DATETIME,
agreed TINYINT,
authorized_individuals TEXT,
release_to VARCHAR(255),
created_at DATETIME,
updated_at DATETIME
);
7) family_history_answers
CREATE TABLE family_history_answers (
id BIGINT PRIMARY KEY,
patient_id BIGINT NOT NULL,
appointment_id BIGINT,
medical_id BIGINT,
relative VARCHAR(255),
value DOUBLE,
sibling_group BIGINT,
custom_medical_history TEXT,
created_at DATETIME,
updated_at DATETIME
);
8) patient_medical_histories
CREATE TABLE patient_medical_histories (
id BIGINT PRIMARY KEY,
patient_id BIGINT NOT NULL,
appointment_id BIGINT,
medical_id BIGINT,
cancer VARCHAR(255),
heart_attack VARCHAR(255),
created_at DATETIME,
updated_at DATETIME
);
9) patient_surgical_histories
CREATE TABLE patient_surgical_histories (
id BIGINT PRIMARY KEY,
patient_id BIGINT NOT NULL,
appointment_id BIGINT,
surgical_id BIGINT,
created_at DATETIME,
updated_at DATETIME
);
10) patient_allergies
CREATE TABLE patient_allergies (
id BIGINT PRIMARY KEY,
patient_id BIGINT NOT NULL,
appointment_id BIGINT,
allergy_id BIGINT,
reaction TEXT,
created_at DATETIME,
updated_at DATETIME
);
11) patient_social_histories
CREATE TABLE patient_social_histories (
id BIGINT PRIMARY KEY,
patient_id BIGINT NOT NULL,
appointment_id BIGINT,
social_id BIGINT,
occupation VARCHAR(255),
created_at DATETIME,
updated_at DATETIME
);
12) patient_habits
CREATE TABLE patient_habits (
id BIGINT PRIMARY KEY,
patient_id BIGINT NOT NULL,
appointment_id BIGINT,
never_smoked TINYINT,
smoked_since BIGINT,
previously_smoked_packs_per_day DOUBLE,
currently_smoke_packs_per_day DOUBLE,
stopped_smoking BIGINT,
smoked_for_years DOUBLE,
e_smoker_cartridges_per_day DOUBLE,
want_to_quit_smoking TINYINT,
chewing_status VARCHAR(255),
chewing_oz_per_week DOUBLE,
previously_chewed_oz_per_week DOUBLE,
quit_tobacco_when BIGINT,
drinking_type VARCHAR(255),
liquor_per_day DOUBLE,
beer_per_day DOUBLE,
wine_per_day DOUBLE,
created_at DATETIME,
updated_at DATETIME
);
✅ How you can use this in your code (Correct Approach)
Step 1: Filter data per table
Example:
assign_patients_df = df[df["source_table"] == "assign_patients"]
appointments_df = df[df["source_table"] == "manage_appointments"]
Step 2: Insert into real DB tables
You can insert each dataframe into MySQL using:
to_sql() (SQLAlchemy)
or manual INSERT
If you want, I can also generate:
✅ Python code that automatically splits the CSV into 12 DataFrames
✅ and writes them into MySQL tables automatically.
Just tell me your DB type:
MySQL / PostgreSQL / SQLite
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team
