Coder Social home page Coder Social logo

ucum-lhc's People

Contributors

lmericle avatar plynchnlm avatar xluanlhc avatar yuriy-sedinkin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ucum-lhc's Issues

Validator throws error on some curly brace expressions

An expression like {g} is a little weird since it seems pretty meaningless (and more often than not I'd expect you'd mean g, grams, rather than {g}, a unitless annotated expression), but it is nonetheless perfectly valid. The validator, however, doesn't seem to think so:

image

This is even weirder because it seems totally willing to behave correctly in other cases, like {a} instead of a for years:

image

Documentation - how to correctly reference using ucum-lhc

Hi, can you please include into a documentation how to correctly reference when using ucum-lhc in another open source project? For example when LOINC and UCUM is used, their terms apply which is totally fine. But how to correctly reference this?

Would it be sufficient to have a third party license file containing all license texts/terms-of-service from all references? So the following ones:

Or would something else be required?
Thanks

Conversion from MG/ML to %

First of all, great package! I am not sure if this is the right place to report issue here. But I notice that conversion from MG/ML (usually used in RxNorm, eg. rxcui 861487) to % is giving the incorrect result as

0.5 mg/mL = 50000.00 %

The correct result should be 0.05 %

Thanks!

`g.m2-1` passes as valid in online validator (but should probably not)

