ucum-lhc
ucum-lhc copied to clipboard
Support Valence Calculations
There are unit conversions that require valence in order for the conversion to be correct.
An example would be: Phosphorus which has a valence 5 converting from mmol/L to meq/L.
Thanks for pointing that out. I had not realized we were handling conversion between moles and equivalents in the ucum-lhc library. The reason we do that is that we are following the UCUM specification, which defines 1 eq = 1 mol (as its base unit). I understand that this is wrong, in general.
Concerning equivalents. the UCUM specification says, "The amount of electrolytes (including acids and bases) is often reported as equivalents instead of amount of substance. This habit originates in the measuring technique of titration. The Unified Code for Units of Measure does not endorse using equivalents. We rather recommend to calculate the proper amount of substance after titration, so that 1 eq of Na+ ions is 1 mol, but 1 eq of Ca++ ions is 0.5 mol. The problem with equivalents is that the measurement results are difficult to compare because their magnitude depends on the degree of ionization of the substance. That is to say, the meaning of equivalents depend not only on the substance, but also on the state that the substance is in. For example, in iron we have to distinguish Fe2+ from Fe3+, so that noone can be sure how much 1 eq of iron really is. "
In other words, it is advising not use the unit, which is probably not of much help if you already have data with those units.
I think we could add another parameter to convertUnitTo, to allow the valence to be specified. (We might put that and the last two parameters in a "options" object.)
In case it is of use, we also have a web service, which does handle valence for certain substances, if you have a LOINC code for it, at https://ucum.nlm.nih.gov/ucum-service.html#mass-mol-eq. Perhaps that should also be generalized to let you specify the valence.
These are now supported as of a few months ago. You can pass in a "charge" option to the convertUnitTo function to specify the valence. (Sorry we did not get back to report this sooner.)