Skip to content

Commit

Permalink
Merge pull request #371 from yentheng0110/YenTheng-AddressBugReports
Browse files Browse the repository at this point in the history
Modify UG, findVisit to include patient's name, extract the printing of unknown commands in Parser.java
  • Loading branch information
kaboomzxc authored Nov 11, 2024
2 parents 829da86 + aa23e9f commit 2a26cd2
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 31 deletions.
34 changes: 18 additions & 16 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ layout: default

---
## Introduction
BookBob is a desktop application tailored for Dr Bob's private General Practitioner clinic. It facilitates the storage
and retrieval of patient information, including names, NRICs, genders, dates of birth, phone numbers, home addresses,
allergies, medical histories and visit records with details on diagnoses and prescribed medications. BookBob also helps
Dr Bob stay organised by tracking daily appointments and providing reminders each morning. Optimised for a Command Line
Interface (CLI), BookBob allows for efficient management of patient information and appointments.
BookBob is a desktop application tailored for Dr Bob's private General Practitioner clinic. BookBob helps
streamline clinic management by storing and retrieving patient information, including names, NRICs, genders, dates of
birth, phone numbers, home addresses, allergies, medical histories and detailed visit records with diagnoses and
prescribed medications. BookBob also assists Dr Bob in staying organised by tracking daily appointments and sending
reminders each morning. Optimised for a Command Line Interface (CLI), BookBob enables efficient management of patient
information and appointment scheduling.

---
## Table of Contents
Expand Down Expand Up @@ -48,10 +49,11 @@ The following output would be shown :`Welcome to BookBob, Dr. Bob!`
<hr style="width: 15%; height: 2px; background-color: black; border: none; margin-top: 10px; margin-bottom: 20px;">

**Note:**
1. Exact Input Required with No Extra Spaces or Inputs: Any extra inputs or spaces after the expected commands will be treated as unknown commands.
2. Case Sensitivity for Commands : Commands are case-sensitive. Ensure correct <u>lowercase</u> for <u>commands</u> e.g. `list` instead of `LIST`,
1. Extra Input After Commands: Additional input provided after expected inputs for commands such as `list`, `listAppointments`, `help` and `exit` will be treated as unknown commands.
2. Extra Spaces After Commands: Additional spaces after expected inputs for commands such as `list`, `listAppointments`, `help` and `exit` will be ignored.
3. Case Sensitivity for Commands: Commands are case-sensitive. Ensure correct <u>lowercase</u> for <u>commands</u> e.g. `list` instead of `LIST`,
and <u>mixed-case</u> for e.g. `addVisit` instead of `addvisit`
3. Case Sensitivity for Commands Prefixes : Command Prefixes are case-sensitive. Ensure correct <u>lowercase</u> for <u>commands prefixes</u> E.g. "n/", "ic/", instead of
4. Case Sensitivity for Commands Prefixes: Command Prefixes are case-sensitive. Ensure correct <u>lowercase</u> for <u>commands prefixes</u> E.g. "n/", "ic/", instead of
"N/", "IC/"

## Viewing Help
Expand Down Expand Up @@ -172,11 +174,11 @@ The examples above result in successful patient record additions, which are then

<div style="background-color: #F5F9FE; padding: 12px; border-radius: 4px; border-left: 4px solid #2196F3; color: #1A1A1A;">
💡 <b>Best Practices of using</b> <em><strong>"add" command together with "addVisit" command</strong></em> <b>:</b> <br>
1.) When a new patient visits the clinic, we use "add" command. <br>
1.) When a new patient visits the clinic, we use <b>"add" command</b>. <br>
<ins> The "add" command is primarily used for adding a patient record with the patient's basic key details information </ins> (such as Name , NRIC , Phone Number), and that Name, NRIC, Patient's First Visit Date, are <ins>Compulsory fields</ins>. <br>
Other <ins>Optional fields</ins> includes e.g. Phone Number, Home Address, DOB, <i>and</i> Diagnoses and Medications from patient's first visit. <br>
<br>
2.) If the <ins>same patient(with same NRIC)</ins> comes back to the clinic for a new visit, we use "addVisit" command,
2.) If the <ins>same patient(with same NRIC)</ins> comes back to the clinic for a new visit, we use <b>"addVisit" command</b>,
to key in the visit Date&Time of this new visit event(which is a compulsory field along with NRIC), AND the Diagnoses of illnesses and Medications prescribed for this new visit event (which are optional fields).<br>
<br>
3.) We then use "list" command to see all patient information.
Expand Down Expand Up @@ -389,7 +391,7 @@ No patient visit record found with NRIC: S7209876Y

By diagnosis: <br> Format: findDiagnosis diagnosis<br>
Note : <br>
• Single diagnosis to be entered. All corresponding patients' information and visit records will be printed to terminal,
• Single diagnosis to be entered (case-insensitive). All corresponding patients' information and visit records will be printed to terminal,
with exactly matched diagnosis. <br>
Example: `findDiagnosis Runny Nose`

Expand All @@ -412,7 +414,7 @@ No patient found with symptom: Runny Nose

By Medication: <br> Format: findMedication medication<br>
Note : <br>
• Single diagnosis to be entered. All corresponding patients' information and visit records will be printed to terminal,
• Single medication to be entered (case-insensitive). All corresponding patients' information and visit records will be printed to terminal,
with exactly matched medication. <br>
Example: `findMedication Panadol`

Expand Down Expand Up @@ -463,8 +465,8 @@ Format: appointment ic/NRIC date/DATE time/TIME \
Note: Deleting a Patient Appointment is case-insensitive.

#### Extra Information
Date format is in DD-MM-YYYY and Time format is in HH:mm\
The nric is case-insensitive
Date format is in DD-MM-YYYY and time format is in HH:mm\
The NRIC is case-insensitive

