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

tidier scr unit conversion #63

Merged
merged 2 commits into from
Sep 30, 2024
Merged

tidier scr unit conversion #63

merged 2 commits into from
Sep 30, 2024

Conversation

jasmineirx
Copy link
Contributor

in valid_units("scr") we accept either "mg_dl" or "mg/dl", but we convert from molar mass if the unit is anything but "mg/dl". This PR instead looks for the presence of "mol" in the unit to identify if the units are molar and should be converted, catching a possible edge case.

this does not affect any production code since we standardize units elsewhere, however I think this is a cleaner approach.

clinPK::valid_units("scr")
#>  [1] "mg/dl"      "mg_dl"      "micromol/l" "micromol_l" "micromol"  
#>  [6] "mmol"       "mumol/l"    "umol/l"     "mumol_l"    "umol_l"

Created on 2024-09-24 with reprex v2.1.1

@dominic-irx
Copy link
Contributor

From the valid units list, are micromol and mmol equal to umol/L?

Copy link
Contributor

@dominic-irx dominic-irx left a comment

Choose a reason for hiding this comment

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

lgtm just one question

@jasmineirx
Copy link
Contributor Author

good catch, I used a function instead, which accounts for all the differences. However, we now use the correct molecular conversion factor instead of the rounded factor. we might see some test values change. I can monitor it.

@jasmineirx jasmineirx merged commit 711ccd2 into master Sep 30, 2024
1 check passed
@jasmineirx jasmineirx deleted the tidier_scr_conversion branch September 30, 2024 15:45
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