For pure UCUM codes I am quite sure that g.m2-1 is invalid. The result in the online validator is g.m2-1 (gram*[meter2]) is a valid unit expression so the parser just drops the -1 part. (related dalito/ucumvert#8)

Or is this a question of the UCUM version? I am wondering because of

g.(m2)-1 (gram*[square meter]) is a valid unit expression.
An exponent (-1) following a parenthesis is invalid as of revision 1.9 of the UCUM Specification. 
Did you mean m2-1?

UCUM_LHC allows multiple prefixes that are invalid

The UCUM LHC demo interprets mcg as

mcg (millicentigram) is a valid unit expression.

This interpretation is based on multiple prefixes m and c combined with a single base unit g. Multiple prefixes are not allowed per UCUM section 4.2:

The unit symbol to be combined with the prefix must not itself contain a prefix. Such a prefix-less unit symbol is called unit atom.

Description of csv

The demo page allows uploading of CSV. It would be a nice addition to state the required CSV format (since CSV is not a formal standard, and quite some variants are used in de practice - standard Excel to CSV export did not work for me).
I got it to work with:

  • commas as delimiter (not semicolon)
  • all fields double quoted ("ml", etc., not just ml, ...)
  • \r\n line ends (Unix style \n did not work)
    Maybe more formats are allowed, but the only way to find out what works now is by trial-and-error.

Parentheses not evaluated when exponent in denominator

When using the Validator on https://ucum.nlm.nih.gov/ucum-lhc/demo.html we get the following issue:
According to the provided Unit Expression Syntax Rules it should hold that:
"Parentheses may be used to override normal left-to-right evaluation of an expreession. For example kg/m.s2 divides kg by m and multiplies the result by s2. kg/(m.s2) divides kg by the result of multiplying m by s2." which aligns perfectly with 2.2 §10 "nested terms" from the ucum-specification (https://ucum.org/ucum.html).

Unfortunately i find that a

      kg/(m.s2) evaluates correctly to (kilogram/[meter*[second - time2]]), 
      kg/(s2.m) evaluates to               (kilogram/[second - time2]*meter)

, which seems to be something different. We encountered the problem when validating

      dyn.s/cm5/m2 <=> dyn.s/(cm5.m2).

I thought, that maybe exponents need to be put in parenthesis too, but that did not help either:

      kg/((s2).m) evaluates to             (kilogram/[second - time2]*meter)

Proposal: Annotation strings should be allowed to contain Chinese characters and like

In the file unitString.js:
// A regular expression for validating annotation strings.
static VALID_ANNOTATION_REGEX = /^\{[!-z|~]*\}$/;

My Proposal:
Annotation strings should be allowed to contain Chinese characters and like, such as:
{片} ... for {tablet}

Proposed regular expression:
// A regular expression for validating annotation strings.
static VALID_ANNOTATION_REGEX = /^\{[!-z|~\u4e00-\u9fa5]*\}$/;

Validated examples:
{片} ... for {tablet}
{肌酐} for {creat} [ Usage: nmol/mmol{肌酐} ... for nmol/mmol{creat} ]
{蛋白质} for {prot} [ Usage: nmol/mg{蛋白质} ... nmol/mg{prot} ]
...

Maybe this is a proposal for the UCUM Specification per se.

"m(/s)" passes validation and gives "1/s" as result

Entering m(/s) in the web-validator gives: m(/s) (1/[second - time]) is a valid unit expression. The "meter" is lost. I would expect that this fails validation.

Another interesting edge case is m.(/s). It passes validation and gives m.(/s) (meter*[1/[second - time]]) is a valid unit expression. - This should probably also fail at least according to

These formal grammars only allow "/" as unary operator at the beginning of a "main term" but not as unary operator of a "term". Interestingly, the written specification only says: The division operator can be used as a binary and unary operator, i.e. a leading solidus will invert the unit that directly follows it. - This is what your code does for m.(/s).

Unexpected results from conversion of unit expression

Note- these results were taken from the interactive demo available at https://ucum.nlm.nih.gov/ucum-lhc/demo.html.

Note: Test value deliberately chosen to be challenging/confusing for UCUM but the syntax is correct I believe.

Item Operation Input Output (Result) Comment
1 Convert to L-1.s-1 (78.2).(mmol/L)/s 9.394533251999998e+22 L-1.s-1 The string "78.2" here is interpreted by UCUM as 78 x 2, so this expression should evaluate to 156.mmol/L/s . How the numerical value ends up beginning with a 9 and with an exponent of 10^22 is hard to understand

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.

Error when instantiating using ES6 import

I'm using Node & Babel, ES6 import is part of my team's coding style guide.

This works:

const ucumlhc = require('@lhncbc/ucum-lhc');
const ucum = ucumlhc.UcumLhcUtils.getInstance();

While this does not:

import ucumlhc from '@lhncbc/ucum-lhc';
const ucum = ucumlhc.UcumLhcUtils.getInstance();

The latter throws the following error:

TypeError: Cannot read property 'UcumLhcUtils' of undefined

Please advise and thank you in advance!

Cannot use the latest version v2.5.x with nodejs

Hi, first thank you for this library.

I'm trying to use it in a new empty node project from scratch, but I'm getting the next error Error: Cannot find module 'is-integer'

After installing it manually I've got the next one Error: Cannot find module '../data/ucumDefs.json'

Looking at the node_modules/@lhncbc/ucum-lhc folder seems the is-integer package is not declared as a dependency in the package.json file and the data folder is missing

Missing restrictions on character validity

Per UCUM 2.1.6.1, "The full range of characters 33–126 can be used within a pair of curly braces (‘{’ and ‘ }’)." However, it doesn't look like the validator throws an error against annotations containing characters outside this range (like spaces and extended ASCII characters):

image

Note that extended ASCII characters aren't allowed anywhere in UCUM anyway: "All expressions of The Unified Code for Units of Measure shall be built from characters of the 7-bit US-ASCII character set exclusively." (UCUM 2.1.3.1)

Also, thanks for this tool!

A potential typo in the Guidance for parsec

In ucum.csv, there might exist a typo in the Guidance for parsec:

Typo:
..., nad used to measure large distances to ...

Correction:
..., and used to measure large distances to ...

Unexpected results from validating or conversion of unit expressions

Note- these results were taken from the interactive demo available at https://ucum.nlm.nih.gov/ucum-lhc/demo.html. That page links to here so I assume the version of code running at that URL is essentially the same as hosted here.

Results from running certain test cases through the tool were not as expected. Note these were deliberately chosen to be "challenging " for UCUM given some if it's characteristics (notably not using the same base units as SI) but even so some of these results look wrong.

`

Item Operation Input Output (Result) Comment
1 validate (mL/L).[pH] ([pH]*[pH]) is a valid unit expression mL/L is unitless (dimension of 1), and pH is unitless in the SI system (but a complex function in UCUM). It is unclear how mL/L is converted to a unit of “pH” in the parsing of this expression.
2 Convert to kg mmol/mol .000001000000 kg (kilogram) Moles are unitless in UCUM, so an expression involving multiplying or dividing Moles should also be unitless. It should not be possible to convert such a  value to a result involving mass (kg).
3 Convert to mol mmol/L 1.00 mol (mole) As Moles are unitless, this value should have a dimension of 1/volume, e.g. L-1
4 Convert to mol 32.4 (ug/g).mg 0.00000000 mol (mole) Incorrect result dimension (should be mass)
5 Convert to mol 78.2 (mmol/L)/s 78.20 mol (mole) Incorrect result dimension (should be L-1s-1)

`

Q: Synonym data?

To the best of my knowledge the UCUM data definition (ucum-essence.xml) doesn't include synonyms for unit codes, with the exception of a textual name/description and (sometimes) a "printSymbol".

So, where is the "synonym data" drawn from in this implementation to provide the checkSynonyms() function? Is this supplemental data that's been added to the master UCUM file from another source?

A potential typo in the Guidance for Ampere

In ucum.csv, there might exist a typo in the Guidance for Ampere:
unit of electric current equal to flow rate of electrons equal to **16.2415×10^18** elementary charges moving past a boundary in one second or 1 Coulomb/second

Proposed correction:
unit of electric current equal to flow rate of electrons equal to **6.2415×10^18** elementary charges moving past a boundary in one second or 1 Coulomb/second

Unexpected results from conversion of unit expression (web service)

Note: This issue specifically refers to the online web service

Given the query URL:

https://ucum.nlm.nih.gov/ucum-service/v1/toBaseUnits/mmol/L

The response is:
<UCUMWebServiceResponse ServerDateTime="2018-11-26T16:11:55"> <WebServiceRequest> http://ucum.nlm.nih.gov/ucum-service/v1/toBaseUnits/mmol/L </WebServiceRequest> <Response> <SourceUnit>mmol/L</SourceUnit> <ResultBaseUnits>mol.m-3</ResultBaseUnits> <ResultQuantity>1.0</ResultQuantity> <ResultBaseUnitsList> <BaseUnit Name="mol" Exponent="1"/> <BaseUnit Name="m" Exponent="-3"/> </ResultBaseUnitsList> </Response> </UCUMWebServiceResponse>

I believe the ResultQuantity should be 1000 (or 10^3) in this case, as 1mol/L == 1000mol/m^3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.