Skip to content

feat: resident profile PR 5 add backend points#1102

Merged
CK-7vn merged 20 commits intoCK-7vn/total-refactorfrom
CK-7vn/total-refactor-resident-profile-5
Apr 3, 2026
Merged

feat: resident profile PR 5 add backend points#1102
CK-7vn merged 20 commits intoCK-7vn/total-refactorfrom
CK-7vn/total-refactor-resident-profile-5

Conversation

@CK-7vn
Copy link
Copy Markdown
Member

@CK-7vn CK-7vn commented Mar 2, 2026

Pre-Submission PR Checklist

  • No debug/console/fmt.Println statements
  • Unnecessary development comments removed
  • All acceptance criteria verified
  • Functions according to ticket specifications
  • Tested manually where applicable
  • Branch rebased with latest main
  • No business logic exists within the database layer

Description of the change

Resident-Profile PR #5
Adds the remaining backend-driven data for the Resident Profile page that was deferred
from PRs 1-4:

Schedule field on Active Enrollments:

  • Adds FormatScheduleFromRRule() helper that parses RRULE BYDAY + DTSTART into
    human-readable format (e.g. "M/W/F 9:00 AM")
  • Adds schedule and recurrence_rule fields to ResidentProgramClassInfo
  • Updates GetUserProgramInfo query to aggregate recurrence rules via STRING_AGG
  • Populates schedule in the existing /api/users/{id}/programs handler

Weekly Attendance Trend endpoint:

  • New GET /api/users/{id}/attendance-trend?weeks=8 endpoint
  • Groups program_class_event_attendance by DATE_TRUNC('week', date) and calculates
    present/total rate per week
  • Frontend wired via useSWR to replace the previously hardcoded empty chart data

Historical Notes:

  • New user_notes table (migration 00066) with user_id, admin_id, note, created_at
  • GET /api/users/{id}/notes — lists notes for a resident (newest first)
  • POST /api/users/{id}/notes — admin-only, creates a note
  • New AddNoteDialog component with textarea and validation
  • HistoricalNotes section now fetches and displays real data
  • Related issues: Resident Profile — backend deferred items

Screenshot(s)

This PR

image image image

Redesign

image image image

Additional context

  • Migration is numbered 00066 because 00065 was already applied from the class detail
    refactor branch. The sequence is contiguous in the DB (64 → 65 → 66).
  • The attendance trend endpoint defaults to 8 weeks but accepts a weeks query param for
    flexibility.
  • FormatScheduleFromRRule handles pipe-delimited aggregated rules by only parsing the
    first one. If a class has multiple events with different schedules, the first is
    displayed.
  • The notes GET route uses validatedRoute (any authenticated user with access) while the
    POST uses validatedAdminRoute with FacilityAdminResolver so only admins at the
    resident's facility can add notes.

@CK-7vn CK-7vn requested a review from a team as a code owner March 2, 2026 20:58
@CK-7vn CK-7vn requested review from calisio and removed request for a team March 2, 2026 20:58
@CK-7vn CK-7vn force-pushed the CK-7vn/total-refactor-resident-profile-4 branch from 79beffe to f4a6811 Compare March 5, 2026 22:08
@CK-7vn CK-7vn force-pushed the CK-7vn/total-refactor-resident-profile-5 branch 2 times, most recently from ae9c0c6 to 0a98407 Compare March 7, 2026 08:03
@CK-7vn CK-7vn force-pushed the CK-7vn/total-refactor-resident-profile-4 branch from f4a6811 to 6a09b18 Compare March 7, 2026 08:08
@github-actions github-actions Bot added documentation Improvements or additions to documentation CI-Actions labels Mar 7, 2026
@CK-7vn CK-7vn force-pushed the CK-7vn/total-refactor-resident-profile-5 branch from 0a98407 to 605264f Compare March 11, 2026 17:58
@CK-7vn CK-7vn force-pushed the CK-7vn/total-refactor-resident-profile-4 branch from 6a09b18 to 4629e48 Compare March 12, 2026 18:28
@CK-7vn CK-7vn force-pushed the CK-7vn/total-refactor-resident-profile-5 branch from 605264f to 7b9c906 Compare March 12, 2026 18:29
@CK-7vn CK-7vn force-pushed the CK-7vn/total-refactor-resident-profile-4 branch from 4629e48 to a881711 Compare March 24, 2026 15:32
@CK-7vn CK-7vn force-pushed the CK-7vn/total-refactor-resident-profile-5 branch from 7b9c906 to fa308b5 Compare March 24, 2026 15:33
@CK-7vn CK-7vn changed the base branch from CK-7vn/total-refactor-resident-profile-4 to CK-7vn/total-refactor March 24, 2026 15:33
@carddev81 carddev81 requested review from carddev81 and removed request for calisio March 25, 2026 20:13
Copy link
Copy Markdown
Contributor

@carddev81 carddev81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CK-7vn Here are my findings

