# Configuring the Medical-CRM Connection

Organizations using both a Medical Vault and Vault CRM can utilize the Spark messaging framework to create a standard Vault to Vault connection. This connection transfers Medical Inquiry and _Case_ data across Vaults. See <a href="/en/gr/879896/">About the Medical-CRM Connection</a>
 for detailed information about how the connection works.

<div class="note-border alert-info">
  <div class="alert alert-info" role="alert">
    <div><i class="far fa-info-circle"></i></div>
    <div class="alert-text">
      <p><strong>Note</strong>: The Medical-CRM Connection is only available for organizations with both a Medical Vault and Vault CRM.</p>
    </div>
  </div>
</div>



## Medical-CRM Connection Components

The following components support the standard Vault to Vault Medical-CRM connection.

### Connections

The _Medical-CRM Connection_ (`medical_crm__v`) record is available from **Admin > Connections** in your Medical Vault. You must <a href="/en/gr/53358/#Establish_Vault_to_Vault">establish the Vault to Vault connection</a>
 before using it.

### Integration & Integration Points

The _Integration_ and _Integration Point_ objects enable Vault to manage the message queues and define what documents and data the connection maps from one Vault to another. These records are used by Vault to manage the connection and track any connection errors.

The _Medical-CRM Connection_ record includes the following default _Integration_ records with standard _Integration Point_ and _Integration Rule_ records in your Medical Vault:

* _Medical Inquiry Details Integration_
  * _Medical Inquiry Details Outbound Integration Point_
  * _Account Inbound Integration Point_
    * _Account Integration Rule_
    * _Only Accounts with Inquiries Integration Rule_
    * _Do Not Pull from Accounts Integration Rule_
  * _Medical Inquiry Details Inbound Integration Point_
    * _Medical Inquiries Integration Rule_
  * _CRM Lookup Integration Point_
* _Country Integration_
  * _Country Inbound Integration Point_
* _CLM Integration_
  * _CLM Outbound Integration Point_
* _CRM Metadata Sync Product Content Integration_
  * _CRM Content Group Inbound Integration Point_
  * _CRM Detail Group Inbound Integration Point_
  * _CRM Product Inbound Integration Point_
  * _CRM Product Group Inbound Integration Point_
* _CRM Metadata Sync Survey Integration_
  * _CRM Survey Configuration Inbound Integration Point_
* _CRM Metadata Sync Content Type Integration_
  * _CRM Content Type Inbound Integration Point_
* _CRM Metadata Sync Directory Integration_
  * _CRM Directory Inbound Integration Point_
* _CRM Metadata Sync Event Management Integration_
  * _CRM Event Configuration Inbound Integration Point_
  * _CRM Event Topic Inbound Integration Point_

### Integration Rules

To support the Medical-CRM Connection, it may be necessary to transform data from the source Vault's data model to fit within the target Vault's data model. You can use the <a href="/en/gr/62154/">_Integration Rules_</a>
 to incorporate configurable rules for mapping object and document fields between the two Vaults. 

You must activate the _Medical Inquiry Details Integration_ in your Medical Vault.

### Data Usage Agreements

The connection supports different data usage agreements with regards to managing Vault CRM _Account_ data in Medical. This is managed via the new _Pull Accounts Rule_ field on the _Country_ object. While configuring the connection, please contact <a class="external-link " href="https://support.veeva.com/hc/en-us" target="_blank" rel="noopener">Veeva Support<i class="fa fa-external-link" aria-hidden="true"></i></a> to populate this field for your relevant data usage agreement.

### Queues

This feature includes two (2) standard <a href="/en/gr/53147/">message processing queues</a>
. You can access and manage these queues from **Admin > Connections > Spark Queues**.

In your Medical Vault, you have:

  * _Medical to CRM_ outbound queue (`medical_crm_outbound_queue__v`)
  * _Medical-CRM_ inbound queue (`medical_crm_inbound_queue__v`)

In your CRM Vault, you have:

  * _CRM to Medical_ outbound queue (`crm_to_medical_outbound_queue__v`)
  * _Medical to CRM_ inbound queue (`medical_to_crm_inbound__v`)

### Query Object Rules

The connection supports <a href="/en/gr/62154/#about-query-object-rules">query object rules</a>
. Query object rules provide an additional layer of specificity to your field rules. Learn more about <a href="/en/gr/62154/#create-query-rule">creating query object rules</a>
.

### User Exception Objects

Vault includes the _User Exception Message_ object and its child object, _User Exception Item_, to help you track and resolve any errors that occur with your Medical-CRM Connection. If either end of your integration can't process an incoming message, Vault creates a _User Exception Message_ record to capture the failure.

