Giter Site home page Giter Site logo

gerilife / caregiving Goto Github PK

View Code? Open in Web Editor NEW
7.0 1.0 6.0 430 KB

GeriLife is a comprehensive toolkit designed to empower caregivers in elder-care communities, promoting wellness and ensuring equitable engagement in life-enriching activities. This project, rooted in real-world insights and collaborative innovation, aims to transform elder care by making quality-of-life activities visible and coordinated.

License: European Union Public License 1.2

Python 86.00% HTML 13.53% Dockerfile 0.41% Procfile 0.02% CSS 0.05%
activity-tracking caregiving data-visualization elder-care elderly-people geriatrics home-care senior-life senior-living wellbeing

caregiving's People

Contributors

adrienneli104 avatar allcontributors[bot] avatar brylie avatar tbennur avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

caregiving's Issues

Add chart(s) to Home List view to show proportional workload by staff role

We want to show some statistical overview on the Homes List page, so there is actionable information at that level of aggregation. Add a statistical chart for each home showing the proportion of work carried out for each role in the home, e.g. what percentage of work was performed by each role. That way, the homes can be compared in some meaningful way and further details can be seen when clicking on the link to the Home Detail view.

Remove ECharts calendar heatmap

Now that we have a Plotly Express multi-series plot showing proportional caregiver work by role and type, we can remove the less-informative calendar heatmap (created with ECharts). We may decide to add it again, but for now let's clean up the code.

Add Activities app

Add the Activities app with Activity model.

Activity

  • activity_type
  • residents
  • caregiver_role
  • minutes

Form

Add activity form

Display

Recent activities table

Implement Data Fixtures or Data Generator for Residents App in Django

Background

In the development phase, testing different views, queries, and functionalities requires working with realistic data. To facilitate this, there is a need for a reliable method to create data fixtures or generate project data.

Task

  • Evaluate and determine the most efficient way to create data fixtures or generate project data, utilizing existing tools like factory_boy and Faker.
  • Develop and implement these fixtures or a data generator as a custom Django management command specifically for the residents app.

Key Considerations

  • Data Realism: Ensure that the generated data closely mimics real-world scenarios to enable effective testing.
  • Flexibility: The solution should allow for customization in terms of the the number of residents generated.
  • Integration: Ensure seamless integration with the current Django setup and workflows.

Technical Approach

  1. Assessment: Review the capabilities of factory_boy and Faker in the context of the project's data requirements.
  2. Design: Plan the structure of the data to be generated, including fields, relationships, and constraints relevant to the residents app.
    • Resident - at least plan to include data generator for residents
    • Residency - if possible, also include Residency generator, which would depend on Resident and Home generators (so is optional)
  3. Implementation:
    • Develop a custom Django management command that leverages factory_boy and Faker to generate realistic data for the residents app.
    • Ensure that the command is flexible, allowing developers to specify parameters like the number of residents to generate.
  4. Testing: Thoroughly test the command to ensure it generates data accurately and efficiently.

Resources

Expected Outcomes

  • A custom Django management command capable of generating realistic and diverse data sets for the residents app.
  • Documentation on how to use the command, including examples of different data generation scenarios.

Acceptance Criteria

  • The command successfully generates data that accurately represents potential real-life data in the residents app.
  • The data generation process is efficient, flexible, and integrates smoothly with the existing development environment.
  • Adequate documentation is provided for developers to utilize the command effectively.

This task is crucial for ensuring that the development team can test and refine the application with realistic data scenarios, ultimately leading to a more robust and reliable final product.

Integrate Weekly Activity Calendar into Home profile Residents listing

Introduction

  • Introduce a dynamic weekly activity calendar on the Home profile page to display resident activities.
  • Objective is to ensure consistent daily care and engagement.
  • Calendar can use HTML table structure and Bootstrap 5 classes

Screenshot_20231208_202037

Detailed Description

  • Calendar to dynamically reflect the past seven days, including "today" as the right-most column.
  • Check marks will indicate days when the resident was active.
  • Inactive days will show no mark.
  • The number of activities will be reflected in a separate column.

Use Case

  • Caregivers can visually track and balance activity distribution throughout the week.
  • Prevents clustering of activities, promoting daily resident engagement.

Technical Considerations

  • Calendar should update dynamically, with the current day always displayed in the right-most column.
    • Query/aggregation can run when requesting the page (no caching or other pre-computation)
  • When viewing on successive days, previous days shift left chronologically, with the oldest day dropping off.
  • Implementation should ensure minimal impact on load times and maintain responsiveness.

Alternatives Considered

  • Static list views lack the temporal context provided by the calendar grid.

Additional Context

  • The feature received positive feedback for its intuitive design in prototype testing.
  • The dynamic nature of the calendar was specifically highlighted as a useful feature.

[Bug]: remove duplicate time unit from Add Work form

Description

The Add Work form has two time-related fields:

  • duration minutes
  • duration hours

image

Steps to Reproduce

  1. start the app
  2. log in
  3. click the Add Work on the navigation menu

Expected Behavior

Only duration minutes or duration hours would be required.

Actual Behavior

Duplicate time fields which can lead to inconsistencies.

Possible Solution

Remove one of the fields and derive it from the remaining field.

Context

No response

Web Browser

N/A

Operating System

N/A

Your Environment

No response

Create initial Home profile page

Create as much of the Home page from the previous GeriLife Wellbeing application as is possible. Open a follow-up ticket for any remaining items.

image

Sub-issues

This issue is split into the following sub-issues

Create Mock Data Generator for Resident Activities

Add a mock data generator for activities, aiming to create a realistic data set for development and testing purposes.

