Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/PrinceCatt/tp
Browse files Browse the repository at this point in the history
Refactor Main and write log into a file
  • Loading branch information
PrinceCatt committed Nov 9, 2024
2 parents 7d9413b + b58a45b commit 3982195
Show file tree
Hide file tree
Showing 21 changed files with 1,385 additions and 807 deletions.
3 changes: 3 additions & 0 deletions data/bookbob_appointment.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
Name: Patrick|NRIC: S9089078U|Date: 08-11-2024|Time: 09:00
Name: John Doe|NRIC: S1234567A|Date: 18-11-2024|Time: 18:00
Name: Yusof|NRIC: S9089079U|Date: 19-11-2024|Time: 09:00
Name: Helen Smith|NRIC: S7654321A|Date: 19-11-2024|Time: 18:00
Name: Yusof|NRIC: S9089079U|Date: 19-11-2024|Time: 18:30
5 changes: 4 additions & 1 deletion data/bookbob_data.txt
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
Name: John Doe | NRIC: S1234567A | Phone Number: 98765432 | Date_Of_Birth: | Home Address: | Allergy: [] | Sex: | Medical History: [] | Visit: [01-10-2024 15:30, Diagnosis: [], Medications: [], 21-10-2024 15:48, Diagnosis: [], Medications: []];
Name: Patricia | NRIC: S908909U | Phone Number: | Date_Of_Birth: | Home Address: | Allergy: [] | Sex: | Medical History: [] | Visit: [01-01-2025 16:00, Diagnosis: [Cough], Medications: [Cough syrup, Lozenges], 01-01-2025 16:00, Diagnosis: [Gastric, Runny Nose], Medications: [Cetirizine, Panadol], 07-11-2024 16:00, Diagnosis: [Asthma], Medications: []];
Name: Aaron Chia | NRIC: T0989087I | Phone Number: 90890765 | Date_Of_Birth: | Home Address: Yio Chu Kang, 650987 | Allergy: [] | Sex: Male | Medical History: [] | Visit: [07-07-2025 10:00, Diagnosis: [], Medications: [], 09-08-2025 10:00, Diagnosis: [Asthma], Medications: [Albuterol]];
Name: John Doe | NRIC: S9876543A | Phone Number: 91234567 | Date_Of_Birth: | Home Address: | Allergy: [] | Sex: | Medical History: [] | Visit: [01-11-2024 14:30, Diagnosis: [Fever], Medications: [Paracetamol]];
Name: Jane Smith | NRIC: S8765432B | Phone Number: 92345678 | Date_Of_Birth: | Home Address: | Allergy: [] | Sex: | Medical History: [] | Visit: [01-11-2024 15:30, Diagnosis: [Cough], Medications: [Cough Syrup]];
4 changes: 2 additions & 2 deletions docs/AfterAppointment.puml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ object "<u>:Main</u>" as Main
object "<u> :CommandHandler</u>" as CommandHandler
object "<u> in:Scanner</u>" as Scanner
object "<u> appointment:Appointment </u>" as Appointment {
name = John Doe
nric = S123A
name = "John Doe"
nric = "S123A"
date = 18-11-2024
time = 18:00
}
Expand Down
Binary file modified docs/AfterExecutionOD.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ layout: default
## Table of Contents
1. [Design & Implementation](#design--implementation)
- [Architecture](#architecture)
- [Managing Patient Visits and Records](#1-managing-patient-visits-and-records)
- [Adding New Visits for Existing Patients](#a-adding-new-visits-for-existing-patients)
- [Adding New Patient to the Patient Records](#b-adding-new-patient-to-the-patient-records)
- [Appointment Feature](#c-appointment-feature)
Expand Down Expand Up @@ -165,6 +164,7 @@ class and records it within the `AppointmentRecord` class. The appointment recor
> The Sequence Diagram for the execution of appointment command:
![img.png](NewAppointmentSD.png)


---
## Appendix A : Product Scope
### Target user profile
Expand Down
56 changes: 36 additions & 20 deletions docs/NewAppointment.puml
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,44 @@
'https://plantuml.com/sequence-diagram

actor Doctor
Doctor -> Main ++
Main -> Record **
Main -> AppointmentRecord **
Main -> FileHandler ++ : initFile(records)
FileHandler -> Main -- :
Main -> FileHandler ++ : initFile(appointmentRecords)
FileHandler -> Main -- :
Main -> CommandHandler ** :
Doctor -> Main : appointment("John Doe, S123A, 18-11-2024, 18:00")
Main -> CommandHandler ++: commandHandler.appointment("John Doe, S123A, 18-11-2024, 18:00")
CommandHandler -> AppointmentRecord ++ : appointmentRecord.checkAvailability("18-11-2024, 18:00")
AppointmentRecord -> CommandHandler -- : nextAvailableTime
Doctor -> ":Main" ++
":Main" -> ":Record" **
activate ":Record"
":Record" --> ":Main" -- : record:Record
":Main" -> ":AppointmentRecord" **
activate ":AppointmentRecord"
":AppointmentRecord" --> ":Main" -- : appointmentRecord:AppointmentRecord
":Main" -> ":FileHandler" ++ : initFile(records)
":FileHandler" --> ":Main" -- :
":Main" -> ":FileHandler" ++ : initFile(appointmentRecords)
":FileHandler" --> ":Main" -- :
":Main" -> ":CommandHandler" ** :
activate ":CommandHandler"
":CommandHandler" --> ":Main" --: commandHandler:CommandHandler
Doctor -> ":Main" : appointment("n/John Doe, ic/S123A, date/18-11-2024, time/18:00")
":Main" -> ":CommandHandler" ++: commandHandler.appointment("n/John Doe, ic/S123A, date/18-11-2024, time/18:00")
":CommandHandler" -> ":CommandHandler" ++: commandHandler.extractName("n/John Doe, ic/S123A, date/18-11-2024, time/18:00")
":CommandHandler" --> ":CommandHandler" --: name = "John Doe"
":CommandHandler" -> ":CommandHandler" ++: commandHandler.extractNric("n/John Doe, ic/S123A, date/18-11-2024, time/18:00")
":CommandHandler" --> ":CommandHandler" --: nric = "S123A""
":CommandHandler" --> ":CommandHandler" ++: commandHandler.extractDate("n/John Doe, ic/S123A, date/18-11-2024, time/18:00")
":CommandHandler" --> ":CommandHandler" --: date = "18-11-2024""
":CommandHandler" -> ":CommandHandler" ++: commandHandler.extractTime("n/John Doe, ic/S123A, date/18-11-2024, time/18:00")
":CommandHandler" --> ":CommandHandler" --: time = "18:00"
":CommandHandler" -> ":AppointmentRecord" ++ : appointmentRecord.checkAvailability("18-11-2024, 18:00")
":AppointmentRecord" --> ":CommandHandler" -- : nextAvailableTime
group alt [nextAvailableTime == "18:00"]
CommandHandler -> Appointment **
CommandHandler -> Appointment ++ : new Appointment("John Doe", "S123A", "18-11-2024", "18:00")
Appointment -> CommandHandler -- : appointment
":CommandHandler" -> ":Appointment" **
activate ":Appointment"
":CommandHandler" -> ":Appointment" : new Appointment("John Doe", "S123A", "18-11-2024", "18:00")
":Appointment" --> ":CommandHandler" -- : appointment

CommandHandler -> AppointmentRecord ++ : appointmentRecords.addAppointment(appointment)
AppointmentRecord -> CommandHandler --
":CommandHandler" -> ":AppointmentRecord" ++ : appointmentRecords.addAppointment(appointment)
":AppointmentRecord" --> ":CommandHandler" --
else
end
CommandHandler -> FileHandler ++ : FileHandler.autosave(appointmentRecords)
FileHandler -> CommandHandler --

":CommandHandler" -> ":FileHandler" ++ : FileHandler.autosave(appointmentRecords)
":FileHandler" --> ":CommandHandler" --
":CommandHandler" --> ":Main" --
deactivate ":Main"
@enduml
Binary file modified docs/NewAppointmentSD.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 0 additions & 6 deletions docs/team/johndoe.md

This file was deleted.

17 changes: 16 additions & 1 deletion src/main/java/bookbob/entity/Appointment.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import java.time.format.DateTimeFormatter;

//@@author G13nd0n
public class Appointment implements Comparable<Appointment> {
public class Appointment implements Comparable<Appointment>, OutputConversion {
private String patientName;
private String patientNric;
private LocalTime time;
Expand Down Expand Up @@ -67,4 +67,19 @@ public int compareTo(Appointment other) {
return 1;
}
}

//@@author G13nd0n
@Override
public String convertPatientToOutputText() {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy");
String patientName = this.getPatientName();
String patientNric = this.getPatientNric();
String date = this.getDate().format(formatter);
String time = this.getTime().toString();
String output = "";
output += "Name: " + patientName + "|" + "NRIC: " + patientNric + "|"
+ "Date: " + date + "|" + "Time: " + time;

return output;
}
}
Loading

0 comments on commit 3982195

Please sign in to comment.