diff --git a/.gitignore b/.gitignore index 2873e189e1..90f9b46619 100644 --- a/.gitignore +++ b/.gitignore @@ -13,5 +13,5 @@ src/main/resources/docs/ *.iml bin/ -/text-ui-test/ACTUAL.TXT +/text-ui-test/EXPECTED.TXT text-ui-test/EXPECTED-UNIX.TXT diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..19e86fe56e --- /dev/null +++ b/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: seedu.duke.Duke + diff --git a/README.md b/README.md index f82e2494b7..a4bc645d21 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,6 @@ Prerequisites: JDK 11 (use the exact version), update Intellij to the most recen > Task :compileJava > Task :processResources NO-SOURCE > Task :classes - > Task :Duke.main() Hello from ____ _ diff --git a/build.gradle b/build.gradle index d5e548e85f..00d77694f2 100644 --- a/build.gradle +++ b/build.gradle @@ -10,8 +10,8 @@ repositories { } dependencies { - testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.5.0' - testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.5.0' + testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.9.2' + testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.9.2' } test { @@ -43,4 +43,5 @@ checkstyle { run{ standardInput = System.in + enableAssertions = true } diff --git a/data/patient-data.txt b/data/patient-data.txt new file mode 100644 index 0000000000..5d073df317 --- /dev/null +++ b/data/patient-data.txt @@ -0,0 +1,19 @@ +-311245909 +49 +Demo1 +0 +0 +50 +Demo +0 +0 +51 +Demo +1 +2023/04/04%Bronchitis%Sore Throat%Fever%Headache%COVID-19% +1 +2023/04/04%Guaifenesin%Ibuprofen%Lozenges%Difflam Throat Spray%Paracetamol% +52 +Demo +0 +0 diff --git a/data/queue_data.txt b/data/queue_data.txt new file mode 100644 index 0000000000..c0d2b86b34 --- /dev/null +++ b/data/queue_data.txt @@ -0,0 +1,3 @@ +1530573 +3 +4 diff --git a/docs/AboutUs.md b/docs/AboutUs.md index 0f072953ea..22dea7c463 100644 --- a/docs/AboutUs.md +++ b/docs/AboutUs.md @@ -1,9 +1,10 @@ # About us -Display | Name | Github Profile | Portfolio ---------|:----:|:--------------:|:---------: -![](https://via.placeholder.com/100.png?text=Photo) | John Doe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) -![](https://via.placeholder.com/100.png?text=Photo) | Don Joe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) -![](https://via.placeholder.com/100.png?text=Photo) | Ron John | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) -![](https://via.placeholder.com/100.png?text=Photo) | John Roe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) -![](https://via.placeholder.com/100.png?text=Photo) | Don Roe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) +| Display | Name | Github Profile | Portfolio | +|-----------------------------------------------------|:-----------------:|:---------------------------------------------:|:-----------------------------------------:| +| ![](https://via.placeholder.com/100.png?text=Photo) | Jerald Chen | [Github](https://github.com/Jeraldchen) | [Portfolio](team%2Fjeraldchen.html) | +| ![](https://via.placeholder.com/100.png?text=Photo) | Ryan Tan | [Github](https://github.com/Thunderdragon221) | [Portfolio](team%2Fthunderdragon221.html) | +| ![](https://via.placeholder.com/100.png?text=Photo) | Gareth Tan | [Github](https://github.com/Geeeetyx) | [Portfolio](team%2Fgeeeetyx.html) | +| ![](https://via.placeholder.com/100.png?text=Photo) | Tan Yi Zhe | [Github](https://github.com/tanyizhe) | [Portfolio](team%2Ftanyizhe.html) | +| ![](https://via.placeholder.com/100.png?text=Photo) | Brannon Aw Xu Wei | [Github](https://github.com/Brennanzuz) | [Portfolio](team%2Fbrennanzuz.html) | + diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md index 64e1f0ed2b..58b8137a7b 100644 --- a/docs/DeveloperGuide.md +++ b/docs/DeveloperGuide.md @@ -1,38 +1,286 @@ # Developer Guide ## Acknowledgements - -{list here sources of all reused/adapted ideas, code, documentation, and third-party libraries -- include links to the original source as well} +[comment]: <> (//@@author tanyizhe) +HealthHub Singapore - www.healthhub.sg +Health Sciences Authority Singapore - www.hsa.giv.sg +Guardian Pharmacy - www.guardian.com.sg +Watsons Pharmacy - www.watsons.com.sg +MayoClinic - www.mayoclinic.org ## Design & implementation -{Describe the design and implementation of the product. Use UML diagrams and short code snippets where applicable.} +[comment]: <> (//@@author Jeraldchen) + +### Architecture +![Architecture.png](diagrams%2FArchitecture.png) + +### Duke Main Sequence Diagram +![MainClass.png](diagrams%2FMainSequenceDiagram.png) + +### User Interface +![UIClass.png](diagrams%2FMenuClassDiagram.png) + +This feature shows how the user interface is being implemented via three main classes which are Menu, Information and Parser. + +### Menu +The menu class is responsible for the user interface of the application. It is responsible for displaying the menu and +taking in user input. The menu class is also responsible for the main loop of the application, which is the loop that +continues to run until the user exits the application. The menu class allows patients to log in, register and exit the +program. + +`showWelcomeMenu()` is used to display the welcome menu to the user. +`register()` is used to register a new patient into the system. +`login()` is used to log a patient into the system. +`exit()` is used to exit the program. +`showAccountMenu()` is used to display the list of choices to the user. +`getUserSymptoms` is to ask input form user and store it in an arraylist. +`addSymptomToSymptomList()` is used to add the symptom to the symptom list. +`parseSymptomInput()` is used to parse the symptom input from the user. +`addSymptoms()` is used to add the symptoms to the symptom list. +`displaySymptomsList()` is used to display the list of symptoms to the user. +`displayPossibleIllnesses()` is used to display the list of possible illnesses to the user. + +### Information +The information class is responsible for displaying information to the user. It is responsible for displaying the +information of the patient, the medicine and the diagnosis. It is also responsible for displaying the list of +symptoms and the list of illnesses. A hashmap is used to store the information of the patient and the hashed password. + +`storePatientInfo()` is used to store the patient information into the hashmap. +`getPatientInfo()` is used to retrieve the patient information from the hashmap. +`printDiagnosis()` is used to print the diagnosis of the patient. +`resetDiagnosticHistory()` is used to reset and clear the diagnostic history of the patient. +`checkHash()` is used to check if the hashed password is correct and matches. +`getAllPatientData()` is used to retrieve all the patient data from the hashmap. +`resetSymptomChoice()` is used to reset the symptom choice of the patient in case an error was made. +`hashPassword()` is used to hash the password of the patient. + +### Parser +The parser class is responsible for parsing the user input. It is responsible for parsing the user input from the +menu and the symptom list. It is also responsible for parsing the user input from the medicine list. + +`parseWelcome()` is used to parse the user input from the welcome menu. +`parseAccountCommand()` is used to parse the user command and then execute the command based on the choice number. + +[comment]: <> (//@@author Brennanzuz) +### Diagnosis + +![DiagnosisClassDiagram.png](diagrams%2FDiagnosisClassDiagram.png) + +#### Symptoms + +All possible symptoms that patients may suffer from are included into this enumeration. + +#### Illness + +This class is inherited by all other illnesses. It contains the name of the illness `illnessName`, its `severityLevel`, +whether it is chronic `isChronic`, and most importantly, the list of symptoms specific to the illness `symptoms`. + +Child classes of `Illness` are given their values on creation of the object in their constructor function. +Hence `new Diarrhoea()` will create an object with `.getSymptoms()` returning an `ArrayList` +of `Symptom.WET_STOOL`, `Symptom.STOMACH_ACHE`, and `Symptom.DIARRHOEA`. + +Knowing this, each child object of `Illness` will be created and stored in `ArrayList ALL_ILLNESSES`. + +#### Diagnosis algorithm + +![DiagnosisSequenceDiagram.png](diagrams%2FDiagnosisSequenceDiagram.png) + +After the patient has entered all their symptoms, it will be passed to the `getPossibleIllnesses()` function +in `Diagnosis` where it will match each symptom the patient has to each symptom of all possible +illnesses `ALL_ILLNESSES`. + +The percentage of matches the patient's symptoms has to the total number of symptoms the illness is specified to exhibit +is calculated, and if this percentage does not cross the `POSSIBILITY_THRESHOLD`, the patient would be declared to +possibly have the illness. To store this likely candidate, an `IllnessMatch` object is created storing the +candidate `Illness` and the `similarityPercentage`. + +An `ArrayList possibleIllnesses` is then returned to retrieve the appropriate medicine in another class. + +[comment]: <> (//@@author tanyizhe) +### Implementation of MedicineManager class, Medicine class + +![img_1.png](diagrams%2FMedicineSequenceDiagram.png) + +*Sequence diagram for medicine class* + +#### From the menu to the Medicine Manager + +User input from the menu will first get parsed by the parser class. +From the Parser class, a new `MedicineManager` class is created. The `MedicineManager` class initialises 2 hash tables +with medicines created with the Medicine class. Each medicine has a different name and dosage, which can be +retrieved using the `Medicine.toString()` and `Medicine.getDosages()` methods. + +#### Medicines + +Medicine information is stored in two hash tables. One for matching the relevant medication with illnesses, the other +matching the medicines with correct dosages. Medicine information are +stored in two separate hash tables so that only relevant information is obtained. +There are a lot of different kinds of medicines, which are all created as constants using the `final` keyword. +Information about medicines are sourced online from various pharmacies and their websites. + +#### Analysing the symptoms and prescribing the medications + +`Diagnosis.getIllnessMatch()` is called in the MedicineManager class, which returns an ArrayList of `illnessMatch` +objects. `IllnessMatch` objects contain information about the illness' name and the likelihood that the symptoms +the user has inputted match the illness as explained in the "Diagnosis" section above. + +Each illness will be analysed in the `analyseIllness()` method, and the medications that are relevant +to the mentioned illness will be suggested to the user. +This information is then printed, and stored in the user's Medicine History. + +#### Medicine History +The user's medicine history is stored in a dictionary within the `Storage` class. Whenever a user is prescribed +medication, the date of the prescription and medications prescribed are saved into a file, as explained below +in the Storage section of this Developer Guide. Medicine history of users is important and needs to be saved +to prevent abuse of the system and may cause undesirable effects such as overdose, if not properly monitored. + +#### Listing and Finding Medicines + +User can list and find available medicines using the application. Listing medicines calls the +`listMedicines()` method of the MedicineManager class. `listMedicines()` will collect all the keys of the +`medicineDosages` hash table, sort them using `Collections.sort()` and proceed to print them out in +alphabetical order. + +[comment]: <> (//@@Thunderdragon221) +### Storage + +![StorageClassDiagram.png](diagrams%2FStorageClassDiagram.png) + +The Storage class is responsible for loading information from and writing information to a designated data file. + +Upon each start up of the application, Dr Duke will call `loadData()`. If Dr Duke is started for the very first time +on a device, the designated directory and file for all subsequent use will be created via `createDirectory()` and +`createFile()`, which are part of the `loadData()` method. `readFile()` will then be called under `loadData()` to read +the data previously stored in the data file (if any). `readFile()` also calls `readMedicineHistoryFromFile()`, which +reads in any past medicine dispensing records of the patient stored in the data file. `readFile()` throws +`CorruptedDataException` if any corruption in the data file is found in the process of reading from it, which is +facilitated by the `endOfFile()` method. + +During use of Dr Duke, if the patient decides to reset his/her diagnosis history, `resetDiagnosisHistory()` will be +called, which will call `saveData()` after resetting the patient's diagnosis history. After the patient has been +diagnosed with possible illnesses and dispensed appropriate medication, these records will also be saved by called +`saveData()`. Finally, before exiting Dr Duke, `saveData()` will also be called to write all existing data to the data +file. + +### Implementation of loadData() in Storage Class +![loadDataSequenceDiagram.png](diagrams%2FloadDataSequenceDiagram.png) + +### Implementation of saveData() in Storage Class +![saveDataSequenceDiagram.png](diagrams%2FsaveDataSequenceDiagram.png) + +[comment]: <> (//@@Geeeetyx) + +### Patient +![PatientClassDiagram.png](diagrams%2FPatientClassDiagram.png) + +The Patient class is responsible for creating a patient object, which is required to store a user's information. + +The method for creating a new Patient object is as follows: + +~~~ +new Patient(name, hash, diagnosisHistory, medicineHistory); +~~~ + +Once key information about the patient is obtained from the Menu class, the new patient object is created via: + +~~~ +Information.storePatientInfo(hash, new Patient(name, hash, diagnosisHistory, medicineHistory)); +~~~ + +which is found in the Menu class. + +#### Patient Class Methods: + +The methods contained in the Patient Class are primarily used in the Information, Parser and Storage class. + +The Patient class contains important getters and setters, allowing different classes to access the patient object and +the patient's information via the following methods: + +`getName()` returns the name of the patient. + +`getPassword()` returns the password of the patient's account. + +`getPatientDiagnosisHistory()` allows for access to the array where past diagnoses are stored. + +`getPatientMedicineHistory()` allows for access to the array where past prescribed medications are stored. + +`setName()` and `setPassword()` allow the programme to set the patient's name and password. + +`setPatientDiagnosisHistory()` and `setPatientMedicineHistory()` allow the programme to read data from a storage file, +and then set the stored data into the Patient object. + +`updatePatientMedicineHistory()` and `updatePatientDiagnosisHistory()` allow us to add new diagnoses and medications +prescribed to the Patient object. + +`appendMedicineToSameDate()` appends medicine patient is prescribed if additional medicine is prescribed on the same +day, allowing us to keep track of multiple prescriptions to one patient in one session. ## Product scope + ### Target user profile -{Describe the target user profile} +Doctor Duke is targeted at people who want to get diagnosed with certain **mild** illnesses they have +and/or get medicine to treat their illness without having to visit a General Practitioner. ### Value proposition -{Describe the value proposition: what problem does it solve?} +The current median wait times at a polyclinics across Singapore average at around 15-20 minutes, +(Source: +[MOH](https://www.moh.gov.sg/resources-statistics/healthcare-institution-statistics/waiting-times-for-registration-and-for-consultation-at-polyclinics)). + +This wait time might be too long for people who only have mild illnesses, and thus do not require consulting a general +practitioner, yet they do not know what medicine they require. + +Thus, Doctor Duke aims to solve this issue, by creating a programme that can diagnose illnesses based on what symptoms +the patient might have, and dispense medicine and dosage accordingly, at a speed much faster than waiting at a clinic. ## User Stories -|Version| As a ... | I want to ... | So that I can ...| -|--------|----------|---------------|------------------| -|v1.0|new user|see usage instructions|refer to them when I forget how to use the application| -|v2.0|user|find a to-do item by name|locate a to-do without having to go through the entire list| +| Version | As a ... | I want to ... | So that I can ... | +|---------|-------------------------------------|------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------| +| v1.0 | new user | see instructions that are clear and succinct on how to use the app | refer to them when I forget how to use the application, without needing to consult anyone | +| v1.0 | new user | view medicine dosages prescribed easily | take medication safely. | +| v1.0 | new user | check what kind of illness I have based on a strange combination of symptoms I woke up with | find out if I need to consult a doctor and prevent myself from wasting time queueing to see one. | +| v1.0 | office worker feeling a bit ill | quickly get medicine during lunch break | get back to work quickly | +| v1.0 | patient who dislikes seeing doctors | be prescribed medication without consulting a doctor | avoid interacting with doctors. | +| v1.0 | patient | to know whether my symptoms are serious enough to warrant a trip to the doctor or would some medicine be enough. | save time on visiting a doctor. | +| v1.0 | medical professional | identify more severe illnesses that patients might have | be referred to by Doctor Duke so that the patient can get the medical care required. | +| v1.0 | government official | only prescribes non-controlled drugs through Doctor Duke | monitor who is getting access to controlled substances. | +| v1.0 | doctor | ensure Doctor Duke does not give out Medical Certificates | control the issuance of such certificates and they are only from a licensed and qualified professional | +| v1.0 | doctor | treat patients with mild illnesses quickly | focus on patients with more severe illnesses. | +| v1.0 | doctor | set a cap on the amount of medicine prescribed | avoid cases of patients overdosing. | +| v2.0 | experienced user | find what symptoms I have entered | check if I entered the correct symptoms | +| v2.0 | meticulous patient | check what symptoms I have entered and have the option to delete certain ones | make sure I key in the information accurately | +| v2.0 | nurse | use Doctor Duke to monitor when patients get their medication | keep tabs on anyone potentially misusing Dr Duke for medicine. | ## Non-Functional Requirements -{Give non-functional requirements} +1. The programme must be secure and protects a patient's data, allowing access to the data either through an admin account, +or by the user himself. +2. The programme must be easy to use, with clear instructions and clean UI design. +3. The system must be reliable and function without errors or crashes. +4. The programme must be easy to maintain and update, with clear documentation and code organization. +5. The programme must comply with legal and regulatory requirements, such as data protection and privacy laws. +6. The programme should follow sound medical practices, by performing proper research into the different diagnoses and +medicines. -## Glossary +[//]: # (## Glossary) -* *glossary item* - Definition +[//]: # () +[//]: # (* *glossary item* - Definition) ## Instructions for manual testing -{Give instructions on how to do a manual product testing e.g., how to load sample data to be used for testing} +Dummy accounts are provided for testing. First, access the Doctor Duke programme by following the steps in the +User Guide, which can be found [here](https://ay2223s2-cs2113-w13-1.github.io/tp/UserGuide.html). + +Upon starting the programme, log in and enter the following name and password: + +~~~ +Name: Demo +Password: 1 +~~~ + +This gives access to a dummy account "Demo", allowing for testing of Doctor Duke. diff --git a/docs/README.md b/docs/README.md index bbcc99c1e7..36e020a4db 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,6 +1,10 @@ -# Duke +[comment]: <> (//@@author Jeraldchen) +# Dr Duke -{Give product intro here} +Hi! I am Dr Duke, a command line application that helps you manage your medical records! +Fell mildly sick and do not wish to queue for long hours at a clinic? Fret not! Just head +down to your local pharmacy and key your symptoms into Dr Duke! Dr Duke will then recommend +you the best medicine for your symptoms! Useful links: * [User Guide](UserGuide.md) diff --git a/docs/UserGuide.md b/docs/UserGuide.md index abd9fbe891..34de3d244a 100644 --- a/docs/UserGuide.md +++ b/docs/UserGuide.md @@ -1,42 +1,686 @@ +[comment]: <> (//@@author Geeeetyx) # User Guide ## Introduction -{Give a product intro} +Dr Duke is a desktop app for diagnosing patients who have **_mild_** illnesses, +optimised for use via a Command Line Interface (CLI). -## Quick Start +Doctor Duke can diagnose illnesses and suggest medicine accordingly faster than visiting a General Practitioner. -{Give steps to get started quickly} +Note: Dr Duke is NOT a multi-user application as defined by CS2113 rules, and does not violate any of the conditions +listed of a multi-user application by CS2113 definition. + +## Start Guide 1. Ensure that you have Java 11 or above installed. -1. Down the latest version of `Duke` from [here](http://link.to/duke). +2. Down the latest version of **Dr Duke** from [this GitHub repo](https://github.com/AY2223S2-CS2113-W13-1/tp/releases/tag/v2.0). +3. Download the jar file from the latest release, labelled as **DrDuke.jar**. +4. Place the file in the folder you want to use as the home folder for your Duke. +5. Run the jar file via double-clicking on the JAR file, or by copying the file path and entering the copied + filepath command into your terminal: + +Example: + +~~~ +java -jar "C:\Users\Albert\Desktop\DrDuke.jar" +~~~ + +# Features Guide + +Upon starting Dr Duke, you will be greeted with a welcome message, + +A menu with options for registering and/or logging in will be shown. + +Expected outcome: +~~~ +Hello I am + ____ ____ _ +| _ \ ___ | _ \ _ _ | | _____ +| | | |/ _ \ | | | | | | | |/ / _ \ +| |_| | | | |_| | |_| | < __/ +|____/|_| |____/ \__,_|_|\_\___| + +--------------------------------------------------- +What would you like to do? Please enter the number: +1. Register +2. Login +3. Exit +--------------------------------------------------- +~~~ + +## Register, Log In, Exiting + +### 1. Registering + +A new patient can register him/herself into Doctor Duke, by keying in his/her name and a password. + +Format: Enter ``1`` to register. + +Note: +1. When keying in passwords, any white spaces in the passwords keyed in will be stripped. +2. There can be patients with the same name and hence username. Thus, we allow the same username with 2 or more passwords to access different accounts. + +Expected Outcome: +~~~ +--------------------------------------------------- +What would you like to do? Please enter the number: +1. Register +2. Login +3. Exit +--------------------------------------------------- +1 +--------------------------------------------------- +Please enter your name: +Demo +--------------------------------------------------- +Please enter your password: +3 +------------------------------- +Please re-enter your password: +3 +--------------------------------------------------- +Registration successful! +--------------------------------------------------- +~~~ + +### Logging In + +Format: Press ``2`` to log in. + +Expected outcome: +~~~ +--------------------------------------------------- +What would you like to do? Please enter the number: +1. Register +2. Login +3. Exit +--------------------------------------------------- +2 +--------------------------------------------------- +Please enter your name: +Demo +--------------------------------------------------- +Please enter your password: +3 +--------------------------------------------------- +Login successful! +Welcome Demo! +--------------------------------------------------- +~~~ + +### Exiting + +Format: Press ``3`` to exit. + +Expected Outcome: +~~~ +--------------------------------------------------- +What would you like to do? Please enter the number: +1. Register +2. Login +3. Exit +--------------------------------------------------- +3 +--------------------------------------------------- +Thank you for using + ____ ____ _ +| _ \ ___ | _ \ _ _ | | _____ +| | | |/ _ \ | | | | | | | |/ / _ \ +| |_| | | | |_| | |_| | < __/ +|____/|_| |____/ \__,_|_|\_\___| +--------------------------------------------------- +~~~ + +## After Registering and/or Logging in + +Upon registering and/or logging in, the following menu will be shown. + +~~~ +--------------------------------------------------- +Login successful! +Welcome Demo! +--------------------------------------------------- +What would you like to do? Please enter the number: +1. Report symptoms +2. View diagnosis history +3. Reset diagnosis history +4. View symptoms History +5. Delete symptom choice +6. Reset symptoms +7. View Medicine history +8. List available medicines +9. Find available medicine +10. Display Queue Number +0. Exit +--------------------------------------------------- +~~~ + +### 1. Report Symptoms +The patient can choose what symptoms they have for Doctor Duke to diagnose. + +Format: `1` + +A list of symptoms will then be displayed to the user. + +~~~ +--------------------------------------------------- +What would you like to do? Please enter the number: +1. Report symptoms +2. View diagnosis history +3. Reset diagnosis history +4. View symptoms History +5. Delete symptom choice +6. Reset symptoms +7. View Medicine history +8. List available medicines +9. Find available medicine +10. Display Queue Number +0. Exit +--------------------------------------------------- +1 +--------------------------------------------------- +Here is the list of possible symptoms: +a. Fever +b. Dry Cough +c. Cough with Phlegm +d. Throat Irritation +e. Loss of Taste or Smell +f. Runny nose +g. Headache +h. Chills +i. Fatigue +j. Sneezing +k. Blocked Nose +l. Itchy eyes +m. Red eyes +n. Diarrhoea +o. Stomachache +p. Wet Stools +q. Hard or Lumpy Stools +r. Nausea +s. Vomiting +t. Sleeplessness +u. Blurred Vision +v. Sensitivity to Light and Sound +w. Muscle ache +x. Backache + +Please enter a symptom. +--------------------------------------------------- + +~~~ +The patient will then key in his/her symptoms accordingly, by keying in 'a' for fever, 'b' for Dry cough, +so on and so forth, in one string or with spaces. + +DO NOT spell out the symptom, just choose the option. + +Both forms yield the same expected result. + +Expected outcome: +``` +Please enter a symptom. +--------------------------------------------------- +abc +Do you have any other symptoms? [Y/N] +n +Your entered symptoms are: +[FEVER, DRY_COUGH, COUGH_WITH_PHLEGM] +``` +OR +``` +Please enter a symptom. +--------------------------------------------------- +abc +Do you have any other symptoms? [Y/N] +N +Your entered symptoms are: +fever +dry cough +cough with phlegm +``` + +The patient may key in `Y` or `y`to continue reporting symptoms. Once the patient is finished reporting their symptoms, they can type `N` or `n` to finish reporting their symptoms. + +After reporting their symptoms, Doctor Duke will then diagnose the patient, by: +1. Showing what illness the patient might have, +2. Displaying what medicine the patient should consume. + +Note that if the combination of symptoms entered does not correspond to any known illness, the patient will be referred to the doctor instead of receiving medication for an unconfirmed illness. + +Expected Outcome: +``` +Please enter a symptom. +--------------------------------------------------- +abc +Do you have any other symptoms? [Y/N] +N +Your entered symptoms are: +fever +dry cough +cough with phlegm +============================================================================================ +You may have: +Sore Throat Match: 66.67% +Fever Match: 100.00% +----------------------------------------------------------- +Below are some recommended medications for you to purchase: +----------------------------------------------------------- +Medication for: Sore Throat + Lozenges - Dosage: When you feel pain from sore throat +----------------------------------------------------------- + Description: Lozenges are used to medicate the mouth and throat for the slow administration in digestion or + cough remedies. Lozenges may contain an anesthetic, a demulcent, or an antiseptic. +----------------------------------------------------------- + Difflam Throat Spray - Dosage: 2 - 4 times every 1.5 - 3 hours until you feel better +----------------------------------------------------------- + Description: This spray offers targeted and rapid symptom relief for hard-to-reach inflamed and + painful areas in your mouth and throat. It provides rapid relief from local inflammation + and pain from 60 seconds. +----------------------------------------------------------- +Medication for: Fever + Paracetamol - Dosage: 1 or 2 pills up to 3 times a day +----------------------------------------------------------- + Description: Paracetamol is a commonly used medicine that can help treat pain and reduce a high temperature + It's typically used to relieve mild or moderate pain, such as headaches, + toothache or sprains, and reduce fevers caused by illnesses such as colds and flu. +----------------------------------------------------------- +End of diagnosis. Please proceed to your nearest pharmacy to purchase the above medications if applicable. +============================================================================================ +``` + +### 2. View Diagnosis History +The patient can view his/her diagnosis history. + +Format: Press `2` to view diagnosis history. + +Expected outcome: +``` +--------------------------------------------------- +What would you like to do? Please enter the number: +1. Report symptoms +2. View diagnosis history +3. Reset diagnosis history +4. View symptoms History +5. Delete symptom choice +6. Reset symptoms +7. View Medicine history +8. List available medicines +9. Find available medicine +10. Display Queue Number +0. Exit +--------------------------------------------------- +2 +--------------------------------------------------- +Your diagnosis history is: +2023/04/05: [Sore Throat, Fever] +--------------------------------------------------- +``` + +### 3. Reset Diagnosis History +The patient can choose to reset his/her diagnosis history. + +Format: Enter `3` to reset diagnosis history. + +To test if the diagnosis history has been reset, enter `2` afterwards to check the diagnosis history. + +Expected outcome: +``` +--------------------------------------------------- +What would you like to do? Please enter the number: +1. Report symptoms +2. View diagnosis history +3. Reset diagnosis history +4. View symptoms History +5. Delete symptom choice +6. Reset symptoms +7. View Medicine history +8. List available medicines +9. Find available medicine +10. Display Queue Number +0. Exit +--------------------------------------------------- +3 +--------------------------------------------------- +Your diagnosis history has been reset. +--------------------------------------------------- +What would you like to do? Please enter the number: +1. Report symptoms +2. View diagnosis history +3. Reset diagnosis history +4. View symptoms History +5. Delete symptom choice +6. Reset symptoms +7. View Medicine history +8. List available medicines +9. Find available medicine +10. Display Queue Number +0. Exit +--------------------------------------------------- +2 +--------------------------------------------------- +You have no past diagnoses +--------------------------------------------------- +``` +[comment]: <> (//@@author Jeraldchen) + +### 4. Viewing Symptoms History +The patient can view the list of his/her symptoms that she has entered into Dr Duke. + +Format: Enter `4` to choose to view the symptoms' history. + +Expected outcome (if no symptoms were entered prior): +``` +--------------------------------------------------- +You have not entered any symptoms. +--------------------------------------------------- +``` + +Else, expected outcome after entering some symptoms: +``` +--------------------------------------------------- +fever +dry cough +cough with phlegm +--------------------------------------------------- +``` +[comment]: <> (//@@author tanyizhe) +### 5. Delete Symptom Choice + +The patient can choose to delete symptom(s) from the list of symptoms that they have +entered into Dr Duke. + +Format: Enter `5` to choose to delete symptom(s). + +Expected outcome (if no symptoms were entered prior): +``` +--------------------------------------------------- +You have not entered any symptoms. +--------------------------------------------------- +``` + +If some symptoms have already been entered: +``` +Here is the list of your symptoms: +1. nausea +2. runny nose +3. throat irritation +4. headache +Please enter the numbers of the symptom you want to delete. +Please put a space between each number to delete multiple symptoms. +--------------------------------------------------- +1 2 +Successfully deleted symptom(s)! +Here is the updated list of your symptoms: +1. throat irritation +2. headache +--------------------------------------------------- +Below is your new diagnosis: +============================================================================================ +You may have: +Headache Match: 100.00% +----------------------------------------------------------- +Medication for: Headache + Paracetamol - Dosage: 1 or 2 pills up to 3 times a day +----------------------------------------------------------- + Description: Paracetamol is a commonly used medicine that can help treat pain and reduce a high temperature + It's typically used to relieve mild or moderate pain, such as headaches, + toothache or sprains, and reduce fevers caused by illnesses such as colds and flu. +----------------------------------------------------------- +End of diagnosis. Please proceed to your nearest pharmacy to purchase the above medications if applicable. +============================================================================================ +``` + +[comment]: <> (//@@author Geeeetyx) +### 6. Reset Symptoms +The patient can choose to reset his/her entered symptoms. + +Format: Enter `6` to reset entered symptoms. + +If the patient has not entered any symptoms prior to this, Doctor Duke will prompt the patient.\ +We assume this occurs after the patient first logs in and attempts to reset the non-existent symptoms. + +Expected outcome (if no symptoms were entered prior): +~~~ +--------------------------------------------------- +Login successful! +Welcome Demo! +--------------------------------------------------- +What would you like to do? Please enter the number: +1. Report symptoms +2. View diagnosis history +3. Reset diagnosis history +4. View symptoms History +5. Delete symptom choice +6. Reset symptoms +7. View Medicine history +8. List available medicines +9. Find available medicine +10. Display Queue Number +0. Exit +--------------------------------------------------- +6 +-------------------------------------------------- +You have not entered any symptoms. No symptoms to reset. +~~~ + +Else, expected outcome after entering some symptoms: +~~~ +--------------------------------------------------- +What would you like to do? Please enter the number: +1. Report symptoms +2. View diagnosis history +3. Reset diagnosis history +4. View symptoms History +5. Delete symptom choice +6. Reset symptoms +7. View Medicine history +8. List available medicines +9. Find available medicine +10. Display Queue Number +0. Exit +--------------------------------------------------- +6 +--------------------------------------------------- +Your symptom choice has been reset. +--------------------------------------------------- +~~~ + +### 7. Viewing Medicine History +The patient can choose to view his/her medicine history. + +Format: Enter `7` to view past medicine history. + -## Features +Expected outcome: +~~~ +--------------------------------------------------- +What would you like to do? Please enter the number: +1. Report symptoms +2. View diagnosis history +3. Reset diagnosis history +4. View symptoms History +5. Delete symptom choice +6. Reset symptoms +7. View Medicine history +8. List available medicines +9. Find available medicine +10. Display Queue Number +0. Exit +--------------------------------------------------- +7 +--------------------------------------------------- +Medication History: +2023/03/22: [Paracetamol] +--------------------------------------------------- +~~~ +[comment]: <> (//@@author tanyizhe) +### 8. List all medicines +The patient can view all available medicines. -{Give detailed description of each feature} +Format: enter `8` to list medicines. -### Adding a todo: `todo` -Adds a new item to the list of todo items. +Expected outcome: +~~~ +--------------------------------------------------- +What would you like to do? Please enter the number: +1. Report symptoms +2. View diagnosis history +3. Reset diagnosis history +4. View symptoms History +5. Delete symptom choice +6. Reset symptoms +7. View Medicine history +8. List available medicines +9. Find available medicine +10. Display Queue Number +0. Exit +--------------------------------------------------- +8 +--------------------------------------------------- +List of available medications: +Aspirin +Dulcolax +Eye Drops +Guaifenesin +Ibuprofen +Lozenges +Magnesium +Paracetamol +Robitussin +Ultracarbon +--------------------------------------------------- +~~~ +### 9. Find medicine +The patient can find an available medicine. -Format: `todo n/TODO_NAME d/DEADLINE` +Format: enter `9` to find a medicine. +The program will prompt the patient for a keyword. -* The `DEADLINE` can be in a natural language format. -* The `TODO_NAME` cannot contain punctuation. +Expected outcome: +~~~ +--------------------------------------------------- +What would you like to do? Please enter the number: +1. Report symptoms +2. View diagnosis history +3. Reset diagnosis history +4. View symptoms History +5. Delete symptom choice +6. Reset symptoms +7. View Medicine history +8. List available medicines +9. Find available medicine +0. Exit +--------------------------------------------------- +9 +--------------------------------------------------- +Please enter a keyword: +--------------------------------------------------- +a +--------------------------------------------------- +Results for "a": +Aspirin +Dulcolax +Guaifenesin +Magnesium +Paracetamol +Ultracarbon +--------------------------------------------------- +~~~ -Example of usage: +[comment]: <> (//@@author Geeeetyx) +### 10. Viewing your Queue Number +When a user logs in, he/she is assigned a queue number. -`todo n/Write the rest of the User Guide d/next week` +As of v2.1, this queue number feature is only a basic feature. With more work it could be further integrated with +an actual pharmercy to manage the queue of patients. -`todo n/Refactor the User Guide to remove passive voice d/13/04/2020` +Format: Enter `10` to view your queue number. +~~~ +--------------------------------------------------- +Login successful! +Welcome Demo! +--------------------------------------------------- +What would you like to do? Please enter the number: +1. Report symptoms +2. View diagnosis history +3. Reset diagnosis history +4. View symptoms History +5. Delete symptom choice +6. Reset symptoms +7. View Medicine history +8. List available medicines +9. Find available medicine +10. Display Queue Number +0. Exit +--------------------------------------------------- +10 +--------------------------------------------------- +This is your queue number +--------------------------------------------------- +7 +--------------------------------------------------- +What would you like to do? Please enter the number: +1. Report symptoms +2. View diagnosis history +3. Reset diagnosis history +4. View symptoms History +5. Delete symptom choice +6. Reset symptoms +7. View Medicine history +8. List available medicines +9. Find available medicine +10. Display Queue Number +0. Exit +--------------------------------------------------- +~~~ -## FAQ -**Q**: How do I transfer my data to another computer? -**A**: {your answer here} +### 0. Exiting Doctor Duke +Once the patient is done with the program, he/she can exit the program. -## Command Summary +Format: Enter `0` to exit Doctor Duke. -{Give a 'cheat sheet' of commands here} +Expected outcome: +~~~ +--------------------------------------------------- +What would you like to do? Please enter the number: +1. Report symptoms +2. View diagnosis history +3. Reset diagnosis history +4. View symptoms History +5. Delete symptom choice +6. Reset symptoms +7. View Medicine history +8. List available medicines +9. Find available medicine +10. Display Queue Number +0. Exit +--------------------------------------------------- +0 +--------------------------------------------------- +Thank you for using + ____ ____ _ +| _ \ ___ | _ \ _ _ | | _____ +| | | |/ _ \ | | | | | | | |/ / _ \ +| |_| | | | |_| | |_| | < __/ +|____/|_| |____/ \__,_|_|\_\___| +--------------------------------------------------- +~~~ +[comment]: <> (//@@author Thunderdragon221) +### Appendix: Corrupted data +Once corruption is detected in any of the data files upon start +up, Dr Duke will automatically exit WITHOUT SAVING with the +following error message: +~~~ +ERROR: Data file is corrupted. Clear all data files or +restore data to uncorrupted state before trying again. +~~~ +This is to give the user a chance to restore the data file(s) and +undo any tampering previously carried out, instead of +mercilessly wiping all data from existence. The option is thus +given to the user to either restore the data or clear it entirely. -* Add todo `todo n/TODO_NAME d/DEADLINE` +Should the corruption be undone, Dr Duke will next start up +successfully as if no corruption had ever existed. diff --git a/docs/_config_yml b/docs/_config_yml new file mode 100644 index 0000000000..9df5f865ed --- /dev/null +++ b/docs/_config_yml @@ -0,0 +1,3 @@ +remote_theme: pages-themes/hacker@v0.2.0 +plugins: +- jekyll-remote-theme \ No newline at end of file diff --git a/docs/diagrams/Architecture.png b/docs/diagrams/Architecture.png new file mode 100644 index 0000000000..dcca16f5ba Binary files /dev/null and b/docs/diagrams/Architecture.png differ diff --git a/docs/diagrams/Architecture.puml b/docs/diagrams/Architecture.puml new file mode 100644 index 0000000000..76f8194202 --- /dev/null +++ b/docs/diagrams/Architecture.puml @@ -0,0 +1,27 @@ +[comment]: <> (//@@author Jeraldchen) +@startuml +'https://plantuml.com/component-diagram +skinparam componentStyle rectangle + +actor user +user --> [Duke]: Enter Input +[Duke] --> [Storage]: Load Data +[Storage] --> [Duke]: Data +[Duke] --> [Menu]: Display Menu +[Duke] --> [Parser]: Parse Input +[Parser] --> [Duke]: Command +[IllnessMatch] --> [Diagnosis]: Symptoms +[Parser] --> [Illness]: Symptoms +[Illness] --> [IllnessMatch]: Symptoms +[MedicineManager] --> [Medicine]: Medicine +[Medicine] --> [Parser]: Medicine +[Parser] --> [Information]: Command +[Information] --> [Parser]: Information +[Diagnosis] --> [MedicineManager]: Illness + + +file data + +[Storage]..> data: Reads and Write Data + +@enduml \ No newline at end of file diff --git a/docs/diagrams/DiagnosisClassDiagram.png b/docs/diagrams/DiagnosisClassDiagram.png new file mode 100644 index 0000000000..58439092e1 Binary files /dev/null and b/docs/diagrams/DiagnosisClassDiagram.png differ diff --git a/docs/diagrams/DiagnosisClassDiagram.puml b/docs/diagrams/DiagnosisClassDiagram.puml new file mode 100644 index 0000000000..c79680fad4 --- /dev/null +++ b/docs/diagrams/DiagnosisClassDiagram.puml @@ -0,0 +1,302 @@ +@startuml +'https://plantuml.com/class-diagram + +!include Style.puml +hide circle +skinparam classAttributeIconSize 0 + +class Illness { +-illnessName: String +-severityLevel: int +-isChronic: boolean +-symptoms: ArrayList ++Illness(illnessName: String, severityLevel: int, isChronic: boolean, symptoms: ArrayList) ++getIllnessName(): String ++getSeverityLevel(): int ++isChronic(): boolean ++getSymptoms(): ArrayList +} + +Illness *--- "1..59" Symptom : contains > + +class IllnessMatch { +-illness: Illness +-similarityPercentage: double ++IllnessMatch(illness: Illness, similarityPercentage: double) ++getIllness(): Illness ++getSimilarityPercentage(): double +} + +IllnessMatch *--- "1" Illness : has > + +class Diagnosis { +-POSSIBILITY_THRESHOLD: double +-ALL_ILLNESSES: ArrayList +-diagnosisLogger: Logger +-getMatchingSymptoms(patientSymptoms: ArrayList, illnessSymptoms: ArrayList): ArrayList ++getPossibleIllnesses(patientSymptoms: ArrayList): ArrayList +} + +Diagnosis *--- "39" Illness : lists all > + +enum Symptom { +DIFFICULTY_BREATHING, +HISTORY_OF_ASTHMA, +HYPERVENTILATION, +HISTORY_OF_ALLERGIES, +RUNNY_NOSE, +FATIGUE, +SNIFFING, +THROAT_IRRITATION, +DRY_COUGH, +COUGH_WITH_PHLEGM, +BLEEDING_WHEN_COUGHING, +CHEST_PAIN, +HEAD_ACHE, +HIGH_HEART_RATE, +TOOTH_ACHE, +BLACK_TEETH, +RED_SKIN, +ITCHY_SKIN, +SWELLING_SKIN, +DRY_SCALING_SKIN, +HARD_LUMPY_STOOL, +WET_STOOL, +DIARRHOEA, +STOMACH_ACHE, +NAUSEA, +VOMITING, +BLOODIED_STOOLS, +WEIGHT_LOSS, +FREQUENT_URINATION, +SLOW_REGENERATION, +FEVER, +SUSCEPTIBILITY_TO_ILLNESS, +CHILLS, +BLOCKED_NOSE, +SWOLLEN_LYMPH_NODES, +SWOLLEN_JOINTS, +MUSCLE_ACHE, +BACK_ACHE, +JOINT_PAIN, +HISTORY_OF_OSTEOPOROSIS, +BLURRED_VISION, +SENSITIVITY_TO_LIGHT_AND_SOUND, +SPRAIN, +SLEEPLESSNESS, +FRACTURE, +BREATHLESSNESS, +GENERAL_SWELLING, +GENERAL_PAIN, +PALENESS_OF_SKIN, +THIRST, +WOUND_OR_CUT, +BLEEDING, +PUSS, +HISTORY_OF_ADHD, +HISTORY_OF_DEPRESSION, +LOSS_OF_TASTE_OR_SMELL, +ITCHY_EYE, +RED_EYES, +SNEEZING +} + +'class Asthma { +'+Asthma() +'} +'class GeneralAllergicReaction { +'+GeneralAllergicReaction() +'} +'class Bronchitis { +'+Bronchitis() +'} +'class GeneralBacterialInfection { +'+GeneralBacterialInfection(), +'} +'class Pneumonia { +'+Pneumonia() +'} +'class SoreThroat { +'+SoreThroat() +'} +'class Tuberculosis { +'+Tuberculosis() +'} +'class CoronaryHeartDisease { +'+CoronaryHeartDisease() +'} +'class Hypertension { +'+Hypertension() +'} +'class GeneralToothAche { +'+GeneralToothAche() +'} +'class ToothDecay { +'+ToothDecay() +'} +'class GeneralRash { +'+GeneralRash() +'} +'class Hives { +'+Hives() +'} +'class Psoriasis { +'+Psoriasis() +'} +'class Constipation { +'+Constipation() +'} +'class Diarrhoea { +'+Diarrhoea() +'} +'class FoodPoisoning { +'+FoodPoisoning() +'} +'class GeneralStomachAche { +'+GeneralStomachAche() +'} +'class Hemorrhoids { +'+Hemorrhoids() +'} +'class Diabetes { +'+Diabetes() +'} +'class GeneralFever { +'+GeneralFever() +'} +'class HumanImmunodeficiencyVirus { +'+HumanImmunodeficiencyVirus() +'} +'class Arthritis { +'+Arthritis() +'} +'class GeneralBackAche { +'+GeneralBackAche() +'} +'class GeneralMuscleAche { +'+GeneralMuscleAche() +'} +'class Osteoporosis { +'+Osteoporosis() +'} +'class GeneralHeadAche { +'+GeneralHeadAche() +'} +'class Migraine { +'+Migraine() +'} +'class Fracture { +'+Fracture() +'} +'class InternalBleeding { +'+InternalBleeding() +'} +'class SuperficialWound { +'+SuperficialWound() +'} +'class AttentionDeficitHyperactivityDisorder { +'+AttentionDeficitHyperactivityDisorder() +'} +'class Depression { +'+Depression() +'} +'class Insomnia { +'+Insomnia() +'} +'class Conjunctivitis { +'+Conjunctivitis() +'} +'class Coronavirus { +'+Coronavirus() +'} +'class Dengue { +'+Dengue() +'} +'class GeneralCold { +'+GeneralCold() +'} +'class GeneralFlu { +'+GeneralFlu() +'} +' +'Asthma -|> Illness +'GeneralAllergicReaction -|> Illness +'Bronchitis -|> Illness +'GeneralBacterialInfection -|> Illness +'Pneumonia -|> Illness +'SoreThroat -|> Illness +'Tuberculosis -|> Illness +'CoronaryHeartDisease -|> Illness +'Hypertension -|> Illness +'GeneralToothAche -|> Illness +'ToothDecay -|> Illness +'GeneralRash -|> Illness +'Hives -|> Illness +'Psoriasis -|> Illness +'Constipation -|> Illness +'Diarrhoea -|> Illness +'FoodPoisoning -|> Illness +'GeneralStomachAche -|> Illness +'Hemorrhoids -|> Illness +'Diabetes -|> Illness +'GeneralFever -|> Illness +'HumanImmunodeficiencyVirus -|> Illness +'Arthritis -|> Illness +'GeneralBackAche -|> Illness +'GeneralMuscleAche -|> Illness +'Osteoporosis -|> Illness +'GeneralHeadAche -|> Illness +'Migraine -|> Illness +'Fracture -|> Illness +'InternalBleeding -|> Illness +'SuperficialWound -|> Illness +'AttentionDeficitHyperactivityDisorder -|> Illness +'Depression -|> Illness +'Insomnia -|> Illness +'Conjunctivitis -|> Illness +'Coronavirus -|> Illness +'Dengue -|> Illness +'GeneralCold -|> Illness +'GeneralFlu -|> Illness +' +'Asthma *-- "3" Symptom : consists > +'GeneralAllergicReaction *-- "1" Symptom : consists > +'Bronchitis *-- "5" Symptom : consists > +'GeneralBacterialInfection *-- "2" Symptom : consists > +'Pneumonia *-- "8" Symptom : consists > +'SoreThroat *-- "3" Symptom : consists > +'Tuberculosis *-- "4" Symptom : consists > +'CoronaryHeartDisease *-- "5" Symptom : consists > +'Hypertension *-- "5" Symptom : consists > +'GeneralToothAche *-- "1" Symptom : consists > +'ToothDecay *-- "2" Symptom : consists > +'GeneralRash *-- "2" Symptom : consists > +'Hives *-- "3" Symptom : consists > +'Psoriasis *-- "3" Symptom : consists > +'Constipation *-- "1" Symptom : consists > +'Diarrhoea *-- "3" Symptom : consists > +'FoodPoisoning *-- "5" Symptom : consists > +'GeneralStomachAche *-- "1" Symptom : consists > +'Hemorrhoids *-- "1" Symptom : consists > +'Diabetes *-- "6" Symptom : consists > +'GeneralFever *-- "1" Symptom : consists > +'HumanImmunodeficiencyVirus *-- "8" Symptom : consists > +'Arthritis *-- "2" Symptom : consists > +'GeneralBackAche *-- "1" Symptom : consists > +'GeneralMuscleAche *-- "1" Symptom : consists > +'Osteoporosis *-- "3" Symptom : consists > +'GeneralHeadAche *-- "1" Symptom : consists > +'Migraine *-- "5" Symptom : consists > +'Fracture *-- "2" Symptom : consists > +'InternalBleeding *-- "6" Symptom : consists > +'SuperficialWound *-- "3" Symptom : consists > +'AttentionDeficitHyperactivityDisorder *-- "1" Symptom : consists > +'Depression *-- "1" Symptom : consists > +'Insomnia *-- "1" Symptom : consists > +'Conjunctivitis *-- "2" Symptom : consists > +'Coronavirus *-- "5" Symptom : consists > +'Dengue *-- "5" Symptom : consists > +'GeneralCold *-- "6" Symptom : consists > +'GeneralFlu *-- "3" Symptom : consists > + +@enduml \ No newline at end of file diff --git a/docs/diagrams/DiagnosisSequenceDiagram.png b/docs/diagrams/DiagnosisSequenceDiagram.png new file mode 100644 index 0000000000..c8b8f2ac88 Binary files /dev/null and b/docs/diagrams/DiagnosisSequenceDiagram.png differ diff --git a/docs/diagrams/DiagnosisSequenceDiagram.puml b/docs/diagrams/DiagnosisSequenceDiagram.puml new file mode 100644 index 0000000000..89ca972428 --- /dev/null +++ b/docs/diagrams/DiagnosisSequenceDiagram.puml @@ -0,0 +1,37 @@ +@startuml +'https://plantuml.com/sequence-diagram + +hide footbox +"<>\nMedicineManager" -> "<>\nDiagnosis": analyseIllness() +activate "<>\nMedicineManager" +activate "<>\nDiagnosis" +group for each child of Illness +create "illness:Illness" +"<>\nDiagnosis" -> "illness:Illness": Illness() +activate "illness:Illness" +"illness:Illness" --> "<>\nDiagnosis" +deactivate "illness:Illness" +end + +loop for all Illness + "<>\nDiagnosis" -> "<>\nDiagnosis": getMatchingSymptoms() + activate "<>\nDiagnosis" + "<>\nDiagnosis" -> "illness:Illness": getSymptoms + activate "illness:Illness" + "illness:Illness" --> "<>\nDiagnosis": size() + deactivate "illness:Illness" + create "illnessMatch:IllnessMatch" + "<>\nDiagnosis" -> "illnessMatch:IllnessMatch": IllnessMatch() + deactivate "<>\nDiagnosis" + activate "illnessMatch:IllnessMatch" + "illnessMatch:IllnessMatch" --> "<>\nDiagnosis": illnessMatch + deactivate "illnessMatch:IllnessMatch" +end +destroy "illness:Illness" +destroy "illnessMatch:IllnessMatch" +"<>\nDiagnosis" --> "<>\nMedicineManager": possibleIllnesses +deactivate "<>\nDiagnosis" +destroy "<>\nDiagnosis" + + +@enduml \ No newline at end of file diff --git a/docs/diagrams/MainSequenceDiagram.png b/docs/diagrams/MainSequenceDiagram.png new file mode 100644 index 0000000000..33be70aaaf Binary files /dev/null and b/docs/diagrams/MainSequenceDiagram.png differ diff --git a/docs/diagrams/MainSequenceDiagram.puml b/docs/diagrams/MainSequenceDiagram.puml new file mode 100644 index 0000000000..cf217c4c04 --- /dev/null +++ b/docs/diagrams/MainSequenceDiagram.puml @@ -0,0 +1,37 @@ +[comment]: <> (//@@author Jeraldchen) +@startuml +'https://plantuml.com/sequence-diagram +hide footbox +!include Style.puml + +activate Duke +activate Storage +Duke -> Storage: loadData() +Storage --> Duke: data +deactivate Storage +loop hash = 0 + Duke -> Menu: showWelcomeMenu() + activate Menu + Menu -> Parser: parseWelcome() + activate Parser + Parser --> Menu: command + deactivate Parser + Menu --> Duke: command + deactivate Menu +end +loop true + Duke -> Menu: showAccountMenu() + activate Menu + Menu -> Parser: parseAccountCommand() + activate Parser + Parser --> Menu: command + deactivate Parser + Menu --> Duke: command + deactivate Menu +end + +destroy Parser +destroy Menu + + +@enduml \ No newline at end of file diff --git a/docs/diagrams/MedicineSequenceDiagram.png b/docs/diagrams/MedicineSequenceDiagram.png new file mode 100644 index 0000000000..d22da34bbb Binary files /dev/null and b/docs/diagrams/MedicineSequenceDiagram.png differ diff --git a/docs/diagrams/MedicineSequenceDiagram.puml b/docs/diagrams/MedicineSequenceDiagram.puml new file mode 100644 index 0000000000..1b67349110 --- /dev/null +++ b/docs/diagrams/MedicineSequenceDiagram.puml @@ -0,0 +1,33 @@ +[comment]: <> (//@@author tanyizhe) +@startuml +'https://plantuml.com/sequence-diagram + +hide footbox + +create MedicineManager +Parser -> MedicineManager : new MedicineManager() +activate MedicineManager +create Medicine +MedicineManager -> Medicine: new Medicine() +MedicineManager -> Medicine: InitialiseMedications() +activate Medicine +Medicine --> MedicineManager: toString() +activate MedicineManager + +MedicineManager -> Medicine: InitialiseMedicineDosages() + +Medicine --> MedicineManager: getDosage() +deactivate Medicine +deactivate MedicineManager +MedicineManager -> Diagnosis: getIllnessMatch() +activate Diagnosis +Diagnosis --> MedicineManager +deactivate Diagnosis + + + +MedicineManager --> Parser: AnalyseIllness() +deactivate MedicineManager + + +@enduml diff --git a/docs/diagrams/MenuClassDiagram.png b/docs/diagrams/MenuClassDiagram.png new file mode 100644 index 0000000000..5b83f8604f Binary files /dev/null and b/docs/diagrams/MenuClassDiagram.png differ diff --git a/docs/diagrams/MenuClassDiagram.puml b/docs/diagrams/MenuClassDiagram.puml new file mode 100644 index 0000000000..2984e8362d --- /dev/null +++ b/docs/diagrams/MenuClassDiagram.puml @@ -0,0 +1,64 @@ +[comment]: <> (//@@author Jeraldchen) + +@startuml +'https://plantuml.com/sequence-diagram + +hide circle +skinparam classAttributeIconSize 0 + +!include Style.puml +class Menu { + + {static} symptoms: ArrayList + + {static} showWelcomeMenu(): void + + {static} register(): void + + {static} login(): void + + {static} exit(): void + + {static} exitWithoutSaving(): void + + {static} showAccountMenu(): void + + {static} getUserSymptoms(): ArrayList + - {static} printExitLogo(): void + - {static} addSymptomToSymptomList(scanner: Scanner, symptoms: ArrayList): void + - {static} parseSymptomInput(symptoms: ArrayList, symptomChoices: String[]): void + - {static} addSymptoms(symptom: Symptom, symptoms: ArrayList): void + - {static} displaySymptomList() : void + + {static} displayPossibleIllness(symptoms: ArrayList): void +} + +class Information { + - {static} patientsList: HashMap + - {static} logger: Logger + + {static} storePatientInfo(hash: int, patient: Patient): void + + {static} getPatientInfo(hash: int): Patient + + {static} printDiagonsis History(int hash) : void + + {static} resetDiagnosticHistory(int hash) : void + + {static} checkHash(int hash) : boolean + + {static} getAllPatientData() : HashMap + + {static} resetSymptomChoice(symptoms: ArrayList)) : void + + {static} hashPassword(String password) : int +} + +class Parser { + + {static} parseWelcome(choice: String): void + + {static} parseAccountCommand(choice: String): void +} + +class Patient { + # patientDiagnosticHistory: ArrayList + # patientMedicineHistory: Hashtable> + # name: String + # hash: int + + getName(): String + + setName(name: String): void + + getPassword(): void + + setPassword(hash: int): void + + setPatientDiagnosticHistory(diagnosis: ArrayList): void + + getPatientDiagnosticHistory(): ArrayList + + updatePatientDiagnosticHistory(diagnosis: String): void +} + +Information "1" *-- "many" Patient : contains +Parser o-- Patient +Parser o-- Information +Parser o-- Menu + +@enduml \ No newline at end of file diff --git a/docs/diagrams/PatientClassDiagram.png b/docs/diagrams/PatientClassDiagram.png new file mode 100644 index 0000000000..57f997db47 Binary files /dev/null and b/docs/diagrams/PatientClassDiagram.png differ diff --git a/docs/diagrams/PatientClassDiagram.puml b/docs/diagrams/PatientClassDiagram.puml new file mode 100644 index 0000000000..81b6d622b8 --- /dev/null +++ b/docs/diagrams/PatientClassDiagram.puml @@ -0,0 +1,35 @@ +[comment]: <> (//@@author Geeeetyx) + +@startuml +'https://plantuml.com/sequence-diagram +hide circle +skinparam classAttributeIconSize 0 + +class Patient{ +#patientDiagnosisHistory: ArrayList +#patientMedicineHistory: HashTable> +#name: String +#hash: int + ++Patient(name: String, hash: int, patientDiagnosisHistory: Hashtable>, + patientDiagnosisHistory: HashTable>) + ++getName() ++getPassword() ++setName(name: String) ++setPassword(hash: int) + ++setPatientDiagnosisHistory(diagnosisHistory: Hashtable>) ++getPatientDiagnosisHistory() ++updatePatientDiagnosisHistory(date: String, diagnoses: ArrayList) + ++getPatientMedicineHistory() ++setPatientMedicineHistory(patientMedicineHistory: Hashtable>) ++updatePatientMedicineHistory(date: String, medicines: ArrayList) ++printPatientMedicineHistory() + +-appendMedicineToSameDate(date: String, medicines: ArrayList) +-appendDiagnosisToSameDate(date: String, diagnoses: ArrayList) +} + +@enduml \ No newline at end of file diff --git a/docs/diagrams/PatientSequenceDiagram.puml b/docs/diagrams/PatientSequenceDiagram.puml new file mode 100644 index 0000000000..a3bbf58b13 --- /dev/null +++ b/docs/diagrams/PatientSequenceDiagram.puml @@ -0,0 +1,19 @@ +[comment] <> (@@author Geeeetyx) + +@startuml +'https://plantuml.com/sequence-diagram + +hide footbox +create Patient +Storage -> Patient : new Patient() +activate Patient +Patient --> Storage: patient +deactivate Patient + +create Patient +Menu -> Patient : new Patient() +activate Patient +Patient --> Menu: patient +deactivate Patient + +@enduml \ No newline at end of file diff --git a/docs/diagrams/StorageClassDiagram.png b/docs/diagrams/StorageClassDiagram.png new file mode 100644 index 0000000000..7c45a774a6 Binary files /dev/null and b/docs/diagrams/StorageClassDiagram.png differ diff --git a/docs/diagrams/StorageClassDiagram.puml b/docs/diagrams/StorageClassDiagram.puml new file mode 100644 index 0000000000..482fc5ea54 --- /dev/null +++ b/docs/diagrams/StorageClassDiagram.puml @@ -0,0 +1,39 @@ +[comment]: <> (//@@author Thunderdragon221) +@startuml +'https://plantuml.com/class-diagram + +hide circle +skinparam classAttributeIconSize 0 + +!include Style.puml +class Storage { +- {static} DIR_PATH: String +- {static} FILE_PATH: String +- {static} QUEUE_FILE_PATH : String +- {static} dataCompare : String +- {static} queueDataCompare : String +- {static} logger : Logger ++ {static} loadData() : void ++ {static} saveData() : void +- {static} createDirectory() : void +- {static} createFile() : void +- {static} readFile() : void +- {static} emptyField(data: String) : boolean +- {static} isValidDate(year: int, month: int, day: int) : boolean +- {static} readMedicineHistoryFromFile(scanner: Scanner) : Hashtable> +- {static} writeMedicineHistory(data: String, medicineHistory: Hashtable>) : String +- {static} createQueueFile() : void +- {static} saveQueue() : void +- {static} readQueueFile() : void +} + +exception CorruptedDataException {} +exception Exception {} +exception FileNotFoundException {} +exception IOException {} + +Exception <|-- CorruptedDataException +Storage ..> IOException +Storage ..> FileNotFoundException +Storage ..> CorruptedDataException +@enduml \ No newline at end of file diff --git a/docs/diagrams/Style.puml b/docs/diagrams/Style.puml new file mode 100644 index 0000000000..33dfa8088c --- /dev/null +++ b/docs/diagrams/Style.puml @@ -0,0 +1,12 @@ +!define RED #FF0000FF +!define ORANGE #FF8000FF +!define YELLOW #FFFF00FF +!define CHARTREUSE #80FF00FF +!define GREEN #00FF00FF +!define SPRING_GREEN #00FF80FF +!define CYAN #00FFFFFF +!define AZURE #0080FFFF +!define BLUE #0000FFFF +!define VIOLET #8000FFFF +!define MAGENTA #FF00FFFF +!define ROSE #FF0080FF \ No newline at end of file diff --git a/docs/diagrams/UIClass.png b/docs/diagrams/UIClass.png new file mode 100644 index 0000000000..23ad444f5b Binary files /dev/null and b/docs/diagrams/UIClass.png differ diff --git a/docs/diagrams/loadDataSequenceDiagram.png b/docs/diagrams/loadDataSequenceDiagram.png new file mode 100644 index 0000000000..652b4b53e6 Binary files /dev/null and b/docs/diagrams/loadDataSequenceDiagram.png differ diff --git a/docs/diagrams/loadDataSequenceDiagram.puml b/docs/diagrams/loadDataSequenceDiagram.puml new file mode 100644 index 0000000000..7f6a9d3ce3 --- /dev/null +++ b/docs/diagrams/loadDataSequenceDiagram.puml @@ -0,0 +1,34 @@ +[comment]: <> (//@@author Thunderdragon221) +@startuml +'https://plantuml.com/sequence-diagram +hide footbox +!include Style.puml + +participant "main :Duke" +"main :Duke" -> Storage: loadData() +activate Storage +Storage -> Storage: createDirectory() +activate Storage +Storage -> Storage: directory created +deactivate Storage +Storage -> Storage: createFile() +activate Storage +Storage -> Storage: file created +deactivate Storage +Storage -> Storage: readFile() +activate Storage +Storage -> Patient: new Patient() +activate Patient +Patient -> Information: storePatientInfo() +activate Information +Information --> Patient: patient stored +deactivate Information +Patient --> Storage: patient added +destroy Information +deactivate Patient +deactivate Storage +Storage --> "main :Duke" : data loaded +destroy Patient +deactivate Storage + +@enduml \ No newline at end of file diff --git a/docs/diagrams/saveDataSequenceDiagram.png b/docs/diagrams/saveDataSequenceDiagram.png new file mode 100644 index 0000000000..de65bfa53f Binary files /dev/null and b/docs/diagrams/saveDataSequenceDiagram.png differ diff --git a/docs/diagrams/saveDataSequenceDiagram.puml b/docs/diagrams/saveDataSequenceDiagram.puml new file mode 100644 index 0000000000..ccabe2be01 --- /dev/null +++ b/docs/diagrams/saveDataSequenceDiagram.puml @@ -0,0 +1,37 @@ +[comment]: <> (//@@author Thunderdragon221) +@startuml +'https://plantuml.com/sequence-diagram + +@startuml +!include Style.puml +hide footbox +participant User + +User -> Storage: saveData() +activate Storage +Storage -> Information: getAllPatientData() +activate Information +Information --> Storage: patientsList +deactivate Information +Storage -> Patient: getPatient() +destroy Information +activate Patient +Patient --> Storage: patient +Storage -> Patient: getName() +Patient --> Storage: name +Storage -> Patient: getPassword() +Patient --> Storage: password +Storage -> Patient: getPatientDiagnosisHistory() +Patient --> Storage: diagnosisHistory +Storage -> Patient: getPatientMedicineHistory() +Patient --> Storage: medicineHistory +deactivate Patient +Storage -> Storage: writeMedicineHistory() +destroy Patient +activate Storage +Storage --> Storage: finished writing to file +deactivate Storage +User <-- Storage: data saved +deactivate Storage + +@enduml \ No newline at end of file diff --git a/docs/team/brennanzuz.md b/docs/team/brennanzuz.md new file mode 100644 index 0000000000..55ce1a1acd --- /dev/null +++ b/docs/team/brennanzuz.md @@ -0,0 +1,56 @@ +# Brannon Aw Xu Wei - Project Portfolio Page + +## Overview of Dr. Duke +Dr. Duke is a medical commandline interface (CLI) software designed for clinics to automate the diagnosis of patients and dispense the appropriate medicine. In short, it: +1. Mimics the registration at a polyclinic. +2. Asks for the patient's symptoms and matches them to known illnesses. +3. Outputs the most likely illnesses. +4. Prescribes medicine for the illnesses, and if the illness is severe or unknown, the patient is referred to the doctor instead. +5. Keeps record of the patient's login details, medical history and prescriptions across instances. It is written in Java and has about 5000 lines of code. + +### Summary of Contributions +* **Code contributed**: [RepoSense](https://nus-cs2113-ay2223s2.github.io/tp-dashboard/?search=brennanzuz&breakdown=true) + +* **Added features** : + + * Added symptom repository [#22](https://github.com/AY2223S2-CS2113-W13-1/tp/pull/22): + * **What it does**: Holds information of all 59 common symptoms of which includes, but is not limited to: throat irritation, headache, sleeplessness, loss of taste or smell and many more. Uses actual symptoms from common illnesses. + * **Justification**: These common symptoms will be used in higher levels in the software and allows the illnesses that commonly share them to reuse this clearly defined library. This will also be used in the main user interface and symptom history for the patient to indicate their symptoms and have them be stored. + + * Added illness repository [#22](https://github.com/AY2223S2-CS2113-W13-1/tp/pull/22): + * **What it does**: Holds information of all 39 common and non-sever classified illnesses which includes but is not limited to: common cold, coronavirus, migraine, conjunctivitis, and many more. List many actual common illnesses. + * **Justification**: Each illness contains information about their common symptoms and severity and is useful for the diagnosis process to easily identify what each illness entails. This clearly defined list of illnesses will be useful for keeping records on the patient's medical history. + + * Added the diagnosis process [#22](https://github.com/AY2223S2-CS2113-W13-1/tp/pull/22): + * **What it does**: This is an integral part of the project that deals with taking in the patient's symptoms as inputs and interpreting them into a list of possible illnesses as output. + * **Justification**: This module is essential as it is the first in the entire Dr. Duke usage sequence; it provides the list of symptoms required for medication output and for recording in the system. + +* **Improved features** + + * Symptom selection options [#73](https://github.com/AY2223S2-CS2113-W13-1/tp/pull/73): + * **What it does**: Added 15 more selectable symptoms in the main menu to allow more illnesses to be detected. Moved boilerplate code for the menu into a neater function. + * **Justification**: To solidify the software's usefulness, it needed more selectable options for the patient to treat more patients and be more applicable. + +* **User Guide improvements** + + * Added and changed few lines to clarify the reporting of symptoms [#105](https://github.com/AY2223S2-CS2113-W13-1/tp/pull/105). + +* **Developer Guide improvements**: + + * Added detailed explanation of the diagnosis process [#80](https://github.com/AY2223S2-CS2113-W13-1/tp/pull/105). + + * Added class diagram describing the various classes involved in the diagnosis process and how they interact with one another [#80](https://github.com/AY2223S2-CS2113-W13-1/tp/pull/80/files).
Diagnosis Class Diagram + + * Added sequence diagram describing diagnosis algorithm and how it works with the objects involved in the diagnosis process [#107](https://github.com/AY2223S2-CS2113-W13-1/tp/pull/107).
Diagnosis Sequence Diagram + +* **Team-based contributions**: + + * Initiated Developer Guide diagrams implementation [#79](https://github.com/AY2223S2-CS2113-W13-1/tp/pull/79). + + * Raised issue on medication crash in intermediate iteration [#74](https://github.com/AY2223S2-CS2113-W13-1/tp/issues/74). + +* Community-based contributions: + + * Reported bugs for other teams [#1](https://github.com/Brennanzuz/ped/issues/1) [#2](https://github.com/Brennanzuz/ped/issues/2) [#3](https://github.com/Brennanzuz/ped/issues/3) [#4](https://github.com/Brennanzuz/ped/issues/4) [#5](https://github.com/Brennanzuz/ped/issues/5) [#6](https://github.com/Brennanzuz/ped/issues/6) [#7](https://github.com/Brennanzuz/ped/issues/7) [#8](https://github.com/Brennanzuz/ped/issues/8). + + * Enquired on the forums [#18](https://github.com/nus-cs2113-AY2223S2/forum/issues/18) [#34](https://github.com/nus-cs2113-AY2223S2/forum/issues/34). \ No newline at end of file diff --git a/docs/team/geeeetyx.md b/docs/team/geeeetyx.md new file mode 100644 index 0000000000..893962a92d --- /dev/null +++ b/docs/team/geeeetyx.md @@ -0,0 +1,102 @@ +[comment]: <> (//@@author Geeeetyx) + +# Gareth Tan - Project Portfolio Page + +## Overview + +## Project: Dr Duke + +Dr Duke is an application used to automate diagnosing patients with mild illnesses. +The main outline of Dr Duke is as follows: + +1. It asks a patient for his/her symptoms and gives them a diagnosis of illness what the patient might have based on the + symptoms entered. +2. Dr Duke then recommends certain medications, that can be bought from a local pharmacy, that can help to cure the mild + illness the patient has. +3. If the illness is determined to be severe or not mild, Dr Duke would then recommend the patient to visit a General + Practitioner instead. + +The Dr Duke programme is designed for use via a Command Line Interface, thus for user that can type fast, Dr Duke give +you a diagnosis faster than visiting a General Practitioner. +It is written in Java 11 and has about 5 kLoC. + +Given below are my contributions to the project. + +### Summary of Contributions + +* **Code contributed**: + [Reposense Link](https://nus-cs2113-ay2223s2.github.io/tp-dashboard/?search=geeeetyx&breakdown=true) + +* **Added Features**: + * Added Patient class [#16](https://github.com/AY2223S2-CS2113-W13-1/tp/pull/16) + * **What it does** : Acts as the main object to be used throughout the Dr Duke programme. + * **Justification** : + 1. Stores the key information about the user, which are name, password, diagnosis history and medicine + history. + 2. Used in other classes in Dr Duke such as Storage and Menu + + * Added Queue system [#117](https://github.com/AY2223S2-CS2113-W13-1/tp/pull/117) + * **What it does** : A queue number system, based on how many users have logged in to the Dr Duke programme. + * **Justification** : + 1. The main purpose is to implement a basic feature that can be built upon should Dr Duke be deployed in + actual pharmacies. + 2. Simulates a queue number system, meant to be implemented in a pharmacy to manage a queue in a pharmacy, + like in a normal polyclinic. + +* **Enhancements to Existing Features**: + * Added more Over-The-Counter Medicines [#118](https://github.com/AY2223S2-CS2113-W13-1/tp/pull/118) + * **What it does** : Improves the database of medicines that Dr Duke has, to be more in line with the medicines + actually found in pharmacies. + * **Justification** : Sets the foundation for more medicines that can be found in pharmacies to be added to Dr + Duke. + + * Added checkers and output messages if patient does not enter any + symptom [#170](https://github.com/AY2223S2-CS2113-W13-1/tp/pull/170) + * **What it does** : Ensures the patient enters symptoms before Dr Duke gives a diagnosis. + * **Justification** : This was a bug found during a review found by other teams. See + Issue [#129](https://github.com/AY2223S2-CS2113-W13-1/tp/issues/129). + + * Dr Duke re-diagnoses the patient when the patient deletes previously entered + symptoms [#170](https://github.com/AY2223S2-CS2113-W13-1/tp/pull/170) + * **What it does** : Dr Duke now gives the patient a new diagnosis after the patient chooses to delete certain + symptoms that were previously chosen. + * **Justification** : To improve the flow of the programme and thus the user experience. + + * Improved UI of Dr Duke [#78](https://github.com/AY2223S2-CS2113-W13-1/tp/pull/78) + * **What it does** : Improves the design of what the user sees when using Dr Duke. + * **Justification** : For better user experience. + +* **Documentation**: + * **User Guide** : + * Laid the groundwork for the improved User Guide [#78](https://github.com/AY2223S2-CS2113-W13-1/tp/pull/78) + + * **Developer Guide** : + * Added explanation of the Patient class [#94](https://github.com/AY2223S2-CS2113-W13-1/tp/pull/94) + + * Added class diagram of the Patient class [#84] (https://github.com/AY2223S2-CS2113-W13-1/tp/pull/84) + + * Added user stories, value proposition and manual testing + instructions [#85](https://github.com/AY2223S2-CS2113-W13-1/tp/pull/85) + +* **Community**: + * Reported bugs for other teams + * [#1](https://github.com/Geeeetyx/ped/issues/1) + * [#2](https://github.com/Geeeetyx/ped/issues/2) + * [#3](https://github.com/Geeeetyx/ped/issues/3) + * [#4](https://github.com/Geeeetyx/ped/issues/4) + * [#5](https://github.com/Geeeetyx/ped/issues/5) + * [#6](https://github.com/Geeeetyx/ped/issues/6) + * [#7](https://github.com/Geeeetyx/ped/issues/7) + * [#8](https://github.com/Geeeetyx/ped/issues/8) + * [#9](https://github.com/Geeeetyx/ped/issues/9) + * [#10](https://github.com/Geeeetyx/ped/issues/10) + * [#11](https://github.com/Geeeetyx/ped/issues/11) + * [#12](https://github.com/Geeeetyx/ped/issues/12) + * [#13](https://github.com/Geeeetyx/ped/issues/13) + * [#14](https://github.com/Geeeetyx/ped/issues/14) + + * Commented on feedback received for Dr Duke v2.0 + * [#153](https://github.com/AY2223S2-CS2113-W13-1/tp/issues/153) + * [#150](https://github.com/AY2223S2-CS2113-W13-1/tp/issues/150) + * [#149](https://github.com/AY2223S2-CS2113-W13-1/tp/issues/149) + * [#136](https://github.com/AY2223S2-CS2113-W13-1/tp/issues/136) diff --git a/docs/team/jeraldchen.md b/docs/team/jeraldchen.md new file mode 100644 index 0000000000..5d40cadf01 --- /dev/null +++ b/docs/team/jeraldchen.md @@ -0,0 +1,72 @@ +[comment]: <> (//@@author Jeraldchen) +# Jerald Chen - Project Portfolio Page + +## Overview + +## Project: DrDuke + +DrDuke is a command line interface (CLI) application for managing patients' medical records. +It can generate a diagnosis based on the symptoms provided by the user and then dispense the appropriate medicine. +This application also stores the patient's medical records in a text file for future reference. +It is optimized for use via a Command Line Interface (CLI). +If you can type fast, DrDuke can get your patient management tasks done faster than traditional GUI apps. +It is written in Java 11 and has about 5 kLoC. + + +Given below are my contributions to the project. + +### Summary of Contributions + +* **New Feature**: Added the ability to reset a patient's diagnosis history. + * What it does: allows the user to reset a patient's diagnosis history. + * Justification: This feature improves the product significantly because a user can make a mistake when adding a diagnosis and + this feature allows the user to rectify the mistake. + * Highlights: This enhancement affects existing commands and commands to be added in the future. It required an in-depth analysis of + design alternatives. The implementation too was challenging as it required changes to existing commands, any changes can result in + regression of the product as components may break. + + +* **New Feature**: Added the ability to reset and delete a patient's symptom choice. + * What it does: allows the user to reset a patient's symptom choice. + * Justification: This feature improves the product significantly because a user can make a mistake when adding a symptom choice and + this feature allows the user to rectify the mistake. + * Highlights: This enhancement brings greater convenience to the patient. At the start, a wrong input being keyed in + will require the user to exit the program and login again which can be a hassle. This feature allows the user to rectify the mistake + without having to exit the program. + + +* **New Feature**: Added the ability to view symptom history. + * What it does: allows the user to view a patient's symptom history. + * Justification: The user could have forgotten what symptoms he/she had keyed in previously. This feature allows the user to view + the symptom history and add/remove any symptoms that he/she may have forgotten. + + +* **New Feature**: Link the commands to the parser to display menu options and output diagnosis and medications for the overall user interface experience. + * What it does: allows the user to interact with the program. + * Justification: This feature serves as the backbone of the program. Without this feature, the program will not be able to + interact with the user. + + +* **Code contributed**: [RepoSense link](https://nus-cs2113-ay2223s2.github.io/tp-dashboard/?search=jeraldchen&breakdown=true) + * Search 'Jeraldchen' to find my contributions. + + +* **Project Management**: + * Managed releases `v1.0` - `v2.1` (3 releases) on GitHub + + +* **Enhancements to existing features**: + * Wrote additional Junit tests to increase test coverage [#91](https://github.com/AY2223S2-CS2113-W13-1/tp/commit/201d52930f3778f2e6e9692a87d308021355ee0a) + * Implemented try-catch blocks to handle exceptions and added defensive measures to prevent program from crashing [#92](https://github.com/AY2223S2-CS2113-W13-1/tp/commit/a8092485e3d44fb52760c7b17c8d658a2e9a3a88) + + +* **Documentation**: + * User Guide: + * Added documentation for features like `resetSymptomChoice`, `viewSymptomHistory`, `deleteSymptom`, `resetDiagnosisHistory`, `addSymptomToSymptomList` and `parseSymptomInput` etc. + * Developer Guide: + * Added architecture diagram, class diagram interaction of UI and Sequence Diagram of Main Duke program. + + +* **Community**: + * Reported bugs and suggestions to other teams in the class [#22](https://github.com/nus-cs2113-AY2223S2/tp/pull/22/files#r1151403222), [#18](https://github.com/nus-cs2113-AY2223S2/tp/pull/18/files#r1151416463), [#49](https://github.com/nus-cs2113-AY2223S2/tp/pull/49/files#r1151409910) + * Engaged in discussions with other reviewers on how to improve our product [#134](https://github.com/AY2223S2-CS2113-W13-1/tp/issues/134#issuecomment-1493253614), [#140](https://github.com/AY2223S2-CS2113-W13-1/tp/issues/140) \ No newline at end of file diff --git a/docs/team/tanyizhe.md b/docs/team/tanyizhe.md new file mode 100644 index 0000000000..dadc56bdc7 --- /dev/null +++ b/docs/team/tanyizhe.md @@ -0,0 +1,63 @@ +[comment]: <> (//@@author tanyizhe) +# Tan Yi Zhe - Project Portfolio Page + + +## Overview +Dr. Duke is a Command-Line Interface application that can take in symptoms from the user +and diagnose the user with an illness. Dr. Duke is not a replacement for an actual doctor! +The main aim of Dr. Duke is to allow users who don't feel so well, but not in need +of serious medical attention, to get an idea of what illness they might have without +consulting a doctor. + +After Diagnosis, Dr. Duke will prescribe relevant medication available over-the-counter +to the user. The medication prescribed gives the user an idea of what medications +can be used to treat their current ailment. + +### Summary of Contributions +* **Code contributed**: [RepoSense](https://nus-cs2113-ay2223s2.github.io/tp-dashboard/?search=tanyizhe&breakdown=true) +* **Added features** : + * Added MedicineManager and Medicine classes [#25](https://github.com/AY2223S2-CS2113-W13-1/tp/pull/25): + * **What it does**: Acts as the link between illnesses and medicines. + * **Justification**: These classes are essential for the prescription function of the application to work. + + * Added Logic to Menu to get patient symptoms and prescribe medication [#43](https://github.com/AY2223S2-CS2113-W13-1/tp/pull/43), + [#44](https://github.com/AY2223S2-CS2113-W13-1/tp/pull/44): + * **What it does**: Takes in symptoms that user inputs, diagnose the user with an illness, + and prescribes medication to the user. + * **Justification**: The most important part of the application, links the Menu, Illness and Medicine + parts of the application together. + + * Added feature to allow user to see their Medicine History [#68](https://github.com/AY2223S2-CS2113-W13-1/tp/pull/68), + [#81](https://github.com/AY2223S2-CS2113-W13-1/tp/pull/81): + * **What it does**: Records down medicine user was prescribed along with the date of the + prescription. Records are saved in a text file with other information. + * **Justification**: It is important for the user to be able to see their medicine history. + This could potentially prevent an overdose of medication due to carelessness or neglect. + + * Added feature to list and find medicines [#102](https://github.com/AY2223S2-CS2113-W13-1/tp/pull/102): + * **What it does**: Lists all available medicines and find an available medicines using a keyword. + * **Justification**: Users need to be aware of what medicines they are consuming and + make an informed choice regarding the medicine they choose to consume. + + * Added feature to delete multiple symptoms at once [#186](https://github.com/AY2223S2-CS2113-W13-1/tp/pull/186): + * **What it does**: Program can now take in multiple numbers with a space between them, and will delete each + selected symptom. + * **Justification**: This feature is introduced after one of our tester's feedback. They wish to be able to delete + multiple symptoms at once. It is useful for veteran users of Dr. Duke. +* **Improved features** : + * Improved symptom delete feature: + * **What it does**: Users are now able to delete multiple symptoms with one command. + * **Justification**: Experienced users may want to delete multiple symptoms in one go, + rather than deleting each symptom one by one. + * Wrote additional Junit tests to increase test coverage [#172](https://github.com/AY2223S2-CS2113-W13-1/tp/pull/172) +* **Documentation**: + * User Guide: + * Added documentation for features such as List Medicines and Find Medicine. Updated User guide accordingly + whenever improvement is made. + * Updated expected output accordingly when new feature is implemented. + * Developer Guide: + * Added sequence diagram for MedicineManager class. Wrote detailed explanation regarding + how MedicineManager, Medicine, Parser, and IllnessMatch classes work and how they interact. + * Community contributions: + * Reported bugs for other teams: + * [#1](https://github.com/tanyizhe/ped/issues/1), [#2](https://github.com/tanyizhe/ped/issues/2), [#3](https://github.com/tanyizhe/ped/issues/3), [#4](https://github.com/tanyizhe/ped/issues/4), [#5](https://github.com/tanyizhe/ped/issues/5), [#6](https://github.com/tanyizhe/ped/issues/6), [#7](https://github.com/tanyizhe/ped/issues/7), [#8](https://github.com/tanyizhe/ped/issues/8), [#9](https://github.com/tanyizhe/ped/issues/9), [#10](https://github.com/tanyizhe/ped/issues/10), [#11](https://github.com/tanyizhe/ped/issues/11), [#12](https://github.com/tanyizhe/ped/issues/12), [#13](https://github.com/tanyizhe/ped/issues/13), [#14](https://github.com/tanyizhe/ped/issues/14) diff --git a/docs/team/thunderdragon221.md b/docs/team/thunderdragon221.md new file mode 100644 index 0000000000..44d0ad0530 --- /dev/null +++ b/docs/team/thunderdragon221.md @@ -0,0 +1,70 @@ +[comment]: <> (//@@author Thunderdragon221) +# Ryan Tan - Project Portfolio Page + +## Overview + +## Project: Dr Duke + +Dr Duke is a command line interface (CLI) application used to diagnose patients with mild illnesses. +Dr Duke is able to offer patients diagnoses based on their symptoms, recommend suitable medication to +purchase from pharmacies and store patients' medical records for future reference. +It is optimized for use via a Command Line Interface (CLI). +If you can type fast, Dr Duke can give you a suitable diagnosis faster than visiting a General Practitioner. +It is written in Java 11 and has about 5 kLoC. + + +Given below are my contributions to the project. + +### Summary of Contributions + +* **New Feature**: Added the ability to display the user's diagnosis history. + * What it does: allows the user to view his/her diagnosis history. + * Justification: This feature improves the product significantly because the user can view his/her past diagnoses + to see if he/she is prone to getting certain illnesses. + +* **New Feature**: Added the ability to read in user symptoms. + * What it does: allows the user to input any symptoms he/she has. + * Justification: Allows the user to input his/her symptoms into Dr Duke to get a suitable diagnosis and relevant + medication recommendations. + +* **New Feature**: Added the ability to write and read data to and from a designated text file. + * What it does: allows Dr Duke to keep track of past information entered for each user. + * Justification: Allows the user to make use of other features to view past data that Dr Duke stores. + * Highlights: This feature is immensely useful since it is the foundation that allows each user to access past + information related to him/her stored in Dr Duke, as well as any information he/she has input in the current + session. + +* **New Feature**: Added the ability to detect corruption in data files by checking validity of data fields. + * What it does: allows Dr Duke to identify any data corruption present in data files. + * Justification: Important as it prevents the program from working with corrupted data. + * Highlights: This feature is extremely useful as it prevents the user from tampering with the data fields in the + text files, and raises a CorruptedDataException once any form of corruption is detected. + + +* **Code contributed**: [RepoSense link](https://nus-cs2113-ay2223s2.github.io/tp-dashboard/?search=&sort=groupTitle&sortWithin=title&since=2023-02-17&until=2023-04-02&timeframe=commit&mergegroup=&groupSelect=groupByRepos&breakdown=false) + * Search 'Thunderdragon221' to find my contributions. + + +* **Project Management**: + * Managed releases `v1.0` - `v2.0` (2 releases) on GitHub + * Currently managing `v2.1` + + +* **Enhancements to existing features**: + * Added tracking of dates to diagnoses of the user [#173](https://github.com/AY2223S2-CS2113-W13-1/tp/commit/511392b7462fb2315695f3fc39a9132642b5bf7d) + * Implemented hashing of users' passwords as a form of security [#67](https://github.com/AY2223S2-CS2113-W13-1/tp/commit/91fd01f7a77507a48f045d5154d1eee58ae99b2f) + * Added Storage Junit test class to test code functionality of Storage class [#112](https://github.com/AY2223S2-CS2113-W13-1/tp/commit/25588b4810094e8b680926d24dde59e626a3a378) + * Implemented data file hashing to prevent program crash in the event of any intentional corruption in the data files [#164](https://github.com/AY2223S2-CS2113-W13-1/tp/commit/80a035704833f71c2aec09d3b441971445dea18e) + + +* **Documentation**: + * User Guide: + * Added documentation on how Dr Duke handles corrupted data files, as well as declaration that Dr Duke does not + violate CS2113 definitions on multi-user applications in case users mistakenly believe it to be so. + * Developer Guide: + * Added Storage class diagram and Sequence Diagrams for Loading and Saving of data of the Duke program. + + +* **Community**: + * Reported bugs and gave suggestions to another team [#32](https://github.com/nus-cs2113-AY2223S2/tp/pull/32/files/bcc9614448e1a1398ae817ead6e06652a4558e6e) + * Commented on JAR file feedback received for V2.0 [#141](https://github.com/AY2223S2-CS2113-W13-1/tp/issues/141), [#151](https://github.com/AY2223S2-CS2113-W13-1/tp/issues/151), [#156](https://github.com/AY2223S2-CS2113-W13-1/tp/issues/156) \ No newline at end of file diff --git a/dummy-data/dummy-patient-data.txt b/dummy-data/dummy-patient-data.txt new file mode 100644 index 0000000000..3c101d09a9 --- /dev/null +++ b/dummy-data/dummy-patient-data.txt @@ -0,0 +1,7 @@ +-528961164 +1 +Jerry +1 +2023/01/01%Fever% +1 +2023/01/01%Paracetamol% diff --git a/src/main/java/seedu/duke/Duke.java b/src/main/java/seedu/duke/Duke.java index 5c74e68d59..f3071da669 100644 --- a/src/main/java/seedu/duke/Duke.java +++ b/src/main/java/seedu/duke/Duke.java @@ -1,21 +1,57 @@ package seedu.duke; +import seedu.duke.save.Storage; +import seedu.duke.ui.Menu; +import seedu.duke.ui.Parser; import java.util.Scanner; public class Duke { + + public static int hash = 0; // Stores hash of user's password + /** * Main entry-point for the java.duke.Duke application. */ + //@@author JeraldChen public static void main(String[] args) { - String logo = " ____ _ \n" - + "| _ \\ _ _| | _____ \n" - + "| | | | | | | |/ / _ \\\n" - + "| |_| | |_| | < __/\n" - + "|____/ \\__,_|_|\\_\\___|\n"; - System.out.println("Hello from\n" + logo); - System.out.println("What is your name?"); + String logo = " ____ ____ _ \n" + + "| _ \\ ___ | _ \\ _ _ | | _____ \n" + + "| | | |/ _ \\ | | | | | | | |/ / _ \\\n" + + "| |_| | | | |_| | |_| | < __/\n" + + "|____/|_| |____/ \\__,_|_|\\_\\___|\n"; + System.out.println("Hello I am\n" + logo); + Storage.loadData(); + while (hash == 0) { + Menu.showWelcomeMenu(); + Scanner in = new Scanner(System.in); + String input = in.nextLine(); + Parser.parseWelcome(input); + } + while (true) { + Menu.showAccountMenu(); + Scanner in = new Scanner(System.in); + String input = in.nextLine(); + input = input.trim(); + Parser.parseAccountCommand(input); + } + } - Scanner in = new Scanner(System.in); - System.out.println("Hello " + in.nextLine()); + /** + * Sets the password. + * @author Thunderdragon221 + * + * @param userPassword password to be set. + */ + public static void setPassword(int userPassword) { + hash = userPassword; + } + + /** + * Returns the password. + * + * @return hashedPassword. + */ + public static int getPassword() { + return hash; } } diff --git a/src/main/java/seedu/duke/diagnosis/Diagnosis.java b/src/main/java/seedu/duke/diagnosis/Diagnosis.java new file mode 100644 index 0000000000..45b9ec4972 --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/Diagnosis.java @@ -0,0 +1,159 @@ +package seedu.duke.diagnosis; +//@@author Brennanzuz +import seedu.duke.diagnosis.illnesses.Illness; +import seedu.duke.diagnosis.illnesses.allergic.Asthma; +import seedu.duke.diagnosis.illnesses.allergic.GeneralAllergicReaction; +import seedu.duke.diagnosis.illnesses.bacterial.Bronchitis; +import seedu.duke.diagnosis.illnesses.bacterial.GeneralBacterialInfection; +import seedu.duke.diagnosis.illnesses.bacterial.Pneumonia; +import seedu.duke.diagnosis.illnesses.bacterial.SoreThroat; +import seedu.duke.diagnosis.illnesses.bacterial.Tuberculosis; +import seedu.duke.diagnosis.illnesses.cardiovascular.CoronaryHeartDisease; +import seedu.duke.diagnosis.illnesses.cardiovascular.Hypertension; +import seedu.duke.diagnosis.illnesses.dental.GeneralToothAche; +import seedu.duke.diagnosis.illnesses.dental.ToothDecay; +import seedu.duke.diagnosis.illnesses.dermatological.GeneralRash; +import seedu.duke.diagnosis.illnesses.dermatological.Hives; +import seedu.duke.diagnosis.illnesses.dermatological.Psoriasis; +import seedu.duke.diagnosis.illnesses.digestive.Constipation; +import seedu.duke.diagnosis.illnesses.digestive.Diarrhoea; +import seedu.duke.diagnosis.illnesses.digestive.FoodPoisoning; +import seedu.duke.diagnosis.illnesses.digestive.GeneralStomachAche; +import seedu.duke.diagnosis.illnesses.digestive.Hemorrhoids; +import seedu.duke.diagnosis.illnesses.immunological.Diabetes; +import seedu.duke.diagnosis.illnesses.immunological.GeneralFever; +import seedu.duke.diagnosis.illnesses.immunological.HumanImmunodeficiencyVirus; +import seedu.duke.diagnosis.illnesses.musculoskeletal.Arthritis; +import seedu.duke.diagnosis.illnesses.musculoskeletal.GeneralBackAche; +import seedu.duke.diagnosis.illnesses.musculoskeletal.GeneralMuscleAche; +import seedu.duke.diagnosis.illnesses.musculoskeletal.Osteoporosis; +import seedu.duke.diagnosis.illnesses.neurological.GeneralHeadAche; +import seedu.duke.diagnosis.illnesses.neurological.Migraine; +import seedu.duke.diagnosis.illnesses.physical.Fracture; +import seedu.duke.diagnosis.illnesses.physical.InternalBleeding; +import seedu.duke.diagnosis.illnesses.physical.SuperficialWound; +import seedu.duke.diagnosis.illnesses.psychological.AttentionDeficitHyperactivityDisorder; +import seedu.duke.diagnosis.illnesses.psychological.Depression; +import seedu.duke.diagnosis.illnesses.psychological.Insomnia; +import seedu.duke.diagnosis.illnesses.viral.Conjunctivitis; +import seedu.duke.diagnosis.illnesses.viral.Coronavirus; +import seedu.duke.diagnosis.illnesses.viral.Dengue; +import seedu.duke.diagnosis.illnesses.viral.GeneralCold; +import seedu.duke.diagnosis.illnesses.viral.GeneralFlu; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + +import static java.util.stream.Collectors.toCollection; +/** + * This class conducts the diagnosis by taking in the patient's symptoms and returning the most probable illnesses based + * on the percentage of overlapping symptoms the patient has with each suspected illness, and based on a predefined + * threshold. + * + * @author Brennanzuz + */ +public class Diagnosis { + private static final double POSSIBILITY_THRESHOLD = 0.5; + private static final ArrayList ALL_ILLNESSES = new ArrayList<>( + List.of( + new Asthma(), + new GeneralAllergicReaction(), + new Bronchitis(), + new GeneralBacterialInfection(), + new Pneumonia(), + new SoreThroat(), + new Tuberculosis(), + new CoronaryHeartDisease(), + new Hypertension(), + new GeneralToothAche(), + new ToothDecay(), + new GeneralRash(), + new Hives(), + new Psoriasis(), + new Constipation(), + new Diarrhoea(), + new FoodPoisoning(), + new GeneralStomachAche(), + new Hemorrhoids(), + new Diabetes(), + new GeneralFever(), + new HumanImmunodeficiencyVirus(), + new Arthritis(), + new GeneralBackAche(), + new GeneralMuscleAche(), + new Osteoporosis(), + new GeneralHeadAche(), + new Osteoporosis(), + new Migraine(), + new Fracture(), + new InternalBleeding(), + new SuperficialWound(), + new AttentionDeficitHyperactivityDisorder(), + new Depression(), + new Insomnia(), + new Conjunctivitis(), + new Coronavirus(), + new Dengue(), + new GeneralCold(), + new GeneralFlu() + ) + ); + private static Logger diagnosisLogger = Logger.getLogger("diagnosisLogger"); + + /** + * @author Brennanzuz + * @param patientSymptoms The ArrayList of Symptoms the patient has indicated to have. + * Passed from UI. + * @param illnessSymptoms The ArrayList of Symptoms the suspected Illness has. + * To be matched with that of the patient + * @return An ArrayList of Symptoms that is the intersection between the arguments, + * or simply put, the symptoms both the patient and the suspected Illness at hand has. + */ + private static ArrayList getMatchingSymptoms(ArrayList patientSymptoms, + ArrayList illnessSymptoms) { + return illnessSymptoms.stream() + .filter(patientSymptoms::contains) + .collect(toCollection(ArrayList::new)); + } + + /** + * @author Brennanzuz + * @param patientSymptoms The ArrayList of Symptoms the patient has indicated to have. Passed from UI. + * @return An ArrayList of IllnessMatch which indicates the most probable Illness and its similarity percentage. + */ + public static ArrayList getPossibleIllnesses(ArrayList patientSymptoms) { + diagnosisLogger.setLevel(Level.SEVERE); + diagnosisLogger.log(Level.INFO, "Receiving patient symptoms for diagnosis."); + ArrayList possibleIllnesses = new ArrayList<>(); + IllnessMatch illnessMatch; + for (Illness illness : ALL_ILLNESSES) { + assert illness.getSymptoms().size() > 0 : illness.getIllnessName() + " should have symptoms listed"; + illnessMatch = new IllnessMatch(illness, (double) getMatchingSymptoms(patientSymptoms, + illness.getSymptoms()).size() / illness.getSymptoms().size()); + diagnosisLogger.log(Level.INFO, "Compared patient's symptoms to those of " + + illnessMatch.getIllness().getIllnessName() + + " and found a " + illnessMatch.getSimilarityPercentage() * 100 + + "% match."); + possibleIllnesses.add(illnessMatch); + } + return possibleIllnesses.stream() + .filter(possibleIllness -> possibleIllness.getSimilarityPercentage() > POSSIBILITY_THRESHOLD) + .collect(toCollection(ArrayList::new)); + } + + //@@author Thunderdragon221 + public static boolean isValidDiagnosis(String diagnosis) { + boolean isValid = false; + + for (Illness illness : ALL_ILLNESSES) { + if (illness.getIllnessName().equals(diagnosis)) { + isValid = true; + } + } + + return isValid; + } +} diff --git a/src/main/java/seedu/duke/diagnosis/IllnessMatch.java b/src/main/java/seedu/duke/diagnosis/IllnessMatch.java new file mode 100644 index 0000000000..367e21b467 --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/IllnessMatch.java @@ -0,0 +1,24 @@ +package seedu.duke.diagnosis; + +import seedu.duke.diagnosis.illnesses.Illness; + +/** + * A class to indicate a match found between the suspected illness and the actual illness by stating the percentage + * similarity it has to the actual symptoms. + * @author Brennanzuz + */ +public class IllnessMatch { + private final Illness illness; + private final double similarityPercentage; + + public IllnessMatch(Illness illness, double similarityPercentage) { + this.illness = illness; + this.similarityPercentage = similarityPercentage; + } + public Illness getIllness() { + return illness; + } + public double getSimilarityPercentage() { + return similarityPercentage; + } +} diff --git a/src/main/java/seedu/duke/diagnosis/illnesses/Illness.java b/src/main/java/seedu/duke/diagnosis/illnesses/Illness.java new file mode 100644 index 0000000000..05f89dc776 --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/illnesses/Illness.java @@ -0,0 +1,41 @@ +//@@Brennanzuz +package seedu.duke.diagnosis.illnesses; + +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; + +/** + * A generic class to be inherited by all other illnesses. Its constructor class will be filled by predefined constants + * when inherited by other classes to match the desired illness. + * @author Brennanzuz + */ +public class Illness { + private final String illnessName; + private final int severityLevel; + private final boolean isChronic; + private final ArrayList symptoms; + + public Illness(String illnessName, int severityLevel, boolean isChronic, ArrayList symptoms) { + this.illnessName = illnessName; + this.severityLevel = severityLevel; + this.isChronic = isChronic; + this.symptoms = symptoms; + } + + public String getIllnessName() { + return illnessName; + } + + public int getSeverityLevel() { + return severityLevel; + } + + public boolean isChronic() { + return isChronic; + } + + public ArrayList getSymptoms() { + return symptoms; + } +} diff --git a/src/main/java/seedu/duke/diagnosis/illnesses/allergic/Asthma.java b/src/main/java/seedu/duke/diagnosis/illnesses/allergic/Asthma.java new file mode 100644 index 0000000000..3ff381524c --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/illnesses/allergic/Asthma.java @@ -0,0 +1,19 @@ +package seedu.duke.diagnosis.illnesses.allergic; + +import seedu.duke.diagnosis.illnesses.Illness; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; +import java.util.List; + +//@@author Brennanzuz +public class Asthma extends Illness { + public Asthma() { + super("Asthma", 3, false, new ArrayList<>( + List.of(Symptom.HYPERVENTILATION, + Symptom.HISTORY_OF_ASTHMA, + Symptom.DIFFICULTY_BREATHING + )) + ); + } +} diff --git a/src/main/java/seedu/duke/diagnosis/illnesses/allergic/GeneralAllergicReaction.java b/src/main/java/seedu/duke/diagnosis/illnesses/allergic/GeneralAllergicReaction.java new file mode 100644 index 0000000000..257eac3028 --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/illnesses/allergic/GeneralAllergicReaction.java @@ -0,0 +1,17 @@ +package seedu.duke.diagnosis.illnesses.allergic; + +import seedu.duke.diagnosis.illnesses.Illness; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; +import java.util.List; + +//@@author Brennanzuz +public class GeneralAllergicReaction extends Illness { + public GeneralAllergicReaction() { + super("General Allergic Reaction", 3, false, new ArrayList<>( + List.of(Symptom.HISTORY_OF_ALLERGIES + )) + ); + } +} diff --git a/src/main/java/seedu/duke/diagnosis/illnesses/bacterial/Bronchitis.java b/src/main/java/seedu/duke/diagnosis/illnesses/bacterial/Bronchitis.java new file mode 100644 index 0000000000..53be052802 --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/illnesses/bacterial/Bronchitis.java @@ -0,0 +1,20 @@ +package seedu.duke.diagnosis.illnesses.bacterial; + +import seedu.duke.diagnosis.illnesses.Illness; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; +import java.util.List; + +//@@author Brennanzuz +public class Bronchitis extends Illness { + public Bronchitis() { + super("Bronchitis", 2, true, new ArrayList<>( + List.of(Symptom.THROAT_IRRITATION, + Symptom.HEAD_ACHE, + Symptom.RUNNY_NOSE, + Symptom.FATIGUE + )) + ); + } +} diff --git a/src/main/java/seedu/duke/diagnosis/illnesses/bacterial/GeneralBacterialInfection.java b/src/main/java/seedu/duke/diagnosis/illnesses/bacterial/GeneralBacterialInfection.java new file mode 100644 index 0000000000..d9103d08e3 --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/illnesses/bacterial/GeneralBacterialInfection.java @@ -0,0 +1,19 @@ +package seedu.duke.diagnosis.illnesses.bacterial; + +import seedu.duke.diagnosis.illnesses.Illness; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; +import java.util.List; + +//@@author Brennanzuz +public class GeneralBacterialInfection extends Illness { + + public GeneralBacterialInfection() { + super("General Bacterial Infection", 1, false, new ArrayList<>( + List.of(Symptom.PUSS, + Symptom.GENERAL_SWELLING + )) + ); + } +} diff --git a/src/main/java/seedu/duke/diagnosis/illnesses/bacterial/Pneumonia.java b/src/main/java/seedu/duke/diagnosis/illnesses/bacterial/Pneumonia.java new file mode 100644 index 0000000000..4a6db0c4ac --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/illnesses/bacterial/Pneumonia.java @@ -0,0 +1,24 @@ +package seedu.duke.diagnosis.illnesses.bacterial; + +import seedu.duke.diagnosis.illnesses.Illness; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; +import java.util.List; + +//@@author Brennanzuz +public class Pneumonia extends Illness { + public Pneumonia() { + super("Pneumonia", 2, true, new ArrayList<>( + List.of(Symptom.CHEST_PAIN, + Symptom.COUGH_WITH_PHLEGM, + Symptom.CHILLS, + Symptom.FEVER, + Symptom.FATIGUE, + Symptom.BREATHLESSNESS, + Symptom.NAUSEA, + Symptom.SNIFFING + )) + ); + } +} diff --git a/src/main/java/seedu/duke/diagnosis/illnesses/bacterial/SoreThroat.java b/src/main/java/seedu/duke/diagnosis/illnesses/bacterial/SoreThroat.java new file mode 100644 index 0000000000..c5883c46ba --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/illnesses/bacterial/SoreThroat.java @@ -0,0 +1,21 @@ +package seedu.duke.diagnosis.illnesses.bacterial; + +import seedu.duke.diagnosis.illnesses.Illness; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Brennanzuz + */ +public class SoreThroat extends Illness { + public SoreThroat() { + super("Sore Throat", 1, true, new ArrayList<>( + List.of(Symptom.THROAT_IRRITATION, + Symptom.COUGH_WITH_PHLEGM, + Symptom.DRY_COUGH + )) + ); + } +} diff --git a/src/main/java/seedu/duke/diagnosis/illnesses/bacterial/Tuberculosis.java b/src/main/java/seedu/duke/diagnosis/illnesses/bacterial/Tuberculosis.java new file mode 100644 index 0000000000..8a8f458931 --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/illnesses/bacterial/Tuberculosis.java @@ -0,0 +1,20 @@ +package seedu.duke.diagnosis.illnesses.bacterial; + +import seedu.duke.diagnosis.illnesses.Illness; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; +import java.util.List; + +//@@author Brennanzuz +public class Tuberculosis extends Illness { + public Tuberculosis() { + super("Tuberculosis", 3, true, new ArrayList<>( + List.of(Symptom.DRY_COUGH, + Symptom.COUGH_WITH_PHLEGM, + Symptom.BLEEDING_WHEN_COUGHING, + Symptom.CHEST_PAIN + )) + ); + } +} diff --git a/src/main/java/seedu/duke/diagnosis/illnesses/cardiovascular/CoronaryHeartDisease.java b/src/main/java/seedu/duke/diagnosis/illnesses/cardiovascular/CoronaryHeartDisease.java new file mode 100644 index 0000000000..cc84eddaeb --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/illnesses/cardiovascular/CoronaryHeartDisease.java @@ -0,0 +1,21 @@ +package seedu.duke.diagnosis.illnesses.cardiovascular; + +import seedu.duke.diagnosis.illnesses.Illness; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; +import java.util.List; + +//@@author Brennanzuz +public class CoronaryHeartDisease extends Illness { + public CoronaryHeartDisease() { + super("Coronary Heart Disease", 3, true, new ArrayList<>( + List.of(Symptom.HIGH_HEART_RATE, + Symptom.CHEST_PAIN, + Symptom.BREATHLESSNESS, + Symptom.NAUSEA, + Symptom.CHILLS + )) + ); + } +} diff --git a/src/main/java/seedu/duke/diagnosis/illnesses/cardiovascular/Hypertension.java b/src/main/java/seedu/duke/diagnosis/illnesses/cardiovascular/Hypertension.java new file mode 100644 index 0000000000..747d53d341 --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/illnesses/cardiovascular/Hypertension.java @@ -0,0 +1,21 @@ +package seedu.duke.diagnosis.illnesses.cardiovascular; + +import seedu.duke.diagnosis.illnesses.Illness; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; +import java.util.List; + +//@@author Brennanzuz +public class Hypertension extends Illness { + public Hypertension() { + super("Hypertension (High Blood Pressure)", 3, true, new ArrayList<>( + List.of(Symptom.HIGH_HEART_RATE, + Symptom.HEAD_ACHE, + Symptom.BLURRED_VISION, + Symptom.SENSITIVITY_TO_LIGHT_AND_SOUND, + Symptom.FEVER + )) + ); + } +} diff --git a/src/main/java/seedu/duke/diagnosis/illnesses/dental/GeneralToothAche.java b/src/main/java/seedu/duke/diagnosis/illnesses/dental/GeneralToothAche.java new file mode 100644 index 0000000000..4755b4e073 --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/illnesses/dental/GeneralToothAche.java @@ -0,0 +1,17 @@ +package seedu.duke.diagnosis.illnesses.dental; + +import seedu.duke.diagnosis.illnesses.Illness; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; +import java.util.List; + +//@@author Brennanzuz +public class GeneralToothAche extends Illness { + public GeneralToothAche() { + super("Tooth Ache", 1, true, new ArrayList<>( + List.of(Symptom.TOOTH_ACHE + )) + ); + } +} diff --git a/src/main/java/seedu/duke/diagnosis/illnesses/dental/ToothDecay.java b/src/main/java/seedu/duke/diagnosis/illnesses/dental/ToothDecay.java new file mode 100644 index 0000000000..ff2b162aeb --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/illnesses/dental/ToothDecay.java @@ -0,0 +1,18 @@ +package seedu.duke.diagnosis.illnesses.dental; + +import seedu.duke.diagnosis.illnesses.Illness; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; +import java.util.List; + +//@@author Brennanzuz +public class ToothDecay extends Illness { + public ToothDecay() { + super("Tooth Decay", 2, true, new ArrayList<>( + List.of(Symptom.BLACK_TEETH, + Symptom.TOOTH_ACHE + )) + ); + } +} diff --git a/src/main/java/seedu/duke/diagnosis/illnesses/dermatological/GeneralRash.java b/src/main/java/seedu/duke/diagnosis/illnesses/dermatological/GeneralRash.java new file mode 100644 index 0000000000..4ca650dfea --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/illnesses/dermatological/GeneralRash.java @@ -0,0 +1,18 @@ +package seedu.duke.diagnosis.illnesses.dermatological; + +import seedu.duke.diagnosis.illnesses.Illness; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; +import java.util.List; + +//@@author Brennanzuz +public class GeneralRash extends Illness { + public GeneralRash() { + super("Rashes", 1, false, new ArrayList<>( + List.of(Symptom.ITCHY_SKIN, + Symptom.RED_SKIN + )) + ); + } +} diff --git a/src/main/java/seedu/duke/diagnosis/illnesses/dermatological/Hives.java b/src/main/java/seedu/duke/diagnosis/illnesses/dermatological/Hives.java new file mode 100644 index 0000000000..75bcd540ef --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/illnesses/dermatological/Hives.java @@ -0,0 +1,19 @@ +package seedu.duke.diagnosis.illnesses.dermatological; + +import seedu.duke.diagnosis.illnesses.Illness; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; +import java.util.List; + +//@@author Brennanzuz +public class Hives extends Illness { + public Hives() { + super("Hives", 2, false, new ArrayList<>( + List.of(Symptom.RED_SKIN, + Symptom.ITCHY_SKIN, + Symptom.SWELLING_SKIN + )) + ); + } +} diff --git a/src/main/java/seedu/duke/diagnosis/illnesses/dermatological/Psoriasis.java b/src/main/java/seedu/duke/diagnosis/illnesses/dermatological/Psoriasis.java new file mode 100644 index 0000000000..1b97fd3c0c --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/illnesses/dermatological/Psoriasis.java @@ -0,0 +1,20 @@ +package seedu.duke.diagnosis.illnesses.dermatological; + +import seedu.duke.diagnosis.illnesses.Illness; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; +import java.util.List; + +//@@author Brennanzuz +public class Psoriasis extends Illness { + + public Psoriasis() { + super("Psoriasis", 1, true, new ArrayList<>( + List.of(Symptom.ITCHY_SKIN, + Symptom.DRY_SCALING_SKIN, + Symptom.RED_SKIN + )) + ); + } +} diff --git a/src/main/java/seedu/duke/diagnosis/illnesses/digestive/Constipation.java b/src/main/java/seedu/duke/diagnosis/illnesses/digestive/Constipation.java new file mode 100644 index 0000000000..031297a5a4 --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/illnesses/digestive/Constipation.java @@ -0,0 +1,18 @@ +package seedu.duke.diagnosis.illnesses.digestive; + +import seedu.duke.diagnosis.illnesses.Illness; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; +import java.util.List; + +//@@author Brennanzuz +public class Constipation extends Illness { + + public Constipation() { + super("Constipation", 1, true, new ArrayList<>( + List.of(Symptom.HARD_LUMPY_STOOL + )) + ); + } +} diff --git a/src/main/java/seedu/duke/diagnosis/illnesses/digestive/Diarrhoea.java b/src/main/java/seedu/duke/diagnosis/illnesses/digestive/Diarrhoea.java new file mode 100644 index 0000000000..9418f222a1 --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/illnesses/digestive/Diarrhoea.java @@ -0,0 +1,19 @@ +package seedu.duke.diagnosis.illnesses.digestive; + +import seedu.duke.diagnosis.illnesses.Illness; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; +import java.util.List; + +//@@author Brennanzuz +public class Diarrhoea extends Illness { + public Diarrhoea() { + super("Diarrhoea", 2, false, new ArrayList<>( + List.of(Symptom.WET_STOOL, + Symptom.STOMACH_ACHE, + Symptom.DIARRHOEA + )) + ); + } +} diff --git a/src/main/java/seedu/duke/diagnosis/illnesses/digestive/FoodPoisoning.java b/src/main/java/seedu/duke/diagnosis/illnesses/digestive/FoodPoisoning.java new file mode 100644 index 0000000000..e2c82c0ef4 --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/illnesses/digestive/FoodPoisoning.java @@ -0,0 +1,21 @@ +package seedu.duke.diagnosis.illnesses.digestive; + +import seedu.duke.diagnosis.illnesses.Illness; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; +import java.util.List; + +//@@author Brennanzuz +public class FoodPoisoning extends Illness { + public FoodPoisoning() { + super("Food Poisoning", 3, false, new ArrayList<>( + List.of(Symptom.DIARRHOEA, + Symptom.STOMACH_ACHE, + Symptom.NAUSEA, + Symptom.VOMITING, + Symptom.FEVER + )) + ); + } +} diff --git a/src/main/java/seedu/duke/diagnosis/illnesses/digestive/GeneralStomachAche.java b/src/main/java/seedu/duke/diagnosis/illnesses/digestive/GeneralStomachAche.java new file mode 100644 index 0000000000..16b570c12d --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/illnesses/digestive/GeneralStomachAche.java @@ -0,0 +1,17 @@ +package seedu.duke.diagnosis.illnesses.digestive; + +import seedu.duke.diagnosis.illnesses.Illness; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; +import java.util.List; + +//@@author Brennanzuz +public class GeneralStomachAche extends Illness { + public GeneralStomachAche() { + super("Stomach Ache", 1, false, new ArrayList<>( + List.of(Symptom.STOMACH_ACHE + )) + ); + } +} diff --git a/src/main/java/seedu/duke/diagnosis/illnesses/digestive/Hemorrhoids.java b/src/main/java/seedu/duke/diagnosis/illnesses/digestive/Hemorrhoids.java new file mode 100644 index 0000000000..73c2fb717d --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/illnesses/digestive/Hemorrhoids.java @@ -0,0 +1,17 @@ +package seedu.duke.diagnosis.illnesses.digestive; + +import seedu.duke.diagnosis.illnesses.Illness; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; +import java.util.List; + +//@@author Brennanzuz +public class Hemorrhoids extends Illness { + public Hemorrhoids() { + super("Hemorrhoids", 2, true, new ArrayList<>( + List.of(Symptom.BLOODIED_STOOLS + )) + ); + } +} diff --git a/src/main/java/seedu/duke/diagnosis/illnesses/immunological/Diabetes.java b/src/main/java/seedu/duke/diagnosis/illnesses/immunological/Diabetes.java new file mode 100644 index 0000000000..b23579b029 --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/illnesses/immunological/Diabetes.java @@ -0,0 +1,22 @@ +package seedu.duke.diagnosis.illnesses.immunological; + +import seedu.duke.diagnosis.illnesses.Illness; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; +import java.util.List; + +//@@author Brennanzuz +public class Diabetes extends Illness { + public Diabetes() { + super("Diabetes", 3, true, new ArrayList<>( + List.of(Symptom.THIRST, + Symptom.FATIGUE, + Symptom.SLOW_REGENERATION, + Symptom.BLURRED_VISION, + Symptom.FREQUENT_URINATION, + Symptom.WEIGHT_LOSS + )) + ); + } +} diff --git a/src/main/java/seedu/duke/diagnosis/illnesses/immunological/GeneralFever.java b/src/main/java/seedu/duke/diagnosis/illnesses/immunological/GeneralFever.java new file mode 100644 index 0000000000..fa57af2302 --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/illnesses/immunological/GeneralFever.java @@ -0,0 +1,17 @@ +package seedu.duke.diagnosis.illnesses.immunological; + +import seedu.duke.diagnosis.illnesses.Illness; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; +import java.util.List; + +//@@author Brennanzuz +public class GeneralFever extends Illness { + public GeneralFever() { + super("Fever", 2, false, new ArrayList<>( + List.of(Symptom.FEVER + )) + ); + } +} diff --git a/src/main/java/seedu/duke/diagnosis/illnesses/immunological/HumanImmunodeficiencyVirus.java b/src/main/java/seedu/duke/diagnosis/illnesses/immunological/HumanImmunodeficiencyVirus.java new file mode 100644 index 0000000000..d7242560b5 --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/illnesses/immunological/HumanImmunodeficiencyVirus.java @@ -0,0 +1,24 @@ +package seedu.duke.diagnosis.illnesses.immunological; + +import seedu.duke.diagnosis.illnesses.Illness; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; +import java.util.List; + +//@@author Brennanzuz +public class HumanImmunodeficiencyVirus extends Illness { + public HumanImmunodeficiencyVirus() { + super("Human Immunodeficiency Virus (HIV)", 3, true, new ArrayList<>( + List.of(Symptom.CHILLS, + Symptom.FATIGUE, + Symptom.FEVER, + Symptom.THROAT_IRRITATION, + Symptom.SWOLLEN_LYMPH_NODES, + Symptom.ITCHY_SKIN, + Symptom.MUSCLE_ACHE, + Symptom.SUSCEPTIBILITY_TO_ILLNESS + )) + ); + } +} diff --git a/src/main/java/seedu/duke/diagnosis/illnesses/musculoskeletal/Arthritis.java b/src/main/java/seedu/duke/diagnosis/illnesses/musculoskeletal/Arthritis.java new file mode 100644 index 0000000000..ec1ab22935 --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/illnesses/musculoskeletal/Arthritis.java @@ -0,0 +1,18 @@ +package seedu.duke.diagnosis.illnesses.musculoskeletal; + +import seedu.duke.diagnosis.illnesses.Illness; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; +import java.util.List; + +//@@author Brennanzuz +public class Arthritis extends Illness { + public Arthritis() { + super("General Arthritis", 1, true, new ArrayList<>( + List.of(Symptom.JOINT_PAIN, + Symptom.SWOLLEN_JOINTS + )) + ); + } +} diff --git a/src/main/java/seedu/duke/diagnosis/illnesses/musculoskeletal/GeneralBackAche.java b/src/main/java/seedu/duke/diagnosis/illnesses/musculoskeletal/GeneralBackAche.java new file mode 100644 index 0000000000..dbae20fc0d --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/illnesses/musculoskeletal/GeneralBackAche.java @@ -0,0 +1,17 @@ +package seedu.duke.diagnosis.illnesses.musculoskeletal; + +import seedu.duke.diagnosis.illnesses.Illness; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; +import java.util.List; + +//@@author Brennanzuz +public class GeneralBackAche extends Illness { + public GeneralBackAche() { + super("Back Ache", 1, false, new ArrayList<>( + List.of(Symptom.BACK_ACHE + )) + ); + } +} diff --git a/src/main/java/seedu/duke/diagnosis/illnesses/musculoskeletal/GeneralMuscleAche.java b/src/main/java/seedu/duke/diagnosis/illnesses/musculoskeletal/GeneralMuscleAche.java new file mode 100644 index 0000000000..b2dba356f8 --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/illnesses/musculoskeletal/GeneralMuscleAche.java @@ -0,0 +1,17 @@ +package seedu.duke.diagnosis.illnesses.musculoskeletal; + +import seedu.duke.diagnosis.illnesses.Illness; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; +import java.util.List; + +//@@author Brennanzuz +public class GeneralMuscleAche extends Illness { + public GeneralMuscleAche() { + super("Muscle Ache", 1, false, new ArrayList<>( + List.of(Symptom.MUSCLE_ACHE + )) + ); + } +} diff --git a/src/main/java/seedu/duke/diagnosis/illnesses/musculoskeletal/Osteoporosis.java b/src/main/java/seedu/duke/diagnosis/illnesses/musculoskeletal/Osteoporosis.java new file mode 100644 index 0000000000..58a0b32f78 --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/illnesses/musculoskeletal/Osteoporosis.java @@ -0,0 +1,20 @@ +package seedu.duke.diagnosis.illnesses.musculoskeletal; + +import seedu.duke.diagnosis.illnesses.Illness; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; +import java.util.List; + +//@@author Brennanzuz +public class Osteoporosis extends Illness { + + public Osteoporosis() { + super("Osteoporosis", 2, true, new ArrayList<>( + List.of(Symptom.JOINT_PAIN, + Symptom.FRACTURE, + Symptom.HISTORY_OF_OSTEOPOROSIS + )) + ); + } +} diff --git a/src/main/java/seedu/duke/diagnosis/illnesses/neurological/GeneralHeadAche.java b/src/main/java/seedu/duke/diagnosis/illnesses/neurological/GeneralHeadAche.java new file mode 100644 index 0000000000..cc4e140bef --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/illnesses/neurological/GeneralHeadAche.java @@ -0,0 +1,17 @@ +package seedu.duke.diagnosis.illnesses.neurological; + +import seedu.duke.diagnosis.illnesses.Illness; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; +import java.util.List; + +//@@author Brennanzuz +public class GeneralHeadAche extends Illness { + public GeneralHeadAche() { + super("Headache", 1, false, new ArrayList<>( + List.of(Symptom.HEAD_ACHE + )) + ); + } +} diff --git a/src/main/java/seedu/duke/diagnosis/illnesses/neurological/Migraine.java b/src/main/java/seedu/duke/diagnosis/illnesses/neurological/Migraine.java new file mode 100644 index 0000000000..b3fbd93e39 --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/illnesses/neurological/Migraine.java @@ -0,0 +1,21 @@ +package seedu.duke.diagnosis.illnesses.neurological; + +import seedu.duke.diagnosis.illnesses.Illness; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; +import java.util.List; + +//@@author Brennanzuz +public class Migraine extends Illness { + public Migraine() { + super("Migraine", 3, true, new ArrayList<>( + List.of(Symptom.BLURRED_VISION, + Symptom.FATIGUE, + Symptom.SENSITIVITY_TO_LIGHT_AND_SOUND, + Symptom.HEAD_ACHE, + Symptom.NAUSEA + )) + ); + } +} diff --git a/src/main/java/seedu/duke/diagnosis/illnesses/physical/Fracture.java b/src/main/java/seedu/duke/diagnosis/illnesses/physical/Fracture.java new file mode 100644 index 0000000000..846632469e --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/illnesses/physical/Fracture.java @@ -0,0 +1,18 @@ +package seedu.duke.diagnosis.illnesses.physical; + +import seedu.duke.diagnosis.illnesses.Illness; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; +import java.util.List; + +//@@author Brennanzuz +public class Fracture extends Illness { + public Fracture() { + super("Fracture", 2, false, new ArrayList<>( + List.of(Symptom.JOINT_PAIN, + Symptom.FRACTURE + )) + ); + } +} diff --git a/src/main/java/seedu/duke/diagnosis/illnesses/physical/InternalBleeding.java b/src/main/java/seedu/duke/diagnosis/illnesses/physical/InternalBleeding.java new file mode 100644 index 0000000000..47aa9393fb --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/illnesses/physical/InternalBleeding.java @@ -0,0 +1,22 @@ +package seedu.duke.diagnosis.illnesses.physical; + +import seedu.duke.diagnosis.illnesses.Illness; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; +import java.util.List; + +//@@author Brennanzuz +public class InternalBleeding extends Illness { + public InternalBleeding() { + super("Internal Bleeding", 3, false, new ArrayList<>( + List.of(Symptom.GENERAL_PAIN, + Symptom.GENERAL_SWELLING, + Symptom.PALENESS_OF_SKIN, + Symptom.THIRST, + Symptom.BREATHLESSNESS, + Symptom.NAUSEA + )) + ); + } +} diff --git a/src/main/java/seedu/duke/diagnosis/illnesses/physical/SuperficialWound.java b/src/main/java/seedu/duke/diagnosis/illnesses/physical/SuperficialWound.java new file mode 100644 index 0000000000..0255a8d87e --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/illnesses/physical/SuperficialWound.java @@ -0,0 +1,20 @@ +package seedu.duke.diagnosis.illnesses.physical; + +import seedu.duke.diagnosis.illnesses.Illness; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; +import java.util.List; + +//@@author Brennanzuz +public class SuperficialWound extends Illness { + + public SuperficialWound() { + super("Superficial Wound", 1, false, new ArrayList<>( + List.of(Symptom.WOUND_OR_CUT, + Symptom.BLEEDING, + Symptom.PUSS + )) + ); + } +} diff --git a/src/main/java/seedu/duke/diagnosis/illnesses/psychological/AttentionDeficitHyperactivityDisorder.java b/src/main/java/seedu/duke/diagnosis/illnesses/psychological/AttentionDeficitHyperactivityDisorder.java new file mode 100644 index 0000000000..26192cc4a4 --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/illnesses/psychological/AttentionDeficitHyperactivityDisorder.java @@ -0,0 +1,17 @@ +package seedu.duke.diagnosis.illnesses.psychological; + +import seedu.duke.diagnosis.illnesses.Illness; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; +import java.util.List; + +//@@author Brennanzuz +public class AttentionDeficitHyperactivityDisorder extends Illness { + public AttentionDeficitHyperactivityDisorder() { + super("Attention Deficit Hyperactivity Disorder (ADHD)", 1, true, new ArrayList<>( + List.of(Symptom.HISTORY_OF_ADHD + )) + ); + } +} diff --git a/src/main/java/seedu/duke/diagnosis/illnesses/psychological/Depression.java b/src/main/java/seedu/duke/diagnosis/illnesses/psychological/Depression.java new file mode 100644 index 0000000000..2e772157a9 --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/illnesses/psychological/Depression.java @@ -0,0 +1,17 @@ +package seedu.duke.diagnosis.illnesses.psychological; + +import seedu.duke.diagnosis.illnesses.Illness; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; +import java.util.List; + +//@@author Brennanzuz +public class Depression extends Illness { + public Depression() { + super("Depression", 2, true, new ArrayList<>( + List.of(Symptom.HISTORY_OF_DEPRESSION + )) + ); + } +} diff --git a/src/main/java/seedu/duke/diagnosis/illnesses/psychological/Insomnia.java b/src/main/java/seedu/duke/diagnosis/illnesses/psychological/Insomnia.java new file mode 100644 index 0000000000..e31374c74e --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/illnesses/psychological/Insomnia.java @@ -0,0 +1,17 @@ +package seedu.duke.diagnosis.illnesses.psychological; + +import seedu.duke.diagnosis.illnesses.Illness; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; +import java.util.List; + +//@@author Brennanzuz +public class Insomnia extends Illness { + public Insomnia() { + super("Insomnia", 1, false, new ArrayList<>( + List.of(Symptom.SLEEPLESSNESS + )) + ); + } +} diff --git a/src/main/java/seedu/duke/diagnosis/illnesses/viral/Conjunctivitis.java b/src/main/java/seedu/duke/diagnosis/illnesses/viral/Conjunctivitis.java new file mode 100644 index 0000000000..f6eaeb2299 --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/illnesses/viral/Conjunctivitis.java @@ -0,0 +1,18 @@ +package seedu.duke.diagnosis.illnesses.viral; + +import seedu.duke.diagnosis.illnesses.Illness; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; +import java.util.List; + +//@@author Brennanzuz +public class Conjunctivitis extends Illness { + public Conjunctivitis() { + super("Conjunctivitis", 2, false, new ArrayList<>( + List.of(Symptom.ITCHY_EYE, + Symptom.RED_EYES + )) + ); + } +} diff --git a/src/main/java/seedu/duke/diagnosis/illnesses/viral/Coronavirus.java b/src/main/java/seedu/duke/diagnosis/illnesses/viral/Coronavirus.java new file mode 100644 index 0000000000..b9adf42422 --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/illnesses/viral/Coronavirus.java @@ -0,0 +1,21 @@ +package seedu.duke.diagnosis.illnesses.viral; + +import seedu.duke.diagnosis.illnesses.Illness; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; +import java.util.List; + +//@@author Brennanzuz +public class Coronavirus extends Illness { + public Coronavirus() { + super("COVID-19", 3, false, new ArrayList<>( + List.of(Symptom.FEVER, + Symptom.CHILLS, + Symptom.LOSS_OF_TASTE_OR_SMELL, + Symptom.THROAT_IRRITATION, + Symptom.SNEEZING + )) + ); + } +} diff --git a/src/main/java/seedu/duke/diagnosis/illnesses/viral/Dengue.java b/src/main/java/seedu/duke/diagnosis/illnesses/viral/Dengue.java new file mode 100644 index 0000000000..1a9ae9dd09 --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/illnesses/viral/Dengue.java @@ -0,0 +1,21 @@ +package seedu.duke.diagnosis.illnesses.viral; + +import seedu.duke.diagnosis.illnesses.Illness; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; +import java.util.List; + +//@@author Brennanzuz +public class Dengue extends Illness { + public Dengue() { + super("Dengue Fever", 3, false, new ArrayList<>( + List.of(Symptom.FEVER, + Symptom.CHILLS, + Symptom.GENERAL_PAIN, + Symptom.HEAD_ACHE, + Symptom.VOMITING + )) + ); + } +} diff --git a/src/main/java/seedu/duke/diagnosis/illnesses/viral/GeneralCold.java b/src/main/java/seedu/duke/diagnosis/illnesses/viral/GeneralCold.java new file mode 100644 index 0000000000..d95419747e --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/illnesses/viral/GeneralCold.java @@ -0,0 +1,23 @@ +package seedu.duke.diagnosis.illnesses.viral; + +import seedu.duke.diagnosis.illnesses.Illness; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; +import java.util.List; + +//@@author Brennanzuz +public class GeneralCold extends Illness { + + public GeneralCold() { + super("General Cold", 2, true, new ArrayList<>( + List.of(Symptom.FATIGUE, + Symptom.RUNNY_NOSE, + Symptom.SNEEZING, + Symptom.CHILLS, + Symptom.FATIGUE, + Symptom.THROAT_IRRITATION + )) + ); + } +} diff --git a/src/main/java/seedu/duke/diagnosis/illnesses/viral/GeneralFlu.java b/src/main/java/seedu/duke/diagnosis/illnesses/viral/GeneralFlu.java new file mode 100644 index 0000000000..e24169197e --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/illnesses/viral/GeneralFlu.java @@ -0,0 +1,19 @@ +package seedu.duke.diagnosis.illnesses.viral; + +import seedu.duke.diagnosis.illnesses.Illness; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; +import java.util.List; + +//@@author Brennanzuz +public class GeneralFlu extends Illness { + public GeneralFlu() { + super("General Flu", 2, false, new ArrayList<>( + List.of(Symptom.SNEEZING, + Symptom.FATIGUE, + Symptom.CHILLS + )) + ); + } +} diff --git a/src/main/java/seedu/duke/diagnosis/symptoms/Symptom.java b/src/main/java/seedu/duke/diagnosis/symptoms/Symptom.java new file mode 100644 index 0000000000..039aef94e3 --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/symptoms/Symptom.java @@ -0,0 +1,67 @@ +package seedu.duke.diagnosis.symptoms; + +/** + * An enumeration of all illnesses that can be identified by Dr. Duke. + * @author Brennanzuz` + */ +public enum Symptom { + DIFFICULTY_BREATHING, + HISTORY_OF_ASTHMA, + HYPERVENTILATION, + HISTORY_OF_ALLERGIES, + RUNNY_NOSE, + FATIGUE, + SNIFFING, + THROAT_IRRITATION, + DRY_COUGH, + COUGH_WITH_PHLEGM, + BLEEDING_WHEN_COUGHING, + CHEST_PAIN, + HEAD_ACHE, + HIGH_HEART_RATE, + TOOTH_ACHE, + BLACK_TEETH, + RED_SKIN, + ITCHY_SKIN, + SWELLING_SKIN, + DRY_SCALING_SKIN, + HARD_LUMPY_STOOL, + WET_STOOL, + DIARRHOEA, + STOMACH_ACHE, + NAUSEA, + VOMITING, + BLOODIED_STOOLS, + WEIGHT_LOSS, + FREQUENT_URINATION, + SLOW_REGENERATION, + FEVER, + SUSCEPTIBILITY_TO_ILLNESS, + CHILLS, + BLOCKED_NOSE, + SWOLLEN_LYMPH_NODES, + SWOLLEN_JOINTS, + MUSCLE_ACHE, + BACK_ACHE, + JOINT_PAIN, + HISTORY_OF_OSTEOPOROSIS, + BLURRED_VISION, + SENSITIVITY_TO_LIGHT_AND_SOUND, + SPRAIN, + SLEEPLESSNESS, + FRACTURE, + BREATHLESSNESS, + GENERAL_SWELLING, + GENERAL_PAIN, + PALENESS_OF_SKIN, + THIRST, + WOUND_OR_CUT, + BLEEDING, + PUSS, + HISTORY_OF_ADHD, + HISTORY_OF_DEPRESSION, + LOSS_OF_TASTE_OR_SMELL, + ITCHY_EYE, + RED_EYES, + SNEEZING +} diff --git a/src/main/java/seedu/duke/diagnosis/symptoms/SymptomHandler.java b/src/main/java/seedu/duke/diagnosis/symptoms/SymptomHandler.java new file mode 100644 index 0000000000..6923d6ce9f --- /dev/null +++ b/src/main/java/seedu/duke/diagnosis/symptoms/SymptomHandler.java @@ -0,0 +1,153 @@ +package seedu.duke.diagnosis.symptoms; + +import java.util.ArrayList; + +/** + * A tool to format symptoms. + * + * @author Brennanzuz + */ +public class SymptomHandler { + + /** + * @author Brennanzuz + * @param symptom ArrayList of symptoms + * @return the name of the symptom in a readable format without capitalisation and underlines. + */ + public static String toString(Symptom symptom) { + switch (symptom) { + case DIFFICULTY_BREATHING: + return "difficulty breathing"; + case HISTORY_OF_ASTHMA: + return "history of asthma"; + case HYPERVENTILATION: + return "hyperventilation"; + case HISTORY_OF_ALLERGIES: + return "history of allergies"; + case RUNNY_NOSE: + return "runny nose"; + case FATIGUE: + return "fatigue"; + case SNIFFING: + return "sniffing"; + case THROAT_IRRITATION: + return "throat irritation"; + case DRY_COUGH: + return "dry cough"; + case COUGH_WITH_PHLEGM: + return "cough with phlegm"; + case BLEEDING_WHEN_COUGHING: + return "coughing blood"; + case CHEST_PAIN: + return "chest pain"; + case HEAD_ACHE: + return "headache"; + case HIGH_HEART_RATE: + return "high heart rate"; + case TOOTH_ACHE: + return "toothache"; + case BLACK_TEETH: + return "blackened teeth"; + case RED_SKIN: + return "reddened skin"; + case ITCHY_SKIN: + return "itchy skin"; + case SWELLING_SKIN: + return "swelling skin"; + case DRY_SCALING_SKIN: + return "dry and scaling skin"; + case HARD_LUMPY_STOOL: + return "hard and lumpy stools"; + case WET_STOOL: + return "wet stools"; + case DIARRHOEA: + return "diarrhoea"; + case STOMACH_ACHE: + return "stomachache"; + case NAUSEA: + return "nausea"; + case VOMITING: + return "vomiting"; + case BLOODIED_STOOLS: + return "bloodied stools"; + case WEIGHT_LOSS: + return "weight loss"; + case FREQUENT_URINATION: + return "frequent urination"; + case SLOW_REGENERATION: + return "slow healing wounds"; + case FEVER: + return "fever"; + case SUSCEPTIBILITY_TO_ILLNESS: + return "susceptibility to other illnesses"; + case CHILLS: + return "chills"; + case BLOCKED_NOSE: + return "blocked nose"; + case SWOLLEN_LYMPH_NODES: + return "swollen lymph nodes"; + case SWOLLEN_JOINTS: + return "swollen joints"; + case MUSCLE_ACHE: + return "muscle ache"; + case BACK_ACHE: + return "backache"; + case JOINT_PAIN: + return "joint pain"; + case HISTORY_OF_OSTEOPOROSIS: + return "history of osteoporosis"; + case BLURRED_VISION: + return "blurred vision"; + case SENSITIVITY_TO_LIGHT_AND_SOUND: + return "sensitivity to light and sound"; + case SPRAIN: + return "sprain"; + case SLEEPLESSNESS: + return "lack of sleep"; + case FRACTURE: + return "fracture"; + case BREATHLESSNESS: + return "short of breath"; + case GENERAL_SWELLING: + return "unspecified swelling"; + case GENERAL_PAIN: + return "unspecified pain"; + case PALENESS_OF_SKIN: + return "pale skin"; + case THIRST: + return "persistent thirst"; + case WOUND_OR_CUT: + return "external wound or cut"; + case BLEEDING: + return "unspecified bleeding"; + case PUSS: + return "secretion of puss"; + case HISTORY_OF_ADHD: + return "history of ADHD"; + case HISTORY_OF_DEPRESSION: + return "history of depression"; + case LOSS_OF_TASTE_OR_SMELL: + return "loss of taste or smell"; + case ITCHY_EYE: + return "itchy eyes"; + case RED_EYES: + return "reddened eyes"; + case SNEEZING: + return "persistent sneezing"; + default: + return String.valueOf(symptom).toLowerCase().replace('_', ' '); + } + } + + /** + * Prints all symptoms in an array in a readable format. + * + * @author Brennanzuz + * @param symptoms ArrayList of symptoms. + */ + public static void printSymptoms(ArrayList symptoms) { + for (Symptom symptom : symptoms) { + System.out.println(toString(symptom)); + } + } +} diff --git a/src/main/java/seedu/duke/medicine/Medicine.java b/src/main/java/seedu/duke/medicine/Medicine.java new file mode 100644 index 0000000000..7df28634fc --- /dev/null +++ b/src/main/java/seedu/duke/medicine/Medicine.java @@ -0,0 +1,35 @@ +package seedu.duke.medicine; +//@@author tanyizhe +public class Medicine { + private String name; + private String dosage; + + //@@author Geeeetyx + private String medicineDescription; + //@@author tanyizhe + + public Medicine(String name, String dosage, String medicineDescription) { + this.name = name; + this.dosage = dosage; + this.medicineDescription = medicineDescription; + } + + /** + * Accesses dosage of medication + * @return dosage of medication + */ + public String getDosage() { + return dosage; + } + @Override + public String toString() { + return name; + } + + + //@@author Geeeetyx + public String getDescription() { + return medicineDescription; + } + //@@author +} diff --git a/src/main/java/seedu/duke/medicine/MedicineManager.java b/src/main/java/seedu/duke/medicine/MedicineManager.java new file mode 100644 index 0000000000..fdd9448e5b --- /dev/null +++ b/src/main/java/seedu/duke/medicine/MedicineManager.java @@ -0,0 +1,432 @@ +package seedu.duke.medicine; + +import seedu.duke.diagnosis.Diagnosis; +import seedu.duke.diagnosis.IllnessMatch; +import seedu.duke.diagnosis.symptoms.Symptom; +import seedu.duke.ui.Menu; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Hashtable; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; +//@@author tanyizhe + +/** + * This class manages Medicines that will be prescribed to patients. + */ +public class MedicineManager { + private static final Hashtable> medicationDict = new Hashtable<>(); + private static final Hashtable medicineDosages = new Hashtable<>(); + private static final Medicine PARACETAMOL = new Medicine( + "Paracetamol", "1 or 2 pills up to 3 times a day", + //@@author Geeeetyx + "Description: Paracetamol is a commonly used medicine that can help treat pain and reduce a " + + "high temperature \n" + + " It's typically used to relieve mild or moderate pain, such as headaches, \n" + + " toothache or sprains, and reduce fevers caused by illnesses such as colds and flu." + ); + //@@author tanyizhe + + private static final Medicine LOZENGE = new Medicine( + "Lozenges", "When you feel pain from sore throat", + //@@author Geeeetyx + "Description: Lozenges are used to medicate the mouth and throat for the slow administration " + + "in digestion or \n" + + " cough remedies. Lozenges may contain an anesthetic, a demulcent, or an antiseptic." + ); + //@@author tanyizhe + + private static final Medicine ROBITUSSIN = new Medicine( + "Robitussin", "20ml every 12 hours", + //@@author Geeeetyx + "Description: Robitussin is an expectorant. It helps loosen congestion in your chest and throat, \n" + + " making it easier to cough out through your mouth. \n" + + " Robitussin is used to reduce chest congestion caused by the common cold, \n" + + " infections, or allergies." + ); + //@@author tanyizhe + + private static final Medicine IBUPROFEN = new Medicine( + "Ibuprofen", "1 or 2 pills every 4 to 6 hours", + //@@author Geeeetyx + "Description: Ibuprofen eases mild to moderate pain – such as toothache, migraine and period pain, \n" + + " control a fever (high temperature) – for example, when someone has the flu (influenza), \n" + + " eases pain and inflammation (redness and swelling) caused by conditions that affect the \n" + + " joints, bones and muscles - such as rheumatoid arthritis and osteoarthritis and eases \n" + + " pain and swelling caused by sprains and strains – such as sports injuries" + ); + //@@author tanyizhe + + private static final Medicine ASPIRIN = new Medicine( + "Aspirin", "1 or 2 pills every 4 to 6 hours", + //@@author Geeeetyx + "Description: A drug that reduces pain, fever, inflammation, and blood clotting." + ); + //@@author tanyizhe + private static final Medicine MAGNESIUM = new Medicine( + "Magnesium", "100 to 350mg before bed", + //@@author Geeeetyx + "Description: Magnesium is a mineral that is important for normal bone structure in the body. \n" + + " People get magnesium from their diet, but sometimes magnesium supplements are needed if \n" + + " magnesium levels are too low. \n" + + " Magnesium is most commonly used for constipation, as an antacid for heartburn, \n" + + " for low magnesium levels, \n" + + " for pregnancy complications called pre-eclampsia and eclampsia, \n" + + " and for a certain type of irregular heartbeat." + ); + //@@author tanyizhe + + private static final Medicine EYE_DROPS = new Medicine( + "Eye Drops", "When your eyes itch", + //@@author Geeeetyx + "Description: Eye Drops are a decongestant used to relieve redness in the eyes caused by " + + "minor eye irritations \n" + + " (such as smog, swimming, dust, or smoke)." + ); + //@@author tanyizhe + + private static final Medicine ULTRACARBON = new Medicine( + "Ultracarbon", "1 250mg Tablet", + //@@author Geeeetyx + "Description: Ultracarbon is thought to offer several benefits, including less gas and flatulence, \n" + + " and is thus administered to treat diarrhoea." + ); + //@@author tanyizhe + + private static final Medicine DULCOLAX = new Medicine( + "Dulcolax", "1 tablet every day", + //@@author Geeeetyx + "Description: Dulcolax is used to treat constipation. \n" + + "Swallow this medication whole. Do not crush, chew, or break the tablet or take it within \n" + + " 1 hour of antacids, milk, or milk products. Doing so can destroy the \n" + + " coating on the tablet and may increase the risk of stomach upset and nausea." + ); + //@@author tanyizhe + private static final Medicine GUAIFENESIN = new Medicine( + "Guaifenesin", "200-400 mg 4 hourly", + + //@@author Geeeetyx + "Description: Guaifenesin is used to relieve chest congestion. \n" + + " It works by thinning the mucus in the air passages to make it easier to \n" + + " cough up the mucus and clear the airways." + ); + + private static final Medicine ZOLPIDEM = new Medicine( + "Zolpidem", "taking it once every 2 or 3 nights", + "Description: Zolpidem is used for short-term treatment of " + + "insomnia (difficulty sleeping). \n" + + " It helps you fall asleep faster and sleep through the night." + ); + + + private static final Medicine DIPHENOXYLATE = new Medicine( + "Diphenoxylate", "2 tablets 3-4 times daily", + "Description: Diphenoxylate works by decreasing activity of the bowel, " + + "for the treatment of diarrhea." + ); + + private static final Medicine LACTULOSE = new Medicine( + "Lactulose", "15ml twice a day", + "Description: This medication is used to treat constipation. \n" + + " It encourages bowel movement by drawing water into the bowel. \n" + + " This helps to soften the stools and increase bowel movement." + ); + + private static final Medicine DECONGESTANT_SPRAY = new Medicine( + "Decongestant", "1 to 4 times a day", + "Description: Decongestants shrink the blood vessels (or decongest them) in the nose, \n" + + " reducing the swelling and allowing easier breathing. \n" + + " Use the spray for 2 - 3 days and then wait 2 - 3 days before using the spray again." + ); + + private static final Medicine ZYRTEC_D = new Medicine( + "Antihistamine", "1 5mg tablet every 12 hours", + "Description: ZYRTEC-D® contains both an antihistamine and a decongestant " + + "for allergies. \n" + + " It clears your blocked nose and relieves other allergy symptoms." + ); + + private static final Medicine DIFFLAM_THROAT_SPRAY = new Medicine( + "Difflam Throat Spray", "2 - 4 times every 1.5 - 3 hours until you feel better", + "Description: This spray offers targeted and rapid symptom relief for " + + "hard-to-reach inflamed and \n" + + " painful areas in your mouth and throat. It provides rapid relief from local inflammation \n" + + " and pain from 60 seconds. " + ); + + private static final Medicine NAPROXEN = new Medicine( + "Naproxen", "Dissolove 1-2 tablets in water, take for 1-2 days ONLY and only after meals", + "Description: Naproxen is a non-steroidal anti-inflammatory drug (NSAID). \n" + + " It reduces swelling (inflammation) and pain in joints and muscles, \n" + + " which can help with muscle aches." + ); + + private static final Medicine BROMHEXINE = new Medicine( + "Bromhexine", "One tablet to be taken 3 times daily", + "Bromhexine is used in a condition where there is a lot of thick phlegm " + + "in the airways. \n" + + " As a mucolytic, it helps to relieve cough by thinning the phlegm in the airways " + + "and facilitating the removal of the mucus." + ); + + private static final Medicine OMEPRAZOLE = new Medicine( + "Omeprazole", + "For indigestion, 10 to 20mg a day. For heartburn and acid reflux, 20-40mg a day.", + "Omeprazole is widely used to treat indigestion and heartburn, and acid reflux. \n" + + " It's also taken to prevent and treat stomach ulcers." + ); + + private static final Medicine LEVOCETIRIZINE = new Medicine( + "Levocetirizine", "10ml once a day, not more than 10 days", + "Levocetirizine is used for the relief of symptoms associated with allergic rhinitis \n" + + " E.g: sneezing, runny nose, itching of the nose and/or eyes. \n" + + " It is also used for the relief of symptoms associated with chronic skin rashes or hives." + ); + + private static final Medicine AMBROXAL = new Medicine( + "Ambroxal", "30mg (one tablet) once a day", + "Ambroxol works by thinning down the mucus in the airway passages, " + + "thus making the mucus less sticky. \n" + + " It also facilitates the removal of the mucus from the airways." + ); + + private static final Medicine KETOPROFEN = new Medicine( + "Ketoprofen", "Apply a thin layer to the area of affected skin once or twice a day", + "It belongs to a group of medicines called " + + "Non-Steroidal Anti-Inflammatory Drugs (NSAIDs). These reduce inflammation and relieve pain. \n" + + " Fastum Gel Max, which contains Ketoprofen, is used to relieve pain and " + + "swelling of muscles and joints." + ); + + private static final Medicine ACETYLCISTEINE = new Medicine( + "Acetylcisteine", "200mg once a day or 100mg 2-3 times a day", + "Acetylcisteine works by thinning the mucus in the air passages to make it easier to " + + "cough up the mucus and clear the airways. \n" + + " Flumicil is the recommended product containing Acetylcisteine." + ); + + private static final Medicine CARBOCISTEINE = new Medicine( + "Carbocisteine", "15ml 3 times a day", + "Carbocisteine works by making phlegm (mucus) less thick and sticky, " + + "and therefore easier to cough up. \n" + + " We recommend taking Rhinathiol cough syrup, which contains Carbocisteine." + ); + + private static final Medicine LORATADINE = new Medicine( + "Loratadine", "10mg once a day", + "Loratadine is an antihistamine medicine that helps with the symptoms of allergies. \n" + + " It's used to treat: conjunctivitis (red, itchy eyes) and others. \n" + + " We recommend LORADINE SYRUP 1MG/ML." + ); + + + //@@author tanyizhe + public MedicineManager() { + initialiseMedications(); + initialiseMedicineDosages(); + } + + /** + * This Method initialises the dictionary of Illnesses and Medications. The keys are the names of illnesses + * and the values are an ArrayList of medications. + */ + private void initialiseMedications() { + ArrayList covidMedications = Stream.of(PARACETAMOL, LOZENGE, ROBITUSSIN) + .collect(Collectors.toCollection(ArrayList::new)); + ArrayList commonFluMedications = Stream.of(IBUPROFEN, ASPIRIN, ROBITUSSIN, LEVOCETIRIZINE) + .collect(Collectors.toCollection(ArrayList::new)); + ArrayList migraineMedications = Stream.of(IBUPROFEN, ASPIRIN) + .collect(Collectors.toCollection(ArrayList::new)); + ArrayList feverMedications = Stream.of(PARACETAMOL) + .collect(Collectors.toCollection(ArrayList::new)); + ArrayList headacheMedications = Stream.of(PARACETAMOL) + .collect(Collectors.toCollection(ArrayList::new)); + ArrayList insomniaMedications = Stream.of(MAGNESIUM, ZOLPIDEM) + .collect(Collectors.toCollection(ArrayList::new)); + ArrayList conjunctivitisMedications = Stream.of(EYE_DROPS, LORATADINE) + .collect(Collectors.toCollection(ArrayList::new)); + ArrayList diarrhoeaMedications = Stream.of(ULTRACARBON, DIPHENOXYLATE) + .collect(Collectors.toCollection(ArrayList::new)); + ArrayList constipationMedications = Stream.of(DULCOLAX, LACTULOSE) + .collect(Collectors.toCollection(ArrayList::new)); + ArrayList soreThroatMedications = Stream.of(LOZENGE, DIFFLAM_THROAT_SPRAY) + .collect(Collectors.toCollection(ArrayList::new)); + ArrayList bronchitisMedications = Stream.of(GUAIFENESIN, IBUPROFEN) + .collect(Collectors.toCollection(ArrayList::new)); + + medicationDict.put("Covid-19", covidMedications); + medicationDict.put("General Flu", commonFluMedications); + medicationDict.put("Migraine", migraineMedications); + medicationDict.put("Fever", feverMedications); + medicationDict.put("Headache", headacheMedications); + medicationDict.put("Insomnia", insomniaMedications); + medicationDict.put("Conjunctivitis", conjunctivitisMedications); + medicationDict.put("Diarrhoea", diarrhoeaMedications); + medicationDict.put("Constipation", constipationMedications); + medicationDict.put("Sore Throat", soreThroatMedications); + medicationDict.put("Bronchitis", bronchitisMedications); + + //@@author Geeeetyx + ArrayList nasalCongestionMedications = Stream.of(DECONGESTANT_SPRAY, ZYRTEC_D) + .collect(Collectors.toCollection(ArrayList::new)); + ArrayList muscleAcheMedications = Stream.of(NAPROXEN, KETOPROFEN) + .collect(Collectors.toCollection(ArrayList::new)); + ArrayList mucusMedications = Stream.of(BROMHEXINE, AMBROXAL, ACETYLCISTEINE, CARBOCISTEINE) + .collect(Collectors.toCollection((ArrayList::new))); + ArrayList indigestionMedications = Stream.of(OMEPRAZOLE) + .collect(Collectors.toCollection(ArrayList::new)); + + medicationDict.put("Nasal Congestion", nasalCongestionMedications); + medicationDict.put("Muscle Ache", muscleAcheMedications); + medicationDict.put("Mucus", mucusMedications); + medicationDict.put("Indigestion", indigestionMedications); + } + + //@@author tanyizhe + + /** + * This Method initialises the dictionary of Medications and their dosages. + * The keys are the names of Medications and the values is a string that describes dosage. + */ + public void initialiseMedicineDosages() { + medicineDosages.put(PARACETAMOL.toString(), PARACETAMOL.getDosage()); + medicineDosages.put(ROBITUSSIN.toString(), ROBITUSSIN.getDosage()); + medicineDosages.put(LOZENGE.toString(), LOZENGE.getDosage()); + medicineDosages.put(ASPIRIN.toString(), ASPIRIN.getDosage()); + medicineDosages.put(IBUPROFEN.toString(), IBUPROFEN.getDosage()); + medicineDosages.put(MAGNESIUM.toString(), MAGNESIUM.getDosage()); + medicineDosages.put(EYE_DROPS.toString(), EYE_DROPS.getDosage()); + medicineDosages.put(ULTRACARBON.toString(), ULTRACARBON.getDosage()); + medicineDosages.put(DULCOLAX.toString(), DULCOLAX.getDosage()); + medicineDosages.put(GUAIFENESIN.toString(), GUAIFENESIN.getDosage()); + + //@@author Geeeetyx + medicineDosages.put(ZOLPIDEM.toString(), ZOLPIDEM.getDosage()); + medicineDosages.put(DIPHENOXYLATE.toString(), DIPHENOXYLATE.getDosage()); + medicineDosages.put(LACTULOSE.toString(), LACTULOSE.getDosage()); + medicineDosages.put(DECONGESTANT_SPRAY.toString(), DECONGESTANT_SPRAY.getDosage()); + medicineDosages.put(ZYRTEC_D.toString(), ZYRTEC_D.getDosage()); + medicineDosages.put(DIFFLAM_THROAT_SPRAY.toString(), DIFFLAM_THROAT_SPRAY.getDosage()); + medicineDosages.put(NAPROXEN.toString(), NAPROXEN.getDosage()); + medicineDosages.put(BROMHEXINE.toString(), BROMHEXINE.getDosage()); + medicineDosages.put(OMEPRAZOLE.toString(), OMEPRAZOLE.getDosage()); + medicineDosages.put(LEVOCETIRIZINE.toString(), LEVOCETIRIZINE.getDosage()); + medicineDosages.put(AMBROXAL.toString(), AMBROXAL.getDosage()); + medicineDosages.put(KETOPROFEN.toString(), KETOPROFEN.getDosage()); + medicineDosages.put(ACETYLCISTEINE.toString(), ACETYLCISTEINE.getDosage()); + medicineDosages.put(CARBOCISTEINE.toString(), CARBOCISTEINE.getDosage()); + medicineDosages.put(LORATADINE.toString(), LORATADINE.getDosage()); + + //@@author tanyizhe + assert medicineDosages.isEmpty() == false : "Medicine dosage hashtable must not be empty"; + } + + /** + * Analyses possible illnesses and outputs relevant medication and their dosages. + */ + public ArrayList analyseIllness(ArrayList symptoms) { + ArrayList possibleIllnesses = Diagnosis.getPossibleIllnesses(symptoms); + for (IllnessMatch illnessMatch : possibleIllnesses) { + System.out.println("Medication for: " + illnessMatch.getIllness().getIllnessName()); + ArrayList relevantMedications = getRelevantMedication(illnessMatch.getIllness().getIllnessName()); + printMedication(relevantMedications); + } + + Menu.displayEndOfDiagnosisMessage(); + return possibleIllnesses; + } + + + /** + * Prints medications if they are available over the counter. Otherwise, recommends patient to consult doctor. + * @param relevantMedications ArrayList of medications suggested. + */ + private static void printMedication(ArrayList relevantMedications) { + if (relevantMedications != null) { + for (Medicine medicine : relevantMedications) { + System.out.println(" " + medicine.toString() + " - Dosage: " + medicine.getDosage()); + //@@author Geeeetyx + System.out.println("-----------------------------------------------------------"); + System.out.println(" " + medicine.getDescription()); + System.out.println("-----------------------------------------------------------"); + //@@author tanyizhe + } + } else { + System.out.println(" No medication available. Please consult a doctor."); + System.out.println("-----------------------------------------------------------"); + } + } + //@@author tanyizhe + + /** + * Prescribes appropriate medications to patients. + * @param illness Name of illness diagnosed by Dr. Duke. + * @return ArrayList of prescribed medications. + */ + public ArrayList getRelevantMedication(String illness) { + return medicationDict.get(illness); + } + + public ArrayList getRelevantMedicationInString(String illness) { + ArrayList medicineList = new ArrayList<>(); + if (medicationDict.containsKey(illness)) { + ArrayList medicineArrayList = medicationDict.get(illness); + for (Medicine medicine : medicineArrayList) { + medicineList.add(medicine.toString()); + } + return medicineList; + } else { + assert medicineList.size() == 0 : "No medicines available"; + return null; + } + + } + + /** + * Gets dosage for medicine. + * @param name name of medication + * @return String specifying dosage of specified medication + */ + public String getMedicineDosages(String name) { + return medicineDosages.get(name); + } + + /** + * List all medicines available. + */ + public void listMedicines() { + System.out.println("---------------------------------------------------"); + System.out.println("List of available medications:"); + List medicationKeys = Collections.list(medicineDosages.keys()); + Collections.sort(medicationKeys); + for (String medicationKey : medicationKeys) { + System.out.println(medicationKey); + } + } + + /** + * Looks for medicine using a keyword or phrase. + * @param phrase String user has inputted to find medicine. + */ + public void findMedicine(String phrase) { + List medicationKeys = Collections.list(medicineDosages.keys()); + Collections.sort(medicationKeys); + int count = 0; + for (String medicationKey : medicationKeys) { + if (medicationKey.toLowerCase().contains(phrase.toLowerCase())) { + System.out.println(medicationKey); + count++; + } + } + if (count == 0) { + System.out.println("No results found."); + } + } + + //@@author Thunderdragon221 + public boolean isValidMedicine(String medicine) { + return medicineDosages.containsKey(medicine); + } +} diff --git a/src/main/java/seedu/duke/patient/Patient.java b/src/main/java/seedu/duke/patient/Patient.java new file mode 100644 index 0000000000..5a4c81e4ac --- /dev/null +++ b/src/main/java/seedu/duke/patient/Patient.java @@ -0,0 +1,133 @@ +//@@author Geeeetyx +package seedu.duke.patient; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Hashtable; +import java.util.List; + +/** + * The Patient Class contains methods related to the information of a Patient. + */ +public class Patient { + protected Hashtable> patientDiagnosisHistory = new Hashtable<>(); + protected Hashtable> patientMedicineHistory = new Hashtable<>(); + protected String name; + protected int hash; + + /** + * Creates a new Patient object, to be used throughout Dr Duke. + * @param name The name of the Patient. + * @param hash The hashed password of the Patient. + * @param patientDiagnosisHistory Array containing the history of diagnoses of the patient. + * @param patientMedicineHistory Array containing the history of prescribed medications to the patient. + */ + public Patient(String name, int hash, Hashtable> patientDiagnosisHistory, + Hashtable> patientMedicineHistory + //int queueNumber + ) { + assert patientDiagnosisHistory.size() >= 0 : "Patient diagnosis history is either empty or not empty"; + this.setName(name); + this.setPassword(hash); + this.setPatientDiagnosisHistory(patientDiagnosisHistory); + this.setPatientMedicineHistory(patientMedicineHistory); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getPassword() { + return hash; + } + + public void setPassword(int hash) { + this.hash = hash; + } + + public void setPatientDiagnosisHistory(Hashtable> diagnosisHistory) { + patientDiagnosisHistory = diagnosisHistory; + } + + public Hashtable> getPatientDiagnosisHistory() { + return patientDiagnosisHistory; + } + + //@@author Thunderdragon221 + /** + * Updates patient's diagnosis history. + * @param date date of use of Dr Duke. + * @param diagnoses ArrayList containing list of illnesses patient is diagnosed with. + */ + public void updatePatientDiagnosisHistory(String date, ArrayList diagnoses) { + if (patientDiagnosisHistory.containsKey(date)) { + appendDiagnosisToSameDate(date, diagnoses); + } else { + patientDiagnosisHistory.put(date, diagnoses); + } + } + + /** + * Appends illnesses patient is diagnosed with if additional illnesses are diagnosed on the same day. + * @param diagnoses ArrayList of illnesses patient is diagnosed with. + * @param date String representing the date that patient was diagnosed. + */ + private void appendDiagnosisToSameDate(String date, ArrayList diagnoses) { + for (String diagnosis : diagnoses) { + if (!patientDiagnosisHistory.get(date).contains(diagnosis)) { + patientDiagnosisHistory.get(date).add(diagnosis); + } + } + } + + //@@author tanyizhe + /** + * Updates patient's medicine history. + * @param medicines ArrayList describing medicines patient has been prescribed + */ + public void updatePatientMedicineHistory(String date, ArrayList medicines) { + if (patientMedicineHistory.containsKey(date)) { + appendMedicineToSameDate(date, medicines); + } else { + patientMedicineHistory.put(date, medicines); + } + } + + /** + * Appends medicine patient is prescribed if additional medicine is prescribed on the same day + * @param medicines ArrayList describing medicines patient has been prescribed + * @param date String representing the date that patients were prescribed medication + */ + private void appendMedicineToSameDate(String date, ArrayList medicines) { + for (String medicine : medicines) { + if (!patientMedicineHistory.get(date).contains(medicine)) { + patientMedicineHistory.get(date).add(medicine); + } + } + } + + /** + * Prints the medication history of patient. + */ + public void printPatientMedicineHistory() { + System.out.println("---------------------------------------------------"); + System.out.println("Medication History:"); + List dates = Collections.list(patientMedicineHistory.keys()); + Collections.sort(dates); + for (String date : dates) { + System.out.println(date + ": " + patientMedicineHistory.get(date)); + } + } + public Hashtable> getPatientMedicineHistory() { + return patientMedicineHistory; + } + + public void setPatientMedicineHistory(Hashtable> patientMedicineHistory) { + this.patientMedicineHistory = patientMedicineHistory; + } +} + diff --git a/src/main/java/seedu/duke/save/CorruptedDataException.java b/src/main/java/seedu/duke/save/CorruptedDataException.java new file mode 100644 index 0000000000..da2878e489 --- /dev/null +++ b/src/main/java/seedu/duke/save/CorruptedDataException.java @@ -0,0 +1,8 @@ +package seedu.duke.save; + +//@@author Thunderdragon221 +/** + * This exception is thrown when corruption is detected in the patient-data file. + */ +public class CorruptedDataException extends Exception { +} diff --git a/src/main/java/seedu/duke/save/Storage.java b/src/main/java/seedu/duke/save/Storage.java new file mode 100644 index 0000000000..1824b4f8a3 --- /dev/null +++ b/src/main/java/seedu/duke/save/Storage.java @@ -0,0 +1,418 @@ +//@@author Thunderdragon221 +package seedu.duke.save; + +import seedu.duke.medicine.MedicineManager; +import seedu.duke.patient.Patient; +import seedu.duke.ui.Information; +import seedu.duke.ui.Menu; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileWriter; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.time.DateTimeException; +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; +import java.util.Scanner; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * This class reads and writes information to and from the patient-data file. + */ +public class Storage { + //@@author Geeeetyx + private static final String QUEUE_FILE_PATH = "./data/queue_data.txt"; + //@@author Thunderdragon221 + + /** Specifies the directory path to be created */ + private static final String DIR_PATH = "./data/"; + + /** Specifies the file path to be created */ + private static final String FILE_PATH = "./data/patient-data.txt"; + + /** Stores the data read in from patient-data file to check hash similar to a checksum */ + private static String dataCompare = ""; + + /** Stores the data read in from queue_data file to check hash similar to a checksum */ + private static String queueDataCompare = ""; + + private static final Logger logger = Logger.getLogger(Storage.class.getName()); + /** + * Loads each patient's data into a hashmap of patients in the Information class + * by reading from the patient-data file. + */ + public static void loadData() { + try { + logger.setLevel(Level.SEVERE); + createDirectory(); + createFile(); + readFile(); + //@@author Geeeetyx + createQueueFile(); + readQueueFile(); + //@@author Thunderdragon221 + } catch (FileNotFoundException e) { + System.out.println("ERROR: File not found."); + } catch (CorruptedDataException e) { + System.out.println("ERROR: Data file is corrupted. Clear all data files " + + "or restore data to uncorrupted state before trying again."); + Menu.exitWithoutSaving(); + } catch (IOException e) { + System.out.println("ERROR: Failed to create files for storage"); + } + } + + /** + * Creates the directory used to store the patient-data file. + * + * @throws IOException if createDirectories() is unsuccessful. + */ + private static void createDirectory() throws IOException { + Path path = Paths.get(DIR_PATH); + Files.createDirectories(path); + } + + /** + * Creates the patient-data file used to store the data in the patientsList. + * + * @throws IOException if createNewFile() is unsuccessful. + */ + private static void createFile() throws IOException { + File file = new File(FILE_PATH); + file.createNewFile(); + } + + /** + * Reads from the patient-data file and converts the data back into the patient data + * before storing all read data into Information.patientsList. + * + * @throws FileNotFoundException if data file does not exist. + * @throws CorruptedDataException if data file is corrupted. + */ + private static void readFile() throws FileNotFoundException, CorruptedDataException { + File file = new File(FILE_PATH); + Scanner scanner = new Scanner(file); + String hashString; + + if (!scanner.hasNextLine()) { + scanner.close(); + return; + } + + hashString = scanner.nextLine(); + if (((!hashString.matches("^[0-9]+$")) && (!hashString.matches("^-[0-9]+$"))) || + hashString.matches("^0{2,}$")) { + logger.log(Level.INFO, "Corrupted data file"); + throw new CorruptedDataException(); + } + int fileHash = Integer.parseInt(hashString); + + ArrayList patientsList = new ArrayList<>(); + while (scanner.hasNextLine()) { + String password = scanner.nextLine(); + dataCompare += password + "\n"; + if (emptyField(password)) { + break; + } else if ((!password.matches("^[0-9]+$")) && (!password.matches("^-[0-9]+$"))) { + logger.log(Level.INFO, "Corrupted data file"); + throw new CorruptedDataException(); + } + + if (!scanner.hasNextLine()) { + logger.log(Level.INFO, "Corrupted data file"); + throw new CorruptedDataException(); + } + String name = scanner.nextLine(); + dataCompare += name + "\n"; + if (emptyField(name)) { + logger.log(Level.INFO, "Corrupted data file"); + throw new CorruptedDataException(); + } + + if (!scanner.hasNextLine()) { + logger.log(Level.INFO, "Corrupted data file"); + throw new CorruptedDataException(); + } + String line = scanner.nextLine(); + if (emptyField(line) || (!line.matches("[0-9]+"))) { + logger.log(Level.INFO, "Corrupted data file"); + throw new CorruptedDataException(); + } + int numberOfEntries = Integer.parseInt(line); + dataCompare += numberOfEntries + "\n"; + Hashtable> diagnosisHistory = new Hashtable<>(); + + for (int i = 0; i < numberOfEntries; i++) { + if (!scanner.hasNextLine()) { + logger.log(Level.INFO, "Corrupted data file"); + throw new CorruptedDataException(); + } + String dateDiagnosisString = scanner.nextLine(); + dataCompare += dateDiagnosisString + "\n"; + if (emptyField(dateDiagnosisString)) { + logger.log(Level.INFO, "Corrupted data file"); + throw new CorruptedDataException(); + } + String[] splitDateDiagnosisStrings = dateDiagnosisString.split("%"); + ArrayList diagnoses = new ArrayList<>(); + for (int diagnosisStringCount = 1; diagnosisStringCount < splitDateDiagnosisStrings.length; + diagnosisStringCount++) { + diagnoses.add(splitDateDiagnosisStrings[diagnosisStringCount]); + } + String date = splitDateDiagnosisStrings[0]; + if (!date.matches("^[0-9]{4}/[0-9]{2}/[0-9]{2}$")) { + logger.log(Level.INFO, "Corrupted data file"); + throw new CorruptedDataException(); + } + int year = Integer.parseInt(date.substring(0, 4)); + int month = Integer.parseInt(date.substring(5, 7)); + int day = Integer.parseInt(date.substring(8, 10)); + if (!isValidDate(year, month, day)) { + logger.log(Level.INFO, "Corrupted data file"); + throw new CorruptedDataException(); + } + diagnosisHistory.put(date, diagnoses); + } + Hashtable> medicineHistory = readMedicineHistoryFromFile(scanner); + + int hash = Integer.parseInt(password); + Patient patient = new Patient(name, hash, diagnosisHistory, medicineHistory); + patientsList.add(patient); + } + + int dataCompareHash = dataCompare.hashCode(); + if (dataCompareHash != fileHash) { + logger.log(Level.INFO, "Corrupted data file"); + throw new CorruptedDataException(); + } + + for (Patient patient : patientsList) { + Information.storePatientInfo(patient.getPassword(), patient); + } + scanner.close(); + } + //@@author tanyizhe + /** + * Reads medicine history data from data storage file. + * @param scanner Scanner that scans user input. + * @return Hashtable with key String and value ArrayList of Strings recording Medicine History of patient. + * @throws CorruptedDataException Exception occurs when file has records more medicines than expected. + */ + private static Hashtable> readMedicineHistoryFromFile(Scanner scanner) + throws CorruptedDataException { + + //@@author Thunderdragon221 + String line = scanner.nextLine(); + if (emptyField(line) || (!line.matches("[0-9]+"))) { + logger.log(Level.INFO, "Corrupted data file"); + throw new CorruptedDataException(); + } + //@@author tanyizhe + int numberOfMedicineEntries = Integer.parseInt(line); + dataCompare += numberOfMedicineEntries + "\n"; + Hashtable> medicineHistory = new Hashtable(); + + for (int entry = 0; entry < numberOfMedicineEntries; entry++) { + //@@author Thunderdragon221 + if (!scanner.hasNextLine()) { + logger.log(Level.INFO, "Corrupted data file"); + throw new CorruptedDataException(); + } + //@@author tanyizhe + String dateMedicineString = scanner.nextLine(); + dataCompare += dateMedicineString + "\n"; + if (emptyField(dateMedicineString)) { + logger.log(Level.INFO, "Corrupted data file"); + throw new CorruptedDataException(); + } + String[] splitDateMedicineStrings = dateMedicineString.split("%"); + ArrayList medicines = new ArrayList<>(); + for (int medStringCount = 1; medStringCount < splitDateMedicineStrings.length; medStringCount++) { + medicines.add(splitDateMedicineStrings[medStringCount]); + } + //@@author Thunderdragon221 + String date = splitDateMedicineStrings[0]; + if (!date.matches("^[0-9]{4}/[0-9]{2}/[0-9]{2}$")) { + logger.log(Level.INFO, "Corrupted data file"); + throw new CorruptedDataException(); + } + int year = Integer.parseInt(date.substring(0, 4)); + int month = Integer.parseInt(date.substring(5, 7)); + int day = Integer.parseInt(date.substring(8, 10)); + if (!isValidDate(year, month, day)) { + logger.log(Level.INFO, "Corrupted data file"); + throw new CorruptedDataException(); + } + + + MedicineManager medicineManager = new MedicineManager(); + for (String medicine : medicines) { + if (!medicineManager.isValidMedicine(medicine)) { + logger.log(Level.INFO, "Corrupted data file"); + throw new CorruptedDataException(); + } + } + + //@@author tanyizhe + medicineHistory.put(date, medicines); + } + return medicineHistory; + } + //@@author Thunderdragon221 + /** + * Writes to the patient-data file to save all patients' data DoctorDuke currently has. + */ + public static void saveData() { + try { + FileWriter writer = new FileWriter(FILE_PATH); + String data = ""; + for (Map.Entry entry : Information.getAllPatientData().entrySet()) { + Patient patient = entry.getValue(); + String name = patient.getName(); + int password = patient.getPassword(); + Hashtable> diagnosisHistory = patient.getPatientDiagnosisHistory(); + int numberOfDiagnoses = diagnosisHistory.size(); + Hashtable> medicineHistory = patient.getPatientMedicineHistory(); + int numberOfMedicines = medicineHistory.size(); + + data += password + "\n" + name + "\n" + numberOfDiagnoses + "\n"; + List dates = Collections.list(diagnosisHistory.keys()); + Collections.sort(dates); + for (String date : dates) { + data += date + "%"; + for (String diagnosisString : diagnosisHistory.get(date)) { + data += diagnosisString + "%"; + } + } + if (dates.size() > 0) { + data += "\n"; + } + data += numberOfMedicines + "\n"; + data = writeMedicineHistory(data, medicineHistory); + } + int fileHash = data.hashCode(); + data = fileHash + "\n" + data; + writer.write(data); + writer.close(); + } catch (IOException e) { + logger.log(Level.WARNING, "Unable to save data to file"); + System.out.println("ERROR: Unable to save data to file."); + } + } + //@@author tanyizhe + /** + * Writes medicine history of patient to data file for storage. + * @param data that writes onto a file. + * @param medicineHistory Hashtable with key String with value of patient's medicine History + * @return updated data to be written to file + */ + private static String writeMedicineHistory(String data, Hashtable> medicineHistory) { + List dates = Collections.list(medicineHistory.keys()); + Collections.sort(dates); + for (String date : dates) { + data += date + "%"; + for (String medString : medicineHistory.get(date)) { + data += medString + "%"; + } + } + if (dates.size() > 0) { + data += "\n"; + } + return data; + } + //@@author Thunderdragon221 + /** + * Checks whether an empty field is scanned. + * + * @param data Current line being read from the patient-data file. + * @return true if the line is empty, and false otherwise. + */ + private static boolean emptyField(String data) { + return data.matches("^ *$"); + } + + /** + * Checks whether the date is valid. + * + * @param year year of the date in integer YYYY format. + * @param month month of the date in integer MM format. + * @param day day of the date in integer DD format. + * @return true if the date is valid and false otherwise. + */ + private static boolean isValidDate(int year, int month, int day) { + boolean isValid = true; + + try { + LocalDate.of(year, month, day); + } catch (DateTimeException e) { + isValid = false; + } + + return isValid; + } + + //@@author Geeeetyx + private static void createQueueFile() throws IOException { + File file = new File(QUEUE_FILE_PATH); + file.createNewFile(); + } + + public static void saveQueue() { + try { + FileWriter writer = new FileWriter(QUEUE_FILE_PATH); + ArrayList queueList = Information.getQueueList(); + String data = ""; + for (String currentQueueNumber : queueList) { + data += currentQueueNumber + "\n"; + } + //@@author Thunderdragon221 + int fileHash = data.hashCode(); + data = fileHash + "\n" + data; + writer.write(data); + writer.close(); + //@@author Geeeetyx + } catch (IOException e) { + System.out.println("ERROR: Unable to save queue to file"); + } + } + + private static void readQueueFile() throws FileNotFoundException, CorruptedDataException { + File file = new File(QUEUE_FILE_PATH); + Scanner scanner = new Scanner(file); + //@@author Thunderdragon221 + String hashString; + if (!scanner.hasNextLine()) { + scanner.close(); + return; + } + hashString = scanner.nextLine(); + if (((!hashString.matches("^[0-9]+$")) && (!hashString.matches("^-[0-9]+$"))) || + hashString.matches("^0{2,}$")) { + logger.log(Level.INFO, "Corrupted data file"); + throw new CorruptedDataException(); + } + int fileHash = Integer.parseInt(hashString); + //@@author Geeeetyx + while (scanner.hasNextLine()) { + String line = scanner.nextLine(); + Information.addToQueue(line); + queueDataCompare += line + "\n"; + } + //@@author Thunderdragon221 + int queueDataHashCompare = queueDataCompare.hashCode(); + if (fileHash != queueDataHashCompare) { + logger.log(Level.INFO, "Corrupted data file"); + throw new CorruptedDataException(); + } + scanner.close(); + } +} diff --git a/src/main/java/seedu/duke/ui/Information.java b/src/main/java/seedu/duke/ui/Information.java new file mode 100644 index 0000000000..e6d767d5d6 --- /dev/null +++ b/src/main/java/seedu/duke/ui/Information.java @@ -0,0 +1,268 @@ +//@@author JeraldChen +package seedu.duke.ui; + +import seedu.duke.diagnosis.symptoms.Symptom; +import seedu.duke.diagnosis.symptoms.SymptomHandler; +import seedu.duke.patient.Patient; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Collections; +import java.util.Hashtable; +import java.util.Scanner; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.stream.Collectors; + +import static seedu.duke.save.Storage.saveData; + +/** + * This class stores information on all patients registered by DoctorDuke. + */ + +//@@author JeraldChen +public class Information { + //@@author Geeeetyx + private static final ArrayList queueList = new ArrayList<>(); + //@@author + + private static final HashMap patientsList = new HashMap<>(); + + private static final Logger logger = Logger.getLogger(Information.class.getName()); + + public static void storePatientInfo(int hash, Patient patient) { + logger.setLevel(Level.SEVERE); + logger.log(Level.INFO, "Storing patient information"); + patientsList.put(hash, patient); + } + + public static Patient getPatientInfo(int hash) { + logger.setLevel(Level.SEVERE); + logger.log(Level.INFO, "Retrieving patient information"); + return patientsList.get(hash); + } + + //@@author Geeeetyx + + /** + * Prints the diagnosis history of the Patient. + * @param hash The key to access the patient's details. + */ + public static void printDiagnosisHistory(int hash) { + logger.log(Level.INFO, "Printing diagnosis history"); + + Patient patient = patientsList.get(hash); + Hashtable> patientDiagnosisHistory = patient.getPatientDiagnosisHistory(); + + System.out.println("---------------------------------------------------"); + if (patientDiagnosisHistory.isEmpty()) { + System.out.println("You have no past diagnoses"); + } else { + System.out.println("Your diagnosis history is: "); + for (int i = 0; i < patientDiagnosisHistory.size(); i++) { + //@@author Thunderdragon221 + List dates = Collections.list(patientDiagnosisHistory.keys()); + Collections.sort(dates); + for (String date : dates) { + System.out.println(date + ": " + patientDiagnosisHistory.get(date)); + } + //@@Geeeetyx + } + } + } + + //@@author JeraldChen + + /** + * Resets the diagnosis history of the patient. + * + * @param hash The hashed password of the patient. + */ + public static void resetDiagnosisHistory(int hash) { + logger.log(Level.INFO, "Resetting diagnosis history"); + + Patient patient = patientsList.get(hash); + patient.getPatientDiagnosisHistory().clear(); + assert patient.getPatientDiagnosisHistory().size() == 0 : "Diagnosis history should be empty"; + System.out.println("---------------------------------------------------"); + System.out.println("Your diagnosis history has been reset."); + saveData(); + } + + //@@author Thunderdragon221 + + /** + * Checks the existence of a password in Dr Duke. + * + * @param hash hashedPassword to check. + * @return true if hashedPassword exists in Dr Duke, and false otherwise. + */ + public static boolean checkHash(int hash) { + logger.log(Level.INFO, "Checking hash"); + return patientsList.containsKey(hash); + } + + /** + * Returns all patient data currently stored in Dr Duke. + * + * @return Hashmap of all patient data. + */ + public static HashMap getAllPatientData() { + logger.log(Level.INFO, "Retrieving all patient data"); + return patientsList; + } + + //@@author Thunderdragon221 + + /** + * Hashes the password keyed in by the user. + * @param password password to hash. + * @return hash of password. + */ + public static int hashPassword(String password) { + return password.hashCode(); + } + + //@@author Jeraldchen + + /** + * Resets the symptom choice of the patient. + * @param symptoms The symptom choice of the patient. + */ + public static void resetSymptomChoice(ArrayList symptoms) { + if (symptoms.size() != 0) { + symptoms.clear(); + //@@author Geeeetyx + System.out.println("---------------------------------------------------"); + //@@author JeraldChen + System.out.println("Your symptom choice has been reset."); + } else { + //@@author Geeeetyx + System.out.println("---------------------------------------------------"); + //@@authorJeraldChen + System.out.println("You have not entered any symptoms. No symptoms to reset."); + } + } + //@@author JeraldChen + /** + * Prints the symptom history of the patient. + * @param symptoms The patient's array of symptoms to print. + */ + public static void viewSymptomHistory(ArrayList symptoms) { + if (symptoms.size() == 0) { + System.out.println("---------------------------------------------------"); + System.out.println("You have not entered any symptoms."); + } else { + System.out.println("---------------------------------------------------"); + SymptomHandler.printSymptoms(symptoms); + } + } + + //@@author Geeeetyx + /** + * Deletes a set of selected symptoms from an array containing symptoms + * previously selected by the patient. + * + * @param symptoms The array of symptoms to delete the chosen symptoms from. + */ + //@@author JeraldChen + public static boolean deleteSymptom(ArrayList symptoms) { + boolean hasDeleted = false; + Scanner scanner = new Scanner(System.in); + if (symptoms.size() == 0) { + System.out.println("You have not entered any symptoms."); + return false; + } + System.out.println("---------------------------------------------------"); + System.out.println("Here is the list of your symptoms:"); + for (int i = 0; i < symptoms.size(); i++) { + System.out.println((i + 1) + ". " + SymptomHandler.toString(symptoms.get(i))); + } + System.out.println("Please enter the numbers of the symptom you want to delete."); + System.out.println("Please put a space between each number to delete multiple symptoms."); + System.out.println("---------------------------------------------------"); + + try { + List deleteIndexIntegerList = parseAndSortInputs(scanner); + for (int deleteIndex : deleteIndexIntegerList) { + if (deleteIndex > symptoms.size() || deleteIndex < 0) { + System.out.println("'" + deleteIndex + "' is not a valid symptom number."); + } else { + symptoms.remove(deleteIndex - 1); + hasDeleted = true; + } + } + if (hasDeleted) { + displayUpdatedSymptomList(symptoms); + } + } catch (IndexOutOfBoundsException e) { + displayInvalidSymptomChoiceErrorMessage(); + } catch (NumberFormatException e) { + System.out.println("Please enter only numbers that match the symptom."); + System.out.println("Returning to main menu."); + } + return hasDeleted; + } + + //@@author tanyizhe + /** + * Displays updated symptom list. Displays an alert if list of symptoms is empty. + * @param symptoms list of symptoms user has entered. + */ + private static void displayUpdatedSymptomList(ArrayList symptoms) { + System.out.println("Successfully deleted symptom(s)!"); + System.out.println("Here is the updated list of your symptoms:"); + if (symptoms.isEmpty()) { + System.out.println("---------- Your symptom list is empty! ----------"); + } else { + for (int i = 0; i < symptoms.size(); i++) { + System.out.println((i + 1) + ". " + SymptomHandler.toString(symptoms.get(i))); + } + } + } + /** + * Sorts input indexes in a descending order. Removes duplicate values. + * @param scanner Scans user input. + * @return List of integers in descending order representing indexes to be deleted. + */ + private static List parseAndSortInputs(Scanner scanner) { + String[] deleteIndexes = scanner.nextLine().split(" "); + List deleteSortedIndexes = Arrays.asList(deleteIndexes); + List deleteIndexIntegerList = deleteSortedIndexes.stream() + .map(Integer::parseInt) + .distinct() + .collect(Collectors.toList()); + Collections.sort(deleteIndexIntegerList, Collections.reverseOrder()); + return deleteIndexIntegerList; + } + + //@@author JeraldChen + /** + * Displays invalid symptom choice error message. + */ + private static void displayInvalidSymptomChoiceErrorMessage() { + System.out.println("Invalid number! Please enter a valid symptom number."); + System.out.println("Returning to main menu."); + } + + + //@@author Geeeetyx + public static ArrayList getQueueList() { + return queueList; + } + + public static void addToQueue(String password) { + queueList.add(password); + } + + public static void printPatientQueueNumber() { + int queueNumber = queueList.size(); + System.out.println("---------------------------------------------------"); + System.out.println("This is your queue number"); + System.out.println("---------------------------------------------------"); + System.out.println(queueNumber); + } + //@@author +} diff --git a/src/main/java/seedu/duke/ui/Menu.java b/src/main/java/seedu/duke/ui/Menu.java new file mode 100644 index 0000000000..1a172b10fa --- /dev/null +++ b/src/main/java/seedu/duke/ui/Menu.java @@ -0,0 +1,504 @@ +//@@author JeraldChen + +package seedu.duke.ui; +import seedu.duke.Duke; +import seedu.duke.diagnosis.Diagnosis; +import seedu.duke.diagnosis.IllnessMatch; +import seedu.duke.diagnosis.symptoms.Symptom; +import seedu.duke.diagnosis.symptoms.SymptomHandler; +import seedu.duke.patient.Patient; +import seedu.duke.save.Storage; + +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.Scanner; + +//@@author JeraldChen +public class Menu { + public static ArrayList symptoms = new ArrayList<>(); + + /** + * Shows the welcome menu. + */ + //@@Geeeetyx + public static void showWelcomeMenu() { + System.out.println("---------------------------------------------------"); + System.out.println("What would you like to do? Please enter the number:"); + System.out.println("1. Register"); + System.out.println("2. Login"); + System.out.println("3. Exit"); + System.out.println("---------------------------------------------------"); + } + + //@@author JeraldChen + /** + * Shows the register menu. + */ + public static void register() { + String name = ""; + Scanner scanner = new Scanner(System.in); + while (true) { + if (name.equals("")) { + System.out.println("---------------------------------------------------"); + System.out.println("Please enter your name: "); + name = scanner.nextLine(); + if (name.equals("")) { + System.out.println("---------------------------------------------------"); + System.out.println("Registration failed! Name cannot be empty."); + continue; + } + } + System.out.println("---------------------------------------------------------------"); + System.out.println("Note: Any whitespaces in passwords entered will be stripped off"); + System.out.println("Please enter your password: "); + String password = scanner.nextLine(); + + password = password.replaceAll("\\s", ""); + int hash = Information.hashPassword(password); + + if (password.equals("")) { + System.out.println("---------------------------------------------------"); + System.out.println("Registration failed! Password cannot be empty."); + } else if (Information.checkHash(hash)) { + System.out.println("--------------------------------------------------------"); + System.out.println("Password is already used. Please enter another password."); + } else { + System.out.println("---------------------------------------------------"); + System.out.println("Please re-enter your password: "); + String password2 = new Scanner(System.in).nextLine(); + password2 = password2.replaceAll("\\s", ""); + if (password.equals(password2)) { + System.out.println("---------------------------------------------------"); + System.out.println("Registration successful!"); + Hashtable> diagnosisHistory = new Hashtable<>(); + Hashtable> medicineHistory = new Hashtable<>(); + Information.storePatientInfo(hash, new Patient(name, hash, diagnosisHistory, medicineHistory)); + Storage.saveData(); + break; + } else { + //@@author Geeeetyx + System.out.println("---------------------------------------------------"); + System.out.println("Registration failed! Passwords do not match."); + } + } + } + } + + //@@author JeraldChen + /** + * Shows the login menu. + */ + public static void login() { + Scanner scanner = new Scanner(System.in); + System.out.println("---------------------------------------------------"); + System.out.println("Please enter your name: "); + String name = new Scanner(System.in).nextLine(); + System.out.println("---------------------------------------------------"); + System.out.println("Please enter your password: "); + String password = scanner.nextLine(); + password = password.replaceAll("\\s", ""); + int hash = Information.hashPassword(password); + if (Information.checkHash(hash) && Information.getPatientInfo(hash).getName().equals(name)) { + Duke.setPassword(hash); + + //@@author Geeeetyx + + System.out.println("---------------------------------------------------"); + System.out.println("Login successful!"); + System.out.println("Welcome " + name + "!"); + + Information.addToQueue(password); + } else { + System.out.println("----------------------------------------------------------------------"); + System.out.println("Login failed! Please register first or key in the correct information."); + } + } + + //@@author Thunderdragon221 + private static void printExitLogo() { + System.out.println("---------------------------------------------------"); + System.out.println("Thank you for using"); + String logo = " ____ ____ _ \n" + + "| _ \\ ___ | _ \\ _ _ | | _____ \n" + + "| | | |/ _ \\ | | | | | | | |/ / _ \\\n" + + "| |_| | | | |_| | |_| | < __/\n" + + "|____/|_| |____/ \\__,_|_|\\_\\___|\n"; + System.out.print(logo); + System.out.println("---------------------------------------------------"); + } + //@@author Geeeetyx + public static void exit() { + printExitLogo(); + Storage.saveData(); + Storage.saveQueue(); + System.exit(0); + } + + //@@author Thunderdragon221 + public static void exitWithoutSaving() { + printExitLogo(); + System.exit(0); + } + + /** + * Shows the account menu. + */ + public static void showAccountMenu() { + System.out.println("---------------------------------------------------"); + System.out.println("What would you like to do? Please enter the number:"); + System.out.println("1. Report symptoms"); + System.out.println("2. View diagnosis history"); + System.out.println("3. Reset diagnosis history"); + System.out.println("4. View symptoms History"); + System.out.println("5. Delete symptom choice"); + System.out.println("6. Reset symptoms"); + System.out.println("7. View Medicine history"); + System.out.println("8. List available medicines"); + System.out.println("9. Find available medicine"); + System.out.println("10. Display Queue Number"); + System.out.println("0. Exit"); + System.out.println("---------------------------------------------------"); + } + + //@@author Thunderdragon221 + /** + * Reads in a list of symptoms the user experiences. + * + * @return ArrayList of symptoms the user experiences. + */ + public static ArrayList getUserSymptoms() { + Scanner scanner = new Scanner(System.in); + displaySymptomList(); + addSymptomToSymptomList(scanner, symptoms); + while (true) { + System.out.println("Do you have any other symptoms? [Y/N]"); + String decision = scanner.nextLine(); + if (decision.equals("Y") || decision.equals("y")) { + displaySymptomList(); + addSymptomToSymptomList(scanner, symptoms); + } else if (decision.equals("N") || decision.equals("n")) { + //@@author Geeeetyx + if (symptoms.isEmpty()) { + break; + } else { + System.out.println("Your entered symptoms are: "); + SymptomHandler.printSymptoms(symptoms); + break; + } + } else { + System.out.println("Invalid command! Please indicate Y/N."); + } + } + return symptoms; + } + + //@@author Jeraldchen + /** + * Checks if symptom is valid, and adds it to the list of symptoms. + * + * @param scanner takes in user input + * @param symptoms list of symptoms + */ + private static void addSymptomToSymptomList(Scanner scanner, ArrayList symptoms) { + String symptomChoiceAlphabets; + symptomChoiceAlphabets = scanner.nextLine(); + symptomChoiceAlphabets = symptomChoiceAlphabets.toUpperCase(); + symptomChoiceAlphabets = symptomChoiceAlphabets.trim(); + String[] symptomChoices = symptomChoiceAlphabets.split("(?!^)"); + parseSymptomInput(symptoms, symptomChoices); + } + + /** + * Parses user's input to a Symptom enumerator. + * + * @param symptoms an ArrayList of symptoms. + * @param symptomChoices an array of strings containing the user's input. + */ + //@@author Jeraldchen + private static void parseSymptomInput(ArrayList symptoms, String[] symptomChoices) { + //@@author tanyizhe + for (String symptomChoice : symptomChoices) { + switch (symptomChoice) { + case "A": + try { + addSymptoms(Symptom.FEVER, symptoms); + } catch (Exception e) { + System.out.println("Invalid command! Please enter a valid symptom."); + } + break; + case "B": + try { + addSymptoms(Symptom.DRY_COUGH, symptoms); + } catch (Exception e) { + System.out.println("Invalid command! Please enter a valid symptom."); + } + break; + case "C": + try { + addSymptoms(Symptom.COUGH_WITH_PHLEGM, symptoms); + } catch (Exception e) { + System.out.println("Invalid command! Please enter a valid symptom."); + } + break; + case "D": + try { + addSymptoms(Symptom.THROAT_IRRITATION, symptoms); + } catch (Exception e) { + System.out.println("Invalid command! Please enter a valid symptom."); + } + break; + case "E": + try { + addSymptoms(Symptom.LOSS_OF_TASTE_OR_SMELL, symptoms); + } catch (Exception e) { + System.out.println("Invalid command! Please enter a valid symptom."); + } + break; + case "F": + try { + addSymptoms(Symptom.RUNNY_NOSE, symptoms); + } catch (Exception e) { + System.out.println("Invalid command! Please enter a valid symptom."); + } + break; + case "G": + try { + addSymptoms(Symptom.HEAD_ACHE, symptoms); + } catch (Exception e) { + System.out.println("Invalid command! Please enter a valid symptom."); + } + break; + //@@author JeraldChen + case "H": + try { + addSymptoms(Symptom.CHILLS, symptoms); + } catch (Exception e) { + System.out.println("Invalid command! Please enter a valid symptom."); + } + break; + case "I": + try { + addSymptoms(Symptom.FATIGUE, symptoms); + } catch (Exception e) { + System.out.println("Invalid command! Please enter a valid symptom."); + } + break; + case "J": + try { + addSymptoms(Symptom.SNEEZING, symptoms); + } catch (Exception e) { + System.out.println("Invalid command! Please enter a valid symptom."); + } + break; + case "K": + try { + addSymptoms(Symptom.BLOCKED_NOSE, symptoms); + } catch (Exception e) { + System.out.println("Invalid command! Please enter a valid symptom."); + } + break; + case "L": + try { + addSymptoms(Symptom.ITCHY_EYE, symptoms); + } catch (Exception e) { + System.out.println("Invalid command! Please enter a valid symptom."); + } + break; + case "M": + try { + addSymptoms(Symptom.RED_EYES, symptoms); + } catch (Exception e) { + System.out.println("Invalid command! Please enter a valid symptom."); + } + break; + case "N": + try { + addSymptoms(Symptom.DIARRHOEA, symptoms); + } catch (Exception e) { + System.out.println("Invalid command! Please enter a valid symptom."); + } + break; + case "O": + try { + addSymptoms(Symptom.STOMACH_ACHE, symptoms); + } catch (Exception e) { + System.out.println("Invalid command! Please enter a valid symptom."); + } + break; + case "P": + try { + addSymptoms(Symptom.WET_STOOL, symptoms); + } catch (Exception e) { + System.out.println("Invalid command! Please enter a valid symptom."); + } + break; + case "Q": + try { + addSymptoms(Symptom.HARD_LUMPY_STOOL, symptoms); + } catch (Exception e) { + System.out.println("Invalid command! Please enter a valid symptom."); + } + break; + case "R": + try { + addSymptoms(Symptom.NAUSEA, symptoms); + } catch (Exception e) { + System.out.println("Invalid command! Please enter a valid symptom."); + } + break; + case "S": + try { + addSymptoms(Symptom.VOMITING, symptoms); + } catch (Exception e) { + System.out.println("Invalid command! Please enter a valid symptom."); + } + break; + case "T": + try { + addSymptoms(Symptom.SLEEPLESSNESS, symptoms); + } catch (Exception e) { + System.out.println("Invalid command! Please enter a valid symptom."); + } + break; + case "U": + try { + addSymptoms(Symptom.BLURRED_VISION, symptoms); + } catch (Exception e) { + System.out.println("Invalid command! Please enter a valid symptom."); + } + break; + case "V": + try { + addSymptoms(Symptom.SENSITIVITY_TO_LIGHT_AND_SOUND, symptoms); + } catch (Exception e) { + System.out.println("Invalid command! Please enter a valid symptom."); + } + break; + case "W": + try { + addSymptoms(Symptom.MUSCLE_ACHE, symptoms); + } catch (Exception e) { + System.out.println("Invalid command! Please enter a valid symptom."); + } + break; + case "X": + try { + addSymptoms(Symptom.BACK_ACHE, symptoms); + } catch (Exception e) { + System.out.println("Invalid command! Please enter a valid symptom."); + } + break; + //@@Geeeetyx + case " ": + break; + //@@author Jeraldchen + default: + System.out.println(symptomChoice + " is not a valid symptom! " + symptomChoice + " will be ignored"); + break; + } + } + } + + //@@author Brennanzuz + /** + * Adds the users' inputted symptom into the symptoms array. + * + * @author brennanzuz + * @param symptom The symptom indicated by the user. Defined and passed from the case statement. + * @param symptoms List of symptoms + */ + private static void addSymptoms(Symptom symptom, ArrayList symptoms) { + if (!symptoms.contains(symptom)) { + assert symptom != null : symptom + " should not be null"; + symptoms.add(symptom); + } else { + System.out.println("You have already entered " + symptom + "!"); + } + } + + /** + * Displays a list of symptoms for users to pick out their symptoms from. + */ + private static void displaySymptomList() { + //Put all these in a dictionary with the symptom's display name hashed to the actual Symptom. + System.out.println("---------------------------------------------------"); + System.out.println("Here is the list of possible symptoms:"); + System.out.println("a. Fever"); + System.out.println("b. Dry Cough"); + System.out.println("c. Cough with Phlegm"); + System.out.println("d. Throat Irritation"); + System.out.println("e. Loss of Taste or Smell"); + System.out.println("f. Runny nose"); + System.out.println("g. Headache"); + System.out.println("h. Chills"); + System.out.println("i. Fatigue"); + System.out.println("j. Sneezing"); + System.out.println("k. Blocked Nose"); + System.out.println("l. Itchy eyes"); + System.out.println("m. Red eyes"); + System.out.println("n. Diarrhoea"); + System.out.println("o. Stomachache"); + System.out.println("p. Wet Stools"); + System.out.println("q. Hard or Lumpy Stools"); + System.out.println("r. Nausea"); + System.out.println("s. Vomiting"); + System.out.println("t. Sleeplessness"); + System.out.println("u. Blurred Vision"); + System.out.println("v. Sensitivity to Light and Sound"); + System.out.println("w. Muscle ache"); + System.out.println("x. Backache"); + System.out.println("\nPlease enter a symptom."); + System.out.println("---------------------------------------------------"); + } + + //@@author tanyizhe + /** + * Displays the possible illnesses that the user may have based on the symptoms he/she has entered. + * + * @author tanyizhe, Jeraldchen, Geeeetyx + * @param symptoms ArrayList of symptoms the user has entered. + */ + public static void displayPossibleIllness(ArrayList symptoms) { + ArrayList possibleIllnesses = Diagnosis.getPossibleIllnesses(symptoms); + + if (!possibleIllnesses.isEmpty()) { + System.out.println("==========================================================================" + + "=================="); + System.out.println("You may have: "); + for (IllnessMatch illnessMatch : possibleIllnesses) { + System.out.println(illnessMatch.getIllness().getIllnessName() + " Match: " + + String.format("%.2f", illnessMatch.getSimilarityPercentage() * 100) + + "%"); + } + System.out.println("-----------------------------------------------------------"); + } else { + //@@author JeraldChen + System.out.println("------------------------------------------------------------"); + System.out.println("Unable to diagnose illness. Please consult a Doctor instead."); + System.out.println("------------------------------------------------------------"); + } + } + //@@author tanyizhe + /** + * Displays prompt for user to input keyword when finding medicines. + */ + public static void displayFindMedicinePrompt() { + System.out.println("---------------------------------------------------"); + System.out.println("Please enter a keyword:"); + System.out.println("---------------------------------------------------"); + } + /** + * Displays message of results found when using find medicine features. + */ + public static void displayFindMedicineMessage(String phrase) { + System.out.println("---------------------------------------------------"); + System.out.println("Results for \"" + phrase + "\":"); + } + //@@author Geeeetyx + public static void displayEndOfDiagnosisMessage() { + System.out.println("End of diagnosis. Please proceed to your nearest pharmacy to purchase the " + + "above medications if applicable."); + System.out.println("==========================================================================" + + "=================="); + } +} diff --git a/src/main/java/seedu/duke/ui/Parser.java b/src/main/java/seedu/duke/ui/Parser.java new file mode 100644 index 0000000000..398e83eb23 --- /dev/null +++ b/src/main/java/seedu/duke/ui/Parser.java @@ -0,0 +1,160 @@ +//@@author JeraldChen +package seedu.duke.ui; + +import seedu.duke.Duke; +import seedu.duke.diagnosis.IllnessMatch; +import seedu.duke.diagnosis.symptoms.Symptom; +import seedu.duke.medicine.MedicineManager; +import seedu.duke.patient.Patient; + +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.Scanner; +import java.time.LocalDateTime; + +import static seedu.duke.save.Storage.saveData; +import static seedu.duke.save.Storage.saveQueue; + +public class Parser { + + /** + * Parses the user input for the main menu. + * @param choice Users choice of input. + */ + public static void parseWelcome(String choice) { + assert choice != null : "Choice cannot be null"; + switch (choice) { + case "1": + Menu.register(); + break; + case "2": + Menu.login(); + break; + case "3": + Menu.exit(); + break; + default: + System.out.println("Invalid input!"); + break; + } + } + + //@@author Thunderdragon221, Geeeetyx, tanyizhe + /** + * Parses the user input for the account menu. + * + * @param choice Users choice of input. + */ + public static void parseAccountCommand(String choice){ + assert choice != null : "Choice cannot be null"; + Patient user = Information.getPatientInfo(Duke.getPassword()); + MedicineManager medicineManager = new MedicineManager(); + + switch (choice) { + case "1": + try { + //@@author tanyizhe + ArrayList symptoms = Menu.getUserSymptoms(); + if (symptoms.isEmpty()) { + System.out.println("You have not entered any symptoms!"); + } else { + Menu.displayPossibleIllness(symptoms); + //@@author Geeeetyx + System.out.println("Below are some recommended medications for you to purchase:"); + System.out.println("-----------------------------------------------------------"); + //@@author tanyizhe + DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd"); + LocalDateTime now = LocalDateTime.now(); + ArrayList possibleIllnesses = medicineManager.analyseIllness(symptoms); + ArrayList diagnoses = new ArrayList<>(); + formatMedicineDate(user, medicineManager, dtf, now, possibleIllnesses, diagnoses); + if (diagnoses.size() > 0) { + user.updatePatientDiagnosisHistory(dtf.format(now), diagnoses); + } + saveData(); + saveQueue(); + } + } catch (Exception e) { + System.out.println("Invalid input!"); + } + break; + //@@author Thunderdragon221 + case "2": + Information.printDiagnosisHistory(Duke.getPassword()); + break; + case "3": + Information.resetDiagnosisHistory(Duke.getPassword()); + break; + //@@author Jeraldchen + case "4": + Information.viewSymptomHistory(Menu.symptoms); + break; + case "5": + boolean deleted = Information.deleteSymptom(Menu.symptoms); + if (deleted) { + //@@author Geeeetyx + ArrayList symptoms = Menu.symptoms; + if (!symptoms.isEmpty()) { + System.out.println("---------------------------------------------------"); + System.out.println("Below is your new diagnosis:"); + Menu.displayPossibleIllness(symptoms); + } + ArrayList possibleIllnesses = medicineManager.analyseIllness(symptoms); + //@@author Thunderdragon221 + ArrayList diagnoses = new ArrayList<>(); + DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd"); + LocalDateTime now = LocalDateTime.now(); + //@@author Geeeetyx + formatMedicineDate(user, medicineManager, dtf, now, possibleIllnesses, diagnoses); + //@@author Thunderdragon221 + if (diagnoses.size() > 0) { + user.updatePatientDiagnosisHistory(dtf.format(now), diagnoses); + } + saveData(); + saveQueue(); + } + break; + case "6": + Information.resetSymptomChoice(Menu.symptoms); + break; + //@@author tanyizhe + case "7": + user.printPatientMedicineHistory(); + break; + case "8": + medicineManager.listMedicines(); + break; + case "9": + Scanner phraseScanner = new Scanner(System.in); + Menu.displayFindMedicinePrompt(); + String phrase = phraseScanner.nextLine(); + Menu.displayFindMedicineMessage(phrase); + medicineManager.findMedicine(phrase); + break; + //@@author Geeeetyx + case "10": //show queue number + Information.printPatientQueueNumber(); + break; + case "0": + Menu.exit(); + break; + default: + System.out.println("Invalid input!"); + break; + } + } + //@@author tanyizhe + private static void formatMedicineDate(Patient user, MedicineManager medicineManager, + DateTimeFormatter dtf, LocalDateTime now, + ArrayList possibleIllnesses, + ArrayList diagnoses) { + for (IllnessMatch illnessMatch : possibleIllnesses) { + diagnoses.add(illnessMatch.getIllness().getIllnessName()); + ArrayList medicineArrayList = medicineManager + .getRelevantMedicationInString(illnessMatch.getIllness().getIllnessName()); + if (!(medicineArrayList == null)) { + user.updatePatientMedicineHistory(dtf.format(now), medicineArrayList); + } + } + } +} diff --git a/src/test/java/seedu/duke/diagnosis/DiagnosisTest.java b/src/test/java/seedu/duke/diagnosis/DiagnosisTest.java new file mode 100644 index 0000000000..a59b1beed3 --- /dev/null +++ b/src/test/java/seedu/duke/diagnosis/DiagnosisTest.java @@ -0,0 +1,302 @@ +package seedu.duke.diagnosis; + +import org.junit.jupiter.api.Test; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * JUnit test for testing of the output of Diagnosis.getPossibleIllnesses. Change the contents of the ArrayList to test + * for different illnesses. + */ +public class DiagnosisTest { + //@@BrennanZuz + @Test + public void diagnoseGeneralCold() { + ArrayList testSymptoms = new ArrayList<>(List.of( + Symptom.FATIGUE, + Symptom.RUNNY_NOSE, + Symptom.SNEEZING, + Symptom.CHILLS, + Symptom.FATIGUE, + Symptom.THROAT_IRRITATION)); + ArrayList testIllnesses = Diagnosis.getPossibleIllnesses(testSymptoms); + assertTrue(testIllnesses.stream() + .anyMatch(illnessMatch -> illnessMatch.getIllness().getIllnessName().equals("General Cold") + )); + } + + //@@author JeraldChen + @Test + public void diagnoseAsthma() { + ArrayList testSymptoms = new ArrayList<>(List.of(Symptom.HYPERVENTILATION, + Symptom.HISTORY_OF_ASTHMA, + Symptom.DIFFICULTY_BREATHING)); + ArrayList testIllnesses = Diagnosis.getPossibleIllnesses(testSymptoms); + assertTrue(testIllnesses.stream() + .anyMatch(illnessMatch -> illnessMatch.getIllness().getIllnessName().equals("Asthma") + )); + } + + //@@author JeraldChen + @Test + public void diagnoseGeneralAllergicReaction() { + ArrayList testSymptoms = new ArrayList<>(List.of(Symptom.HISTORY_OF_ALLERGIES)); + ArrayList testIllnesses = Diagnosis.getPossibleIllnesses(testSymptoms); + assertTrue(testIllnesses.stream() + .anyMatch(illnessMatch -> illnessMatch.getIllness().getIllnessName().equals("General Allergic Reaction") + )); + } + + //@@author JeraldChen + @Test + public void diagnoseBronchitis() { + ArrayList testSymptoms = new ArrayList<>(List.of(Symptom.THROAT_IRRITATION, + Symptom.HEAD_ACHE, + Symptom.RUNNY_NOSE, + Symptom.FATIGUE)); + ArrayList testIllnesses = Diagnosis.getPossibleIllnesses(testSymptoms); + assertTrue(testIllnesses.stream() + .anyMatch(illnessMatch -> illnessMatch.getIllness().getIllnessName().equals("Bronchitis") + )); + } + + //@@author JeraldChen + @Test + public void diagnoseGeneralBacterialInfection() { + ArrayList testSymptoms = new ArrayList<>(List.of(Symptom.PUSS, + Symptom.GENERAL_SWELLING + )); + ArrayList testIllnesses = Diagnosis.getPossibleIllnesses(testSymptoms); + assertTrue(testIllnesses.stream() + .anyMatch(illnessMatch -> + illnessMatch.getIllness().getIllnessName().equals("General Bacterial Infection") + )); + } + + //@@author JeraldChen + @Test + public void diagnosePneumonia() { + ArrayList testSymptoms = new ArrayList<>(List.of(Symptom.CHEST_PAIN, + Symptom.COUGH_WITH_PHLEGM, + Symptom.CHILLS, + Symptom.FEVER, + Symptom.FATIGUE, + Symptom.BREATHLESSNESS, + Symptom.NAUSEA, + Symptom.SNIFFING + )); + ArrayList testIllnesses = Diagnosis.getPossibleIllnesses(testSymptoms); + assertTrue(testIllnesses.stream() + .anyMatch(illnessMatch -> illnessMatch.getIllness().getIllnessName().equals("Pneumonia") + )); + + } + + //@@author JeraldChen + @Test + public void diagnoseSoreThroat() { + ArrayList testSymptoms = new ArrayList<>( + List.of(Symptom.THROAT_IRRITATION, + Symptom.COUGH_WITH_PHLEGM, + Symptom.DRY_COUGH + )); + ArrayList testIllnesses = Diagnosis.getPossibleIllnesses(testSymptoms); + assertTrue(testIllnesses.stream() + .anyMatch(illnessMatch -> illnessMatch.getIllness().getIllnessName().equals("Sore Throat") + )); + } + + //@@author JeraldChen + @Test + public void diagnoseTuberculosis() { + ArrayList testSymptoms = new ArrayList<>( + List.of(Symptom.DRY_COUGH, + Symptom.COUGH_WITH_PHLEGM, + Symptom.BLEEDING_WHEN_COUGHING, + Symptom.CHEST_PAIN + )); + ArrayList testIllnesses = Diagnosis.getPossibleIllnesses(testSymptoms); + assertTrue(testIllnesses.stream() + .anyMatch(illnessMatch -> illnessMatch.getIllness().getIllnessName().equals("Tuberculosis") + )); + } + + //@@author JeraldChen + @Test + public void diagnoseCoronaryHeartDisease() { + ArrayList testSymptoms = new ArrayList<>( + List.of(Symptom.HIGH_HEART_RATE, + Symptom.CHEST_PAIN, + Symptom.BREATHLESSNESS, + Symptom.NAUSEA, + Symptom.CHILLS + )); + ArrayList testIllnesses = Diagnosis.getPossibleIllnesses(testSymptoms); + assertTrue(testIllnesses.stream() + .anyMatch(illnessMatch -> illnessMatch.getIllness().getIllnessName().equals("Coronary Heart Disease") + )); + } + + //@@author JeraldChen + @Test + public void diagnoseHypertension() { + ArrayList testSymptoms = new ArrayList<>( + List.of(Symptom.HIGH_HEART_RATE, + Symptom.HEAD_ACHE, + Symptom.BLURRED_VISION, + Symptom.SENSITIVITY_TO_LIGHT_AND_SOUND, + Symptom.FEVER + )); + ArrayList testIllnesses = Diagnosis.getPossibleIllnesses(testSymptoms); + assertTrue(testIllnesses.stream() + .anyMatch(illnessMatch -> + illnessMatch.getIllness().getIllnessName().equals("Hypertension (High Blood Pressure)") + )); + } + + //@@author JeraldChen + @Test + public void diagnoseGeneralToothAche() { + ArrayList testSymptoms = new ArrayList<>( + List.of(Symptom.TOOTH_ACHE + )); + ArrayList testIllnesses = Diagnosis.getPossibleIllnesses(testSymptoms); + assertTrue(testIllnesses.stream() + .anyMatch(illnessMatch -> + illnessMatch.getIllness().getIllnessName().equals("Tooth Ache") + )); + } + + //@@author JeraldChen + @Test + public void diagnoseToothDecay() { + ArrayList testSymptoms = new ArrayList<>( + List.of(Symptom.TOOTH_ACHE, + Symptom.BLACK_TEETH + )); + ArrayList testIllnesses = Diagnosis.getPossibleIllnesses(testSymptoms); + assertTrue(testIllnesses.stream() + .anyMatch(illnessMatch -> + illnessMatch.getIllness().getIllnessName().equals("Tooth Decay") + )); + } + + //@@author JeraldChen + @Test + public void diagnoseGeneralRash() { + ArrayList testSymptoms = new ArrayList<>( + List.of(Symptom.ITCHY_SKIN, + Symptom.RED_SKIN + )); + ArrayList testIllnesses = Diagnosis.getPossibleIllnesses(testSymptoms); + assertTrue(testIllnesses.stream() + .anyMatch(illnessMatch -> + illnessMatch.getIllness().getIllnessName().equals("Rashes") + )); + } + + //@@author JeraldChen + @Test + public void diagnoseHives() { + ArrayList testSymptoms = new ArrayList<>( + List.of(Symptom.ITCHY_EYE, + Symptom.RED_SKIN, + Symptom.SWELLING_SKIN + )); + ArrayList testIllnesses = Diagnosis.getPossibleIllnesses(testSymptoms); + assertTrue(testIllnesses.stream() + .anyMatch(illnessMatch -> + illnessMatch.getIllness().getIllnessName().equals("Hives") + )); + } + + //@@author JeraldChen + @Test + public void diagnosePsoriasis() { + ArrayList testSymptoms = new ArrayList<>( + List.of(Symptom.ITCHY_SKIN, + Symptom.RED_SKIN, + Symptom.DRY_SCALING_SKIN + )); + ArrayList testIllnesses = Diagnosis.getPossibleIllnesses(testSymptoms); + assertTrue(testIllnesses.stream() + .anyMatch(illnessMatch -> + illnessMatch.getIllness().getIllnessName().equals("Psoriasis") + )); + } + + //@@author JeraldChen + @Test + public void diagnoseConstipation() { + ArrayList testSymptoms = new ArrayList<>( + List.of(Symptom.HARD_LUMPY_STOOL + )); + ArrayList testIllnesses = Diagnosis.getPossibleIllnesses(testSymptoms); + assertTrue(testIllnesses.stream() + .anyMatch(illnessMatch -> + illnessMatch.getIllness().getIllnessName().equals("Constipation") + )); + } + + //@@author JeraldChen + @Test + public void diagnoseDiarrhoea() { + ArrayList testSymptoms = new ArrayList<>( + List.of(Symptom.WET_STOOL, + Symptom.STOMACH_ACHE, + Symptom.DIARRHOEA + )); + ArrayList testIllnesses = Diagnosis.getPossibleIllnesses(testSymptoms); + assertTrue(testIllnesses.stream() + .anyMatch(illnessMatch -> + illnessMatch.getIllness().getIllnessName().equals("Diarrhoea") + )); + } + + //@@author JeraldChen + @Test + public void diagnoseFoodPoisoning() { + ArrayList testSymptoms = new ArrayList<>( + List.of(Symptom.DIARRHOEA, + Symptom.STOMACH_ACHE, + Symptom.NAUSEA, + Symptom.VOMITING, + Symptom.FEVER + )); + ArrayList testIllnesses = Diagnosis.getPossibleIllnesses(testSymptoms); + assertTrue(testIllnesses.stream() + .anyMatch(illnessMatch -> + illnessMatch.getIllness().getIllnessName().equals("Food Poisoning") + )); + } + + //@@author JeraldChen + @Test + public void diagnoseGeneralStomachAche() { + ArrayList testSymptoms = new ArrayList<>( + List.of(Symptom.STOMACH_ACHE + )); + ArrayList testIllnesses = Diagnosis.getPossibleIllnesses(testSymptoms); + assertTrue(testIllnesses.stream() + .anyMatch(illnessMatch -> + illnessMatch.getIllness().getIllnessName().equals("Stomach Ache") + )); + } + + //@@author JeraldChen + @Test + public void diagnoseHemorrhoids() { + ArrayList testSymptoms = new ArrayList<>( + List.of(Symptom.BLOODIED_STOOLS + )); + ArrayList testIllnesses = Diagnosis.getPossibleIllnesses(testSymptoms); + assertTrue(testIllnesses.stream() + .anyMatch(illnessMatch -> + illnessMatch.getIllness().getIllnessName().equals("Hemorrhoids") + )); + } +} diff --git a/src/test/java/seedu/duke/information/InformationTest.java b/src/test/java/seedu/duke/information/InformationTest.java new file mode 100644 index 0000000000..5a8841dc32 --- /dev/null +++ b/src/test/java/seedu/duke/information/InformationTest.java @@ -0,0 +1,42 @@ +//@@author Jeraldchen +package seedu.duke.information; + +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.HashMap; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class InformationTest { + //@@author Jeraldchen + @Test + public void resetDiagosisHistory() { + ArrayList diagnosisHistory = new ArrayList<>(); + diagnosisHistory.add("Diagnosis 1"); + diagnosisHistory.add("Diagnosis 2"); + diagnosisHistory.clear(); + assertEquals(diagnosisHistory.size(), 0); + } + + //@@author Jeraldchen + @Test + public void checkPassword() { + HashMap personalInfo = new HashMap<>(); + String password = "iloveCS2113"; + String name = "Akshay"; + personalInfo.put(password, name); + assertEquals(personalInfo.containsKey(password), true); + + } + + //@@author Jeraldchen + @Test + public void resetSymptoms() { + ArrayList symptoms = new ArrayList<>(); + symptoms.add("Symptom 1"); + symptoms.add("Symptom 2"); + symptoms.clear(); + assertEquals(symptoms.size(), 0); + } +} diff --git a/src/test/java/seedu/duke/medicine/MedicineManagerTest.java b/src/test/java/seedu/duke/medicine/MedicineManagerTest.java new file mode 100644 index 0000000000..d814c0c86e --- /dev/null +++ b/src/test/java/seedu/duke/medicine/MedicineManagerTest.java @@ -0,0 +1,105 @@ +//@@author tanyizhe +package seedu.duke.medicine; + +import org.junit.jupiter.api.Test; +import seedu.duke.diagnosis.IllnessMatch; +import seedu.duke.diagnosis.symptoms.Symptom; + +import java.util.ArrayList; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNull; + +class MedicineManagerTest { + @Test + public void getDosage_basedOnMedicine_expectCorrectDosage() { + String input = "Aspirin"; + MedicineManager medicineManager = new MedicineManager(); + System.out.println(medicineManager.getMedicineDosages(input)); + assertEquals("1 or 2 pills every 4 to 6 hours", medicineManager.getMedicineDosages(input)); + } + @Test + public void getDosage_whenNoMedicine_expectNull() { + String input = ""; + MedicineManager medicineManager = new MedicineManager(); + System.out.println(medicineManager.getMedicineDosages(input)); + assertNull(medicineManager.getMedicineDosages(input)); + } + @Test + public void haveTooFewSymptoms_expectEmpty() { + MedicineManager medicineManager = new MedicineManager(); + ArrayList symptoms = new ArrayList<>(); + symptoms.add(Symptom.WET_STOOL); + ArrayList possibleIllnesses = medicineManager.analyseIllness(symptoms); + assertTrue(possibleIllnesses.isEmpty()); + } + @Test + public void getFever_expectCorrectMedicine() { + MedicineManager medicineManager = new MedicineManager(); + ArrayList symptoms = new ArrayList<>(); + symptoms.add(Symptom.FEVER); + ArrayList possibleIllnesses = medicineManager.analyseIllness(symptoms); + ArrayList medicineArrayList = new ArrayList<>(); + for (IllnessMatch illnessMatch : possibleIllnesses) { + medicineArrayList = medicineManager + .getRelevantMedicationInString(illnessMatch.getIllness().getIllnessName()); + } + assertEquals("Paracetamol", medicineArrayList.get(0)); + } + @Test + public void getBronchitis_expectCorrectMedicine() { + MedicineManager medicineManager = new MedicineManager(); + ArrayList symptoms = new ArrayList<>(); + symptoms.add(Symptom.THROAT_IRRITATION); + symptoms.add(Symptom.HEAD_ACHE); + symptoms.add(Symptom.RUNNY_NOSE); + symptoms.add(Symptom.FATIGUE); + ArrayList possibleIllnesses = medicineManager.analyseIllness(symptoms); + ArrayList medicineArrayList = new ArrayList<>(); + medicineArrayList = medicineManager + .getRelevantMedicationInString(possibleIllnesses.get(0).getIllness().getIllnessName()); + assertEquals("Guaifenesin", medicineArrayList.get(0)); + assertEquals("Ibuprofen", medicineArrayList.get(1)); + } + @Test + public void getSoreThroat_expectCorrectMedicine() { + MedicineManager medicineManager = new MedicineManager(); + ArrayList symptoms = new ArrayList<>(); + symptoms.add(Symptom.THROAT_IRRITATION); + symptoms.add(Symptom.COUGH_WITH_PHLEGM); + symptoms.add(Symptom.DRY_COUGH); + ArrayList possibleIllnesses = medicineManager.analyseIllness(symptoms); + ArrayList medicineArrayList = new ArrayList<>(); + medicineArrayList = medicineManager + .getRelevantMedicationInString(possibleIllnesses.get(0).getIllness().getIllnessName()); + assertEquals("Lozenges", medicineArrayList.get(0)); + } + @Test + public void getDiarrhoea_expectCorrectMedicine() { + MedicineManager medicineManager = new MedicineManager(); + ArrayList symptoms = new ArrayList<>(); + symptoms.add(Symptom.WET_STOOL); + symptoms.add(Symptom.STOMACH_ACHE); + symptoms.add(Symptom.DIARRHOEA); + ArrayList possibleIllnesses = medicineManager.analyseIllness(symptoms); + ArrayList medicineArrayList = new ArrayList<>(); + medicineArrayList = medicineManager + .getRelevantMedicationInString(possibleIllnesses.get(0).getIllness().getIllnessName()); + assertEquals("Ultracarbon", medicineArrayList.get(0)); + assertEquals("Diphenoxylate", medicineArrayList.get(1)); + } + @Test + public void getRashesOrHivesOrPsoriasis_expectNoMedicine() { + MedicineManager medicineManager = new MedicineManager(); + ArrayList symptoms = new ArrayList<>(); + symptoms.add(Symptom.DRY_SCALING_SKIN); + symptoms.add(Symptom.RED_SKIN); + symptoms.add(Symptom.ITCHY_SKIN); + ArrayList possibleIllnesses = medicineManager.analyseIllness(symptoms); + ArrayList medicineArrayList = new ArrayList<>(); + medicineArrayList = medicineManager + .getRelevantMedicationInString(possibleIllnesses.get(0).getIllness().getIllnessName()); + assertNull(medicineArrayList); + } +} diff --git a/src/test/java/seedu/duke/menu/MenuTest.java b/src/test/java/seedu/duke/menu/MenuTest.java new file mode 100644 index 0000000000..513ae256c7 --- /dev/null +++ b/src/test/java/seedu/duke/menu/MenuTest.java @@ -0,0 +1,39 @@ +//@@author Jeraldchen +package seedu.duke.menu; + +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.HashMap; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class MenuTest { + //@@author Jeraldchen + @Test + public void registerPatient() { + String name = "Tom"; + String password1 = "iloveCS2113"; + String password2 = "iloveCS2113"; + + HashMap personalInfo = new HashMap<>(); + if (password1 == password2) { + personalInfo.put(name, password1); + } + + assertEquals(personalInfo.get(name), password1); + } + + //@@author Jeraldchen + @Test + public void addSymptomsToSymptomsList() { + String symptom = "Fever"; + String symptom2 = "Cough"; + ArrayList symptomsList = new ArrayList<>(); + symptomsList.add(symptom); + symptomsList.add(symptom2); + assertEquals(symptomsList.get(0), symptom); + assertEquals(symptomsList.get(1), symptom2); + } + +} diff --git a/src/test/java/seedu/duke/patient/PatientTest.java b/src/test/java/seedu/duke/patient/PatientTest.java new file mode 100644 index 0000000000..932bedf86f --- /dev/null +++ b/src/test/java/seedu/duke/patient/PatientTest.java @@ -0,0 +1,88 @@ +//@@author Geeeetyx +package seedu.duke.patient; + +import org.junit.jupiter.api.Test; +import seedu.duke.ui.Information; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.Hashtable; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * Class of test methods to test the Patient class's methods. + */ +public class PatientTest { + private final String testName = "Akshay"; + private final String testPassword = "iloveCS2113"; + private final Hashtable> testDiagnosisHistory = new Hashtable<>(); + private final Hashtable> testMedicineHistory = new Hashtable<>(); + + @Test + public void createNewPatientTest() { + + Hashtable> dummyDiagnosisHistory = new Hashtable<>(); + + Patient testPatient = new Patient( + testName, Information.hashPassword(testPassword), testDiagnosisHistory, testMedicineHistory); + + assertEquals(testPatient.getName(), "Akshay"); + assertEquals(testPatient.getPassword(), Information.hashPassword("iloveCS2113")); + assertEquals(dummyDiagnosisHistory, testPatient.getPatientDiagnosisHistory()); + + } + + //@@author Thunderdragon221 + @Test + public void testUpdatePatientDiagnosisHistory() { + + Hashtable> dummyPatientDiagnosisHistory = new Hashtable<>(); + ArrayList dummyPatientDiagnoses = new ArrayList<>(); + dummyPatientDiagnoses.add("Flu"); + dummyPatientDiagnoses.add("Fever"); + dummyPatientDiagnoses.add("COVID-19"); + dummyPatientDiagnosisHistory.put("2023/01/01", dummyPatientDiagnoses); + + Patient testPatient = new Patient( + testName, Information.hashPassword(testPassword), testDiagnosisHistory, testMedicineHistory); + + ArrayList testPatientDiagnoses = new ArrayList<>(); + testPatientDiagnoses.add("Flu"); + testPatientDiagnoses.add("Fever"); + testPatientDiagnoses.add("COVID-19"); + testPatient.updatePatientDiagnosisHistory("2023/01/01", testPatientDiagnoses); + + assertEquals(dummyPatientDiagnosisHistory, testPatient.getPatientDiagnosisHistory()); + + } + + //@@author Geeeetyx + @Test + public void testUpdatePatientMedicineHistory() { + + DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd"); + LocalDateTime now = LocalDateTime.now(); + + String testDate = dtf.format(now); + + Hashtable> dummyMedicineHistory = new Hashtable<>(); + ArrayList dummyMedicineArrayList = new ArrayList<>(); + + dummyMedicineArrayList.add("Ultracarbon"); + dummyMedicineArrayList.add("Paracetamol"); + dummyMedicineArrayList.add("Ibuprofen"); + dummyMedicineArrayList.add("Aspirin"); + + dummyMedicineHistory.put(testDate, dummyMedicineArrayList); + + Patient testPatient = new Patient( + testName, Information.hashPassword(testPassword), testDiagnosisHistory, testMedicineHistory); + + testPatient.updatePatientMedicineHistory(testDate, dummyMedicineArrayList); + + assertEquals(dummyMedicineHistory, testPatient.getPatientMedicineHistory()); + } +} +//@@author diff --git a/src/test/java/seedu/duke/save/StorageTest.java b/src/test/java/seedu/duke/save/StorageTest.java new file mode 100644 index 0000000000..5453fbabeb --- /dev/null +++ b/src/test/java/seedu/duke/save/StorageTest.java @@ -0,0 +1,278 @@ +//@@author Thunderdragon221 +package seedu.duke.save; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import seedu.duke.patient.Patient; +import seedu.duke.stubs.InformationStub; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Scanner; +import java.util.ArrayList; +import java.util.Map; +import java.util.List; +import java.util.Collections; +import java.util.Hashtable; + +/** + * Class containing test methods to test the methods in the Storage class. + */ + +public class StorageTest { + + /** Specifies the directory path to be created */ + private static final String DUMMY_DIR_PATH = "./dummy-data/"; + + /** Specifies the file path to be created */ + private static final String DUMMY_FILE_PATH = "./dummy-data/dummy-patient-data.txt"; + + private static final String DUMMY_QUEUE_PATH = "/dummy-data/dummy_queue_data.txt"; + + private static final String DUMMY_FILE_PATH_TEST = "./dummy-data/dummy-patient-data-2.txt"; + + private static final String DUMMY_QUEUE_PATH_TEST = "./dummy-data/dummy_queue_data_2.txt"; + + @Test + public void createDirectory() { + Path path = Paths.get(DUMMY_DIR_PATH); + try { + Files.createDirectories(path); + } catch (IOException e) { + Assertions.assertFalse(false); + } + Assertions.assertTrue(Files.exists(path)); + Assertions.assertTrue(Files.isDirectory(path)); + } + + @Test + public void createFile() { + Path path = Paths.get(DUMMY_FILE_PATH); + try { + Files.createFile(path); + } catch (IOException e) { + Assertions.assertFalse(false); + } + Assertions.assertTrue(Files.exists(path)); + Assertions.assertTrue(Files.isRegularFile(path)); + } + + @Test + public void emptyField() { + String data = ""; + Assertions.assertTrue(data.matches("^ *$")); + } + + @Test + public void saveData() { + createDirectory(); + createFile(); + + String data = ""; + try { + FileWriter writer = new FileWriter(DUMMY_FILE_PATH); + for (Map.Entry entry : InformationStub.getAllPatientData().entrySet()) { + Patient patient = entry.getValue(); + String name = patient.getName(); + int password = patient.getPassword(); + Hashtable> diagnosisHistory = patient.getPatientDiagnosisHistory(); + int numberOfDiagnoses = diagnosisHistory.size(); + Hashtable> medicineHistory = patient.getPatientMedicineHistory(); + int numberOfMedicines = medicineHistory.size(); + + data += password + "\n"; + data += name + "\n"; + data += numberOfDiagnoses + "\n"; + List diagnosisDates = Collections.list(diagnosisHistory.keys()); + Collections.sort(diagnosisDates); + for (String date : diagnosisDates) { + data += date + "%"; + for (String diagnosisString : diagnosisHistory.get(date)) { + data += diagnosisString + "%"; + } + } + if (diagnosisDates.size() > 0) { + data += "\n"; + } + data += numberOfMedicines + "\n"; + List dates = Collections.list(medicineHistory.keys()); + Collections.sort(dates); + for (String date : dates) { + data += date + "%"; + for (String medString : medicineHistory.get(date)) { + data += medString + "%"; + } + } + if (dates.size() > 0) { + data += "\n"; + } + } + int fileHash = data.hashCode(); + data = fileHash + "\n" + data; + writer.write(data); + writer.close(); + + Path path = Paths.get(DUMMY_FILE_PATH); + // Create dummy file with identical data to test corruption checking + Path pathTest = Paths.get(DUMMY_FILE_PATH_TEST); + + Files.createFile(path); + FileWriter writerTest = new FileWriter(DUMMY_FILE_PATH_TEST); + String dataTest = ""; + dataTest += 1 + "\nJerry\n" + 1 + "\n2023/01/01%Fever%\n" + 1 + "\n2023/01/01%Paracetamol%\n"; + int fileHashTest = dataTest.hashCode(); + dataTest = fileHashTest + "\n" + dataTest; + writerTest.write(dataTest); + writerTest.close(); + + byte[] pathBytes = Files.readAllBytes(path); + byte[] pathTestBytes = Files.readAllBytes(pathTest); + + Assertions.assertArrayEquals(pathBytes, pathTestBytes); + } catch (IOException e) { + Assertions.assertFalse(false); + } + } + + @Test + public void loadData() { + createDirectory(); + createFile(); + saveData(); + + try { + File file = new File(DUMMY_FILE_PATH); + Scanner scanner = new Scanner(file); + String dataCompare = ""; + + while (scanner.hasNextLine()) { + int fileHash = Integer.parseInt(scanner.nextLine()); + String password = scanner.nextLine(); + String name = scanner.nextLine(); + int hash = Integer.parseInt(password); + dataCompare += hash + "\n" + name + "\n"; + + int numberOfEntries = Integer.parseInt(scanner.nextLine()); + dataCompare += numberOfEntries + "\n"; + Hashtable> diagnosisHistory = new Hashtable<>(); + for (int i = 0; i < numberOfEntries; i++) { + String dateDiagnosisString = scanner.nextLine(); + dataCompare += dateDiagnosisString + "\n"; + String[] splitDateDiagnosisStrings = dateDiagnosisString.split("%"); + ArrayList diagnoses = new ArrayList<>(); + for (int diagnosisStringCount = 1; diagnosisStringCount < splitDateDiagnosisStrings.length; + diagnosisStringCount++) { + diagnoses.add(splitDateDiagnosisStrings[diagnosisStringCount]); + } + String date = splitDateDiagnosisStrings[0]; + diagnosisHistory.put(date, diagnoses); + } + + int numberOfMedicineEntries = Integer.parseInt(scanner.nextLine()); + dataCompare += numberOfMedicineEntries + "\n"; + Hashtable> medicineHistory = new Hashtable(); + for (int entry = 0; entry < numberOfMedicineEntries; entry++) { + String dateMedicineString = scanner.nextLine(); + dataCompare += dateMedicineString + "\n"; + String[] splitDateMedicineStrings = dateMedicineString.split("%"); + ArrayList medicines = new ArrayList<>(); + for (int medStringCount = 1; medStringCount < splitDateMedicineStrings.length; medStringCount++) { + medicines.add(splitDateMedicineStrings[medStringCount]); + } + medicineHistory.put(splitDateMedicineStrings[0], medicines); + } + int fileHashCompare = dataCompare.hashCode(); + + Assertions.assertEquals(name, "Jerry"); + Assertions.assertEquals(hash, 1); + Assertions.assertEquals(numberOfEntries, 1); + Assertions.assertEquals(diagnosisHistory.size(), 1); + Assertions.assertTrue(diagnosisHistory.containsKey("2023/01/01")); + Assertions.assertEquals(diagnosisHistory.get("2023/01/01").size(), 1); + Assertions.assertTrue(diagnosisHistory.get("2023/01/01").get(0).equals("Fever")); + Assertions.assertEquals(numberOfMedicineEntries, 1); + Assertions.assertEquals(medicineHistory.size(), 1); + Assertions.assertTrue(medicineHistory.containsKey("2023/01/01")); + Assertions.assertEquals(medicineHistory.get("2023/01/01").size(), 1); + Assertions.assertTrue(medicineHistory.get("2023/01/01").get(0).equals("Paracetamol")); + Assertions.assertEquals(fileHash, fileHashCompare); + } + scanner.close(); + } catch (IOException e) { + Assertions.assertFalse(false); + } + } + + @Test + public void saveQueue() { + createDirectory(); + createFile(); + + String data = ""; + try { + FileWriter writer = new FileWriter(DUMMY_QUEUE_PATH); + ArrayList queueList = InformationStub.getQueueList(); + for (String queueNumber : queueList) { + data += queueNumber + "\n"; + } + int fileHash = data.hashCode(); + data = fileHash + "\n" + data; + writer.write(data); + writer.close(); + + Path path = Paths.get(DUMMY_QUEUE_PATH); + // Create dummy file with identical data to test corruption checking + Path pathTest = Paths.get(DUMMY_QUEUE_PATH_TEST); + + Files.createFile(path); + FileWriter writerTest = new FileWriter(DUMMY_QUEUE_PATH_TEST); + String dataTest = "1\n"; + int fileHashTest = dataTest.hashCode(); + dataTest = fileHashTest + "\n" + dataTest; + writerTest.write(dataTest); + writerTest.close(); + + byte[] pathBytes = Files.readAllBytes(path); + byte[] pathTestBytes = Files.readAllBytes(pathTest); + + Assertions.assertArrayEquals(pathBytes, pathTestBytes); + } catch (IOException e) { + Assertions.assertFalse(false); + } + } + + @Test + public void loadQueue() { + createDirectory(); + createFile(); + saveQueue(); + + try { + File file = new File(DUMMY_QUEUE_PATH); + Scanner scanner = new Scanner(file); + String dataCompare = ""; + + while (scanner.hasNextLine()) { + int fileHash = Integer.parseInt(scanner.nextLine()); + ArrayList queueList = new ArrayList<>(); + while (scanner.hasNextLine()) { + String line = scanner.nextLine(); + dataCompare += line + "\n"; + queueList.add(line); + } + int fileHashCompare = dataCompare.hashCode(); + + Assertions.assertEquals(queueList.size(), 1); + Assertions.assertEquals(queueList.get(0), "1"); + Assertions.assertEquals(fileHash, fileHashCompare); + } + scanner.close(); + } catch (IOException e) { + Assertions.assertFalse(false); + } + } +} diff --git a/src/test/java/seedu/duke/stubs/InformationStub.java b/src/test/java/seedu/duke/stubs/InformationStub.java new file mode 100644 index 0000000000..a3923c22ee --- /dev/null +++ b/src/test/java/seedu/duke/stubs/InformationStub.java @@ -0,0 +1,22 @@ +//@@author Thunderdragon221 +package seedu.duke.stubs; + +import seedu.duke.patient.Patient; + +import java.util.ArrayList; +import java.util.HashMap; + +public class InformationStub { + + public static HashMap getAllPatientData() { + HashMap dummyPatientsList = new HashMap<>(); + dummyPatientsList.put(PatientStub.getHash(), PatientStub.getDummyPatient()); + return dummyPatientsList; + } + + public static ArrayList getQueueList() { + ArrayList queueList = new ArrayList<>(); + queueList.add("1"); + return queueList; + } +} diff --git a/src/test/java/seedu/duke/stubs/PatientStub.java b/src/test/java/seedu/duke/stubs/PatientStub.java new file mode 100644 index 0000000000..c721495699 --- /dev/null +++ b/src/test/java/seedu/duke/stubs/PatientStub.java @@ -0,0 +1,31 @@ +//@@author Thunderdragon221 +package seedu.duke.stubs; + +import seedu.duke.patient.Patient; + +import java.util.ArrayList; +import java.util.Hashtable; + +public class PatientStub { + + public static Patient getDummyPatient() { + Hashtable> dummyPatientDiagnosisHistory = new Hashtable<>(); + ArrayList dummydiagnoses = new ArrayList<>(); + dummydiagnoses.add("Fever"); + dummyPatientDiagnosisHistory.put("2023/01/01", dummydiagnoses); + + Hashtable> dummyPatientMedicineHistory = new Hashtable<>(); + ArrayList dummyMedicines = new ArrayList<>(); + dummyMedicines.add("Paracetamol"); + dummyPatientMedicineHistory.put("2023/01/01", dummyMedicines); + + String dummyName = "Jerry"; + int dummyHash = 1; + return new Patient(dummyName, dummyHash, dummyPatientDiagnosisHistory, + dummyPatientMedicineHistory); + } + + public static int getHash() { + return 1; + } +} diff --git a/src/test/java/seedu/duke/symptom/SymptomTest.java b/src/test/java/seedu/duke/symptom/SymptomTest.java new file mode 100644 index 0000000000..6a4f80dfaf --- /dev/null +++ b/src/test/java/seedu/duke/symptom/SymptomTest.java @@ -0,0 +1,37 @@ +package seedu.duke.symptom; + +import org.junit.jupiter.api.Test; +import seedu.duke.diagnosis.symptoms.Symptom; +import seedu.duke.diagnosis.symptoms.SymptomHandler; + +import java.util.ArrayList; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * JUnit test for testing of the output of SymptomHandler.printSymptoms. Change the contents of the ArrayList to test + * for different symptoms. + */ +public class SymptomTest { + @Test + public void printSymptoms() { + ArrayList testSymptoms = new ArrayList<>(List.of( + Symptom.FATIGUE, + Symptom.RUNNY_NOSE, + Symptom.SNEEZING, + Symptom.CHILLS, + Symptom.FATIGUE, + Symptom.THROAT_IRRITATION)); + ArrayList testSymptomNames = new ArrayList<>(List.of( + "fatigue", + "runny nose", + "persistent sneezing", + "chills", + "fatigue", + "throat irritation")); + for (int i = 0; i < testSymptomNames.size(); i += 1) { + assertEquals(SymptomHandler.toString(testSymptoms.get(i)), testSymptomNames.get(i)); + } + } +} diff --git a/text-ui-test/ACTUAL.TXT b/text-ui-test/ACTUAL.TXT new file mode 100644 index 0000000000..586757d528 --- /dev/null +++ b/text-ui-test/ACTUAL.TXT @@ -0,0 +1,21 @@ +Hello I am + ____ ____ _ +| _ \ ___ | _ \ _ _ | | _____ +| | | |/ _ \ | | | | | | | |/ / _ \ +| |_| | | | |_| | |_| | < __/ +|____/|_| |____/ \__,_|_|\_\___| + +--------------------------------------------------- +What would you like to do? Please enter the number: +1. Register +2. Login +3. Exit +--------------------------------------------------- +--------------------------------------------------- +Thank you for using + ____ ____ _ +| _ \ ___ | _ \ _ _ | | _____ +| | | |/ _ \ | | | | | | | |/ / _ \ +| |_| | | | |_| | |_| | < __/ +|____/|_| |____/ \__,_|_|\_\___| +--------------------------------------------------- diff --git a/text-ui-test/EXPECTED.TXT b/text-ui-test/EXPECTED.TXT index 892cb6cae7..586757d528 100644 --- a/text-ui-test/EXPECTED.TXT +++ b/text-ui-test/EXPECTED.TXT @@ -1,9 +1,21 @@ -Hello from - ____ _ -| _ \ _ _| | _____ -| | | | | | | |/ / _ \ -| |_| | |_| | < __/ -|____/ \__,_|_|\_\___| +Hello I am + ____ ____ _ +| _ \ ___ | _ \ _ _ | | _____ +| | | |/ _ \ | | | | | | | |/ / _ \ +| |_| | | | |_| | |_| | < __/ +|____/|_| |____/ \__,_|_|\_\___| -What is your name? -Hello James Gosling +--------------------------------------------------- +What would you like to do? Please enter the number: +1. Register +2. Login +3. Exit +--------------------------------------------------- +--------------------------------------------------- +Thank you for using + ____ ____ _ +| _ \ ___ | _ \ _ _ | | _____ +| | | |/ _ \ | | | | | | | |/ / _ \ +| |_| | | | |_| | |_| | < __/ +|____/|_| |____/ \__,_|_|\_\___| +--------------------------------------------------- diff --git a/text-ui-test/input.txt b/text-ui-test/input.txt index f6ec2e9f95..00750edc07 100644 --- a/text-ui-test/input.txt +++ b/text-ui-test/input.txt @@ -1 +1 @@ -James Gosling \ No newline at end of file +3