Detailed Description

  • The generator will produce a random number of activities per resident, ranging from 10 to 30.
  • All activities will be backdated within the past 30 days to simulate a typical month.
  • Randomization will apply to all activity properties, including:
    • duration_m: Randomly set to 15, 30, 45, or 60 minutes.
    • caregiver_role: Randomly selected from the predefined caregiver roles.
    • activity_type: Randomly chosen from the available activity types.
  • The generated data should have a natural variance to mimic real-world scenarios.

Use Case

  • Facilitates UI testing by providing a diverse data set.
  • Assists in demonstrations to stakeholders and potential clients.
  • Enhances the development process with a rich, local testing environment.

Technical Considerations

  • Implement a script or management command within the Django framework for ease of use.
  • Utilize a probability distribution to ensure organic data variety, leveraging libraries such as numpy, scipy, or statsmodels which are already included in the project.
  • The generator should create a realistic spread of activity durations and types, using the probability distribution functions available in these libraries to select values.
  • Ensure the generator script is idempotent, allowing it to be run multiple times without duplicating data.
  • Generate a diverse set of data reflecting various resident activity levels, though perfect distribution across levels is not a requirement for the initial iteration.

Additional Context

  • While achieving a spread across different activity levels is ideal, the initial version need not strictly enforce this distribution.

Enable localization

Users need to see application text in their native language. To this end, we will add internationalization to all default texts. Once the texts are internationalized, we will have a localization process to translate the texts into supported languages.

Task

  • ensure all UI texts are internationalized
  • ensure users can select from enabled languages
  • localize UI texts into initial language(s)

Add "Groups" Feature with Home Lists and View Buttons

Introduction

  • Proposal to create a "Groups" feature, which will organize Homes into defined groups on a new page using Bootstrap 5 cards and lists.

Screenshot_20231208_215529

Detailed Description

  • A new "Groups" page will be created to list all the Groups.
  • Each Group will be represented as a Bootstrap 5 card.
  • The Group name will be displayed as the card title.
  • Within each card, display a Bootstrap 5 list showing the homes associated with that group.
  • Each home in the list will have:
    • Home name displayed.
    • A "View" button to the left of the home name, styled with a Bootstrap icon (e.g., an eye icon) to indicate navigation to the Home profile page.
  • The "View" button will link to the corresponding Home profile page.
  • Visual: Screenshot provided should be used as a reference for the "View" button design and placement.

Use Case

  • Facilitates the management and organization of multiple Homes within larger Groups.
  • Provides quick navigation to each Home profile from the Groups page.

Technical Considerations

  • Ensure proper routing and linking of the "View" buttons to the respective Home profile pages.
  • Cards and lists should be responsive and maintain the overall design language of the application.
  • Accessibility considerations should be taken into account, ensuring that icons and buttons are easily identifiable and usable.

Alternatives Considered

  • N/A, as the card layout provides a clear and organized way to represent groups and their associated homes.

Additional Context

  • The visual styling should be consistent with existing Bootstrap 5 elements used in the project.
  • Care should be taken to ensure that the Groups page is scalable and performs well even with a large number of groups and homes.

This issue is intended to clearly define the requirements for the new Groups feature, ensuring a user-friendly interface that aligns with the current design system used throughout the project. The provided screenshot will serve as a visual guide for the expected outcome.

Add `make_fake_data` Command for Generating Comprehensive Fake Data

Overview: Implement a make_fake_data management command in Django that generates 30 days of complete, interconnected fake data for development and demonstration purposes.

Background/Context:

  • To effectively test and demonstrate the application's functionality, there's a need for realistic and interconnected fake data that mimics real-world scenarios.
  • The data should reflect the natural order and interdependencies of our data model.

Goals/Objectives:

  • Develop a command that systematically generates fake data across different models (HomeGroups, Homes, Residencies, and ResidentActivity).
  • Ensure the data covers a variety of scenarios, including different activity levels and home group associations.

Acceptance Criteria

  • Successful execution of the make_fake_data command without errors.
  • Generation of data for HomeGroups, Homes (both within and outside of home groups), Residencies, and ResidentActivities.
  • Data reflects specified ranges and probabilities (e.g., number of homes per HomeGroup, active vs. moved-out residencies).
  • Verification that the generated data is suitable for testing different application scenarios.

Tasks/Subtasks

  1. HomeGroups Generation: Create 3-5 HomeGroups.
  2. Homes Generation Within HomeGroups: For each HomeGroup, generate 2-3 Homes.
  3. Homes Generation Without HomeGroups: Generate 3-5 standalone Homes.
  4. Residencies and Residents Generation: For each Home, create 5-15 Residencies and corresponding Residents. Assign move-out dates based on a 60% probability of being active.
  5. ResidentActivity Generation: For each Resident, create 7-60 ResidentActivity instances within the past 30 days.
  6. Data Integrity and Interconnections: Ensure data reflects natural order and interdependencies.
  7. Testing and Validation: Test the command thoroughly to validate data generation and integrity.

Dependencies

  • Understanding of the existing data models and their relationships.

Implement 'ResidentActivity' Model in New 'Metrics' App for Efficient Data Aggregation

Overview

Our current Activity data model, while robust, presents challenges in generating charts and reports due to its complex relationships, particularly the ManyToMany relationship between Residents and Activities. To streamline data aggregation and improve performance, we propose creating a new Django application, metrics, featuring a more efficient data model.

