Skip to content

Conversation

@chitrankd
Copy link
Collaborator

@chitrankd chitrankd commented Jun 3, 2025

Resolved the issue where medication quantity was incorrectly calculated when strength values (e.g., "1000 mg" or "5g") were misinterpreted as dosage amounts.

Example:
Input instruction: "1000 mg po tid x 7 days"
Expected quantity: 21
Previously calculated: 21000

Root Cause:
takeMin and takeMax were incorrectly derived from strength values in the instruction, causing incorrect quantity calculations.

Fix Summary:

  • Added validation for any takeMin or takeMax values greater than 10:

    • If such values are detected, they are checked for trailing strength units (e.g., mg, ml, mcg, etc.) using a new checkIfStrengthVal() utility.
    • If confirmed to be strength-related, these values are reset to "1" to represent a single unit dose.
  • Introduced fallback logic:

    • When takeMin is "0" or empty but frequency and duration are valid, default it to "1" to allow for reasonable quantity estimation.

Ensured symmetry between takeMin and takeMax when applicable.

Sample error instruction: '1000 mg po tid x 7 days' --> qty is calculated as 21000 instead of 21

- Added logic to adjust `takeMin` and `takeMax` based on strength checks.
- Ensured accurate interpretation of frequency and duration for dosage calculations.
- Introduced `checkIfStrengthVal` method to validate strength units within instructions.
@chitrankd chitrankd changed the title Bugfix: Rx qty/mitte calculation errors Bugfix: quantity calculation for instructions containing strength values Jun 3, 2025
- Added random example generation for instructions input to improve usability.
- Added `startShowingSampleInstructions` and `stopShowingSampleInstructions` for placeholder management on focus/blur events.
- Updated `prescribe.jsp` to invoke these functions.
- Updated `startShowingSampleInstructions` and `stopShowingSampleInstructions` to manage ripple animations on focus/blur events.
- Adjusted `prescribe.jsp` to pass `randId` parameter for unique placeholders.
- Added new CSS animations for enhanced visual attention to encourage user to open the modal.
Eliminated 'ripple-wrap', 'ripple-icon', and 'pulse-icon' classes from the instructions help link and image in prescribe.jsp to avoid animation until manually focused.
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