-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create Health Connect to FHIR converter module (#15)
# Create Health Connect to FHIR converter module The HealthConnectOnFHIR library provides a mapper that converts supported [Android Health Connect](https://health.google/health-connect-android/) Records to corresponding [HL7® FHIR® R4 Observations](https://hl7.org/fhir/r4/observation.html) with standardized codes (e.g. [LOINC](https://loinc.org/)).
- Loading branch information
1 parent
b77e6ea
commit b9f4ae6
Showing
13 changed files
with
918 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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 was deleted.
Oops, something went wrong.
This file contains 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 |
---|---|---|
@@ -1,4 +1,2 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest> | ||
|
||
</manifest> | ||
<manifest /> |
This file contains 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 @@ | ||
/build |
This file contains 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,83 @@ | ||
# Module healthconnectonfhir | ||
|
||
The HealthConnectOnFHIR library provides a mapper that converts supported [Android Health Connect](https://health.google/health-connect-android/) Records to corresponding [HL7® FHIR® R4 Observations](https://hl7.org/fhir/r4/observation.html) with standardized codes (e.g. [LOINC](https://loinc.org/)). | ||
|
||
For more information, please refer to the API documentation. | ||
|
||
## Mapping Table | ||
|
||
| Health Connect Record | FHIR Observation Category | LOINC Code | Unit | Display | | ||
|------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------|------------|------------|--------------------------------------------| | ||
| [ActiveCaloriesBurnedRecord](https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/ActiveCaloriesBurnedRecord) | Activity | 41981-2 | kcal | Calories burned | | ||
| [BloodGlucoseRecord](https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/BloodGlucoseRecord) | | 41653-7 | mg/dL | Glucose Glucometer (BldC) [Mass/Vol] | | ||
| [BloodPressureRecord](https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/BloodPressureRecord) | Vital Signs | 85354-9 | mmHg | Blood pressure panel with all children optional | | ||
| [BodyFatRecord](https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/BodyFatRecord) | | 41982-0 | % | Percentage of body fat Measured | | ||
| [BodyTemperatureRecord](https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/BodyTemperatureRecord) | Vital Signs | 8310-5 | Cel | Body temperature | | ||
| [HeartRateRecord](https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/HeartRateRecord) | Vital Signs | 8867-4 | /min | Heart rate | | ||
| [HeightRecord](https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/HeightRecord) | Vital Signs | 8302-2 | m | Body height | | ||
| [OxygenSaturationRecord](https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/OxygenSaturationRecord) | Vital Signs | 59408-5 | % | Oxygen saturation in Arterial blood by Pulse oximetry | | ||
| [RespiratoryRateRecord](https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/RespiratoryRateRecord) | Vital Signs | 9279-1 | /min | Respiratory rate | | ||
| [StepsRecord](https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/StepsRecord) | Activity | 55423-8 | steps | Number of steps | | ||
| [WeightRecord](https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/WeightRecord) | Vital Signs | 29463-7 | kg | Body weight | | ||
|
||
|
||
## Installation | ||
|
||
HealthConnectOnFHIR can be installed into your Android Studio project [via Jitpack](https://jitpack.io/#StanfordSpezi/SpeziKt/healthconnectonfhir-maven). | ||
|
||
## Usage | ||
|
||
```kotlin | ||
// Initialize the mapper | ||
val mapper = RecordToObservationMapperImpl() | ||
|
||
// Query a `Record` from Health Connect | ||
val record = // .. | ||
|
||
// Map the record to an HL7 FHIR Observation | ||
val observation = mapper.map(record) | ||
``` | ||
|
||
## Example | ||
|
||
First, you will need to configure your application to use Android Health Connect. For more information, please see the [official documentation](https://developer.android.com/health-and-fitness/guides/health-connect). | ||
|
||
```kotlin | ||
// Initialize a `HealthConnectClient` (see Health Connect docs for full details) | ||
val healthConnectClient = HealthConnectClient.getOrCreate(context) | ||
|
||
// Define a time range for the query | ||
val startTime = Instant.parse("2023-05-01T00:00:00Z") | ||
val endTime = Instant.parse("2023-06-01T00:00:00Z") | ||
|
||
// Query a list of `WeightRecord`s from Health Connect | ||
val result = healthConnectClient.readRecords( | ||
ReadRecordsRequest( | ||
recordType = WeightRecord::class, | ||
timeRangeFilter = TimeRangeFilter.between(startTime, endTime) | ||
) | ||
).records | ||
|
||
// Initialize the mapper | ||
val mapper = RecordToObservationMapperImpl() | ||
|
||
// Convert each weight record to a FHIR Observation | ||
result.forEach { weightRecord -> | ||
val observations = mapper.map(weightRecord) | ||
observations.forEach { observation -> | ||
// Do something with the observation | ||
} | ||
} | ||
``` | ||
|
||
## License | ||
|
||
This project is licensed under the MIT license. | ||
|
||
## Contributors | ||
|
||
This project is developed as a part of the Stanford Biodesign for Digital Health projects at Stanford. See CONTRIBUTORS.md for a full list of all HealthConnectOnFHIR contributors. | ||
|
||
## Notices | ||
|
||
Health Connect is a registered trademark of Google. FHIR is a registered trademark of Health Level Seven International. |
This file contains 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 @@ | ||
plugins { | ||
alias(libs.plugins.spezi.library) | ||
alias(libs.plugins.spezi.hilt) | ||
} | ||
|
||
android { | ||
namespace = "edu.stanford.spezi.modules.healthconnectonfhir" | ||
} | ||
|
||
dependencies { | ||
api(libs.androidx.health.connect.client) | ||
api(libs.hapi.fhir.structures.r4) | ||
} |
This file contains 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,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
</manifest> |
3 changes: 3 additions & 0 deletions
3
modules/healthconnectonfhir/src/main/java/edu/stanford/healthconnectonfhir/MappedUnit.kt
This file contains 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,3 @@ | ||
package edu.stanford.healthconnectonfhir | ||
|
||
data class MappedUnit(val unit: String, val system: String, val code: String) |
15 changes: 15 additions & 0 deletions
15
...connectonfhir/src/main/java/edu/stanford/healthconnectonfhir/RecordToObservationMapper.kt
This file contains 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,15 @@ | ||
package edu.stanford.healthconnectonfhir | ||
|
||
import androidx.health.connect.client.records.Record | ||
import org.hl7.fhir.r4.model.Observation | ||
|
||
interface RecordToObservationMapper { | ||
/** | ||
* Maps a given Health Connect record to a list of HL7 FHIR Observations | ||
* | ||
* @param T the type of the Health Connect record, extending from `Record` | ||
* @param record the record to be mapped | ||
* @return a list of `Observation` objects derived from the provided health record | ||
*/ | ||
fun <T : Record> map(record: T): List<Observation> | ||
} |
Oops, something went wrong.