In: Computer Science
'''
File: pyPatientLL.py
Author: JD
'''
class Node: #ADT
def __init__(self, p = None):
self.name = ""
self.ss = self.age = int(0)
self.smoker = self.HBP = self.HFD = self.points = int(0)
self.link = None
#if list not empty
if p != None:
p.link = self
ptrFront = ptrEnd = None
choice = int(0)
def menu():
print( "\n\tLL Health Clinic\n\n")
print( "1. New patient\n")
print( "2. View patient by SS#\n")
print( "3. Update patient's record\n")
print( "4. Quit the App\n\n")
print( "Enter your choice: ")
def getChoice():
choice = int(input(""))
# Validate the menu selection
while ((choice < 1) or (choice > 4)):
print( "Please enter 1, 2, 3, or 4: ")
choice = int(input(""))
return choice
def getInfo(ptr): #Populate the record
ptr.name = input("Enter patient's name: ")
ptr.age = int(input("Enter age: "))
ptr.ss = int (input("Enter patient's SS: "))
habits = input("Enter habits 1/0: smoker, HBP, HFD:").split()
ptr.smoker, ptr.HBP, ptr.HFD = map(int, habits)
calPoints(ptr)
# implement flowchart here
def calPoints(ptr):
pass
def searchBySS(ptr, ssKey): #search by SS
pass
def dispPatient(ptr): #disp record
pass
def updatepatinet(ptr): #update any habits (smoking, HBP, HFD)
pass #recalculate points
def processChoice(choice):
ptr = None
global ptrEnd
global ptrFront
# Procee based on user input
if choice == 1: #New patinet
if (ptrEnd == None):
ptrEnd = ptrFront = Node(ptrEnd)
else:
ptrEnd = Node(ptrEnd)
getInfo(ptrEnd) #Populate the record
elif choice == 2: #case 2 find patient
key = int(input("Enter SS: "))
if (ptr == searchBySS(ptrFront, key)):
dispPatient(ptr)
else:
print ("\nRecord not found\n\n")
elif choice == 3: #case 3 update patient
key = int(input("Enter SS: "))
if (ptr == searchBySS(ptrFront, key)):
updatepatinet(ptr)
else:
cout<<"\nRecord not found\n\n";
def main():
do = bool(True)
while(do == True):
menu()
choice = getChoice()
if choice == 4:
do = False
else:
processChoice(choice)
#call main
main()
KEEP THE PYTHON CODE AS IT IS and try the python singly linked list code first and ask questions.
Secondly implement the functions having just "pass" one at a time and fully test and move on to next function.
"calPoints function" is implemented based on the flowchart you will find in the announcement section.