Skip to content

Commit

Permalink
Rename Person to Patient in all files
Browse files Browse the repository at this point in the history
  • Loading branch information
nramapurath committed Mar 8, 2023
1 parent f7d0134 commit a67468a
Show file tree
Hide file tree
Showing 66 changed files with 620 additions and 626 deletions.
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ MIT License

Copyright (c) 2016 Software Engineering Education - FOSS Resources

Permission is hereby granted, free of charge, to any person obtaining a copy
Permission is hereby granted, free of charge, to any patient obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
copies of the Software, and to permit patients to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
Expand Down
18 changes: 9 additions & 9 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Here's a (partial) class diagram of the `Logic` component:
How the `Logic` component works:
1. When `Logic` is called upon to execute a command, it uses the `AddressBookParser` class to parse the user command.
1. This results in a `Command` object (more precisely, an object of one of its subclasses e.g., `AddCommand`) which is executed by the `LogicManager`.
1. The command can communicate with the `Model` when it is executed (e.g. to add a person).
1. The command can communicate with the `Model` when it is executed (e.g. to add a patient).
1. The result of the command execution is encapsulated as a `CommandResult` object which is returned back from `Logic`.

The Sequence Diagram below illustrates the interactions within the `Logic` component for the `execute("delete 1")` API call.
Expand Down Expand Up @@ -172,19 +172,19 @@ Step 1. The user launches the application for the first time. The `VersionedAddr

![UndoRedoState0](images/UndoRedoState0.png)

Step 2. The user executes `delete 5` command to delete the 5th person in the address book. The `delete` command calls `Model#commitAddressBook()`, causing the modified state of the address book after the `delete 5` command executes to be saved in the `addressBookStateList`, and the `currentStatePointer` is shifted to the newly inserted address book state.
Step 2. The user executes `delete 5` command to delete the 5th patient in the address book. The `delete` command calls `Model#commitAddressBook()`, causing the modified state of the address book after the `delete 5` command executes to be saved in the `addressBookStateList`, and the `currentStatePointer` is shifted to the newly inserted address book state.

![UndoRedoState1](images/UndoRedoState1.png)

Step 3. The user executes `add n/David …​` to add a new person. The `add` command also calls `Model#commitAddressBook()`, causing another modified address book state to be saved into the `addressBookStateList`.
Step 3. The user executes `add n/David …​` to add a new patient. The `add` command also calls `Model#commitAddressBook()`, causing another modified address book state to be saved into the `addressBookStateList`.

![UndoRedoState2](images/UndoRedoState2.png)

<div markdown="span" class="alert alert-info">:information_source: **Note:** If a command fails its execution, it will not call `Model#commitAddressBook()`, so the address book state will not be saved into the `addressBookStateList`.

</div>

Step 4. The user now decides that adding the person was a mistake, and decides to undo that action by executing the `undo` command. The `undo` command will call `Model#undoAddressBook()`, which will shift the `currentStatePointer` once to the left, pointing it to the previous address book state, and restores the address book to that state.
Step 4. The user now decides that adding the patient was a mistake, and decides to undo that action by executing the `undo` command. The `undo` command will call `Model#undoAddressBook()`, which will shift the `currentStatePointer` once to the left, pointing it to the previous address book state, and restores the address book to that state.

![UndoRedoState3](images/UndoRedoState3.png)

Expand Down Expand Up @@ -229,7 +229,7 @@ The following activity diagram summarizes what happens when a user executes a ne

* **Alternative 2:** Individual command knows how to undo/redo by
itself.
* Pros: Will use less memory (e.g. for `delete`, just save the person being deleted).
* Pros: Will use less memory (e.g. for `delete`, just save the patient being deleted).
* Cons: We must ensure that the implementation of each individual command are correct.

_{more aspects and alternatives to be added}_
Expand Down Expand Up @@ -381,17 +381,17 @@ testers are expected to do more *exploratory* testing.

1. _{ more test cases …​ }_

### Deleting a person
### Deleting a patient

1. Deleting a person while all persons are being shown
1. Deleting a patient while all patients are being shown

1. Prerequisites: List all persons using the `list` command. Multiple persons in the list.
1. Prerequisites: List all patients using the `list` command. Multiple patients in the list.

1. Test case: `delete 1`<br>
Expected: First contact is deleted from the list. Details of the deleted contact shown in the status message. Timestamp in the status bar is updated.

