Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add DenominationValidator to validate dosage fields in Prescription model #1716

Merged
merged 6 commits into from
Dec 7, 2023

Conversation

sainak
Copy link
Member

@sainak sainak commented Nov 15, 2023

Proposed Changes

  • Add DosageValidator to validate dosage char field

Associated Issue

Merge Checklist

  • Tests added/fixed
  • Update docs in /docs
  • Linting Complete
  • Any other necessary step

Only PR's with test cases included and passing lint and test pipelines will be reviewed

@coronasafe/care-backend-maintainers @coronasafe/care-backend-admins

Copy link

codecov bot commented Nov 15, 2023

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (033d085) 60.75% compared to head (da914b9) 60.48%.

❗ Current head da914b9 differs from pull request most recent head b088601. Consider uploading reports for the commit b088601 to get more accurate results

Files Patch % Lines
care/facility/models/prescription.py 81.48% 3 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1716      +/-   ##
==========================================
- Coverage   60.75%   60.48%   -0.28%     
==========================================
  Files         210      210              
  Lines       11533    11498      -35     
  Branches     1644     1636       -8     
==========================================
- Hits         7007     6954      -53     
- Misses       4285     4310      +25     
+ Partials      241      234       -7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@rithviknishad rithviknishad left a comment

Choose a reason for hiding this comment

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

Maybe we could have made it more generic as DenominationValidator

and wherever dosage is there we could initialize the validator with:

dosage_validator = DenominationValidator(
  min=0.0001, 
  max=5000, 
  allowed_units={"mg", "g", "ml", "drop(s)", "ampule(s)", "tsp"},
)

@sainak sainak changed the title add DosageValidator to Prescription model add DenominationValidator to validate dosage fields in Prescription model Nov 20, 2023
@vigneshhari vigneshhari merged commit 46341e1 into master Dec 7, 2023
9 checks passed
@vigneshhari vigneshhari deleted the sainak/fix/dosage-validation branch December 7, 2023 17:50
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.

The backend allows for any kind of string in the dosage field in the prescription.
4 participants