Proposed Model: ResidentActivity

  • Purpose: Simplify querying and aggregating activity data by flattening the complex relationships.
  • Structure:
    • resident: ForeignKey(Resident)
    • activity: ForeignKey(Activity)
    • residency: ForeignKey(Residency) - Linking Resident and Home at the activity time
    • home: ForeignKey(Home) - Derived from residency
    • activity_type: string
    • activity_minutes: int
    • caregiver_role: str

Synchronization with Activity Model

Ensuring data consistency between the Activity and ResidentActivity models is critical. We are considering two approaches:

  1. Custom Django Model Manager:

    • Implement Create, Read, Update, Delete (CRUD) operations within a transaction.
    • Automatically handle ResidentActivity entries whenever an Activity record is modified.
    • Rollback changes if any part of the transaction fails.
  2. Django Signals:

    • Utilize signals to update ResidentActivity entries upon CRUD operations on Activity records.
    • This approach decouples the logic but still ensures data synchronization.

Task Breakdown

  1. Create metrics App: Develop the new Django application within our project.
  2. Model Implementation: Define and implement the ResidentActivity model.
  3. Data Synchronization Strategy: Choose and implement the most suitable method (Model Manager or Signals) for data synchronization.
  4. Testing and Validation: Ensure that the new model accurately reflects changes in the Activity model and that data integrity is maintained.
  5. Performance Benchmarking: Assess the impact on performance and the efficiency of data aggregation.

Next Steps

Once the metrics application and ResidentActivity model are established, we will focus on defining specific metrics and developing visualizations to support caregiving in elder care communities.

Conclusion

This initiative aims to enhance our data handling capabilities, making it easier to generate meaningful insights and reports. The success of this implementation will lay the groundwork for advanced analytics in our caregiving project.

Refactor duplicate code for Work Report and Home Detail view

The Work Report and Home Detail view contain a significant amount of duplicated code. However, the code contains subtle changes, due to filtering the work reports on the Home Detail view.

Task

  • determine how to share code/queries between the Work Report and Home Detail view
  • create a new app called metrics
  • move the shared code to the new app
  • make changes to the code so it can be shared across the two views

Add work percent by role and type to global report view

We want to experiment with displaying the percent of work done by each role for particular types of work. E.g. "nurses spend X% of time doing Y activity"

This will help to ensure that workers are doing work that is appropriate for their expertise and can inform staff hiring.

MVP reports

We want technology to make ”Indirect work” visible. Basically I just want to find out how many minutes staff (different roles) is doing the work

Ensure we have the following MVP reports:

  • work/all homes
  • work by facilitator role in all homes.
  • work/unit
  • work by facilitator role/unit

[Feature]: Add Django debug toolbar

Feature Description

Add the Django debug toolbar and ensure it is only enabled in debug mode.

Motivation

We want to debug and audit our Django views for things like query slowness and other possible optimizations.

Possible Implementation

Install and configure Django debug toolbar.

Add initial "Duties" prototype

We want to raise awareness about caregiving duties. To that end, we need a streamlined way for users to record duties.

Duty model

The Duty model might contain the following fields:

  • uuid: a unique ID for the Duty instance, alternatively consider using big ID, if that is sufficient
  • type: the type of Duty, with default CHOICES
  • caregiver: the User who completed the task, consider whether an intermediary model would be useful instead of using the User model directly
    • alternatively, extend the User model with an is_caregiver attribute, useful for filtering and distinguishing between types of users (staff, administrator, etc.)
  • caregiver_role: the role of the Caregiver who completed the task, with predefined CHOICES
  • date: the date the Duty was completed
  • time: the time the Duty was completed
  • timezone: the timezone where the Duty was completed, used for accurate display and analytics
  • created_by: the user that created the Duty instance
  • created: the DateTime (in UTC) when the Duty instance was created

Extended Duty model

If the above Duty model is fairly easy to achieve, consider extending the Duty model as part of this task to include the following fields. Otherwise, the relationships can be continued in a subsequent task.

  • home: the related Home where the Duty was completed

Task

  • add initial Duties app
  • define options for duty type
  • add localization to pre-defined data, where possible
  • determine the minimum-viable approach for date/time data with timezone support
  • consider adding relationships to the Home and Caregivers models from the Duty model

[Feature]: Integrate IBM Carbon Design System for Enhanced Enterprise-Grade UI and User Experience

Feature Description

Integrate IBM's Carbon Design System into our project as a complement or replacement for Bootstrap. This transition aims to enhance the professional appearance, usability, and modernity of our web application's UI, especially focusing on forms, data tables, and bespoke dashboards. Carbon's enterprise-oriented design language aligns perfectly with the goal of appealing to enterprise customers while supporting our users effectively in their daily tasks.

Motivation

Our current use of Bootstrap, while effective, lacks the specific focus and advanced features needed for enterprise-grade applications. By experimenting with the Carbon Design System, we can leverage its professional design language, adherence to web standards, and modern UI conventions. This aligns with our goal to offer an application that not only meets but exceeds the expectations of enterprise clients, particularly in areas where our application is most utilized – forms, data tables, and custom dashboards.

Possible Implementation

  • Gradual Transition: Start by applying Carbon Design components in less complex parts of the application to assess compatibility and ease of integration.
  • Forms and Data Tables: Utilize Carbon's comprehensive set of form elements and data table configurations to enhance user interactions and data presentation.
  • Dashboards: Leverage Carbon's grid system and UI components to redesign dashboards, ensuring a cohesive and intuitive user experience.
  • Carbon Charts: Explore replacing Plotly with Carbon Charts for a more integrated and consistent visualization experience across the application.
  • Compatibility Check: Ensure seamless coexistence or transition from Bootstrap to Carbon, maintaining application stability throughout the process.

