Skip to content
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

finished patients database #68

Open
wants to merge 39 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
b9450db
finished patients database
Joeljohn2922 May 28, 2024
a6315e0
Merge pull request #1 from NandoD95/joels-branch
NandoD95 May 28, 2024
a1395bc
worked on doctor db .. fixed a few syntax errors
NandoD95 May 28, 2024
702c17b
Merge pull request #2 from NandoD95/nandos
NandoD95 May 28, 2024
bf55a3c
finsihed helpers.py and updated patient.py
Joeljohn2922 May 28, 2024
d395513
Merge pull request #3 from NandoD95/joels-branch
NandoD95 May 28, 2024
c9c708b
updated cli
NandoD95 May 28, 2024
202e128
Merge pull request #4 from NandoD95/nandos
NandoD95 May 28, 2024
76287f5
worked on doctor.py, fixed up syntax on other programs
NandoD95 May 29, 2024
c6816f4
Merge pull request #5 from NandoD95/nandos
Joeljohn2922 May 29, 2024
94e3004
added to menu on cli
NandoD95 May 29, 2024
4c338e2
Merge pull request #6 from NandoD95/nandos
NandoD95 May 29, 2024
24d1281
updated doctor.py
Joeljohn2922 May 29, 2024
7f6739a
Merge pull request #7 from NandoD95/joels-branch
Joeljohn2922 May 29, 2024
ca226f2
updated patients and doctors
Joeljohn2922 May 29, 2024
a81f2c2
Merge pull request #8 from NandoD95/joels-branch
NandoD95 May 29, 2024
07b735b
completed cli, corrected syntax error
NandoD95 May 29, 2024
f7cf15d
Merge pull request #9 from NandoD95/nandos
NandoD95 May 29, 2024
7a35aba
working on the debug
NandoD95 May 29, 2024
a29408b
Merge pull request #10 from NandoD95/nandos
NandoD95 May 29, 2024
ca8476c
worked on debugging the code, fixed some syntax that was not working
NandoD95 May 29, 2024
7ce00b4
Merge pull request #11 from NandoD95/nandos
NandoD95 May 29, 2024
bc42417
was able to fix 1-3 problems after going into each class
NandoD95 May 30, 2024
964a092
Merge pull request #12 from NandoD95/nandos
NandoD95 May 30, 2024
ca6f9ae
more debugging
Joeljohn2922 May 30, 2024
a8f8a53
Merge pull request #13 from NandoD95/joels-branch
Joeljohn2922 May 30, 2024
1fc4bbf
pushing to pull
NandoD95 May 30, 2024
03157fb
Merge pull request #14 from NandoD95/nandos
NandoD95 May 30, 2024
6c89cf9
options 0-3 working in both classes.. need to fix 4-6
NandoD95 May 30, 2024
0f0eadf
Merge pull request #15 from NandoD95/nandos
NandoD95 May 30, 2024
03b6f3f
got ssn to work on patient
NandoD95 May 30, 2024
6efbf96
Merge pull request #16 from NandoD95/nandos
NandoD95 May 30, 2024
4f11747
create a patient works
Joeljohn2922 May 30, 2024
71f05c8
Merge pull request #17 from NandoD95/joels-branch
Joeljohn2922 May 30, 2024
2535252
pushing to pull
NandoD95 May 30, 2024
10b4d38
Merge pull request #18 from NandoD95/nandos
NandoD95 May 30, 2024
dcee95e
fixed all errors we had
NandoD95 May 30, 2024
2bc1b66
Merge pull request #19 from NandoD95/nandos
NandoD95 May 30, 2024
adbc94a
debugging more
Joeljohn2922 May 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 102 additions & 3 deletions lib/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,19 @@

from helpers import (
exit_program,
helper_1
list_patients,
find_patient_by_user_input,
find_patient_by_id,
create_patient,
update_patient,
delete_patient,
list_doctors,
find_doctor_by_name,
find_doctor_by_id,
create_doctor,
update_doctor,
delete_doctor,
list_patient_doctors
)


Expand All @@ -13,16 +25,103 @@ def main():
if choice == "0":
exit_program()
elif choice == "1":
helper_1()
patients()
elif choice == "2":
doctors()
elif choice == "3":
patient_doctors()
else:
print("Invalid choice")


def menu():
print("Patient and Doctor Management System")
print("Please select an option:")
print("0. Exit the program")
print("1. Some useful function")
print("1. Patients")
print("2. Doctors")
print("3. Patient-Doctor Associations")

def patients():
while True:
patient_options()
choice = input("> ")
if choice == "0":
exit_program()
elif choice == "1":
list_patients()
elif choice == "2":
find_patient_by_user_input()
elif choice == "3":
find_patient_by_id()
elif choice == "4":
create_patient()
elif choice == "5":
update_patient()
elif choice == "6":
delete_patient()
else:
print("Invalid choice")

def patient_options():
print("Patient Options:")
print("0. Back to main menu")
print("1. List all patients")
print("2. Find patient by name")
print("3. Find patient by ID")
print("4. Create new patient")
print("5. Update patient")
print("6. Delete patient")
print("Please select an option:")

def doctors():
while True:
doctor_options()
choice = input("> ")
if choice == "0":
exit_program()
elif choice == "1":
list_doctors()
elif choice == "2":
find_doctor_by_name()
elif choice == "3":
find_doctor_by_id()
elif choice == "4":
create_doctor()
elif choice == "5":
update_doctor()
elif choice == "6":
delete_doctor()
else:
print("Invalid choice")

def doctor_options():
print("Doctor Options:")
print("0. Back to main menu")
print("1. List all doctors")
print("2. Find doctor by name")
print("3. Find doctor by ID")
print("4. Create new doctor")
print("5. Update doctor")
print("6. Delete doctor")
print("Please select an option:")