Vault also creates individual _User Exception Item_ records for each item that failed on the related _Integration Point_ record in one of your Vaults. Vault typically creates _User Exception Messages_ in the source Vault when there are issues with the configuration or connection itself. _User Exception Messages_ in the target Vault often contain _User Exception Items_, as the target Vault can encounter document-specific errors as well as configuration errors.

You can view and manage these messages from **Admin > Connections > User Exception Messages**. If you want specific users or groups to receive notifications when Vault creates _User Exception Message_ records, you must create a custom lifecycle for the _User Exception Message_ object and configure a notification <a href="/en/gr/59885/#entry-actions">entry action</a>
.

A _User Exception Message_ means you need to update your configuration. After you update the configuration, Vault attempts to resolve any errors the next time the connection runs. You can also select the **Retry Transfer** action on the _User Exception Message_ record to run the connection and resolve errors.

### Last Successful Run Time Field

On each _Integration_ record, the _Last Successful Run Time_ field captures the date and time that the integration last ran with no errors. Vault uses this date to query changes since the integration's last successful run.

When an integration becomes active, Vault automatically sets its _Last Successful Run Time_ to the current datetime. If you inactivate and reactivate an _Integration_ record, Vault also sets the _Last Successful Run Time_ to the current datetime.

You can also manually set the _Last Successful Run Time_ field to a prior datetime. Setting the field to a prior datetime automatically triggers the integration to schedule a job.

## Configuring Your Vaults for the Connection

### Enabling the Integrations in MedInquiry

The _Medical Inquiry Details Integration_ is inactive by default. To activate this integration:

  1. In your MedInquiry Vault, navigate to **Admin > Connections > Medical-CRM Connection**.
  2. Expand the **Integrations** section.
  3. Click **Medical Inquiry Details Integration**.
  4. Select **Active** in the _Status_ field.
  5. Click **Save**.
  6. Repeat steps 3 through 5 to activate other applicable integrations.

<div class="note-border alert-info">
  <div class="alert alert-info" role="alert">
    <div><i class="far fa-info-circle"></i></div>
    <div class="alert-text">
      <p><strong>Note</strong>: You must also add the <em>Transfer to Medical</em> action to the <em>Submitted</em> state on the <em>Inquiry</em> lifecycle, as either an entry or user action.</p>
    </div>
  </div>
</div>



### Enabling the Integrations in Vault CRM

The _Medical Inquiry Details Integration_ is inactive by default. To activate this integration:

  1. In Vault CRM, navigate to **Admin > Connections > Medical-CRM Connection**.
  2. Expand the **Integrations** section.
  3. Click **Medical Inquiry Details Integration**.
  4. Click **Edit** and expand the **System Information** section.
  5. Select **Active** in the _Status_ field.
  6. Click **Save**.
  7. Repeat steps 3 through 6 to activate other applicable integrations.

### Configuring Reference Lookups

<a href="/en/gr/58198/">Reference lookups</a>
 are a configuration component referenced by integration rules that allow you to map the value of a field on a target object or document indirectly from a value in the source Vault. When you configure the Medical-CRM connection, you need to add reference lookups for controlled fields within the integration scope. We recommend creating CSV mapping files and loading these to your Vault to create reference lookups.

### Reviewing Field Rules {#field-rules}

We recommend reviewing the field rules for each integration rule for the Medical-CRM Connection. To do so, navigate to **Admin > Connections > Integration Rules**, select an integration rule, and click **Field Rules**.

Vault pulls metadata from the _Accounts_ and _Inquiries_ based on the field rules and uses the metadata to create or update the _Case Contact Source Data_ and the _Case_/_Case Request_ records. Vault populates the _Global ID_ from the Vault CRM _Account_ into the _Link_ field on the _Case Contact Source Data_ record.

## Duplicating the Medical-CRM Connection {#duplicating}

After configuring the Medical-CRM Connection, you can duplicate the _Medical-CRM Connection_ (`medical_crm__v`) record to connect the same Medical Vault to multiple Vault CRMs.

## Related Permissions

You need a _System Admin_ security profile as well as the following permissions to set up the standard Medical-CRM connection:

| Type | Permission Label | Controls |
| --- | --- | --- |
| Security Profile | Admin: Application: Manage Connections | Ability to set up the standard Medical-CRM Connection |
| Security Profile | Object: User Exception Item, User Exception Message: Read | Ability to see _User Exception Item_ and _User Exception Message_ records if a connection failure occurs |


