-
Notifications
You must be signed in to change notification settings - Fork 15
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
Implement Validation for String-Float Conversions in Quantity Class #68
Comments
Hello, can you assign me this issue? |
Thank you for assigning me the issue. I will start working on it next week. I tried to join your Discord community for communication, but the link appears to be invalid. |
👋 Hey thanks for contributing! Will update the Discord link - this one should work! |
Hi @guco44 , thank you so much for taking an interest in contributing to healthchain, we really appreciate it! It looks like someone else may have already tackled this one unfortunately, we'd be happy if there's any other open issues you'd like to work on. We're hoping to add some more over the weekend too, so there should be lots more to work on next week. |
@adamkells I have added the test file and two more checks in the Quantity Class. |
Description
The
Quantity
class in thehealthchain/models/data/concept.py
file currently allows both string and float values for thevalue
field. We need to implement validation for conversions between string and float representations to ensure data consistency and prevent potential errors.Context
This validation is important for maintaining data integrity within the
Quantity
class, which is used in various concepts such as medication dosages and ranges. Proper validation will help prevent issues related to data type mismatches and ensure that all quantity values are consistently represented and can be reliably used in calculations or comparisons.Possible Implementation
Quantity
class using Pydantic's@validator
decorator.ValueError
with a descriptive message if the conversion fails.Possible Alternatives
value
field to accept only float inputs, removing the string option entirely.pint
, which could provide more robust unit conversion and representation capabilities.The text was updated successfully, but these errors were encountered: