diff --git a/src/main/java/seedu/address/logic/Messages.java b/src/main/java/seedu/address/logic/Messages.java index eaa4fc48632..06aa5c6c123 100644 --- a/src/main/java/seedu/address/logic/Messages.java +++ b/src/main/java/seedu/address/logic/Messages.java @@ -47,6 +47,8 @@ public static String format(Person person) { .append(person.getWard()) .append("\n Admitted: ") .append(person.getAdmissionDate()) + .append("\n Remarks: ") + .append(person.getRemark()) .append("\n Tags: "); person.getTags().forEach(builder::append); return builder.toString(); diff --git a/src/main/java/seedu/address/logic/commands/AddCommand.java b/src/main/java/seedu/address/logic/commands/AddCommand.java index 4008f76bcc3..9969f85e7cd 100644 --- a/src/main/java/seedu/address/logic/commands/AddCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddCommand.java @@ -5,6 +5,7 @@ import static seedu.address.logic.parser.CliSyntax.PREFIX_DOB; import static seedu.address.logic.parser.CliSyntax.PREFIX_IC; import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; +import static seedu.address.logic.parser.CliSyntax.PREFIX_REMARK; import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; import static seedu.address.logic.parser.CliSyntax.PREFIX_WARD; @@ -21,13 +22,14 @@ 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 person to the address book. \n" + "Parameters: " + PREFIX_NAME + "NAME " + PREFIX_IC + "IC " + PREFIX_DOB + "DOB " - + PREFIX_ADMISSION_DATE + "ADMISSION DATE " - + PREFIX_WARD + "WARD NUMBER " + + PREFIX_ADMISSION_DATE + "ADMISSION_DATE " + + PREFIX_WARD + "WARD_NUMBER " + + "[" + PREFIX_REMARK + "REMARK] " + "[" + PREFIX_TAG + "TAG]...\n" + "Example: " + COMMAND_WORD + " " + PREFIX_NAME + "John Doe " @@ -35,6 +37,7 @@ public class AddCommand extends Command { + PREFIX_DOB + "1/1/2000 " + PREFIX_ADMISSION_DATE + "15/03/2024 " + PREFIX_WARD + "3 " + + PREFIX_REMARK + "Prevent bed sores. " + PREFIX_TAG + "FallRisk"; public static final String MESSAGE_SUCCESS = "New patient added: %1$s"; diff --git a/src/main/java/seedu/address/logic/commands/EditCommand.java b/src/main/java/seedu/address/logic/commands/EditCommand.java index 95e8b99028e..23a34b8bb8a 100644 --- a/src/main/java/seedu/address/logic/commands/EditCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditCommand.java @@ -5,6 +5,7 @@ import static seedu.address.logic.parser.CliSyntax.PREFIX_DOB; import static seedu.address.logic.parser.CliSyntax.PREFIX_IC; import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; +import static seedu.address.logic.parser.CliSyntax.PREFIX_REMARK; import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; import static seedu.address.logic.parser.CliSyntax.PREFIX_WARD; import static seedu.address.model.Model.PREDICATE_SHOW_ALL_PERSONS; @@ -29,6 +30,7 @@ import seedu.address.model.person.Ic; import seedu.address.model.person.Name; import seedu.address.model.person.Person; +import seedu.address.model.person.Remark; import seedu.address.model.person.Ward; import seedu.address.model.tag.Tag; @@ -49,6 +51,7 @@ public class EditCommand extends Command { + "[" + PREFIX_WARD + "WARD] " + "[" + PREFIX_ADMISSION_DATE + "ADMISSION DATE] " + "[" + PREFIX_TAG + "TAG]...\n" + + "[" + PREFIX_REMARK + "REMARK]...\n" + "Example: " + COMMAND_WORD + " 1 " + PREFIX_IC + "T1234567Q " + PREFIX_DOB + "12/08/1999"; @@ -115,8 +118,10 @@ private static Person createEditedPerson(Person personToEdit, EditPersonDescript AdmissionDate updatedAdmissionDate = editPersonDescriptor.getAdmissionDate().orElse(personToEdit.getAdmissionDate()); Ward updatedWard = editPersonDescriptor.getWard().orElse(personToEdit.getWard()); + Remark updatedRemark = editPersonDescriptor.getRemark().orElse(personToEdit.getRemark()); - return new Person(updatedName, updatedTags, updatedDob, updatedIc, updatedAdmissionDate, updatedWard); + return new Person(updatedName, updatedTags, updatedDob, updatedIc, updatedAdmissionDate, + updatedWard, updatedRemark); } @Override @@ -154,7 +159,7 @@ public static class EditPersonDescriptor { private Dob dob; private AdmissionDate admissionDate; private Ward ward; - + private Remark remark; public EditPersonDescriptor() {} /** @@ -168,6 +173,7 @@ public EditPersonDescriptor(EditPersonDescriptor toCopy) { setIc(toCopy.ic); setAdmissionDate(toCopy.admissionDate); setWard(toCopy.ward); + setRemark(toCopy.remark); } /** @@ -225,6 +231,12 @@ public void setWard(Ward ward) { public Optional getWard() { return Optional.ofNullable(ward); } + public void setRemark(Remark remark) { + this.remark = remark; + } + public Optional getRemark() { + return Optional.ofNullable(remark); + } @Override public boolean equals(Object other) { if (other == this) { @@ -242,7 +254,8 @@ public boolean equals(Object other) { && Objects.equals(ic, otherEditPersonDescriptor.ic) && Objects.equals(dob, otherEditPersonDescriptor.dob) && Objects.equals(admissionDate, otherEditPersonDescriptor.admissionDate) - && Objects.equals(ward, otherEditPersonDescriptor.ward); + && Objects.equals(ward, otherEditPersonDescriptor.ward) + && Objects.equals(remark, otherEditPersonDescriptor.remark); } @@ -250,11 +263,12 @@ public boolean equals(Object other) { public String toString() { return new ToStringBuilder(this) .add("name", name) - .add("tags", tags) - .add("ic", ic) .add("dob", dob) + .add("ic", ic) + .add("tags", tags) .add("admissionDate", admissionDate) .add("ward", ward) + .add("remark", remark) .toString(); } } diff --git a/src/main/java/seedu/address/logic/commands/RemarkCommand.java b/src/main/java/seedu/address/logic/commands/RemarkCommand.java new file mode 100644 index 00000000000..6f1ee93d35a --- /dev/null +++ b/src/main/java/seedu/address/logic/commands/RemarkCommand.java @@ -0,0 +1,94 @@ +package seedu.address.logic.commands; + +import static seedu.address.commons.util.CollectionUtil.requireAllNonNull; +import static seedu.address.model.Model.PREDICATE_SHOW_ALL_PERSONS; + +import java.util.List; + +import seedu.address.commons.core.index.Index; +import seedu.address.logic.Messages; +import seedu.address.logic.commands.exceptions.CommandException; +import seedu.address.model.Model; +import seedu.address.model.person.Person; +import seedu.address.model.person.Remark; + + + +/** + * Changes the remark of an existing person in the address book. + */ +public class RemarkCommand extends Command { + public static final String COMMAND_WORD = "remark"; + 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. " + + "Existing remark will be overwritten by the input.\n" + + "Parameters: INDEX (must be a positive integer) " + + "r\\[REMARK]\n" + + "Example: " + COMMAND_WORD + " 1 " + + "r\\Likes to swim."; + + public static final String MESSAGE_ARGUMENTS = "Index: %1$d, Remark: %2$s"; + public static final String MESSAGE_ADD_REMARK_SUCCESS = "Added remark to Patient: %1$s"; + public static final String MESSAGE_DELETE_REMARK_SUCCESS = "Removed remark from Patient: %1$s"; + + private final Index index; + private final Remark remark; + + /** + * @param index of the person in the filtered person list to edit the remark + * @param remark of the person to be updated to + */ + public RemarkCommand(Index index, Remark remark) { + requireAllNonNull(index, remark); + + this.index = index; + this.remark = remark; + } + + @Override + public CommandResult execute(Model model) throws CommandException { + List lastShownList = model.getFilteredPersonList(); + + if (index.getZeroBased() >= lastShownList.size()) { + throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); + } + + Person personToEdit = lastShownList.get(index.getZeroBased()); + Person editedPerson = new Person( + personToEdit.getName(), personToEdit.getTags(), personToEdit.getDob(), + personToEdit.getIc(), personToEdit.getAdmissionDate(), personToEdit.getWard(), + remark); + + model.setPerson(personToEdit, editedPerson); + model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); + + return new CommandResult(generateSuccessMessage(editedPerson)); + } + + /** + * Generates a command execution success message based on whether + * the remark is added to or removed from + * {@code personToEdit}. + */ + private String generateSuccessMessage(Person personToEdit) { + String message = !remark.value.isEmpty() ? MESSAGE_ADD_REMARK_SUCCESS : MESSAGE_DELETE_REMARK_SUCCESS; + return String.format(message, Messages.format(personToEdit)); + } + + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + + // instanceof handles nulls + if (!(other instanceof RemarkCommand)) { + return false; + } + + RemarkCommand e = (RemarkCommand) other; + return index.equals(e.index) + && remark.equals(e.remark); + } +} diff --git a/src/main/java/seedu/address/logic/parser/AddCommandParser.java b/src/main/java/seedu/address/logic/parser/AddCommandParser.java index c816349cb38..2b067a98802 100644 --- a/src/main/java/seedu/address/logic/parser/AddCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddCommandParser.java @@ -6,6 +6,7 @@ import static seedu.address.logic.parser.CliSyntax.PREFIX_DOB; import static seedu.address.logic.parser.CliSyntax.PREFIX_IC; import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; +import static seedu.address.logic.parser.CliSyntax.PREFIX_REMARK; import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; import static seedu.address.logic.parser.CliSyntax.PREFIX_WARD; @@ -21,6 +22,7 @@ import seedu.address.model.person.Ic; import seedu.address.model.person.Name; import seedu.address.model.person.Person; +import seedu.address.model.person.Remark; import seedu.address.model.person.Ward; import seedu.address.model.tag.Tag; @@ -37,7 +39,7 @@ public class AddCommandParser implements Parser { public AddCommand parse(String args) throws ParseException { ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_TAG, - PREFIX_DOB, PREFIX_IC, PREFIX_ADMISSION_DATE, PREFIX_WARD); + PREFIX_DOB, PREFIX_IC, PREFIX_ADMISSION_DATE, PREFIX_WARD, PREFIX_REMARK); if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_DOB, PREFIX_IC, PREFIX_ADMISSION_DATE, PREFIX_WARD) @@ -53,6 +55,8 @@ public AddCommand parse(String args) throws ParseException { AdmissionDate admissionDate = ParserUtil.parseAdmissionDate(argMultimap.getValue(PREFIX_ADMISSION_DATE).orElse(null)); Ward ward = ParserUtil.parseWard(argMultimap.getValue(PREFIX_WARD).orElse(null)); + Remark remark = ParserUtil.parseRemark(argMultimap.getValue(PREFIX_REMARK).orElse(null)); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy"); LocalDate dobDate = LocalDate.parse(dob.value, formatter); @@ -61,7 +65,7 @@ public AddCommand parse(String args) throws ParseException { throw new ParseException(MESSAGE_DOB_LATER_THAN_ADMISSION); } - Person person = new Person(name, tagList, dob, ic, admissionDate, ward); + Person person = new Person(name, tagList, dob, ic, admissionDate, ward, remark); return new AddCommand(person); } diff --git a/src/main/java/seedu/address/logic/parser/AddressBookParser.java b/src/main/java/seedu/address/logic/parser/AddressBookParser.java index 88cbea43998..77eac25b078 100644 --- a/src/main/java/seedu/address/logic/parser/AddressBookParser.java +++ b/src/main/java/seedu/address/logic/parser/AddressBookParser.java @@ -17,6 +17,7 @@ import seedu.address.logic.commands.FindCommand; import seedu.address.logic.commands.HelpCommand; import seedu.address.logic.commands.ListCommand; +import seedu.address.logic.commands.RemarkCommand; import seedu.address.logic.parser.exceptions.ParseException; /** @@ -76,6 +77,8 @@ public Command parseCommand(String userInput) throws ParseException { case HelpCommand.COMMAND_WORD: return new HelpCommand(); + case RemarkCommand.COMMAND_WORD: + return new RemarkCommandParser().parse(arguments); default: logger.finer("This user input caused a ParseException: " + userInput); diff --git a/src/main/java/seedu/address/logic/parser/CliSyntax.java b/src/main/java/seedu/address/logic/parser/CliSyntax.java index 4b797463a48..f6df528f8c4 100644 --- a/src/main/java/seedu/address/logic/parser/CliSyntax.java +++ b/src/main/java/seedu/address/logic/parser/CliSyntax.java @@ -12,4 +12,5 @@ public class CliSyntax { public static final Prefix PREFIX_WARD = new Prefix("w\\"); public static final Prefix PREFIX_IC = new Prefix("ic\\"); public static final Prefix PREFIX_ADMISSION_DATE = new Prefix("ad\\"); + public static final Prefix PREFIX_REMARK = new Prefix("r\\"); } diff --git a/src/main/java/seedu/address/logic/parser/EditCommandParser.java b/src/main/java/seedu/address/logic/parser/EditCommandParser.java index d86334091b4..e2611ce5e1c 100644 --- a/src/main/java/seedu/address/logic/parser/EditCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/EditCommandParser.java @@ -6,6 +6,7 @@ import static seedu.address.logic.parser.CliSyntax.PREFIX_DOB; import static seedu.address.logic.parser.CliSyntax.PREFIX_IC; import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; +import static seedu.address.logic.parser.CliSyntax.PREFIX_REMARK; import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; import static seedu.address.logic.parser.CliSyntax.PREFIX_WARD; @@ -34,7 +35,7 @@ public EditCommand parse(String args) throws ParseException { requireNonNull(args); ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_DOB, PREFIX_WARD, PREFIX_IC, - PREFIX_ADMISSION_DATE, PREFIX_TAG); + PREFIX_ADMISSION_DATE, PREFIX_TAG, PREFIX_REMARK); Index index; @@ -67,6 +68,10 @@ public EditCommand parse(String args) throws ParseException { editPersonDescriptor.setWard(ParserUtil.parseWard(argMultimap.getValue(PREFIX_WARD).get())); } + if (argMultimap.getValue(PREFIX_REMARK).isPresent()) { + editPersonDescriptor.setRemark(ParserUtil.parseRemark(argMultimap.getValue(PREFIX_REMARK).get())); + } + if (!editPersonDescriptor.isAnyFieldEdited()) { throw new ParseException(EditCommand.MESSAGE_NOT_EDITED); } diff --git a/src/main/java/seedu/address/logic/parser/ParserUtil.java b/src/main/java/seedu/address/logic/parser/ParserUtil.java index 7330ce195d9..ffbb8a65521 100644 --- a/src/main/java/seedu/address/logic/parser/ParserUtil.java +++ b/src/main/java/seedu/address/logic/parser/ParserUtil.java @@ -15,6 +15,7 @@ import seedu.address.model.person.Dob; import seedu.address.model.person.Ic; import seedu.address.model.person.Name; +import seedu.address.model.person.Remark; import seedu.address.model.person.Ward; import seedu.address.model.tag.Tag; @@ -152,4 +153,17 @@ public static Ward parseWard(String ward) throws ParseException { return new Ward(trimmedWard); } + /** + * Parses a {@code String remark} into a {@code Remark}. + * Leading and trailing whitespaces will be trimmed. + */ + public static Remark parseRemark(String remark) throws ParseException { + if (remark == null) { + return new Remark(""); + } else { + String trimmedRemark = remark.trim(); + return new Remark(trimmedRemark); + } + } + } diff --git a/src/main/java/seedu/address/logic/parser/RemarkCommandParser.java b/src/main/java/seedu/address/logic/parser/RemarkCommandParser.java new file mode 100644 index 00000000000..c0367155377 --- /dev/null +++ b/src/main/java/seedu/address/logic/parser/RemarkCommandParser.java @@ -0,0 +1,45 @@ +package seedu.address.logic.parser; + +import static java.util.Objects.requireNonNull; +import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; +import static seedu.address.logic.parser.CliSyntax.PREFIX_REMARK; + +import seedu.address.commons.core.index.Index; +import seedu.address.commons.exceptions.IllegalValueException; +import seedu.address.logic.commands.RemarkCommand; +import seedu.address.logic.parser.exceptions.ParseException; +import seedu.address.model.person.Remark; + + + +/** + * Parses input arguments and creates a new RemarkCommand object + */ +public class RemarkCommandParser implements Parser { + + /** + * Parses the given {@code String} of arguments in the context of the RemarkCommand + * and returns an RemarkCommand object for execution. + * @throws ParseException if the user input does not conform the expected format + */ + @Override + public RemarkCommand parse(String args) throws ParseException { + requireNonNull(args); + ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args, + PREFIX_REMARK); + + Index index; + try { + index = ParserUtil.parseIndex(argMultimap.getPreamble()); + } catch (IllegalValueException ive) { + throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, + RemarkCommand.MESSAGE_USAGE), ive); + } + + argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_REMARK); + + Remark remark = new Remark(argMultimap.getValue(PREFIX_REMARK).orElse("")); + + return new RemarkCommand(index, remark); + } +} diff --git a/src/main/java/seedu/address/model/person/Person.java b/src/main/java/seedu/address/model/person/Person.java index 90b5f84562d..7b485c1119e 100644 --- a/src/main/java/seedu/address/model/person/Person.java +++ b/src/main/java/seedu/address/model/person/Person.java @@ -28,12 +28,13 @@ public class Person { private final Set tags = new HashSet<>(); private final AdmissionDate admissionDate; private final Ward ward; + private final Remark remark; /** * Every field must be present and not null. */ public Person(Name name, Set tags, - Dob dob, Ic ic, AdmissionDate admissionDate, Ward ward) { + Dob dob, Ic ic, AdmissionDate admissionDate, Ward ward, Remark remark) { requireAllNonNull(name, dob, ic, admissionDate, ward); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy"); @@ -46,6 +47,12 @@ public Person(Name name, Set tags, this.ic = ic; this.admissionDate = admissionDate; this.ward = ward; + + if (remark == null) { + this.remark = new Remark(""); + } else { + this.remark = remark; + } } public Name getName() { @@ -72,6 +79,10 @@ public AdmissionDate getAdmissionDate() { public Ward getWard() { return ward; } + public Remark getRemark() { + return remark; + } + /** * Returns true if both persons have the same name. * This defines a weaker notion of equality between two persons. @@ -106,13 +117,14 @@ public boolean equals(Object other) { && dob.equals(otherPerson.dob) && ic.equals(otherPerson.ic) && admissionDate.equals(otherPerson.admissionDate) - && ward.equals(otherPerson.ward); + && ward.equals(otherPerson.ward) + && remark.equals(otherPerson.remark); } @Override public int hashCode() { // use this method for custom fields hashing instead of implementing your own - return Objects.hash(name, tags, dob, ic, admissionDate, ward); + return Objects.hash(name, tags, dob, ic, admissionDate, ward, remark); } @Override @@ -124,6 +136,7 @@ public String toString() { .add("ic", ic) .add("admissionDate", admissionDate) .add("ward", ward) + .add("remark", remark) .toString(); } diff --git a/src/main/java/seedu/address/model/person/Remark.java b/src/main/java/seedu/address/model/person/Remark.java new file mode 100644 index 00000000000..255d75a91e8 --- /dev/null +++ b/src/main/java/seedu/address/model/person/Remark.java @@ -0,0 +1,44 @@ +package seedu.address.model.person; + +import static java.util.Objects.requireNonNull; +/** + * Represents a Person's remarks in the address book. + */ +public class Remark { + public final String value; + + /** + * Constructs an {@code Remark}. + * + * @param value A valid remark. + */ + public Remark(String value) { + requireNonNull(value); + this.value = value; + } + + @Override + public String toString() { + return value; + } + + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + + // instanceof handles nulls + if (!(other instanceof Remark)) { + return false; + } + + Remark otherRemark = (Remark) other; + return value.equals(otherRemark.value); + } + + @Override + public int hashCode() { + return value.hashCode(); + } +} diff --git a/src/main/java/seedu/address/model/util/SampleDataUtil.java b/src/main/java/seedu/address/model/util/SampleDataUtil.java index fa84b02deb1..e57e157f5b5 100644 --- a/src/main/java/seedu/address/model/util/SampleDataUtil.java +++ b/src/main/java/seedu/address/model/util/SampleDataUtil.java @@ -11,27 +11,32 @@ import seedu.address.model.person.Ic; import seedu.address.model.person.Name; import seedu.address.model.person.Person; +import seedu.address.model.person.Remark; import seedu.address.model.person.Ward; import seedu.address.model.tag.Tag; + /** * Contains utility methods for populating {@code AddressBook} with sample data. */ public class SampleDataUtil { public static Person[] getSamplePersons() { return new Person[]{ + new Person(new Name("Alex Yeoh"), getTagSet("Diabetes"), new Dob("01/01/1990"), - new Ic("S1234567A"), new AdmissionDate("01/01/2022"), new Ward("WA")), + new Ic("S1234567A"), new AdmissionDate("01/01/2022"), new Ward("WA"), + new Remark("Requires assistance with feeding.")), new Person(new Name("Bernice Yu"), getTagSet("FallRisk", "Diabetes"), new Dob("01/01/1990"), - new Ic("S1234567A"), new AdmissionDate("02/01/2022"), new Ward("WB")), + new Ic("S1234567A"), new AdmissionDate("02/01/2022"), new Ward("WB"), + new Remark("Flip every 2 hours to prevent bed sores.")), new Person(new Name("Charlotte Oliveiro"), getTagSet("FallRisk"), new Dob("01/01/1990"), - new Ic("S1234567A"), new AdmissionDate("03/01/2022"), new Ward("WC")), + new Ic("S1234567A"), new AdmissionDate("03/01/2022"), new Ward("WC"), new Remark("")), new Person(new Name("David Li"), getTagSet("Dementia"), new Dob("01/01/1990"), - new Ic("S1234567A"), new AdmissionDate("04/01/2022"), new Ward("WD")), + new Ic("S1234567A"), new AdmissionDate("04/01/2022"), new Ward("WD"), new Remark("")), new Person(new Name("Irfan Ibrahim"), getTagSet("NPO"), new Dob("01/01/1990"), - new Ic("S1234567A"), new AdmissionDate("05/01/2022"), new Ward("WE")), + new Ic("S1234567A"), new AdmissionDate("05/01/2022"), new Ward("WE"), new Remark("")), new Person(new Name("Roy Balakrishnan"), getTagSet("Dementia"), new Dob("01/01/1990"), - new Ic("S1234567A"), new AdmissionDate("06/01/2022"), new Ward("WF")) + new Ic("S1234567A"), new AdmissionDate("06/01/2022"), new Ward("WF"), new Remark("")) }; } diff --git a/src/main/java/seedu/address/storage/JsonAdaptedPerson.java b/src/main/java/seedu/address/storage/JsonAdaptedPerson.java index 7d140059c87..e04b5b58a86 100644 --- a/src/main/java/seedu/address/storage/JsonAdaptedPerson.java +++ b/src/main/java/seedu/address/storage/JsonAdaptedPerson.java @@ -15,9 +15,11 @@ import seedu.address.model.person.Ic; import seedu.address.model.person.Name; import seedu.address.model.person.Person; +import seedu.address.model.person.Remark; import seedu.address.model.person.Ward; import seedu.address.model.tag.Tag; + /** * Jackson-friendly version of {@link Person}. */ @@ -31,7 +33,7 @@ class JsonAdaptedPerson { private final String ic; private final String admissionDate; private final String ward; - + private final String remark; /** * Constructs a {@code JsonAdaptedPerson} with the given person details. */ @@ -39,7 +41,7 @@ class JsonAdaptedPerson { public JsonAdaptedPerson(@JsonProperty("name") String name, @JsonProperty("tags") List tags, @JsonProperty("dob") String dob, @JsonProperty("ic") String ic, @JsonProperty("admissionDate") String admissionDate, - @JsonProperty("ward") String ward) { + @JsonProperty("ward") String ward, @JsonProperty("remark") String remark) { this.name = name; if (tags != null) { this.tags.addAll(tags); @@ -48,6 +50,7 @@ public JsonAdaptedPerson(@JsonProperty("name") String name, this.ic = ic; this.admissionDate = admissionDate; this.ward = ward; + this.remark = remark; } /** @@ -62,6 +65,7 @@ public JsonAdaptedPerson(Person source) { ic = source.getIc().value; admissionDate = source.getAdmissionDate().value; ward = source.getWard().value; + remark = source.getRemark().value; } /** @@ -115,8 +119,13 @@ public Person toModelType() throws IllegalValueException { } final Ward modelWard = new Ward(ward); + if (remark == null) { + throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Remark.class.getSimpleName())); + } + final Remark modelRemark = new Remark(remark); + return new Person(modelName, modelTags, modelDob, modelIc, - modelAdmissionDate, modelWard); + modelAdmissionDate, modelWard, modelRemark); } } diff --git a/src/main/java/seedu/address/ui/PersonCard.java b/src/main/java/seedu/address/ui/PersonCard.java index 4623e28aecc..4f844584616 100644 --- a/src/main/java/seedu/address/ui/PersonCard.java +++ b/src/main/java/seedu/address/ui/PersonCard.java @@ -41,6 +41,8 @@ public class PersonCard extends UiPart { private Label ward; @FXML private FlowPane tags; + @FXML + private Label remark; /** @@ -58,5 +60,6 @@ public PersonCard(Person person, int displayedIndex) { person.getTags().stream() .sorted(Comparator.comparing(tag -> tag.tagName)) .forEach(tag -> tags.getChildren().add(new Label(tag.tagName))); + remark.setText("Remarks: " + person.getRemark().value); } } diff --git a/src/main/resources/view/PersonListCard.fxml b/src/main/resources/view/PersonListCard.fxml index 3b122f0a4ce..42bf7641dfe 100644 --- a/src/main/resources/view/PersonListCard.fxml +++ b/src/main/resources/view/PersonListCard.fxml @@ -32,6 +32,7 @@