def patient_doctors():
while True:
patient_doctor_options()
choice = input("> ")
if choice == "0":
exit_program()
elif choice == "1":
list_patient_doctors()
else:
print("Invalid choice")

def patient_doctor_options():
print("Patient and Doctor Options:")
print("0. Back to main menu")
print("1. List patient doctors")
print("Please select an option:")

if __name__ == "__main__":
main()
15 changes: 15 additions & 0 deletions lib/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,22 @@
# lib/debug.py

from models.__init__ import CONN, CURSOR
from models.doctor import Doctor
from models.patient import Patient

import ipdb

Doctor.drop_table()
Doctor.create_table()
Patient.drop_table()
Patient.create_table()

Patient.create_individual_patient("Joel Smith", "male", '123-45-6789', 23, "Queens NY")
Patient.create_individual_patient("Jane Doe", "female", '987-65-4321', 25, "Brentwood NY")
Patient.create_individual_patient("John Doe", "male", '111-11-1111', 30, "Flushing NY")

Doctor.create_individual_doctor("Dr. John", "Cardiologist", 1)
Doctor.create_individual_doctor("Dr. Jane", "Dermatologist", 2)
Doctor.create_individual_doctor("Dr. Bob", "Neurologist", 3)

ipdb.set_trace()
144 changes: 142 additions & 2 deletions lib/helpers.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,149 @@
# lib/helpers.py
from models.patient import Patient
from models.doctor import Doctor

def helper_1():
print("Performing useful function#1.")
# def helper_1():
# print("Performing useful function#1.")


def exit_program():
print("Goodbye!")
exit()

def list_patients():
patients = Patient.get_all()
print (patients)
for patient in patients:
print(patient)

def find_patient_by_user_input():
name = input("Enter patient name: ")
patient = Patient.find_by_name(name)
print(patient) if patient else print(f'Patient {name} not found')

def find_patient_by_id():
patient_id = input("Enter patient ID: ")
patient = Patient.find_by_id(patient_id)
print(patient) if patient else print(f'Patient with ID {patient_id} not found')

def create_patient():
name = input("Enter patient name: ")
gender = input("Enter patient gender: ")
ssn = input("Enter patient ssn: ")
age = input("Enter patient age: ")
address = input("Enter patient address: ")
try:
patient = Patient.create_individual_patient(name, gender, ssn, age, address)
print(f'Success: {patient}')

except Exception as exc:
print(f'Error creating patient:', exc)

def update_patient():
patient_id = input("Enter patient ID: ")
patient = Patient.find_by_id(patient_id)
if patient:
try:
name = input("Enter new patient name: ")
patient.name = name
gender = input("Enter new patient gender: ")
patient.gender = gender
ssn = input("Enter new patient ssn: ")
patient.ssn = ssn
age = input("Enter new patient age: ")
patient.age = age
address = input("Enter new patient address: ")
patient.address = address
patient.update()
print(f'Success: {patient_id}')
except Exception as exc:
print(f'Error updating patient:', exc)
else:
print(f'Patient with ID {patient_id} not found')

def delete_patient():
patient_id = input("Enter patient ID: ")
patient = Patient.find_by_id(patient_id)
if patient:
patient.delete()
print(f'Patient with ID {patient_id} deleted')
else:
print(f'Patient with ID {patient_id} not found')


def list_doctors():
doctors = Doctor.get_all_doctor()
print (doctors)
for doctor in doctors:
print(f'ID: {doctor.id}, Name: {doctor.name}, Specialty: {doctor.specialization}')
# for doctor in doctors:
# print(doctor)

def find_doctor_by_name():
name = input("Enter doctor name: ")
doctor = Doctor.find_by_name(name)
print(doctor) if doctor else print(f'Doctor {name} not found')

def find_doctor_by_id():
doctor_id = input("Enter doctor ID: ")
doctor = Doctor.find_by_id(doctor_id)
print(doctor) if doctor else print(f'Doctor with ID {doctor_id} not found')

def create_doctor():
name = input("Enter the doctor's name: ")
specialization = input("Enter the doctor's specialization: ")
patient_id = input("Enters the patient_id: ")
try:
doctor = Doctor.create_individual_doctor(name, specialization, int(patient_id))
print(f'Success: {doctor}')
except Exception as exc:
print(f'Error creating doctor:', exc)

def update_doctor():
doctor_id = input("Enter doctor ID: ")
doctor = Doctor.find_by_id(doctor_id)
if doctor:
try:
name = input("Enter new doctor name: ")
doctor.name = name
specialization = input("Enter new doctor specialization: ")
doctor.specialization = specialization
patient_id = input("Enter new patient id: ")
doctor.patient_id = int(patient_id)

doctor.update()
print(f'Success {doctor}')
except Exception as exc:
print(f'Error updating doctor:', exc)
else:
print(f'Doctor with ID {doctor_id} not found')

def delete_doctor():
doctor_id = input("Enter doctor ID: ")
doctor = Doctor.find_by_id(doctor_id)
if doctor:
doctor.delete()
print(f'Doctor with ID {doctor_id} deleted')
else:
print(f'Doctor with ID {doctor_id} not found')

def list_patient_doctors():
id_ = input("Enter patient ID: ")
patient = Patient.find_by_id(id_)
if patient:
try:
for doctor in patient.doctors():
print(doctor)
except Exception as exc:
print("Error listing doctors", exc)
else :
print(f"Can not find patient by id of {id_}")









2 changes: 1 addition & 1 deletion lib/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import sqlite3

CONN = sqlite3.connect('company.db')
CONN = sqlite3.connect('medical.db')
CURSOR = CONN.cursor()
Loading