Alternatives Considered

Continuing with Bootstrap, while feasible, may not fully meet the evolving demands of our enterprise clients. Other design systems were considered, but Carbon's alignment with enterprise needs and its comprehensive design and component offerings make it the most suitable choice.

Additional Context

  • Enterprise Appeal: Carbon's design system is meticulously crafted to cater to enterprise needs, offering a more tailored solution than Bootstrap.
  • Standard Adherence: Carbon is built with adherence to accessibility and international web standards, ensuring our product is usable by a wide audience.
  • Vanilla HTML/CSS/JS Support: Carbon works with core web technologies, making it a versatile choice for our diverse tech stack.
  • User Interaction Modalities: Carbon introduces new interaction patterns, potentially offering a more intuitive user experience.
  • Design Consistency: Using a single, comprehensive design system like Carbon can bring uniformity and consistency across various elements of the application.
  • Community and Support: IBM's backing provides a robust support system and community, ensuring ongoing updates and enhancements to the design system.

This proposal to experiment with and potentially adopt the IBM Carbon Design System reflects our commitment to staying at the forefront of modern web application design, prioritizing both user experience and client appeal.

Resources

  • IBM Carbon Design System Official Website: This is the primary resource for all things related to the Carbon Design System. It includes guidelines, components, patterns, and much more. Visit Carbon Design System
  • Carbon Design System on GitHub: For developers, this GitHub repository is an invaluable resource. It contains the source code, component libraries, and development guides. Carbon Design System GitHub
  • Carbon Charts: A dedicated library of chart components designed to work seamlessly with the Carbon Design System, offering a potential alternative to Plotly for data visualization. Carbon Charts
  • IBM Design Language: Understanding the IBM Design Language will provide context on the principles underpinning the Carbon Design System. IBM Design Language
  • Carbon Design System Documentation: Detailed documentation that covers implementation, component usage, design guidelines, and much more. Carbon Documentation
  • Developer Tutorials for Carbon: These tutorials are excellent for developers to get hands-on experience with implementing Carbon Design System components. Carbon Tutorials
  • IBM Carbon Design System Medium Blog: For the latest updates, user stories, and articles written by the Carbon Design System team and community. IBM Carbon Medium Blog
  • IBM Accessibility Standards: Since Carbon adheres to accessibility standards, understanding IBM's approach to accessibility might be beneficial. IBM Accessibility

These resources will provide a comprehensive understanding of the Carbon Design System, its components, design philosophy, and how it can be implemented and utilized in our project.

Add User Assignment to Homes for Access Control

Add the ability to assign users to specific homes, which will form the basis of basic access control within the application.

Detailed Description

  • The system will allow for users to be associated with one or more homes.
  • The Homes page will only list the homes to which a regular user has been assigned.
  • Users attempting to access a Home profile without proper assignment will encounter a 403 error page.
  • Properly assigned users will have full access to the Home profile, including the ability to create activities for residents of the home.

Use Case

  • Enables finer control over user access, ensuring users only interact with homes relevant to them.
  • Enhances security by restricting user access to authorized homes only.

Technical Considerations

  • Update the user model to include a many-to-many relationship with homes.
  • Modify the Homes page view to filter the list of homes based on the user's assignments.
  • Implement access control checks in the Home profile view to return a 403 error for unauthorized access attempts.
  • Ensure the activity creation functionality checks for user assignment to the relevant home.

Alternatives Considered

  • Considered role-based access control but decided on a direct assignment approach for simplicity.

Additional Context

  • This feature requires updates to the database schema, views, and possibly middleware for access checks.
  • Proper testing should be conducted to ensure that access control is enforced consistently across the application.

Certainly, here is the UI/UX section for the GitHub issue regarding user assignment to homes:

UI/UX Considerations

  • A "Assign User" button will be added to the Home profile page visible only to staff or superuser accounts.
  • Clicking the "Assign User" button will redirect to a new form page dedicated to user assignment.
  • The form will contain:
    • An input field for 'email address'
    • A pre-populated 'home' select menu, defaulting to the home currently being viewed.
    • 'Submit' and 'Cancel' buttons for form operations.
  • On form submission:
    • A POST request will be processed by a dedicated view.
    • If an existing user is found for the email address, a new record will be added to a many-to-many table (e.g., HomeUsers) linking the user to the home.
      • If no user is found for an email address, the form submission will result in an error message being returned to the user causing a Django message to display: "No registered user found for the following email addresses: ..."
      • The user will be redirected back to the Home profile page, which now includes an updated list of assigned users for verification.

Use shortuuid for model URL slugs

We will want to locate model instances by a short URL slug, which is non-sequential.

Task

  • add the shortuuid package to the project
  • add a ShortUuidField to each model that we would retrieve via URL slug
  • consider whether to use the ShortUuidField as the primary key or just a url_uuid field

[Feature]: Implement Async Views and Database Operations in Django for Enhanced Performanc

Feature Description

Port existing views and database operations in the project to utilize Python/Django's asynchronous features. This enhancement involves refactoring current synchronous views and database interactions to asynchronous ones using the latest async capabilities provided by Django. The objective is to improve the overall performance and scalability of the application by enabling non-blocking database operations and handling concurrent requests more efficiently.

Motivation

As the application grows in complexity and user base, performance and scalability become increasingly important. Traditional synchronous processing can lead to inefficiencies, especially under heavy load. By adopting Django's async features, we can handle more requests simultaneously, reduce response times, and improve user experience, particularly in data-intensive operations. This shift is also in line with modern web development practices, ensuring our application remains robust and future-proof.

