6.0.0 • Published 5 years ago

@datafire/twinehealth v6.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

@datafire/twinehealth

Client library for Fitbit Plus API

Installation and Usage

npm install --save @datafire/twinehealth
let twinehealth = require('@datafire/twinehealth').create({
  access_token: "",
  refresh_token: "",
  client_id: "",
  client_secret: "",
  redirect_uri: ""
});

.then(data => {
  console.log(data);
});

Description

Overview

The Fitbit Plus API is a RESTful API. The requests and responses are formated according to the JSON API specification.

In addition to this documentation, we also provide an OpenAPI "yaml" file describing the API: Fitbit Plus API Specification.

Authentication

Authentication for the Fitbit Plus API is based on the OAuth 2.0 Authorization Framework. Fitbit Plus currently supports grant types of client_credentials and refresh_token.

See POST /oauth/token for details on the request and response formats.

Building Integrations

We will provide customers with unique client credentials for each application/integration they build, allowing us to enforce appropriate access controls and monitor API usage. The client credentials will be scoped to the organization, and allow full access to all patients and related data within that organization.

These credentials are appropriate for creating an integration that does one of the following:

  • background reporting/analysis
  • synchronizing data with another system (such as an EMR)

The API credentials and oauth flows we currently support are not well suited for creating a user-facing application that allows a user (patient, coach, or admin) to login and have access to data which is appropriate to that specific user. It is possible to build such an application, but it is not possible to use Fitbit Plus as a federated identity provider. You would need to have a separate means of verifying a user's identity. We do not currently support the required password-based oauth flow to make this possible.

Paging

The Fitbit Plus API supports two different pagination strategies for GET collection endpoints.

Skip-based paging

Skip-based paging uses the query parameters page[size] and page[number] to specify the max number of resources returned and the page number. We default to skip-based paging if there are no page parameters. The response will include a links object containing links to the first, last, prev, and next pages of data.

If the contents of the collection change while you are iterating through the collection, you will see duplicate or missing documents. For example, if you are iterating through the calender_event resource via GET /pub/calendar_event?sort=start_at&page[size]=50&page[number]=1, and a new calendar_event is created that has a start_at value before the first calendar_event, when you fetch the next page at GET /pub/calendar_event?sort=start_at&page[size]=50&page[number]=2, the first entry in the second response will be a duplicate of the last entry in the first response.

Cursor-based paging

Cursor-based paging uses the query parameters page[limit] and page[after] to specify the max number of entries returned and identify where to begin the next page. Add page[limit] to the parameters to use cursor-based paging. The response will include a links object containing a link to the next page of data, if the next page exists.

Cursor-based paging is not subject to duplication if new resources are added to the collection. For example, if you are iterating through the calender_event resource via GET /pub/calendar_event?sort=start_at&page[limit]=50, and a new calendar_event is created that has a start_at value before the first calendar_event, you will not see a duplicate entry when you fetch the next page at GET /pub/calendar_event?sort=start_at&page[limit]=50&page[after]=<cursor>.

We encourage the use of cursor-based paging for performance reasons.

In either form of paging, you can determine whether any resources were missed by comparing the number of fetched resources against meta.count. Set page[size] or page[limit] to 0 to get only the count.

It is not valid to mix the two strategies.

Actions

oauthCallback

Exchange the code passed to your redirect URI for an access_token

twinehealth.oauthCallback({
  "code": ""
}, context)

Input

  • input object
    • code required string

Output

  • output object
    • access_token string
    • refresh_token string
    • token_type string
    • scope string
    • expiration string

oauthRefresh

Exchange a refresh_token for an access_token

twinehealth.oauthRefresh(null, context)

Input

This action has no parameters

Output

  • output object
    • access_token string
    • refresh_token string
    • token_type string
    • scope string
    • expiration string

createAction

Create a plan action

twinehealth.createAction({
  "body": {
    "data": {
      "type": "",
      "id": ""
    }
  }
}, context)

Input

Output

fetchAction

Get a health action from a patient's plan.

twinehealth.fetchAction({
  "id": ""
}, context)

Input

  • input object
    • id required string: Action identifier

Output

updateAction

Update a health action from a patient's plan.

twinehealth.updateAction({
  "id": "",
  "body": {
    "data": {
      "type": "",
      "id": ""
    }
  }
}, context)

Input

Output

createBundle

Create a bundle in a patient's plan

twinehealth.createBundle({
  "body": {
    "data": {
      "type": "",
      "id": ""
    }
  }
}, context)

Input

Output

fetchBundle

Get a bundle from a patient's plan.

twinehealth.fetchBundle({
  "id": ""
}, context)

Input

  • input object
    • id required string: Bundle identifier

Output

updateBundle

Updte a bundle from a patient's plan.

