Skip to content

Commit

Permalink
Merge pull request #220 from Mohammed-Faizzzz/branch-Modify-UG
Browse files Browse the repository at this point in the history
Modify UG
  • Loading branch information
tanveersingh10 committed Nov 12, 2023
2 parents 0abbbc6 + 423b723 commit 6ffae7b
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 41 deletions.
65 changes: 63 additions & 2 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,11 @@ A doctor can have any number of tags (including 0). Duplicate tags, however, are

**:information_source: Take Note:**<br>

- 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:</br>
`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
Expand All @@ -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`

<div markdown="block" class="alert alert-info">

**:information_source: Common Errors:**<br>
1. Invalid Command Format <br>
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`. <br>
Example: `add-doctor ic/S9851586G g/F p/98765433 e/betsycrowe@example.com a/#104-C, Wakanda St 42 t/Surgeon`<br>
Error Message: `Invalid command format!` <br>
`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 <br>
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 <br>
Adding custom prefixes will mostly cause the preceding flag to become invalid. <br>
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.
<br>
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 <br>
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`
</div>

### Adding a Patient: `add-patient`

Adds a Patient to the clinic database.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
18 changes: 0 additions & 18 deletions src/main/java/seedu/address/model/appointment/Appointment.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}


Expand All @@ -42,20 +42,21 @@ 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);
}

@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
Expand Down Expand Up @@ -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());
}

/**
Expand Down Expand Up @@ -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.");
Expand Down Expand Up @@ -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));
}
}

}
11 changes: 2 additions & 9 deletions src/test/java/seedu/address/model/person/AppointmentTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down

0 comments on commit 6ffae7b

Please sign in to comment.