openmhealth_schemas 0.1.1

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 46

Open mHealth Schemas for Flutter

A Flutter implementation of the Open mHealth schemas. The original Java schemas are available on the Open mHealth GitHub.

Disclaimer: Note that not all OMH schemas are implemented yet. This is work in progress.

Usage

To use this plugin, add openmhealth_schemas as a dependency in your pubspec.yaml file.

Note that this plugin relies on json_serialization: ^1.0.0 which again rely on Dart 2.1. This mean that (at the time of writing) you should use the dev channel in Flutter. This can be set using the following Flutter command:

flutter channel dev

Example

The following example shows how to use the OMH Flutter classes to model OMH measures, convert these to JSON, and read them back from JSON.

Creating OMH Measures as Dart Objects

First, create an OMH BloodPressure measure similar to the OMH BloodPressure example.

  BloodPressure bp = new BloodPressure(new SystolicBloodPressure(BloodPressureUnit.MM_OF_MERCURY, 160.0),
      new DiastolicBloodPressure(BloodPressureUnit.MM_OF_MERCURY, 60.0),
      positionDuringMeasurement: PositionDuringMeasurement.SITTING);
  DateTime start = new DateTime(2016, 2, 5);
  DateTime end = new DateTime(2016, 6, 5);
  TimeInterval time = new TimeInterval(startDateTime: start, endDateTime: end);
  bp.effectiveTimeFrame = new TimeFrame(timeInterval: time);
  bp.descriptiveStatistic = DescriptiveStatistic.MAXIMUM;

This can now be converted to JSON.

  final bp_json = JsonEncoder.withIndent(' ').convert(bp);

which should produce the following JSON

{
 "effective_time_frame": {
  "time_interval": {
   "start_date_time": "2016-02-05T00:00:00.000",
   "end_date_time": "2016-06-05T00:00:00.000"
  }
 },
 "descriptive_statistic": "maximum",
 "systolic_blood_pressure": {
  "unit": "mmHg",
  "value": 160.0
 },
 "diastolic_blood_pressure": {
  "unit": "mmHg",
  "value": 60.0
 },
 "position_during_measurement": "sitting"
}

Similarly, a OMH Geoposition similar to the OMH Geoposition example can be created

  Geoposition position = new Geoposition(new PlaneAngleUnitValue(PlaneAngleUnit.DEGREE_OF_ARC, 40.059692382),
      new PlaneAngleUnitValue(PlaneAngleUnit.DEGREE_OF_ARC, -105.21440124511719),
      elevation: new LengthUnitValue((LengthUnit.METER), 1548.5));

  position.effectiveTimeFrame = new TimeFrame(dateTime: DateTime.now());
  position.positioningSystem = PositioningSystem.GPS;

This should give the following JSON OMH measure.

{
 "effective_time_frame": {
  "date_time": "2018-08-24T11:08:33.772301"
 },
 "latitude": {
  "unit": "deg",
  "value": 40.059692382
 },
 "longitude": {
  "unit": "deg",
  "value": -105.21440124511719
 },
 "elevation": {
  "unit": "m",
  "value": 1548.5
 },
 "positioning_system": "GPS"
}

Reading OMH JSON Schemas

If you have a OMH JSON measure (in this case a PhysicalActivity) you can instantiate a Dart object from it by;

  final activity = PhysicalActivity.fromJson(json.decode(json_activity_string) as Map<String, dynamic>);

Creating and Uploading OMH Data Points

An OMH DataPoint for the above BloodPressure measure can be created by;

  DataPoint dp = new DataPoint(bp);

which can be converted (using JsonEncoder.withIndent(' ').convert(dp)) into the following OMH JSON data point with its header and body.

{
 "header": {
  "id": "747cf980-9620-11e8-afe9-9bf5923b2a8c",
  "creation_date_time": "2018-08-24T11:31:18.681644",
  "schema_id": {
   "namespace": "omh",
   "name": "blood-pressure",
   "version": "1.0"
  }
 },
 "body": {
  "effective_time_frame": {
   "time_interval": {
    "start_date_time": "2016-02-05T00:00:00.000",
    "end_date_time": "2016-06-05T00:00:00.000"
   }
  },
  "descriptive_statistic": "maximum",
  "systolic_blood_pressure": {
   "unit": "mmHg",
   "value": 160.0
  },
  "diastolic_blood_pressure": {
   "unit": "mmHg",
   "value": 60.0
  },
  "position_during_measurement": "sitting"
 }
}

Uploading to OMH Data Storage Unit

Uploading to a OMH Data Storage Unit (DSU) (like the omh-dsu-ri) is not implemented yet.

Getting Started with Flutter

For help getting started with Flutter, view the online documentation.

For help on editing package code, view the documentation.

Features and bugs

Please file feature requests and bug reports at the issue tracker.

License

This software is copyright (c) 2018 Copenhagen Center for Health Technology (CACHET) at the Technical University of Denmark (DTU). This software is made available 'as-is' in a MIT license.

0.1.1

  • Updated documentation

0.1.0

  • Update to support Dart 2.0

0.0.4

  • Implemented cardio-related schemas, such as RrInterval and HeartRate.
  • Improvement to documentation.

0.0.3

  • Implementation of BloodPressure and associated schemas.
  • Implementation of time-related schemas, such as TemporalRelationshipToMeal etc.
  • Adding support for JSON de/serialization of the OMH schemas implemented so far.
  • Extensive unit test for the de/serialization, including loading test data from the OMH website.