1. Test case: `delete 0`<br>
Expected: No person is deleted. Error details shown in the status message. Status bar remains the same.
Expected: No patient is deleted. Error details shown in the status message. Status bar remains the same.

1. Other incorrect delete commands to try: `delete`, `delete x`, `...` (where x is larger than the list size)<br>
Expected: Similar to previous.
Expand Down
4 changes: 2 additions & 2 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Format: `add nric/NRIC name/NAME cond/CONDITION​`

<!-- EXAMPLE OF TIP -->
<!-- <div markdown="span" class="alert alert-primary">:bulb: **Tip:**
A person can have any number of tags (including 0)
A patient can have any number of tags (including 0)
</div> -->

Examples:
Expand Down Expand Up @@ -129,7 +129,7 @@ Delete patient by NRIC.

Format: `delete nric/NRIC`

- Deletes the person at the specified `NRIC`.
- Deletes the patient at the specified `NRIC`.

Examples:

Expand Down
38 changes: 19 additions & 19 deletions docs/tutorials/AddRemark.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ package seedu.address.logic.commands;
import seedu.address.model.Model;

/**
* Changes the remark of an existing person in the address book.
* Changes the remark of an existing patient in the address book.
*/
public class RemarkCommand extends Command {

Expand Down Expand Up @@ -65,8 +65,8 @@ Following the convention in other commands, we add relevant messages as constant

``` java
public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Edits the remark of the person identified "
+ "by the index number used in the last person listing. "
+ ": Edits the remark of the patient identified "
+ "by the index number used in the last patient listing. "
+ "Existing remark will be overwritten by the input.\n"
+ "Parameters: INDEX (must be a positive integer) "
+ "r/ [REMARK]\n"
Expand Down Expand Up @@ -101,8 +101,8 @@ public class RemarkCommand extends Command {
private final String remark;

/**
* @param index of the person in the filtered person list to edit the remark
* @param remark of the person to be updated to
* @param index of the patient in the filtered patient list to edit the remark
* @param remark of the patient to be updated to
*/
public RemarkCommand(Index index, String remark) {
requireAllNonNull(index, remark);
Expand Down Expand Up @@ -225,11 +225,11 @@ If you are stuck, check out the sample

## Add `Remark` to the model

Now that we have all the information that we need, let’s lay the groundwork for propagating the remarks added into the in-memory storage of person data. We achieve that by working with the `Person` model. Each field in a Person is implemented as a separate class (e.g. a `Name` object represents the person’s name). That means we should add a `Remark` class so that we can use a `Remark` object to represent a remark given to a person.
Now that we have all the information that we need, let’s lay the groundwork for propagating the remarks added into the in-memory storage of patient data. We achieve that by working with the `Person` model. Each field in a Person is implemented as a separate class (e.g. a `Name` object represents the patient’s name). That means we should add a `Remark` class so that we can use a `Remark` object to represent a remark given to a patient.

### Add a new `Remark` class

Create a new `Remark` in `seedu.address.model.person`. Since a `Remark` is a field that is similar to `Address`, we can reuse a significant bit of code.
Create a new `Remark` in `seedu.address.model.patient`. Since a `Remark` is a field that is similar to `Address`, we can reuse a significant bit of code.

A copy-paste and search-replace later, you should have something like [this](https://github.com/se-edu/addressbook-level3/commit/4516e099699baa9e2d51801bd26f016d812dedcc#diff-41bb13c581e280c686198251ad6cc337cd5e27032772f06ed9bf7f1440995ece). Note how `Remark` has no constrains and thus does not require input
validation.
Expand All @@ -240,7 +240,7 @@ Let’s change `RemarkCommand` and `RemarkCommandParser` to use the new `Remark`

## Add a placeholder element for remark to the UI

Without getting too deep into `fxml`, let’s go on a 5 minute adventure to get some placeholder text to show up for each person.
Without getting too deep into `fxml`, let’s go on a 5 minute adventure to get some placeholder text to show up for each patient.

Simply add the following to [`seedu.address.ui.PersonCard`](https://github.com/se-edu/addressbook-level3/commit/850b78879582f38accb05dd20c245963c65ea599#diff-639834f1e05afe2276a86372adf0fe5f69314642c2d93cfa543d614ce5a76688).

Expand Down Expand Up @@ -311,9 +311,9 @@ Just add [this one line of code!](https://github.com/se-edu/addressbook-level3/c
**`PersonCard.java`:**

``` java
public PersonCard(Person person, int displayedIndex) {
public PersonCard(Person patient, int displayedIndex) {
//...
remark.setText(person.getRemark().value);
remark.setText(patient.getRemark().value);
}
```

Expand Down Expand Up @@ -343,25 +343,25 @@ save it with `Model#setPerson()`.
throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX);
}

