EnteredUnit
EnteredUnit
Characteristic |
Description |
---|---|
Icon |
|
Availability |
An item with a base unit selected on the Design tab for the item. |
Return type |
String (for Central Designer string types). |
Description |
Returns the localized name of the unit, or null if a unit was not selected. For example, you can use this property in query or email text. |
Purpose |
If you allow InForm users to choose between metric and imperial units but want to require that the user is consistent within a form, use this property to check that the values are from the same measurement system. Consider that values entered in the InForm application are normalized to their base unit. For example, if kg is the base unit, a value of 150 lbs. is stored in the database as 68.0388555 kg. Some unit conversions are not absolute, which can make writing rules difficult. For example, converting mmol/L requires knowledge of a chemical’s molecular weight.
You have the following options for recording this information:
The following rule example uses EnteredUnit and EnteredValue to convert glucose from mmol/L to mg/dL, and stores that value in the itmNormalizedGlucose item. Consider that a conversion is not done if another unit is chosen; if the base unit is selected, EnteredValue and Value are the same. value = this.itmGlucose.EnteredUnit == "mmol/L" ? this.itmGlucose.EnteredValue * 18 : this.itmGlucose.Value always set this.itmNormalizedGlucose = value
You can write a similar rule to convert cholesterol, triglycerides, and other measurements. Additionally, you can replace numerical values, such as 18 and 39, with constants such as Constants.Conversions.Glucose and Constants.Conversions.Cholesterol. You define the constants in the study or a library. |