0.0.2

  • Implementation of OMH schemas:
    • Activity, including PhysicalActivity, KcalUnitValue, KcalUnit, StepCount, CalloriesBurden, etc.
    • updates and refactor of other base schemas
  • Adding more tests

0.0.1

  • Initial commit of OMH domain model ...
    • Basic support for schemas, including SchemaId, SchemaVersion, and the mixin class AdditionalPropertySupport.
    • The core OMH units, including Unit, UnitValue and TypedUnitValue.
    • Implementation of DescriptiveStatistic.
    • Support for the OMH geoposition schemas including Geoposition, PlaneAngleUnitValue, etc.
  • Test skeleton -- which needs to be extended to better coverage.

example/lib/main.dart

import 'package:openmhealth_schemas/openmhealth_schemas.dart';
import 'dart:convert';

void main() {
  // Creating a [BloodPressure] similar to the one shown at
  // http://www.openmhealth.org/documentation/#/schema-docs/schema-library/schemas/omh_blood-pressure
  BloodPressure bp = new BloodPressure(
      new SystolicBloodPressure(BloodPressureUnit.MM_OF_MERCURY, 160.0),
      new DiastolicBloodPressure(BloodPressureUnit.MM_OF_MERCURY, 60.0),
      positionDuringMeasurement: PositionDuringMeasurement.SITTING);
  DateTime start = new DateTime(2016, 2, 5);
  DateTime end = new DateTime(2016, 6, 5);
  TimeInterval time = new TimeInterval(startDateTime: start, endDateTime: end);
  bp.effectiveTimeFrame = new TimeFrame(timeInterval: time);
  bp.descriptiveStatistic = DescriptiveStatistic.MAXIMUM;

  // Now convert this to JSON
  final bp_json = _encode(bp);
  print("\nBloodPressure:\n" + bp_json);

  // Similarly - create a [Geoposition] object, convert it to JSON and print it.
  Geoposition position = new Geoposition(
      new PlaneAngleUnitValue(PlaneAngleUnit.DEGREE_OF_ARC, 40.059692382),
      new PlaneAngleUnitValue(
          PlaneAngleUnit.DEGREE_OF_ARC, -105.21440124511719),
      elevation: new LengthUnitValue((LengthUnit.METER), 1548.5));

  position.positioningSystem = PositioningSystem.GPS;
  position.effectiveTimeFrame = new TimeFrame(dateTime: DateTime.now());
  print("\nGeoposition:\n" + _encode(position));

  //Creating OMH data point ready to be uploaded to an OMH sever

  //First, the data point for the blood pressure measure.
  DataPoint dp_1 = new DataPoint(bp);
  print("\nDataPoint_BloodPressure:\n" + _encode(dp_1));

  // Then the data point for the geo position measure.
  DataPoint dp_2 = new DataPoint(position,
      userId: "bardram",
      provenance: new DataPointAcquisitionProvenance("Android Nexus Phone",
          modality: DataPointModality.SENSED));

  print("\nDataPoint_Geoposition:\n" + _encode(dp_2));

  //Finally, read a JSON string and convert it into a Flutter object.
  final act_1 =
      PhysicalActivity.fromJson(json.decode(omh_pa) as Map<String, dynamic>);

  print("\nA person has been " +
      act_1.activityName +
      " " +
      act_1.distance.value.toString() +
      " " +
      act_1.distance.unit);
}

String _encode(Object object) =>
    const JsonEncoder.withIndent(' ').convert(object);

// The following data is various OMH JSON examples from the OMH website.
// Testing if we can load these.
final String omh_pa =
    '{    "activity_name": "walking", "distance": { "value": 3.1, "unit": "mi" }, "effective_time_frame": { "time_interval": { "start_date_time": "2015-02-06T06:25:00Z", "end_date_time": "2015-02-06T07:25:00Z" } },"kcal_burned": {"value": 160,"unit": "kcal"},"met_value": 3.5}';

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  openmhealth_schemas: ^0.1.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:openmhealth_schemas/openmhealth_schemas.dart';
  
Version Uploaded Documentation Archive
0.1.1 Oct 13, 2018 Go to the documentation of openmhealth_schemas 0.1.1 Download openmhealth_schemas 0.1.1 archive
0.1.0 Oct 11, 2018 Go to the documentation of openmhealth_schemas 0.1.0 Download openmhealth_schemas 0.1.0 archive
0.0.4 Aug 24, 2018 Go to the documentation of openmhealth_schemas 0.0.4 Download openmhealth_schemas 0.0.4 archive
0.0.3 Aug 23, 2018 Go to the documentation of openmhealth_schemas 0.0.3 Download openmhealth_schemas 0.0.3 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
46
Learn more about scoring.

We analyzed this package on Nov 14, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.6
  • Flutter: 0.11.3

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Maintenance suggestions

The description is too short. (-20 points)

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
flutter 0.0.0
json_annotation ^1.0.0 1.2.0 2.0.0
uuid ^1.0.0 1.0.3
Transitive dependencies
charcode 1.1.2
collection 1.14.11
convert 2.0.2
crypto 2.0.6
meta 1.1.6
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
build_runner ^0.10.0
flutter_test
json_serializable ^1.0.0