twinehealth.updateBundle({
  "id": "",
  "body": {
    "data": {
      "type": "",
      "id": ""
    }
  }
}, context)

Input

Output

fetchCalendarEvents

Get a list of calendar events

twinehealth.fetchCalendarEvents({}, context)

Input

  • input object
    • filterpatient string: Patient id to fetch calendar event. Note that one of the following filters must be specified: filter[patient], filter[group], filter[organization], or filter[attendees].
    • filtergroups string: Comma-separated list of group ids. Note that one of the following filters must be specified: filter[patient], filter[group], filter[organization], or filter[attendees].
    • filterorganization string: Fitbit Plus organization id. Note that one of the following filters must be specified: filter[patient], filter[group], filter[organization], or filter[attendees].
    • filterattendees string: Comma-separated list of coach or patient ids. Note that one of the following filters must be specified: filter[patient], filter[group], filter[organization], or filter[attendees].
    • filtertype string (values: plan-check-in, reminder, telephone-call, office-visit, video-call): Calendar event type
    • filtercompleted boolean: If not specified, return all calendar events. If set to true return only events marked as completed, if set to false, return only events not marked as completed yet.
    • filterstart_at string: The start (inclusive) and end (exclusive) dates are ISO date and time strings separated by ... Example for events starting in November 2017 (America/New_York): filter[start_at]=2017-11-01T00:00:00-04:00..2017-12-01T00:00:00-05:00
    • filterend_at string: The start (inclusive) and end (exclusive) dates are ISO date and time strings separated by ... Example for events ending in November 2017 (America/New_York): filter[end_at]=2017-11-01T00:00:00-04:00..2017-12-01T00:00:00-05:00
    • filtercompleted_at string: The start (inclusive) and end (exclusive) dates are ISO date and time strings separated by ... Example for events completed in November 2017 (America/New_York): filter[completed_at]=2017-11-01T00:00:00-04:00..2017-12-01T00:00:00-05:00
    • filtercreated_at string: The start (inclusive) and end (exclusive) dates are ISO date and time strings separated by ... Example for events created in November 2017 (America/New_York): filter[created_at]=2017-11-01T00:00:00-04:00..2017-12-01T00:00:00-05:00
    • filterupdated_at string: The start (inclusive) and end (exclusive) dates are ISO date and time strings separated by ... Example for events updated in November 2017 (America/New_York): filter[updated_at]=2017-11-01T00:00:00-04:00..2017-12-01T00:00:00-05:00
    • pagenumber integer: Page number
    • pagesize integer: Page size
    • pagelimit integer: Page limit
    • pagecursor string: Page cursor
    • include string (values: owner): List of related resources to include in the response

Output

createCalendarEvent

Create a calendar event for a patient. Attribute all_day must be set to true and end_at cannot be set for plan-check-in event type.

twinehealth.createCalendarEvent({
  "body": {
    "data": {
      "type": "",
      "attributes": null,
      "relationships": {}
    }
  }
}, context)

Input

Output

deleteCalendarEvent

Delete a calendar event by id

twinehealth.deleteCalendarEvent({
  "id": ""
}, context)

Input

  • input object
    • id required string: Calendar event identifier

Output

Output schema unknown

fetchCalendarEvent

Get a calendar event by id

twinehealth.fetchCalendarEvent({
  "id": ""
}, context)

Input

  • input object
    • id required string: Calendar event identifier

Output

updateCalendarEvent

Update a calendar event for a patient. Attribute all_day must be true and end_at cannot be specified for plan-check-in event type. To mark a calendar event as 'completed', set completed_at and completed_by to desired values. To mark a completed calendar event as 'not completed', set completed_at and completed_by to null. Attendees can be added or removed, but response status cannot be updated. Use the calendar event response api for response status updates instead.

twinehealth.updateCalendarEvent({
  "id": "",
  "body": {}
}, context)

Input

Output

createCalendarEventResponse

Create a calendar event response for an attendee of a calendar event, the attendee can be a coach or patient. Calendar event responses cannot be fetched, updated nor deleted. Use calendar event api to fetch the response status for attendees.

twinehealth.createCalendarEventResponse({
  "body": {
    "data": {
      "type": "",
      "attributes": null,
      "relationships": {}
    }
  }
}, context)

Input

Output

fetchCoaches

Get a list of coaches matching the specified filters.

twinehealth.fetchCoaches({}, context)

Input

  • input object
    • filtergroups string: Comma-separated list of group ids. Note that one of the following filters must be specified: filter[groups], filter[organization].
    • filterorganization string: Fitbit Plus organization id. Note that one of the following filters must be specified: filter[groups], filter[organization].

Output

fetchCoach

Get a coach record by id.

