healthkitonomh

Converts HealthKit data to Open mHealth/IEEE 1752 schemas

https://github.com/stanfordbdhg/healthkitonomh

Science Score: 67.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 2 DOI reference(s) in README
  • Academic publication links
    Links to: ieee.org, zenodo.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.5%) to scientific vocabulary
Last synced: 10 months ago · JSON representation ·

Repository

Converts HealthKit data to Open mHealth/IEEE 1752 schemas

Basic Info
Statistics
  • Stars: 3
  • Watchers: 8
  • Forks: 0
  • Open Issues: 0
  • Releases: 3
Created over 3 years ago · Last pushed over 1 year ago
Metadata Files
Readme License Citation

README.md

HealthKitOnOMH

Build and Test codecov DOI

The HealthKitonOMH library provides extensions that convert supported HealthKit samples into corresponding IEEE Standard 1752.1 and Open mHealth (OMH) schemas.

Installation

HealthKitOnOMH can be installed into your Xcode project using Swift Package Manager.

  1. In Xcode 14 and newer (requires Swift 5.7), go to “File” » “Add Packages...”
  2. Enter the URL to this GitHub repository, then select the HealthKitOnOMH package to install.

Usage

The HealthKitonOMH library provides extensions that convert supported HealthKit samples into corresponding IEEE Standard 1752.1 and Open mHealth (OMH) schemas.

swift let sample: HKQuantitySample = // ... let dataPoint: DataPoint<HealthKitQuantitySample> = try sample.omhDataPoint

Example

In the following example, we will query the HealthKit store for step count data, convert the resulting samples to Open mHealth data points based on the omh:heart-rate schema.

```swift import HealthKitOnOMH

// Initialize an HKHealthStore instance and request permissions with it // ...

// Or create a HealthKit sample let date = ISO8601DateFormatter().date(from: "1885-11-11T00:00:00-08:00") ?? .now let sample = HKQuantitySample( type: HKQuantityType(.heartRate), quantity: HKQuantity(unit: HKUnit.count().unitDivided(by: .minute()), doubleValue: 42.0), start: date, end: date )

// Convert the sample into an Open mHealth (OMH) Data Point let json: String do { guard let omhDataPoint = try sample.omhDataPoint as? any DataPoint else { return }

// Encode the data point as JSON
let encoder = JSONEncoder()
encoder.outputFormatting = [.prettyPrinted, .withoutEscapingSlashes, .sortedKeys]

// Note that Open mHealth uses snake case for its properties when represented in JSON
encoder.keyEncodingStrategy = .convertToSnakeCase

let data = try encoder.encode(omhDataPoint)

json = String(decoding: data, as: UTF8.self)

} catch { // Handle any errors here. // ... } ```

The above code will produce the following JSON in conformance with Open mHealth's heart-rate schema:

{ "body" : { "effective_time_frame" : { "time_interval" : { "end_date_time" : { "value" : "1885-11-11T08:00:00Z" }, "start_date_time" : { "value" : "1885-11-11T08:00:00Z" } } }, "heart_rate" : { "unit" : "beats/min", "value" : 42 } }, "header" : { "creation_date_time" : { "value" : "2023-10-11T11:53:30Z" }, "id" : "FF7F647D-8757-4926-871A-3D61DDCD0900", "schema_id" : { "name" : "heart-rate", "namespace" : "omh", "version" : "2.0" } } }

Supported Types

