Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 8 of 8

Thread: **Struggling severly can any expert help**

  1. #1
    Junior Member
    Join Date
    Dec 2013
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default **Struggling severly can any expert help**

    I've been trying to get this done for days and the deadline is tomorrow...


    The patients who are registered at the Smiley GoodDoctors practice can see any of the specialists. The practice keeps track of patients, doctors, and visits by patients to doctors in three text files. When the patient information system is booted up, it initializes itself by loading information from these files. Then, it present a menu based interface to the front desk staff. Staff can add patients, doctors, and record visits. They can also list visit information in various ways, and confirm appointments. When the system is shut down, all new doctors, patients, and visits are written into the text files so that they will be in the system.
    The format for the patient file is as follows Fname|Lname|ssn|city|state
    The format for the doctor file is Fname|Lname|npi|specialty
    The format for the visit file is Patientssn|npi|date
    Note: NPI refers to National Provider ID, which is a 10 digit number that identifies all health providers for insurance purposes. Sample data files are provided with the assignment, but you should add additional records for testing.
    The functionality provided in the menu system should be as follows:  Add a patient  Add a doctor  Add a visit
     List all visits on a given date. The display should show patient name and ssn, provider name and specialty, and the date. The display should be sorted by provider name.
     List all visits for a patient. The display should show provider name, specialty, and the date. The display should be sorted by date.
     List all visits for a provider. The display should show patient name, ssn, and the date. The display should be sorted by patient last name.
     Confirm if a particular patient has or had an appointment with a particular doctor on a given date.

    please help!

    the Patient, doctor, and visit classes are completely finished I'm just struggling with the menu system and the menu itself and I have been lost completely

    import java.io.*;
    import java.util.*;
     
     
     
    public class MenuSystem 
    {
    	private ArrayList<Patient> patients;
    	private ArrayList<Visit> visits;
    	private ArrayList<Doctor> physicians;	
     
    	public MenuSystem()
    {
    	patients = new ArrayList<Patient>();
    	visits = new ArrayList<Visit>();
    	physicians = new ArrayList<Doctor>();
     
    }	
     
    	public void writePatient()
    	{
     
    		try {
    			ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream("Patients.txt"));
    			os.writeObject(patients);
    			os.close();
    		} catch (FileNotFoundException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		} catch (IOException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}
     
    	}
     
    	public void readPatient()
    	{
     
    		try{
    		ObjectInputStream is = new ObjectInputStream(new FileInputStream("Patients.txt"));
    		Patient p = (Patient) is.readObject();
    		System.out.print(p.toString());
    		is.close();
    		} catch (FileNotFoundException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		} catch (IOException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		} catch(ClassNotFoundException e){
    			e.printStackTrace();
    		}
     
     
    	}
     
     
    	public void addPatient(Patient name)
    	 {
    		patients.add(name);
     
    	 }
     
    	public void addPhysician(Doctor physician)
    	{
    		physicians.add(physician);
    	}
     
    	public void addVisit(Visit visit)
    	{
    		visits.add(visit);
    	}
     
     
    }


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,803
    My Mood
    Mellow
    Thanks
    236
    Thanked 717 Times in 703 Posts

    Default Re: **Struggling severly can any expert help**

    Please read the Announcement topic at the top of the sub-forum to learn how to post code in code or highlight tags and other useful info for newcomers. I believe you can edit your post to fix it.

  3. #3
    Junior Member
    Join Date
    Dec 2013
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: **Struggling severly can any expert help**

    fixed

  4. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,803
    My Mood
    Mellow
    Thanks
    236
    Thanked 717 Times in 703 Posts

    Default Re: **Struggling severly can any expert help**

    This part of the assignment describes the menu and the items it should have:

    " . . . it present a menu based interface to the front desk staff. Staff can add patients, doctors, and record visits. They can also list visit information in various ways, and confirm appointments. When the system is shut down, . . . "

    Can you pick out the necessary menu items from that description and present them to the user to make a choice?

  5. #5
    Junior Member
    Join Date
    Dec 2013
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: **Struggling severly can any expert help**

    The best way for me to answer this question is that this is what the exact output is supposed to be:

    Please enter a command
    AP: Add a patient
    AD: Add a doctor
    V: Record a visit
    LP: List the visits for a given patient
    LD: List the visits for a given doctor
    D: List the visits on a given date
    Q: quit
    >>>>>>
    LP
    Please enter the patient's ssn
    333-33-3333
    Visit date: 08/19/2013
    Patient: Heather Smith 333-33-3333
    Physician: Sarah Wasserman internal medicine
    Please enter a command
    AP: Add a patient
    AD: Add a doctor
    V: Record a visit
    LP: List the visits for a given patient
    LD: List the visits for a given doctor
    D: List the visits on a given date
    Q: quit
    >>>>>>
    LD
    Please enter the doctor's NPI
    444
    That doctor has not seen any patients
    Please enter a command
    AP: Add a patient
    AD: Add a doctor
    V: Record a visit
    LP: List the visits for a given patient
    LD: List the visits for a given doctor
    D: List the visits on a given date
    Q: quit
    >>>>>>
    LD
    Please enter the doctor's NPI
    1233355589
    Visit date: 11/23/2012
    Patient: Janice Snealy 233-45-2222
    Physician: Jeff Goldman pediatrics
    Visit date: 11/25/2012
    Patient: Janice Snealy 233-45-2222
    Physician: Jeff Goldman pediatrics
    Please enter a command
    AP: Add a patient
    AD: Add a doctor
    V: Record a visit
    LP: List the visits for a given patient
    LD: List the visits for a given doctor
    D: List the visits on a given date
    Q: quit
    >>>>>>
    D
    Please enter the date in mm/dd/yy format
    11/25/2012
    Visit date: 11/25/2012
    Patient: Janice Snealy 233-45-2222
    Physician: Jeff Goldman pediatrics
    Please enter a command
    AP: Add a patient
    AD: Add a doctor
    V: Record a visit
    LP: List the visits for a given patient
    LD: List the visits for a given doctor
    D: List the visits on a given date
    Q: quit
    >>>>>>
    AD
    Enter first name 
    Bernice
    Enter last name 
    Wasserman
    Enter National Provider ID 
    1233355555
    Enter specialty 
    oncology
    Doctor added
    Please enter a command
    AP: Add a patient
    AD: Add a doctor
    V: Record a visit
    LP: List the visits for a given patient
    LD: List the visits for a given doctor
    D: List the visits on a given date
    Q: quit
    >>>>>>
    AP
    Enter first name 
    Sally
    Enter last name 
    Timmsman
    Enter social security number 
    555-66-7878
    Enter city 
    Bedford
    Enter state 
    MA
    Patient added
    Please enter a command
    AP: Add a patient
    AD: Add a doctor
    V: Record a visit
    LP: List the visits for a given patient
    LD: List the visits for a given doctor
    D: List the visits on a given date
    Q: quit
    >>>>>>
    V
    Enter National Provider ID 
    1233355589
    Enter patient ssn 
    555-66-7878
    Enter date of visit 
    11/15/2013
    Please enter a command
    AP: Add a patient
    AD: Add a doctor
    V: Record a visit
    LP: List the visits for a given patient
    LD: List the visits for a given doctor
    D: List the visits on a given date
    Q: quit
    >>>>>>
    Q
    Bye!

  6. #6
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,803
    My Mood
    Mellow
    Thanks
    236
    Thanked 717 Times in 703 Posts

    Default Re: **Struggling severly can any expert help**

    Now that you have that detail, what help do you need?

  7. #7
    Junior Member
    Join Date
    Dec 2013
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: **Struggling severly can any expert help**

    LP: List the visits for a given patient
    LD: List the visits for a given doctor
    D: List the visits on a given date

    I cant seem to figure this out for my life, also for some stringtokenizer for splitting the files into delimiters

    --- Update ---

    this is my new code:

    import java.io.*;
    import java.util.*;
     
     
     
    public class MenuSystem 
    {
    	private ArrayList<Patient> patients;
    	private ArrayList<Visit> visits;
    	private ArrayList<Doctor> doctors;	
     
    	public MenuSystem()
    {
    	patients = new ArrayList<Patient>();
    	visits = new ArrayList<Visit>();
    	doctors = new ArrayList<Doctor>();
     
     
    }
     
    	public void addPatient(String fname, String lname, String ssn, String city, String state) {
     
     
    		Patient patient = new Patient(fname,lname,ssn,city,state);
     
    		try{
    			FileReader fr = new FileReader("Patients.txt");
    			BufferedReader br = new BufferedReader(fr);
    			String str;
     
    			while ((str = br.readLine()) != null){	
    				patients.add(patient);
    				System.out.println(str + "\n");
     
    			}
    				br.close();
    		} catch (IOException e){
     
    		}
    	}
     
    	public void writeToPatient(String textToWrite){
    		try{
    			final String outputPath = "Patients.txt";
    			FileWriter fw = new FileWriter(outputPath, true);
    			fw.write(textToWrite);
    			Writer out = new BufferedWriter(fw);
    			int s = patients.size();
    			for(int i = 0; i < s; i++){
    				out.write(patients.get(i).toString());
    			}
    			out.close();
    		}catch(Exception e){	
    	}
    	}
     
    	public ArrayList<Patient>getpatients(){
    		return patients;
    	}
     
    	public Patient find(String patient)
    	   {  
    	      for (Patient p : patients)
    	         if (p.toString().equals(patient))
    	            return p;
     
    	      return null;
    	   }
     
    public void addDoctor(String Fname, String Lname, String npi, String special) {
     
    		Doctor doctor = new Doctor(Fname,Lname,npi,special);
    		try{
    			FileReader fr = new FileReader("doctors.txt");
    			BufferedReader br = new BufferedReader(fr);
     
    			String str;
     
    			while ((str = br.readLine()) != null){	
    				doctors.add(doctor);
    				System.out.println(str + "\n");
    			}
    				br.close();
    		} catch (IOException e){
    		}
    	}
     
    public void writeToDoctor(String textToWrite){
    	try{
    		final String outputPath = "doctors.txt";
    		FileWriter fw = new FileWriter(outputPath, true);
    		fw.write(textToWrite);
    		Writer out = new BufferedWriter(fw);
    		int s = doctors.size();
    		for(int i = 0; i < s; i++){
    			out.write(doctors.get(i).toString());
    		}
    		out.close();
    	}catch(Exception e){
     
    	}
    }
    	public ArrayList<Doctor>getdoctors(){
    		return doctors;
    	}
     
    	public Doctor findDoctor(String doctor)
    	   {  
    	      for (Doctor d : doctors)
    	         if (d.toString().equals(doctor))
    	            return d;
     
    	      return null;
    	   }
     
    public void addVisit(String date, String social, String npi){
     
    	Visit visit = new Visit(date, social, npi);
     
    	try{
    		FileReader fr = new FileReader("visits.txt");
    		BufferedReader br = new BufferedReader(fr);
     
    		String str;
     
    		while ((str = br.readLine()) != null){	
    			visits.add(visit);
    			System.out.println(str + "\n");
    		}
    			br.close();
    	} catch (IOException e){
    	}
    }
     
    public void writeToVisit(String textToWrite){
    try{
    	final String outputPath = "visits.txt";
    	FileWriter fw = new FileWriter(outputPath, true);
    	fw.write(textToWrite);
    	Writer out = new BufferedWriter(fw);
    	int s = visits.size();
    	for(int i = 0; i < s; i++){
    		out.write(visits.get(i).toString());
    	}
    	out.close();
    }catch(Exception e){
     
    }
    }
    public ArrayList<Visit>getvisits(){
    	return visits;
    }
     
    public Visit findVisit(String visit)
       {  
          for (Visit v : visits)
             if (v.toString().equals(visit))
                return v;
     
          return null;
       }
     
     
     
    }

  8. #8
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,803
    My Mood
    Mellow
    Thanks
    236
    Thanked 717 Times in 703 Posts

    Default Re: **Struggling severly can any expert help**

    Jeesh! Getting a straight answer from you is like pulling teeth. Can you see that your first post and post #7 have almost nothing in common? And we still don't know what you need help with. The three menu items you listed are simple counters, probably best stored as fields in a class.

    As for StringTokenizer, show how you're trying to use it, the format of the data file you're saving to record the office's business. You may want to store objects (patient, doctor, office, etc.), OR more simply just store the data as Strings and use the split() method to break the data at commas or some other acceptable delimiter.

Similar Threads

  1. anybody expert in java???
    By navxxxx in forum What's Wrong With My Code?
    Replies: 2
    Last Post: December 14th, 2012, 09:37 AM
  2. XMPP Expert needed. High Payout!
    By padredox in forum Paid Java Projects
    Replies: 1
    Last Post: May 8th, 2012, 08:42 AM
  3. java expert
    By dilawar in forum Member Introductions
    Replies: 0
    Last Post: June 17th, 2011, 02:11 AM
  4. Greting all Java Expert
    By narutomatic2006 in forum Member Introductions
    Replies: 1
    Last Post: November 13th, 2010, 01:27 PM
  5. hello all java expert
    By dread_arisawa in forum Member Introductions
    Replies: 1
    Last Post: August 19th, 2010, 08:18 AM