Possible Implementation

  • Refactor views to asynchronous using Django's async def where appropriate.
  • Utilize asyncio along with Django's support for async ORM queries for database operations.
  • Ensure middleware, context processors, and authentication backends are compatible with async views.
  • Conduct thorough testing to ensure that the asynchronous implementation maintains the current functionality and improves performance.
  • Gradual rollout: Start by converting less critical views and monitor for performance gains and potential issues before moving to more critical parts of the application.

Alternatives Considered

The primary alternative to implementing Django's async features is to continue using synchronous views and database operations. This approach relies on the existing, well-understood synchronous programming model, ensuring stability and maintaining the current performance benchmarks. While it lacks the potential performance improvements of async processing, it avoids the complexities and potential challenges involved in refactoring to asynchronous code. This approach would be more about optimizing within the current synchronous framework, focusing on database query optimizations, efficient view logic, and potentially leveraging caching strategies to improve performance.

Additional Context

This transition to asynchronous processing is part of a strategic move towards adopting modern web development practices. It requires careful planning and testing to ensure seamless integration with the existing synchronous parts of the application. The latest version of Django's improved async support makes it a suitable time for this upgrade.

Documentation

For adding Django async support, the official Django documentation provides a comprehensive guide on implementing asynchronous support. Key aspects include:

  1. Asynchronous ORM Queries: Django supports async ORM queries, allowing you to run database queries asynchronously. This includes methods with an 'a'-prefix for asynchronous variants and support for async for on all QuerySets.
  2. Async Model Methods: Django also supports asynchronous model methods, such as asave and acreate, which can be used for database operations.
  3. Performance Considerations: It's important to note the performance implications of running async views under WSGI or sync views under ASGI. Django tries to minimize context-switches between sync and async, but mixing them can lead to a performance penalty.
  4. Async Safety: Certain parts of Django, like the ORM, are not safe to use in an async environment due to global state that is not coroutine-aware. To handle this, Django protects async-unsafe parts from execution in an async environment, and you can use sync_to_async() for calling sync functions from an async context.
  5. Async Adapter Functions: Django uses adapter functions like async_to_sync() and sync_to_async() from the asgiref.sync module to adapt calling styles between sync and async code.
  6. Handling Disconnects: For long-lived requests, an asyncio.CancelledError might be raised if a client disconnects before the view returns a response.

The Django documentation covers these topics and more in-depth and is an essential resource for implementing async in Django. You can read more about asynchronous support in Django on the official documentation.

Additionally, the DEV Community provides an article discussing the comparison between WSGI and ASGI in the context of Django, highlighting the benefits of ASGI for async support, including scalability, concurrency, and real-time functionality. It also covers why ASGI is needed for async support in Django and provides a comparison of Uvicorn and Daphne, two popular ASGI server implementations. You can read more about this on the DEV Community article.

Add Resident Activity Levels Visualization on Groups Page

Continued from #57

Add a horizontal bar chart for resident activity levels beside each home listed on the Groups page.

Screenshot_20231208_220759

Detailed Description

  • Integrate a bar chart indicating percentages of residents by activity level: inactive, low, good, high.
  • Utilize the activity_level method from the Resident model to determine activity statuses.
  • Develop get_percent_residents_by_activity_level as the main aggregation function.
  • The chart will be added next to each home, displaying the data distribution.
  • Visual: The provided screenshot illustrates the chart layout and expected appearance.

Use Case

  • Offers a visual summary of resident engagement, aiding in activity management.

Technical Considerations

  • Introduce property methods in the Home model for active residency counts and resident activity level aggregation.
  • Optimize data processing for real-time updates and ensure the chart's responsive design.

Alternatives Considered

  • A direct SQL approach using the ResidentActivitiesTable to join on active residencies and aggregate recent activities.
  • Filtering for activities within the past seven days, with aggregation by resident activity count.
  • Apply activity level labels based on the WEEKLY_ACTIVITY_RANGES constant for consistency.
  • This method could potentially improve performance by reducing the overhead of multiple ORM calls.

Additional Context

  • The chart complements current data representations and aims to enhance the dashboard's analytical utility.

Implement Activity Level Trends Chart on Home Profile Template

We aim to enhance the Home profile template by adding a multi-line chart to display activity level trends of residents over the past seven days. This visualization will provide insights into the daily activity patterns of residents, categorized into four levels: inactive, low, good, and high.

image

Objective

To visualize the trend of activity levels of residents in a specific home, helping staff and caregivers to monitor and understand changes in resident activity patterns.

Chart Details

  • Type: Multi-Line Chart
  • X-Axis: Dates of the past seven days.
  • Y-Axis: Integer count of residents.
  • Lines: Four lines representing the daily count of residents with different activity levels (inactive, low, good, high).
  • Color Coding: Each line will have a distinct color corresponding to its activity level.

Data Calculation

  • Activity Levels: Defined by the WEEKLY_ACTIVITY_RANGES constant.
  • Data Source: Resident activities, homes, and residencies data. For each of the past seven days, calculate the number of residents in the home and their respective activity levels based on the past week's activities.
  • Activity Level Calculation: The resident's activity level is determined by the count of activities over the prior seven days from the date of counting.

Aggregation Summary for Activity Level Trends Chart