twinehealth.fetchCoach({
  "id": ""
}, context)

Input

  • input object
    • id required string: Coach identifier

Output

fetchEmailHistories

Get a list of email histories

twinehealth.fetchEmailHistories({}, context)

Input

  • input object
    • filterreceiver string: Fitbit Plus user id of email recipient. Required if filtersender is not defined.
    • filtersender string: Fitbit Plus user id of email sender. Required if filterreceiver is not defined.
    • filteremailType string: Type of email
    • sort string (values: send_time, -send_time): valid sorts:

Output

fetchEmailHistory

Get an email history by id

twinehealth.fetchEmailHistory({
  "id": ""
}, context)

Input

  • input object
    • id required string: Email history identifier

Output

fetchGroups

Get a list of groups matching the specified filters.

twinehealth.fetchGroups({
  "filter[organization]": ""
}, context)

Input

  • input object
    • filterorganization required string: Organization identifier
    • filtername string: Group name

Output

createGroup

Create a group record.

twinehealth.createGroup({
  "body": {
    "data": {
      "id": "",
      "type": "",
      "attributes": {
        "name": ""
      }
    }
  }
}, context)

Input

Output

fetchGroup

Get a group record by id.

twinehealth.fetchGroup({
  "id": ""
}, context)

Input

  • input object
    • id required string: Group identifier

Output

fetchHealthProfiles

Get a list of health profiles

twinehealth.fetchHealthProfiles({}, context)

Input

  • input object
    • filterpatient string: Patient id to fetch health profile. Note that one of the following filters must be specified: filter[patient], filter[group], or filter[organization].
    • filtergroups string: Comma-separated list of group ids. Note that one of the following filters must be specified: filter[patient], filter[group], or filter[organization].
    • filterorganization string: Fitbit Plus organization id. Note that one of the following filters must be specified: filter[patient], filter[group], or filter[organization].
    • pagenumber integer: Page number
    • pagesize integer: Page size
    • pagelimit integer: Page limit
    • pagecursor string: Page cursor
    • include string (values: patient, questions): List of related resources to include in the response

Output

fetchHealthProfile

Get a health profile by id

twinehealth.fetchHealthProfile({
  "id": ""
}, context)

Input

  • input object
    • id required string: Health profile identifier
    • include string (values: patient, questions): List of related resources to include in the response

Output

fetchHealthProfileAnswers

Get a list of health profile answers

twinehealth.fetchHealthProfileAnswers({}, context)

Input

  • input object
    • filterpatient string: Patient id to fetch healt profile answers. Note that one of the following filters must be specified: filter[patient], filter[group], or filter[organization].
    • filtergroups string: Comma-separated list of group ids. Note that one of the following filters must be specified: filter[patient], filter[group], or filter[organization].
    • filterorganization string: Fitbit Plus organization id. Note that one of the following filters must be specified: filter[patient], filter[group], or filter[organization].
    • pagenumber integer: Page number
    • pagesize integer: Page size
    • pagelimit integer: Page limit
    • pagecursor string: Page cursor
    • include string (values: patient): List of related resources to include in the response

Output

fetchHealthProfileAnswer

Get a health profile answer by id

twinehealth.fetchHealthProfileAnswer({
  "id": ""
}, context)

Input

  • input object
    • id required string: Health profile answer identifier
    • include string (values: patient): List of related resources to include in the response

Output

fetchHealthProfileQuestions

Get a list of health profile questions

twinehealth.fetchHealthProfileQuestions({}, context)

Input

  • input object
    • filterpatient string: Patient id to fetch healt profile questions. Note that one of the following filters must be specified: filter[patient], filter[group], or filter[organization].
    • filtergroups string: Comma-separated list of group ids. Note that one of the following filters must be specified: filter[patient], filter[group], or filter[organization].
    • filterorganization string: Fitbit Plus organization id. Note that one of the following filters must be specified: filter[patient], filter[group], or filter[organization].
    • include string (values: question_definition, answer): List of related resources to include in the response

Output

fetchHealthProfileQuestion

Get a health profile by id

twinehealth.fetchHealthProfileQuestion({
  "id": ""
}, context)

Input

  • input object
    • id required string: Health profile question identifier
    • include string (values: question_definition, answer): List of related resources to include in the response

Output

fetchHealthQuestionDefinitions

Get a list of all health question definitions

twinehealth.fetchHealthQuestionDefinitions(null, context)

Input

This action has no parameters

Output

fetchHealthQuestionDefinition

Get a health question definition by id

twinehealth.fetchHealthQuestionDefinition({
  "id": ""
}, context)

Input

  • input object
    • id required string: Health question definition identifier

Output

createToken

Create an OAuth 2.0 Bearer token. A valid bearer token is required for all other API requests.

