diff --git a/addressBook/addressBook.py b/addressBook/addressBook.py index 78943f2..8d9f8a8 100644 --- a/addressBook/addressBook.py +++ b/addressBook/addressBook.py @@ -12,7 +12,7 @@ def createUser(): # Read Json File -> Record.Json file - data = serialzeJson() + data = deSerialzeJson() # User Input Details firstName = input("Enter the first name : ") @@ -46,14 +46,14 @@ def createUser(): def showUserInJson(): # Read Json File -> Record.Json file - data = serialzeJson() + data = deSerialzeJson() pprint.pprint(data) def showUser(): # Read Json File -> Record.Json file - data = serialzeJson() + data = deSerialzeJson() for user in data['person']: print("\nFirstName: " + user['firstName'] + "\n" + "Last Name : " + user['lastName'] + "\n" + "Address : " + user['address'] + "\n" + @@ -61,7 +61,7 @@ def showUser(): def delUser(): # Read Json File -> Record.Json file - data = serialzeJson() + data = deSerialzeJson() # index to display for delete option index = 1 @@ -79,7 +79,7 @@ def delUser(): def editUser(): # Read Json File -> Record.Json file - data = serialzeJson() + data = deSerialzeJson() index = 1 for user in data['person']: @@ -98,7 +98,12 @@ def editUser(): with open("record.json", "w") as f: f.write(json_obj) -def serialzeJson(): +def sortUser(): + pass + # Sort using last name of the person (Ties broken by first name) + # Sort using zip code of the person (Ties broken by second name) + +def deSerialzeJson(): with open('record.json') as f: data = json.loads(f.read()) return(data) @@ -107,7 +112,7 @@ def serialzeJson(): while True: print(" ") print("User Management Panel") - print(" 1.Create User \n 2.Show Users In Json Format \n 3. Show Users \n 4. Delete User \n 5. edit User") + print(" 1.Create User \n 2.Show Users In Json Format \n 3. Show Users \n 4. Delete User \n 5. Edit User") val = input("Enter your choice : \t") diff --git a/clinicManagement/__pycache__/appointment.cpython-38.pyc b/clinicManagement/__pycache__/appointment.cpython-38.pyc new file mode 100644 index 0000000..706981d Binary files /dev/null and b/clinicManagement/__pycache__/appointment.cpython-38.pyc differ diff --git a/clinicManagement/__pycache__/doctor.cpython-38.pyc b/clinicManagement/__pycache__/doctor.cpython-38.pyc index 71f9ea1..1d18dad 100644 Binary files a/clinicManagement/__pycache__/doctor.cpython-38.pyc and b/clinicManagement/__pycache__/doctor.cpython-38.pyc differ diff --git a/clinicManagement/__pycache__/patient.cpython-38.pyc b/clinicManagement/__pycache__/patient.cpython-38.pyc index 92cf999..6e304b1 100644 Binary files a/clinicManagement/__pycache__/patient.cpython-38.pyc and b/clinicManagement/__pycache__/patient.cpython-38.pyc differ diff --git a/clinicManagement/__pycache__/searchDoctor.cpython-38.pyc b/clinicManagement/__pycache__/searchDoctor.cpython-38.pyc index 850b7b2..9e05f05 100644 Binary files a/clinicManagement/__pycache__/searchDoctor.cpython-38.pyc and b/clinicManagement/__pycache__/searchDoctor.cpython-38.pyc differ diff --git a/clinicManagement/appointment.py b/clinicManagement/appointment.py index 43fc438..3b612a8 100644 --- a/clinicManagement/appointment.py +++ b/clinicManagement/appointment.py @@ -2,6 +2,7 @@ import os from os import path from doctor import deSerialzeJson +import patient as p ''' Function: @@ -16,12 +17,15 @@ ''' def checkDoctor(): - queryName = input("Enter the name of the doctor you want you appointment with : ").upper() - data = deSerialzeJson() - for doctors in data['doctorsData']: - if(doctors['name'] == queryName): - doctorMatch = doctors['name'] - return(doctorMatch) + try: + queryName = input("Enter the name of the doctor you want you appointment with : ").upper() + except Exception as e: + print("Exception handles", e) + data = deSerialzeJson() + for doctors in data['doctorsData']: + if(doctors['name'] == queryName): + doctorMatch = doctors['name'] + return(doctorMatch) # Able to search doctors; ''' @@ -38,7 +42,10 @@ def checkDoctor(): def appointDoctor(): match = checkDoctor() - client = input("Enter the your name : ") + try: + client = input("Enter the your name : ").upper() + except Exception as e: + print("Sorry an error happend : ") appointment = [] appointment.append(client) data = deSerialzeJson() @@ -52,11 +59,13 @@ def appointDoctor(): if len(doctors['appointment'])<5: doctors['appointment'].append(client) + p.addPatient() else: print('Sorry appointment list is full : ') else: doctors['appointment'] = appointment + p.addPatient() if flag is not True: print("Doctor unavailable : ") @@ -65,6 +74,6 @@ def appointDoctor(): f.write(json_obj) -if __name__ == "__main__": - appointDoctor() +# if __name__ == "__main__": + diff --git a/clinicManagement/doctor.py b/clinicManagement/doctor.py index 57804d7..7066d90 100644 --- a/clinicManagement/doctor.py +++ b/clinicManagement/doctor.py @@ -2,6 +2,17 @@ import json import os from os import path +import logging + +LOG_FORMAT = "%(LeveLname)s %(asctime)s - %(message)s" + +logging.basicConfig(filename= "D:\\vs studio\\bridgeLabz\\codes\\programmingProblems\\clinic_log\\clinic.log", +level=logging.DEBUG, format= LOG_FORMAT) + +logger = logging.getLogger() + + + doctorsData = [] # Global array to create new json array ''' @@ -70,8 +81,7 @@ def doctorID(): with open('clinicData.json') as f: if f.read() == '': return(id) - else: - + else: data = deSerialzeJson() id = len(data['doctorsData']) return(id+1) @@ -87,6 +97,8 @@ def doctorID(): ''' def shiftInput(): checkShift = input("Enter shift AM/PM/BOTH : ").upper() + logging.debug("Collecting the shift input", checkShift) + logger.info if (checkShift == 'AM') or (checkShift == 'PM') or (checkShift == 'BOTH'): return(checkShift) else: @@ -104,9 +116,13 @@ def shiftInput(): ''' def createData(): name = input("Enter the name : ").upper() + logging.debug("Collecting the name input", name) id = str(doctorID()) + logging.debug("Collecting the id input", id) specialization = input("Enter the doctors specialization : ").upper() + logging.debug("Collecting the specialization input", specialization) shift = shiftInput() + logging.debug("Collecting the shift input", shift) x = { 'name': 'DR '+name, diff --git a/clinicManagement/main.py b/clinicManagement/main.py index 9a607ce..8bd3fc7 100644 --- a/clinicManagement/main.py +++ b/clinicManagement/main.py @@ -9,10 +9,13 @@ import doctor as d import patient as p import searchDoctor as sd +import appointment as ap +import logging + def main(): print("Clinique Management System") - ch = input("1. Enter 1 to add a doctor \n2. Enter 2 to see all avaiable doctors \n3. Search Doctors: \nEnter your choice : ") + ch = input("1. Enter 1 to add a doctor \n2. Enter 2 to see all avaiable doctors \n3. Search Doctors \n4. Get an appointment \nEnter your choice : ") if (ch =='1'): d.addDoctor() @@ -20,6 +23,11 @@ def main(): d.showDoctor() elif(ch == '3'): sd.keySearch() + elif(ch == '4'): + ap.appointDoctor() + else: + print("enter a proper choice : \n") + main() if __name__ == "__main__": diff --git a/addressBook/ad.txt b/clinic_log/clinic.log similarity index 100% rename from addressBook/ad.txt rename to clinic_log/clinic.log diff --git a/cliniqueManagement/__pycache__/doctor.cpython-38.pyc b/cliniqueManagement/__pycache__/doctor.cpython-38.pyc deleted file mode 100644 index 599e9e8..0000000 Binary files a/cliniqueManagement/__pycache__/doctor.cpython-38.pyc and /dev/null differ diff --git a/cliniqueManagement/__pycache__/patient.cpython-38.pyc b/cliniqueManagement/__pycache__/patient.cpython-38.pyc deleted file mode 100644 index 19740db..0000000 Binary files a/cliniqueManagement/__pycache__/patient.cpython-38.pyc and /dev/null differ diff --git a/cliniqueManagement/__pycache__/searchDoctor.cpython-38.pyc b/cliniqueManagement/__pycache__/searchDoctor.cpython-38.pyc deleted file mode 100644 index af40fbb..0000000 Binary files a/cliniqueManagement/__pycache__/searchDoctor.cpython-38.pyc and /dev/null differ diff --git a/cliniqueManagement/doctor.py b/cliniqueManagement/doctor.py deleted file mode 100644 index 5547112..0000000 --- a/cliniqueManagement/doctor.py +++ /dev/null @@ -1,78 +0,0 @@ - -import json -import os -from os import path - -data= {} # Global dict to create new json -doctorsData = [] # Global array to create new json array - - -def addDoctor(): - os.chdir('D:/vs studio/bridgeLabz/codes') - - if(path.exists("clinicData.json")): - - with open('clinicData.json') as f: - if f.read() == '': - - x = createData() - - doctorsData.append(x) - data['doctorsData'] = doctorsData - json_obj = json.dumps(data, indent=2) - - with open("clinicData.json", "w") as f: - f.write(json_obj) - else: - - data = deSerialzeJson() - x = createData() - - data["doctorsData"].append(x) - json_obj = json.dumps(data, indent=2) - - with open("clinicData.json", "w") as f: - f.write(json_obj) - - else: - - - x = createData() - - doctorsData.append(x) - data['doctorsData'] = doctorsData - json_obj = json.dumps(data, indent=2) - - with open("clinicData.json", "w") as f: - f.write(json_obj) - - -def createData(): - name = input("Enter the name : ").upper() - id = input("Enter the id : ") - specialization = input("Enter the doctors specialization : ").upper() - shift = input("Enter shift AM/PM/BOTH : ").upper() - - x = { - 'name': 'DR '+name, - 'id' : id, - 'specialization': specialization, - 'shift': shift - } - - return(x) - -def showDoctor(): - - # Read Json File -> Record.Json file - data = deSerialzeJson() - count = 0 - for doctors in data['doctorsData']: - print("\nname: " + doctors['name'] + "\n" + "id : " + doctors['id'] + "\n" + "specialization : " + doctors['specialization'] + "\n" + - "shift : " + doctors['shift']+"\n") - - -def deSerialzeJson(): - with open('clinicData.json') as f: - data = json.loads(f.read()) - return(data) diff --git a/cliniqueManagement/main.py b/cliniqueManagement/main.py deleted file mode 100644 index 9a607ce..0000000 --- a/cliniqueManagement/main.py +++ /dev/null @@ -1,26 +0,0 @@ -""" -title - This program is Clinic Management system which keeps records a doctor's as well as patient's attributes . -author name - Aditya Kumar -creation time - ‎26 ‎February ‎2021, ‏‎23:28:05 -modified time - ‎‎26 ‎February ‎2021, ‏‎23:41:34‏‎ - -""" - -import doctor as d -import patient as p -import searchDoctor as sd - -def main(): - print("Clinique Management System") - ch = input("1. Enter 1 to add a doctor \n2. Enter 2 to see all avaiable doctors \n3. Search Doctors: \nEnter your choice : ") - - if (ch =='1'): - d.addDoctor() - elif (ch == '2'): - d.showDoctor() - elif(ch == '3'): - sd.keySearch() - - -if __name__ == "__main__": - main() diff --git a/cliniqueManagement/patient.py b/cliniqueManagement/patient.py deleted file mode 100644 index c9c205c..0000000 --- a/cliniqueManagement/patient.py +++ /dev/null @@ -1,80 +0,0 @@ - -# This module is to add patients -import json -import os -from os import path - - -patientData = [] -data = {} - - -def addPatient(): - - os.chdir('D:/vs studio/bridgeLabz/codes') - - if(path.exists("patientRecord.json")): - - with open('patientRecord.json') as f: - if f.read() == '': - - x = createPatientData() - - patientData.append(x) - data['patientData'] = patientData - json_obj = json.dumps(data, indent=2) - - with open("patientRecord.json", "w") as f: - f.write(json_obj) - - else: - - data = deSerialzePatientData() - x = createPatientData() - - data["patientData"].append(x) - json_obj = json.dumps(data, indent=2) - - with open("patientRecord.json", "w") as f: - f.write(json_obj) - - else: - - x = createPatientData() - patientData.append(x) - data['patientData'] = patientData - json_obj = json.dumps(data, indent=2) - - with open("patientRecord.json", "w") as f: - f.write(json_obj) - - -def createPatientData(): - name = input("Enter the name of the patient : ").upper() - id = input("Enter the id of the patient : ") - mobileNumber = input("Enter your mobile number : ") - age = input("Enter your age : ") - - x = { - 'name': name, - 'id' : id, - 'specialization': mobileNumber, - 'shift': age - } - - # print("X is being returned") - - return(x) - - -def deSerialzePatientData(): - with open('patientRecord.json') as f: - data = json.loads(f.read()) - return(data) - - - -if __name__ == "__main__": - choice = input("Enter 1 if you want an appointment : ") - if (choice == '1'): - addPatient() \ No newline at end of file diff --git a/cliniqueManagement/searchDoctor.py b/cliniqueManagement/searchDoctor.py deleted file mode 100644 index cf8096a..0000000 --- a/cliniqueManagement/searchDoctor.py +++ /dev/null @@ -1,73 +0,0 @@ -# This is the search module. -from doctor import deSerialzeJson -import json -import os -from os import path - - -def byName(): - - key = input("Enter the name of the Doctor : ").upper() - data = deSerialzeJson() - - for doctors in data['doctorsData']: - try: - dName = doctors['name'].split(' ') - if(key == dName[1])or(key == dName[2])or(key == dName[1]+" "+dName[2]): - print("\nname: " + doctors['name'] + "\n" + "id : " + doctors['id'] + "\n" + "specialization : " + doctors['specialization'] + "\n" + - "shift : " + doctors['shift']+"\n") - return - except IndexError: - pass - except Exception as e: - print("An unknown error is occouring", e) - print("Doctor not found") - - - - -def byid(): - - key = input("Enter the id of the Doctor : ") - data = deSerialzeJson() - - for doctors in data['doctorsData']: - if(key == doctors['id']): - print("\nname: " + doctors['name'] + "\n" + "id : " + doctors['id'] + "\n" + "specialization : " + doctors['specialization'] + "\n" + - "shift : " + doctors['shift']+"\n") -def bySpecialization(): - - key = input("Enter the specialzation of the Doctor : ").upper() - data = deSerialzeJson() - - for doctors in data['doctorsData']: - if(key == doctors['specialization']): - print("\nname: " + doctors['name'] + "\n" + "id : " + doctors['id'] + "\n" + "specialization : " + doctors['specialization'] + "\n" + - "shift : " + doctors['shift']+"\n") -def byAvailability(): - - key = input("AM/PM/Both : ").upper() - data = deSerialzeJson() - - for doctors in data['doctorsData']: - if(key == doctors['shift']): - print("\nname: " + doctors['name'] + "\n" + "id : " + doctors['id'] + "\n" + "specialization : " + doctors['specialization'] + "\n" + - "shift : " + doctors['shift']+"\n") -def keySearch(): - - choice = input("Search doctor by : \n1. Name \n2. ID \n3. Specialization \n4. Availability \nEnter your choice : ") - if (choice == '1'): - byName() - - elif (choice == '2'): - byid() - - elif (choice == '3'): - bySpecialization() - - elif (choice == '4'): - byAvailability() - - else: - print("Enter a proper choice : ") - keySearch() diff --git a/record.json b/record.json deleted file mode 100644 index cc10faf..0000000 --- a/record.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "person": [ - { - "firstName": "Avinash", - "lastName": "singh", - "address": "sonari", - "city": "jsr", - "state": "jhsarkhand", - "zip": "400", - "phoneNumber": "900" - }, - { - "firstName": "Aman", - "lastName": "Kumar", - "address": "kadma", - "city": "jsr", - "state": "jharkhand", - "zip": "831005", - "phoneNumber": "3007894129" - } - ] -} \ No newline at end of file