|HKQuantityType|Supported|Open mHealth / IEEE 1752 schema| |-------------|:---------:|-------------| | HKQuantityTypeIdentifierBodyTemperature | :whitecheckmark: | omh:body-temperature:3.x | | HKCorrelationTypeIdentifierBloodPressure | :whitecheckmark: | omh:blood-pressure:3.x | | HKQuantityTypeIdentifierBloodGlucose | :whitecheckmark: | omh:blood-glucose:3.x | | HKQuantityTypeIdentifierBodyFatPercentage | :whitecheckmark: | omh:body-fat-percentage:1.x | | HKQuantityTypeIdentifierBodyMass | :whitecheckmark: | omh:body-weight:2.x | | HKQuantityTypeIdentifierBodyMassIndex | :whitecheckmark: | omh:body-mass-index:1.x | | HKQuantityTypeIdentifierBodyTemperature | :whitecheckmark: | omh:body-temperature:3.x | | HKQuantityTypeIdentifierHeartRate | :whitecheckmark: | omh:heart-rate:2.x | | HKQuantityTypeIdentifierHeight | :whitecheckmark: | omh:body-height:1.x | | HKQuantityTypeIdentifierOxygenSaturation | :whitecheckmark: | omh:oxygen-saturation:2.x | | HKQuantityTypeIdentifierRespiratoryRate | :whitecheckmark: | omh:respiratory-rate:2.x | | HKQuantityTypeIdentifierStepCount | :whitecheckmark: | omh:step-count:3.x |

License

This project is licensed under the MIT License. See Licenses for more information.

Contributors

This project is developed as part of the Stanford Biodesign for Digital Health projects at Stanford. See CONTRIBUTORS.md for a full list of all HealthKitOnOMH contributors.

Notices

HealthKit is a registered trademark of Apple, Inc.

Stanford Byers Center for Biodesign Logo Stanford Byers Center for Biodesign Logo

Owner

  • Name: Stanford Biodesign Digital Health
  • Login: StanfordBDHG
  • Kind: organization
  • Location: United States of America

Citation (CITATION.cff)

#
# This source file is part of the HealthKitOnOMH open source project
#
# SPDX-FileCopyrightText: 2023 Stanford University and the project authors (see CONTRIBUTORS.md)
#
# SPDX-License-Identifier: MIT
# 

cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- family-names: "Ravi"
  given-names: "Vishnu"
  orcid: "https://orcid.org/0000-0003-0359-1275"
- family-names: "Schmiedmayer"
  given-names: "Paul"
  orcid: "https://orcid.org/0000-0002-8607-9148"
title: "HealthKitOnOMH"
doi: 10.5281/zenodo.14004335
url: "https://github.com/StanfordBDHG/HealthKitOnOMH"

GitHub Events

Total
  • Release event: 2
  • Delete event: 3
  • Issue comment event: 3
  • Member event: 3
  • Push event: 6
  • Pull request event: 5
  • Pull request review comment event: 2
  • Pull request review event: 2
  • Create event: 4
Last Year
  • Release event: 2
  • Delete event: 3
  • Issue comment event: 3
  • Member event: 3
  • Push event: 6
  • Pull request event: 5
  • Pull request review comment event: 2
  • Pull request review event: 2
  • Create event: 4

Issues and Pull Requests

Last synced: 10 months ago

All Time
  • Total issues: 0
  • Total pull requests: 16
  • Average time to close issues: N/A
  • Average time to close pull requests: about 14 hours
  • Total issue authors: 0
  • Total pull request authors: 2
  • Average comments per issue: 0
  • Average comments per pull request: 0.81
  • Merged pull requests: 16
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 4
  • Average time to close issues: N/A
  • Average time to close pull requests: 4 minutes
  • Issue authors: 0
  • Pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.75
  • Merged pull requests: 4
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
  • vishnuravi (14)
  • PSchmiedmayer (1)
  • Supereg (1)
Top Labels
Issue Labels
Pull Request Labels
enhancement (1)

Packages

  • Total packages: 1
  • Total downloads: unknown
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 3
swiftpackageindex.com: github.com/StanfordBDHG/HealthKitOnOMH

Converts HealthKit data to Open mHealth/IEEE 1752 schemas

  • Versions: 3
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 16.6%
Dependent repos count: 33.7%
Average: 45.9%
Forks count: 62.1%
Stargazers count: 71.3%
Last synced: 10 months ago