Be sure to set the header Content-Type: "application/vnd.api+json". Otherwise, you will get an error 403 Forbidden. Using Content-Type: "application/json" is permitted (to support older oauth clients) but when using application/json the body should have a body in the following format instead of nesting under data.attributes:

{
  "grant_type": "client_credentials",
  "client_id": "95c78ab2-167f-40b8-8bec-8398d4b87454",
  "client_secret": "35d18dc9-a3dd-4948-b787-063a490b9354"
}
twinehealth.createToken({
  "body": {
    "data": {
      "attributes": {
        "client_id": "",
        "grant_type": ""
      }
    }
  }
}, context)

Input

  • input object
    • include string (values: groups, organization): List of related resources to include in the response
    • body required CreateTokenRequest

Output

fetchTokenGroups

Get the list of groups a token can be used to access.

twinehealth.fetchTokenGroups({
  "id": ""
}, context)

Input

  • input object
    • id required string: Token identifier

Output

fetchTokenOrganization

Get the organization a token can be used to access.

twinehealth.fetchTokenOrganization({
  "id": ""
}, context)

Input

  • input object
    • id required string: Token identifier

Output

fetchOrganization

Get an organization record by id.

twinehealth.fetchOrganization({
  "id": ""
}, context)

Input

  • input object
    • id required string: Organization identifier

Output

fetchPatients

Get a list of patients.

twinehealth.fetchPatients({}, context)

Input

  • input object
    • filtergroups string: Comma-separated list of group ids. Note that either filter[group] or filter[organization] must be specified.
    • filterorganization string: Fitbit Plus organization id. Note that either filter[group] or filter[organization] must be specified.
    • filteridentifier string: Identifier system (example: "MyEHR") - requires a "filteridentifier" parameter
    • filteridentifier string: Identifier value (example: "12345") - requires a "filteridentifier" parameter
    • filterarchived boolean: If not specified, return all patients. If set to 'true' return only archived patients, if set to 'false', return only patients who are not archived.
    • filtercreated_at string: The start (inclusive) and end (exclusive) dates are ISO date and time strings separated by ... Example for patients created in November 2017 (America/New_York): filter[created_at]=2017-11-01T00:00:00-04:00..2017-12-01T00:00:00-05:00
    • filterupdated_at string: The start (inclusive) and end (exclusive) dates are ISO date and time strings separated by ... Example for patients updated in November 2017 (America/New_York): filter[updated_at]=2017-11-01T00:00:00-04:00..2017-12-01T00:00:00-05:00
    • pagenumber integer: Page number
    • pagesize integer: Page size
    • pagelimit integer: Page limit
    • pagecursor string: Page cursor

Output

createPatient

Create a patient record.

Example for creating a patient with a group specified using meta.query instead of id:

{
  "data": {
    "type": "patient",
    "attributes": {
      "first_name": "Andrew",
      "last_name": "Smith"
    },
    "relationships": {
      "groups": {
        "data": [
          {
            "type": "group",
            "meta": {
              "query": {
                "organization": "58c88de7c93eb96357a87033",
                "name": "Patients Lead"
              }
            }
          }
        ]
      }
    }
  }
}
twinehealth.createPatient({
  "body": {
    "data": {
      "type": "",
      "attributes": {}
    }
  }
}, context)

Input

Output

upsertPatient

Create a new patient or update an existing patient

twinehealth.upsertPatient({
  "body": {
    "meta": {
      "query": {
        "identifier": {},
        "groups": []
      }
    },
    "data": {
      "type": "",
      "attributes": {}
    }
  }
}, context)

Input

Output

fetchPatient

Gets a patient record by id.

twinehealth.fetchPatient({
  "id": ""
}, context)

Input

  • input object
    • id required string: Patient identifier

Output

updatePatient

Update a patient record.

twinehealth.updatePatient({
  "id": "",
  "body": {
    "data": {
      "type": "",
      "attributes": {}
    }
  }
}, context)

Input

Output

fetchPatientCoaches

Get the list of coaches for a patient.

twinehealth.fetchPatientCoaches({
  "id": ""
}, context)

Input

  • input object
    • id required string: Patient identifier

Output

fetchPatientGroups

Get the list of groups for a patient.

twinehealth.fetchPatientGroups({
  "id": ""
}, context)

Input

  • input object
    • id required string: Patient identifier

Output

fetchPatientHealthMetrics

Get a list of patient health metrics.

twinehealth.fetchPatientHealthMetrics({}, context)

Input

  • input object
    • filterpatient string: Filter the patient health metrics for a specified patient. Note that one of the following filters must be specified: filter[patient], filter[groups], filter[organization].
    • filtergroups string: Comma-separated list of group ids. Note that one of the following filters must be specified: filter[patient], filter[groups], filter[organization].
    • filterorganization string: Fitbit Plus organization id. Note that one of the following filters must be specified: filter[patient], filter[groups], filter[organization].
    • pagenumber integer: Page number
    • pagesize integer: Page size
    • pagelimit integer: Page limit
    • pagecursor string: Page cursor

Output

createPatientHealthMetric

Create one or more patient health metrics.

Example for creating a patient health result with a patient specified using meta.query instead of id:

  {
    "data": {
      "type": "patient_health_metric",
       "attributes": {
         "code": {
           "system": "LOINC",
           "value": "13457-7"
         },
         "type": "ldl_cholesterol",
         "occurred_at": "2017-03-14T11:00:57.000Z",
         "value": 121,
         "unit": "mg/dl"
      },
      "relationships": {
        "patient": {
          "data": {
            "type": "patient",
            "meta": {
              "query": {
                "identifier": {
                  "system": "medical-record-number",
                  "value": "121212"
                },
                "organization": "58c4554710123c5c40dbab81"
              }
            }
          }
        }
      }
    }
  }
twinehealth.createPatientHealthMetric({
  "body": {
    "data": {
      "type": "",
      "id": ""
    }
  }
}, context)

Input

Output

fetchPatientHealthMetric

Get the plan summary for a patient.

twinehealth.fetchPatientHealthMetric({
  "id": ""
}, context)

Input

  • input object
    • id required string: Patient health metric identifier

Output

fetchPatientPlanSummaries

Get a list of patient plan summaries

twinehealth.fetchPatientPlanSummaries({}, context)

Input

  • input object
    • filterpatient string: Patient id to fetch plan summary for. Note that one of the following filters must be specified: filter[patient], filter[groups], filter[organization].
    • filtergroups string: Comma-separated list of group ids. Note that one of the following filters must be specified: filter[patient], filter[groups], filter[organization].
    • filterorganization string: Fitbit Plus organization id. Note that one of the following filters must be specified: filter[patient], filter[groups], filter[organization].
    • include string (values: actions, bundles, patient, current_results): List of related resources to include in the response

Output

fetchPatientPlanSummary

Get the plan summary for a patient.

twinehealth.fetchPatientPlanSummary({
  "id": ""
}, context)

Input

  • input object
    • id required string: Plan summary identifier
    • include string (values: actions, bundles, patient, current_results): List of related resources to include in the response

Output

updatePatientPlanSummary

Update a plan summary record for a patient.

twinehealth.updatePatientPlanSummary({
  "id": "",
  "body": {
    "data": {
      "id": "",
      "type": ""
    }
  }
}, context)

Input

Output

fetchPatientHealthResults

Get a list of patient health results.

twinehealth.fetchPatientHealthResults({
  "filter[patient]": ""
}, context)

Input

  • input object
    • filterpatient required string: Filter the patient health results for a specified patient
    • filteractions string: A comma-separated list of action identifiers
    • filterstart_at string: Filter results that occurred after the passed ISO date and time string
    • filterend_at string: Filter results that occurred before the passed ISO date and time string
    • filterthreads string: A comma-separated list of thread identifiers
    • filtercreated_at string: The start (inclusive) and end (exclusive) dates are ISO date and time strings separated by ... Example for results created in November 2017 (America/New_York): filter[created_at]=2017-11-01T00:00:00-04:00..2017-12-01T00:00:00-05:00
    • filterupdated_at string: The start (inclusive) and end (exclusive) dates are ISO date and time strings separated by ... Example for results updated in November 2017 (America/New_York): filter[updated_at]=2017-11-01T00:00:00-04:00..2017-12-01T00:00:00-05:00
    • pagenumber integer: Page number
    • pagesize integer: Page size
    • pagelimit integer: Page limit
    • pageafter string: Page cursor

Output

fetchPatientHealthResult

Get patient health result by id.

twinehealth.fetchPatientHealthResult({
  "id": ""
}, context)

Input

  • input object
    • id required string: Patient health result identifier

Output

fetchRewards

Get a list of rewards matching the specified filters.

twinehealth.fetchRewards({}, context)

Input

  • input object
    • filterpatient string: Patient identifier. Note that one of the following filters must be specified: filter[patient], filter[groups], filter[organization].
    • filterreward_program_activation string: Reward program activation identifier
    • filterthread string: Thread identifier
    • filtergroups string: Comma-separated list of group ids. Note that one of the following filters must be specified: filter[patient], filter[groups], filter[organization].
    • filterorganization string: Fitbit Plus organization id. Note that one of the following filters must be specified: filter[patient], filter[groups], filter[organization].

Output

createReward

Create a reward for a patient.

twinehealth.createReward({
  "body": {
    "data": {
      "type": ""
    }
  }
}, context)

