# Add Lab Test Report

Use the `createLabTestReport` mutation to create a lab test report.

## Arguments

<table data-header-hidden><thead><tr><th width="252"></th><th width="127"></th><th width="113"></th><th></th></tr></thead><tbody><tr><td><strong>Argument Name</strong></td><td><strong>Type</strong></td><td><strong>Required?</strong></td><td><strong>Description</strong></td></tr><tr><td><code>testName</code></td><td>String</td><td>Yes</td><td>Lab test report name.</td></tr><tr><td><code>title</code></td><td>String</td><td>Yes</td><td>Lab test report title. Not used on the app.</td></tr><tr><td><code>labName</code></td><td>String</td><td>Yes</td><td>Laboratory or processor name.</td></tr><tr><td><code>description</code></td><td>String</td><td>No</td><td>Description of the lab test.</td></tr><tr><td><code>testDate</code></td><td>DateTime</td><td>No</td><td>Date and time when the lab test report is created.</td></tr><tr><td><code>sampleCollectionDate</code></td><td>DateTime</td><td>No</td><td>Date and time of sample collection.</td></tr><tr><td><code>isVisible</code></td><td>Boolean</td><td>Yes</td><td>True if the lab test report should be displayed to end-users.</td></tr><tr><td><code>status</code></td><td>LabTestReportStatus</td><td>No</td><td><p>CREATED</p><p>ORDERED</p><p>FULFILLED</p><p>ERROR</p><p>RETURNED_TO_LAB</p><p>RESULTS_READY</p><p>PROCESS_COMPLETE</p><p>RESULTS_DELIVERED</p></td></tr><tr><td><code>orderingPhysician</code> </td><td>String</td><td>No</td><td>Name or ID of the ordering provider.</td></tr><tr><td><code>externalId</code> </td><td>String</td><td>No</td><td>External ID</td></tr><tr><td><code>orderId</code> </td><td>String</td><td>No</td><td>Order ID</td></tr><tr><td><code>requisitionId</code> </td><td>String</td><td>No</td><td>Requisition ID</td></tr><tr><td><code>reportPDF</code></td><td>Upload</td><td>No</td><td>Lab report file</td></tr><tr><td><code>imageUrl</code></td><td>String</td><td>No</td><td>URL of an image representative of the lab test. Will be used as video thumbnail if video is available.</td></tr><tr><td><code>videoUrl</code></td><td>String</td><td>No</td><td>Video URL to show in the report.</td></tr><tr><td><code>alert</code></td><td>Boolean</td><td>No</td><td><code>True</code> if alert is active otherwise <code>False.</code></td></tr><tr><td><code>alertText</code></td><td>String</td><td>No</td><td>Text shown in the alert.</td></tr><tr><td><code>alertAction</code></td><td>AlertAction</td><td>No</td><td><ul><li>ATTEMPTED_FAILED: Unable to contact.</li><li>CONTACTED: Member Contacted and resolved.</li></ul></td></tr><tr><td><code>alertStatus</code></td><td>AlertStatus</td><td>No</td><td><ul><li>IN_REVIEW: In Review.</li><li>REVIEWED: Lab Reviewed - No Alerts.</li><li>OUT_OF_RANGE: Biomarker(s) Out of Range.</li><li>OTHER: Other.</li><li>FOLLOW_UP: Follow-up Required.</li><li>NO_FOLLOW_UP: No Follow-up Required.</li><li>COMPLETED: Lab Alert Completed.</li></ul></td></tr></tbody></table>

## Available fields

The following fields will be displayed in the response:

| **Field Name** | **Type** | **Description**                                                                                                                                                                 |
| -------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `success`      | Boolean  | **True** if the lab test report has been created successfully. Otherwise, **Flase**                                                                                             |
| `message`      | String   | Description of the result                                                                                                                                                       |
| `report`       | Object   | Object that returns the information of the [lab test report ](https://docs.suggestic.com/coaching-portal/api-references/lab-test-reports/lab-test-report-list#available-fields) |

## Examples

Because it is not possible to upload files in the GraphQL playground, the following example creates a lab test report using the Postman tool.

**Example 1**

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

```graphql
{
    "query": "mutation CreateLabTest($testName: String!, $testDate: DateTime!, $labName: String!, $title: String!, $reportPdf: Upload!) {createLabTestReport(testName: $testName testDate: $testDate labName: $labName title: $title reportPdf: $reportPdf) {success message }}",
    "variables": {
        "title":"Hormone Testing",
        "testName": "Hormone Testing",
        "testDate": "2022-02-03T10:01:01",
        "labName": "Lab Test",
        "reportPdf": null
    }
}
```

{% endtab %}
{% endtabs %}

**Example 2 with Lab Alerts**

{% tabs %}
{% tab title="Mutation" %}
{% code overflow="wrap" %}

```graphql
{
    "query": "mutation CreateLabTest($testName: String!, $testDate: DateTime!, $labName: String!, $title: String!, $reportPdf: Upload!, $alert: Boolean, $alertText: String, $alertStatus: AlertStatus, $alertStatus: AlertStatus) {createLabTestReport(testName: $testName testDate: $testDate labName: $labName title: $title reportPdf: $reportPdf alert: $alert alertText: $alertText alertStatus: $alertStatus alertAction: $alertAction) {success message }}",
    "variables": {
        "testName": "Hormone Testing",
        "testDate": "2022-02-03T10:01:01",
        "labName": "Lab Test",
        "reportPdf": null,
        "alert": true,
        "alertText":"Validation Error",
        "alertStatus":"REVIEWED",
        "alertAction":"CONTACTED"

    }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

**Example 3 with video and image**

{% tabs %}
{% tab title="Mutation" %}
{% code overflow="wrap" %}

```graphql
{
    "query": "mutation CreateLabTest($testName: String!, $testDate: DateTime!, $labName: String!, $title: String!, $reportPdf: Upload!, $status: LabTestReportStatus $videoUrl:String) {createLabTestReport( testName: $testName testDate: $testDate labName: $labName title: $title reportPdf: $reportPdf, status: $status, videoUrl: $videoUrl) {success message }}",
    "variables": {
        "testName": "Test with video",
        "testDate": "2023-04-12T14:44:19",
        "labName": "Test V",
        "reportPdf": null,
        "status": "RESULTS_READY",
        "videoUrl":"https://www.samplevideo.com/file.mp4"
        "imageUrl":"https://www.image.com/image.jpg"
    }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

**SET UP POSTMAN**

**Step 2: Add the URL server, select the POST method and add the Header**

<mark style="color:green;">`POST`</mark> `https://production.suggestic.com/graphql`

#### Headers

| Name                                            | Type                 | Description |
| ----------------------------------------------- | -------------------- | ----------- |
| Authorization<mark style="color:red;">\*</mark> | Bearer \<JSON Token> | JSON Token  |

**Step 3: Add the Body information**

Click on the `form-data` option within the Body option and add the following 3 Key values:

* **operations:** Add the mutation defined in step 1.
* **map:** Map the files to your mutation.
* **0:** Choose the file type to upload your PDF file.

<mark style="color:green;">`POST`</mark> `https:production.suggestic.com/graphql`

#### Request Body

| Name                                  | Type                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | Description         |
| ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------- |
| <mark style="color:red;">\*</mark>    | {"query": "mutation CreateLabTest($memberId: ID!, $testName: String!, $testDate: DateTime!, $labName: String!, $title: String!, $reportPdf: Upload!) {createLabTestReport(memberId:$memberId testName: $testName testDate: $testDate labName: $labName title: $title reportPdf: $reportPdf) {success message }}","variables": {"memberId": "TWVtYmVyOjVlZDk5MjMyLWNhMTMtNGE2NS05MmIyLWZjMDk4ZjgyOWUwNA==", "testName": "Tester", "testDate": "2021-09-01T10:01:01", "labName": "Lab Test", "title": "Report Test", "reportPdf": null}} | Mutation Request    |
| map<mark style="color:red;">\*</mark> | {"0":\["variables.reportPdf"]}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | Map the files       |
| 0<mark style="color:red;">\*</mark>   | lab-test-report.pdf                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | Upload the PDF File |

{% tabs %}
{% tab title="200: OK Lab Test Report was successfully created" %}

```javascript
{
    // Response
}
```

{% endtab %}

{% tab title="500: Internal Server Error Internal Server Error" %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}

<figure><img src="https://920729701-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LwqSnBDpAb6mFZYLsuB%2Fuploads%2FxjTzCnmVW0nmTHx7RJ0R%2Flabtestpostman.png?alt=media&#x26;token=d248797f-6865-4d1c-89d1-5d991759c542" alt=""><figcaption></figcaption></figure>

**Step 4: Adding the Headers**&#x20;

* **Suggestic-partner:** Partner Id
* **Authorization:** Partner token
* **sg-user:** Target `userId`

The response will be:

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

```graphql
{
 "data": {
    "createLabTestReport": {
        "success": true,
        "message": "Lab Test Report was successfully created"
    }
 }
```

{% endtab %}
{% endtabs %}

Within the TeleWellness Portal, the created lab test is displayed as follows:

<figure><img src="https://920729701-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LwqSnBDpAb6mFZYLsuB%2Fuploads%2FkHBvYVLn1qDac1n6VmUf%2Flabtest.png?alt=media&#x26;token=073dcea6-dbef-41f4-bfa4-2cf95a9ee53b" alt=""><figcaption></figcaption></figure>

\ <br>
