Math
The Math extension provides some useful actions to perform simple mathematical operations.
The Math extension provides some useful actions to perform simple mathematical operations.
Category: Math. Adds 7 actions to a care flow.
Actions
Math adds these 7 actions to a care flow. Add one to a step, then fill in its inputs.
Assign to cohort
Deterministically assign a value to a cohort number. Given the same input and number of cohorts, the result will always be the same.
This action can be previewed in Studio before you publish.
| Input | Type | Required | Description |
|---|---|---|---|
| Input value | string | Yes | Any string value used to determine the cohort assignment (e.g. patient ID, hash, email). The same input will always produce the same cohort. |
| Number of cohorts | numeric | Yes | The total number of cohorts to distribute inputs across. Must be an integer greater than or equal to 1. |
Returns:
| Data point | Type |
|---|---|
cohortNumber | number |
Deterministically assign any string value (e.g. patient ID, email, UUID) to a cohort number between 1 and a given number of cohorts. The same input will always produce the same cohort, making this action ideal for A/B testing and patient randomization.
**Inputs:
- Input value: Any string used to determine the cohort assignment.
- Number of cohorts: The total number of cohorts to distribute inputs across (must be >= 1).
Output:
- Cohort number: An integer between 1 and the number of cohorts (inclusive).
Note**: When the number of cohorts changes, a patient's assigned cohort may change because the underlying hash modulo base changes. This action does not guarantee cohort stability across different values of the number of cohorts.
Calculate date difference
Calculate the difference between 2 dates in a unit of your choice.
This action can be previewed in Studio before you publish.
| Input | Type | Required | Description |
|---|---|---|---|
| Date left (minuend) | date | Yes | The date from which the other date (date right) is to be subtracted. |
| Date right (subtrahend) | date | Yes | The date to be subtracted from the other date (date left). |
| Duration unit | string | Yes | The unit of duration One of: seconds, minutes, hours, days, weeks, months, years. |
Returns:
| Data point | Type |
|---|---|
dateDifference | number |
Calculate the difference between two dates where "date left" is the minuend and "date right" the subtrahend.
You can choose the unit in which you would like to see the difference expressed:
- Seconds: get the number of seconds between the given dates. Fractional seconds are truncated towards zero.
- Minutes: get the signed number of full (rounded towards 0) minutes between the given dates. Fractional minutes are truncated towards zero.
- Hours: get the number of hours between the given dates. Fractional hours are truncated towards zero.
- Days: get the number of full day periods between two dates. Fractional days are truncated towards zero.
- Weeks: get the number of full weeks between two dates. Fractional weeks are truncated towards zero.
- Months: get the number of full months between the given dates. Fractional months are truncated towards zero.
- Years: get the number of full years between the given dates.
Divide
Divide two numbers
This action can be previewed in Studio before you publish.
| Input | Type | Required | Description |
|---|---|---|---|
| Dividend | numeric | Yes | — |
| Divisor | numeric | Yes | — |
Returns:
| Data point | Type |
|---|---|
quotient | number |
Divide two numbers.
Generate random number
Generate a random number between a given range.
This action can be previewed in Studio before you publish.
| Input | Type | Required | Description |
|---|---|---|---|
| Minimum number | numeric | Yes | The minimum number in the range (INCLUSIVE). Should be an integer. |
| Maximum number | numeric | Yes | The maximum end of the range (INCLUSIVE). Should be an integer. |
Returns:
| Data point | Type |
|---|---|
generatedNumber | number |
Generates a random (whole) number that falls between the ranges of two numbers [min, max].
Multiply
Multiply a series of numbers to get a final product
This action can be previewed in Studio before you publish.
| Input | Type | Required | Description |
|---|---|---|---|
| Factor | numeric | Yes | — |
| Factor | numeric | Yes | — |
| Factor | numeric | No | — |
| Factor | numeric | No | — |
| Factor | numeric | No | — |
| Factor | numeric | No | — |
| Factor | numeric | No | — |
| Factor | numeric | No | — |
| Factor | numeric | No | — |
| Factor | numeric | No | — |
| Factor | numeric | No | — |
| Factor | numeric | No | — |
| Factor | numeric | No | — |
| Factor | numeric | No | — |
| Factor | numeric | No | — |
| Factor | numeric | No | — |
| Factor | numeric | No | — |
| Factor | numeric | No | — |
| Factor | numeric | No | — |
| Factor | numeric | No | — |
Returns:
| Data point | Type |
|---|---|
product | number |
Multiply a series of numbers to get a final product.
Subtract
Calculate the difference between two numbers
This action can be previewed in Studio before you publish.
| Input | Type | Required | Description |
|---|---|---|---|
| Minuend | numeric | Yes | — |
| Subtrahend | numeric | Yes | — |
Returns:
| Data point | Type |
|---|---|
absoluteDifference | number |
difference | number |
Calculate the difference between two numbers.
Sum
Calculate the sum of two or more addends
This action can be previewed in Studio before you publish.
| Input | Type | Required | Description |
|---|---|---|---|
| Addend | numeric | Yes | — |
| Addend | numeric | Yes | — |
| Addend | numeric | No | — |
| Addend | numeric | No | — |
| Addend | numeric | No | — |
| Addend | numeric | No | — |
| Addend | numeric | No | — |
| Addend | numeric | No | — |
| Addend | numeric | No | — |
| Addend | numeric | No | — |
| Addend | numeric | No | — |
| Addend | numeric | No | — |
| Addend | numeric | No | — |
| Addend | numeric | No | — |
| Addend | numeric | No | — |
| Addend | numeric | No | — |
| Addend | numeric | No | — |
| Addend | numeric | No | — |
| Addend | numeric | No | — |
| Addend | numeric | No | — |
Returns:
| Data point | Type |
|---|---|
sum | number |
Calculate the sum of two or more addends.
Setup and notes
This extension adds custom actions to your care flow for simple mathematical operations.
Changelog
Math changelog
Where this page comes from
The settings, actions, inputs, outputs and webhooks above are generated from the
extension's own code, at @awell-health/awell-extensions v2.1.159. They match what the
platform actually does rather than a description of it.
Field-level detail also appears in Awell Studio when you configure the action. Something wrong or missing? Email support@awellhealth.com.