Input

Output

fetchReward

Get a reward record by id.

twinehealth.fetchReward({
  "id": ""
}, context)

Input

  • input object
    • id required string: Reward identifier

Output

fetchRewardEarnings

Get a list of reward earnings matching the specified filters.

twinehealth.fetchRewardEarnings({
  "filter[groups]": "",
  "filter[patient]": ""
}, context)

Input

  • input object
    • filtergroups required string: Group identifiers
    • filterpatient required string: Patient identifier
    • filterready_for_fulfillment boolean: If true, only returns those reward earnings for which ready_for_fulfillment is true and fulfilled_at is null. If false, only returns those reward earnings for which ready_for_fulfillment is false and fulfilled_at is null.

Output

createRewardEarning

Create a reward earning for a reward. There can only be one earning for a reward. It is possilble to create multiple reward earnings simultaneously by providing and array of reward earnings in the data property.

twinehealth.createRewardEarning({
  "body": {
    "data": {
      "type": ""
    }
  }
}, context)

Input

Output

fetchRewardEarning

Get a reward earning record by id.

twinehealth.fetchRewardEarning({
  "id": ""
}, context)

Input

  • input object
    • id required string: Reward earning identifier

Output

fetchRewardEarningFulfillments

Get a list of reward earning fulfillments matching the specified filters.

twinehealth.fetchRewardEarningFulfillments({
  "filter[patient]": ""
}, context)

Input

  • input object
    • filterpatient required string: Patient identifier

Output

createRewardEarningFulfillment

Create a reward earning fulfillment for a reward earning. There can only be one fulfillment for each earning.

twinehealth.createRewardEarningFulfillment({
  "body": {
    "data": {
      "type": ""
    }
  }
}, context)

Input

Output

fetchRewardEarningFulfillment

Get a reward earning fulfillment record by id.

twinehealth.fetchRewardEarningFulfillment({
  "id": ""
}, context)

Input

  • input object
    • id required string: Reward earning fulfillment identifier

Output

fetchRewardPrograms

Get a list of reward programs matching the specified filters.

twinehealth.fetchRewardPrograms({}, context)

Input

  • input object
    • filtergroups string: Comma-separated list of group identifiers. Note that one of the following filters must be specified: filter[groups], filter[organization].
    • filterorganization string: Fitbit Plus organization id. Note that one of the following filters must be specified: filter[groups], filter[organization].

Output

createRewardProgram

Create a reward program for a group.

twinehealth.createRewardProgram({
  "body": {
    "data": {
      "type": ""
    }
  }
}, context)

Input

Output

fetchRewardProgram

Get a reward program record by id.

twinehealth.fetchRewardProgram({
  "id": ""
}, context)

Input

  • input object
    • id required string: Reward program identifier

Output

fetchRewardProgramGroup

Get the group related to a reward program.

twinehealth.fetchRewardProgramGroup({
  "id": ""
}, context)

Input

  • input object
    • id required string: Reward program identifier

Output

fetchRewardProgramActivations

Get a list of reward program activations matching the specified filters.

twinehealth.fetchRewardProgramActivations({}, context)

Input

  • input object
    • filterpatient string: Patient identifier. Note that one of the following filters must be specified: filter[patient], filter[groups], filter[organization].
    • filtergroups string: Comma-separated list of group ids. Note that one of the following filters must be specified: filter[patient], filter[groups], filter[organization].
    • filterorganization string: Fitbit Plus organization id. Note that one of the following filters must be specified: filter[patient], filter[groups], filter[organization].

Output

createRewardProgramActivation

Create a reward program activation for a patient. There can only be one activation for a patient for a given reward program.

twinehealth.createRewardProgramActivation({
  "body": {
    "data": {
      "type": ""
    }
  }
}, context)

Input

Output

fetchRewardProgramActivation

Get a reward program activationrecord by id.

twinehealth.fetchRewardProgramActivation({
  "id": ""
}, context)

Input

  • input object
    • id required string: Reward program activation identifier

Output

Definitions

ActionMetric

  • ActionMetric object
    • goal object
    • metric_type string
    • unit string
    • validations object
      • maximum object
        • unit string
        • value number
      • minimum object
        • unit string
        • value number

ActionResource

  • ActionResource object
    • attributes object
      • _thread string
      • adherence object
        • complete integer
        • due integer
        • streak object
          • count integer
          • updated_at string
      • details object
      • effective_from required string
      • effective_to string
      • frequency_goal object
        • weeks object
          • days array
            • items integer (values: 0, 1, 2, 3, 4, 5, 6): Days of week that the action is scheduled for. Zero-indexed, ex 0 represents Sunday, etc.
      • identifiers array
      • intake object
      • metric_required boolean
      • metrics array
      • static_title string
      • title required string
      • tracking boolean
      • type required string (values: other_lifestyle)
      • windows array
    • id required string
    • relationships object
      • plan object
        • data object
          • id string
          • type string
        • links object
    • type required string

