Skip to content

Implement prescription edit and archive - #138

Merged
mudabs merged 4 commits into
oss-slu:mainfrom
OliviaH05:feature/issue-127
Sep 27, 2026
Merged

mudabs merged 4 commits into
oss-slu:mainfrom
OliviaH05:feature/issue-127

Conversation

@OliviaH05

Copy link
Copy Markdown
Contributor

This PR adds the ability for users to edit and archive their prescriptions. Users can update prescription information, and changes are saved to the database. Users can also archive prescriptions they no longer use, which removes them from the active list while keeping the prescription history in the database.

Changes Made:

  • Added the ability to edit active prescriptions.
  • Added the ability to archive prescriptions without deleting them.
  • Added backend API endpoints and frontend service functions for updating and archiving prescriptions.
  • Updated the prescription page to display edit and archive actions.

Closes #127

@mudabs mudabs left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Request changes

Thanks Olivia for expanding the prescription module with edit, archive, and creation support. The endpoint and frontend service are now wired correctly, and the existing frontend test suite, lint checks, production build, and backend compilation are passing.

Before approving this PR, please address the following:

  1. Add backend tests for prescription lifecycle behavior

Please add tests covering:

  • Creating a prescription for an authenticated user
  • Requiring completed health consent
  • Assigning the prescription to the authenticated user rather than accepting a client-provided user ID
  • Retrieving only active prescriptions
  • Updating only prescriptions owned by the current user
  • Archiving only prescriptions owned by the current user
  • Returning 404 for missing, archived, or another user’s prescription
  • Confirming that archiving sets archived and archived_at without deleting the record
  • Rejecting empty, whitespace-only, or null values for medication name, dosage, and frequency
  • Accepting an optional next_dose value

Because these endpoints handle personal medication information, ownership and authorization tests are particularly important.

  1. Add frontend tests for the prescription workflows

Please add tests for:

  • Loading and displaying active prescriptions
  • Showing the empty state when no active prescriptions exist
  • Opening and submitting the add-prescription form
  • Sending the expected payload to the create endpoint
  • Refreshing the list after a successful create
  • Opening and submitting the edit form
  • Refreshing the list after a successful update
  • Confirming an archive action
  • Refreshing the list after archiving
  • Canceling an archive action without making an API request
  • Displaying errors when loading, creating, updating, or archiving fails
  • Disabling the relevant controls while a request is in progress

The current general frontend suite passes, but it does not directly verify the new prescription functionality.

  1. Replace hard-coded user-facing strings with translations

The prescription page currently contains hard-coded text such as:

  • Loading prescriptions...
  • No active prescriptions found.
  • Add prescription
  • Medication name
  • Dosage
  • Frequency
  • Next dose
  • Save prescription
  • Saving...
  • Prescription added successfully.
  • Prescription updated successfully.
  • Prescription archived successfully.
  • Failed to add prescription.
  • The archive confirmation text

Please add translation keys to the appropriate locale files and use t(...) consistently. Please also verify the layout with the supported languages, including Arabic RTL mode.

  1. Show a visible error when the initial prescription load fails

loadPrescriptions() currently catches the error and only logs it to the console. If the API request fails, the user sees an empty or incomplete page without knowing what happened.

Please add a visible error message with a retry action. The same existing error/toast conventions used elsewhere in the application should be used where appropriate.

  1. Add form validation and clear submission behavior

Please ensure that:

  • Medication name, dosage, and frequency cannot be submitted as blank or whitespace-only values.
  • The Save button is disabled while a request is running.
  • The Add form cannot be submitted multiple times.
  • The edit form cannot be submitted multiple times.
  • The form displays the backend validation message when a request is rejected.
  • A successful operation resets the appropriate form state.

Once these changes are added and the new tests pass, I would be comfortable approving the PR. The core direction is good; the remaining work is primarily verification, localization, and production-quality error handling.

@mudabs mudabs left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approved

Thanks for addressing the requested changes.

The prescription lifecycle is now covered end to end:

  • Users can create prescriptions through the authenticated API and frontend form.
  • Users can edit active prescriptions.
  • Users can archive prescriptions without deleting their database records.
  • Prescription ownership and health-consent requirements are enforced.
  • Backend validation rejects blank medication, dosage, and frequency values.
  • Frontend tests cover loading, empty states, creation, editing, archiving, cancellation, validation, errors, retry behavior, and disabled submission states.
  • New prescription UI text has been localized.
  • The frontend test suite, lint checks, production build, and GitHub CI checks pass.

Approved for merge after the whitespace cleanup.

@mudabs
mudabs merged commit 3183e30 into oss-slu:main Sep 27, 2026
4 checks passed
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.

Prescription item actions support edit and archive

2 participants