diff --git a/docs/UserGuide.md b/docs/UserGuide.md
index cc517bf9aeb..49841d4c839 100644
--- a/docs/UserGuide.md
+++ b/docs/UserGuide.md
@@ -114,8 +114,11 @@ A doctor can have any number of tags (including 0). Duplicate tags, however, are
**:information_source: Take Note:**
-- A doctor cannot have the same NRIC as another person.
-- A person can either be a doctor or a patient, but not both. Hence, if the doctor's NRIC is already in the app
+- A doctor **MUST** have all fields non-empty except TAG.
+ Failure to include these details may result in an error.
+- The order is not important (i.e, IC can come before NAME). What matters is that all the mandatory fields are declared,
+and the format for each field is adhered to.
+- A person can either be a doctor or a patient, but not both. Hence if the doctor's IC is already in the app
as a patient, it may result in an error.
- Adding additional prefixes (eg. `b/O+`) not specified by the command format above will be considered as a **parameter input**. For example:
`add-doctor n/John Doe ic/S9851386G g/M p/98765432 e/johnd@example.com a/John street, block 123, #01-01 b/O+` will result
@@ -130,6 +133,64 @@ Examples:
* `add-doctor n/John Doe ic/S9851386G g/M p/98765432 e/johnd@example.com a/John street, block 123, #01-01 t/Pediatrician`
* `add-doctor n/Betsy Crowe ic/S9851586G g/F p/98765433 e/betsycrowe@example.com a/#104-C, Wakanda St 42 t/Surgeon`
+
+
+**:information_source: Common Errors:**
+1. Invalid Command Format
+All fields are mandatory except the tag field. Omission of the fields will throw an error stating
+that an invalid command has been given, and specify the correct format for the `add-doctor command`.
+Example: `add-doctor ic/S9851586G g/F p/98765433 e/betsycrowe@example.com a/#104-C, Wakanda St 42 t/Surgeon`
+Error Message: `Invalid command format!`
+ `add-doctor: Adds a person to the address book. Parameters: n/NAME p/PHONE e/EMAIL a/ADDRESS g/GENDER ic/NRIC [t/TAG]...`
+2. Invalid/Empty Field
+ Fields have specific formats to be followed. Failure to adhere to this format will lead to an error message
+that specifies the format to be used for that field. Usage of flags without any message will lead to the same
+corresponding error message since no field supports empty inputs.
+ ```
+ add-doctor n/ ic/S9851586G g/F p/98765433 e/betsycrowe@example.com a/#104-C, Wakanda St 42 t/Surgeon
+ Names should only contain alphanumeric characters and spaces, and it should not be blank
+
+ add-doctor n/Betsy Crowe ic/999 g/F p/98765433 e/betsycrowe@example.com a/#104-C, Wakanda St 42 t/Surgeon
+ Ic should start with S or T, followed by 7 numbers, and ends with a letter. Letters inputs are case-insensitive. Empty strings are not allowed
+
+ add-doctor n/Betsy Crowe ic/S9851586G g/B p/98765433 e/betsycrowe@example.com a/#104-C, Wakanda St 42 t/Surgeon
+ Gender should only be M for Male or F for Female
+
+ add-doctor n/Betsy Crowe ic/S9851586G g/F p/phoneNumber e/betsycrowe@example.com a/#104-C, Wakanda St 42 t/Surgeon
+ Phone numbers should only contain numbers, and it should be at least 3 digits long
+
+ add-doctor n/Betsy Crowe ic/S9851586G g/F p/98765433 e/ a/#104-C, Wakanda St 42 t/Surgeon
+ Emails should be of the format local-part@domain and adhere to the following constraints:
+ 1. The local-part should only contain alphanumeric characters and these special characters, excluding the parentheses, (+_.-). The local-part may not start or end with any special characters.
+ 2. This is followed by a '@' and then a domain name. The domain name is made up of domain labels separated by periods.
+ The domain name must:
+ - end with a domain label at least 2 characters long
+ - have each domain label start and end with alphanumeric characters
+ - have each domain label consist of alphanumeric characters, separated only by hyphens, if any.
+
+ add-doctor n/Betsy Crowe ic/S9851586G g/F p/98765433 e/betsycrowe@example.com a/ t/Surgeon
+ Addresses can take any values, and it should not be blank
+
+ add-doctor n/Betsy Crowe ic/S9851586G g/F p/98765433 e/betsycrowe@example.com a/#104-C, Wakanda St 42 t/BestDoctor
+ Doctor tag should be a valid specialisation.
+ ```
+3. Adding custom prefixes
+Adding custom prefixes will mostly cause the preceding flag to become invalid.
+Exceptions:
+ * Adding 'custom' flags to the address or condition field will, however, be accepted as
+Addresses may involve the usage of the `/` character. Hence, take note to use the address field carefully.
+ * Adding the 'custom' flag before any other field will recognise the input to be of Invalid Command Format.
+
+Examples:
+ * `add-doctor pic/ n/Faiz ic/S9851486G g/F p/98765433 e/betsycrowe@example.com a/#104-C, Wakanda St 42 t/surgeon`
+ * `add-doctor n/Faiz pic/ ic/S9851486G g/F p/98765433 e/betsycrowe@example.com a/#104-C, Wakanda St 42 t/surgeon`
+ * `add-doctor n/Faiz ic/S9851486G g/F p/98765433 e/betsycrowe@example.com a/#104/C, Wakanda St 42 t/surgeon`
+4. Special Cases
+Names with special characters may not adhere to the current format for names, and may be recognised as an invalid input.
+Example:
+ * `add-doctor n/David s/o Beckham ic/S9851486G g/F p/98765433 e/betsycrowe@example.com a/#104-C, Wakanda St 42 t/surgeon`
+
+
### Adding a Patient: `add-patient`
Adds a Patient to the clinic database.
diff --git a/src/main/java/seedu/address/logic/commands/AddDoctorCommand.java b/src/main/java/seedu/address/logic/commands/AddDoctorCommand.java
index 75207d50ce5..7da87dbf757 100644
--- a/src/main/java/seedu/address/logic/commands/AddDoctorCommand.java
+++ b/src/main/java/seedu/address/logic/commands/AddDoctorCommand.java
@@ -28,19 +28,19 @@ public class AddDoctorCommand extends Command {
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a person to the address book. "
+ "Parameters: "
+ PREFIX_NAME + "NAME "
+ + PREFIX_NRIC + "NRIC "
+ + PREFIX_GENDER + "GENDER "
+ PREFIX_PHONE + "PHONE "
+ PREFIX_EMAIL + "EMAIL "
+ PREFIX_ADDRESS + "ADDRESS "
- + PREFIX_GENDER + "GENDER "
- + PREFIX_NRIC + "NRIC "
+ "[" + PREFIX_TAG + "TAG]...\n"
+ "Example: " + COMMAND_WORD + " "
+ PREFIX_NAME + "John Doe "
+ + PREFIX_NRIC + "S1234567Z "
+ + PREFIX_GENDER + "M "
+ PREFIX_PHONE + "98765432 "
+ PREFIX_EMAIL + "johnd@example.com "
+ PREFIX_ADDRESS + "311, Clementi Ave 2, #02-25 "
- + PREFIX_GENDER + "M "
- + PREFIX_NRIC + "S1234567Z "
+ PREFIX_TAG + "SURGEON";
public static final String MESSAGE_SUCCESS = "New doctor added: %1$s";
diff --git a/src/main/java/seedu/address/model/appointment/Appointment.java b/src/main/java/seedu/address/model/appointment/Appointment.java
index b702ab733af..5b0804da74f 100644
--- a/src/main/java/seedu/address/model/appointment/Appointment.java
+++ b/src/main/java/seedu/address/model/appointment/Appointment.java
@@ -32,24 +32,6 @@ public Appointment(Ic doctorIc, Ic patientIc, AppointmentTime appointmentTime) {
this.appointmentTime = appointmentTime;
}
- /**
- * Constructs a new appointment with the specified doctor, patient, appointment time, and status.
- *
- * @param doctorIc The doctor involved in the appointment.
- * @param patientIc The patient involved in the appointment.
- * @param appointmentTime The date and time of the appointment.
- * @param status The status of the appointment.
- */
- public Appointment(Ic doctorIc, Ic patientIc, AppointmentTime appointmentTime, String status) {
- requireNonNull(doctorIc);
- requireNonNull(patientIc);
- requireNonNull(appointmentTime);
- requireNonNull(status);
- this.doctorIc = doctorIc;
- this.patientIc = patientIc;
- this.appointmentTime = appointmentTime;
- }
-
public AppointmentTime getAppointmentTime() {
return appointmentTime;
}
diff --git a/src/test/java/seedu/address/logic/commands/AddDoctorCommandTest.java b/src/test/java/seedu/address/logic/commands/AddDoctorCommandTest.java
index 4973d767cbd..5a9db45c360 100644
--- a/src/test/java/seedu/address/logic/commands/AddDoctorCommandTest.java
+++ b/src/test/java/seedu/address/logic/commands/AddDoctorCommandTest.java
@@ -33,7 +33,7 @@
public class AddDoctorCommandTest {
@Test
public void constructor_nullDoctor_throwsNullPointerException() {
- assertThrows(NullPointerException.class, () -> new AddCommand(null));
+ assertThrows(NullPointerException.class, () -> new AddDoctorCommand(null));
}
@@ -42,9 +42,9 @@ public void execute_doctorAcceptedByModel_addSuccessful() throws Exception {
ModelStubAcceptingPersonAdded modelStub = new ModelStubAcceptingPersonAdded();
Doctor validDoctor = new DoctorBuilder().build();
- CommandResult commandResult = new AddCommand(validDoctor).execute(modelStub);
+ CommandResult commandResult = new AddDoctorCommand(validDoctor).execute(modelStub);
- assertEquals(String.format(AddCommand.MESSAGE_SUCCESS, Messages.format(validDoctor)),
+ assertEquals(String.format(AddDoctorCommand.MESSAGE_SUCCESS, Messages.format(validDoctor)),
commandResult.getFeedbackToUser());
assertEquals(Arrays.asList(validDoctor), modelStub.personsAdded);
}
@@ -52,10 +52,11 @@ public void execute_doctorAcceptedByModel_addSuccessful() throws Exception {
@Test
public void execute_duplicateDoctor_throwsCommandException() {
Doctor validDoctor = new DoctorBuilder().build();
- AddDoctorCommand addCommand = new AddDoctorCommand(validDoctor);
+ AddDoctorCommand addDoctorCommand = new AddDoctorCommand(validDoctor);
ModelStub modelStub = new ModelStubWithDoctor(validDoctor);
- assertThrows(CommandException.class, AddCommand.MESSAGE_DUPLICATE_PERSON, () -> addCommand.execute(modelStub));
+ assertThrows(CommandException.class, AddDoctorCommand.MESSAGE_DUPLICATE_PERSON, () ->
+ addDoctorCommand.execute(modelStub));
}
@Test
@@ -84,9 +85,9 @@ public void equals() {
@Test
public void toStringMethod() {
- AddDoctorCommand addCommand = new AddDoctorCommand(WAYNE);
+ AddDoctorCommand addDoctorCommand = new AddDoctorCommand(WAYNE);
String expected = AddDoctorCommand.class.getCanonicalName() + "{toAdd=" + WAYNE + "}";
- assertEquals(expected, addCommand.toString());
+ assertEquals(expected, addDoctorCommand.toString());
}
/**
@@ -148,7 +149,6 @@ public ReadOnlyAddressBook getAddressBook() {
public boolean hasPerson(Person person) {
throw new AssertionError("This method should not be called.");
}
-
@Override
public void deletePerson(Person target) {
throw new AssertionError("This method should not be called.");
@@ -252,6 +252,10 @@ public void addPerson(Person person) {
public ReadOnlyAddressBook getAddressBook() {
return new AddressBook();
}
+ @Override
+ public boolean hasIc(Ic nric) {
+ return personsAdded.stream().anyMatch(person -> person.getIc().equals(nric));
+ }
}
}
diff --git a/src/test/java/seedu/address/model/person/AppointmentTest.java b/src/test/java/seedu/address/model/person/AppointmentTest.java
index 7b4a67dbfc0..ab0856164cf 100644
--- a/src/test/java/seedu/address/model/person/AppointmentTest.java
+++ b/src/test/java/seedu/address/model/person/AppointmentTest.java
@@ -43,25 +43,18 @@ public void constructor_nullAppointmentTime_throwsNullPointerException() {
@Test
public void secondConstructor_nullDoctor_throwsNullPointerException() {
assertThrows(NullPointerException.class, () -> new Appointment(null, new Ic(VALID_NRIC_AMY),
- new AppointmentTime(VALID_DATE_1), "Follow-Up"));
+ new AppointmentTime(VALID_DATE_1)));
}
@Test
public void secondConstructorr_nullPatient_throwsNullPointerException() {
assertThrows(NullPointerException.class, () -> new Appointment(new Ic(VALID_NRIC_DEREK), null,
- new AppointmentTime(VALID_DATE_1), "Follow-Up"));
+ new AppointmentTime(VALID_DATE_1)));
}
@Test
public void secondConstructor_nullAppointmentTime_throwsNullPointerException() {
assertThrows(NullPointerException.class, () -> new Appointment(new Ic(VALID_NRIC_DEREK), new Ic(VALID_NRIC_AMY),
- null, "Follow-Up"));
- }
-
- @Test
- public void constructor_nullStatus() { // should this throw a nullPointerException?
- assertThrows(NullPointerException.class, (
- ) -> new Appointment(new Ic(VALID_NRIC_DEREK), new Ic(VALID_NRIC_AMY), new AppointmentTime(VALID_DATE_1),
null));
}