Example: `deleteAppointment ic/S1234567A date/18-11-2024 time/18:00`
```
Expand All @@ -488,7 +490,7 @@ Appointment on 18-11-2024 18:00 with Patient Will Smith, S7654321A.

---
## Finding a Patient Appointment
Find an appointment with a patient based on the given name, nric, date or time\
Find an appointment with a patient based on the given name, NRIC, date or time\
Format:
findAppointment n/NAME OR\
findAppointment ic/NRIC OR\
Expand All @@ -497,7 +499,7 @@ findAppointment time/TIME

#### Extra Information:
Date format is in DD-MM-YYYY and Time format is in HH:mm
The name and nric are case-insensitive
The name and NRIC are case-insensitive

Example: `findAppointment n/John`
```
Expand Down
Empty file removed logs/logs.log.lck
Empty file.
2 changes: 1 addition & 1 deletion src/main/java/bookbob/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static void main(String[] args) throws IOException {
System.out.println("Please check data file or delete it to start afresh");
System.out.println("Exiting");
System.exit(0);
}catch (Exception e) {
} catch (Exception e) {
logger.log(Level.SEVERE, "Error during initialization: " + e.getMessage(), e);
System.out.println("Error initializing program. Please check data files.");
System.exit(0);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/bookbob/functions/CommandHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,7 @@ public void findVisitByIc(String nric, Records records) {
if (patient.getNric().equals(nric)) {
ArrayList<Visit> visits = patient.getVisits();
isFound = true;
System.out.println("Patient name: " + patient.getName());

for (Visit visit : visits) {
System.out.println(visit.toString());
Expand Down
28 changes: 14 additions & 14 deletions src/main/java/bookbob/parser/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ public static boolean handleCommand(String input, CommandHandler commandHandler,
switch (command) {
case "help":
if (inputArray.length > 1) {
System.out.println("Unknown command. Type 'help' for a list of commands.");
logger.log(Level.INFO, "Unknown command received: {0}", command);
printUnknownCommand(command);
break;
}
logAndExecute("help", commandHandler::help);
Expand All @@ -59,16 +58,15 @@ public static boolean handleCommand(String input, CommandHandler commandHandler,
throw new RuntimeException(e);
}
} else {
System.out.println("Please specify an NRIC to delete.");
System.out.println("Please specify a NRIC to delete.");
logger.log(Level.INFO, "Empty NRIC inputted for delete command");
}
});
break;

case "list":
if (inputArray.length > 1) {
System.out.println("Unknown command. Type 'help' for a list of commands.");
logger.log(Level.INFO, "Unknown command received: {0}", command);
printUnknownCommand(command);
break;
}
logAndExecute("list", () -> commandHandler.list(records));
Expand Down Expand Up @@ -123,8 +121,7 @@ public static boolean handleCommand(String input, CommandHandler commandHandler,

case "listAppointments":
if (inputArray.length > 1) {
System.out.println("Unknown command. Type 'help' for a list of commands.");
logger.log(Level.INFO, "Unknown command received: {0}", command);
printUnknownCommand(command);
break;
}
logAndExecute("listAppointments", () -> commandHandler.listAppointments(appointmentRecord));
Expand Down Expand Up @@ -154,7 +151,7 @@ public static boolean handleCommand(String input, CommandHandler commandHandler,
if (inputArray.length > 1) {
logAndExecute("findVisit", () -> commandHandler.findVisitByIc(inputArray[1], records));
} else {
System.out.println("Please provide NRIC for findVisit.");
System.out.println("Please provide a NRIC for findVisit.");
logger.log(Level.INFO, "Missing NRIC for findVisit");
}
break;
Expand All @@ -163,7 +160,7 @@ public static boolean handleCommand(String input, CommandHandler commandHandler,
if (inputArray.length > 1) {
logAndExecute("findMedication", () -> commandHandler.findVisitByMedication(inputArray[1], records));
} else {
System.out.println("Please provide medication for findMedication.");
System.out.println("Please provide a medication for findMedication.");
logger.log(Level.INFO, "Missing medication for findMedication");
}
break;
Expand All @@ -172,15 +169,14 @@ public static boolean handleCommand(String input, CommandHandler commandHandler,
if (inputArray.length > 1) {
logAndExecute("findDiagnosis", () -> commandHandler.findVisitByDiagnosis(inputArray[1], records));
} else {
System.out.println("Please provide diagnosis for findDiagnosis.");
System.out.println("Please provide a diagnosis for findDiagnosis.");
logger.log(Level.INFO, "Missing diagnosis for findDiagnosis");
}
break;

case "exit":
if (inputArray.length > 1) {
System.out.println("Unknown command. Type 'help' for a list of commands.");
logger.log(Level.INFO, "Unknown command received: {0}", command);
printUnknownCommand(command);
break;
}
logAndExecute("exit", () -> {
Expand All @@ -194,8 +190,7 @@ public static boolean handleCommand(String input, CommandHandler commandHandler,
break;

default:
System.out.println("Unknown command. Type 'help' for a list of commands.");
logger.log(Level.INFO, "Unknown command received: {0}", command);
printUnknownCommand(command);
break;
}
return true;
Expand All @@ -206,6 +201,11 @@ public static boolean handleCommand(String input, CommandHandler commandHandler,
}
}

private static void printUnknownCommand(String command) {
System.out.println("Unknown command. Type 'help' for a list of commands.");
logger.log(Level.INFO, "Unknown command received: {0}", command);
}

private static void logAndExecute(String commandName, Runnable action) {
logger.log(Level.INFO, "Processing {0} command", commandName);
try {
Expand Down

0 comments on commit 2a26cd2

Please sign in to comment.