Open pradyuprasad opened 2 days ago
We planned to use the tags
attribute (SetPerson
class to mark someone as a patient or caregiver.
Create a Role
enum (with PATIENT
and CAREGIVER
) and add a Set<Role>
to the Person
class.
We'll add two new fields to Person:
These will store the IC numbers of a person's dependents and caregivers.
I chose "dependent" instead of "patient" to avoid confusion with the PATIENT role we already have.
By storing just the IC numbers, we can:
We'll need to add methods like:
And update equals(), hashCode(), and toString() to include these new fields.
Also, we'll need to update other parts of the code that work with Person objects
Feature: Add Patient and Caregiver Details with Validation
TODO
equals
method to check for NRIC onlyisSamePerson
to check for NRIC onlyRole
enum to show kinds of roles (at the moment Patient and Caregiver)roles
inside Person classrole
to /add commandAdd
class toStep 1: Add Patient Details
Command Format:
addpatient /fname /lname /nric /phone /address /email
Example Commands:
addpatient /fname John /lname Doe /nric S1234567A /phone 91234567 /address 123 Clementi Ave /email john.doe@example.com addpatient /fname Sarah /lname Tan /nric T9876543Z /phone 98765432 /address 45 Upper Thomson /email sarah.tan@example.com
Parameters and Validation:
1. First Name (fname)
Acceptable Values:
Error Message:
"First name must contain only alphabetical characters and cannot exceed 50 characters."
2. Last Name (lname)
Acceptable Values:
Error Message:
"Last name must contain only alphabetical characters and cannot exceed 50 characters."
3. NRIC (nric)
Acceptable Values:
Error Message:
"NRIC must be in the valid Singapore NRIC format (e.g., S1234567A or T9876543Z)."
4. Phone (phone)
Acceptable Values:
Error Message:
"Phone number must be 8 digits and start with 6, 8, or 9."
5. Address (address)
Acceptable Values:
Error Message:
"Address must not exceed 100 characters."
6. Email (email)
Acceptable Values:
Error Message:
"Email must be in a valid email format (e.g., example@example.com)."
Outputs:
On Success:
"Patient <First Name> <Last Name> has been successfully added."
On Failure:
"NRIC must be in the valid Singapore NRIC format"
).Step 2: Add Caregiver Details and Link to Patient
Command Format:
addcaregiver /fname /lname /nric /phone /address /email /patientid
Example Commands:
addcaregiver /fname Emma /lname Tan /nric S2345678B /phone 91234567 /address 456 Yishun Ave /email emma.tan@example.com /patientid 1 addcaregiver /fname Liam /lname Lee /nric T8765432Y /phone 87654321 /address 78 Serangoon Ave /email liam.lee@example.com /patientid 2
Parameters and Validation:
1. First Name (fname)
2. Last Name (lname)
3. NRIC (nric)
4. Phone (phone)
5. Address (address)
6. Email (email)
7. Patient ID (patientid)
Acceptable Values:
Error Message:
"Patient ID must refer to an existing patient."
Outputs:
On Success:
"Caregiver <First Name> <Last Name> has been successfully added and linked to patient <Patient ID>."
On Failure:
"Patient ID must refer to an existing patient."
Duplicate Handling:
For Patients:
"Patient with NRIC <NRIC> already exists in the system."
For Caregivers:
"Caregiver with NRIC <NRIC> already exists in the system."