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

A Flutter implementation of the Open mHealth (omh) schemas. Used for formatting health data collected from mobile phones (mHealth).

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.

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 = BloodPressure(
      systolicBloodPressure: SystolicBloodPressure(
          unit: BloodPressureUnit.MM_OF_MERCURY, value: 160.0),
      diastolicBloodPressure: DiastolicBloodPressure(
          unit: BloodPressureUnit.MM_OF_MERCURY, value: 80.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 = Geoposition(
      longitude: PlaneAngleUnitValue(
          unit: PlaneAngleUnit.DEGREE_OF_ARC, value: 40.059692382),
      latitude: PlaneAngleUnitValue(
          unit: PlaneAngleUnit.DEGREE_OF_ARC, value: -105.21440124511719),
      elevation: LengthUnitValue((LengthUnit.METER), 1548.5));

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

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(body: 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-2021 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
150
pub points
37%
popularity

Publisher

verified publishercachet.dk

A Flutter implementation of the Open mHealth (omh) schemas. Used for formatting health data collected from mobile phones (mHealth).

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

json_annotation, uuid

More

Packages that depend on openmhealth_schemas