# User's Goals

Use the `profileMacroGoalsSettings` mutation to determine and set up a user's weight-related goals based on personal information such as *weight*, *height,* *activity level, etc.* Check [this information](#available-arguments) to know which fields are used to calculate a user's caloric daily requirement.

{% hint style="warning" %}
The information is saved and read in the **metric unit** (kilograms, grams, meters, centimeters, etc). We **DO NOT** do unit conversions.&#x20;
{% endhint %}

{% hint style="warning" %}
You are responsible for Unit Conversion. Make sure your units are correct.
{% endhint %}

## Considerations to calculate your macros

### Setup the goals

If goals are set as "**on**", those will be used. However, If they are not set or are "**off**" then for meal planning purposes, the meal plan will default to the program's pre-defined goal settings.

The following profile attributes relate to the goals' functionality and can be set directly on the user's profile.

{% hint style="info" %}
If goals are on and the [`updateMealPlanSettings`](https://docs.suggestic.com/graphql/query/mutations/user-profile/update-meal-plan-settings) mutation is used, all the information will be overwritten.
{% endhint %}

### Define your macro goals to lose weight

If the goal is to lose weight, your `targetWeight` have to be less than the `currentWeight`.

Check the following equation:

$$
targetWeight < startingWeight
$$

Then, define the rate to lose weight by choosing a weekly weight-related goal in the `weeklyWeightGoal`to add calories to the total daily expenditure.

Check [this documentation](#available-arguments) to see the valid values to define for the `weeklyWeightGoal`

Example:

You will have the following macros:

* `currentWeight`: **80kg**
* `targetWeight`: **60kg**
* `weeklyWeightGoal`: <mark style="background-color:blue;">**`GOAL_1`**</mark> *(lose 0.5 kg)*

This means that the user's goal is to lose 0.5 kg per week until the target weight is reached.

### Define your macros goals to gain weight

If the goal is to gain weight, your `targetWeight` have to be greater than the `currentWeight`.

Check the following equation:

$$
targetWeight >  startingWeight
$$

Then, define the rate to lose weight by choosing a weekly weight-related goal in the `weeklyWeightGoal`to add calories to the total daily expenditure.

Check [this documentation](#available-arguments) to see the valid values to define for the `weeklyWeightGoal`

Example:

You will have the following macros:

* `currentWeight`: **60kg**
* `targetWeight`: **80kg**
* `weeklyWeightGoal`: <mark style="background-color:blue;">**`GOAL_1`**</mark> *(gain 0.5 kg)*

This means that the user's goal is to gain 0.5 kg per week until the target weight is reached.

## Available Arguments

<table data-header-hidden><thead><tr><th width="218.86489258383682">Argument</th><th width="150">Is Required</th><th width="150">Type</th><th width="249.90140845070425">Description</th></tr></thead><tbody><tr><td><strong>Argument</strong></td><td><strong>is Required?</strong></td><td><strong>Type</strong></td><td><strong>Description</strong></td></tr><tr><td><code>activityLevel</code> </td><td>Yes</td><td>ActivityLevel</td><td><p>User's weekly activity level. <br>Valid values are </p><p>- <code>NOT_ACTIVE</code>, </p><p>- <code>EXERCISE_1</code> (1 - 2 times per week) </p><p>- <code>EXERCISE_2</code> (3+ times per week)<br><em>Use this to calculate your caloric daily requirement</em> </p></td></tr><tr><td><code>biologicalSex</code> </td><td>Yes</td><td>BiologicalSex</td><td>The biological sex of the user. Valid values are <code>MALE</code> and <code>FEMALE</code><br><em>Use this to calculate your caloric daily requirement</em> </td></tr><tr><td><code>birthdate</code> </td><td>Yes</td><td>Date</td><td>User's birthday. <br><em>Use this to calculate your caloric daily requirement</em> </td></tr><tr><td><code>goalsOn</code> </td><td>Yes</td><td>Boolean</td><td>True if the goals functionality is enabled. Requires all other parameters to be set.</td></tr><tr><td><code>height</code> </td><td>Yes</td><td>Float</td><td>The height of the user. <em>Use this to calculate your caloric daily requirement</em> . Expressed in centimeters</td></tr><tr><td><code>startingWeight</code> </td><td>Yes</td><td>Float</td><td>The user's current weight. <em>Use this to calculate your caloric daily requirement</em>. Expressed in kilograms.</td></tr><tr><td><code>targetWeight</code> </td><td>Yes</td><td>Float</td><td>The user's target weight. <em>Use this to calculate your caloric daily requirement.</em> Expressed in kilograms.</td></tr><tr><td><code>weeklyWeightGoal</code> </td><td>Yes</td><td>WeeklyWeightGoal</td><td><p>User weekly weight-related goal. Depending on the user's goals, use this to gain, lose or maintain weight.<br>Valid values are:</p><p> <code>MANTAIN:</code> maintain the weight,</p><p><code>GOAL_1:</code> lose/gain 0.5 kg, </p><p><code>GOAL_2:</code> lose/gain (1 kg), </p><p><code>GOAL_3:</code> lose/gain (1.5 kg), </p><p><code>GOAL_4:</code> lose/gain (4 kg)<br><br><em>Use this to calculate your caloric daily requirement</em> </p></td></tr></tbody></table>

## Available Fields

The following field will be part of the response.

<table data-header-hidden><thead><tr><th>Field Name</th><th width="151.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>Field Name</strong></td><td><strong>Type</strong></td><td><strong>Description</strong></td></tr><tr><td><code>success</code></td><td>Boolean</td><td><strong>True</strong> if the user weight-related goals has been set successfully. Otherwise, <strong>False</strong></td></tr></tbody></table>

The following fields are the result of the macro goals calculation:

<table data-header-hidden><thead><tr><th>Field Name</th><th width="151.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>Field Name</strong></td><td><strong>Type</strong></td><td><strong>Description</strong></td></tr><tr><td><code>dcig</code></td><td>Int</td><td>Daily Caloric Intake Goal</td></tr><tr><td><a href="../../../../helpful-resources/glossary#cd"><code>cd</code></a></td><td>Int</td><td>Caloric Difference between the daily caloric intake goal and the totaly daily energy expenditure</td></tr><tr><td><a href="../../../../helpful-resources/glossary#tdee"><code>tdee</code></a></td><td>Int</td><td>Total Daily Energy Expenditure </td></tr><tr><td><a href="../../../../helpful-resources/glossary#bmr"><code>bmr</code></a></td><td>Int</td><td>Basal Metabolic Rate calculated with the Harris–Benedict equation. </td></tr><tr><td><a href="../../../../helpful-resources/glossary#bmi"><code>bmi</code></a></td><td>Int</td><td>Body Mass Index calculated from user's weight and height values.</td></tr></tbody></table>

## Example

{% tabs %}
{% tab title="Mutation" %}

```graphql
mutation {
  profileMacroGoalsSettings(
    goalsOn: true
    biologicalSex: FEMALE
    birthdate: "1982-01-10"
    height: 158 
    startingWeight: 70
    targetWeight: 58
    weeklyWeightGoal: GOAL_4
    activityLevel: EXERCISE_2
  ) {
    success
    bmr
    bmi 
    tdee 
    cd
    dcig 
  }
}
```

{% endtab %}

{% tab title="Response" %}

```javascript
{
  "data": {
    "profileMacroGoalsSettings": {
      "success": true,
      "bmr": 1126,
      "bmi": 22,
      "tdee": 1576,
      "cd": 250,
      "dcig": 1326
    }
  }
}
```

{% endtab %}
{% endtabs %}

Execute the [`myProfile`](https://docs.suggestic.com/graphql/query/queries/my-profile) query to check these goals configured.

{% tabs %}
{% tab title="Request" %}

```graphql
{
  myProfile {
    id
    age
    birthdate
    biologicalSex
    activityLevel
    startingWeight
    customAttributes
    targetWeight
    height
    weeklyWeightGoal
    goalsOn
    programName
    language
    subscription{
      id
      createdAt
      name
    }
    restrictions {
      name
    }
    dailyCaloricIntakeGoal
		caloricDifference 
		totalDailyEnergyExpenditure
		basalMetabolicRate
		program {
		  databaseId,
		  name
      author
		}
  }
}

```

{% endtab %}

{% tab title="Response" %}

```graphql
{
  "data": {
    "myProfile": {
      "id": "05d50bb8-20cd-461f-a15f-788dbe18fdbb",
      "age": 40,
      "birthdate": "1982-01-10",
      "biologicalSex": "FEMALE",
      "activityLevel": "EXERCISE_2",
      "startingWeight": 70,
      "customAttributes": "[{\"name\": \"Carbohydrate Metabolism\", \"value\": \"Slow\", \"data_type\": \"STRING\"}, {\"name\": \"Gluten Sensitivity\", \"value\": 1, \"data_type\": \"INT\"}, {\"name\": \"Lactose Tolerance\", \"value\": 1.4, \"data_type\": \"FLOAT\"}, {\"name\": \"Fiber Need\", \"value\": true, \"data_type\": \"BOOLEAN\"}]",
      "targetWeight": 58,
      "height": 1.58,
      "weeklyWeightGoal": "GOAL_4",
      "goalsOn": true,
      "programName": "Wheat Belly 10-Day Grain Detox",
      "language": "en",
      "subscription": {
        "id": "U3Vic2NyaXB0aW9uOjY4ZjM4YTkzLWE3YTYtNGRhMy1hYTU4LTFhNTBlNTE4N2I4Mg==",
        "createdAt": "2022-01-20T23:37:10.795183+00:00",
        "name": "Suggestic Default"
      },
      "restrictions": [
        {
          "name": "Yogurt"
        },
        {
          "name": "Beef"
        },
        {
          "name": "Chicken"
        }
      ],
      "dailyCaloricIntakeGoal": 1142,
      "caloricDifference": 1000,
      "totalDailyEnergyExpenditure": 2142,
      "basalMetabolicRate": 1428,
      "program": {
        "databaseId": "01bbd541-939b-4b85-8d90-48ff0b02d0ee",
        "name": "Wheat Belly 10-Day Grain Detox",
        "author": "Dr. William Davis"
      }
    }
  }
}
```

{% endtab %}
{% endtabs %}

&#x20;

### PHP Example

```php
<?php

$token = 'TOKEN';
$user = 'USER';

$query = <<<'GQL'
mutation profileMacroGoalsSettings(
    $biologicalSex: BiologicalSex!
    $birthdate: Date!
    $height: Float!
    $startingWeight:Float!
    $targetWeight: Float!
    $weeklyWeightGoal: WeeklyWeightGoal!
    $activityLevel: ActivityLevel!
  ){
    profileMacroGoalsSettings(
      biologicalSex: $biologicalSex,
      birthdate: $birthdate,
      goalsOn: true,
      height: $height,
      startingWeight: $startingWeight,
      targetWeight: $targetWeight,
      weeklyWeightGoal: $weeklyWeightGoal,
      activityLevel: $activityLevel
    ) {
      success
      bmr
      bmi 
      tdee 
      cd
      dcig 
    }
  }
  
GQL;

$variables = array(
    'biologicalSex' => 'FEMALE',
    'birthdate' => '1983-04-09',
    'height' => 179.71,
    'startingWeight' => 83,
    'targetWeight' => 73,
    'weeklyWeightGoal' => 'GOAL_3',
    'activityLevel' => 'NOT_ACTIVE',
);

$json = json_encode(['query' => $query, 'variables' => $variables]);

$curl = curl_init();
curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://production.suggestic.com/graphql',
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_POSTFIELDS => $json,
    CURLOPT_HTTPHEADER => array(
        'Authorization: Token ' . $token,
        'sg-user: ' . $user,
        'Content-Type: application/json',
    ) ,
));

$response = curl_exec($curl);
$result = curl_close($curl);
echo $result;
```
