openmhealth_schemas 0.0.3 copy "openmhealth_schemas: ^0.0.3" to clipboard
openmhealth_schemas: ^0.0.3 copied to clipboard

outdated

A Flutter implementation of the Open mHealth (omh) schemas.

Open mHealth Schemas for Flutter #

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

Usage #

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

Example #

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

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;
  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}';

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.

1
likes
0
pub points
32%
popularity

Publisher

verified publishercachet.dk

A Flutter implementation of the Open mHealth (omh) schemas.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, json_annotation, uuid

More

Packages that depend on openmhealth_schemas