AnpherosAnpheros PlatformDevelopers

Try it free in the sandbox · first FHIR call in 5 minutesFree · 30 synthetic patients · no card

Health Connect と FHIR

FlutterでFitbit、Garmin、Oura、Withings、Wear OSからのAndroid Health Connectデータを読み取り、FHIR R4レコードに書き込む方法:権限、履歴、Playストア審査。

Health Connect は Android のオンデバイスヘルスストアです。Samsung Health, Fitbit, Garmin Connect, Oura, Withings, Wear OS アプリが書き込みを行い、あなたのアプリはユーザーの許可を得てそこから読み取ります。 そのデータを FHIR レコードに入れるには、電話で日次合計と平均を読み取り、バックエンドに送信し、各メトリックを LOINC コードと UCUM 単位を持つ Observation として書き込みます。このページでは、Android が要求するパーミッション、同じコードで Android の Health Connect と iOS の Apple Health を読み取る Flutter の例(flutter analyze で確認済み)、および Google Play での公開に関するルールについて説明します。

Health Connect に到達するもの

Health Connect は Android 14 以降に組み込まれており、古いバージョンではアプリとして利用できます。HeartRateRecord、RestingHeartRateRecord、HeartRateVariabilityRmssdRecord、OxygenSaturationRecord、RespiratoryRateRecord、StepsRecord、DistanceRecord、ActiveCaloriesBurnedRecord、SleepSessionRecord、WeightRecord、BloodPressureRecord、BloodGlucoseRecord、BodyTemperatureRecord、ExerciseSessionRecord などの記録を保持します。

各ベンダーのドキュメントによると、誰がそこに書き込むか:

ソース 期待される内容
Fitbit および Pixel Watch Fitbit アプリは、ユーザーがセットアップすると Health Connect と同期します (Google ヘルプ)
Garmin Garmin Connect は Android 14 以降で Health Connect をサポートしています:心拍数やカロリーなどのアクティビティおよびウェルネスデータ (Android Developers, August 2025)
Oura 心拍数、HRV、睡眠ステージ、歩数、距離、カロリー、ワークアウト (Oura)
Withings Health Mate は、Health Connect を介してアクティビティ、体重、睡眠、その他のデータを交換します (Android Developers blog)
Samsung Health, Galaxy Watch 一部のデータのみ。Samsung Health のペースで行われます — Samsung Health to FHIR を参照してください

各ベンダーアプリは、Health Connect への書き込み権限が必要です。これは、ユーザーがそのアプリまたは Health Connect の設定で付与します。ソースが見つからない場合は、まずこれをチェックしてください。

Android で必要な権限

Flutterで日次値を取得する

health パッケージは、AndroidのHealth ConnectとiOSのApple Healthを単一のAPIで読み取ります。この例では、Anpheros Dailyが同梱しているバージョン13.2.1を使用しています。

import 'dart:math' as math;

import 'package:health/health.dart';

/// One day of data from Health Connect (Android) or Apple Health (iOS), ready for your backend.
class DailyValue {
  DailyValue(this.metric, this.day, this.value, {this.min, this.max});
  final String metric; // 'heart_rate', 'steps'
  final String day; // '2026-10-01', the user's local day
  final double value;
  final double? min, max;

  Map<String, Object?> toJson() => {'metric': metric, 'day': day, 'value': value, 'min': min, 'max': max};
}

final health = Health();

Future<List<DailyValue>> collectLastDays({int days = 30}) async {
  await health.configure();
  if (!await health.isHealthConnectAvailable()) {
    await health.installHealthConnect(); // opens the Play Store on Android; always available on iOS
    return [];
  }
  const types = [HealthDataType.HEART_RATE, HealthDataType.STEPS];
  final granted = await health.requestAuthorization(types, permissions: [HealthDataAccess.READ, HealthDataAccess.READ]);
  if (!granted) return [];

  final now = DateTime.now();
  final out = <DailyValue>[];
  for (var i = days - 1; i >= 0; i--) {
    final start = DateTime(now.year, now.month, now.day - i); // local midnight, safe across DST changes
    final end = DateTime(start.year, start.month, start.day + 1);
    final day = start.toIso8601String().substring(0, 10);

    final steps = await health.getTotalStepsInInterval(start, end);
    if (steps != null) out.add(DailyValue('steps', day, steps.toDouble()));

    final samples = await health.getHealthDataFromTypes(types: [HealthDataType.HEART_RATE], startTime: start, endTime: end);
    final bpm = [for (final p in samples) if (p.value is NumericHealthValue) (p.value as NumericHealthValue).numericValue.toDouble()];
    if (bpm.isNotEmpty) {
      out.add(DailyValue('heart_rate', day, bpm.reduce((a, b) => a + b) / bpm.length,
          min: bpm.reduce(math.min), max: bpm.reduce(math.max)));
    }
  }
  return out; // POST these to your backend, which writes them to the FHIR record
}