There is a rebase issue and assume there may be more than this, I didn't search for all off them, just assuming I could point this one out and you would be able to fix all others:

  • Within the 'Classes' listing, the grey background is not expanding the full width of the view port and also all the facility filter is not displaying like we discussed on the 'Class Details' PR--just a rebase.
  • On next review I'll double check the completed screens to make sure they are in sync with the total-refactor branch in next review.
  1. 'Attendance Trend' is out of sync with figma, ie. percentages are not rounded--decimals are displayed
  2. 'Attendance Trend' states 'last 8 weeks ...'--doesn't display Weeks, it is displaying dates.
  3. No toast notification when resetting password
  4. After deactivating a resident the resident's profile doesn't fully update to reflect the changes. ie Active enrollments was 2 until I came back to the screen. NOTE that the pill did update automatically to 'Inactive'
  5. Similar to issue above, after transferring a resident, the resident's profile doesn't fully update to reflect the changes. ie Active enrollments was 2 until I came back to the screen. NOTE: the 'Current' facility did automatically update.
  6. The details of the attendance--I believe this should display 'Unexcused' rather than 'Absent' to be consistent with how the prototype is marked up. For example, it displays Absent (Excused) and Absent (Unexcused) for when you take attendance. This is why I'm thinking we should use the word 'Unexcused' here.
  7. A note consisting of more than 25 characters bleeds to the outside of the modal. @calisio's figma doesn't show what happens in this scenario, I would ask her for design suggestions and research best practices and implement the best but of course the least complex approach.
Image
  1. The attendance csv file is incorrectly named, it contains an underscore at the end of it.
  2. The attendance csv file does not contain anything other than the header--no data is being populated into it
  3. Nav bar scrolls off of screen (similiar issue to Class Details)
  4. Unable to add historical notes, I see the SQL migration file for notes table. But the functionality is missing? Also since you will be modifying and adding this functionality, can you please add all of the standardized columns to the table for auditing purposes.
    • created_at
    • updated_at
    • deleted_at
    • create_user_id
    • update_user_id
      Please make sure these are all added and you can probably remove admin_id and just rely on the associated columns below, also note that update_user_id could be utilized in the future in case we allow editing.

REVIEWER'S NOTES: This was a review of functionality and Figma synchronization. What remains is a follow-up review of the code changes and backend logic to ensure queries are pulling the correct data.

@corypride corypride self-assigned this Mar 26, 2026
@CK-7vn CK-7vn force-pushed the CK-7vn/total-refactor-resident-profile-5 branch from 7f77044 to 1fc8fa3 Compare March 26, 2026 21:47
@carddev81 carddev81 self-requested a review March 30, 2026 14:18
Copy link
Copy Markdown
Contributor

@carddev81 carddev81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebase Checks

On classes page, you fixed the grey background but there is an issue with the scroll now--nav links scrolls off of the page when scrolling

  1. Toast message does not match when adding a historical note
  2. Carry over issue from last review screenshot:
Image - A note consisting of more than 25 characters bleeds to the outside of the modal. @calisio's figma doesn't show what happens in this scenario, I would ask her for design suggestions and research best practices and implement the best but of course the least complex approach.
  1. Two things to note here for attendance
    • in the details modal it states 'Complete attendance record for this class' but only displays 10 attendances--for this resident I am using as a test it should have 35 displayed. @caliso is this correct to only display the latest 10 records or should this be paginated?
    • When I click Export to CSV the CSV contains all attendance taken for all classes versus just the class. I believe the functionality should export the CSV for just the class being requested

Comment thread backend/migrations/00067_fix_user_notes_columns.sql Outdated
Comment thread backend/src/handlers/user_handler.go Outdated
Comment thread backend/src/database/users.go Outdated
Copy link
Copy Markdown
Contributor

@carddev81 carddev81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CK-7vn There are a few additional coding comments along with these below

  1. When there are many attendance records to display the modal grows larger than the height of the screen and am unable to access buttons. Add pagination to display only so many records to the user at once? @calisio Is adding pagination an option here?
Image
  1. Figma will display the note 'Medical Appointment' but current PR displays 'Medical App...'

Target Figma

Image

Current

Image

Comment thread backend/migrations/00066_create_user_notes.sql Outdated
Comment thread backend/src/handlers/user_handler.go
Comment thread backend/src/models/users.go Outdated
Comment thread backend/src/services/users.go
@carddev81 carddev81 self-requested a review April 2, 2026 18:31
return rpc.AttendancePercentage
}

type UserNote struct {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CK-7vn Nice! I was praying this could be used.

@carddev81 carddev81 self-requested a review April 2, 2026 18:57
Copy link
Copy Markdown
Contributor

@carddev81 carddev81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work on this one!! I went through it thoroughly and everything looks solid. Backend code is clean, it tested well, and ready to go. Thank you so much for your patience through the review rounds, it paid off!

@CK-7vn CK-7vn merged commit 5cedaca into CK-7vn/total-refactor Apr 3, 2026
8 checks passed
@CK-7vn CK-7vn deleted the CK-7vn/total-refactor-resident-profile-5 branch April 3, 2026 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backend CI-Actions documentation Improvements or additions to documentation HAS_MIGRATION

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants