# Define and manage filters

A <u>**filter**</u> is a rule you define to conditionally allow or automatically stop certain asynchronous notifications from delivering to your destination(s) (i.e., notifications you receive). You should use filters to: 

- <u>Reduce noise</u>: Prevent irrelevant data from reaching your system. 
- <u>Manage workflows</u>: Only process notifications that meet specific criteria (e.g., only accept `PatientAdmin` messages for patients in the cardiology department).

There are two types of filters: 

- <u>**Send if**</u>: Conditionally allow certain notifications based on one or more defined rules. 
- <u>**Block all**</u>: Don’t allow any notifications for this subscription. 

You can apply, or <u>**link**</u>, filters to subscriptions that rely on either Redox data models or Redox FHIR. 

Filters are one of many operations that can be applied during log processing. [Learn about operations](/basics/data-exchange-with-redox/operations-for-data-processing). 

## Prerequisites

- All environment users can view filters. However, a user must be assigned to an <u>**engineer**</u> or a <u>**support**</u> role to create or edit filters. [Learn about user roles](/basics/managing-access-for-your-redox-organization/what-are-user-roles).


> **Recommendation about PHI in filters**
>
> If you choose to filter fields with PHI, users assigned to an <u>**observer**</u> role might unintentionally access confidential data. Keep in mind that access to filter contents is managed by a different permission from the one managing access to log payloads.


- _Before creating a filter_, identify the specific field path (JSON or FHIR) you want to filter on. 
- _To create a filter_, select a subscription with <u>**async traffic**</u> (an event notification that goes one way). 
- _To edit a promoted filter_, first edit the staging version of the filter, then re-promote to production.

## View filters

Follow these instructions to review all the filters in your environment at once.

1. Log in to the Redox dashboard.
2. From the side nav menu, click the **Operations** drop-down.
3. The Operations options expand. Click the **Filters** option.


![The Filters option is a sub-option under the Operations tab. ](https://images.ctfassets.net/cl3wt5ehhnlv/2KFIgea3KOcnxrO7JhWaRb/074d6bfb662c8d2db9902d4edde7c9c5/side-nav-operations-filters.png)

*Filters in the side nav*


4. All existing filters in the environment display. 

> **Editing options**
>
> You can’t edit filters on this page. However, you can click the **Edit** button to open its settings and edit within the <u>Connections</u> page.
>
> If you’re viewing a promoted asset, though, you first have to edit in staging, then re-promote to production.

## View filtered logs

On the <u>Logs</u> page of the dashboard, any filtered logs have the <u>Filtered</u> icon.

![The filtered icon appears at the bottom right of a log entry.](https://images.ctfassets.net/cl3wt5ehhnlv/7nU2Uk07PlSEtYXG2bvPYT/04609d13474ad9b487c76e9fe40270a3/logs-filtered.png)

*Filtered status*

Selecting the log opens the processing stages, which have a <u>Filtered</u> label and icon if a filter was applied. You can select the processing stage to view the log details, then click the filter label to see the specific filter details. These details include the status of the log and the outcome of each filter rule.

<details>
<summary>Filter details</summary>

For <u>Block all</u> rules, the filter details show that the message was blocked due to the defined filter rule.

![A warning banner in the log details notes that the message was blocked. ](https://images.ctfassets.net/cl3wt5ehhnlv/G5hiwmTIhLSZvV6ajnvqF/28e089257896fe7baceea96fbb86d180/log-filter-details-blocked.png)

*"Block all" outcome*

For <u>Send if</u> rules, the log details show an <u>outcome</u> for each rule.

If you have multiple <u>Send if</u> rules, the rules are evaluated in the order they’re defined. If a filter rule isn’t met, any subsequent rules aren’t evaluated.

![For send if rules, an outcome appears for each defined field path. ](https://images.ctfassets.net/cl3wt5ehhnlv/5rvzltRsj052KyS4iWCiDm/2687ee67d7ee128d097ca538cbe7257f/log-filter-details-send-if.png)

*"Send if" outcomes*

| **Outcome** | **Notes** |
| --- | --- |
| Satisfied | The criteria for this filter rule was met. The next filter rule was evaluated. |
| Unsatisfied | The criteria for the filter rule wasn’t met. Any subsequent filter rules weren’t evaluated. |
| Skipped | A previous filter rule was unsatisfied, so this rule wasn’t checked at all. |

</details>

## Create a filter

1. Follow the steps to view filters. 
2. Click the **New** button. 
3. The create form opens. Enter a **human-friendly name** for the filter. This name appears on the <u>Filters</u> page.
4. In the <u>Type</u> field, select either **Block all** or **Send if**. Follow the instructions for the relevant type. 


![A user clicks the New button on the Filters page and enters a name.](https://images.ctfassets.net/cl3wt5ehhnlv/1Su9IsvIwg2QeSBrUaAJ83/32d416cc423739e5f6a278d659e78504/filter-create.gif)

*Create a filter*




<details>
<summary>Option A: Block all filter rule</summary>

<u>**Block all**</u> restricts any notifications for the given subscription. Only deleting the filter will allow notifications to resume. Blocking is helpful when preparing for a new integration that’s not quite ready for go-live.

1. From the <u>Type</u> drop-down, select the **Block all** option**.**
2. Click the **Create** button.

![A user creates a filter rule to block all traffic. ](https://images.ctfassets.net/cl3wt5ehhnlv/54tFUAtjkf3ISHcPDOR5TU/4371bda5d7a59d275c4487770de168d8/filter-block-all-create.gif)

*Create a block all filter rule*


3. Your new filter is saved. To apply it to your traffic, follow the instructions for linking a filter. 


</details>




<details>
<summary>Option B: Send if filter rule</summary>

These conditional filters are the most common, since they allow you to moderate the event notifications you receive from one of your connections.

1. From the <u>Type</u> drop-down, select the **Send if** option**.**
2. From the <u>Data model</u> drop-down, select the expected **data model** in the subscription you want to link the filter to. 
3. Under the <u>Rules</u> section, click the **Select field path** drop-down to view a list of fields and select the **field** you want to filter on. 
4. A modal opens to test the field path and value. You can change your selection by clicking the <u>Field Path</u> drop-down again to view a list of fields. 

> **Array field paths**
>
> Some fields are arrays, meaning there might be multiple values at one field path. You can tell if a field path is an array if it has brackets (`[]`) in the title. In this case, if _any_ value within the array meets the filter rule, then the filter applies.



![A user selects the Patient ID type field path to filter on. ](https://images.ctfassets.net/cl3wt5ehhnlv/10PsyY2J8bUOOeYJXtzhLk/e204cf058e754b97ba48c66d967616df/Filters_send-if_select-field-path__1_.gif)

*Select a field path*


5. (Optional) Once you have the correct path, use the validation tools to test your choice. Keep in mind that Redox doesn’t validate the filter like this. But it does give you an idea of whether you selected the right field path by using an existing log payload.
   1. Find a log payload for the subscription you want to filter. [Learn how to search for logs](/how-to-use-redox/search-for-logs).

![A user selects the Redox processing stage to view and copy a log payload.](https://images.ctfassets.net/cl3wt5ehhnlv/5bvDyJIoYtzNhvvnBp3jIo/b246fbea87b530be8ab0bfb99c0cb3e1/Logs-copy-payload.gif)

*Copy a log payload*


   2. Copy and paste the **log payload** into the <u>Test message</u> section. 

![A user pastes the copied log payload into the Select Field Path modal to pull out the relevant ID types to filter.](https://images.ctfassets.net/cl3wt5ehhnlv/22er7ky1pdOcmZn5uoz0BA/42077af606edb899757f3e892b935ec7/Filters-select-field-path-paste-log-payload.gif)

*Paste a log payload to test the field values*


   3. On the right side of the modal, under <u>Field values</u>, the value that displays is the one found at the field path you selected.
   4. Click the **Select** button on the bottom right of the modal.
6. The modal closes. In the second drop-down, select **is in** or **is not in**.
   1. <u>**is in**</u>: The field path value must equal something in the defined value set. In other words, if the specified value(s) exist, the notification should be sent.
   2. <u>**is not in**</u>: The field path value must not equal something in the defined value set. In other words, if these value(s) exist, the notification shouldn’t be sent.
7. Enter the relevant **comma-separated values**. You can also use **`null`** as a string value in the value set if you want to filter by whether the field path is populated. 

> **Comma-delimited value sets**
>
> Trailing or leading spaces are ignored, unless you add them within quotation marks. If a value has a comma within it, you must use quotation marks to distinguish it from the other values. For example, you could specify an order code <u>is in</u> the value set `100,200,300`. But if one of the codes is `10,000`, you have to use quotation marks (e.g., `100,”10,000”,200,300`).



> **Case-sensitive values**
>
> Pay attention to case when you enter the value set. Value matching is case-sensitive for both “is in” and “is not in.” For example, `New` won’t match `new`.



![A user adds an "is in" rule with MRN and EPI values to conditionally filter on Patient ID Type.](https://images.ctfassets.net/cl3wt5ehhnlv/2N7x0anFbPACYrjmQGKylm/036e54af10827b9f382846e8ce1aa0f3/filter-send-if-create.gif)

*Create and save a filter*


8. To add a rule for another field, click the **Add rule** button. Populate the fields for the new rule. Or click the **delete** icon to remove a rule. 


![The Add rule option appears underneath any defined rules and the delete icon appears at the right of each of rule. ](https://images.ctfassets.net/cl3wt5ehhnlv/67dlLPBJ31YCdas6WoLg94/982a3c3849ed22526c292558a3da7d70/filter-multiple-rules.png)

*Add or delete filter rules*


9. Once you’ve finished defining all the necessary rules, click the **Save** button. Alternatively, you can click the **Cancel** button to discard the filter.


> **Filter details in logs**
>
> The filtered status and details will appear in related logs. [Learn about filter statuses and outcomes](https://docs.redoxengine.com/permalink/Zn8kiEw3GdyBFaSwQNSAN/#view-filtered-logs).



> **Filters for data model event types**
>
> Remember that filters are for async event types. As an example, if you create a filter for the Redox `Notes` data model, the filter applies to the `Notes.New`, `Notes.Replace`, and `Notes.Delete` event types. But it doesn’t apply to `Notes.Query`. [Learn the difference between async and sync event types](/api-reference/redox-data-model-api/event-types-for-data-models). 
>
> However, if you want to receive only one event type, you can create a <u>is in</u> filter on the `$.Meta.EventType` field. For example, if you only want to receive `Notes.New` event types, set the **field path** to `$.Meta.EventType` and the **value** to `New`. This filter ensures you won’t receive `Notes.Replace` or `Notes.Delete` event types.

</details>



#### Differences for FHIR field paths

If you’re creating a filter for a subscription that relies on Redox FHIR, the instructions are the same with a couple of minor differences when selecting the <u>**FHIR field path**</u>. 

In the <u>Select field path</u> modal, you can click the **Switch to Advanced Mode** option to directly edit the <u>field path</u> or enter one that doesn’t appear in the drop-down list. _We don_’_t recommend advanced editing for FHIR beginners._ 

![The option to switch to advanced template mode is in the top right of the modal.](https://images.ctfassets.net/cl3wt5ehhnlv/27n7lsg3pW0U5Qm6XaCaR4/9f64d33b4a3c9b829c250198e0c2ae34/filter-field-path-advanced-mode.png)

*Switch to template mode for FHIR field paths*

In advanced mode, you can click the **JSONPath Expressions** link to open help text definitions. Switch back to <u>template mode</u> anytime.

![In advanced mode, the JSONPath Expressions help link appears below the field path.](https://images.ctfassets.net/cl3wt5ehhnlv/4QyyLjeZsiZfxRWYeoH4TK/523973e03cf8f59a2e5eaef0f0140624/filter-select-path-advance-mode-json-expressions.png)

*JSONPath expressions help option*

When validating the FHIR field path, you have the additional option to toggle between <u>**Field values**</u> and <u>**Output paths**</u> to test that you have both correct. The value tells you what value would be filtered, and the path tells you the location in the FHIR payload.

![A user toggles between field values and output paths to validate the correct value will be filtered.](https://images.ctfassets.net/cl3wt5ehhnlv/lwmKA0t2hTremsWdOfxFB/cc6252941a1386a31f1756b1225cba11/filter-select-path-value-output-toggle.gif)

*Toggle between field values and output paths*

## Edit a filter

1. Follow the steps to view filters.
2. Find the filter you want to edit and click anywhere it in its **row**. 
3. Under <u>Filter details</u>, click the **Edit** button at the top right.
For promoted filters, follow the instructions below these. 
4. The edit form opens. Edit any details or defined rules, or add new ones.
5. When you’re finished, click the **Save** button. 

<details>
<summary>Edit a promoted filter</summary>

1. In a production environment, select the **promoted filter** you want to edit. 
2. Under the <u>Filter details</u>, click the **Go to staging** button. 


![The Go to Staging option is on the top right corner of the filter details. ](https://images.ctfassets.net/cl3wt5ehhnlv/4Qh5I5ovKpXEnkoy0P0sPu/b7a07da85a7189506695e720344ef7a8/filter-go-to-staging.png)

*Go to staging to edit*


3. A confirmation modal appears to acknowledge that you’re switching environments. Click the **Proceed** button to continue. 
4. The filter opens in the <u>**staging**</u> environment. Click the **Edit** button and make any changes. 
5. Click the **Save** button.
6. Once changes are successfully made, re-promote the filter to keep the assets in sync across environments.  

</details>

> **Previous filter rule settings**
>
> Any edits to a filter rule are  immediately applied to live traffic. However, when looking at past filtered logs, you’ll still see the old filter rules that were in effect at the time of that log. 

## Link a filter

A filter can only be linked to one <u>**subscription**</u>. You have to create one for each subscription you want to filter. 

1. Follow the steps to view filters.
2. Find the filter you want to edit and click anywhere it in its **row**. 
3. The <u>Details</u> page opens. Fill out the fields under the <u>Links</u> section. 
   1. From the <u>Connection</u> drop-down, select the **connection** you want to link the filter to.
   2. Click the <u>Subscription</u> drop-down. A modal opens with a list of the selected connection’s subscription(s). Click the **radio button** of the subscription you want, then click the **Select** button. 
4. Click the **Link** button. 


![A user selects a connection and subscription to link the filter to. ](https://images.ctfassets.net/cl3wt5ehhnlv/2e0RnSRnzhpKTXbeaDOmLU/ed3da9ea638deffda3c0764b0b03c8bc/filter-link.gif)

*Link a filter*


5. The filter automatically applies to the subscription’s traffic. For <u>block all</u> filters, all traffic for the selected subscription is restricted until the filter is removed.


> **Filter details in logs**
>
> The filtered status and details will appear in related logs. [Learn about filter statuses and outcomes](https://docs.redoxengine.com/permalink/Zn8kiEw3GdyBFaSwQNSAN/#view-filtered-logs).



## View and manage filter links

A filter can only be linked to one <u>**subscription**</u>. You have to create one for each subscription you want to filter. 

Also, a s<u>ubscription</u> can only have one filter link. This means there’s a 1:1 relationship between filters and subscriptions. [Learn about subscriptions](https://docs.redoxengine.com/permalink/5k6U4ofmE0bKPBk4fhRcj5/#what-are-subscriptions). 

> **Example scope**
>
> Let’s say you have two subscriptions for receiving `Order.New` notifications from two different healthcare organizations.
>
> - The first subscription is with Baylor Hospital. You create a <u>Send if</u> filter with a rule that looks for certain order type(s).
> - The second subscription is with UT-Southwestern. You want only the same order types as from Baylor, but you can’t link the Baylor filter to UT-Southwestern. This subscription needs its own filter, even if you want the same rule applied.
>
> However, you could add a rule to the Baylor filter if you only want to get orders from a specific facility within the health system. Then your filter would have two rules to conditionally allow new orders (of a specific type) from a specific facility.
>
> Remember that both of your subscriptions now have linked filters. This means you can’t create or link a new <u>Block all</u> filter to either of them.

1. Follow the steps to view filters.
2. Find the filter with the link you want to manage and click anywhere it in its **row**. 
3. The <u>Details</u> page opens. A filter can only be linked to one subscription. To add a new link, you have to delete the existing filter link.  
   1. To view an existing link in context, click the **link** to open related logs. 
   2. To delete an existing link, click the **three-dots** icon to the right of the subscription, then the **Delete** option. A modal opens to confirm that you want to proceed. Click the **Delete** button to continue or the **Cancel** button to discard the changes. 


![The Delete option is under the three-dots icon menu. ](https://images.ctfassets.net/cl3wt5ehhnlv/43asewM89ys4a2whuixiFc/274250202f0bbb69333aec07f163b28e/filter-links-delete.png)

*Delete a filter link*


   3. To add a new link, you must first delete an existing link. Then, follow the steps to link a filter. 

Alternatively, you can see the filter link information on the <u>Details</u> page of the linked subscription. You can click the **Manage** button to navigate back to the Filters page to edit or remove the link. 

![The filter details are highlighted at the bottom of a subscription's Details page. ](https://images.ctfassets.net/cl3wt5ehhnlv/1oI893Xrd95AGo8gsgiT6A/ddc012a4d3572788f6c08ddddbd3e24b/subscription-details-filters.png)

*Filter links on the subscription Details page*

## Promote a filter

During implementation, you can build and test a filter in a staging environment. Once you’re confident it works, you can promote it to production. Promoting an asset saves time and avoids introducing errors by rebuilding it in a different environment. [Learn about promoting assets](/implementation-guide/promote-assets-in-your-redox-organization). 

1. Follow the steps to view filters. 
2. From the <u>Environments</u> drop-down, make sure you’ve selected the **Staging** environment.


![The environment drop-down field in the top left corner of the Redox allows you to switch between environments.](https://images.ctfassets.net/cl3wt5ehhnlv/5fgoEIuUz7oSO5DrNXvJFw/39e6d7e79fe09106705e931ecd9b2ebc/Environment-select-staging.png)

*Select the staging environment*


3. Find the filter you want to promote and click anywhere in its **row.** 
4. The <u>Details</u> page opens. Click the **Promote** button.
5. A modal appears to let you know you’re exiting the staging environment and proceeding to the production environment. Click the **Proceed** button. Otherwise, click the **Cancel** button to discard the promotion. 


![A user selects a filter and proceeds to production to promote the filter. ](https://images.ctfassets.net/cl3wt5ehhnlv/1Naby4fSYbp0K0GG34NPs0/c9931c74c3364218005bac62a7161119/filter-promote.gif)

*Promote a filter to production*


6. The <u>Details</u> page in the production environment opens. Add a **filter link** to a subscription to apply the filter in your production environment.   

## Restore a filter version

Every time you edit a filter, you create a new version of the asset. You can restore a version of a filter that’s not currently in use. This may be helpful when troubleshooting to see where an error might have been introduced or to resolve an error by using a version that worked previously.    

1. Follow the steps to view filters. 
2. Find the filter with a version you want to restore and click anywhere in its **row.** 
3. The <u>Details</u> page opens. Click the **Restore** button.
4. A modal appears to restore a version. From the drop-down, select a **version** to restore. 


> **Restore notes**
>
> Restoring means activating a version that’s not in use. That means you can go backwards or forwards a version. 
>
> Keep in mind you can’t restore a version that’s already in use or an asset that’s been deleted. 

 
5. The diff view shows what’s different between the current and selected version. Review the differences. When finished, click the **Restore** button. 


> **Versions after editing**
>
> If you edit an asset after restoring a previously used version, a new version is created.
>
> For example, let’s say you were on version 3 and you restore version 2. Then you make and save edits to version 2. This creates version 4 of the asset. At that point, you can still restore to version 3 at any time.




![A user selects a filter version to restore and reviews the diff view of both versions. ](https://images.ctfassets.net/cl3wt5ehhnlv/5jOBvFbdyPO1ep1cKUESBF/67fde24c01149d39efd1160ba0b594b1/filter-restore.gif)

*Restore a filter version*


6. For promoted assets, restoring a version only applies to the current environment. If you restore a version in staging, you may need to re-promote the asset if you want to apply it to production as well. 


![The unpushed changes warning appears under the filter details. ](https://images.ctfassets.net/cl3wt5ehhnlv/5NeUaOx8vKpDLYE7mKsg4f/2d7c10caa86f8db2d19b1bc1dc3d37ce/filter-unpushed-changes.png)

*Unpushed changes*




![A warning appears on the filter table when a filter has out of sync versions. ](https://images.ctfassets.net/cl3wt5ehhnlv/5EgcsHxsSJFJzFKMo6Lg8w/fafa6a95d506b71414e4e7ecb6096979/filter-out-of-sync.png)

*Out of sync versions*



> **Platform API endpoints**
>
> This article describes how to manage filters in the <u>**Redox dashboard**</u>. To manage destinations via <u>**API**</u>, use these <u>**Redox Platform API**</u> endpoints instead:
>
> - [Get environment filters](https://docs.redoxengine.com/permalink/d662015b-022e-57b9-9ba2-bf610511b7b2-get-env-filters)
> - [Get filter by ID](https://docs.redoxengine.com/permalink/79066a05-a025-5ff8-89f3-0242f6a7ccab-get-filter-by-id)
> - [Create filter](https://docs.redoxengine.com/permalink/468a2307-c05c-5c8f-8435-dcaf40321455-create-filter)
> - [Update filter](https://docs.redoxengine.com/permalink/45ab5582-31d1-592b-a541-a8713883581c-update-filter)
> - [Restore filter](https://docs.redoxengine.com/permalink/b527dbc1-f1a6-5072-bc4f-39580de4479a-restore-filter)
> - [Delete filter by ID](https://docs.redoxengine.com/permalink/799df785-1de7-5b0e-9791-df4d70163d50-delete-filter-by-id)
> - [Create link](https://docs.redoxengine.com/permalink/e2c6549b-6be3-5768-95bf-98beb2a45ee2-create-filter-link)
> - [Get link](https://docs.redoxengine.com/permalink/bfe7eee4-3273-5516-b8d1-34d2d0f0d42f-get-filter-link)
> - [Delete link](https://docs.redoxengine.com/permalink/e7756300-60db-5a9d-a985-58343687a57c-delete-filter-link)
> - [Promote asset](https://docs.redoxengine.com/permalink/00e540fd-52b8-5bcd-8b56-e392e9db575e-promote-asset)