Person personToEdit = lastShownList.get(index.getZeroBased());
Person editedPerson = new Person(
personToEdit.getName(), personToEdit.getPhone(), personToEdit.getEmail(),
personToEdit.getAddress(), remark, personToEdit.getTags());
Person patientToEdit = lastShownList.get(index.getZeroBased());
Person editedPatient = new Person(
patientToEdit.getName(), patientToEdit.getPhone(), patientToEdit.getEmail(),
patientToEdit.getAddress(), remark, patientToEdit.getTags());

model.setPerson(personToEdit, editedPerson);
model.setPerson(patientToEdit, editedPatient);
model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS);

return new CommandResult(generateSuccessMessage(editedPerson));
return new CommandResult(generateSuccessMessage(editedPatient));
}

/**
* Generates a command execution success message based on whether
* the remark is added to or removed from
* {@code personToEdit}.
* {@code patientToEdit}.
*/
private String generateSuccessMessage(Person personToEdit) {
private String generateSuccessMessage(Person patientToEdit) {
String message = !remark.value.isEmpty() ? MESSAGE_ADD_REMARK_SUCCESS : MESSAGE_DELETE_REMARK_SUCCESS;
return String.format(message, personToEdit);
return String.format(message, patientToEdit);
}
```

Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/RemovingFields.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ IntelliJ IDEA provides a refactoring tool that can identify *most* parts of a re

### Assisted refactoring

The `address` field in `Person` is actually an instance of the `seedu.address.model.person.Address` class. Since removing the `Address` class will break the application, we start by identifying `Address`'s usages. This allows us to see code that depends on `Address` to function properly and edit them on a case-by-case basis. Right-click the `Address` class and select `Refactor` \> `Safe Delete` through the menu.
The `address` field in `Person` is actually an instance of the `seedu.address.model.patient.Address` class. Since removing the `Address` class will break the application, we start by identifying `Address`'s usages. This allows us to see code that depends on `Address` to function properly and edit them on a case-by-case basis. Right-click the `Address` class and select `Refactor` \> `Safe Delete` through the menu.
* :bulb: To make things simpler, you can unselect the options `Search in comments and strings` and `Search for text occurrences`

![Usages detected](../images/remove/UnsafeDelete.png)
Expand Down Expand Up @@ -100,7 +100,7 @@ In `src/test/data/`, data meant for testing purposes are stored. While keeping t

```json
{
"persons": [ {
"patients": [ {
"name": "Person with invalid name field: Ha!ns Mu@ster",
"phone": "9482424",
"email": "[email protected]",
Expand Down
20 changes: 10 additions & 10 deletions docs/tutorials/TracingCode.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,22 +189,22 @@ Recall from the User Guide that the `edit` command has the format: `edit INDEX [
@Override
public CommandResult execute(Model model) throws CommandException {
...
Person personToEdit = lastShownList.get(index.getZeroBased());
Person editedPerson = createEditedPerson(personToEdit, editPersonDescriptor);
if (!personToEdit.isSamePerson(editedPerson) && model.hasPerson(editedPerson)) {
Person patientToEdit = lastShownList.get(index.getZeroBased());
Person editedPatient = createEditedPerson(patientToEdit, editPersonDescriptor);
if (!patientToEdit.isSamePerson(editedPatient) && model.hasPerson(editedPatient)) {
throw new CommandException(MESSAGE_DUPLICATE_PERSON);
}
model.setPerson(personToEdit, editedPerson);
model.setPerson(patientToEdit, editedPatient);
model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS);
return new CommandResult(String.format(MESSAGE_EDIT_PERSON_SUCCESS, editedPerson));
return new CommandResult(String.format(MESSAGE_EDIT_PERSON_SUCCESS, editedPatient));
}
```

1. As suspected, `command#execute()` does indeed make changes to the `model` object. Specifically,
* it uses the `setPerson()` method (defined in the interface `Model` and implemented in `ModelManager` as per the usual pattern) to update the person data.
* it uses the `updateFilteredPersonList` method to ask the `Model` to populate the 'filtered list' with _all_ persons.<br>
FYI, The 'filtered list' is the list of persons resulting from the most recent operation that will be shown to the user immediately after. For the `edit` command, we populate it with all the persons so that the user can see the edited person along with all other persons. If this was a `find` command, we would be setting that list to contain the search results instead.<br>
To provide some context, given below is the class diagram of the `Model` component. See if you can figure out where the 'filtered list' of persons is being tracked.
* it uses the `setPerson()` method (defined in the interface `Model` and implemented in `ModelManager` as per the usual pattern) to update the patient data.
* it uses the `updateFilteredPersonList` method to ask the `Model` to populate the 'filtered list' with _all_ patients.<br>
FYI, The 'filtered list' is the list of patients resulting from the most recent operation that will be shown to the user immediately after. For the `edit` command, we populate it with all the patients so that the user can see the edited patient along with all other patients. If this was a `find` command, we would be setting that list to contain the search results instead.<br>
To provide some context, given below is the class diagram of the `Model` component. See if you can figure out where the 'filtered list' of patients is being tracked.
<img src="../images/ModelClassDiagram.png" width="450" /><br>
* :bulb: This may be a good time to read through the [`Model` component section of the DG](../DeveloperGuide.html#model-component)

Expand All @@ -231,7 +231,7 @@ Recall from the User Guide that the `edit` command has the format: `edit INDEX [
* {@code JsonSerializableAddressBook}.
*/
public JsonSerializableAddressBook(ReadOnlyAddressBook source) {
persons.addAll(
patients.addAll(
source.getPersonList()
.stream()
.map(JsonAdaptedPerson::new)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/commons/core/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class Messages {

public static final String MESSAGE_UNKNOWN_COMMAND = "Unknown command";
public static final String MESSAGE_INVALID_COMMAND_FORMAT = "Invalid command format! \n%1$s";
public static final String MESSAGE_INVALID_PERSON_DISPLAYED_INDEX = "The person index provided is invalid";
public static final String MESSAGE_INVALID_PERSON_DISPLAYED_INDEX = "The patient index provided is invalid";
public static final String MESSAGE_PERSONS_LISTED_OVERVIEW = "%1$d persons listed!";

}
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/logic/Logic.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.ReadOnlyAddressBook;
import seedu.address.model.person.Person;
import seedu.address.model.patient.Patient;

/**
* API of the Logic component
Expand All @@ -31,7 +31,7 @@ public interface Logic {
ReadOnlyAddressBook getAddressBook();

/** Returns an unmodifiable view of the filtered list of persons */
ObservableList<Person> getFilteredPersonList();
ObservableList<Patient> getFilteredPersonList();

/**
* Returns the user prefs' address book file path.
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/logic/LogicManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.Model;
import seedu.address.model.ReadOnlyAddressBook;
import seedu.address.model.person.Person;
import seedu.address.model.patient.Patient;
import seedu.address.storage.Storage;

/**
Expand Down Expand Up @@ -60,7 +60,7 @@ public ReadOnlyAddressBook getAddressBook() {
}

@Override
public ObservableList<Person> getFilteredPersonList() {
public ObservableList<Patient> getFilteredPersonList() {
return model.getFilteredPersonList();
}

Expand Down
20 changes: 10 additions & 10 deletions src/main/java/seedu/address/logic/commands/AddCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@

import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.person.Person;
import seedu.address.model.patient.Patient;

/**
* Adds a person to the address book.
* Adds a patient to the address book.
*/
public class AddCommand extends Command {

public static final String COMMAND_WORD = "add";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a person to the address book. "
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a patient to the address book. "
+ "Parameters: "
+ PREFIX_NAME + "NAME "
+ PREFIX_PHONE + "PHONE "
Expand All @@ -33,17 +33,17 @@ public class AddCommand extends Command {
+ PREFIX_TAG + "friends "
+ PREFIX_TAG + "owesMoney";

public static final String MESSAGE_SUCCESS = "New person added: %1$s";
public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in the address book";
public static final String MESSAGE_SUCCESS = "New patient added: %1$s";
public static final String MESSAGE_DUPLICATE_PERSON = "This patient already exists in the address book";

private final Person toAdd;
private final Patient toAdd;

/**
* Creates an AddCommand to add the specified {@code Person}
* Creates an AddCommand to add the specified {@code Patient}
*/
public AddCommand(Person person) {
requireNonNull(person);
toAdd = person;
public AddCommand(Patient patient) {
requireNonNull(patient);
toAdd = patient;
}

@Override
Expand Down
Loading

0 comments on commit a67468a

Please sign in to comment.