# Televisit

Televisits enable providers to initiate video calls with patients. They can be created using a script. For a more detailed explanation, please see Object Room.

## Overview

Create televisit

```javascript
return org.objects.objects
  .insertOne({
    name: 'room',
    label: 'My Televisit Room',

    // apply access control lists (optional)
    acl: [
      'account.public.read',
      'account.anonymous.read',
      'role.developer.read',
      'account.[ACL ID].read'
    ],

    // apply custom properties (optional)
    properties: [{
      name: 'c_number',
      label: 'Room Number',
      type: 'Number',
      indexed: true
    }]
  })
  .execute()
```

Use the following to update the televisit ACL.

```javascript
const _id = '[Room ID]'
const _acl_id = '[ACL ID]'
return org.objects.rooms
  .updateOne({ _id }, {

    // Adds an additional account to the ACL
    $push: {
      acl: [
        `account.${ _acl_id }.read`
      ]
    }
  })
  .execute()
```

The potential televisit states are `new`, `open`, or `closed`. Immediately following the command to create a televisit, its state is `new`. Once the televisit has completed setup, it's state is set to `open`. A televisit is considered concluded when its state is set to `closed`. Once `closed`, a televisit cannot be reopend. If no one joins the televisit for 5 minutes after being open, its state is automatically set to `closed`.

To view the state of a televisit, please run the following.

```javascript
const _id = '[Room ID]'
return org.objects.room.find({ _id }).next().state
```

To end a televisit, set its state to closed.

```javascript
const _id = '[Room ID]'
return org.objects.room
  .updateOne({ _id }, {
    $set: {
      state: 'closed'
    }
  })
  .execute()
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.medable.com/cortex-api/scripting/televisit.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
