forked from MORE-Platform/more-data-gateway
-
Notifications
You must be signed in to change notification settings - Fork 0
#196: Implemented BloodPressure storage to elastic #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/java/io/redlink/more/data/model/garmin/transformation/GarminBloodPressure.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package io.redlink.more.data.model.garmin.transformation; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
|
|
||
| /** | ||
| * Represents a blood pressure record in the Garmin ecosystem. | ||
| * This record encapsulates systolic and diastolic blood pressure readings, | ||
| * pulse information, and the source from which the data was obtained. | ||
| * <p> | ||
| * The {@link SourceType} enum defines the possible origins of the measurement, | ||
| * which can either be entered manually or recorded by a device. | ||
| * | ||
| * @param systolic The systolic blood pressure value measured in mmHg. | ||
| * @param diastolic The diastolic blood pressure value measured in mmHg. | ||
| * @param pulse The pulse rate measured in beats per minute (BPM). | ||
| * @param sourceType The origin of the blood pressure record (manual entry or device). | ||
| */ | ||
| @JsonIgnoreProperties(ignoreUnknown = true) | ||
| public record GarminBloodPressure( | ||
| Integer systolic, | ||
| Integer diastolic, | ||
| Integer pulse, | ||
| SourceType sourceType | ||
| ) { | ||
| public enum SourceType { | ||
| MANUAL, | ||
| DEVICE | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/main/java/io/redlink/more/data/transformers/garmin/BloodPressureTransformer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| package io.redlink.more.data.transformers.garmin; | ||
|
|
||
| import io.redlink.more.data.custom.model.GarminDataPoint; | ||
| import io.redlink.more.data.model.DataPoint; | ||
| import io.redlink.more.data.model.DataType; | ||
| import io.redlink.more.data.model.Observation; | ||
| import io.redlink.more.data.model.garmin.GarminSummaryType; | ||
| import io.redlink.more.data.model.garmin.transformation.GarminBloodPressure; | ||
| import io.redlink.more.data.model.garmin.transformation.GarminTimeData; | ||
| import io.redlink.more.data.util.MapperUtils; | ||
| import org.apache.commons.lang3.Range; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| import java.time.Instant; | ||
| import java.util.List; | ||
|
|
||
| @Component | ||
| public class BloodPressureTransformer extends AbstractGarminTransformer { | ||
| @Override | ||
| public GarminSummaryType getSupportedType() { | ||
| return GarminSummaryType.BLOODPRESSURES; | ||
| } | ||
|
|
||
| @Override | ||
| protected List<DataPoint> transformToDataPoint(List<Observation> observations, GarminDataPoint garminDataPoint) { | ||
| var data = extractBloodPressure(garminDataPoint); | ||
| return super.transformGarminTimeDataToDataPoint(observations, garminDataPoint.getSummaryId(), DataType.BLOOD_PRESSURE, data); | ||
| } | ||
|
|
||
| @Override | ||
| protected List<DataPoint> filterDataPointByTimeRange(List<Range<Instant>> validTimeRanges, List<DataPoint> dataBulk) { | ||
| return dataBulk; | ||
| } | ||
|
|
||
| private GarminTimeData<GarminBloodPressure> extractBloodPressure(GarminDataPoint garminDataPoint) { | ||
| GarminBloodPressure data = MapperUtils.convertValue(garminDataPoint, GarminBloodPressure.class); | ||
| var measurementTime = super.recordingTimestamp(garminDataPoint); | ||
| return new GarminTimeData<>(measurementTime.toInstant(), data); | ||
| } | ||
| } |
13 changes: 13 additions & 0 deletions
13
src/main/java/io/redlink/more/data/util/DateTimeUtils.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package io.redlink.more.data.util; | ||
|
|
||
| import java.time.Instant; | ||
| import java.time.OffsetDateTime; | ||
| import java.time.ZoneOffset; | ||
|
|
||
| public class DateTimeUtils { | ||
| public static OffsetDateTime offsetDateTimeFromEpochSeconds(long epochSecond, int offset) { | ||
| Instant unixTimestamp = Instant.ofEpochSecond(epochSecond); | ||
| ZoneOffset zoneOffset = ZoneOffset.ofTotalSeconds(offset); | ||
| return unixTimestamp.atOffset(zoneOffset); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.