0% found this document useful (0 votes)
7 views4 pages

Patient Management System in Python

The document is a Python script for managing patient records in a hospital's OPD department using a CSV file. It provides functionalities to add, update, delete, search, and view patient data, as well as generate charts for patient statistics. The script uses the pandas library for data manipulation and matplotlib for visualizations.

Uploaded by

aliyakhatoon1018
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views4 pages

Patient Management System in Python

The document is a Python script for managing patient records in a hospital's OPD department using a CSV file. It provides functionalities to add, update, delete, search, and view patient data, as well as generate charts for patient statistics. The script uses the pandas library for data manipulation and matplotlib for visualizations.

Uploaded by

aliyakhatoon1018
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

import pandas as pd

import [Link] as plt

print('++++++++++++++++++++++++++++++++++++++++++++++++++')
print('+ +')
print('+ Welcome to Health Hospital +')
print('+ OPD Department +')
print('+ +')
print('++++++++++++++++++++++++++++++++++++++++++++++++++')
dfPatient = pd.read_csv('[Link]',
header=None,
names=['patno','name','dept','doctor','dt','charges'])
choice = 0
while(choice != 6):
print('Choices for the module')
print('1. Add a new Patient')
print('2. Update Patient')
print('3. Delete Patient')
print('4. Search & View Patients')
print('5. View Charts')
print('6. Exit')
choice = int(input('Enter your choice : '))

if(choice == 1):
patno = int(input('Input Patient Number : '))
name = input('Input Patient Name : ')
dept = input('Input Department (Othro/ENT/Gen Phy) : ')
doctor = input('Input doctor name: ')
dt = input('Input Date : ')
charges = input('Input Charges : ')
noofPatients = len(dfPatient)
[Link][noofPatients] = [patno,name,dept,doctor,dt,charges]
print(dfPatient)
dfPatient.to_csv('[Link]',header=False,index=False)
elif (choice == 2):
patno = int(input('Enter Patient Number : '))
print([Link][dfPatient['patno'] == patno])
indexno = [Link][dfPatient['patno'] == patno].index
print('1. Update Patient number')
print('2. Update Name')
print('3. Update department')
print('4. Update doctor')
print('5. Update date')
print('6. Update charges')
updatechoice = int(input('Enter your choice for update : '))
if (updatechoice == 1):
newpatno = int(input('Enter new Patient number : '))
[Link][indexno,'patno'] = newpatno
dfPatient.to_csv('[Link]',header=False,index=False)
elif (updatechoice == 2):
newname = input('Enter updated Patient Name : ')
[Link][indexno,'name'] = newname
dfPatient.to_csv('[Link]',header=False,index=False)
elif (updatechoice == 3):
newdept = input('Enter updated department name : ')
[Link][indexno,'dept'] = newdept
dfPatient.to_csv('[Link]',header=False,index=False)
elif (updatechoice == 4):
newdoctor = input('Enter updated doctor : ')
[Link][indexno,'doctor'] = newdoctor
dfPatient.to_csv('[Link]',header=False,index=False)
elif (updatechoice == 5):
newdt = input('Enter updated date : ')
[Link][indexno,'dt'] = newdt
dfPatient.to_csv('[Link]',header=False,index=False)
elif (updatechoice == 6):
newcharges = input('Enter updated charges : ')
[Link][indexno,'charges'] = newcharges
dfPatient.to_csv('[Link]',header=False,index=False)
print([Link][dfPatient['patno'] == patno])
print('----Patient Record Updated----')

elif (choice == 3):


patno = int(input('Enter Patient Number to Delete : '))
print([Link][dfPatient['patno'] == patno])
indexno = [Link][dfPatient['patno'] == patno].index
confirm = input('Are you sure you want to delete it (Y/N) : ')
if (confirm == 'Y' or confirm == 'y'):
dfPatient = [Link](indexno)
dfPatient.to_csv('[Link]',header=False,index=False)
print('---------- Patient Deleted ---------')

elif (choice == 4):


print('1. Display all ')
print('2. Display top ___ records')
print('3. Display bottom ___ records')
print('4. Display on the basis of dept')
print('5. Display on the basis of doctor')
print('6. Display on the basis of Date')
print('7. Display date wise and doctor wise charges')
dispchoice = int(input('Enter your choice : '))
if (dispchoice == 1):
print(dfPatient)
elif (dispchoice == 2):
top = int(input('Enter how many top records to be displayed : '))
print([Link](top))
elif (dispchoice == 3):
bottom = int(input('Enter how many bottom records to be displayed : '))
print([Link](bottom))
elif (dispchoice == 4):
dept = input('Enter department to search (Ortho/ENT/Gen Phy) : ')
print([Link][dfPatient['dept'] == dept])
elif (dispchoice == 5):
doctor = input('Enter Doctor Name : ')
print([Link][dfPatient['doctor'] == doctor])
elif (dispchoice == 6):
dt = input('Enter Date (dd-mmm-yyyy) : ')
print([Link][dfPatient['dt'] == dt])
elif (dispchoice == 7):
dt = input('Enter Date (dd-mmm-yyyy) : ')
dfTemp = [Link][dfPatient['dt'] == dt]
dfTemp2 = [Link]('doctor').aggregate('sum')
print(dfTemp2)
elif (choice == 5):
print('1. Bar Chart - Department wise Total Patients')
print('2. Line Chart - Doctor wise Charges on a specific date')
print('3. Back Menu')
chartchoice = int(input('Enter your choice : '))
if (chartchoice == 1):
dftemp = [Link] ('dept').aggregate('count')
dept = [Link].to_list()
Patientcount = dftemp['patno']
[Link](dept,Patientcount)
[Link]('Department')
[Link]('Number of Patients')
[Link]('Department wise Number of Patients')
[Link]()
elif (chartchoice == 2):
dt = input('Enter Date (dd-mmm-yyyy) : ')
dfTemp = [Link][dfPatient['dt'] == dt]
dfTemp2 = [Link]('doctor').aggregate('sum')
doctors = [Link].to_list()
charges = dfTemp2['charges'].to_list()
[Link](doctors,charges)
[Link]('Doctors')
[Link]('Charges')
[Link]('Doctor Wise Charges on '+dt)
[Link]()

print('---------------Thank You---------------------')

You might also like