The core of this chart lies in the aggregation of resident activity data to accurately represent activity levels over the past seven days. This involves several key steps:

  1. Time Frame Selection: Identify the seven-day period for analysis, ending with the current date.
  2. Residency Determination: For each day within this period, get a list of residents who were living in the home. This requires checking the move_in and move_out dates for each residency.
  3. Activity Counting: For each resident, count the number of activities they participated in during the seven days prior to the specific date being analyzed.
  4. Categorization: Based on the counted activities, categorize each resident into one of the four activity levels (inactive, low, good, high) as defined by WEEKLY_ACTIVITY_RANGES.
  5. Daily Aggregation: For each of the past seven days, aggregate the number of residents in each activity level category.
  6. Data Structuring: Organize this aggregated data in a format suitable for the multi-line chart, ensuring each line represents one of the activity level categories across the seven-day period.
  7. Data Integrity and Performance: Ensure the aggregation logic is optimized for performance, especially considering the potentially large dataset of residents and activities.

Design Considerations

  • Ensure the chart is visually consistent with the existing UI design of the Home profile template.
  • The chart should be responsive and easily interpretable.
  • Default to dark mode theme

Technical Requirements

  • Implement the chart using Plotly Python (with logic being defined in Python rather than JavaScript)
  • Backend logic should efficiently aggregate and process data to feed into the chart.

Reference Image

picture showing desired output

Acceptance Criteria

  • A multi-line chart accurately displaying the trend of resident activity levels over the past seven days is present on the Home profile template.
  • The chart updates dynamically with the latest data (when page is reloaded).
  • The implementation is efficient, responsive, and aligns with the design aesthetics of the platform.

Create initial Resident page

Create as much of the resident page from the previous GeriLife Wellbeing application as is possible. Open a follow-up ticket for any remaining items.

screen shot of original resident page

Home Resident Percent by Activity Level Do Not Sum to 100%

There is a bug in the function resident_counts_by_activity_level where the calculated percentages for
each activity level (inactive, low active, good active, high active) do not sum up to 100%.

image

Expected Behavior

The sum of the percentages for all activity levels should be exactly 100%.

Current Behavior

The current implementation results in a sum that can be slightly lower or higher than 100%.

Steps to Reproduce

  1. Call the resident_counts_by_activity_level method on a Home instance.
  2. Observe the output percentages for each activity level.
  3. Note that the sum of these percentages is not always 100%.

Possible Solution

A rounding strategy needs to be implemented to adjust the individual percentages so that they sum up to 100%,
while still reflecting the accurate proportions as closely as possible.

[Feature]: Implement HTMX on Resident Page for Asynchronous Chart Loading

Feature Description

Integrate HTMX into the Resident page to enable asynchronous loading of chart data. The goal is to have the page load immediately with placeholders where charts will be displayed. HTMX will then send a GET request to a backend view for each chart. This view returns the chart's HTML, which is processed asynchronously and loaded into the page as soon as it's ready. This approach will enhance the user experience by providing immediate page feedback and gradually loading complex data.

Motivation

The current Resident page load time is slow due to the synchronous loading of complex chart data. This leads to a suboptimal user experience. By integrating HTMX, we aim to improve page load times, provide immediate feedback to users, and enhance the overall user interface responsiveness. Asynchronous loading of charts will ensure that users are not kept waiting and that they can interact with other page elements while data is being processed.

Possible Implementation

Implement HTMX on the Resident page by adding hx-get attributes to placeholder elements where charts will be displayed. Create dedicated Django views for processing each chart's data. These views will return HTML snippets containing the rendered charts. Use Django channels or background tasks for asynchronous data processing. Ensure that the frontend gracefully handles the asynchronous insertion of these charts into the DOM.

Alternatives Considered

Alternatives such as Ajax calls and client-side JavaScript frameworks were considered. However, HTMX provides a simpler implementation with less JavaScript, aligning well with the current project's technology stack and coding practices.

Additional Context

This feature is part of an ongoing effort to improve the application's performance and user experience. It aligns with our goals to make the application more efficient and user-friendly.

[Feature]: Create fake Work data generator

Feature Description

While developing, we would like to have some fake Work data to preview and test the app.

Motivation

The fake data would help us demo and develop the app.

Possible Implementation

Generate a significant amount of work data sufficient to demonstrate all Work-related charts, such as 30 or 365 days (depending on the chart contents.) Include the Work-data generation code when calling the make_fake_data command.

Alternatives Considered

Manually creating the data but this is a bit tedious and doesn't help with demonstrating the software quickly.

Redirect user to "current" view when submitting work

We currently have a modal dialogue for submitting work reports. However, the user is redirected to the Home page when submitting a work report. It may be more natural to redirect the user to the page they were viewing when they submitted the modal dialogue.

Deprecate Activity Model in Favor of ResidentActivity

Deprecate the Activity model and transition all functionalities to the ResidentActivity model.

Background/Context:

  • Currently, we have two models: Activity for building application views and ResidentActivity for efficient metric aggregations.
  • Maintaining both models in sync is creating unnecessary complexity.
  • The ResidentActivity model is capable of fulfilling application requirements, ranging from page building to analytics.

Goals/Objectives:

  • Deprecate the Activity model.
  • Transition all functionalities and references to the ResidentActivity model.
  • Possibly extend the ResidentActivity model to include an activity_group field for enhanced analytics.

Acceptance Criteria

  • Complete removal of the Activity model from the codebase.
  • Refactoring of all existing functionalities to use the ResidentActivity model.
  • Successful migration of any relevant data from Activity to ResidentActivity.
  • Implementation of the activity_group field in the ResidentActivity model, if required.
  • All tests passing with the new model structure.

Tasks/Subtasks

  1. Analyze all current usages of the Activity model.
  2. Plan the migration strategy for data and functionalities to ResidentActivity.
  3. Implement the changes in the codebase.
  4. Conduct thorough testing to ensure functionality.
  5. Update documentation to reflect the changes.

