Skip to content

Commit

Permalink
Fix oxygen saturation and body fat percent
Browse files Browse the repository at this point in the history
  • Loading branch information
schaefba committed Mar 3, 2016
1 parent aadafc3 commit 514e5ff
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PODS:
- Expecta (1.0.5)
- Granola (0.3.0):
- Granola (0.4.0):
- ObjectiveSugar (~> 1.1)
- ObjectiveSugar (1.1.0)
- Specta (1.0.5)
Expand All @@ -18,7 +18,7 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
Expecta: e1c022fcd33910b6be89c291d2775b3fe27a89fe
Granola: 9363048b8cc0309b43ed1f6b700af47b55b74f35
Granola: c765790ab0a5ab322cb09717f415a1d12e0bdcb4
ObjectiveSugar: a6a25f23d657c19df0a0b972466d5b5ca9f5295c
Specta: ac94d110b865115fe60ff2c6d7281053c6f8e8a2
VVJSONSchemaValidation: 11f5ba886e80baccae5d606f3b10f20c1303200d
Expand Down
8 changes: 4 additions & 4 deletions Example/Tests/OMHSerializerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,7 @@
describe(@"HKQuantityTypeIdentifierOxygenSaturation with time_interval", ^{
itShouldBehaveLike(@"AnySerializerForSupportedSample",^{
NSDate *start = [NSDate date];
NSNumber *value = [NSNumber numberWithFloat:96.1];
NSNumber *value = [NSNumber numberWithDouble:.961];
NSString *unitString = @"%";
HKSample *sample = [OMHSampleFactory typeIdentifier:HKQuantityTypeIdentifierOxygenSaturation
attrs:@{@"value":value,
Expand All @@ -1071,7 +1071,7 @@
@"header.schema_id.name": @"oxygen-saturation",
@"header.schema_id.namespace":@"omh",
@"header.schema_id.version": @"1.0",
@"body.oxygen_saturation.value":value,
@"body.oxygen_saturation.value":@96.1,
@"body.oxygen_saturation.unit":unitString,
@"body.effective_time_frame.date_time":[start RFC3339String]
}
Expand Down Expand Up @@ -1109,7 +1109,7 @@
itShouldBehaveLike(@"AnySerializerForSupportedSample",^{
NSDate *start = [NSDate date];
NSDate *end = [start dateByAddingTimeInterval:3600];
NSNumber *value = [NSNumber numberWithFloat:23.2];
NSNumber *value = [NSNumber numberWithDouble:.232];
NSString *unitString = @"%";
HKSample *sample = [OMHSampleFactory typeIdentifier:HKQuantityTypeIdentifierBodyFatPercentage
attrs:@{@"value":value,
Expand All @@ -1122,7 +1122,7 @@
@"header.schema_id.name": @"body-fat-percentage",
@"header.schema_id.namespace":@"omh",
@"header.schema_id.version": @"1.0",
@"body.body_fat_percentage.value": value,
@"body.body_fat_percentage.value": @23.2,
@"body.body_fat_percentage.unit": unitString,
@"body.effective_time_frame.time_interval.start_date_time": [sample.startDate RFC3339String],
@"body.effective_time_frame.time_interval.end_date_time": [sample.endDate RFC3339String]
Expand Down
9 changes: 4 additions & 5 deletions Pod/Classes/OMHSerializer.m
Original file line number Diff line number Diff line change
Expand Up @@ -430,11 +430,11 @@ + (BOOL)canSerialize:(HKQuantitySample*)sample error:(NSError**)error {
- (id)bodyData {
NSString* unitString = @"%";
HKUnit* unit = [HKUnit unitFromString:unitString];
float value = [[(HKQuantitySample*)self.sample quantity] doubleValueForUnit:unit];
double value = [[(HKQuantitySample*)self.sample quantity] doubleValueForUnit:unit];

return @{
@"oxygen_saturation": @{
@"value": [NSNumber numberWithDouble:value],
@"value": [NSNumber numberWithDouble:value*100],
@"unit": unitString
},
@"effective_time_frame": [self populateTimeFrameProperty:self.sample.startDate endDate:self.sample.endDate]
Expand Down Expand Up @@ -618,11 +618,10 @@ + (BOOL)canSerialize:(HKQuantitySample*)sample error:(NSError**)error {
- (id)bodyData {
NSString* unitString = @"%";
HKUnit* unit = [HKUnit unitFromString:unitString];
float value =
[[(HKQuantitySample*)self.sample quantity] doubleValueForUnit:unit];
double value = [[(HKQuantitySample*)self.sample quantity] doubleValueForUnit:unit];
return @{
@"body_fat_percentage": @{
@"value": [NSNumber numberWithDouble:value],
@"value": [NSNumber numberWithDouble:value*100],
@"unit": unitString
},
@"effective_time_frame": [self populateTimeFrameProperty:self.sample.startDate endDate:self.sample.endDate]
Expand Down

0 comments on commit 514e5ff

Please sign in to comment.