Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pillbox Feature #142

Merged
merged 72 commits into from
Oct 7, 2021
Merged

Pillbox Feature #142

merged 72 commits into from
Oct 7, 2021

Conversation

RyanNerd
Copy link
Owner

@RyanNerd RyanNerd commented Sep 3, 2021

Major rewrite with many changes:

UI 💄

  • Rx Tab has 4 states set by 📻 radio buttons: Medicine, OTC, Pillbox, Print Medicine Checkout
    • Medicine lists the prescription meds for the active client and allows logging the meds
    • OTC lists all OTC drugs and allows logging these for the client
    • Pillbox 💊 📦 is a new feature that allows the user to create a pillbox that includes meds that the client takes in bulk.
    • For example an AM Regiment and a PM Regiment could be created making it easy to log these drugs en mass
    • Drug history is now limited to the last five days

Medicine can no longer be physically deleted, but is now deactivated.

Closes #140
Closes #142
Closes #146

- Set up observers for Pillbox and PillboxItem
- Create providers for Pillbox and PillboxItem
- Add `PillboxList`, `PillboxItemList`, `__pillbox`, `__pillboxItem` to the global settings
- Add `PillboxRecord` and `PillboxItemRecord` in RecordTypes.ts
- Set up observers for Pillbox and PillboxItem
- Create providers for Pillbox and PillboxItem
- Add `PillboxList`, `PillboxItemList`, `__pillbox`, `__pillboxItem` to the global settings
- Add `PillboxRecord` and `PillboxItemRecord` in RecordTypes.ts
- Got default pillbox and tab content to work via `active` attribute
- Added a really important field to `PillboxItemRecord` (MedicineId was missing)
- PillboxItemObserver.ts removal of `console.log()` diagnostic
- PillboxItemGrid.tsx component added
- Removal of unused imports in PillboxEdit.tsx
- Moved state for PillboxPage up to the LandingPage.tsx
- A bit of refactoring in PillboxPage.tsx
- Added scaffolding for edit and delete buttons for Pillboxes
- LandingPage.tsx fixed for tabs not being disabled when apiKey is not set
- Show hide logic for add drugs, Edit Pillbox and Delete Pillbox
- Delete Pillbox is fully functional with confirmation dialog.
- `activePillbox.Notes` now shows in the `<Card.Footer>`
- PillboxItemGrid.tsx returns null if there aren't any `pillboxItemList[]` items.
- `pillboxItemList[]` is filtered before being sent to the PillboxItemGrid.tsx
- If no drugs are in the active pillbox then a message displays indicating this otherwise the PillboxItemGrid.tsx is displayed
- Added missing Strength column in PillboxItemGrid.tsx
- Only display Pillbox notes if there are notes.
- 💄 UI change moved the + Add drugs to button inside the pillbox card.
   - sorting on Quantity, Drug
   - Removed 💥 delete button
   - Added small buttons of + qty
   - All medicines for the client are displayed in the grid
- PillboxPage.tsx changed to handle the new signature of PillboxItemGrid.tsx
- Added _multiSort()_ function in common.ts to handle multiple column sorting.
…utton

- Scaffolding set up for `onEdit()` handling in PillboxPage.tsx
  - The `Card.Title` now has a formatted pillbox name that looks similar to the selected `Nav` item.
  - Added some text to help users know how to determine what is in the selected pillbox
- Added Bootstrap color enumerator `BsColor` to common.ts
- Both PillboxPage.tsx and PillboxItemGrid.tsx use `BsColor` enum
- Moving state up to the LandingPage.tsx for global lists.
- Starting on the major revamp of MedicinePage.tsx so that it can support Pillboxes
- MedListGroup.tsx created to replace MedicineListGroup.tsx
- MedDropdown.tsx replaces MedicineDropdown.tsx
- Minor 💄 cosmetic changes to PillboxEdit.tsx
- Minor 💄 changes in PillboxPage.tsx
…and support pillboxes. activeId is used instead of activeDrug.

