Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

class Node: def _ _ init _ _ ( self , filename, date _ time ) : self.filename = filename self.date _ time = date

class Node: def __init__(self, filename, date_time): self.filename = filename self.date_time = date_time self.next = None class LinkedList: def __init__(self): self.head = None def insert(self, filename, date_time): new_node = Node(filename, date_time) if self.head is None or self.head.date_time > date_time: new_node.next = self.head self.head = new_node else: current = self.head while current.next and current.next.date_time < date_time: current = current.next new_node.next = current.next current.next = new_node def print_list(self): current = self.head while current: print(current.filename) current = current.next def display_menu(): print("
Menu:") print("1. View patient visit list") print("2. Add new patient visit") print("3. Exit") def add_new_visit(linked_list): patient = input("Enter patient name: ") date_time = input("Enter visit date and time (YYYYMMDD_HHMM): ") filename = f"{patient}_{date_time}" linked_list.insert(filename, date_time) print("New patient visit added.") def main(): # Simulated data patients_visits =[("Alice","20230520_0930"),("Bob","20230521_1030"),("Alice","20230522_1100"),("Charlie","20230522_1130"),("David","20230523_1230"),("Eve","20230524_1330"),("Alice","20230524_1430"),("Frank","20230525_1530"),("George","20230526_1630"),("Henry","20230527_1730"),("Ivy","20230528_1830"),("Jack","20230529_1930"),("Bob","20230530_2030"),("Charlie","20230601_2130"),("Bob","20230602_2230"),] # Create linked list and add data ll = LinkedList() for patient, datetime in patients_visits: filename = f"{patient}_{datetime}" ll.insert(filename, datetime) while True: display_menu() choice = input("
Enter your choice: ") if choice =='1': print("
List of patient visit filenames:") ll.print_list() elif choice =='2': add_new_visit(ll) elif choice =='3': print("
Exiting the program.") break else: print("
Invalid choice. Please try again.") if __name__=="__main__": main()add comments and explanation

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spomenik Monument Database

Authors: Donald Niebyl, FUEL, Damon Murray, Stephen Sorrell

1st Edition

0995745536, 978-0995745537

More Books

Students also viewed these Databases questions

Question

Explain the various techniques of Management Development.

Answered: 1 week ago

Question

What are the issues of concern for each of the affected parties?

Answered: 1 week ago

Question

What steps should be taken to address any undesirable phenomena?

Answered: 1 week ago