ActionWindow

  • ActionWindow object
    • _id string
    • title string
    • type required string

Address

  • Address object
    • city string
    • country string
    • district string
    • lines array
      • items string
    • postal_code string
    • state string
    • text string
    • type string
    • use string

ArchiveHistory

  • ArchiveHistory object
    • archived boolean
    • modified_at string
    • notes string
    • reason string

BundleResource

  • BundleResource object
    • attributes object
      • _thread string
      • effective_from required string
      • effective_to string
      • title required string
      • type required string
    • id required string
    • relationships object
      • actions object
        • data object
          • id string
          • type string
        • links object
      • plan object
        • data object
          • id string
          • type string
        • links object
    • type required string

CalendarEventResource

  • CalendarEventResource object
    • attributes object
      • all_day boolean: True if the calendar event is an all day event, false otherwise. Must be set to true for plan-check-in event type. If it is true, then start_at and end_at must also be set to beginning of day, except plan-check-in event type does not need an end_at date. If it is false, then start_at and end_at must be on the same day.
      • attendees array: List of attendees for the calendar event
        • items object
          • response_status string (values: needsAction, declined, tentative, accepted): Status of responses from attendees
          • user string
      • completed_at string: The date and time when the calendar event is marked as completed. Only valid for plan-check-in event type.
      • completed_by object: The coach who marked the calendar event as completed. Only valid for plan-check-in event type.
      • description string
      • end_at string: The date and time when the calendar event ends. Not valid for plan-check-in event type.
      • location string
      • start_at string: The date and time when the calendar event starts
      • time_zone string: The time zone in which the dates for the calendar event are specified
      • title string: The title of the calendar event. Must not be empty or null
      • type string (values: plan-check-in, reminder, telephone-call, office-visit, video-call): The type of calendar event. Immutable after event creation.
    • id string
    • links object
      • self string
    • relationships object
      • owner object: The owner is the patient for whom the calendar event is created specificially for
        • data required object
          • id string
          • type string
        • links object
          • related string
    • type string (values: calendar_event)

CalendarEventResponseResource

  • CalendarEventResponseResource object
    • attributes object
      • attendee object: The attendee in the attendees list of the calendar event.
      • response_status string (values: accepted, declined, tentative): The response status for the attendee.
    • id string
    • links object
      • self string
    • relationships object
      • calendar_event object: The calendar_event is the calendar event for which the calendar event response is created specificially for
        • data required object
          • id string
          • type string
        • links object
          • related string
      • user object: The user is the coach or patient for whom the calendar event response is created specificially for
        • data required object
          • id string
          • type string
        • links object
          • related string
    • type string (values: calendar_event_response)

CoachResource

  • CoachResource object
    • attributes required object
      • first_name string
      • last_name string
    • id required string
    • links object
      • self required string
    • type required string (values: coach)

CollectionResponseLinks

  • CollectionResponseLinks object
    • last string
    • next string
    • prev string
    • self string

CreateActionRequest

CreateActionResponse

CreateBundleRequest

CreateBundleResponse

CreateCalendarEventRequest

  • CreateCalendarEventRequest object
    • data required object
      • attributes required
        • all_day boolean: True if the calendar event is an all day event, false otherwise. Must be set to true for plan-check-in event type. If it is true, then start_at and end_at must also be set to beginning of day, except plan-check-in event type does not need an end_at date. If it is false, then start_at and end_at must be on the same day.
        • attendees array: List of attendees for the calendar event
          • items object
            • response_status string (values: needsAction, declined, tentative, accepted): Status of responses from attendees
            • user string
        • completed_at string: The date and time when the calendar event is marked as completed. Only valid for plan-check-in event type.
        • completed_by object: The coach who marked the calendar event as completed. Only valid for plan-check-in event type.
        • description string
        • end_at string: The date and time when the calendar event ends. Not valid for plan-check-in event type.
        • location string
        • start_at string: The date and time when the calendar event starts
        • time_zone string: The time zone in which the dates for the calendar event are specified
        • title string: The title of the calendar event. Must not be empty or null
        • type string (values: plan-check-in, reminder, telephone-call, office-visit, video-call): The type of calendar event. Immutable after event creation.
      • relationships required object
      • type required CalendarEventResource/properties/type

CreateCalendarEventResponse

CreateCalendarEventResponseRequest

CreateGroupRequest

CreateGroupResponse

CreateOrUpdateErrorResponse

CreateOrUpdateMetaResponse

  • CreateOrUpdateMetaResponse object
    • ignored array
      • items string
    • req_id string

