Summary Table
Categories |
Total Count |
PII |
0 |
URL |
0 |
DNS |
0 |
EKL |
0 |
IP |
0 |
PORT |
0 |
VsID |
0 |
CF |
0 |
AI |
0 |
VPD |
0 |
PL |
0 |
Other |
0 |
File Content
package gov.va.med.pbm.ampl.fhir.unmarshall.dstu2.unbundle;
import java.util.Locale;
import gov.va.med.pbm.ampl.model.ValueQuantity;
import gov.va.med.pbm.ampl.utility.Unit;
import gov.va.med.pbm.ampl.utility.UnitConversion;
/**
* The UnbundleValueQuantity class marshals a given object from a {@link Bundle} to a {@link ValueQuantity}.
*
* @author Ian Meinert
*
*/
public class UnbundleValueQuantity {
/**
* Gets a unit of Measure for a given observation.
* <p>
* If flagged, provides an imperial to metric conversion.
*
* @param measurementName the measurement name
* @param quantityValue the value
* @param doConvert determines whether or not to convert to metric
*
* @return an observation with measurement
*/
public ValueQuantity getMeasureForObservation(String measurementName, double quantityValue, Boolean doConvert) {
double value = doConvert ? UnitConversion.convertMeasurement(measurementName, quantityValue) : quantityValue;
String unit = new String();
switch (measurementName.toUpperCase(Locale.ENGLISH)) {
case "TEMPERATURE":
unit = doConvert ? Unit.CELSIUS.getAbbreviation() : Unit.FAHRENHEIT.getAbbreviation();
break;
case "HEIGHT":
unit = doConvert ? Unit.CENTIMETER.getAbbreviation() : Unit.INCH.getAbbreviation();
break;
case "WEIGHT":
unit = doConvert ? Unit.KILOGRAM.getAbbreviation() : Unit.POUND.getAbbreviation();
break;
default:
break;
}
return new ValueQuantity(Double.toString(value), unit);
}
}