CV | My profile | Photo gallery
  Chat room
  Matlab interface
Visual Basic


DevelopmentJavaDoctor's Appointment

Under construction


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



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.


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
Lists available free bookings
When listing all the available free time slots for the week they must be in time order.
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.
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.
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
List the error file
E Read the error file and show the contents of the file to the screen in a readable format
Terminate the application


Console version


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");
        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!");
        if (!docs.exists()){
            System.err.println("The file "+args[1]+" does not exist!");
        if (!err.exists()){
            System.err.println("The file "+errorsFileStr+" does not exist!");
		DoctorAppointments app = new DoctorAppointments(bookings, docs, errorsFileStr);
		// wait for user input
		BufferedReader std = new BufferedReader( 
		        new InputStreamReader( ) );
		while ((option = std.readLine()) != null) {
			if (option.equalsIgnoreCase("X")) {
				System.out.println( "Thanks for using this application");;
			else if (option.equalsIgnoreCase("A"))
				app.addBooking (std);
			else if (option.equalsIgnoreCase("D"))
			else if (option.equalsIgnoreCase("F"))
			else if (option.equalsIgnoreCase("R"))
			else if (option.equalsIgnoreCase("L"))
			else if (option.equalsIgnoreCase("RP"))
			else if (option.equalsIgnoreCase("E"))
			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