AndroidアプリとWebアプリのIF設計


【最終更新日】2023-04-07

AndroidアプリとFlask Webアプリとのインターフェイス設計とデータベーステーブル定義は下記のとおりです

1.Webアプリケーションインターフェイス仕様
1-1.登録時 I/F
  • HTTPメソッド: POST
  • URLパス: /helthcare/register
  • Content-type: application/json
  • 文字コード: UTF-8
  • 登録データ形式: JSON文字列
    下記【新規登録時のJSONデータと登録先テーブル】参照
  • レスポンスデータ: JSON文字列(UTF-8)
1-2.更新時 I/F
  • HTTPメソッド: POST
  • URLパス: /helthcare/update
  • Content-type: application/json
  • 文字コード: UTF-8
  • データ形式: JSON文字列 ※更新箇所のデーブル分のみ
    下記【更新時のJSONデータ用テンプレートと更新用JSONデータ例】参照
  • レスポンスデータ: JSON文字列(UTF-8)
1-3.テータ取得 I/F
  • HTTPメソッド: GET
  • URLパス: /helthcare/getcurrentdata
  • リクエストパラメータ: emailAddress, measurementDay
  • レスポンスデータ: JSON文字列(UTF-8)
【新規登録時のJSONデータと登録先テーブル】
【更新時のJSONデータ用テンプレートと更新用JSONデータ例】
1-1.リクエスト・レスポンス例

(1)登録時

リクエストデータ(JSON)

{
  "emailAddress": "user1@examples.com",
  "measurementDay":"2023-02-13",
  "healthcareData":{
    "sleepManagement":{
      "wakeupTime":"05:30",
      "sleepScore":89,
      "sleepingTime":"06:17",
      "deepSleepingTime":"01:10"
    },
    "bloodPressure":{
      "morningMeasurementTime":"06:50",
      "morningMax":118,
      "morningMin":71,
      "morningPulseRate":66,
      "eveningMeasurementTime":"22:40",
      "eveningMax":135,
      "eveningMin":76,
      "eveningPulseRate":57
    },
    "bodyTemperature":{
      "measurementTime":null,"temperature":null
    },
    "nocturiaFactors":{
      "midnightToiletVisits":1,
      "hasCoffee":true,
      "hasTea":false,
      "hasAlcohol":false,
      "hasNutritionDrink":true,
      "hasSportsDrink":false,
      "hasDiuretic":false,
      "takeMedicine":false,
      "takeBathing":false,
      "conditionMemo":"風邪気味で風邪薬を飲んだ"
    },
    "walkingCount":{
      "counts":8518
    }
  },
  "weatherData": {
    "weatherCondition":{
      "condition":"曇りのち雪"
    }
  }
}

レスポンスOK(JSON)

{
  "data": {
    "emailAddress": "user1@examples.com", 
    "measurementDay": "2023-02-13"
  }, 
  "status": {
    "code": 0, 
    "message": "OK"
  }
}

レスポンスNG(JSON)

{
  "status": {
    "code": 400, 
    "message": "461,User is not found."
  }
}

(2)更新時

リクエストデータ(JSON)

{
  "emailAddress": "user1@examples.com",
  "measurementDay":"2023-02-13",
  "healthcareData":{
    "sleepManagement":{
      "wakeupTime":"05:30",
      "sleepScore":91,
      "sleepingTime":"06:30",
      "deepSleepingTime":"00:40"
    }
  },
  "weatherData": {
    "weatherCondition":{
      "condition":"雪"
    }
  }
}

レスポンスOK(JSON)

{
  "data": {
    "emailAddress": "user1@examples.com", 
    "measurementDay": "2023-02-13"
  }, 
  "status": {
    "code": 0, 
    "message": "OK"
  }
}

レスポンスNG(JSON)

{
  "status": {
    "code": 400, 
    "message": "461,User is not found."
  }
}

(3)データ取得時

リクエストパラメータ
/helthcare/getcurrentdata?emailAddress=user1@examples.com&measurementDay=2023-02-13

レスポンスOK(JSON)

{
  "data": {
    "emailAddress": "user1@examples.com", 
    "healthcareData": {
      "bloodPressure": {
        "eveningMax": 124, 
        "eveningMeasurementTime": "22:20", 
        "eveningMin": 72, 
        "eveningPulseRate": 59, 
        "morningMax": 112, 
        "morningMeasurementTime": "06:45", 
        "morningMin": 67, 
        "morningPulseRate": 65
      }, 
      "bodyTemperature": {
        "measurementTime": null, 
        "temperature": null
      }, 
      "nocturiaFactors": {
        "conditionMemo": null, 
        "hasAlcohol": false, 
        "hasCoffee": true, 
        "hasDiuretic": true, 
        "hasNutritionDrink": false, 
        "hasSportsDrink": false, 
        "hasTea": false, 
        "midnightToiletVisits": 4, 
        "takeBathing": false, 
        "takeMedicine": true
      }, 
      "sleepManagement": {
        "deepSleepingTime": "01:10", 
        "sleepScore": 78, 
        "sleepingTime": "06:00", 
        "wakeupTime": "05:30"
      }, 
      "walkingCount": {
        "counts": 8576
      }
    }, 
    "measurementDay": "2023-02-13", 
    "weatherData": {
      "weatherCondition": {
        "condition": "曇りのち雪"
      }
    }
  }, 
  "status": {
    "code": 0, 
    "message": "OK"
  }
}

レスポンスNG(JSON)

{
  "status": {
    "code": 404, 
    "message": "Data is not found."
  }
}
2. テーブル設計
メニューページへ
戻る
健康管理データベース登録アプリケーションのソースコードはこちら
https://github.com/pipito-yukio/personal_healthcare