forked from nus-cs2113-AY2425S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from yentheng0110/YenTheng-AboutUs
Yen Theng AboutUs
- Loading branch information
Showing
4 changed files
with
208 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
# About us | ||
|
||
Display | Name | Github Profile | Portfolio | ||
--------|:-----------:|:--------------------------------------:|:---------: | ||
![](https://via.placeholder.com/100.png?text=Photo) | OngJunZheng | [Github](https://github.com/kaboomzxc) | [Portfolio](docs/team/ongjunzheng.md) | ||
![](https://via.placeholder.com/100.png?text=Photo) | Cora Zhang | [Github](https://github.com/coraleaf0602) | [Portfolio](coraleaf0602) | ||
![](https://via.placeholder.com/100.png?text=Photo) | Glendon Tan | [Github](https://github.com/G13nd0n) | [Portfolio](docs/team/GlendonTan.md) | ||
![](https://via.placeholder.com/100.png?text=Photo) | Ma Yitao | [Github](https://github.com/PrinceCatt) | [Portfolio](docs/team/yitao.md) | ||
![](https://via.placeholder.com/100.png?text=Photo) | Wong Yen Theng | [Github](https://github.com/yentheng0110) | [Portfolio](docs/team/wongyentheng.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package BookBob; | ||
import BookBob.entity.Records; | ||
import BookBob.functions.CommandHandler; | ||
import BookBob.functions.SaveAndRetrieve; | ||
import java.util.Scanner; | ||
|
||
public class Main { | ||
|
||
public static void main(String[] args) { | ||
System.out.println("Welcome to BookBob, Dr. Bob!"); | ||
|
||
Scanner in = new Scanner(System.in); | ||
Records records = new Records(); | ||
SaveAndRetrieve.initFile(records); | ||
CommandHandler commandHandler = new CommandHandler(); | ||
|
||
while (true) { | ||
String input = in.nextLine(); | ||
String[] inputArr = input.split(" ", 2); | ||
String command = inputArr[0]; | ||
|
||
switch (command) { | ||
case "exit": | ||
commandHandler.exit(input); | ||
break; | ||
|
||
case "add": | ||
commandHandler.add(input, records); | ||
break; | ||
|
||
case "list": | ||
commandHandler.list(records); | ||
break; | ||
|
||
case "delete": | ||
if (inputArr.length > 1) { | ||
String NRIC = inputArr[1].trim(); | ||
commandHandler.delete(NRIC, records); | ||
} else { | ||
System.out.println("Please specify an NRIC to delete."); | ||
} | ||
break; | ||
|
||
case "help": | ||
commandHandler.help(); | ||
break; | ||
|
||
default: | ||
System.out.println("Unknown command. Type 'help' for a list of commands."); | ||
break; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
package BookBob.functions; | ||
|
||
import BookBob.entity.Patient; | ||
import BookBob.entity.Records; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class CommandHandler { | ||
|
||
// Prints output for help command | ||
public void help() { | ||
System.out.println("+-----------+---------------------------------------+---------------------------------+\n" + | ||
"| Action | Format | Example |\n" + | ||
"+-----------+---------------------------------------+---------------------------------+\n" + | ||
"| Help | help | help |\n" + | ||
"+-----------+---------------------------------------+---------------------------------+\n" + | ||
"| Add | add n/NAME ic/NRIC [p/PHONE_NUMBER] | add n/James Ho ic/S9534567A |\n" + | ||
"| | [d/DIAGNOSIS] [m/MEDICATION] | p/91234567 d/Asthma m/Albuterol |\n" + | ||
"| | [ha/HOME_ADDRESS] [dob/DATE_OF_BIRTH] | ha/NUS-PGPR dob/13121995 |\n" + | ||
"+-----------+---------------------------------------+---------------------------------+\n" + | ||
"| List | list | list |\n" + | ||
"+-----------+---------------------------------------+---------------------------------+\n" + | ||
"| Find | find NAME [KEYWORDS] OR | find NRIC S1234 |\n" + | ||
"| | find NRIC [KEYWORDS] OR | |\n" + | ||
"| | find PHONE_NUMBER [KEYWORDS] OR | |\n" + | ||
"| | find DIAGNOSIS [KEYWORDS] OR | |\n" + | ||
"| | find MEDICATION [KEYWORDS] OR | |\n" + | ||
"| | find HOME_ADDRESS [KEYWORDS] OR | |\n" + | ||
"| | find DATE_OF_BIRTH [KEYWORDS] | |\n" + | ||
"+-----------+---------------------------------------+---------------------------------+\n" + | ||
"| Delete | delete NRIC | delete S9534567A |\n" + | ||
"+-----------+---------------------------------------+---------------------------------+\n" + | ||
"| Save | save(automatic) | save |\n" + | ||
"+-----------+---------------------------------------+---------------------------------+\n" + | ||
"| Retrieve/ | retrieve or import | retrieve |\n" + | ||
"| Import | (automatic) | |\n" + | ||
"+-----------+---------------------------------------+---------------------------------+\n" + | ||
"| Exit | exit | exit |\n" + | ||
"+-----------+---------------------------------------+---------------------------------+\n"); | ||
} | ||
|
||
public void add(String input, Records records) { | ||
String name = ""; | ||
String NRIC = ""; | ||
String dateOfBirth = ""; | ||
String phoneNumber = ""; | ||
String homeAddress = ""; | ||
String diagnosis = ""; | ||
List<String> medications = new ArrayList<>(); | ||
|
||
// Extract name | ||
int nameStart = input.indexOf("n/"); | ||
int NRICStart = input.indexOf("ic/"); | ||
if (nameStart != -1 && NRICStart != -1) { | ||
name = input.substring(nameStart + 2, NRICStart).trim(); | ||
} | ||
|
||
// Extract NRIC | ||
int phoneStart = input.indexOf("p/"); | ||
if (NRICStart != -1 && phoneStart != -1) { | ||
NRIC = input.substring(NRICStart + 3, phoneStart).trim(); | ||
} | ||
|
||
// Extract phone number | ||
int diagnosisStart = input.indexOf("d/"); | ||
if (phoneStart != -1 && diagnosisStart != -1) { | ||
phoneNumber = input.substring(phoneStart + 2, diagnosisStart).trim(); | ||
} | ||
|
||
// Extract diagnosis | ||
int medicationStart = input.indexOf("m/"); | ||
if (diagnosisStart != -1 && medicationStart != -1) { | ||
diagnosis = input.substring(diagnosisStart + 2, medicationStart).trim(); | ||
} | ||
|
||
// Extract medications (split by comma) | ||
int homeAddressStart = input.indexOf("ha/"); | ||
if (medicationStart != -1 && homeAddressStart != -1) { | ||
String meds = input.substring(medicationStart + 2, homeAddressStart).trim(); | ||
String[] medsArray = meds.split(",\\s*"); | ||
for (String med : medsArray) { | ||
medications.add(med.trim()); | ||
} | ||
} | ||
|
||
// Extract home address | ||
int dobStart = input.indexOf("dob/"); | ||
if (homeAddressStart != -1 && dobStart != -1) { | ||
homeAddress = input.substring(homeAddressStart + 3, dobStart).trim(); | ||
} | ||
|
||
// Extract date of birth | ||
if (dobStart != -1) { | ||
dateOfBirth = input.substring(dobStart + 4).trim(); | ||
} | ||
|
||
Patient patient = new Patient(name, NRIC); | ||
patient.setPhoneNumber(phoneNumber); | ||
patient.setDiagnosis(diagnosis); | ||
patient.setHomeAddress(homeAddress); | ||
patient.setDateOfBirth(dateOfBirth); | ||
patient.setMedication(medications); | ||
|
||
records.addPatient(patient); | ||
System.out.println("Patient " + name + " with NRIC " + NRIC + " added."); | ||
} | ||
|
||
|
||
public void list(Records records) { | ||
List<Patient> patients = records.getPatients(); | ||
if (patients.isEmpty()) { | ||
System.out.println("No patients found."); | ||
return; | ||
} | ||
for (Patient patient : patients) { | ||
System.out.println("Name: " + patient.getName() + ", NRIC: " + patient.getNric() + | ||
", Phone: " + patient.getPhoneNumber() + ", Diagnosis: " + patient.getDiagnosis() + | ||
", Medication: " + patient.getMedication() + ", Address: " + patient.getHomeAddress() + | ||
", DOB: " + patient.getDateOfBirth()); | ||
} | ||
} | ||
|
||
public void delete(String nric, Records records) { | ||
List<Patient> patients = records.getPatients(); | ||
int initialPatientSize = patients.size(); | ||
if (initialPatientSize == 0) { | ||
System.out.println("There are no patients in the record currently."); | ||
return; | ||
} | ||
for (int i = 0; i < patients.size(); i++) { | ||
Patient currentPatient = patients.get(i); | ||
String patientNRIC = currentPatient.getNric(); | ||
if (patientNRIC.equals(nric)) { | ||
patients.remove(i); | ||
System.out.println("Patient " + currentPatient.getName() + ", " + patientNRIC + ", has been deleted."); | ||
break; | ||
} | ||
} | ||
if (patients.size() == initialPatientSize) { | ||
System.out.println("Patient " + nric + " not found"); | ||
} | ||
} | ||
|
||
// Takes in an input string and determines whether to exit the program | ||
public void exit(String input) { | ||
if(input.equalsIgnoreCase("exit")) { | ||
System.exit(0); | ||
} | ||
} | ||
} | ||
|