- Moved state from MedDropdown.tsx for the buildout of the listItems to MedListGroup.tsx. This solved a bunch of issues.
- Removed the `medicineList` and `pillboxList` from MedDropdown.tsx replacing them with an `itemList` prop that comes from the MedListGroup.tsx solving a bunch of issues.
- ActiveResidentObserver.ts uses the `usePrevious()` hook now.
- ApiKeyObserver.ts uses `asyncWrapper()` for better error control.
- Minor code clean-up in ConfirmDialogModal.tsx
- Very minor code clean-up in ErrorDetailsObserver.ts (removed a space)
- Added function getPillboxItems.ts so MedicinePage.tsx and PillboxPage.tsx can share code.
- Added `IPillboxItemObserver` interface to global.d.ts
- Some code clean-up for LandingPage.tsx as well as some todos. Also `<PillboxPage>`` takes additional attributes passed in from LandingPage.
- Minor code clean-up in MedDropdown.tsx
- Added `<PillboxItemGrid>` to be displayed when the selected activeId is a pillbox.
- Code clean-up for MedListGroup.tsx
 - `<TooltipButton>` replaced with a standard `<Button>`
 - Removed `tooltipText()` since it was displaying with the `<ToolTipButton>` anyway
 - Added a + Log ALL Drugs in Pillbox button (not currently functional
- PillboxItemGrid.tsx uses getPillboxItems.ts to build out the `PillRows. Some code clean-up.
- Code clean-up in PillboxItemObserver.ts
- PillboxPage.tsx
  - Added props refresh for `pillboxItemList`, `pillboxList`, and `activePillbox`
  - Use `getPillboxItems()` to fetch `PillboxItemRows`
- Added a `usePrevious()` hook.
- MedicinePage can now be in one of three states:
  1. Medicine - select and log prescriptions
  2. OTC - Select and log OTC drugs
  3. Pillbox - Select a pill box and log drugs therein
- Complete UI 💄 redesign for MedicinePage.tsx
- MedListGroup changed to **only** handle prescriptions (was handling pillbox and drugs -- needed separation of concerns)
- Removed Show/Hide OTC buttons in OtcListGroup
- Added PillboxListGroup.tsx
- Added radio buttons Medicine, OTC, and Pillbox to let user set state.
- OtcList global moved to LandingPage.tsx and passed into MedicinePage.tsx

Unrelated:
- Fixed getInitialState.ts `pillboxList` was missing an initializing value.
…using `usePrevious()` hook.

- Changed `LIST_TYPE` to `DISPLAY_TYPE` and added a Print to the enum.
- Removal of the `<Collapse>` component in OtcListGroup.tsx
- Conditional rendering fixed and updated in MedListGroup.tsx
- LandingPage.tsx documentation updated
- Moved the logic from PillboxPage as a landing page item instead making it a ListGroup item
- Fixed a bug in `getPillboxItemS()` where the filter wasn't including the `pillboxId`
- Removed the PillboxPage from the LandingPage
- Added PillboxCard.tsx as a more feature rich PillboxItemGrid
- MedicinePage.tsx updated to use PillboxListGroup new features and PillboxCard
- PillboxItemGrid.tsx 🏗️  scaffolding added for click on row functionality
- PillboxListGroup.tsx placeholder replaced with actual logic and features ⚛️
- Destroyed 💣 PillboxPage.tsx
- Destroyed 💣 MedicineListGroup.tsx
- Removed unused references
- Removed todos already done.
- Split prop update via hooks in MedicinePage.tsx into their own `useEffect()` hook. This seemed to be the reason that state of activeMed became unpredictable.

Other:
- In an attempt to sync up call backs were added to many observers (these are unused but left in place in case future need).
- New global activeClient was added (also unused but left in place in case a different direction for client state is decided on).
- cb property added to `__medicine` observer
- When a medicine is added or edited in MedicinePage.tsx the MedicineObserver cb sets `activeMed` to the added or edited medicine.
- `editMedicine` attribute added to MedListGroup to allow adding and editing of medicines.
- Couldn't get call back for activeOtc working in OtcListGroup so added todos.
- Call backs added to OtcMedicineObserver.ts
- Some minor code clean up.
- Combined `editOtcMedicine` and `addOtcMedicine` into just `editOtcMedicine`
- The MedicineDetail grid row will appear in bold if selected
- If there are pillboxes then they will appear at the top of the dropdown with a divider before the list of meds
- When a user clicks on a pillbox from the med dropdown that pillbox will become the activePillbox and the display will switch to the Pillbox view
- Saving progress and marking this as a rollback point since some major refactoring needs to take place:

Discovered a major bug in DrugLogObserver.ts
  - Separation of concerns: DrugLogObserver "update" is reloading the drugLogList every time an update occurs.
  - This is causing trouble with updates that happen in rapid succession (such as a logging all pills in a pillbox).
- Move + Log Pillbox to the right so it's less likely to accidently get clicked
- Added a button as a label for the Pillbox Dropdown
- Button as a label for the Pillbox Dropdown cursor style changed to `default`
- Grid selection height for OTC meds dynamically adjusts as valid search text is entered.
- When an OTC drug is selected the select text is updated to the Drug value
- Removed the `useEffect()` in MedicinePage.tsx for updating the `activeOtc` and instead set this to default to null
- When an OTC drug is selected the select text is updated to the Drug value
- Changed the `setActiveOtcDrug` prop name to `otcSelected`
- Disabled the + Log Drug and <LogButtons> if `activeOtc` is null
- Only show the <ListGroup.Item> for Directions and OtherNames if the `activeOtc.Drug === searchText`
- PillboxCard.tsx removed a todo that is a won't do. Cleaned up code
- PillboxItemGrid.tsx:
  - Removed a fixme that is already documented.
  - Removed a row click that did nothing.
  - Reduced the dropdown items from 10 to 5.
  - Code formatting
