本文整理汇总了Java中org.openmhealth.schema.domain.omh.TypedUnitValue类的典型用法代码示例。如果您正苦于以下问题:Java TypedUnitValue类的具体用法?Java TypedUnitValue怎么用?Java TypedUnitValue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TypedUnitValue类属于org.openmhealth.schema.domain.omh包,在下文中一共展示了TypedUnitValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: asDataPoint
import org.openmhealth.schema.domain.omh.TypedUnitValue; //导入依赖的package包/类
@Override
protected Optional<DataPoint<OxygenSaturation>> asDataPoint(JsonNode listEntryNode,
Integer measureUnitMagicNumber) {
BigDecimal bloodOxygenValue = asRequiredBigDecimal(listEntryNode, "BO");
// iHealth has stated that missing values would most likely be represented as a 0 value for the field
if (bloodOxygenValue.compareTo(ZERO) == 0) {
return Optional.empty();
}
OxygenSaturation.Builder oxygenSaturationBuilder =
new OxygenSaturation.Builder(new TypedUnitValue<>(PERCENT, bloodOxygenValue))
.setMeasurementMethod(PULSE_OXIMETRY)
.setMeasurementSystem(PERIPHERAL_CAPILLARY);
getEffectiveTimeFrameAsDateTime(listEntryNode).ifPresent(oxygenSaturationBuilder::setEffectiveTimeFrame);
getUserNoteIfExists(listEntryNode).ifPresent(oxygenSaturationBuilder::setUserNotes);
OxygenSaturation oxygenSaturation = oxygenSaturationBuilder.build();
return Optional.of(new DataPoint<>(createDataPointHeader(listEntryNode, oxygenSaturation), oxygenSaturation));
}
示例2: asDataPointsShouldReturnCorrectSensedDataPoints
import org.openmhealth.schema.domain.omh.TypedUnitValue; //导入依赖的package包/类
@Test
public void asDataPointsShouldReturnCorrectSensedDataPoints() {
BloodGlucose.Builder expectedBloodGlucoseBuilder = new BloodGlucose.Builder(
new TypedUnitValue<>(MILLIGRAMS_PER_DECILITER, 60))
.setEffectiveTimeFrame(OffsetDateTime.parse("2015-09-17T12:03:27-08:00"))
.setTemporalRelationshipToMeal(BEFORE_BREAKFAST)
.setUserNotes("Such glucose, much blood.");
assertThat(dataPoints.get(0).getBody(), equalTo(expectedBloodGlucoseBuilder.build()));
assertThat(dataPoints.get(0).getBody().getAdditionalProperty("temporal_relationship_to_medication").get(),
equalTo("Before_taking_pills"));
testDataPointHeader(dataPoints.get(0).getHeader(), SCHEMA_ID, SENSED,
"f706b6152f684c0e9185b1fa6b7c5148", OffsetDateTime.parse("2015-09-17T20:03:41Z"));
}
示例3: asDataPointsShouldReturnCorrectDataPointWithTimeZone
import org.openmhealth.schema.domain.omh.TypedUnitValue; //导入依赖的package包/类
@Test
public void asDataPointsShouldReturnCorrectDataPointWithTimeZone() {
List<DataPoint<BodyMassIndex1>> dataPoints = mapper.asDataPoints(singletonList(responseNode));
BodyMassIndex1 expectedBodyMassIndex = new BodyMassIndex1
.Builder(new TypedUnitValue<>(BodyMassIndexUnit1.KILOGRAMS_PER_SQUARE_METER, 23))
.setEffectiveTimeFrame(OffsetDateTime.parse("2015-10-05T19:52:52-06:00"))
.build();
assertThat(dataPoints.get(0).getBody(), equalTo(expectedBodyMassIndex));
Map<String, Object> testProperties = Maps.newHashMap();
testProperties.put(HEADER_SCHEMA_ID_KEY, BodyMassIndex1.SCHEMA_ID);
testProperties.put(HEADER_EXTERNAL_ID_KEY, "JM2JlMHcHlUP2mAvWWVlwwNFFVo_4CfQ");
testProperties.put(HEADER_SOURCE_UPDATE_KEY, "2015-10-06T01:52:52Z");
testProperties.put(HEADER_SHARED_KEY, true);
testDataPointHeader(dataPoints.get(0).getHeader(), testProperties);
}
示例4: asDataPointsShouldReturnCorrectDataPointWithoutTimeZone
import org.openmhealth.schema.domain.omh.TypedUnitValue; //导入依赖的package包/类
@Test
public void asDataPointsShouldReturnCorrectDataPointWithoutTimeZone() {
List<DataPoint<BodyMassIndex1>> dataPoints = mapper.asDataPoints(singletonList(responseNode));
BodyMassIndex1 expectedBodyMassIndex = new BodyMassIndex1
.Builder(new TypedUnitValue<>(BodyMassIndexUnit1.KILOGRAMS_PER_SQUARE_METER, 22))
.setEffectiveTimeFrame(OffsetDateTime.parse("2015-10-06T19:39:01Z"))
.build();
assertThat(dataPoints.get(1).getBody(), equalTo(expectedBodyMassIndex));
Map<String, Object> testProperties = Maps.newHashMap();
testProperties.put(HEADER_EXTERNAL_ID_KEY, "JM2JlMHcHlVYbz0vvV-tzteoDrIYcQ7k");
testProperties.put(HEADER_SCHEMA_ID_KEY, BodyMassIndex1.SCHEMA_ID);
testProperties.put(HEADER_SOURCE_UPDATE_KEY, "2015-10-06T19:39:02Z");
testProperties.put(HEADER_SHARED_KEY, null);
testDataPointHeader(dataPoints.get(1).getHeader(), testProperties);
}
示例5: main
import org.openmhealth.schema.domain.omh.TypedUnitValue; //导入依赖的package包/类
/**
* The main method.
*
* @param args the arguments
*/
public static void main(String[] args) {
try {
String testJson =
"{\"effective_time_frame\":{\"date_time\":1499546066.953000000},\"descriptive_statistic\":\"median\",\"user_notes\":\"feeling fine\",\"blood_glucose\":{\"unit\":\"mg/dL\",\"value\":110},\"blood_specimen_type\":\"whole blood\",\"temporal_relationship_to_meal\":\"fasting\",\"temporal_relationship_to_sleep\":\"before sleeping\"}";
System.out.println("orginal length: " + testJson.length() );
byte[] compressed = CompressionUtils.compress(testJson.getBytes());
System.out.println("compressed length: " + compressed.length);
String decompressed = CompressionUtils.decompress(compressed).toString();
System.out.println("decompressed: " + decompressed);
TypedUnitValue<BloodGlucoseUnit> bloodGlucoseLevel = new TypedUnitValue<>(MILLIGRAMS_PER_DECILITER, 110);
TimeFrame timeFrame = new TimeFrame(OffsetDateTime.now() );
BloodGlucose bloodGlucose = new BloodGlucose.Builder(bloodGlucoseLevel)
.setBloodSpecimenType(WHOLE_BLOOD)
.setTemporalRelationshipToMeal(FASTING)
.setTemporalRelationshipToSleep(BEFORE_SLEEPING)
.setEffectiveTimeFrame(timeFrame)
// .setEffectiveTimeFrame()
.setDescriptiveStatistic(MEDIAN)
.setUserNotes("feeling fine")
.build();
ObjectMapper objectMapper = new ObjectMapper();
// SimpleModule rfc3339Module = new SimpleModule("rfc3339Module");
// rfc3339Module.addSerializer(new Rfc3339OffsetDateTimeSerializer(OffsetDateTime.class));
// objectMapper.registerModule(rfc3339Module);
objectMapper.registerModule(new JavaTimeModule());
String rawJson = objectMapper.writeValueAsString(bloodGlucose);
System.out.println(rawJson);
BloodGlucose second = objectMapper.readValue(rawJson, BloodGlucose.class);
System.out.println(second.getEffectiveTimeFrame().getDateTime().toString());
System.out.println( objectMapper.writeValueAsString(second));
} catch( Exception e ) {
System.out.println(e);
e.printStackTrace();
}
}
示例6: createBody
import org.openmhealth.schema.domain.omh.TypedUnitValue; //导入依赖的package包/类
@Override// TODO Auto-generated method stub
public Object createBody( OffsetDateTime now, Object prevBody ) throws Exception {
final long mid = 110;
final long max = 130;
final long min = 90;
final long exceed = 170;
final long incr = 3;
long value = 0;// TODO Auto-generated method stub
if( prevBody != null ) {
long prevValue = ((BloodGlucose)prevBody).getBloodGlucose().getValue().longValue();
if( (random.nextInt() % 2) == 1 ) value = prevValue + incr;
else value = prevValue - incr;
if( value < min ) value = min;
else if( value > max ) value = max;
} else value = mid;
// 5% of the time use exceeded value
String userNotes = "Feeling fine";
if( random.nextInt(100) <= MIN_PCT_EXCEED ) {
value = exceed;
userNotes = "light headed";
}
TypedUnitValue<BloodGlucoseUnit> bloodGlucoseLevel = new TypedUnitValue<>(MILLIGRAMS_PER_DECILITER, value);
BloodGlucose bloodGlucose = new BloodGlucose.Builder(bloodGlucoseLevel)
.setBloodSpecimenType(WHOLE_BLOOD)
.setTemporalRelationshipToMeal(FASTING)
.setTemporalRelationshipToSleep(BEFORE_SLEEPING)
.setEffectiveTimeFrame( new TimeFrame(now) )
// .setEffectiveTimeFrame()
.setDescriptiveStatistic(MEDIAN)
.setUserNotes(userNotes)
.build();
return bloodGlucose;
}
示例7: newMeasure
import org.openmhealth.schema.domain.omh.TypedUnitValue; //导入依赖的package包/类
@Override
public BodyFatPercentage newMeasure(TimestampedValueGroup valueGroup) {
return new BodyFatPercentage.Builder(new TypedUnitValue<>(PERCENT, valueGroup.getValue(FAT_PERCENTAGE_KEY)))
.setEffectiveTimeFrame(valueGroup.getTimestamp())
.build();
}
示例8: newMeasure
import org.openmhealth.schema.domain.omh.TypedUnitValue; //导入依赖的package包/类
@Override
public BloodGlucose newMeasure(TimestampedValueGroup valueGroup) {
// TODO set the specimen source once the SDK is updated to omh:blood-glucose:2.0
return new BloodGlucose.Builder(
new TypedUnitValue<>(MILLIGRAMS_PER_DECILITER, valueGroup.getValue(GLUCOSE_KEY)))
.setEffectiveTimeFrame(valueGroup.getTimestamp())
.build();
}
示例9: newMeasureBuilder
import org.openmhealth.schema.domain.omh.TypedUnitValue; //导入依赖的package包/类
@Override
Optional<Measure.Builder<BodyMassIndex1, ?>> newMeasureBuilder(JsonNode listEntryNode) {
TypedUnitValue<BodyMassIndexUnit1> bmiValue =
new TypedUnitValue<>(KILOGRAMS_PER_SQUARE_METER, asRequiredDouble(listEntryNode, "bmi"));
return Optional.of(new BodyMassIndex1.Builder(bmiValue));
}
示例10: asDataPointsShouldReturnCorrectSensedDataPoints
import org.openmhealth.schema.domain.omh.TypedUnitValue; //导入依赖的package包/类
@Test
public void asDataPointsShouldReturnCorrectSensedDataPoints() {
OxygenSaturation expectedOxygenSaturation = new OxygenSaturation.Builder(new TypedUnitValue<>(PERCENT, 99))
.setMeasurementMethod(PULSE_OXIMETRY)
.setMeasurementSystem(PERIPHERAL_CAPILLARY)
.setEffectiveTimeFrame(OffsetDateTime.parse("2015-09-23T15:46:00-06:00"))
.build();
assertThat(dataPoints.get(0).getBody(), equalTo(expectedOxygenSaturation));
assertThat(dataPoints.get(0).getHeader().getAcquisitionProvenance().getModality(), equalTo(SENSED));
assertThat(dataPoints.get(0).getHeader().getBodySchemaId(), equalTo(SCHEMA_ID));
assertThat(dataPoints.get(0).getHeader().getAcquisitionProvenance().getSourceName(),
equalTo(RESOURCE_API_SOURCE_NAME));
}
示例11: asDataPointsShouldReturnCorrectSensedDataPoints
import org.openmhealth.schema.domain.omh.TypedUnitValue; //导入依赖的package包/类
@Test
public void asDataPointsShouldReturnCorrectSensedDataPoints() {
BodyMassIndex1 expectedBodyMassIndex = new BodyMassIndex1.Builder(new TypedUnitValue<>(
KILOGRAMS_PER_SQUARE_METER, 22.56052563257619))
.setEffectiveTimeFrame(OffsetDateTime.parse("2015-09-17T12:04:09-08:00"))
.build();
assertThat(dataPoints.get(0).getBody(), equalTo(expectedBodyMassIndex));
testDataPointHeader(dataPoints.get(0).getHeader(), SCHEMA_ID, SENSED, "5fe5893c418b48cd8da7954f8b6c2f36",
OffsetDateTime.parse("2015-09-17T20:04:17Z"));
}
示例12: asDataPointsShouldReturnCorrectSelfReportedDataPoints
import org.openmhealth.schema.domain.omh.TypedUnitValue; //导入依赖的package包/类
@Test
public void asDataPointsShouldReturnCorrectSelfReportedDataPoints() {
BodyMassIndex1 expectedBodyMassIndex = new BodyMassIndex1.Builder(
new TypedUnitValue<>(KILOGRAMS_PER_SQUARE_METER, 22.56052398681641))
.setEffectiveTimeFrame(OffsetDateTime.parse("2015-09-17T14:07:57-06:00"))
.setUserNotes("Weight so good, look at me now")
.build();
assertThat(dataPoints.get(1).getBody(), equalTo(expectedBodyMassIndex));
testDataPointHeader(dataPoints.get(1).getHeader(), SCHEMA_ID, SELF_REPORTED,
"b702a3a5e998f2fca268df6daaa69871", OffsetDateTime.parse("2015-09-17T20:08:00Z"));
}
示例13: asDataPointsShouldReturnCorrectSelfReportedDataPoints
import org.openmhealth.schema.domain.omh.TypedUnitValue; //导入依赖的package包/类
@Test
public void asDataPointsShouldReturnCorrectSelfReportedDataPoints() {
BloodGlucose expectedBloodGlucose = new BloodGlucose.Builder(new TypedUnitValue<>(MILLIGRAMS_PER_DECILITER, 70))
.setTemporalRelationshipToMeal(AFTER_BREAKFAST)
.setEffectiveTimeFrame(OffsetDateTime.parse("2015-09-24T14:44:40-06:00"))
.build();
assertThat(dataPoints.get(1).getBody(), equalTo(expectedBloodGlucose));
assertThat(dataPoints.get(1).getBody().getAdditionalProperty("temporal_relationship_to_medication").get(),
equalTo("After_taking_pills"));
assertThat(dataPoints.get(1).getHeader().getAcquisitionProvenance().getModality(), equalTo(SELF_REPORTED));
}
示例14: main
import org.openmhealth.schema.domain.omh.TypedUnitValue; //导入依赖的package包/类
/**
* The main method.
*
* @param args the arguments
*/
public static void main(String[] args) {
try {
String id = UUID.randomUUID().toString();
OffsetDateTime now = OffsetDateTime.now();
DataPointHeader header = new DataPointHeader.Builder(id, BloodGlucose.SCHEMA_ID, now)
.setUserId("testUser001")
.setAcquisitionProvenance(
new DataPointAcquisitionProvenance.Builder("RunKeeper")
.setSourceCreationDateTime(now)
.setModality(DataPointModality.SENSED)
.build()
)
.build();
TypedUnitValue<BloodGlucoseUnit> bloodGlucoseLevel = new TypedUnitValue<>(MILLIGRAMS_PER_DECILITER, 110);
BloodGlucose bloodGlucose = new BloodGlucose.Builder(bloodGlucoseLevel)
.setBloodSpecimenType(WHOLE_BLOOD)
.setTemporalRelationshipToMeal(FASTING)
.setTemporalRelationshipToSleep(BEFORE_SLEEPING)
.setEffectiveTimeFrame( new TimeFrame(now) )
// .setEffectiveTimeFrame()
.setDescriptiveStatistic(MEDIAN)
.setUserNotes("feeling fine")
.build();
DataPoint<BloodGlucose> dataPoint = new DataPoint<BloodGlucose>(header, bloodGlucose);
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new JavaTimeModule());
String rawJson = objectMapper.writeValueAsString(dataPoint);
System.out.println(rawJson);
DataPoint after = objectMapper.readValue(rawJson, DataPoint.class);
System.out.println( after.getHeader().getBodySchemaId().getName() + " " + after.getHeader().getBodySchemaId().getVersion() );
System.out.println( after.getHeader().getUserId() );
System.out.println(after.getBody());
String rawJsonBody = objectMapper.writeValueAsString(after.getBody());
BloodGlucose bgAfter = objectMapper.readValue(rawJsonBody, BloodGlucose.class);
System.out.println(bgAfter.getUserNotes());
// System.out.println("orginal length: " + rawJson.length() );
// byte[] compressed = CompressionUtils.compress(rawJson.getBytes());
// System.out.println("compressed length: " + compressed.length);
} catch( Exception e ) {
System.out.println(e);
e.printStackTrace();
}
}
示例15: asDataPoint
import org.openmhealth.schema.domain.omh.TypedUnitValue; //导入依赖的package包/类
@Override
protected Optional<DataPoint<BodyMassIndex1>> asDataPoint(JsonNode listEntryNode, Integer measureUnitMagicNumber) {
Double bmiValue = asRequiredDouble(listEntryNode, "BMI");
if (bmiValue == 0) {
return Optional.empty();
}
BodyMassIndex1.Builder bodyMassIndexBuilder =
new BodyMassIndex1.Builder(new TypedUnitValue<>(KILOGRAMS_PER_SQUARE_METER, bmiValue));
getEffectiveTimeFrameAsDateTime(listEntryNode).ifPresent(bodyMassIndexBuilder::setEffectiveTimeFrame);
getUserNoteIfExists(listEntryNode).ifPresent(bodyMassIndexBuilder::setUserNotes);
BodyMassIndex1 bodyMassIndex = bodyMassIndexBuilder.build();
return Optional.of(new DataPoint<>(createDataPointHeader(listEntryNode, bodyMassIndex), bodyMassIndex));
}