HEALTH MANAGEMENT SYSTEM (MINIPROJECT)
Github Health Management System
HEALTH
MANAGEMENT
SYSTEM
# Health management system
# 3 clients-Harry,Rohan,Hammad
# total 6 user defined files
# write a function that when executed takes as input client name
# order of print :[]"chicken butter"
#define one more function to retrieve exercise or food for any client
def gettime():
import datetime
return datetime.datetime.now()
def enter(k):
if k==1:
c=int(input("Press 1 for Exercise\nPress 2 for food\n"))
if c==1:
value=input("Type here \n")
with open('Harry_Exercise.txt','a') as f:
f.write("["+str(gettime)+']'+ value+'\n')
print("Written Successfully ")
elif c==2:
value = input("Type here \n")
with open('Harry_food.txt', 'a') as f:
f.write("[" + str(gettime) + ']' + value + '\n')
print("Written Successfully ")
elif k==2:
c = int(input("Press 1 for Exercise\nPress 2 for food\n"))
if c == 1:
value = input("Type here \n")
with open('Rohan_Exercise.txt', 'a') as f:
f.write("[" + str(gettime) + ']' + value + '\n')
print("Written Successfully ")
elif c == 2:
value = input("Type here \n")
with open('Rohan_food.txt', 'a') as f:
f.write("[" + str(gettime) + ']' + value + '\n')
print("Written Successfully ")
elif k==3:
c = int(input("Press 1 for Exercise\nPress 2 for food\n"))
if c == 1:
value = input("Type here \n")
with open('Hammad_Exercise.txt', 'a') as f:
f.write("[" + str(gettime) + ']' + value + '\n')
print("Written Successfully ")
elif c == 2:
value = input("Type here \n")
with open('Hammad_food.txt', 'a') as f:
f.write("[" + str(gettime) + ']' + value + '\n')
print("Written Successfully ")
else:
print("INVALID INPUT")
def retrieve(z):
if z==1:
w=int(input("Press 1 for Exercise\nPress 2 for Food\n"))
if w==1:
with open("Harry_Exercise.txt") as f:
for i in f:
print(i,end=' ')
if w==2:
with open("Harry_food.txt") as f:
for i in f:
print(i,end=" ")
elif z==2:
w = int(input("Press 1 for Exercise\nPress 2 for Food\n"))
if w == 1:
with open("Rohan_Exercise.txt") as f:
for i in f:
print(i, end=' ')
if w == 2:
with open("Rohan_food.txt") as f:
for i in f:
print(i, end=" ")
elif z==3:
w = int(input("Press 1 for Exercise\nPress 2 for Food\n"))
if w == 1:
with open("Hammad_Exercise.txt") as f:
for i in f:
print(i, end=' ')
if w == 2:
with open("Hammad_food.txt") as f:
for i in f:
print(i, end=" ")
else:
print("INVALID INPUT")
x=int(input("Press 1 to Log the info\nPress 2 to Retrieve\n"))
if x==1:
y=int(input(" Press the following key \n 1--Harry\n 2--Rohan\n 3--Hammad\n"))
enter(y)
elif x==2:
y=int(input(" Press the following key \n 1--Harry\n 2--Rohan\n 3--Hammad"))
retrieve(y)
else:
print("INVALID INPUT")
THE AFOREMENTIONED CODE IS WRITTEN BY ME !!
THE IDEAL CODE I.E. BEST POSSIBLE CODE IS MENTIONED BELOW:
# Health Management System
client_list = {1: "Harry", 2: "Rohan", 3: "Hammad"}
lock_list = {1: "Exercise", 2: "Diet"}
def getdate():
import datetime
return datetime.datetime.now()
try:
print("Select Client Name:")
for key, value in client_list.items():
print("Press", key, "for", value, "\n", end="")
client_name = int(input())
print("Selected Client : ", client_list[client_name], "\n", end="")
print("Press 1 for Lock")
print("Press 2 for Retrieve")
op = int(input())
if op == 1:
for key, value in lock_list.items():
print("Press", key, "to lock", value, "\n", end="")
lock_name = int(input())
print("Selected Job : ", lock_list[lock_name])
f = open(client_list[client_name] + "_" + lock_list[lock_name] + ".txt", "a")
k = 'y'
while (k =="y" or k=='Y'):
print("Enter", lock_list[lock_name], "\n", end="")
mytext = input()
f.write("[ " + str(getdate()) + " ] : " + mytext + "\n")
k = input("ADD MORE ? y/n:")
continue
f.close()
elif op == 2:
for key, value in lock_list.items():
print("Press", key, "to retrieve", value, "\n", end="")
lock_name = int(input())
print(client_list[client_name], "-", lock_list[lock_name], "Report :", "\n", end="")
f = open(client_list[client_name] + "_" + lock_list[lock_name] + ".txt", "r")
contents = f.readlines()
for line in contents:
print(line, end="")
f.close()
else:
print("Invalid Input !!!")
except Exception as e:
print("Wrong Input !!!")
Comments
Post a Comment