getTotalStepsInInterval はHealth Connectに集計された合計値を要求します。これは、ユーザーがHealth Connectで設定したデータソースの優先度に従って、重複するソース(電話と時計が同じ歩行をカウントしている場合など)を既に解決しています。生のステップレコードを自分で合計すると二重カウントになります。

Anpheros Dailyでの出荷に関する注記:

Flutterの値をFHIR Observationに変換する

値をバックエンドに送信し、人物、メトリック、および日付ごとに1つのObservationを安定した識別子とともに作成します。同じ日が再度送信された場合は、それを更新します。完全なマッピングテーブル(Health Connectレコード → LOINC → UCUM)、検証済みのFHIR例、およびプラットフォームに対して実行されるTypeScriptのupsertについては、Wearable data in FHIRを参照してください。

Google Play での公開

Health Connect を読み取るアプリは、Play Console で Health Connect の権限宣言を完了し、すべてのデータ型について正当な理由を説明し、それに一致するプライバシーポリシーを提示する必要があります。アプリが目に見えて使用しないデータ型の要求は拒否されます。審査のために計画を立ててください。各データ型を使用する画面の横にリストアップしてください。

Wear OS

Wear OS ウォッチ上のアプリは、Health Services を介してライブセンサーデータ(例:ワークアウト中の心拍数)を読み取ることができます。ウォッチ自身のヘルスアプリが記録したデータは、ベンダーの電話アプリを通じてスマートフォンの Health Connect に到達します。医療記録の場合、通常はスマートフォンの Health Connect を読み取るだけで十分です。ウォッチアプリはライブ機能用です。

Anpheros の位置づけ

Anpheros Platform は、結果として、個人の FHIR R4 レコードを保存します。各ウェアラブル値は、同意、来歴、およびアクセスログの背後にある Observation としてデバイスデータとしてマークされます。Anpheros Platform は Health Connect 自体を読み取るのではなく、Android アプリが読み取ります。Anpheros 独自のアプリである Anpheros Daily は、Android 上の Health Connect を読み取り(Plus および Max プラン)、日次サマリーをレコードに書き込みます。

よくある質問

Health Connect にはクラウド API はありますか?

いいえ。Health Connect はデータを電話機に保存し、その電話機上のアプリのみが、ユーザーの許可を得てデータを読み取ることができます。データをサーバーに送信するには、アプリがデータを読み取り、送信する必要があります。

Health Connect REST API または Web API はありますか?

いいえ。Health Connect は、REST または Web エンドポイントを持たない、オンデバイスの Android API です。サーバーは、電話機上のアプリがデータを読み取って送信した場合にのみデータを受信します。例えば、FHIR Observations を Anpheros に送信する場合などです。

Python または React Native から Health Connect API を使用できますか?

Python からはできません。Health Connect はサーバーではなく電話機上で実行されるためです。React Native または Flutter からは、アプリ内の Android API を呼び出すコミュニティまたは公式プラグインを通じて、はい、可能です。

なぜ私のアプリは Health Connect のデータしか 30 日分しか読み取れないのですか?

READ_HEALTH_DATA_HISTORY パーミッションがない場合、Health Connect は、最初のパーミッションが付与される前の 30 日間に読み取りを制限します。古いデータが必要な場合は、履歴パーミッションをリクエストしてください。

Garmin は Health Connect と同期しますか?

はい。Google は 2025 年 8 月に、Garmin Connect が Android 14 以降で Health Connect をサポートし、心拍数やカロリーなどのアクティビティおよびウェルネスデータに対応すると発表しました。Body Battery などの Garmin 独自のスコアは共有されません。

Fitbit Web API を使用せずに Fitbit データを読み取れますか?

Android では可能です。ユーザーが Fitbit アプリで Health Connect を有効にすると、Fitbit データは Health Connect で利用可能になり、ユーザーが許可したアプリが読み取れるようになります。

Health Connect の歩数カウントがベンダーアプリと異なるのはなぜですか?

ベンダーアプリが最新のデータをまだエクスポートしていない、一部のタイプのみをエクスポートしている、または Health Connect が同じ期間に対して別のソースを優先している可能性があります。Health Connect の設定で、データソースとその優先順位を確認してください。

関連情報

Try it free in the sandbox · first FHIR call in 5 minutesFree · 30 synthetic patients · no card

Product updates by email

New features, guides and the end of the beta. One email a month at most.

Send me occasional Anpheros Platform updates by email (new features, API changes, guides). I'll confirm by email and can unsubscribe in one click from any email. Privacy