diff --git a/CMSC 355 Requirements (1).pdf b/CMSC 355 Requirements (1).pdf new file mode 100644 index 000000000..1d1f210a7 Binary files /dev/null and b/CMSC 355 Requirements (1).pdf differ diff --git a/README.md b/README.md index b2588bc51..0e5bfe506 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,10 @@ -My groupmembers are: -- XXXX -- XXXX -- XXXX -- XXXX +This is a project for CMSC 355 - Software Engineering. +We attempted to make a medicine adherence system. It is a full stack program but very rudimentary as there was not much alloted time throughout the semester. The entirety of this project was coded in IntelliJIDE with each of the initial processes divided amongst the group. +---------------------------------------------------- +CSMC 355 Group Members: - ------------------- Fill in some information about your project under this ------------------ +- Zoya Ahktar +- Miya Collingwood +- Inayah O’Neil +- Cara Routh +- Shawn Watson diff --git a/Sprint 1/3.1 and 3.2.java b/Sprint 1/3.1 and 3.2.java new file mode 100644 index 000000000..a4189c654 --- /dev/null +++ b/Sprint 1/3.1 and 3.2.java @@ -0,0 +1,37 @@ +/* Medication Vaildation System 3.1 and 3.2 */ +import java.util; +import java.util.HashMap; +import java.util.Scanner; + +public class ValidateMedication { + private static final HashMap vaildMeds = new HashMap<>(); +static { + validMeds.put("Tyelnol", true); +} +public class TimeMedsTaken{ + private static final HashMap TimeVal = new HashMap<>(); + +static { + TimeVal.put("2:00 PM", true); +} +} +} + +public static void main(String[] args) { +Scanner scan = new Scanner(System.in); +System.out.println("Enter Medication name"); +String input = scan.nextLine(); +if (validMeds(input)){ + System.out.println("Medication Logged: Confirmed"); + System.out.println("Enter the time the medication was taken"); + String inputtime = scan.nextLine(); + if (TimeVal(inputtime)){ + System.out.println("Medication Time Logged: Confirm Positive Status"); + } else{ + System.out.println("Medication Time Logged: Confirm Negative Status"); + } +} else { + System.out.println("Input was incorrect. Please Try Again"); +} + +} \ No newline at end of file diff --git a/Sprint 1/Authentication.java b/Sprint 1/Authentication.java new file mode 100644 index 000000000..0529b12a4 --- /dev/null +++ b/Sprint 1/Authentication.java @@ -0,0 +1,59 @@ +/** + * Medical Adherence System + * Sprint 1 + * CMSC 355 - Fundamentals of Software Engineering + * + */ + +import java.util.HashMap; + +public class Authentication { + private HashMap users; + + //creates hashmap using current user + public Authentication(){ + this.users = new HashMap<>(); + } + + /** + * Checks availability of username + * @param username + * @return false if username is taken, true if username is available + */ + public boolean usernameAvail(String username){ + if(users.containsKey(username)){ + System.out.println("Username already taken."); + return false; + } + else { + return true; + } + } + + public boolean register(String username, String password) { + if (users.containsKey(username)) { + System.out.println("Username already taken."); + return false; + } + users.put(username, new User(username,password)); + System.out.println("User registerd successfully!"); + return true; + } + + public boolean login(String username, String password) { + if (!users.containsKey(username)){ + System.out.println("User not found"); + return false; + } + User user = users.get(username); + if (user.checkPassword(password)) { + System.out.println("login successful!"); + return true; + } + else { + System.out.println("Incorrect password."); + return false; + } + } + +} diff --git a/Sprint 1/CMSC 355 Test Cases.pdf b/Sprint 1/CMSC 355 Test Cases.pdf new file mode 100644 index 000000000..f2f1ea269 Binary files /dev/null and b/Sprint 1/CMSC 355 Test Cases.pdf differ diff --git a/Sprint 1/DoctorName.java b/Sprint 1/DoctorName.java new file mode 100644 index 000000000..238862023 --- /dev/null +++ b/Sprint 1/DoctorName.java @@ -0,0 +1,50 @@ +import java.util.*; + +public class DoctorName { + private static Map> doctorMedications = new HashMap<>(); + + public static void main(String[] args) { + // test data + doctorMedications.put("John Smith", Arrays.asList("Aspirin", "Ibuprofen")); + doctorMedications.put("Jane Doe", Arrays.asList("Paracetamol")); + + Scanner scanner = new Scanner(System.in); + + // Get doctor name from user + System.out.print("Enter doctor's first name: "); + String firstName = scanner.nextLine().trim(); + + System.out.print("Enter doctor's last name: "); + String lastName = scanner.nextLine().trim(); + + String fullName = firstName + " " + lastName; + + if (doctorMedications.containsKey(fullName)) { + System.out.println("Doctor found: " + fullName); + System.out.println("Menu Options:"); + System.out.println("1. View Medications"); + System.out.println("2. Enter a new Rx number"); + + System.out.print("Enter your choice: "); + int choice = scanner.nextInt(); + scanner.nextLine(); //newline + + switch (choice) { + case 1: + System.out.println("Medications: " + doctorMedications.get(fullName)); + break; + case 2: + System.out.print("Enter new Rx number: "); + String rxNumber = scanner.nextLine(); + System.out.println("Rx number " + rxNumber + " has been added."); + break; + default: + System.out.println("Invalid choice."); + } + } else { + System.out.println("Doctor not found in the system."); + } + + scanner.close(); + } +} \ No newline at end of file diff --git a/Sprint 1/Main.java b/Sprint 1/Main.java new file mode 100644 index 000000000..266bf047d --- /dev/null +++ b/Sprint 1/Main.java @@ -0,0 +1,89 @@ +/** + * Medical Adherence System + * Sprint 1 + * CMSC 355 - Fundamentals of Software Engineering + * + */ +import java.util.Scanner; + +public class Main { + + public static void main(String[] args){ + login(); //call in the login function + + } + + public static void login() { + + Authentication authentication = new Authentication(); + Scanner scr = new Scanner(System.in); + + while (true){ + System.out.println("\n1. Register\n2. Login\n3. Exit"); + System.out.println("Choose an option: "); + String choice = scr.nextLine(); + + if (choice.equals("1")){ //Register + System.out.println("Enter username: "); + String username = scr.nextLine(); + + if (authentication.usernameAvail(username)) { + System.out.println("Enter password: "); + String password = scr.nextLine(); + authentication.register(username, password); + } + } + else if (choice.equals("2")){ //Login + System.out.println("Enter username: "); + String username = scr.nextLine(); + + System.out.println("Enter password: "); + String password = scr.nextLine(); + + if (authentication.login(username,password)){ + home(); + } + } + else { //Exit + System.out.println("Goodbye!"); + break; + } + } + scr.close(); + } + + /** + * serves as home page + */ + public static void home() { + Scanner scr = new Scanner(System.in); + + while (true){ + System.out.println("\n1. Add User Info \n2. Add Rx Info \n3. Log Medicine \n4. Pull Medicine Adherence Report \n5. Exit"); + System.out.println("Choose an option: "); + String choice = scr.nextLine(); + + if (choice.equals("1")){ //Add User Info + System.out.println("Enter username: "); + String username = scr.nextLine(); + } + else if (choice.equals("2")){ //Add Rx Info + System.out.println("Enter username: "); + String username = scr.nextLine(); + } + else if (choice.equals("3")){ //Log Medicine + System.out.println("Enter username: "); + String username = scr.nextLine(); + } + else if (choice.equals("4")){ //Pull Med report + System.out.println("Enter username: "); + String username = scr.nextLine(); + } + else { //Exit + System.out.println("Goodbye!"); + break; + } + } + scr.close(); + } +} diff --git a/Sprint 1/MedicineReport.java b/Sprint 1/MedicineReport.java new file mode 100644 index 000000000..fc8db2e70 --- /dev/null +++ b/Sprint 1/MedicineReport.java @@ -0,0 +1,17 @@ +public class MedicineReport { + public static void main(String[] args) { + System.out.println("Generating medicine report..."); + + String medication = "Aspirin"; + String schedule = "Twice a day"; + String adherence = "90%"; + String sideEffect = "None"; + + System.out.println("Medication: " + medication); + System.out.println("Schedule: " + schedule); + System.out.println("Adherence: " + adherence); + System.out.println("Side Effects: " + sideEffect); + + System.out.println("Report ready to view or download."); + } + } diff --git a/Sprint 1/PerscriptionNumberVerification.java b/Sprint 1/PerscriptionNumberVerification.java new file mode 100644 index 000000000..8b63f306c --- /dev/null +++ b/Sprint 1/PerscriptionNumberVerification.java @@ -0,0 +1,81 @@ +import java.util.*; + +public class PrescriptionNumberVerification { + private static Map rxStore = new HashMap<>(); + + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + + while (true) { + System.out.println("Menu Options:"); + System.out.println("1. Add a new prescription"); + System.out.println("2. Retrieve medication details"); + System.out.println("3. Exit"); + + System.out.print("Enter your choice: "); + int choice = scanner.nextInt(); + scanner.nextLine(); // Consume newline + + switch (choice) { + case 1: + System.out.print("Enter Rx number: "); + String rxNumber = scanner.nextLine().trim(); + + System.out.print("Enter medication name: "); + String medicationName = scanner.nextLine().trim(); + + System.out.print("Enter times to take the medication: "); + String times = scanner.nextLine().trim(); + + rxStore.put(rxNumber, new Prescription(rxNumber, medicationName, times)); + System.out.println("Prescription added successfully."); + break; + + case 2: + System.out.print("Enter Rx number: "); + String searchRxNumber = scanner.nextLine().trim(); + + if (rxStore.containsKey(searchRxNumber)) { + Prescription prescription = rxStore.get(searchRxNumber); + System.out.println("Medication: " + prescription.getMedicationName()); + System.out.println("Times: " + prescription.getTimes()); + } else { + System.out.println("Rx number not found."); + } + break; + + case 3: + System.out.println("Exiting the system."); + scanner.close(); + return; + + default: + System.out.println("Invalid choice. Please try again."); + } + } + } +} + +class Prescription { + private String rxNumber; + private String medicationName; + private String times; + + public Prescription(String rxNumber, String medicationName, String times) { + this.rxNumber = rxNumber; + this.medicationName = medicationName; + this.times = times; + } + + public String getRxNumber() { + return rxNumber; + } + + public String getMedicationName() { + return medicationName; + } + + public String getTimes() { + return times; + } +} diff --git a/Sprint 1/SendMedicationReminder.java b/Sprint 1/SendMedicationReminder.java new file mode 100644 index 000000000..3f9485616 --- /dev/null +++ b/Sprint 1/SendMedicationReminder.java @@ -0,0 +1,68 @@ +/** + * Medical Adherence System + * Sprint 1 + * CMSC 355 - Fundamentals of Software Engineering + * + */ +import java.util.ArrayList; +import java.util.Scanner; +import java.util.List; +class Reminder { + private String username; + private String medication; + private boolean acknowledged; + + public Reminder(String username, String medication) { + this.username = username; + this medication = medication; + this.acknowledged = false; + } + + public String getUsername() { + return username; + } + + public String getMedication() { + return medication; + } + + public boolean isAcknowledged() { + return acknowledged; + } + + public void acknowledge() { + this.acknowledged = true; + } +} + +class ReminderService { + private List reminders = new ArrayList<>(); + + public void addReminder(String username, String medication) { + reminders.add(new Reminder(username, medication)); + System.out.println("Reminder added for " + username + ": " + medication); + } + + public void sendReminders() { + Scanner scanner = new Scanner(System.in); + for (Reminder reminder : reminders) { + if (!reminder.isAcknowledged()) { + System.out.println("Sending reminder to " + reminder.getUsername() + " for " + reminder.getMedication()); + System.out.printlm("Did the user acknowledge the reminder? (yes/no)"); + String response = scanner.nextLine(); + + if (response.equalsIgnoreCase("yes")) { + reminder.acknowledge(); + System.out.println("Reminder acknowledged."); + } + else { + System.out.println("Reminder missed. Logging missed reminder."); + handleMissedReminder(reminder); + } + } + } + } + private void handleMissedReminder(Reminder reminder) { + System.out.println("User " + reminder.getUsername() + " missed their medication. Alerting caregiver if necessary."); + } +} diff --git a/Sprint 1/TestCasesPlaceholder.txt b/Sprint 1/TestCasesPlaceholder.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/Sprint 1/TrackReminderResponse.java b/Sprint 1/TrackReminderResponse.java new file mode 100644 index 000000000..0d27fe398 --- /dev/null +++ b/Sprint 1/TrackReminderResponse.java @@ -0,0 +1,36 @@ +/** + * Medical Adherence System + * Sprint 1 + * CMSC 355 - Fundamentals of Software Engineering + * + */ +import java.util.Scanner; + +class ResponseTracker { + private ReminderService reminderService; + + public ResponseTracker(ReminderService reminderService) { + this.reminderService = reminderService; + } + + public void trackResponse() { + Scanner scanner = new Scanner(System.in); + + for (Reminder reminder : reminderService.getReminders()) { + if (!reminder.isAcknowledged()) { + System.out.println("Checking response for " + reminder.getUsername() + " - Medication: " + reminder.getMedication()); + + System.out.println("Did the user acknowledge the reminder? (yes/no)"); + String response = scanner.nextLine(); + + if (response.equalsIgnoreCase("yes")) { + reminder.acknowledge(); + System.out.println("Response recorded: User took medication."); + } else { + System.out.println("Response not received. Logging as a missed dose."); + handleMissedResponse(reminder); + } + } + } + } +} diff --git a/Sprint 1/User.java b/Sprint 1/User.java new file mode 100644 index 000000000..b69ba5ea0 --- /dev/null +++ b/Sprint 1/User.java @@ -0,0 +1,50 @@ +/** + * Medical Adherence System + * Sprint 1 + * CMSC 355 - Fundamentals of Software Engineering + * + */ +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +public class User { + private String username; + private String hashedPassword; + + public User(String username, String password){ + this.username = username; + this.hashedPassword = hashPassword(password); + } + + public String getUsername(){ + return username; + } + + public String getHashedPassword() { + return hashedPassword; + } + + private String hashPassword(String password) { + try { + MessageDigest md = MessageDigest.getInstance("SHA-256"); + byte[] hash = md.digest(password.getBytes()); + StringBuilder hexString = new StringBuilder(); + + for (byte b : hash){ + hexString.append(String.format("%02x",b)); + } + return hexString.toString(); + } + catch (NoSuchAlgorithmException e){ + throw new RuntimeException("Error hashing password", e); + } + } + + public boolean checkPassword(String password){ + return this.hashedPassword.equals(hashedPassword(password)); + } + + private String hashedPassword(String password) { + return this.hashedPassword; + } +} diff --git a/Sprint 1/codePlaceHolder.txt b/Sprint 1/codePlaceHolder.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/Sprint 2/Authentication.java b/Sprint 2/Authentication.java new file mode 100644 index 000000000..0529b12a4 --- /dev/null +++ b/Sprint 2/Authentication.java @@ -0,0 +1,59 @@ +/** + * Medical Adherence System + * Sprint 1 + * CMSC 355 - Fundamentals of Software Engineering + * + */ + +import java.util.HashMap; + +public class Authentication { + private HashMap users; + + //creates hashmap using current user + public Authentication(){ + this.users = new HashMap<>(); + } + + /** + * Checks availability of username + * @param username + * @return false if username is taken, true if username is available + */ + public boolean usernameAvail(String username){ + if(users.containsKey(username)){ + System.out.println("Username already taken."); + return false; + } + else { + return true; + } + } + + public boolean register(String username, String password) { + if (users.containsKey(username)) { + System.out.println("Username already taken."); + return false; + } + users.put(username, new User(username,password)); + System.out.println("User registerd successfully!"); + return true; + } + + public boolean login(String username, String password) { + if (!users.containsKey(username)){ + System.out.println("User not found"); + return false; + } + User user = users.get(username); + if (user.checkPassword(password)) { + System.out.println("login successful!"); + return true; + } + else { + System.out.println("Incorrect password."); + return false; + } + } + +} diff --git a/Sprint 2/DoctorName.java b/Sprint 2/DoctorName.java new file mode 100644 index 000000000..c4a7be44e --- /dev/null +++ b/Sprint 2/DoctorName.java @@ -0,0 +1,60 @@ +import java.util.*; + +public class DoctorName { + + // Static map to store doctor names and their associated medications + private static Map> doctorMedications = new HashMap<>(); + + // Initialize with some sample doctor data (can later be replaced with real input) + static { + doctorMedications.put("John Smith", Arrays.asList("Aspirin", "Ibuprofen")); + doctorMedications.put("Jane Doe", Arrays.asList("Paracetamol")); + } + + /** + * Adds doctor info or lets users view existing doctor prescriptions + */ + public static void addDoctorInfo() { + Scanner scanner = new Scanner(System.in); + + // Get doctor's full name from user + System.out.print("Enter doctor's first name: "); + String firstName = scanner.nextLine().trim(); + + System.out.print("Enter doctor's last name: "); + String lastName = scanner.nextLine().trim(); + + String fullName = firstName + " " + lastName; + + // Check if the doctor exists in the system + if (doctorMedications.containsKey(fullName)) { + System.out.println("Doctor found: " + fullName); + System.out.println("Menu Options:"); + System.out.println("1. View Medications"); + System.out.println("2. Enter a new Rx number"); + + System.out.print("Enter your choice: "); + int choice = scanner.nextInt(); + scanner.nextLine(); // Clear newline character + + switch (choice) { + case 1: + // Show medications assigned to this doctor + System.out.println("Medications: " + doctorMedications.get(fullName)); + break; + + case 2: + // Allow adding a new Rx number (future feature: link to Prescription module) + System.out.print("Enter new Rx number: "); + String rxNumber = scanner.nextLine(); + System.out.println("Rx number " + rxNumber + " has been added."); // No storage yet + break; + + default: + System.out.println("Invalid choice."); + } + } else { + System.out.println("Doctor not found in the system."); + } + } +} \ No newline at end of file diff --git a/Sprint 2/Main.java b/Sprint 2/Main.java new file mode 100644 index 000000000..cbb229cb8 --- /dev/null +++ b/Sprint 2/Main.java @@ -0,0 +1,87 @@ +/** + * Medical Adherence System + * Sprint 1 + * CMSC 355 - Fundamentals of Software Engineering + * + */ +import java.util.Scanner; + +public class Main { + + public static void main(String[] args){ + login(); //call in the login function + } + + public static void login() { + + Authentication authentication = new Authentication(); + Scanner scr = new Scanner(System.in); + + while (true){ + System.out.println("\n1. Register\n2. Login\n3. Exit"); + System.out.println("Choose an option: "); + String choice = scr.nextLine(); + + if (choice.equals("1")){ //Register + System.out.println("Enter username: "); + String username = scr.nextLine(); + + if (authentication.usernameAvail(username)) { + System.out.println("Enter password: "); + String password = scr.nextLine(); + authentication.register(username, password); + } + } + else if (choice.equals("2")){ //Login + System.out.println("Enter username: "); + String username = scr.nextLine(); + + System.out.println("Enter password: "); + String password = scr.nextLine(); + + if (authentication.login(username,password)){ + home(); + } + } + else { //Exit + System.out.println("Goodbye!"); + break; + } + } + scr.close(); + } + + /** + * serves as home page + */ + public static void home() { + Scanner scr = new Scanner(System.in); + + while (true){ + System.out.println("\n1. Add Doctor Info \n2. Add Rx Info \n3. Log Medicine \n4. Pull Medicine Adherence Report \n5. Reminders \n6. Exit"); + System.out.println("Choose an option: "); + String choice = scr.nextLine(); + + if (choice.equals("1")){ //Add Doctor Info + DoctorName.main(new String[]{}); + } + else if (choice.equals("2")){ //Add Rx Info + PrescriptionNumberVerification.main(new String[]{}); + } + else if (choice.equals("3")){ //Log Medicine + ValidateMedication.main(new String[] {}); + } + else if (choice.equals("4")){ //Pull Med report + MedicineReport.main(new String[]{}); + } + else if (choice.equals("5")){ //Reminders + ResponseTracker.trackResponse(); + } + else { //Exit + System.out.println("Goodbye!"); + break; + } + } + scr.close(); + } +} diff --git a/Sprint 2/MedicineReport (1).java b/Sprint 2/MedicineReport (1).java new file mode 100644 index 000000000..b12d470b4 --- /dev/null +++ b/Sprint 2/MedicineReport (1).java @@ -0,0 +1,33 @@ +// MedicineReport.java + +class Medicine { + String name; + String schedule; + String adherence; + String sideEffects; + + public Medicine(String name, String schedule, String adherence, String sideEffects) { + this.name = name; + this.schedule = schedule; + this.adherence = adherence; + this.sideEffects = sideEffects; + } + + public void printReport() { + System.out.println("Medication: " + name); + System.out.println("Schedule: " + schedule); + System.out.println("Adherence: " + adherence); + System.out.println("Side Effects: " + sideEffects); + } +} + +public class MedicineReport { + public static void main(String[] args) { + System.out.println("Generating medicine report..."); + + Medicine med = new Medicine("Aspirin", "Twice a day", "90%", "None"); + med.printReport(); + + System.out.println("Report ready to view or download."); + } +} diff --git a/Sprint 2/PerscriptionNumberVerification.java b/Sprint 2/PerscriptionNumberVerification.java new file mode 100644 index 000000000..6f5ab8282 --- /dev/null +++ b/Sprint 2/PerscriptionNumberVerification.java @@ -0,0 +1,89 @@ +import java.util.*; + +public class PrescriptionNumberVerification { + + // Stores prescriptions using Rx number as key + private static Map rxStore = new HashMap<>(); + + /**hod to manage adding and retrieving prescriptions + */ + public static void managePrescriptions() { + Scanner scann + * Meter = new Scanner(System.in); + + System.out.println("Menu Options:"); + System.out.println("1. Add a new prescription"); + System.out.println("2. Retrieve medication details"); + System.out.println("3. Go back"); + + System.out.print("Enter your choice: "); + int choice = scanner.nextInt(); + scanner.nextLine(); // Consume newline character + + switch (choice) { + case 1: + // Add a new prescription to the system + System.out.print("Enter Rx number: "); + String rxNumber = scanner.nextLine().trim(); + + System.out.print("Enter medication name: "); + String medicationName = scanner.nextLine().trim(); + + System.out.print("Enter times to take the medication: "); + String times = scanner.nextLine().trim(); + + rxStore.put(rxNumber, new Prescription(rxNumber, medicationName, times)); + System.out.println("Prescription added successfully."); + break; + + case 2: + // Look up a prescription by Rx number + System.out.print("Enter Rx number: "); + String searchRxNumber = scanner.nextLine().trim(); + + if (rxStore.containsKey(searchRxNumber)) { + Prescription prescription = rxStore.get(searchRxNumber); + System.out.println("Medication: " + prescription.getMedicationName()); + System.out.println("Times: " + prescription.getTimes()); + } else { + System.out.println("Rx number not found."); + } + break; + + case 3: + // Return to previous menu (Main.home) + System.out.println("Returning to main menu."); + break; + + default: + System.out.println("Invalid choice. Please try again."); + } + } +} + +/** + * Prescription class to store detailof a medication prescription + */ +class Prescription { + private String rxNumber; + private String medicationName; + private String times; + + public Prescription(String rxNumber, String medicationName, String times) { + this.rxNumber = rxNumber; + this.medicationName = medicationName; + this.times = times; + } + + public String getRxNumber() { + return rxNumber; + } + + public String getMedicationName() { + return medicationName; + } + + public String getTimes() { + return times; + } +} diff --git a/Sprint 2/SendMedicationReminder.java b/Sprint 2/SendMedicationReminder.java new file mode 100644 index 000000000..45715e460 --- /dev/null +++ b/Sprint 2/SendMedicationReminder.java @@ -0,0 +1,73 @@ +/** + * Medical Adherence System + * Sprint 2 + * CMSC 355 - Fundamentals of Software Engineering + */ + +import java.util.ArrayList; +import java.util.List; +import java.util.Scanner; + +// Reminder object +public class Reminder { + private String username; + private String medication; + private boolean acknowledged; + + public Reminder(String username, String medication) { + this.username = username; + this.medication = medication; + this.acknowledged = false; + } + + public String getUsername() { + return username; + } + + public String getMedication() { + return medication; + } + + public boolean isAcknowledged() { + return acknowledged; + } + + public void acknowledge() { + this.acknowledged = true; + } +} + +// Handles storing and sending reminders +class ReminderService { + private List reminders = new ArrayList<>(); + + public void addReminder(String username, String medication) { + reminders.add(new Reminder(username, medication)); + } + + public void sendReminders(Scanner scanner) { + for (Reminder reminder : reminders) { + if (!reminder.isAcknowledged()) { + System.out.println("Reminder for " + reminder.getUsername() + ": Take " + reminder.getMedication()); + System.out.println("Did the user acknowledge the reminder? (yes/no)"); + String response = scanner.nextLine(); + + if (response.equalsIgnoreCase("yes")) { + reminder.acknowledge(); + System.out.println("Reminder acknowledged."); + } else { + System.out.println("Reminder missed. Logging missed reminder."); + handleMissedReminder(reminder); + } + } + } + } + + public List getReminders() { + return reminders; + } + + private void handleMissedReminder(Reminder reminder) { + System.out.println("User " + reminder.getUsername() + " missed their medication. Alerting caregiver if necessary."); + } +} diff --git a/Sprint 2/TrackReminderResponse.java b/Sprint 2/TrackReminderResponse.java new file mode 100644 index 000000000..a78039e01 --- /dev/null +++ b/Sprint 2/TrackReminderResponse.java @@ -0,0 +1,40 @@ +/** + * Medical Adherence System + * Sprint 2 + * CMSC 355 - Fundamentals of Software Engineering + */ + +import java.util.Scanner; + +public class TrackReminderResponse { + private ReminderService reminderService; + + public TrackReminderResponse(ReminderService reminderService) { + this.reminderService = reminderService; + } + + public void run() { + Scanner scanner = new Scanner(System.in); + + for (Reminder reminder : reminderService.getReminders()) { + if (!reminder.isAcknowledged()) { + System.out.println("Reminder for user: " + reminder.getUsername() + " - Medication: " + reminder.getMedication()); + System.out.println("Has the user responded? (yes/no)"); + + String response = scanner.nextLine(); + + if (response.equalsIgnoreCase("yes")) { + reminder.acknowledge(); + System.out.println("Marked as acknowledged."); + } else { + System.out.println("No response received. Logging as missed."); + handleMissedResponse(reminder); + } + } + } + } + + private void handleMissedResponse(Reminder reminder) { + System.out.println("ALERT: User " + reminder.getUsername() + " missed their medication (" + reminder.getMedication() + ")."); + } +} diff --git a/Sprint 2/User.java b/Sprint 2/User.java new file mode 100644 index 000000000..b69ba5ea0 --- /dev/null +++ b/Sprint 2/User.java @@ -0,0 +1,50 @@ +/** + * Medical Adherence System + * Sprint 1 + * CMSC 355 - Fundamentals of Software Engineering + * + */ +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +public class User { + private String username; + private String hashedPassword; + + public User(String username, String password){ + this.username = username; + this.hashedPassword = hashPassword(password); + } + + public String getUsername(){ + return username; + } + + public String getHashedPassword() { + return hashedPassword; + } + + private String hashPassword(String password) { + try { + MessageDigest md = MessageDigest.getInstance("SHA-256"); + byte[] hash = md.digest(password.getBytes()); + StringBuilder hexString = new StringBuilder(); + + for (byte b : hash){ + hexString.append(String.format("%02x",b)); + } + return hexString.toString(); + } + catch (NoSuchAlgorithmException e){ + throw new RuntimeException("Error hashing password", e); + } + } + + public boolean checkPassword(String password){ + return this.hashedPassword.equals(hashedPassword(password)); + } + + private String hashedPassword(String password) { + return this.hashedPassword; + } +} diff --git a/Sprint 2/ValidateMedication.java b/Sprint 2/ValidateMedication.java new file mode 100644 index 000000000..094c6a494 --- /dev/null +++ b/Sprint 2/ValidateMedication.java @@ -0,0 +1,109 @@ +/** +* Medication Vaildation System +* +* 3.1 and 3.2 */ +import java.util.ArrayList; +import java.util.Scanner; +class ValidatingMedication { + private String nameOfMedication; + + public ValidatingMedication(String name) { + this.nameOfMedication = name; + } + + public String getNameofMedication() { + return nameOfMedication; + } +} +public class MedicationLogging{ +private ArrayList medications; +private ArrayList userLogs; +private ArrayList TimeInMinutes; + + +public MedicationLogging(){ + medications = new ArrayList<>(); + userLogs = new ArrayList<>(); + TimeInMinutes = new ArrayList<>(); + + medications.add(new ValidatingMedication("Tylenol")); + medications.add(new ValidatingMedication("Ibuprofen")); + medications.add(new ValidatingMedication("Clartin")); +} +public void logMedication(){ + Scanner scan = new Scanner(System.in); + System.out.println("Enter the name of the medication that was taken:"); + String medInput = scan.nextLine(); + boolean valid = false; + for(ValidatingMedication med : medications){ + if(med.getNameofMedication().equalsIgnoreCase(medInput)){ + valid = true; + System.out.println("Medicine Logged!"); + break; + } + } + if (valid){ + System.out.println("Please enter the time the medicine was taken. Please enter the hour, minutes, then AM or PM. (Ex. 8:30)"); + int hour = scan.nextInt(); + String semicolon = scan.nextLine(); + int minute = scan.nextInt(); + String ending = scan.nextLine(); + int total = 0; + if ((hour <= 12 && hour >= 1 && minute <= 59 && minute >= 0 && semicolon.equalsIgnoreCase(":")) && (ending.equalsIgnoreCase("AM")||ending.equalsIgnoreCase("PM"))){ + total = ConvertToMinutes(hour, minute, ending); + TimeInMinutes.add(total); + String TimeFormat = ConvertToTimeFormat(hour, minute, ending); + ComplianceCheck(total); + userLogs.add(TimeFormat); + } + else{ + System.out.println("Invaild time input.Please enter the correct time format."); + } + } + } + public int ConvertToMinutes(int hour, int minute, String ending){ + if (ending.equalsIgnoreCase("PM") && hour != 12 ){ + hour = hour + 12; + } + if (ending.equalsIgnoreCase("AM") && hour == 12 ){ + hour = 0; + } + return (hour * 60) + minute; + } + public String ConvertToTimeFormat(int hour, int mintue, String ending){ + String hourF = String.valueOf(hour); + String minuteF = String.valueOf(mintue); + return hourF + ":"+ minuteF + ending; + } + public void ComplianceCheck(int check){ + if(!TimeInMinutes.isEmpty()){ + int previous = TimeInMinutes.get(TimeInMinutes.size()-1); + int difference = Math.abs(check - previous); + if (difference > 30){ + System.out.println("Not Compliant: Medication was not taken on time your doctor will be notified."); + } else { + System.out.println("Compliant: Medication taken on time. "); + } + } + + } + public void ShowHistory(){ + if (userLogs.isEmpty()){ + System.out.println("No times have not been logged yet."); + }else{ + System.out.println("Times that are logged:"); + for (String timestamps : userLogs){ + System.out.println(timestamps); + } + } + } + public static void main(String[] args){ + MedicationLogging app = new MedicationLogging(); + Scanner scan = new Scanner(System.in); + app.logMedication(); + app.ShowHistory(); + System.out.println("Goodbye!"); + } +} + + diff --git a/Sprint 3/Authentication.java b/Sprint 3/Authentication.java new file mode 100644 index 000000000..1bd09c25e --- /dev/null +++ b/Sprint 3/Authentication.java @@ -0,0 +1,79 @@ +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.HashMap; + +public class Authentication { + private HashMap users; // Stores username -> hashed password + + public Authentication() { + this.users = new HashMap<>(); + } + + /** + * Checks availability of username + * @param username the username to check + * @return true if available, false if taken + */ + public boolean usernameAvail(String username) { + return !users.containsKey(username); + } + + /** + * Registers a new user + * @param username username + * @param password password + * @return true if successful, false if username already taken + */ + public boolean register(String username, String password) { + if (users.containsKey(username)) { + System.out.println("Username already taken."); + return false; + } + String hashed = hashPassword(password); + users.put(username, hashed); + System.out.println("User registered successfully!"); + return true; + } + + /** + * Attempts to log in + * @param username username + * @param password password + * @return true if login successful, false otherwise + */ + public boolean login(String username, String password) { + if (!users.containsKey(username)) { + System.out.println("User not found."); + return false; + } + String storedHashedPassword = users.get(username); + String inputHashedPassword = hashPassword(password); + + if (storedHashedPassword.equals(inputHashedPassword)) { + System.out.println("true"); + return true; + } else { + return false; + } + } + + /** + * Hashes a password using SHA-256 + * @param password the password to hash + * @return hashed password as a hex string + */ + private String hashPassword(String password) { + try { + MessageDigest md = MessageDigest.getInstance("SHA-256"); + byte[] hash = md.digest(password.getBytes()); + StringBuilder hexString = new StringBuilder(); + + for (byte b : hash) { + hexString.append(String.format("%02x", b)); + } + return hexString.toString(); + } catch (NoSuchAlgorithmException e) { + throw new RuntimeException("Error hashing password", e); + } + } +} diff --git a/Sprint 3/CMSC 355 Test Cases (1).pdf b/Sprint 3/CMSC 355 Test Cases (1).pdf new file mode 100644 index 000000000..4df8a7cb7 Binary files /dev/null and b/Sprint 3/CMSC 355 Test Cases (1).pdf differ diff --git a/Sprint 3/DoctorName.java b/Sprint 3/DoctorName.java new file mode 100644 index 000000000..85555820b --- /dev/null +++ b/Sprint 3/DoctorName.java @@ -0,0 +1,32 @@ +import java.util.*; + +public class DoctorName { + + // Static map to store doctor names and their associated medications + public static Map doctorMedications = new HashMap<>(); + + /** + * Lets users look up a doctor and either view their meds or add a new Rx number + */ + public static void addDoctorInfo(User givenUser, String givenDoc) { + + User user = givenUser; + String fullName = givenDoc; + doctorMedications.put(user, fullName); + + // Check if the doctor exists in the system + //if (doctorMedications.containsKey(fullName)) { + //} + // Check if doctor exists in the system + // Show the list of medications this doctor prescribes + // Allow user to \"add\" a new Rx number (this is just a placeholder message for now) + } +} + + + + + + + + diff --git a/Sprint 3/Main.java b/Sprint 3/Main.java new file mode 100644 index 000000000..46ec25902 --- /dev/null +++ b/Sprint 3/Main.java @@ -0,0 +1,428 @@ +import javax.swing.*; +import java.awt.*; +import java.util.List; + +public class Main extends JFrame{ + private CardLayout cardLayout; //organizes multiple pages + private JPanel mainPanel;//main panel + + Authentication auth = new Authentication(); //calls authentication method + User user = new User(); //creates a new user + MedicationLogging app = new MedicationLogging(); + + /* + * Main method that navigates the app + * + */ + public Main() { + setTitle("Medical Adherence System"); + setSize(500, 500); + setDefaultCloseOperation(EXIT_ON_CLOSE); + setLocationRelativeTo(null); + + cardLayout = new CardLayout(); + mainPanel = new JPanel(cardLayout); + mainPanel.setBackground(new Color(173, 216, 230)); + mainPanel.add(createWelcomePanel(), "Welcome"); + mainPanel.add(createRegisterPanel(), "Register"); + mainPanel.add(createLoginPanel(), "Login"); + mainPanel.add(createDashboardPanel(), "Dashboard"); + mainPanel.add(createDoctorPanel(), "AddDoctor"); + mainPanel.add(createPrescriptionPanel(),"PrescriptionHome"); + mainPanel.add(createAddPrescriptionPanel(), "AddPrescription"); + mainPanel.add(createRetrievePrescriptionPanel(),"RetrieveMeds"); + mainPanel.add(createLogMedicationPanel(), "LogMedication"); + mainPanel.add(createReminderPanel(), "Reminder"); + mainPanel.add(createReportPanel(), "ComplianceReport"); + + add(mainPanel); + cardLayout.show(mainPanel, "Welcome"); + } + + /* + * Creates buttons + */ + private JButton styledButton(String text, Runnable action) { + JButton button = new JButton(text); + button.setFont(new Font("Arial", Font.PLAIN, 14)); + button.setMaximumSize(new Dimension(200, 40)); + button.setAlignmentX(Component.CENTER_ALIGNMENT); + button.addActionListener(e -> action.run()); + return button; + } + + //Welcome Page + private JPanel createWelcomePanel() { + JPanel panel = new JPanel(); + panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); + panel.setBorder(BorderFactory.createEmptyBorder(40, 40, 40, 40)); + panel.setBackground(new Color(173, 216, 230)); + + JLabel label = new JLabel("Welcome to the Medical Adherence System"); + label.setFont(new Font("Arial", Font.BOLD, 18)); + label.setAlignmentX(Component.CENTER_ALIGNMENT); + + panel.add(label); + panel.add(Box.createRigidArea(new Dimension(0, 40))); + panel.add(styledButton("Register", () -> cardLayout.show(mainPanel, "Register"))); + panel.add(Box.createRigidArea(new Dimension(0, 20))); + panel.add(styledButton("Login", () -> cardLayout.show(mainPanel, "Login"))); + + return panel; + } + + //Register Page + private JPanel createRegisterPanel() { + JPanel panel = new JPanel(new GridLayout(7, 2, 10, 10)); + panel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); + panel.setBackground(new Color(173, 216, 230)); + + panel.add(new JLabel("First Name:")); + panel.add(new JTextField()); + panel.add(new JLabel("Last Name:")); + panel.add(new JTextField()); + panel.add(new JLabel("Phone:")); + panel.add(new JTextField()); + panel.add(new JLabel("Email:")); + JTextField emailReg = new JTextField(); + panel.add(emailReg); + panel.add(new JLabel("Password:")); + JTextField passwordReg = new JTextField(); + panel.add(passwordReg); + + panel.add(styledButton("Confirm", () -> { + + if (auth.usernameAvail(emailReg.getText())) { + auth.register(emailReg.getText(), passwordReg.getText()); + user.setUsername(emailReg.getText()); + cardLayout.show(mainPanel, "Login"); + } + else { + JOptionPane.showMessageDialog(panel, "Invalid Credentials"); + } + })); + + panel.add(styledButton("Back", () -> cardLayout.show(mainPanel, "Welcome"))); + + return panel; + } + + //Login Page + private JPanel createLoginPanel() { + JPanel panel = new JPanel(new GridLayout(3, 2, 10, 10)); + panel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); + panel.setBackground(new Color(173, 216, 230)); + + panel.add(new JLabel("Email:")); + JTextField emailLog = new JTextField(); + panel.add(emailLog); + panel.add(new JLabel("Password:")); + JTextField passwordLog = new JTextField(); + panel.add(passwordLog); + + panel.add(styledButton("Confirm", () -> { + user.setUsername(emailLog.getText().trim()); + + if (auth.login(emailLog.getText().trim(),passwordLog.getText().trim()) == true) + { + cardLayout.show(mainPanel, "Dashboard"); + } else { + JOptionPane.showMessageDialog(panel, "Invalid Credentials"); + } + })); + + panel.add(styledButton("Back", () -> cardLayout.show(mainPanel, "Welcome"))); + return panel; + } + + //Dashboard + private JPanel createDashboardPanel() { + JPanel panel = new JPanel(); + panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); + panel.setBorder(BorderFactory.createEmptyBorder(30, 40, 30, 40)); + panel.setBackground(new Color(173, 216, 230)); + + panel.add(styledButton("Add Doctor Information", () -> cardLayout.show(mainPanel, "AddDoctor"))); + panel.add(Box.createRigidArea(new Dimension(0, 10))); + panel.add(styledButton("Prescription Information", () -> cardLayout.show(mainPanel, "PrescriptionHome"))); + panel.add(Box.createRigidArea(new Dimension(0, 10))); + panel.add(styledButton("Log Medication", () -> cardLayout.show(mainPanel, "LogMedication"))); + panel.add(Box.createRigidArea(new Dimension(0, 10))); + JButton reminderButton = styledButton("Reminders", () -> cardLayout.show(mainPanel, "Reminder")); // <-- ADD THIS + panel.add(reminderButton); + panel.add(Box.createRigidArea(new Dimension(0, 10))); + panel.add(styledButton("Request Compliance Report", () -> cardLayout.show(mainPanel, "ComplianceReport"))); + panel.add(Box.createRigidArea(new Dimension(0, 10))); + panel.add(styledButton("Logout", () -> cardLayout.show(mainPanel, "Welcome"))); + + return panel; + } + + //Doctor Page + private JPanel createDoctorPanel() { + JPanel panel = new JPanel(new GridLayout(5, 2, 10, 10)); + panel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); + panel.setBackground(new Color(173, 216, 230)); + + panel.add(new JLabel("Doctor Name:")); + JTextField docName = new JTextField(); + panel.add(docName); + panel.add(new JLabel("Phone:")); + JTextField phoneNum = new JTextField(); + panel.add(phoneNum); + panel.add(new JLabel("Email:")); + JTextField emailDoc = new JTextField(); + panel.add(emailDoc); + + panel.add(styledButton("Confirm", () -> { + user.setDoctor(docName.getText()); + DoctorName.addDoctorInfo(user,user.getDoctor()); + user.setDocPhone(phoneNum.getText()); + user.setDocEmail(emailDoc.getText()); + cardLayout.show(mainPanel, "Dashboard"); + })); + panel.add(styledButton("Back to Dashboard", () -> cardLayout.show(mainPanel, "Dashboard"))); + + return panel; + } + + //Rx Page + private JPanel createPrescriptionPanel(){ + JPanel panel = new JPanel(new GridLayout(3, 2, 10, 10)); + panel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); + panel.setBackground(new Color(173, 216, 230)); + + panel.add(styledButton("Add Prescription", () -> cardLayout.show(mainPanel, "AddPrescription"))); + panel.add(styledButton("Retrieve Medication", () -> cardLayout.show(mainPanel,"RetrieveMeds"))); + panel.add(styledButton("Back to Dashboard", () -> cardLayout.show(mainPanel, "Dashboard"))); + + return panel; + } + + //Add Rx Page + private JPanel createAddPrescriptionPanel() { + JPanel panel = new JPanel(new GridLayout(7, 2, 10, 10)); + panel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); + panel.setBackground(new Color(173, 216, 230)); + + panel.add(new JLabel("Rx Number:")); + JTextField rxNumberField = new JTextField(); + panel.add(rxNumberField); + panel.add(new JLabel("Medication Name:")); + JTextField medNameField = new JTextField(); + panel.add(medNameField); + panel.add(new JLabel("Frequency:")); + JTextField frequencyField = new JTextField(); + panel.add(frequencyField); + panel.add(new JLabel("Doctor Name:")); + JTextField docNameField = new JTextField(); + panel.add(docNameField); + + panel.add(styledButton("Confirm", () -> { + Prescription prescription = new Prescription(rxNumberField.getText(),medNameField.getText(),frequencyField.getText()); + PrescriptionNumberVerification.addPrescriptions(rxNumberField.getText(), prescription); + cardLayout.show(mainPanel, "PrescriptionHome"); + })); + panel.add(styledButton("Back to Dashboard", () -> cardLayout.show(mainPanel, "PrescriptionHome"))); + + return panel; + } + + //Retrieve Rx Page + private JPanel createRetrievePrescriptionPanel() { + JPanel panel = new JPanel(new GridLayout(3, 2, 10, 10)); + panel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); + panel.setBackground(new Color(173, 216, 230)); + + panel.add(new JLabel("Enter Rx Number:")); + JTextField rxNumberField = new JTextField(); + panel.add(rxNumberField); + + panel.add(new JLabel("Medication: ")); + JTextField foundMeds = new JTextField(); + panel.add(foundMeds); + + panel.add(styledButton("Confirm", () -> { + String medStats = PrescriptionNumberVerification.retrievePrescription(rxNumberField.getText()); + foundMeds.setText(medStats); + })); + panel.add(styledButton("Back to Dashboard", () -> cardLayout.show(mainPanel, "PrescriptionHome"))); + + return panel; + } + + //Log Medication Page + private JPanel createLogMedicationPanel() { + JPanel panel = new JPanel(new GridLayout(5, 2, 10, 10)); + panel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); + panel.setBackground(new Color(173, 216, 230)); + + panel.add(new JLabel("Medication Name:")); + JTextField medNameField = new JTextField(); + panel.add(medNameField); + + panel.add(new JLabel("Hour (1-12):")); + JTextField hourField = new JTextField(); + panel.add(hourField); + + panel.add(new JLabel("Minute (0-59):")); + JTextField minuteField = new JTextField(); + panel.add(minuteField); + + panel.add(new JLabel("AM or PM:")); + JTextField ampmField = new JTextField(); + panel.add(ampmField); + + panel.add(styledButton("Confirm", () -> { + // Get user inputs + String medName = medNameField.getText(); + int hour = Integer.parseInt(hourField.getText()); + int minute = Integer.parseInt(minuteField.getText()); + String ampm = ampmField.getText(); + + MedicationLogging.logMedication(medName, hour, minute, ampm); + + cardLayout.show(mainPanel, "Dashboard"); + })); + + panel.add(styledButton("Back to Dashboard", () -> cardLayout.show(mainPanel, "Dashboard"))); + + return panel; + } + + //create Reports + private JPanel createReportPanel() { + JPanel panel = new JPanel(new BorderLayout()); + panel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); + panel.setBackground(new Color(230, 230, 250)); + + JTextArea reportArea = new JTextArea(); + reportArea.setEditable(false); + JScrollPane scrollPane = new JScrollPane(reportArea); + panel.add(scrollPane, BorderLayout.CENTER); + + JPanel controls = new JPanel(new GridLayout(2, 2, 10, 10)); + + JTextField nameField = new JTextField(); + JTextField scheduleField = new JTextField(); + JTextField adherenceField = new JTextField(); + JTextField sideEffectsField = new JTextField(); + + controls.add(new JLabel("Name:")); + controls.add(nameField); + controls.add(new JLabel("Schedule:")); + controls.add(scheduleField); + controls.add(new JLabel("Adherence:")); + controls.add(adherenceField); + controls.add(new JLabel("Side Effects:")); + controls.add(sideEffectsField); + + panel.add(controls, BorderLayout.NORTH); + + JPanel buttonPanel = new JPanel(); + + buttonPanel.add(styledButton("View Report", () -> ReportSystem.generateReport(user, reportArea))); + buttonPanel.add(styledButton("Add Medicine", () -> { + ReportSystem.addMedicine( + nameField.getText(), + scheduleField.getText(), + adherenceField.getText(), + sideEffectsField.getText() + ); + reportArea.setText("Medicine added successfully!\n"); + })); + buttonPanel.add(styledButton("Remove Medicine", () -> { + ReportSystem.removeMedicine(nameField.getText()); + reportArea.setText("Medicine removed successfully!\n"); + })); + buttonPanel.add(styledButton("Back to Dashboard", () -> cardLayout.show(mainPanel, "Dashboard"))); + + panel.add(buttonPanel, BorderLayout.SOUTH); + + return panel; + } + + //Reminder Page + private JPanel createReminderPanel() { + JPanel panel = new JPanel(new BorderLayout()); + panel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); + panel.setBackground(new Color(250, 250, 210)); + + ReminderService reminderService = new ReminderService(); + + JTextArea reminderArea = new JTextArea(); + reminderArea.setEditable(false); + JScrollPane scrollPane = new JScrollPane(reminderArea); + panel.add(scrollPane, BorderLayout.CENTER); + + JPanel inputPanel = new JPanel(new GridLayout(2, 2, 10, 10)); + JTextField userField = new JTextField(); + JTextField medField = new JTextField(); + + inputPanel.add(new JLabel("Username:")); + inputPanel.add(userField); + inputPanel.add(new JLabel("Medication:")); + inputPanel.add(medField); + + panel.add(inputPanel, BorderLayout.NORTH); + + JPanel buttonPanel = new JPanel(); + + buttonPanel.add(styledButton("Add Reminder", () -> { + reminderService.addReminder(userField.getText(), medField.getText()); + reminderArea.setText("Reminder added successfully!\n"); + })); + + buttonPanel.add(styledButton("Send Reminders", () -> { + StringBuilder output = new StringBuilder(); + List reminders = reminderService.getReminders(); + + for (Reminder r : reminders) { + if (!r.isAcknowledged()) { + output.append("Reminder for ").append(r.getUsername()) + .append(": Take ").append(r.getMedication()).append("\n"); + } + } + + if (output.length() == 0) { + reminderArea.setText("No pending reminders.\n"); + } else { + reminderArea.setText(output.toString()); + } + })); + + buttonPanel.add(styledButton("Acknowledge Reminder", () -> { + String username = userField.getText(); + String medication = medField.getText(); + boolean found = false; + + for (Reminder r : reminderService.getReminders()) { + if (r.getUsername().equalsIgnoreCase(username) && + r.getMedication().equalsIgnoreCase(medication) && + !r.isAcknowledged()) { + r.acknowledge(); + reminderArea.setText("Reminder acknowledged!\n"); + found = true; + break; + } + } + + if (!found) { + reminderArea.setText("No matching pending reminder found.\n"); + } + })); + + buttonPanel.add(styledButton("Back to Dashboard", () -> cardLayout.show(mainPanel, "Dashboard"))); + + panel.add(buttonPanel, BorderLayout.SOUTH); + + return panel; + } + + //Runs the program + public static void main(String[] args) { + Main window = new Main(); + window.setVisible(true); + } + +} diff --git a/Sprint 3/MedicationLogging.java b/Sprint 3/MedicationLogging.java new file mode 100644 index 000000000..dda027586 --- /dev/null +++ b/Sprint 3/MedicationLogging.java @@ -0,0 +1,94 @@ +/** +* Medication Vaildation System +* +* 3.1 and 3.2 */ + +import java.util.ArrayList; + +class ValidatingMedication { + private String nameOfMedication; + + public ValidatingMedication(String name) { + this.nameOfMedication = name; + } + + public String getNameofMedication() { + return nameOfMedication; + } +} +public class MedicationLogging{ +public static ArrayList medications; +private static ArrayList userLogs; +private static ArrayList TimeInMinutes; + + public MedicationLogging(){ + medications = new ArrayList<>(); + userLogs = new ArrayList<>(); + TimeInMinutes = new ArrayList<>(); +} + public static void logMedication(String medInput, int hour, int minute, String ending) { + boolean valid = false; + for (ValidatingMedication med : medications) { + if (med.getNameofMedication().equalsIgnoreCase(medInput)) { + valid = true; + System.out.println("Medicine Logged!"); + break; + } + } + + if (valid) { + int total = 0; + if ((hour <= 12 && hour >= 1 && minute <= 59 && minute >= 0) && (ending.equalsIgnoreCase("AM") || ending.equalsIgnoreCase("PM"))) { + total = ConvertToMinutes(hour, minute, ending); + TimeInMinutes.add(total); + String TimeFormat = ConvertToTimeFormat(hour, minute, ending); + ComplianceCheck(total); + userLogs.add(TimeFormat); + } else { + System.out.println("Invalid time input. Please enter the correct time format."); + } + } else { + System.out.println("Medication name not recognized."); + } + } + + public static int ConvertToMinutes(int hour, int minute, String ending){ + if (ending.equalsIgnoreCase("PM") && hour != 12 ){ + hour = hour + 12; + } + if (ending.equalsIgnoreCase("AM") && hour == 12 ){ + hour = 0; + } + return (hour * 60) + minute; + } + public static String ConvertToTimeFormat(int hour, int mintue, String ending){ + String hourF = String.valueOf(hour); + String minuteF = String.valueOf(mintue); + return hourF + ":"+ minuteF + ending; + } + public static void ComplianceCheck(int check){ + if(!TimeInMinutes.isEmpty()){ + int previous = TimeInMinutes.get(TimeInMinutes.size()-1); + int difference = Math.abs(check - previous); + if (difference > 30){ + System.out.println("Not Compliant: Medication was not taken on time your doctor will be notified."); + } else { + System.out.println("Compliant: Medication taken on time. "); + } + } + + } + public void ShowHistory(){ + if (userLogs.isEmpty()){ + System.out.println("No times have not been logged yet."); + }else{ + System.out.println("Times that are logged:"); + for (String timestamps : userLogs){ + System.out.println(timestamps); + } + } + } +} + + + diff --git a/Sprint 3/MedicineReport.java b/Sprint 3/MedicineReport.java new file mode 100644 index 000000000..8ade235eb --- /dev/null +++ b/Sprint 3/MedicineReport.java @@ -0,0 +1,93 @@ +import javax.swing.*; +import java.awt.*; +import java.util.*; +import java.util.List; + +// Represents a medicine entry +class Medicine { + String name; + String schedule; + String adherence; + String sideEffects; + + public Medicine(String name, String schedule, String adherence, String sideEffects) { + this.name = name; + this.schedule = schedule; + this.adherence = adherence; + this.sideEffects = sideEffects; + } + + public void printDetails() { + System.out.println("Medication: " + name); + System.out.println(" Schedule: " + schedule); + System.out.println(" Adherence: " + adherence); + System.out.println(" Side Effects: " + sideEffects); + } +} + +// System that manages the medication report +class ReportSystem { + static List medicationList = new ArrayList<>(); + MedicationLogging medicationLogging; + + public ReportSystem(MedicationLogging medicationLogging) { + this.medicationLogging = medicationLogging; + retrieveMedicationData(); + } + + public void retrieveMedicationData() { + for (ValidatingMedication med : medicationLogging.medications) { + medicationList.add(new Medicine( + med.getNameofMedication(), + "Unknown Schedule", + "Unknown", + "None" + )); + } + } + + public static void generateReport(User user, JTextArea outputArea) { + /* + if (!user.isAuthenticated) { + outputArea.setText("Access denied. Please log in.\n"); + return; + } + + if (medicationList.isEmpty()) { + outputArea.setText("No medication data available.\n"); + return; + } + + */ + + StringBuilder report = new StringBuilder(); + report.append("=== Medication Adherence Report ===\n"); + + for (Medicine med : medicationList) { + report.append("Medication: ").append(med.name).append("\n") + .append(" Schedule: ").append(med.schedule).append("\n") + .append(" Adherence: ").append(med.adherence).append("\n") + .append(" Side Effects: ").append(med.sideEffects).append("\n") + .append("-----------------------------------\n"); + } + + /* + if (user.isDoctor()) { + report.append("Doctor Recommendations:\n") + .append(" - Continue medications as prescribed\n") + .append(" - Adjust based on side effects\n\n"); + } + + */ + + outputArea.setText(report.toString()); + } + + public static void addMedicine(String name, String schedule, String adherence, String sideEffects) { + medicationList.add(new Medicine(name, schedule, adherence, sideEffects)); + } + + public static void removeMedicine(String name) { + medicationList.removeIf(med -> med.name.equalsIgnoreCase(name)); + } +} diff --git a/Sprint 3/PerscriptionNumberVerification.java b/Sprint 3/PerscriptionNumberVerification.java new file mode 100644 index 000000000..01745db40 --- /dev/null +++ b/Sprint 3/PerscriptionNumberVerification.java @@ -0,0 +1,53 @@ +import java.util.*; + +class PrescriptionNumberVerification { + + // Stores prescriptions using Rx number as key + private static Map rxStore = new HashMap<>(); + + /**hod to manage adding and retrieving prescriptions + */ + public static void addPrescriptions(String rxNumber,Prescription givenRx) { + + // Add a new prescription to the system + rxStore.put(rxNumber,givenRx); + } + + // Look up a prescription by Rx number + public static String retrievePrescription(String givenRxNumber) { + + if (rxStore.containsKey(givenRxNumber)) { + Prescription prescription = rxStore.get(givenRxNumber); + return prescription.getMedicationName() + prescription.getTimes(); + } else { + return "Rx number not found."; + } + } +} + +/** + * Prescription class to store detail of a medication prescription + */ +class Prescription { + private String rxNumber; + private String medicationName; + private String times; + + public Prescription(String rxNumber, String medicationName, String times) { + this.rxNumber = rxNumber; + this.medicationName = medicationName; + this.times = times; + } + + public String getRxNumber() { + return rxNumber; + } + + public String getMedicationName() { + return medicationName; + } + + public String getTimes() { + return times; + } +} \ No newline at end of file diff --git a/Sprint 3/Reminder.java b/Sprint 3/Reminder.java new file mode 100644 index 000000000..f455527d3 --- /dev/null +++ b/Sprint 3/Reminder.java @@ -0,0 +1,89 @@ +/** + * Medical Adherence System + * Sprint 3 + * CMSC 355 - Fundamentals of Software Engineering + */ + +import java.util.ArrayList; +import java.util.List; +import java.util.Scanner; + +//Represents a medication reminder for a user. +public class Reminder { + private String username; + private String medication; + private boolean acknowledged; + + + // Constructs a Reminder for a specific user and medication. + public Reminder(String username, String medication) { + this.username = username; + this.medication = medication; + this.acknowledged = false; + } + + // Returns the username associated with this reminder. + public String getUsername() { + return username; + } + + //Returns the medication associated with this reminder + public String getMedication() { + return medication; + } + + //Returns true if the reminder has been acknowledged. + public boolean isAcknowledged() { + return acknowledged; + } + + //Marks the reminder as acknowledged. + public void acknowledge() { + this.acknowledged = true; + } +} + +//Handles storing, sending, and processing reminders for users. +class ReminderService { + private List reminders = new ArrayList<>(); + + //Adds a new reminder for a given user and medication. + public void addReminder(String username, String medication) { + reminders.add(new Reminder(username, medication)); + } + + //Sends reminders to users and prompts for acknowledgment. + public void sendReminders(Scanner scanner) { + for (Reminder reminder : reminders) { + if (!reminder.isAcknowledged()) { + processReminder(reminder, scanner); + } + } + } + + //Processes a single reminder by prompting the user for a response. + public void processReminder(Reminder reminder, Scanner scanner) { + System.out.println("Reminder for " + reminder.getUsername() + ": Take " + reminder.getMedication()); + System.out.println("Did the user acknowledge the reminder? (yes/no)"); + + String response = scanner.nextLine(); + + if (response.equalsIgnoreCase("yes")) { + reminder.acknowledge(); + System.out.println("Reminder acknowledged."); + } else { + System.out.println("Reminder missed. Logging missed reminder."); + handleMissedReminder(reminder); + } + } + + //Returns the list of reminders. + public List getReminders() { + return reminders; + } + + //Handles a missed reminder by alerting the caregiver or logging it. + private void handleMissedReminder(Reminder reminder) { + System.out.println("ALERT: User " + reminder.getUsername() + " missed their medication (" + reminder.getMedication() + ")."); + } +} \ No newline at end of file diff --git a/Sprint 3/TestCasesPlaceholder.txt b/Sprint 3/TestCasesPlaceholder.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/Sprint 3/TrackReminderResponse.java b/Sprint 3/TrackReminderResponse.java new file mode 100644 index 000000000..068d9d4bd --- /dev/null +++ b/Sprint 3/TrackReminderResponse.java @@ -0,0 +1,28 @@ +/** + * Medical Adherence System + * Sprint 3 + * CMSC 355 - Fundamentals of Software Engineering + */ + +import java.util.Scanner; + +//TrackReminderResponse handles tracking user responses to reminders. +public class TrackReminderResponse { + private ReminderService reminderService; + + //Constructor initializes with a given ReminderService. + public TrackReminderResponse(ReminderService reminderService) { + this.reminderService = reminderService; + } + + //Runs the reminder response tracking process. + public void run() { + Scanner scanner = new Scanner(System.in); + + for (Reminder reminder : reminderService.getReminders()) { + if (!reminder.isAcknowledged()) { + reminderService.processReminder(reminder, scanner); + } + } + } +} \ No newline at end of file diff --git a/Sprint 3/UML class.pdf b/Sprint 3/UML class.pdf new file mode 100644 index 000000000..4c528ba77 Binary files /dev/null and b/Sprint 3/UML class.pdf differ diff --git a/Sprint 3/UMLDiagrams.txt b/Sprint 3/UMLDiagrams.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/Sprint 3/User.java b/Sprint 3/User.java new file mode 100644 index 000000000..b6a801109 --- /dev/null +++ b/Sprint 3/User.java @@ -0,0 +1,51 @@ +/** + * Medical Adherence System + * Sprint 1 + * CMSC 355 - Fundamentals of Software Engineering + * + */ +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +public class User { + private String username = null; + private String doctor = null; + private String docPhone = null; + private String docEmail = null; + + public User(){ + this.username = null; + } + + public String getUsername(){ + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public void setDoctor(String doctor) { + this.doctor = doctor; + } + + public String getDoctor() { + return doctor; + } + + public String getDocPhone() { + return docPhone; + } + + public void setDocPhone(String docPhone) { + this.docPhone = docPhone; + } + + public String getDocEmail() { + return docEmail; + } + + public void setDocEmail(String docEmail) { + this.docEmail = docEmail; + } +} diff --git a/Sprint 3/Video Link b/Sprint 3/Video Link new file mode 100644 index 000000000..2cd35ef88 --- /dev/null +++ b/Sprint 3/Video Link @@ -0,0 +1 @@ +https://drive.google.com/file/d/1gucxKgfNdhEjOcT9NpRRnF-0K1A25mc7/view?usp=sharing diff --git a/Sprint 3/codePlaceHolder.txt b/Sprint 3/codePlaceHolder.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/Sprint 3/videoPlaceholder.txt b/Sprint 3/videoPlaceholder.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/requirementPlaceholder.txt b/requirementPlaceholder.txt deleted file mode 100644 index e69de29bb..000000000