diff --git a/docs/DeveloperGuide.adoc b/docs/DeveloperGuide.adoc index ac2eecbe85d0..d2310a0a1601 100644 --- a/docs/DeveloperGuide.adoc +++ b/docs/DeveloperGuide.adoc @@ -20,11 +20,11 @@ By: `Team T12-3`      Since: `Feb 2019`      Licence: `MIT` // tag::introduction[] == Introduction -Welcome to the _MediTabs Developer Guide_. You can find step by step instructions on how to set up MediTabs project on your computer and modify the project to suit your needs. You can also find out more about the development process of MediTabs such as its design and implementation. Interested? You can jump to <> to get started. Enjoy! +Welcome to the _MediTabs Developer Guide_. This guide contains step by step instructions on how to set up the MediTabs project on your computer and modify the project to suit your needs. You can also find out more about the technical aspects of MediTabs such as its design rationales and implementation details. Interested? You can jump to <> to get started. Enjoy! === What is MediTabs -MediTabs is a desktop application, developed using Java, for managing medicine stock taking. You can use MediTabs in your clinics to easily keep track of your medicine inventory and take note of important information such as which medicines are low in stock, expiring soon or have expired. +MediTabs is a desktop application, developed using Java, for managing medicine stock taking. It was created to provide pharmacist with a straightforward and efficient way to keep track of and maintain their medicine inventory. With MediTabs, pharmacist can easily organize medicine details and take note of important information such as which medicines are low in stock, expiring soon or have expired. MediTabs also contains functionality to help pharmacists with tasks which require medicine data such as medicine labelling and inventory analysis. MediTabs supports Windows, Linux and macOS operating systems. @@ -212,7 +212,7 @@ link:{repoURL}/src/main/java/seedu/address/logic/Logic.java[`Logic.java`] === Model component .Structure of the Model Component -image::ModelClassDiagram.png[width="800"] +image::ModelClassDiagram.png[width="900"] *API* : link:{repoURL}/src/main/java/seedu/address/model/Model.java[`Model.java`] @@ -223,14 +223,17 @@ The `Model`, * exposes an unmodifiable `ObservableList` that can be 'observed' e.g. the UI can be bound to this list so that the UI automatically updates when the data in the list change. * does not depend on any of the other three components. -Given below an object diagram to better illustrate how a medicine is stored in the `Model` component. +// tag::modelcomponentobjectdiagram[] +Given below is an object diagram to better illustrate how details of a medicine is stored in the `Model` component. .An example of how the medicine "Paracetamol" could be represented by the `Medicine` class. -image::ModelMedicineObjectDiagram.png[width="800"] +image::ModelMedicineObjectDiagram.png[width="900"] + +// end::modelcomponentobjectdiagram[] [NOTE] As a more OOP model, we can store a `Tag` list in `Inventory`, which `Medicine` can reference. This would allow `Inventory` to only require one `Tag` object per unique `Tag`, instead of each `Medicine` needing their own `Tag` object. An example of how such a model may look like is given below. + -+ + + image:ModelClassBetterOopDiagram.png[width="800"] [[Design-Storage]] @@ -262,35 +265,42 @@ This section provides you with some description of how certain key features of o ==== Current Implementation The information panel is mainly driven by `InformationPanel` which extends `UiPart` with an added mechanism to interact with the currently selected medicine and information panel settings. -It implements the following operations: +It implements the following main operations: -* `InformationPanel#showSelectedInformation(Medicine medicine)` -- Creates and displays a `BatchTable` that contains information of the selected medicine and its batches. Values in the `BatchTable` are sorted according to `SortProperty` and `SortDirection` specified in the `InformationPanelSettings`. -* `InformationPanel#emptyInformationPanel()` -- Deletes the `BatchTable` being displayed (if any) to show an empty pane. +* `InformationPanel#showSelectedInformation(Medicine medicine)` -- Creates and displays a `BatchTable` that contains information of the selected medicine and its batches. Values in the `BatchTable` are sorted according to `SortProperty` and `SortDirection` specified in `InformationPanelSettings` stored in `InformationPanel`. +* `InformationPanel#emptyInformationPanel()` -- Deletes the `BatchTable` being displayed to show an empty pane. -These operations are hidden and are only triggered when the value of the selected medicine or information panel settings changes. -The `InformationPanel` is initialized with the selected medicine and information panel settings as `ObservableValue` and ObservableValue observable, T oldValue, T newValue)` is called whenever the values in either of the `ObservableValue` objects changes. +These operations are hidden and are only triggered when the value of the selected medicine or information panel settings changes. The `InformationPanel` is initialized with the selected medicine and information panel settings passed in as `ObservableValue` and `ObservableValue observable, T oldValue, T newValue)` is called whenever the values in either of the `ObservableValue` objects changes. -Given below is a diagram showing the execution of `InformationPanel` when a change to the selected medicine occurs: +Given below is a diagram showing the execution of `InformationPanel` when a change to the selected medicine occurs. `informationPanel` variable seen in the diagram is a `StackPane` object used to display the created `BatchTable` by adding it as a child node. -image::InformationPanelSequenceDiagram.png[width="800"] +.Sequence Diagram for InformationPanel when a change in selected medicine occurs +image::InformationPanelSequenceDiagram.png[width="1000"] Given below is an example usage scenario and how the information panel behaves at each step when the selected medicine changes. -Step 1. The user launches the application for the first time. An empty `InformationPanel` is displayed. +Step 1. The user launches the application. The selected medicine is always null when the application is launched. An empty `InformationPanel` is displayed. -Step 2. The user executes `select 1` command to select the 1st medicine in the inventory. Since the new value is not null, `InformationPanel#showSelectedInformation(Medicine medicine)` is called. +Step 2. The user executes `select 1` command to select the 1st medicine in the inventory. Since the new value is not null, `InformationPanel#showSelectedInformation(Medicine medicine)` is called. A new `BatchTable` with information of the selected medicine is created and displayed. [NOTE] An `update` command will also cause `ChangeListener#changed(ObservableValue observable, T oldValue, T newValue)` to be called as although the same medicine is still selected, the medicine is replaced in the `Inventory` with updated fields. -Step 3. The user executes `find n/Paracetamol ...`. The `find` command deselects the selected medicine and the new value is null. Only `InformationPanel#emptyInformationPanel()` is called. +Step 3. The user executes `find n/Paracetamol`. The `find` command deselects the selected medicine and the new value is null. Only `InformationPanel#emptyInformationPanel()` is executed. + +Changes to the information panel settings results in a similar sequence of events, except the new value of `InformationPanelSettings` is saved in `InformationPanel` before `InformationPanel#display()` is called. + +Given below is another example usage scenario of how the information panel interacts with `InformationPanelSettings` and the `sort` command. -Given below is another example usage scenario and how the information panel behaves with the `sort` command. +Step 1. The user launches the application. `InformationPanelSettings` stored in `Model` is passed as an `ObservableValue` to initialize the `InformationPanel`. -Step 1. The user launches the application for the first time. The `InformationPanel` is initialized with `InformationPanelSettings` stored in `UserPrefs`. +Step 2. The user executes `sort p/quantity d/ascending` command to sort all batch tables by quantity in ascending order. The `sort` command calls `Model#setInformationPanelSettings(InformationPanelSettings informationPanelSettings))` which changes the value of the `InformationPanelSettings` in `Model`. The new `InformationPanelSettings` is saved in `InformationPanel`. If the selected medicine is not null, `InformationPanel#showSelectedInformation(Medicine medicine)` is called. Given below is an activity diagram to show how the saved `InformationPanelSettings` is used to sort the `BatchTable` during its initialization. A `TableView` object populated with the details of the selected medicine is created before the sorting takes place. -Step 2. The user executes `sort p/quantity d/ascending` command to sort all batch tables by quantity in ascending order. The `sort` command calls `Model#setInformationPanelSettings(InformationPanelSettings informationPanelSettings))` which changes the value of the `InformationPanelSettings` in `Model`. `InformationPanel#Display(Medicine medicine)` is called because of the changed value. +.Activity Diagram demonstrating how BatchTable is sorted during initialization +image::InformationPanelActivityDiagram.png[width="900"] + +[NOTE] +For more information on the `TableView` class, you may refer to its API https://docs.oracle.com/javase/8/javafx/api/javafx/scene/control/TableView.html[here]. ==== Design Considerations @@ -301,7 +311,7 @@ Step 2. The user executes `sort p/quantity d/ascending` command to sort all batc ** Cons: May have performance issues in terms of time needed to retrieve the information and build the table, especially if number of batches becomes huge. * **Alternative 2:** Save created `BatchTables` as a field in `Medicine`. ** Pros: Save time needed for creating the `BatchTable` for faster response time. -** Cons: More memory needed to store `BatchTable`. Complicated implementation. +** Cons: More memory needed to store `BatchTable`. `BatchTable` may still have to be recreated if the details of the `Medicine` are changed after the `BatchTable` has been created. // end::informationpanel[] // tag::exportcommand[] @@ -943,9 +953,9 @@ Priorities: High (must have) - `* * \*`, Medium (nice to have) - `* \*`, Low (un |`* * *` |pharmacist |view batch details easily |get batch information quickly -|`* * *` |pharmacist |add new and existing medicine to the inventory |keep my inventory updated +|`* * *` |pharmacist |add new medicine to the inventory |keep my inventory updated -|`* * *` |pharmacist |delete medicine |remove medicine that have expired or are no longer need +|`* * *` |pharmacist |delete medicine |remove medicine that have become obsolete |`* * *` |pharmacist |edit inventory level |keep my inventory updated @@ -961,13 +971,13 @@ Priorities: High (must have) - `* * \*`, Medium (nice to have) - `* \*`, Low (un |`* *` |pharmacist |view purchase and sales history |forecast sales and performance -|`* *` |pharmacist |view manufacturers' contact details |find out who to contact for more stock quickly +|`*` |pharmacist |view manufacturers' contact details |find out who to contact for more stock quickly -|`* *` |pharmacist |be redirected to a mailer to email manufacturers |restock quickly +|`*` |pharmacist |be redirected to a mailer to email manufacturers |restock quickly -|`* *` |pharmacist |be recommended dosage |recommend dosage based on patient's profile +|`*` |pharmacist |be recommended dosage |recommend dosage based on patient's profile -|`* *` |pharmacist |have a task list |set reminders for myself +|`*` |pharmacist |have a task list |set reminders for myself |`*` |pharmacist |save information on medicine's usage |remind myself of its usage @@ -1039,7 +1049,7 @@ Use case resume at step 2. + [none] ** 2a1. An error message is shown. -** 2a2. System requests expiry date be entered for new batches. +** 2a2. System requests both quantity and expiry date be entered for new batches. ** 2a3. Pharmacist repeats request with the required input. + Use case resume at step 3. @@ -1062,7 +1072,7 @@ Use case ends. + [none] ** 1a1. Pharmacist uses the `find` function to look for medicine listing. -** 1a2. System list the search results. +** 1a2. System lists the search results. ** 1a3. Pharmacist notes the index of the medicine listing from the search result. + Use case resume at step 2. @@ -1140,6 +1150,62 @@ Expected: No medicine is deleted. Error details shown in the status message. Sta .. Other incorrect delete commands to try: `delete`, `delete x` (where x is larger than the list size) + Expected: Similar to previous. +//tag::updatetesting[] +=== Updating batch details of a medicine + +. Updating a medicine with a new batch while all medicines are listed + +.. Prerequisites: List all medicines using the `list` command. Multiple medicines in the list. All batch numbers used for testing should not exist in the batch records of the selected medicine. Use `select 1` to load the information page. +.. Test case: `update 1 b/A q/1 e/1/1/2020` (valid input) + +Expected: New batch is added to the batch table shown in the information panel. Details of the added batch shown in the status message. Total quantity should increase by `1`. Next expiry of medicine should change if `01/01/2020` is earlier. +.. Test case: `update 1 q/1 e/1/1/2020` (missing batch number) + +Expected: Error details shown in the status message. No changes to medicine. Status bar remains the same. +.. Test case: `update 1 b/B e/1/1/2020` (missing quantity) + +Expected: Error details shown in the status message. No changes to medicine. Status bar remains the same. +.. Test case: `update 1 b/B q/1` (missing expiry) + +Expected: Error details shown in the status message. No changes to medicine. Status bar remains the same. +//end::updatetesting[] + +.. Test case: `update 1 b/- q/A e/1/1/2020` (invalid batch number) + +Expected: Error details shown in the status message. No changes to medicine. Status bar remains the same. +.. Test case: `update 1 b/B q/10000000000000 e/1/1/2020` (invalid quantity - max quantity exceeded) + +Expected: Error details shown in the status message. No changes to medicine. Status bar remains the same. +.. Test case: `update 1 b/B q/1 e/1/1/10000` (invalid expiry) + +Expected: Error details shown in the status message. No changes to medicine. Status bar remains the same. +.. Test case: `update 1 b/B q/0 e/1/1/2020` (zero quantity) + +Expected: Error details shown in the status message. No changes to medicine. Status bar remains the same. +.. Test case: `update 1 b/B q/1 e/1/1/1995` (passed date for expiry) + +Expected: Error details shown in the status message. No changes to medicine. Status bar remains the same. +.. Test case: `update 1 b/B q/1 e/29/2/2019` (invalid leap year) + +Expected: Error details shown in the status message. No changes to medicine. Status bar remains the same. +.. Test case: `update 1 b/B q/1 e/29/2/2020` (valid leap year) + +Expected: New batch is added to the batch table shown in the information panel. Details of the added batch shown in the status message. Total quantity should increase by `1`. Next expiry of medicine should change if `29/02/2020` is earlier. +.. Test case: `update 1 e/29/2/2020 q/1 b/C` (different order of arguments) + +Expected: New batch is added to the batch table shown in the information panel. Details of the added batch shown in the status message. Total quantity should increase by `1`. Next expiry of medicine should change if `29/02/2020` is earlier. + +. Updating a medicine with a existing batch while all medicines are listed + +.. Prerequisites: List all medicines using the `list` command. Multiple medicines in the list. Batch number used for testing should already exist in the batch records of the selected medicine (B is added in the tests above). Use `select 1` to load the information page. +.. Test case: `update 1 b/B q/10` (missing expiry allowed) + +Expected: batch is updated in batch table shown in the information panel with quantity changed to `10`. Details of the updated batch shown in the status message. Total quantity should increase by `9`. Next expiry should not change. +.. Test case: `update 1 b/B e/1/1/2020` (missing quantity allowed) + +Expected: batch is updated in batch table shown in the information panel with expiry changed to `01/01/2020`. Details of the updated batch shown in the status message. Total quantity should not change. Next expiry of medicine should change if `01/01/2020` is earlier. + +. Updating a medicine by removing an existing batch while all medicines are listed + +.. Prerequisites: List all medicines using the `list` command. Multiple medicines in the list. Batch number used for testing should already exist in the batch records of the selected medicine (B is added in the tests above). Use `select 1` to load the information page. +.. Test case: `update 1 b/B q/0` (valid input) + +Expected: batch is removed from batch table shown in the information panel. Details of the removed batch shown in the status message. Total quantity should be reduced by `10`. Next expiry should be updated if batch removed had the closest expiry date. + +. Updating a medicine by adding a new batch while medicine list is filtered + +.. Prerequisites: use `find` command to filter the list. Recommended `find t/ fever`. Batch number used for testing should not exist in the batch records of the selected medicine. Use `select 1` to load the information page. +.. Test case: `update 1 b/D q/1 e/1/1/2020` (valid input) + +Expected: batch is added to batch table shown in the information panel. Details of the added batch shown in the status message. Total quantity should increase by `1`. Next expiry should be updated if batch removed had the closest expiry date. Filtered list should remain filtered. +.. Test case: `update 1 b/E q/1 e/1/1/2020 b/F b/G q/2 e/2/1/2020` (more than one valid input) + +Expected: batch `G` is added to batch table shown in the information panel as last valid input is taken. Details of the added batch shown in the status message. Total quantity should increase by `2`. Next expiry of medicine should change if `02/01/2020` is earlier. Filtered list should remain filtered. +======= + // tag::exportcommandtest[] === Exporting as CSV file format diff --git a/docs/UserGuide.adoc b/docs/UserGuide.adoc index 80a97e8dcab7..3d7eb34cd8a2 100644 --- a/docs/UserGuide.adoc +++ b/docs/UserGuide.adoc @@ -19,11 +19,13 @@ By: `Team T12-3` Since: `Feb 2019` Licence: `MIT` // tag::introduction[] == Introduction -Welcome to the _MediTabs User Guide_! Over here, you can find step by step instructions on setting up MediTabs and learn ways to take advantage of the features provided to optimise your clinic's inventory management flow. Interested? You can jump to <> to get started. Enjoy! +Welcome to the _MediTabs User Guide_! Over here, you can find step by step instructions on setting up MediTabs and learn ways to take advantage of the features provided to optimise your clinic's inventory management. Interested? You can jump to <> to get started. Enjoy! === What is MediTabs? -MediTabs is a desktop application for managing medicine stock taking. You can use MediTabs in your clinics to easily keep track of your medicine inventory and take note of important information such as which medicines are low in stock, expiring soon or have expired. +MediTabs is a desktop application for managing medicine stock taking. Managing medicine can be time consuming and frustrating due to the overwhelming number of medicines in the market. Thus, MediTabs was created to provide pharmacist with a straightforward and efficient way to keep track of and maintain their inventory. + +With MediTabs, medicine data is organized in a format that helps you quickly locate the information you need. MediTabs also sieves out and provides you with critical information such as which medicines are low in stock, expiring soon or have expired so that you can ensure your inventory is well maintained. Functionality to help you with tasks which require medicine data such as medicine labelling and inventory analysis is also provided, making MediTabs the only application you need for all things inventory related. MediTabs supports Windows, Linux and macOS operating systems. @@ -40,6 +42,7 @@ If you are looking for a medicine stock taking application for clinics, MediTabs . Copy the `meditabs.jar` file to the folder you want to use as the home folder for your MediTabs application. . Double-click the file to start the app. The GUI should appear in a few seconds. + +.MediTabs image::Ui.png[width="790"] + [NOTE] @@ -47,18 +50,19 @@ image::Ui.png[width="790"] This program requires a minimum resolution of 1200*810. Best viewed in full screen. ==== + -. Type the command in the command box and press kbd:[Enter] to execute it. + +. Type a command in the command box and press kbd:[Enter] to execute it. + e.g. typing *`help`* and pressing kbd:[Enter] will open the help window. . Some example commands you can try: * *`list`* : lists all medicines in the inventory * *`add`* `n/Paracetamol c/3M Pharmaceuticals` : adds a new medicine named `Paracetamol` to the inventory with the manufacturing company `3M Pharmaceuticals` * *`delete`* `3` : deletes the 3rd entry shown in the current list -* *`exit`* : exits the app +* *`exit`* : exits the application -. Refer to <> for details of each command. +. You can refer to <> for details of each command. . Having trouble setting up MediTabs? You can refer to the <> for solutions to common problems you might encounter. Do you require further assistance? If so, you can also post your queries link:{repoURL}/issues[here] and our team will do our best to assist you. +// tag::applicationinterface[] == Application Interface image::UserGuide_ApplicationInterface.png[width="1000"] @@ -100,17 +104,19 @@ image::WarningPanelLabeled.png[width="500"] As an inventory management application, MediTabs supports basic functionalities (add, edit, delete, list). On top of these basic functions, MediTabs also boasts several features tailored to your needs. These features aim to streamline your inventory management process, thereby enhancing your user experience. +// tag::informationpanelfeature[] === Information Panel .Information panel -image::UserGuide_InformationPanel.png[width="715"] +image::UserGuide_InformationPanel.png[width="700"] -Managing medicines by batch is efficient and logical since medicines from the same batch share the same properties. However, with so many different batches of the same medicine, you need an organized way to keep track of them. +Having a way to keep track of individual batches of medicine makes medicine management more efficient as problematic batches can easily be located and removed. However, with so many different batches of the same medicine, you need an effective way to organize them or it could get confusing. The information panel provides all the details and information you need about each batch of medicine in a neat and organized manner. You can easily refer to the batch table provided in the information panel while updating and managing your inventory. Simply select a medicine using the `select` command to view all its relevant details. You may refer to <> for more details. You can also sort the table by any of its columns with the `sort` command to suit your needs and preference. You may refer to <> for more details. +// end::informationpanelfeature[] // tag::warningpanelfeature[] === Warning Panel @@ -151,13 +157,15 @@ When typing fields that include medicine name, a list of suggested medicine name Press the kbd:[↑] and kbd:[↓] arrows to select from the generated list of suggestions. ==== +// tag::inventoryforecasting[] ==== Inventory Forecasting -MediTabs will store information about your monthly stock level and predict the optimal amount of stock needed for the future. It will be possible to forecast inventory needs up to 3 months into the future with no extra effort from you as all analysis and calculations will take place with data already provided by routine use of MediTabs. -It will also be possible to import past sales data to increase accuracy of forecasting immediately without having to wait for the application to collect data. +MediTabs will store information about your monthly stock level and predict the optimal amount of stock needed for the future. It will be possible to forecast inventory needs up to 3 months in advance with no extra effort from you as all analysis and calculations will take place with data already provided by routine use of MediTabs. +It will also be possible to import past inventory data to increase accuracy of forecasting immediately without having to wait for the application to collect data. [NOTE] -We recommend importing or allowing MediTabs to collect data for 6 months or more for a more accurate forecast. +Importing or allowing MediTabs to collect data for 6 months or more will produce a more accurate forecast. +// end::inventoryforecasting[] // tag::integrationaddon[] ==== Integration Addon Support @@ -190,20 +198,24 @@ Due to the nature of medical inventories, the integrity of data stored is of utm // tag::previewresults[] ==== Preview of results -. Preview of results for Export and Label Commands to be available in the UI. -- Current implementation: You may have to manually search for the external files created in their respective folders. + -- In v2.0, a snapshot of the resulting files will be previewed under the UI for easier reference. This further streamline the inventory management and improve your usability. -- Below is a mock up on how the UI may look like with the features integrated. +Preview of results for Export and Label Commands to be available in the UI. + +* Current implementation: You may have to manually search for the external files created in their respective folders. + +* In v2.0, a snapshot of the resulting files will be previewed under the UI for easier reference. This further streamline the inventory management and improve your usability. +* Below is a mock up on how the UI may look like with the features integrated. image::MockUp.png[width="790"] // end::previewresults[] // tag::importpictures[] ==== Importing pictures -. Import of pictures to aid in the medicine identification. -- Pictures and snapshot of the medicine may be added to MediTabs such that it is easier for you to identify what the physical medicine looks like. + +Import of pictures to aid in the medicine identification. + +* Pictures and snapshot of the medicine may be added to MediTabs such that it is easier for you to identify what the physical medicine looks like. // end::importpictures[] + [[Commands]] == Commands @@ -212,9 +224,10 @@ image::MockUp.png[width="790"] *Command Format* * Words in `UPPER_CASE` are the parameters to be supplied by the user e.g. in `add n/NAME`, `NAME` is a parameter which can be used as `add n/Paracetamol`. -* Items in square brackets are optional e.g `e.g n/NAME [t/TAG] can be used as n/Paracetamol t/fever` or as `n/Paracetamol`. -* Items with `…`​ after them can be used multiple times including zero times e.g. `[t/TAG]…` can be used as `{nbsp}` (i.e. 0 times), t/fever, t/painkiller t/inflammation etc.. +* Items in square brackets are optional e.g `e.g n/NAME [t/TAG] can be used as `n/Paracetamol t/fever` or as `n/Paracetamol`. +* Items with `…`​ after them can be used multiple times including zero times e.g. `[t/TAG]…` can be used as `{nbsp}` (i.e. 0 times), `t/fever, t/painkiller t/inflammation` etc.. * Parameters can be in any order e.g. if the command specifies `n/NAME c/COMPANY_NAME`, `c/COMPANY_NAME n/NAME` is also acceptable. +* `INDEX` refers to the index number shown in the displayed medicine list. The index *must be a positive integer* 1, 2, 3, ... * If only one input is required but more than one valid input is entered, only the last input will be registered e.g. `n/Paracetamol n/Ibuprofen`, only `Ibuprofen` is registered. ==== @@ -228,6 +241,9 @@ Format: `help` Adds a new medicine to the inventory. + Format: `add n/NAME c/COMPANY_NAME [t/TAG]…​` +[WARNING] +Medicines already in the inventory cannot be added again. A duplicate medicine is one with the same name and same manufacturing company. + Examples: * `add n/Paracetamol c/3M Pharmaceuticals` @@ -239,39 +255,41 @@ Shows a list of all medicine in the inventory. + Format: `list` **** -* The details of the medicine shown in the list include: name, company, total quantity, closest expiry date and tags. +* The details of the medicine shown in the list include: name, company, total quantity, next expiry date and tags. **** // tag::find[] === Locating medicines : `find` -Finds medicine whose data contain any of the given keywords and displays them in the list. + +Finds medicine whose details contain any of the given keywords and displays them in the list. + Format: `find PREFIX KEYWORD [MORE_KEYWORDS]...` +**** .Possible prefixes: * `n/` : name of medicine is searched. * `c/`: company name of medicine is searched. * `t/` : tags of medicine are searched. * `b/` : batch number of batches of medicine are searched. -**** -* Only the field indicated by the entered prefix will be searched. -* The search is case insensitive. e.g `sodium` will match `Sodium` -* The order of the keywords does not matter. e.g. `Sodium Levothyroxine` will match `Levothyroxine Sodium` -* Only full words will be matched e.g. `Sod` will not match `Sodium` -* Medicines matching at least one keyword will be returned (i.e. `OR` search). e.g. `Sodium Ibuprofen` will return `Levothyroxine Sodium`, `Ibuprofen` +{nbsp} + +* Only the category indicated by the entered prefix will be searched. You can only enter one prefix at a time. Prefix must be entered before keywords. +* The search is case insensitive. e.g `sodium` will match `Sodium`. +* The order of the keywords does not matter. e.g. `Sodium Levothyroxine` will match `Levothyroxine Sodium`. +* Only full words will be matched e.g. `Sod` will not match `Sodium`. +* Medicines matching at least one keyword will be returned (i.e. `OR` search). e.g. `Sodium Ibuprofen` will return `Levothyroxine Sodium` and `Ibuprofen`. **** Examples: * `find n/ Sodium` + -Returns `Levothyroxine Sodium` and `Naproxen Sodium`. +`Levothyroxine Sodium` and `Naproxen Sodium` are displayed in the list. * `find c/ 3M Johnson Pharmaceutical` + -Returns any medicine from companies with names containing `3M`, `Johnson` or `Pharmaceutical` such as `3M Pharmaceuticals`. +All medicines from companies with names containing `3M`, `Johnson` or `Pharmaceutical` such as `3M Pharmaceuticals` are displayed in the list. * `find t/ fever` + -Returns any medicine with tag `fever`. +All medicines with tag `fever` are displayed in the list. * `find b/ NDC` + -Returns any medicine with batches with batch number containing `NDC` such as `NDC 0777-3105-02`. +All medicines with batches with batch number containing `NDC` such as `NDC 0777-3105-02` are displayed in the list. // end::find[] === Editing a medicine : `edit` @@ -283,8 +301,6 @@ Format: `edit INDEX [n/NAME] [c/COMPANY_NAME] [t/TAG]...` * Edits the medicine at the specified INDEX. * At least one of the optional fields must be provided. * Existing values will be updated to the input values. -* The index refers to the index number shown in the displayed medicine list. -* The index *must be a positive integer* 1, 2, 3, ... **** Examples: @@ -301,12 +317,6 @@ Remove tags from the 1st medicine in the results of the `find` command. Deletes the specified medicine from the inventory. + Format: `delete INDEX` -**** -* Deletes the medicine at the specified `INDEX`. -* The index refers to the index number shown in the displayed medicine list. -* The index *must be a positive integer* 1, 2, 3, ... -**** - Examples: * `list` + @@ -322,25 +332,24 @@ Deletes the 1st medicine in the results of the `find` command. Selects a medicine and loads the information page of the medicine. + Format: `select INDEX` -.Information page will be loaded when a medicine is selected -image::UserGuide_InformationPanel.png[width="715"] - **** * Loads the information page of the medicine at the specified `INDEX` in the information panel. * The information page consists of a table with details of all batches of the selected medicine. * These details include: batch number, quantity and expiry date. -* The index refers to the index number shown in the displayed medicine list. -* The index *must be a positive integer* `1, 2, 3, ...` +* The total quantity and next expiry date of the medicine is also displayed at the bottom of the table. **** +.An example of the information page loaded when Aspirin is selected +image::UserGuide_SelectCommand.png[width="800"] + Examples: * `list` + `select 2` + -Selects the 2nd medicine in the inventory. +Selects the 2nd medicine in the inventory and loads its information page. * `find n/ Gabapentin` + `select 1` + -Selects the 1st medicine in the results of the `find` command. +Selects the 1st medicine in the results of the `find` command and loads its information page. // end::select[] // tag::sort[] @@ -349,14 +358,16 @@ Selects the 1st medicine in the results of the `find` command. Sorts the batch table in the medicine information page based on the entered property and direction + Format: `sort p/PROPERTY d/DIRECTION` +**** .Possible properties: -* `batchnumber` : sorts the table by batch number (alphabetical order). +* `batchnumber` : sorts the table by batch number (lexicographically). * `expiry`: sorts the table by expiry date. -* `quantity` : sorts table list by quantity. +* `quantity` : sorts the table by quantity. .Possible directions: * `ascending`: sorts the table in ascending order. -* `descending` : sorts table list in descending order. +* `descending` : sorts the table in descending order. +**** Examples: @@ -369,29 +380,30 @@ The table is sorted starting from the batch with the lowest quantity. // tag::update[] === Updating batch records : `update` -Updates details of a batch of medicine. + +Updates batch details of a medicine. + Format: `update INDEX b/BATCH_NUMBER [q/QUANTITY] [e/EXPIRY_DATE]` **** -* Updates details of a batch in the batch records of medicine at specified `INDEX`. +* Updates details of a batch in the batch records of the medicine at specified `INDEX`. * At least one of the optional fields must be provided. -* If batch number already exists, the quantity or expiry date of the batch is updated. -* If batch number does not exist, a new batch record is created. Both quantity and expiry date must be entered for new batches. -* If quantity of batch is updated to `0`, it will be removed. -* If `q/QUANTITY` or `e/EXPIRY_DATE` is not inputted, batch must already exist in the records and existing information is maintained. -* The total quantity and closest expiry date of the medicine will also be updated. -* The index refers to the index number shown in the displayed medicine list. -* The index *must be a positive integer* `1, 2, 3, ...` +* If the entered batch number does not already exist in the record, a new batch record is created. Both quantity and expiry date must be entered for new batches. +* If the batch number already exists, the quantity or expiry date of the batch is replaced with the new information entered. +* If quantity of a batch is updated to `0`, it will be removed. +* The total quantity and next expiry date of the medicine will also be updated. +* Note that in order to prevent confusion, you cannot set expiry date to a passed date. You also cannot add a new batch with 0 quantity. **** Examples: * `list` + -`update 2 b/s9c4x9532 q/1000 e/11/2/2020` + -Updates quantity and expiry date of batch `s9c4x9532` in batch records of the 2nd medicine in the list to `1000` and `11/2/2020`. +`update 2 b/NDC 0777-3105-02 q/30 e/11/2/2020` + +Updates quantity and expiry date of batch `NDC 0777-3105-02` in the batch records of the 2nd medicine in the list to `30` and `11/2/2020`. A new record is created if batch `NDC 0777-3105-02` did not already exist. * `find n/ Gabapentin` + -`update 1 b/8937v1x7 q/500` + -Updates quantity of batch `8937v1x7` in batch records of the 1st medicine in the results of the `find` command to `500`. +`update 1 b/GKP1684 q/50` + +Updates quantity of batch `GKP1684` in the batch records of the 1st medicine in the results of the `find` command to `50`. An error message is shown if batch `GKP1684` did not already exist. +* `list` + +`update 1 b/HK85412 q/0` + +Removes batch `HK85412` from the batch records of the 1st medicine in the list. An error message is shown if batch `HK85412` did not already exist. //end::update[] // tag::warningpanelcommand[] @@ -632,7 +644,7 @@ e.g. `add n/Paracetamol c/3M Pharmaceuticals t/fever` * *Delete* : `delete INDEX` + e.g. `delete 3` * *Edit* : `edit INDEX [n/NAME] [c/COMPANY_NAME] [t/TAG]...` + -e.g. `edit 2 n/Amoxicillin c/GlaxoSmithKline t/antibiotic' +e.g. `edit 2 n/Amoxicillin c/GlaxoSmithKline t/antibiotic` * *Exit* : `exit` * *Export* : `export [FILE_NAME]` + e.g. export Records @@ -658,7 +670,7 @@ e.g. `warning e/20`, `warning s/10`, `warning show` * *List:* This refers to the currently displayed list (possibly filtered). * *Inventory:* This refers to the storage containing all medicines that have been added. Display all medicines in the inventory by using the `list` command. -* *Batch:* This refers to medicine with the same name, medical properties and manufacturing date. There may be more than one batch of medicine with the same name, but they will have different batch numbers and manufacturing dates. View all batches of a medicine by using the `select` command. +* *Batch:* This refers to a group of medicine with the same name, medical properties and manufacturing date. There may be more than one batch of medicine with the same name, but they will have different batch numbers and manufacturing dates. View all batches of a medicine by using the `select` command. // tag::filenamingconvention[] == Appendix A: File Naming Convention diff --git a/docs/diagrams/InformationPanelActivityDiagram.pptx b/docs/diagrams/InformationPanelActivityDiagram.pptx new file mode 100644 index 000000000000..a7cd21b210d0 Binary files /dev/null and b/docs/diagrams/InformationPanelActivityDiagram.pptx differ diff --git a/docs/diagrams/ModelComponentClassBetterOopDiagram.pptx b/docs/diagrams/ModelComponentClassBetterOopDiagram.pptx index ac6e1d63f839..d373b8eaa714 100644 Binary files a/docs/diagrams/ModelComponentClassBetterOopDiagram.pptx and b/docs/diagrams/ModelComponentClassBetterOopDiagram.pptx differ diff --git a/docs/diagrams/ModelComponentClassDiagram.pptx b/docs/diagrams/ModelComponentClassDiagram.pptx index 4ddd442ee9bd..6e7ebb988bd0 100644 Binary files a/docs/diagrams/ModelComponentClassDiagram.pptx and b/docs/diagrams/ModelComponentClassDiagram.pptx differ diff --git a/docs/diagrams/ModelMedicineObjectDiagram.pptx b/docs/diagrams/ModelMedicineObjectDiagram.pptx new file mode 100644 index 000000000000..11c4bf03924d Binary files /dev/null and b/docs/diagrams/ModelMedicineObjectDiagram.pptx differ diff --git a/docs/diagrams/SDforDeleteMedicine.pptx b/docs/diagrams/SDforDeleteMedicine.pptx index 52da1b35ed8f..70570242bf6a 100644 Binary files a/docs/diagrams/SDforDeleteMedicine.pptx and b/docs/diagrams/SDforDeleteMedicine.pptx differ diff --git a/docs/images/InformationPanelActivityDiagram.png b/docs/images/InformationPanelActivityDiagram.png new file mode 100644 index 000000000000..686928689693 Binary files /dev/null and b/docs/images/InformationPanelActivityDiagram.png differ diff --git a/docs/images/InformationPanelSequenceDiagram.png b/docs/images/InformationPanelSequenceDiagram.png index 6866c0e6f676..92bcd1709636 100644 Binary files a/docs/images/InformationPanelSequenceDiagram.png and b/docs/images/InformationPanelSequenceDiagram.png differ diff --git a/docs/images/ModelClassBetterOopDiagram.png b/docs/images/ModelClassBetterOopDiagram.png index 97f2651c2248..070981c177d0 100644 Binary files a/docs/images/ModelClassBetterOopDiagram.png and b/docs/images/ModelClassBetterOopDiagram.png differ diff --git a/docs/images/ModelClassDiagram.png b/docs/images/ModelClassDiagram.png index 5548af43b2db..571d4335af78 100644 Binary files a/docs/images/ModelClassDiagram.png and b/docs/images/ModelClassDiagram.png differ diff --git a/docs/images/ModelMedicineObjectDiagram.png b/docs/images/ModelMedicineObjectDiagram.png index 22a6834d849c..3ea843f3669e 100644 Binary files a/docs/images/ModelMedicineObjectDiagram.png and b/docs/images/ModelMedicineObjectDiagram.png differ diff --git a/docs/images/SDforDeleteMedicine.png b/docs/images/SDforDeleteMedicine.png index 7ad11aca1ac0..7920d4e599e9 100644 Binary files a/docs/images/SDforDeleteMedicine.png and b/docs/images/SDforDeleteMedicine.png differ diff --git a/docs/images/Ui.png b/docs/images/Ui.png index ee4dcb4c5b18..04a1e6c700ff 100644 Binary files a/docs/images/Ui.png and b/docs/images/Ui.png differ diff --git a/docs/images/UserGuide_InformationPanel.png b/docs/images/UserGuide_InformationPanel.png index eb03b2b68773..d8fa57b9edd7 100644 Binary files a/docs/images/UserGuide_InformationPanel.png and b/docs/images/UserGuide_InformationPanel.png differ diff --git a/docs/images/UserGuide_ListCommand.png b/docs/images/UserGuide_ListCommand.png new file mode 100644 index 000000000000..79ccb90b38a2 Binary files /dev/null and b/docs/images/UserGuide_ListCommand.png differ diff --git a/docs/images/UserGuide_SelectCommand.png b/docs/images/UserGuide_SelectCommand.png new file mode 100644 index 000000000000..ed6351e3e23d Binary files /dev/null and b/docs/images/UserGuide_SelectCommand.png differ diff --git a/docs/team/jtankw3.adoc b/docs/team/jtankw3.adoc index 7f2aefb6e0bd..82564f8bc104 100644 --- a/docs/team/jtankw3.adoc +++ b/docs/team/jtankw3.adoc @@ -3,40 +3,47 @@ :imagesDir: ../images :stylesDir: ../stylesheets -== PROJECT: MediTabs - ---- +Welcome to my Project Portfolio. Here you can find out more about my contributions in various projects to help you better evaluate my technical and communication skills. -== Overview +== PROJECT: MediTabs +=== Introduction -MediTabs is a desktop application for managing medicine stock taking. -It aims to equip clinics with the ability to easily keep track of their medicine inventory and take note of important information such as which medicines are low in stock, expiring soon or have expired. +MediTabs is a desktop application for managing medicine stock taking. It was created to provide pharmacist with a straightforward and efficient way to keep track of and maintain their medicine inventory. MediTabs is a brownfield project that initially started as an address book application. It was developed in a team of 4 as part of a software engineering module which spanned a total of about 13 weeks. -Our team identified the strengths of the initial product, which is the ability to store and organize information easily, and chose to morph the product in order to capitalize on these strengths and use them to solve a more realistic problem. -== Summary of contributions +In this project, I was in charge of implementing the information panel feature. + +=== Summary of contributions -* *Major enhancement*: added *the information panel and the commands to manipulate information on the panel* -** What it does: allows users to add, edit and remove information of different batches of medicine. This information is displayed in a table format for easy reference in the information panel. Information of the batches is also collated by the panel and a summary of important information such as total quantity and next expiry date is shown. The table can also be sorted by batch number, quantity or expiry date. -** Justification: The information panel provides a visual interface for users to refer to when updating their inventory. Organzing medicine by type and batch instead of just by type also allows for quicker identification of problematic batches. -** Highlights: The information panel is the main visual interface that the user will be referring to, hence it was essential to provide enough details for it to be useful to the user, but not so much that it looks cluttered. Implementation was challenging as it not only involved changing existing commands (add and edit) but also required a good understanding of the whole architecture of the program. This is because the feature involved adding functionality to all components of the architecture, namely UI, Logic, Model and Storage. -** Credits: The existing code for UI and commands in address book was used as a reference to implement this feature. +* *Major enhancement*: added the information panel and the `sort` and `update` commands used to manipulate information on the panel. +** What it does: allows users to add, edit and remove information of different batches of medicine. This information is displayed in a table format for easy reference in the information panel. The panel also collates the information and provides a summary of important details such as total quantity and next expiry date. The table can also be sorted by batch number, quantity or expiry date. +** Justification: Organizing medicine by batch allows for quicker identification of problematic batches. With each medicine having multiple batches, a way to organize the information neatly to avoid confusion for the user is needed. The information panel provides a visual interface that is simple and well structured for users to refer to when updating their inventory. +** Highlights: A large amount of planning was done to decide what information would be useful to the user. Implementation was challenging as it not only involved changing existing commands (`add` and `edit`) but also adding functionality to every component of the architecture, namely Logic, Storage, Model and UI. -* *Minor enhancement*: +* *Minor enhancement*: Enhanced the existing `find` command to be able to search other fields. (Pull requests: https://github.com/CS2103-AY1819S2-T12-3/main/pull/180[#180]) -* *Code contributed*: +* *Code contributed*: https://nus-cs2103-ay1819s2.github.io/cs2103-dashboard/#=undefined&search=jtankw3[code] * *Other contributions*: +** Project management: +*** Helped to manage issue tracker for the first few weeks before individual project boards were set up: (Issues: https://github.com/CS2103-AY1819S2-T12-3/main/issues/9[#9] https://github.com/CS2103-AY1819S2-T12-3/main/issues/2[#2] Project board: https://github.com/CS2103-AY1819S2-T12-3/main/projects/3[#3]) +** Enhancements to existing features: +*** Did initial refactoring from address book to MediTabs (Pull request https://github.com/CS2103-AY1819S2-T12-3/main/pull/34[#34]) +*** UI enhancement - Moved tags to bottom of `MedicineCard` shown in the list to improve readability (Pull request https://github.com/CS2103-AY1819S2-T12-3/main/pull/193[#193]) +** Team contributions: +*** Reviewed team's pull requests (Notable reviews: https://github.com/CS2103-AY1819S2-T12-3/main/pull/25[#25] https://github.com/CS2103-AY1819S2-T12-3/main/pull/115[#115] https://github.com/CS2103-AY1819S2-T12-3/main/pull/191[#191]) +*** Helped edit ContactUs.adoc to reflect our team's information (Pull request https://github.com/CS2103-AY1819S2-T12-3/main/pull/31[#31]) -_{you can add/remove categories in the list above}_ +=== Contributions to the User Guide +Given below are sections I contributed to the User Guide. They showcase my ability to write documentation targeting end-users. -== Contributions to the User Guide +include::../UserGuide.adoc[tag=informationpanelfeature] -|=== -|_Given below are sections I contributed to the User Guide. They showcase my ability to write documentation targeting end-users._ -|=== +include::../UserGuide.adoc[tag=inventoryforecasting] + +include::../UserGuide.adoc[tag=find] include::../UserGuide.adoc[tag=select] @@ -44,14 +51,13 @@ include::../UserGuide.adoc[tag=sort] include::../UserGuide.adoc[tag=update] +=== Contributions to the Developer Guide +Given below are sections I contributed to the Developer Guide. They showcase my ability to write technical documentation and the technical depth of my contributions to the project. - -== Contributions to the Developer Guide - -|=== -|_Given below are sections I contributed to the Developer Guide. They showcase my ability to write technical documentation and the technical depth of my contributions to the project._ -|=== +include::../DeveloperGuide.adoc[tag=modelcomponentobjectdiagram] include::../DeveloperGuide.adoc[tag=informationpanel] -include::../DeveloperGuide.adoc[tag=usecase] +include::../DeveloperGuide.adoc[tag=updatetesting] + +Click https://cs2103-ay1819s2-t12-3.github.io/main/DeveloperGuide.html#updating-batch-details-of-a-medicine[here] to see the remainder of the test cases. diff --git a/src/main/java/seedu/address/logic/commands/UpdateCommand.java b/src/main/java/seedu/address/logic/commands/UpdateCommand.java index c496a89fa858..1b35ec9ff9aa 100644 --- a/src/main/java/seedu/address/logic/commands/UpdateCommand.java +++ b/src/main/java/seedu/address/logic/commands/UpdateCommand.java @@ -35,7 +35,7 @@ public class UpdateCommand extends Command { + "Parameters: INDEX " + PREFIX_BATCHNUMBER + "BATCH_NUMBER " + "[" + PREFIX_QUANTITY + "QUANTITY] " - + "[" + PREFIX_EXPIRY + "EXPIRY]\n" + + "[" + PREFIX_EXPIRY + "EXPIRY_DATE]\n" + "Example: " + COMMAND_WORD + " 1 " + PREFIX_BATCHNUMBER + "HH-156224 " + PREFIX_QUANTITY + "40 " @@ -76,7 +76,10 @@ public CommandResult execute(Model model, CommandHistory history) throws Command } Medicine medicineToUpdate = lastShownList.get(targetIndex.getZeroBased()); - Batch batchToUpdate = getBatchToUpdate(medicineToUpdate); + Batch batchToUpdate = medicineToUpdate.getBatches().get(newBatchDetails.getBatchNumber()); + if (batchToUpdate == null) { + assertCanAddNewBatchToMedicine(medicineToUpdate); + } Batch updatedBatch = createUpdatedBatch(batchToUpdate); Medicine updatedMedicine = createUpdatedMedicine(medicineToUpdate, batchToUpdate, updatedBatch); @@ -88,14 +91,6 @@ public CommandResult execute(Model model, CommandHistory history) throws Command return new CommandResult(String.format(MESSAGE_SUCCESS, updatedBatch)); } - private Batch getBatchToUpdate(Medicine medicineToUpdate) throws CommandException { - Batch batchToUpdate = medicineToUpdate.getBatches().get(newBatchDetails.getBatchNumber()); - if (batchToUpdate == null) { - assertCanAddNewBatchToMedicine(medicineToUpdate); - } - return batchToUpdate; - } - /** * @throws CommandException if requirements needed to add a new batch is not met. */ diff --git a/src/main/java/seedu/address/logic/parser/ParserUtil.java b/src/main/java/seedu/address/logic/parser/ParserUtil.java index 8fe94c77fe15..4c18cf623545 100644 --- a/src/main/java/seedu/address/logic/parser/ParserUtil.java +++ b/src/main/java/seedu/address/logic/parser/ParserUtil.java @@ -121,7 +121,7 @@ public static Company parseCompany(String company) throws ParseException { public static Expiry parseExpiry(String expiry) throws ParseException { requireNonNull(expiry); String trimmedExpiry = expiry.trim(); - if (!Expiry.isValidDate(trimmedExpiry)) { + if (trimmedExpiry.equals("-") || !Expiry.isValidDate(trimmedExpiry)) { throw new ParseException(Expiry.MESSAGE_CONSTRAINTS); } return new Expiry(trimmedExpiry); diff --git a/src/main/java/seedu/address/model/util/SampleDataUtil.java b/src/main/java/seedu/address/model/util/SampleDataUtil.java index 014fe44e7bb4..a8b7fc08ffdd 100644 --- a/src/main/java/seedu/address/model/util/SampleDataUtil.java +++ b/src/main/java/seedu/address/model/util/SampleDataUtil.java @@ -23,21 +23,21 @@ public class SampleDataUtil { public static Medicine[] getSampleMedicines() { return new Medicine[] { - new Medicine(new Name("Aspirin"), new Company("Otsuka Pharmaceutical Co."), new Quantity("807"), - new Expiry("29/11/2019"), getTagSet("fever"), getBatchSet("CD485", "807", "29/11/2019")), - new Medicine(new Name("Atorvastatin"), new Company("Mitsubishi Tanabe Pharma"), new Quantity("296"), + new Medicine(new Name("Aspirin"), new Company("Otsuka Pharmaceutical Co."), new Quantity("27"), + new Expiry("29/11/2019"), getTagSet("fever"), getBatchSet("CD485", "27", "29/11/2019")), + new Medicine(new Name("Atorvastatin"), new Company("Mitsubishi Tanabe Pharma"), new Quantity("39"), new Expiry("31/12/2019"), getTagSet("cardiovascular"), - getBatchSet("BAL101025", "296", "31/12/2019")), - new Medicine(new Name("Bendroflumethiazide"), new Company("Piramal Healthcare"), new Quantity("58"), + getBatchSet("BAL101025", "39", "31/12/2019")), + new Medicine(new Name("Bendroflumethiazide"), new Company("Piramal Healthcare"), new Quantity("52"), new Expiry("03/10/2019"), getTagSet("hypertension", "tablet"), - getBatchSet("1001194", "58", "03/10/2019")), - new Medicine(new Name("Co-codamol"), new Company("Renovo PLC"), new Quantity("283"), - new Expiry("28/02/2020"), getTagSet("painkiller"), getBatchSet("HK-85412", "283", "28/02/2020")), - new Medicine(new Name("Omeprazole"), new Company("Eli Lilly and Company"), new Quantity("921"), + getBatchSet("1001194", "52", "03/10/2019")), + new Medicine(new Name("Co-codamol"), new Company("Renovo PLC"), new Quantity("28"), + new Expiry("28/02/2020"), getTagSet("painkiller"), getBatchSet("HK-85412", "28", "28/02/2020")), + new Medicine(new Name("Omeprazole"), new Company("Eli Lilly and Company"), new Quantity("121"), new Expiry("02/07/2019"), getTagSet("gastroesophageal"), - getBatchSet("A4415115698", "421", "02/07/2019", "A4415118456", "500", "22/09/2019")), - new Medicine(new Name("Simvastatin"), new Company("Vion Pharmaceuticals, Inc."), new Quantity("312"), - new Expiry("16/09/2019"), getTagSet("lipid"), getBatchSet("B5003B504", "312", "16/09/2019")) + getBatchSet("A4415115698", "21", "02/07/2019", "A4415118456", "100", "22/09/2019")), + new Medicine(new Name("Simvastatin"), new Company("Vion Pharmaceuticals, Inc."), new Quantity("41"), + new Expiry("16/09/2019"), getTagSet("lipid"), getBatchSet("B5003B504", "41", "16/09/2019")) }; } diff --git a/src/main/java/seedu/address/ui/BatchTable.java b/src/main/java/seedu/address/ui/BatchTable.java index fadd2e9c1926..b4af35d51b7d 100644 --- a/src/main/java/seedu/address/ui/BatchTable.java +++ b/src/main/java/seedu/address/ui/BatchTable.java @@ -64,6 +64,7 @@ public BatchTable(Medicine selectedMedicine, InformationPanelSettings informatio setColumnWidth(); populateTable(selectedMedicine); sortTable(informationPanelSettings); + disableSortingByClicks(); // To prevent sorting without change to InformationPanelSettings } private void setDescriptionTexts(Medicine selectedMedicine) { @@ -102,8 +103,6 @@ private void populateTable(Medicine selectedMedicine) { * Sorts the table depending on the {@code informationPanelSettings}. */ private void sortTable(InformationPanelSettings informationPanelSettings) { - table.getSortOrder().clear(); - SortProperty sortProperty = informationPanelSettings.getSortProperty(); SortDirection sortDirection = informationPanelSettings.getSortDirection(); @@ -122,12 +121,23 @@ private void sortTable(InformationPanelSettings informationPanelSettings) { throw new IllegalArgumentException("Unknown sort property."); } - if (sortDirection.equals(SortDirection.ASCENDING)) { + switch (sortDirection) { + case ASCENDING: column.setSortType(TableColumn.SortType.ASCENDING); - } else if (sortDirection.equals(SortDirection.DESCENDING)) { + break; + case DESCENDING: column.setSortType(TableColumn.SortType.DESCENDING); + break; + default: + throw new IllegalArgumentException("Unknown sort direction."); } table.getSortOrder().add(column); } + + private void disableSortingByClicks() { + numberColumn.setSortable(false); + quantityColumn.setSortable(false); + expiryColumn.setSortable(false); + } } diff --git a/src/main/java/seedu/address/ui/InformationPanel.java b/src/main/java/seedu/address/ui/InformationPanel.java index 738230a7924e..6c3c7f312e80 100644 --- a/src/main/java/seedu/address/ui/InformationPanel.java +++ b/src/main/java/seedu/address/ui/InformationPanel.java @@ -26,7 +26,6 @@ public class InformationPanel extends UiPart { public InformationPanel(ObservableValue selectedMedicine, ObservableValue settings) { super(FXML); - informationPanelSettings = settings.getValue(); // Load medicine information page when selected medicine changes.