- Unrelated remove todos that are wontdo
- Dropped the OtcMedicineObserver.ts and MedicineObserver.ts in favor of direct calls to MedicalManager.
- Removed unneeded `e: React.MouseEvent` parameters from many call backs.
- Deleting a medicine actually marks it as inactive now.
- `isOtc` prop added to MedicineDetail.tsx (since deleting a OTC drug actually deletes the medicine).
- Bootstrap imports changed to be direct imports instead of importing the entire library (still more need to be changed but started on this).
- Removed the client roster printout by default as it didn't appear to be used very much anyway.
…ponents

- When the OTC search textbox is cleared the `activeOtc` gets set to null. This was causing visual sync up issues. The search text would be set to an empty string but the selected drug would still be active.
- Factored CheckoutListGroup.tsx from MedicineCheckoutPage.tsx
- Printing can happen on the MedicineCheckoutPage as well as the Rx (MedicinePage)
- Signature change for `clientFullName(client: ResidentRecord, includeNickname: boolean)` ClientButton is currently the only component that switches this to true.
- MedicinePage.tsx does not show second column when `displayType !== DisplayType.Print`
- Remove unneeded `e: React.MouseEvent<HTMLElement>` arguments in MedicineDetail.tsx and components that use it.
- Moved the todo: add search box to Manage OTC from comment to an issue
- Fixed a bug where even if cancel was chosen do delete an OTC drug the drug would get deleted anyway.
- ActiveResidentObserver.ts uses MedicineManager instead to refresh the `drugLogList` global
- In MedicineManager.ts changed the method name `loadPillboxItem()` to `loadPillboxItemList()`
- Removed `__drugLog` in global.d.ts and getInitialState.ts
- PillboxCard.tsx uses MedicineManager directly now.
- PillboxCard.tsx no longer takes `pillboxItemList` as a prop but gets this from `useGlobal()` also `setPillboxItemList()`.
- global.d.ts and getInitialState.ts reference to `__pillboxItem` observer removed.
- PillboxListGroup.tsx uses MedicineManager directly now.
- PillboxListGroup.tsx no longer takes `pillboxList` as a prop but gets this from `useGlobal()` also `setPillboxList()`.
- global.d.ts and getInitialState.ts reference to `__pillbox` observer removed.
- ApiKeyObserver uses ResidentManager directly.
- ResidentPage.tsx uses ResidentManager directly.
- Removed `__client` from global.d.ts and getInitialState.ts
- Fixed bug 🐛 in ActiveResidentObserver.ts where a Promise was being returned and saved as an error value.
- Removed unneeded `React.MouseEvent` arguments from ResidentGrid.tsx
ResidentPage.tsx
- Removed `focusRef` replacing it with `autoFocus` attribute
- Removed the `useEffect()` to set `focusRef`
- Combined `residentToDelete` into `showDeleteResident`

common.ts
- Start on making `asyncWrapper()` support generic typing ⌨️
@RyanNerd RyanNerd changed the title [WIP] Pillbox full feature Pillbox Feature Oct 1, 2021
- Moved updating and deleting of records process to MedicinePage.tsx
- Fixed a 🐛 bug where the dropdown QTY would stop working if a modal had been launched.
- Added props `onEdit`, `onDelete`, and `pillboxList`
- Added a disabled prop to PillboxListGroup.tsx
- When disabled is true a spinner will show on the Pillbox dropdown
- Improved how the alert shows for pillboxes that are logged today.
  - Added a badge to the + Log Pillbox with the time last logged (if logged today)
  - Alert is dismissible. If the alert is dismissed then + Log Pillbox is enabled (the logged time still appears as a badge in the button).
The child is PillboxLogGrid which displays a table of drugs and amounts logged for the current pillbox
- PillboxCard margins shrunk down so there's more screen realestate for the PillboxItemGrid
- Pillbox notes removed from PillboxCard to PillboxListGroup
- Code clean up. 🧹
- Multiple toasts via + Log Pillbox are listed in a single toast as are other single logged drugs
- Resident tab renamed Clients
- When saving (insert/update) drug log records the active ListGroup will show a spinner until the record update is complete and input elements will be disabled as well
- Focus is set to the search client textbox when Clients tab becomes active
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Limit the amount of past data Remove the delete option from the Manage Medicine page Pillbox
1 participant