add a Drug Thresholds button and remove the thresholds from Drug Library table#223
Conversation
📝 WalkthroughWalkthroughA new "Drug Thresholds" modal workflow was introduced to manage drug threshold values separately from the main "Edit Drug Defaults" interface. The Changes
Sequence DiagramsequenceDiagram
participant User
participant UI as UI Layer
participant Server as Server Logic
participant drugDefaults as drugDefaults Reactive
User->>UI: Click "Drug Thresholds" button
UI->>Server: Trigger input$editThresholds
Server->>Server: Render editThresholdsTable<br/>(with current endCe values)
Server->>UI: Display threshold modal
User->>UI: Edit "Threshold" column<br/>in modal
User->>UI: Click thresholdEditsOK
UI->>Server: Trigger input$thresholdEditsOK
Server->>drugDefaults: Update only endCe<br/>(matched by Drug)
drugDefaults->>Server: Return updated state
Server->>UI: Close modal & refresh UI
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Review rate limit: 2/3 reviews remaining, refill in 20 minutes. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@R/app_server.R`:
- Around line 1493-1534: The threshold edits handler (observeEvent for
input$thresholdEditsOK) currently coerces edited values with
as.numeric(hot_to_r(...)) and writes NAs into drugDefaults(), so validate the
table output before persisting: in the observeEvent for input$thresholdEditsOK,
call tt <- hot_to_r(input$editThresholdsTable) and parsed <-
as.numeric(tt$Threshold), then check if any(is.na(parsed)) or
any(!is.finite(parsed)); if so, show a user-facing error (e.g., showModal or
showNotification) and abort without calling drugDefaults(); otherwise map parsed
values into newDrugDefaults$endCe and assign drugDefaults(newDrugDefaults) as
before, ensuring you reference the existing symbols tt, parsed, newDrugDefaults,
drugDefaults and keep removeModal() only after validation succeeds.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: cf5a591a-64b0-4f83-b8bf-3341e41c5c04
📒 Files selected for processing (2)
R/app_server.RR/app_ui.R
|
Preview Deployment This PR has been deployed to: https://steveshafer.shinyapps.io/stanpumpr_PR_223/ This deployment will be automatically cleaned up when the PR is closed. |
There was a problem hiding this comment.
Code Review
This pull request refactors the drug library management by moving the drug threshold settings (endCe and endCeText) into a dedicated "Drug Thresholds" modal and updating the UI icons. The main drug library table is simplified by removing these columns. Feedback suggests that the new threshold modal should include the threshold label (endCeText) to avoid a regression in functionality, as users can no longer customize these labels. Additionally, input validation should be added to the threshold numeric column, and the save logic needs to be updated to persist the labels.
Summary by CodeRabbit
Release Notes
New Features
Style