Skip to content
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

Create Health Connect to FHIR converter module #15

Merged
merged 44 commits into from
Jun 17, 2024
Merged

Conversation

vishnuravi
Copy link
Member

@vishnuravi vishnuravi commented May 22, 2024

Create Health Connect to FHIR converter module

The HealthConnectOnFHIR library provides a mapper that converts supported Android Health Connect Records to corresponding HL7® FHIR® R4 Observations with standardized codes (e.g. LOINC).

For more information, please refer to the API documentation.

Mapping Table

Health Connect Record FHIR Observation Category LOINC Code Unit Display
ActiveCaloriesBurnedRecord Activity 41981-2 kcal Calories burned
BloodGlucoseRecord 41653-7 mg/dL Glucose Glucometer (BldC) [Mass/Vol]
BloodPressureRecord Vital Signs 85354-9 mmHg Blood pressure panel with all children optional
BodyFatRecord 41982-0 % Percentage of body fat Measured
BodyTemperatureRecord Vital Signs 8310-5 Cel Body temperature
HeartRateRecord Vital Signs 8867-4 /min Heart rate
HeightRecord Vital Signs 8302-2 m Body height
OxygenSaturationRecord Vital Signs 59408-5 % Oxygen saturation in Arterial blood by Pulse oximetry
RespiratoryRateRecord Vital Signs 9279-1 /min Respiratory rate
StepsRecord Activity 55423-8 steps Number of steps
WeightRecord Vital Signs 29463-7 kg Body weight

Installation

HealthConnectOnFHIR can be installed into your Android Studio project via Jitpack.

Usage

// 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.

// 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
    }
}

📝 Code of Conduct & Contributing Guidelines

By submitting creating this pull request, you agree to follow our Code of Conduct and Contributing Guidelines:

@vishnuravi vishnuravi marked this pull request as ready for review May 26, 2024 18:12
@vishnuravi vishnuravi requested a review from PSchmiedmayer May 27, 2024 00:06
Copy link
Member

@PSchmiedmayer PSchmiedmayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for adding this in the @StanfordSpezi ecosystem @vishnuravi!

I added my thoughts in the discussions below, thank you @eldcn & @Basler182 for the first reviews!

.DS_Store Outdated Show resolved Hide resolved
Copy link

codecov bot commented Jun 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 26.40%. Comparing base (b77e6ea) to head (4217b3b).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main      #15      +/-   ##
============================================
+ Coverage     19.38%   26.40%   +7.02%     
- Complexity      146      193      +47     
============================================
  Files            99      101       +2     
  Lines          2611     2860     +249     
  Branches        392      404      +12     
============================================
+ Hits            506      755     +249     
  Misses         2063     2063              
  Partials         42       42              
Flag Coverage Δ
unittests 26.40% <100.00%> (+7.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...ava/edu/stanford/healthconnectonfhir/MappedUnit.kt 100.00% <100.00%> (ø)
...althconnectonfhir/RecordToObservationMapperImpl.kt 100.00% <100.00%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b77e6ea...4217b3b. Read the comment docs.

@PSchmiedmayer
Copy link
Member

Thanks for the updates here @vishnuravi 🚀
Wondering if we can merge the PR in its current state for now?

@vishnuravi
Copy link
Member Author

Thanks for the updates here @vishnuravi 🚀 Wondering if we can merge the PR in its current state for now?

We can merge it if everyone is OK with the updated method of implementing the mapper - can discuss at the meeting today.

Copy link
Contributor

@eldcn eldcn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

Copy link
Member

@PSchmiedmayer PSchmiedmayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @vishnuravi!

@vishnuravi vishnuravi merged commit b9f4ae6 into main Jun 17, 2024
7 checks passed
@vishnuravi vishnuravi deleted the healthconnectonfhir branch June 17, 2024 02:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants