Thanks to visit codestin.com
Credit goes to github.com

Skip to content

add a Drug Thresholds button and remove the thresholds from Drug Library table#223

Merged
daattali merged 1 commit into
masterfrom
feat-drug-thresholds
Apr 30, 2026
Merged

add a Drug Thresholds button and remove the thresholds from Drug Library table#223
daattali merged 1 commit into
masterfrom
feat-drug-thresholds

Conversation

@daattali
Copy link
Copy Markdown
Collaborator

@daattali daattali commented Apr 30, 2026

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced "Drug Thresholds" button and dedicated modal workflow for managing drug threshold values independently from other drug default settings.
  • Style

    • Updated toolbar button icons for improved visual consistency.
    • Optimized table column formatting for better readability.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 30, 2026

📝 Walkthrough

Walkthrough

A new "Drug Thresholds" modal workflow was introduced to manage drug threshold values separately from the main "Edit Drug Defaults" interface. The endCe and endCeText columns are excluded from the main editing table and now updated through a dedicated threshold modal triggered by the new "Drug Thresholds" button, with pre-edit values preserved by row matching on Drug.

Changes

Cohort / File(s) Summary
Server Logic & Drug Thresholds
R/app_server.R
Removed endCe and endCeText from the main drug-defaults Handsontable; added new reactive observer for input$editThresholds that renders editThresholdsTable modal; implemented thresholdEditsOK observer to update only endCe from the threshold table while preserving other fields via pre-edit restoration by drug matching; compacted column formatting for columns 6–13.
UI Button Actions
R/app_ui.R
Added new "Drug Thresholds" action button with bullseye icon; updated Font Awesome icons for "Suggest Dosing" (fas fa-prescription) and "Drug Library" (fas fa-capsules).

Sequence Diagram

sequenceDiagram
    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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

DEPLOY

Poem

🐰 A threshold for thresholds, we hop and we cheer,
Separated concerns make the flow crystal clear,
Defaults stay steady, while thresholds take flight,
In their own little modal, all bullseye-bright!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately summarizes the main changes: adding a Drug Thresholds button and removing thresholds from the Drug Library table, which aligns with the file summaries showing a new editThresholds button, separated threshold management workflow, and removal of endCe/endCeText from the main table.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat-drug-thresholds

Review rate limit: 2/3 reviews remaining, refill in 20 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3d57d2d and d10909a.

📒 Files selected for processing (2)
  • R/app_server.R
  • R/app_ui.R

Comment thread R/app_server.R
@github-actions
Copy link
Copy Markdown

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.

@daattali daattali merged commit d564e0c into master Apr 30, 2026
7 checks passed
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

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.

Comment thread R/app_server.R
Comment thread R/app_server.R
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.

2 participants