CreatePatientHealthMetricRequest

  • CreatePatientHealthMetricRequest object
    • data required PatientHealthMetricCreateResource
    • meta object
      • ignore_duplicates boolean: If true, the patient health metric will be ignored if there is an existing patient health metric for

CreatePatientHealthMetricResponse

CreatePatientRequest

  • CreatePatientRequest object
    • data required PatientCreateResource
    • meta object
      • ignore_duplicates boolean: If true, patients with any conflicting identifiers (same system and value) will be ignored.

CreatePatientResponse

CreateRewardEarningFulfillmentRequest

CreateRewardEarningFulfillmentResponse

CreateRewardEarningRequest

CreateRewardEarningResponse

CreateRewardProgramActivationRequest

CreateRewardProgramActivationResponse

CreateRewardProgramRequest

CreateRewardProgramResponse

CreateRewardRequest

CreateRewardResponse

CreateTokenRequest

  • CreateTokenRequest object
    • data required object
      • attributes required object
        • client_id required string: Contact Fitbit Plus API Support to get a client id and secret.
        • client_secret string: Contact Fitbit Plus API Support to get a client id and secret. Secret is required if grant_type is "client_credentials"
        • grant_type required string (values: refresh_token, client_credentials)
        • refresh_token string: Required if grant_type is "refresh_token"
      • type string (values: token)

CreateTokenResponse

EmailHistoryResource

  • EmailHistoryResource object
    • attributes object
      • email_address string: Address email was sent to.
      • email_type string: Type of email.
      • send_time string: Time email was sent.
      • status_times object: Status of email. Multiple statuses may be defined. The current status is the one with the most recent date.
        • bounce string: Time email was bounced.
        • click string: Time email was clicked.
        • deferred string: Time email was deferred.
        • delivered string: Time email was delivered.
        • dropped string: Time email was dropped.
        • open string: Time email was opened.
        • processed string: Time email was processed.
        • spamreport string: Time email was reported as spam.
        • unsubscribe string: Time email was unsubscribed from.
      • twine_email_id string: Unique identifier for this email.
    • id string
    • relationships object
      • receiver object
        • data object
          • id string
          • type string
      • sender object
        • data object
          • id string
          • type string
    • type required string

Error

  • Error object
    • code string (values: Forbidden, InvalidParameter, InvalidBodyParameter, ResourceNotFound, Unauthorized, InvalidCredentials, InvalidGrantType)
    • detail string
    • source object
      • parameter string
      • pointer string
    • status string
    • title string

FetchActionResponse

FetchBundleResponse

FetchCalendarEventResponse

FetchCalendarEventsResponse

FetchCoachResponse

FetchCoachesResponse

FetchEmailHistoriesResponse

FetchEmailHistoryResponse

FetchErrorResponse

FetchGroupResponse

FetchGroupsResponse

FetchHealthProfileAnswerResponse

FetchHealthProfileAnswersResponse

FetchHealthProfileQuestionResponse

FetchHealthProfileQuestionsResponse

FetchHealthProfileResponse

FetchHealthProfilesResponse

FetchHealthQuestionDefinitionResponse

FetchHealthQuestionDefinitionsResponse

FetchMetaResponse

  • FetchMetaResponse object
    • count integer
    • req_id string

FetchOrganizationResponse

FetchPatientHealthMetricResponse

FetchPatientHealthResultResponse

FetchPatientPlanSummariesResponse

FetchPatientPlanSummaryResponse

FetchPatientResponse

FetchPatientsResponse

FetchRewardEarningFulfillmentResponse

FetchRewardEarningFulfillmentsResponse

FetchRewardEarningResponse

FetchRewardEarningsResponse

FetchRewardProgramActivationResponse

FetchRewardProgramActivationsResponse

FetchRewardProgramResponse

FetchRewardProgramsResponse

FetchRewardResponse

FetchRewardsResponse

GroupResource

  • GroupResource object
    • attributes required object
      • bio string: A description of the group
      • name required string: The name of the group
    • id required string
    • links object
      • self required string
    • type required string (values: group)

HealthProfileAnswerResource

  • HealthProfileAnswerResource object
    • attributes object
      • history array: List of details of previous answers for a health profile question
        • items object: The details of a previous answer for a health profile question
          • _created_by string: The id of the patient or coach who answered the health profile question
          • answered_at string: The date when the health profile question is answered
          • value string: The value of the answer entered for the health profile question
      • latest object: The details of the latest answer for a health profile question
        • _created_by string: The id of the patient or coach who answered the health profile question
        • answered_at string: The date when the health profile question is answered
        • value string: The value of the answer entered for the health profile question
      • question_id string
    • id required string
    • links `o