Dependencies

  • Review of current implementation to identify all dependencies related to the Activity model.

Home profile: monthly grouped bar chart for Activity Minutes or Hours by Caregiver Role

Introduction

On the Home profile page, implement a new bar chart report that groups activity minutes or hours by month and caregiver role.

Screenshot_20231208_213335

This is a grouped bar chart where the data are grouped by month and subgrouped by activity type with an aggregated sum of activity minutes (or hours.)

Detailed Description

  • Each bar represents a month, starting from the first day of the month and including the year in the datetime. (e.g., 2023-11-01)
  • The vertical height of each bar corresponds to the total sum of activity minutes or hours for that month.
  • Bars are further subdivided into segments, each representing an caregiver role with its sum of minutes or hours.
  • The chart should display data for the last complete year, up to the current month.

Use Case

  • This report allows for a better understanding of monthly trends in resident activity.
  • As a future goal: Facilitates year-on-year comparisons of activity engagement and helps in resource planning.

Technical Considerations

  • The report should dynamically adjust to include the most recent 12 months of data.
  • Data processing must ensure accuracy in summing and grouping the activity data.
  • The chart must be visually distinct and legible, with clear legends and scaling.

Alternatives Considered

  • A simple cumulative graph was considered but does not provide the granularity or seasonality of monthly caregiver roles.

Additional Context

  • The new chart is expected to align with the styling and interaction of the existing grouped bar charts.
  • The current charting library should be assessed for suitability with the new requirements.

Add a dark/light mode toggle switch on navbar

Now that Bootstrap 5.3 supports dark and light mode and we have set the dark mode on our base html element, we can allow users to toggle their preferred mode.

