Bugfix: quantity calculation for instructions containing strength values #96
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
21Previously calculated:
21000Root 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:
Introduced fallback logic:
Ensured symmetry between takeMin and takeMax when applicable.