diff --git a/.idea/copilot.data.migration.ask2agent.xml b/.idea/copilot.data.migration.ask2agent.xml new file mode 100644 index 0000000..1f2ea11 --- /dev/null +++ b/.idea/copilot.data.migration.ask2agent.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index fdc35ea..17e9c2e 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,3 @@ - diff --git a/src/main/java/org/codedifferently/GlennAppointment.java b/src/main/java/org/codedifferently/GlennAppointment.java new file mode 100644 index 0000000..4b0ae0a --- /dev/null +++ b/src/main/java/org/codedifferently/GlennAppointment.java @@ -0,0 +1,74 @@ +package org.codedifferently; + +public class GlennAppointment { + private String timeSlot; + private GlennPatient patient; + private boolean completed; + private boolean cancelled; + + //Constructor + public GlennAppointment(String timeSlot, GlennPatient patient) { + this.timeSlot = timeSlot; + this.patient = patient; + this.completed = false; + this.cancelled = false; + } + + +//Getters + public GlennPatient getPatient() { + return patient; + } + + public boolean isCompleted() { + return completed; + } + + public boolean isCancelled() { + return cancelled; + } + +//Setter + public void setTimeSlot(String timeSlot) { + if (timeSlot != null && !timeSlot.trim().isEmpty()) { + this.timeSlot = timeSlot; + } else { + System.out.println("Invalid Time"); + } + } + + + +//Method + public void complete() { + if (cancelled) { + System.out.println("Appointment was cancelled"); + return; + } + if (completed) { + System.out.println("Appointment was already completed"); + return; + } + completed = true; + System.out.println("Appointment was check as completed"); + } + + public void cancel() { + if (completed) { + System.out.println("Can't cancel completed appointment"); + return; + } + if (cancelled) { + System.out.println("Appointment already canceled"); + return; + } + cancelled = true; + System.out.println("Appointment already canceled"); + } + + public String toString() { + return timeSlot + "|" + patient.getName() + " | Completed: " + completed + " | Canceled: " + cancelled; + } + + +} diff --git a/src/main/java/org/codedifferently/GlennClinicApp.java b/src/main/java/org/codedifferently/GlennClinicApp.java new file mode 100644 index 0000000..7047165 --- /dev/null +++ b/src/main/java/org/codedifferently/GlennClinicApp.java @@ -0,0 +1,84 @@ +package org.codedifferently; +import java.util.Scanner; + +public class GlennClinicApp{ + public static void main(String[] args) { + + + theClinic(); + + } + +//The Method That Directs the user to all the methods in the System class + public static void theClinic() { + Scanner scan = new Scanner(System.in); + GlennClinicSystem system = new GlennClinicSystem(); + + +do { + System.out.println("Welcome to Derwin & Glenn's Geek Squad"); + System.out.println(""" + 1. Add New Customer + 2. View All Customers + 3. Check In Customers + 4. Search for Customers + 5. Schedule Appointment + 6. Cancel Appointment + 7. Complete Appointment + 8. View Daily Schedule + 9. Daily Report + 10. Exit"""); + int choice = scan.nextInt(); + + switch (choice) { + case 1: + System.out.println("Enter Customer's Name: "); + String patientName = scan.next(); + + system.addPatient(patientName); + break; + + case 2: + System.out.println("Customer LIST"); + system.patientList(); + break; + case 3: + system.checkPatientIn(); + + break; + case 4: + system.searchPatient(); + break; + case 5: + system.schedulePatient(); + break; + case 6: + system.cancelAppointment(); + break; + case 7: + system.completeAppointment(); + case 8: + system.dailySchedule(); + break; + case 9: + system.dailyReport(); + break; + case 10: + System.out.println("Goodbye, Thanks For Coming!"); + System.exit(0); + break; + default: + System.out.println("Invalid Option"); + break; + + + } +}while(true); + + + + + + } +} + diff --git a/src/main/java/org/codedifferently/GlennClinicSystem.java b/src/main/java/org/codedifferently/GlennClinicSystem.java new file mode 100644 index 0000000..6c89e15 --- /dev/null +++ b/src/main/java/org/codedifferently/GlennClinicSystem.java @@ -0,0 +1,360 @@ +package org.codedifferently; + + +import java.util.ArrayList; +import java.util.Scanner; + +public class GlennClinicSystem { + + // Properties + + // (private and final because the values can't be changed nor accessed outside this class) + + // Array List for the Glenn Patient class, this holds newly created patient objects + // that allows us to track the patients individual properties + // same for the Glenn Appointment Array List + private final ArrayList patients = new ArrayList<>(); + private final ArrayList appointments = new ArrayList<>(); + + // Array made for time slots, this just holds the available times the user can book + private final String[] timeSlots = {"9:00 AM", "10:00 AM", "11:00 AM", "1:00 PM", "2:00 PM"}; + // Array made with the Appointment Class, holds the properties of the class + // has the same amount of cells as the timeslot array + private final GlennAppointment[] schedule = new GlennAppointment[timeSlots.length]; + + // Use ONE scanner for the system + private final Scanner scan = new Scanner(System.in); + + //Behaviors + + //uses a for each loop to search through the array + // print out ever patient object's name, id, and check in status + // if customers array is Empty say no customers found + public void patientList(){ + + if (patients.isEmpty()) { + System.out.println("No Customer found."); + return; + } + /* + for (int i =0; i < patients.size(); i++){ + GlennPatient p = new GlennPatient(); + + System.out.println("ID: " + p.getId() + + " | Name: " + p.getName() + + " | Checked In: " + p.isCheckedIn()); + + } + + */ + + + for (GlennPatient p : patients) { + System.out.println("ID: " + p.getId() + + " | Name: " + p.getName() + + " | Checked In: " + p.isCheckedIn()); + } + + } + + //create new customers object, add it to the array, print out unique ID + public void addPatient(String name){ + + + GlennPatient p = new GlennPatient(); + p.setName(name); + + patients.add(p); + + System.out.println("Customer added successfully!"); + System.out.println("Customer ID: " + p.getId()); + + + } + + //ask user for ID + //search through the array to see if user given + // id matches any id of a patient object in the array + // call checkin to make true + // set found to true if not found say so + public void checkPatientIn(){ + + System.out.println("Enter Customer ID to check"); + int patientId = scan.nextInt(); + + scan.nextLine(); // consume leftover newline + + boolean found = false; + + for (GlennPatient p : patients) { + if (p.getId() == patientId) { + p.checkIn(); // changes checkedIn to true + System.out.println("Customer " + p.getName() + " checked in successfully."); + found = true; + break; // stop looping once we found them + } + } + + if (!found) { + System.out.println("No Customer found with ID: " + patientId); + } + + + } + + + //Find customer with the given ID using for loop + public void searchPatient(){ + if (patients.isEmpty()) { + System.out.println("No Customer exist yet. Add a patient first."); + + + } + System.out.print("Enter Customer ID to Find: "); + int patientId = scan.nextInt(); + + for (GlennPatient p : patients){ + + if(p.getId() == patientId){ + + System.out.println("Customer " + p.getName() + " is in the Database"); + System.out.println("ID: " + p.getId()); + System.out.println("Check In Status: " + p.isCheckedIn()); + System.out.println("Priority: " + p.getPriority()); + + } + } + + } + + //checks if customer array list is empty + // ask for customer ID from user + // if patient returns null it doesnt exist + // if Patient isnt checked in tell user to check in first + //ask for priority, set priority in the Patient object + // if emergency find the earliest available slot + // if regular you can choose any available slot + // follow ups can only be between 1pm or 2pm + + public void schedulePatient(){ + + if(patients.isEmpty()){ + System.out.println("No customers exist yet."); + return; + } + + System.out.print("Enter Customer ID: "); + int patientId = scan.nextInt(); + scan.nextLine(); + + GlennPatient p = findPatientById(patientId); + + if(p == null){ + System.out.println("Customer not found."); + return; + } + + if(!p.isCheckedIn()){ + System.out.println("Customer must be checked in first."); + return; + } + + System.out.print("Enter Priority (Emergency / Regular / Follow-Up): "); + String priority = scan.nextLine(); + p.setPriority(priority); + + + // EMERGENCY PATIENT + + if(p.getPriority().equals("EMERGENCY")){ + + int slotIndex = findEarliestAvailableSlot(); + + if(slotIndex == -1){ + System.out.println("No available slots today."); + return; + } + + GlennAppointment appt = new GlennAppointment(timeSlots[slotIndex], p); + schedule[slotIndex] = appt; + appointments.add(appt); + + System.out.println("Emergency Customer scheduled at " + timeSlots[slotIndex]); + return; + } + + + // REGULAR OR FOLLOW-UP + + + System.out.println("Available Time Slots:"); + + for(int i = 0; i < timeSlots.length; i++){ + + String status = (schedule[i] == null) ? "Available" : "Booked"; + System.out.println((i+1) + ". " + timeSlots[i] + " - " + status); + } + + System.out.print("Select Slot: "); + int slotChoice = scan.nextInt(); + + if(slotChoice < 1 || slotChoice > timeSlots.length){ + System.out.println("Invalid Slot"); + return; + } + + int slotIndex = slotChoice - 1; + + if(schedule[slotIndex] != null){ + System.out.println("Slot already booked."); + return; + } + + // FOLLOW-UP RULE + if(p.getPriority().equals("FOLLOW-UP")){ + + if(!isFollowUpSlot(slotIndex)){ + System.out.println("Follow-up customers can only be scheduled at 1:00 PM or 2:00 PM"); + return; + } + } + + GlennAppointment appt = new GlennAppointment(timeSlots[slotIndex], p); + schedule[slotIndex] = appt; + appointments.add(appt); + + System.out.println("Appointment scheduled at " + timeSlots[slotIndex]); + } + + +// deletes appointment object from the schedule array freeing up the spot in the cell + public void cancelAppointment(){ + + System.out.print("Enter Customer ID to cancel appointment: "); + int patientId = scan.nextInt(); + + int slotIndex = findSlotIndex(patientId); + if (slotIndex == -1) { + System.out.println("No scheduled appointment found for this patient."); + return; + } + + GlennAppointment appt = schedule[slotIndex]; + appt.cancel(); // marks canceled in the appointment object + schedule[slotIndex] = null; // frees the slot so it shows "Available" + + System.out.println("Appointment cancelled successfully."); + + } + + + // deletes appointment object from the schedule array freeing up the spot in the cell + public void completeAppointment(){ + + System.out.print("Enter Customer ID to complete appointment: "); + int patientId = scan.nextInt(); + + int slotIndex = findSlotIndex(patientId); + if (slotIndex == -1) { + System.out.println("No scheduled appointment found for this Customer."); + return; + } + + GlennAppointment appt = schedule[slotIndex]; + appt.complete(); // marks complete in the appointment object + schedule[slotIndex] = null; // frees the slot so it shows "Available" + + System.out.println("Appointment completed successfully."); + + } + + +// goes through the timeslots checking if its avalible +// if not show the name of the customers the took up said spot + public void dailySchedule(){ + + System.out.println("Daily Schedule:"); + for (int i = 0; i < timeSlots.length; i++) { + if (schedule[i] == null) { + System.out.println(timeSlots[i] + " - Available"); + } else { + GlennAppointment appt = schedule[i]; + System.out.println(timeSlots[i] + " - " + appt.getPatient().getName()); + } + } + + + } +//tells you the amount of customers checked in +//as well as patients currently scheduled +//completed and canceled appointments +// total number of customers + public void dailyReport(){ + + int checkedInCount = 0; + for (GlennPatient p : patients) { + if (p.isCheckedIn()) checkedInCount++; + } + + int scheduledCount = 0; + for (GlennAppointment a : schedule) { + if (a != null) scheduledCount++; + } + + int completedCount = 0; + int cancelledCount = 0; + for (GlennAppointment a : appointments) { + if (a.isCompleted()) completedCount++; + if (a.isCancelled()) cancelledCount++; + } + + System.out.println("Daily Summary Report"); + System.out.println("-------------------------"); + System.out.println("Total Customers: " + patients.size()); + System.out.println("Total Customers Checked In: " + checkedInCount); + System.out.println("Appointments Scheduled (active): " + scheduledCount); + System.out.println("Appointments Completed: " + completedCount); + System.out.println("Appointments Cancelled: " + cancelledCount); + + } + + // Methods for reused code throughout the program + private GlennPatient findPatientById(int id) { + for (GlennPatient p : patients) { + if (p.getId() == id) return p; + } + return null; + } + + private int findSlotIndex(int patientId) { + for (int i = 0; i < schedule.length; i++) { + if (schedule[i] != null && schedule[i].getPatient().getId() == patientId) { + return i; + } + } + return -1; + } + + private int findEarliestAvailableSlot(){ + + for(int i = 0; i < schedule.length; i++){ + + if(schedule[i] == null){ + return i; + } + } + + return -1; + } + + private boolean isFollowUpSlot(int slotIndex){ + + if(slotIndex == 3 || slotIndex == 4){ + return true; + } + + return false; + } + + +} diff --git a/src/main/java/org/codedifferently/GlennPatient.java b/src/main/java/org/codedifferently/GlennPatient.java new file mode 100644 index 0000000..d15393b --- /dev/null +++ b/src/main/java/org/codedifferently/GlennPatient.java @@ -0,0 +1,62 @@ +package org.codedifferently; + +import java.util.concurrent.atomic.AtomicInteger; + + +public class GlennPatient { + //Properties + // Makes it so our id counter is going up by 1 everytime someone is added + private static AtomicInteger idCounter = new AtomicInteger(1000); + private int id; + private String name; + private boolean checkedIn; + private String priority; // Emergency , Reg, Follow + +//Constructor + public GlennPatient() { + this.id = idCounter.getAndIncrement(); + this.checkedIn = false; + + } +//Getters + public int getId() { + return id; + } + + + public String getName() { + return name; + } + + public boolean isCheckedIn() { + return checkedIn; + } + +//Setters + public void setPriority(String priority){ + this.priority = priority.toUpperCase(); + } + + public String getPriority(){ + return priority; + } +//Methods + public void setName(String name) { + if (name != null && !name.trim().isEmpty()) { + this.name = name; + } else { + System.out.println("Invalid Name."); + } + } + + + public void checkIn() { + this.checkedIn = true; + } + +//toString + public String toString() { + return "ID: " + id + " | Name: " + name + " | " + "| Checked In: " + checkedIn; + } + +} diff --git a/src/main/java/org/codedifferently/Main.java b/src/main/java/org/codedifferently/Main.java deleted file mode 100644 index 435139b..0000000 --- a/src/main/java/org/codedifferently/Main.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.codedifferently; - -//TIP To Run code, press or -// click the icon in the gutter. -public class Main { - public static void main(String[] args) { - //TIP Press with your caret at the highlighted text - // to see how IntelliJ IDEA suggests fixing it. - System.out.printf("Hello and welcome!"); - - for (int i = 1; i <= 5; i++) { - //TIP Press to start debugging your code. We have set one breakpoint - // for you, but you can always add more by pressing . - System.out.println("i = " + i); - } - } -} \ No newline at end of file