Task

  • add a button, icon, or toggle widget on the navbar to allow users to toggle between dark and light mode
  • bonus: user preference is saved across sessions (e.g., localstorage?)
  • bonus: users can save their preference on a "my preferences" page when logged in (this is a stretch goal, so don't worry about it for now)

Resources

Implement Nordhealth Design System for Enhanced UI Aesthetics and Accessibility

Feature Description

Our project aims to appeal to decision-makers in large institutional care networks. To achieve this, we propose adopting the Nordhealth Design System for our UI components. Nordhealth's design system offers a professional, sleek aesthetic and includes numerous usability and accessibility features that would significantly enhance the user experience of our project.

Motivation

The decision to integrate the Nordhealth Design System is motivated by several key factors:

Professional Aesthetics: A polished and professional user interface is crucial for making a strong impression on decision-makers in large care networks. Nordhealth's design system offers a contemporary, clean look that aligns with this goal.

Usability and Accessibility Improvements: Nordhealth's design system is built with accessibility and usability at its core. Implementing it would ensure our application is more user-friendly and accessible to a wider audience, including those with disabilities.

Ease of Design Scalability: As our project grows, the need for a scalable design system becomes more apparent. Nordhealth provides a robust framework for scaling our UI design efficiently.

Figma Integration: For future UI design enhancements, the availability of Figma components within the Nordhealth design system is highly beneficial. This would streamline our design process, especially if we onboard professional UI designers.

Possible Implementation

The implementation would involve a phased approach:

Evaluation Phase: Assess the compatibility of Nordhealth design system with our current UI and backend framework.

Planning Phase: Develop a detailed plan for the integration, including timelines and resources needed.

Implementation Phase: Gradual replacement of current UI components with those from the Nordhealth design system, ensuring minimal disruption to existing users.

Testing and Feedback Phase: Rigorous testing for usability and accessibility, followed by gathering feedback from a select user group.

Roll-out Phase: Full implementation of the design system across the platform, accompanied by user education initiatives as needed.

Alternatives Considered

We have considered maintaining our current design or adopting other design systems. However, the specific benefits of Nordhealth in terms of professional aesthetics and its focus on healthcare contexts make it a more compelling choice.

Additional Context

Further information about the Nordhealth Design System can be found at Nordhealth Design. The design system's focus on healthcare interfaces aligns well with the needs of our project, making it an ideal candidate for our UI overhaul.

Implement Stacked Bar Chart for Activity Counts by Resident and Activity Type

Objective

To introduce a stacked bar chart on the Home profile template that displays activity counts grouped by resident and activity type. This visualization aims to provide a clear overview of each resident's participation in different activities, enhancing the understanding of individual engagement patterns.

Chart Details

  • Type: Stacked Bar Chart (Horizontal Orientation)
  • X-Axis: Activity Count.
  • Y-Axis: Residents (each bar represents a resident with their name as the label).
  • Bar Composition: Each resident's bar is a stack of colors, each representing a different activity type they participated in.
  • Color Coding: Consistent across all bars, where each color denotes the same activity type.

Data Calculation and Aggregation

  • Data Source: Activity records.
  • Aggregation Method: Group activity records first by resident, then by activity type. For each grouping, aggregate to a single count representing the number of times the resident participated in that activity type.
  • Bar Composition: Each resident's bar in the chart will consist of segments (stacked), each segment’s length proportional to the count of activities of that type the resident participated in.
  • Color Consistency: Maintain uniformity in color representation for each activity type across all resident bars.

Aggregation Summary for Activity Counts by Resident and Activity Type Chart

This chart requires a multi-level aggregation approach:

  1. Resident Identification: For each resident, compile all their activity records.
  2. Activity Type Grouping: Within each resident's data, group the activities by type.
  3. Count Aggregation: For each group (resident-activity type combination), count the total number of activities.
  4. Bar Segment Representation: Represent each activity type count as a segment in the resident's bar, with the segment's length corresponding to the activity count.
  5. Color Coding: Assign a unique color to each activity type and use this color consistently across all residents' bars.
  6. Data Structuring for Visualization: Organize the aggregated data to fit the stacked bar chart format, ensuring clarity in representing each resident's activity engagement.

Design Considerations

  • The chart should be intuitive, with clear labels for residents and distinct colors for activity types.
  • Ensure the chart is responsive and aligns with the UI design of the Home profile template.
  • Prioritize readability, especially when dealing with multiple activity types and residents.

Technical Requirements

  • Use Python Plotly library for chart implementation, focusing on backend data processing for accuracy.
  • Ensure efficient data processing for the aggregation of activity counts by resident and activity type.

Reference Image

Desired Chart Output

Acceptance Criteria

  • A responsive, horizontal stacked bar chart displaying activity counts by resident and activity type is integrated into the Home profile template.
  • The chart accurately reflects the aggregated data and updates dynamically with current records.
  • The visualization adheres to design and performance standards set for the platform.

Home profile: monthly grouped bar chart for Activity Minutes or Hours by Activity Type

Introduction

On the Home profile page, implement a new bar chart report that groups activity minutes or hours by month and activity type.

Screenshot_20231208_212315

This is a grouped bar chart where the data are grouped by month and subgrouped by activity type with an aggregated sum of activity minutes (or hours.)

Detailed Description

  • Each bar represents a month, starting from the first day of the month and including the year in the datetime. (e.g., 2023-11-01)
  • The vertical height of each bar corresponds to the total sum of activity minutes or hours for that month.
  • Bars are further subdivided into segments, each representing an activity type with its sum of minutes or hours.
  • The chart should display data for the last complete year, up to the current month.

Use Case

  • This report allows for a better understanding of monthly trends in resident activity.
  • As a future goal: Facilitates year-on-year comparisons of activity engagement and helps in resource planning.

Technical Considerations

  • The report should dynamically adjust to include the most recent 12 months of data.
  • Data processing must ensure accuracy in summing and grouping the activity data.
  • The chart must be visually distinct and legible, with clear legends and scaling.

Alternatives Considered

  • A simple cumulative graph was considered but does not provide the granularity of monthly activity types.

Additional Context

  • The new chart is expected to align with the styling and interaction of the existing grouped bar charts.
  • The current charting library should be assessed for suitability with the new requirements.

MVP add work-activity form

Ensure the "add work activity" form has these minimal viable features:

  • Select unit (Group home level)
  • [type of] Indirect work (Laundry, Cleaning, Food prepation and heating etc.)
  • Activity facilitator role —> Nurse, Practical nurse, Student, Volunteer etc.
  • Activity date —> This can be just ”Date”
  • Activity duration (in minutes) —> Time in minutes

And then ”Submit”

This ”Add acitivity” -form is really easy and quick to use.

Determine how to group homes together and create initial Homes page

Determine how we want to group homes, such as the allowed hierarchy level. After doing so, use the previous Homes display as inspiration to design new data visualizations for the new homes list display.

Task

  • create HomeGroup model
    • add name field to HomeGroup model
  • add group field to Home model as a ForeignKey to HomeGroup
  • add group field to HomeForm so homes can be assigned to groups
  • create Homes view that lists homes
    • homes should be grouped by group
    • if homes aren't part of a group, they will be displayed below grouped homes

Example listing

  • Group A
    • Home A
    • Home B
  • Group B
    • Home C
    • Home D
  • Home E (no group)

Reference screen

Note: you don't need to build the following data visualizations. This screen is only a visual reference to show the homes nested within home groups.

image

Implement "Add Activity" Modal Dialogue on Home Profile Page

Introduction
Add an "Add Activity" feature on the Home profile page, to be implemented as a modal dialogue with a form.

Screenshot_20231208_214843

Detailed Description

  • The "Add Activity" button will be placed in the upper right corner of the Home profile page.
  • On click, a Bootstrap 5 modal dialogue will appear, containing a Django form for the Activity model.
  • Form fields:
    • resident: Multi-select for residents with active residencies (use Select2 for enhanced UI).
    • activity_type: Single-select dropdown, options from ActivityTypeChoices.
    • activity_date: Datetime field with a calendar widget.
    • duration_minutes: Positive integer field for activity duration in minutes.
    • caregiver_role: Select widget, options from CaregiverRoleChoices.
  • Buttons:
    • "Save": Green button to submit form, POST request to Django view, redirect to Home profile on success.
    • "Cancel": Blue button to close the modal without action.
  • Additional UI elements:
    • Small 'X' button in the upper right of the modal to dismiss it.

Use Case

  • Streamlines the process of logging activities by caregivers.
  • Enhances data accuracy and efficiency in activity tracking.

Technical Considerations

  • Form field names should match the actual model field names in the Activity model.
  • The Django view handling the form submission must require user authentication.
  • Ensure POST method is used for form submission with proper CSRF protection.
  • Modal and form must be responsive and accessible on various devices and screen sizes.
  • The modal dialogue approach is chosen to give the user the feeling of being on the same page, thus providing a convenient user experience.

Alternatives Considered

  • N/A, as the modal dialogue is a standard for form submissions in the current design pattern.

Additional Context

  • Consistent UI/UX design with existing modals in the project.
  • Bootstrap 5 and Select2 should be used to maintain design uniformity and enhance user experience.

Change work reports to use hours instead of minutes

Our work reports currently display the amount of work in minutes. However, employers may be more oriented towards planning staff needs in hours.

Task

  • change work reports to use hours instead of minutes

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.