DevelopmentJava
CV | My profile | Photo gallery
Development
C/C++
Java
  Chat room
  Matlab interface
PHP/SQL/HTML
Visual Basic
Perl
 
 
 
 
 

 

DevelopmentJavaDoctor's Appointment

Under construction

Background

A specialist doctor has requested a personalised booking system for his surgery with the following requirements and specifications. Your task is to create this system accordingly. The first version of the application uses a command line (console application). The second version will use the java SWING package for the graphic user interface. We are required to use collections not Array’s to maintain any information lists. The selection of appropriate collection types is an important step in the design process. The application takes bookings for one week only Monday to Friday 8:00 am to 5:00 pm with one hour reserved for lunch between 12:00 to 1:00. Each consultation is to be booked as ten minutes with options for patients to book two ten minute slots consecutively. The price of a consultation for a ten minute slot is $45.50. Unless the patient is from a referring doctor in which case the consultation price is $75.00 per ten minute slot.

Data storage

At the start of the application we pass the path and the file name of the bookings and referring doctors file from the command line. These files should are read by the application to initialise the current bookings since the last application shutdown.The bookings file have this format:
Day, Time, patient’s last name, patient’s first name, referring doctor ID

Referring doctor file contains details of the doctors that have referred their details for
consultation. The referring doctors file has this format:
Doctor ID, doctor’s last name, doctor’s first name, date of the referral

Options

Option
Description
A

Add a booking
use case:

  1. The application prompts the day of the week. The user enters the id for the selected day
  2. Application prompts the booking details. Details are entered
  3. If the booking is available for the day the application reserves the time slot for the patient, otherwise a message is displayed that the time slot has already been reserved for another patient, and stored to the errors file.
    1. If the time slot is free, an option should is given to book a longer consultation (two consecutive ten minute times’ slots). If the second ten minute time slot is already reserved then an appropriately worded message is displayed, and stored to the errors file.
  4. If a patient has been referred,
    1. The user enters the referring doctor’s last name when prompted.
    2. The program then checks the referring doctors list to find a match. If more than one match is found, they are displayed so that the user can select one of them.
    3. If no matches are found, the user is then prompted for the details (see referring doctors file) of that referring doctor, and added to the list of referring doctors with appropriate ID.
    4. The modified doctors list is to be saved back to the doctors file when the application is shut down.

D

Delete a booking
Use case:

  1. Application first prompt for the day of the week the Booking had been made followed by the time slot.
  2. Use enter the the required details
  3. If the time slot is booked the application displays details of the booking and then ask to confirm the deletion process
  4. Use confirms deletion
  5. Application deletes the booking but does not remove the doctor from the list
F
Lists available free bookings
When listing all the available free time slots for the week they must be in time order.
L
List all the patients
List all the patients for the week. They must be in the order of the number of
bookings they have per week.
RP
List referral doctors with a list of patients for each referring doctor
This option lists all the referral doctors, in alphabetical order of their last name. For each doctor list the patients last names.
R
List referral doctors and the number of patients referred
This option lists all the referral doctors and the number of the patients that each doctor referred. The doctors must be listed in alphabetical order of their last name, and the total number of patients that this doctor referred for the week
E
List the error file
E Read the error file and show the contents of the file to the screen in a readable format
X
Terminate the application

 

Console version

Controller

The main tread in contained in the class named named DoctorsAppoinmets. This is the controller for our application. It interacts with with user and delegates work to the appropriates objects, and returns the results to the user. The code snippet below shows a snapshot of the main method.
		//Get two file names from command line.
        if (args.length != 2) {
        	System.err.println("Input file(s) missing. Please specify the booking's\n" +
        			"and/or the doctors referral file.");
            System.err.println("Usage: java DoctorAppointments bookings'file doctors'file");
            System.exit(1);
        }	
    
        bookings = new File (args[0]);	// the that contains the previous bookings
        docs = new File(args[1]);		// the referral doctors' file
        err = new File(errorsFileStr);	// the errors' file
        
        //Check if the files exist
        if (!bookings.exists()){
            System.err.println("The file "+args[0]+" does not exist!");
            System.exit(1);
        }
        if (!docs.exists()){
            System.err.println("The file "+args[1]+" does not exist!");
            System.exit(1);
        }
        if (!err.exists()){
            System.err.println("The file "+errorsFileStr+" does not exist!");
            System.exit(1);
        }
        //Initialize
		DoctorAppointments app = new DoctorAppointments(bookings, docs, errorsFileStr);
		
		// wait for user input
		app.printStartApp();
		
		BufferedReader std = new BufferedReader( 
		        new InputStreamReader( System.in ) );
		while ((option = std.readLine()) != null) {
			
			if (option.equalsIgnoreCase("X")) {
				System.out.println( "Thanks for using this application");
				app.save();
				System.exit(0);
			}
			else if (option.equalsIgnoreCase("A"))
				app.addBooking (std);
			else if (option.equalsIgnoreCase("D"))
				app.deleteBooking(std);
			else if (option.equalsIgnoreCase("F"))
				app.showFreeBookings(std);
			else if (option.equalsIgnoreCase("R"))
				app.showReferralDoctors(std);
			else if (option.equalsIgnoreCase("L"))
				app.showAllPatients(std);
			else if (option.equalsIgnoreCase("RP"))
				app.showReferralDoctorsPatient(std);
			else if (option.equalsIgnoreCase("E"))
				app.showErrors(std);
			else {
				System.out.println( "The option "+ option + " is not recognized");
					

The method starts by checking the input arguments for the names of the two files needed for intialization. We then check if the files exist, and create our man controller (DoctorAppoinments). The application then waits for user input from the command line as show below

Adding a booking

If the user enters "A", the control invokes the method addBooking (...) to service this request