@lhncbc/ucum-lhc 7.0.0 → 7.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -71,12 +71,12 @@ those functions via the ucumPkg object. For example,
71
71
  ### Function descriptions
72
72
 
73
73
  Below is documentation for the public functions on the UcumLhcUtils instance.
74
- * [validateUnitString](#validateUnitString)
75
- * [convertUnitTo](#convertUnitTo)
76
- * [checkSynonyms](#checkSynonyms)
77
- * [convertToBaseUnits](#convertToBaseUnits)
74
+ * [validateUnitString](#validateunitstringustr-suggest)
75
+ * [convertUnitTo](#convertunittofromunitcode-fromval-tounitcode-options)
76
+ * [checkSynonyms](#checksynonymsthesyn)
77
+ * [convertToBaseUnits](#converttobaseunitsfromunit-fromval)
78
+ * [commensurablesList](#commensurableslistfromunit-categorylist)
78
79
 
79
- <a id="validateUnitString"></a>
80
80
  #### validateUnitString(uStr, suggest)
81
81
 
82
82
  This method validates a unit string. It first checks to see if the string passed
@@ -92,12 +92,14 @@ return, if requested, a list of suggested units in the suggestions array
92
92
  that is returned. Suggestions are based on matching the expression with
93
93
  unit names and synonyms.
94
94
 
95
- * _@param_ uStr the string to be validated;
96
- * _@param_ suggest a boolean to indicate whether or not suggestions are
95
+ **Parameters**:
96
+ 1) uStr: the string to be validated;
97
+ 2) suggest: a boolean to indicate whether or not suggestions are
97
98
  requested for a string that cannot be resolved to a valid unit;
98
99
  true indicates suggestions are wanted; false indicates they are not,
99
100
  and is the default if the parameter is not specified;
100
- * _@returns_ an object with five properties:
101
+
102
+ **Returns**: an object with five properties:
101
103
  * 'status' will be 'valid' (the uStr is a valid UCUM code), 'invalid'
102
104
  (the uStr is not a valid UCUM code, and substitutions or
103
105
  suggestions may or may not be returned, depending on what was
@@ -148,7 +150,6 @@ of unit strings, and includes a link to the
148
150
  [UCUM Specification](http://unitsofmeasure.org/ucum.html), where you can find
149
151
  the full deal.
150
152
 
151
- <a id="convertUnitTo"></a>
152
153
  #### convertUnitTo(fromUnitCode, fromVal, toUnitCode, options)
153
154
 
154
155
  This method converts a number of one type of unit to the equivalent number of
@@ -158,25 +159,27 @@ rounded to any particular precision or significant digits.
158
159
  Disclaimer: Conversion results should be verified independently before
159
160
  using them in actual clinical settings.
160
161
 
161
- * _@param_ fromUnitCode the unit code/expression/string of the unit to be converted;
162
- * _@param_ fromVal the number of "from" units to be converted to "to" units;
163
- * _@param_ toUnitCode the unit code/expression/string of the unit that the from
162
+ **Parameters**:
163
+ 1) fromUnitCode: the unit code/expression/string of the unit to be converted;
164
+ 2) fromVal: the number of "from" units to be converted to "to" units;
165
+ 3) toUnitCode: the unit code/expression/string of the unit that the from
164
166
  field is to be converted to;
165
- * _@param_ options an optional hash of options that can be passed in:
166
- * 'suggestions' a boolean to indicate whether or not suggestions are wanted
167
+ 4) options: an optional hash of options that can be passed in:
168
+ * 'suggestions' a boolean to indicate whether or not suggestions are wanted
167
169
  for a string that cannot be resolved to a valid unit; true indicates
168
170
  suggestions are wanted; false indicates they are not, and is the default
169
171
  if the parameter is not specified;
170
- * 'molecularWeight' the molecular weight of the substance in question when a
172
+ * 'molecularWeight' the molecular weight of the substance in question when a
171
173
  conversion is being requested from mass to moles/equivalents and vice versa. It is
172
174
  ignored if neither unit includes a measurement in moles. In such cases
173
175
  the mole-based unit must have a single mole unit in the numerator and the
174
176
  mass-based unit must have a single mass unit in the numerator.
175
- * 'charge' the absolute value of the charge of the substance in question when a conversion
177
+ * 'charge' the absolute value of the charge of the substance in question when a conversion
176
178
  is being requested from mass/moles to equivalents and vice versa. It is required
177
179
  when one of the units represents a value in equivalents and the other in mass or moles.
178
180
  It is ignored if neither unit includes an equivalent unit
179
- * _@returns_ a hash with six elements:
181
+
182
+ **Returns**: a hash with six elements:
180
183
  * 'status' the will be: 'succeeded' if the conversion was successfully
181
184
  calculated; 'failed' if the conversion could not be made, e.g., if
182
185
  the units are not commensurable; or 'error' if an error occurred;
@@ -250,7 +253,6 @@ If you want to know what unit types a particular unit can be converted to, the
250
253
  checkSynonyms function will provide a list of commensurable units for a specified
251
254
  unit expression.
252
255
 
253
- <a id="checkSynonyms"></a>
254
256
  #### checkSynonyms(theSyn)
255
257
 
256
258
  This method searches for units that include a single search term (theSyn) in the
@@ -260,8 +262,10 @@ submitting the term "pound" to the _validUnitString_ method will result in a
260
262
  "not found" response. Submitting it to this method will return with a list
261
263
  of possible pound units.
262
264
 
263
- * _@param_ theSyn the term to search for
264
- * _@returns_ a hash with three elements:
265
+ **Parameters**:
266
+ 1) theSyn: the term to search for
267
+
268
+ **Returns**: a hash with three elements:
265
269
  * 'status' contains the status of the request, which can be 'error',
266
270
  'failed' or 'succeeded';
267
271
  * 'msg' contains a message for an error or if no units were found; and
@@ -290,7 +294,6 @@ of possible pound units.
290
294
  /* returnObj['status'] will be 'error' and returnObj['msg'] will indicate
291
295
  what the error was. */
292
296
 
293
- <a id="convertToBaseUnits"></a>
294
297
  #### convertToBaseUnits(fromUnit, fromVal)
295
298
 
296
299
  Converts the given unit string into its base units, their exponents, and
@@ -320,6 +323,27 @@ a magnitude, and returns that data.
320
323
  and usefulness for the input values that produced it).
321
324
  * unitToExp: a map of base units in fromUnit to their exponent
322
325
 
326
+ #### commensurablesList(fromUnit[, categoryList])
327
+
328
+ Retrieves a list of units commensurable, i.e., that can be converted from and
329
+ to, a specified unit. Returns an error if the "from" unit cannot be found.
330
+ If necessary, you can filter the list of units by specifying a list of unit
331
+ categories that should be in the resulting list.
332
+
333
+ **Parameters**:
334
+ 1) fromUnit: the name/unit string
335
+ 2) categoryList: optional parameter - the list of unit categories; possible
336
+ list values: 'Clinical', 'Nonclinical', 'Obsolete', 'Constant'
337
+
338
+ **Returns**: an array containing two elements:
339
+ * 0: an array of commensurable units if any were found, each of which is an
340
+ object with the properties:
341
+ * name_: unit name;
342
+ * csCode_: unit code;
343
+ * other properties are currently undocumented and their existence should not
344
+ be relied upon.
345
+ * 1: an error message if the "from" unit is not found.
346
+
323
347
 
324
348
  ### Download the GitHub repository
325
349