# Configure Custom Validation Criteria

Learn how to configure _Validation Criteria_ for Agencies not already supported by Veeva Safety.

## About Custom Validation Criteria

As standard, Safety provides _Validation Criteria_ for the ICH, EMA, FDA, FDA VAERS, PMDA, NMPA, and MFDS health authorities.

If you need to add custom _Validation Criteria_ to enforce data quality requirements for _Submissions_ or _Distributions_ other than the ones already included in Safety, you can configure your Vault by adding custom _Validation Criteria_. This custom criteria then runs as part of <a href="/en/lr/01226/">_Case_ and _Submission_ Validation</a>.


<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>: 
For help adding custom <em>Inbound Validation Criteria</em>, see <a href="/en/lr/01202/#add-validation-criteria">Manage Transmission Profiles</a>.</p>
    </div>
  </div>
</div>



The next section describes how you can add custom _Validation Criteria_ to your Vault.


## Create Custom Validation Criteria {#create-custom-validation-criteria}

Complete the following steps to create and configure custom _Validation Criteria_:

1. Navigate to **Business Admin > Objects > Validation Criteria**.
2. Select **Create**.
3. Complete the applicable <a href="#fields">fields</a>.
4. Select **Save**.

Repeat the above steps for each custom _Validation Criteria_ required.


### Validation Criteria Fields {#fields}

<table>
    <thead>
        <tr>
            <th>
                Field
            </th>
            <th>
                Description
            </th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>
                <em>Name</em>
            </td>
            <td>
                Enter the name of the custom <em>Validation Criteria</em>.
            </td>
        </tr>
        <tr>
            <td>
                <em>Source</em>
            </td>
            <td>
                Select <strong>Custom</strong>.
                <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>: If you require a <strong>Custom SDK</strong> validation, contact your Veeva Representative.</p>
    </div>
  </div>
</div>


            </td>
        </tr>
        <tr>
            <td>
                <em>Always Evaluate</em>
            </td>
            <td>
                <p>Select this option if Vault should evaluate this <em>Validation Criteria</em> for all global and regional destinations regardless of the <em>Case</em> having a reporting obligation.</p>
            <p>If the <em>Always Evaluate</em> option is selected for a <em>Validation Criteria</em>, leave the <em>Agency</em> and <em>File Format</em> fields blank.</p>
            </td>
        </tr>
        <tr>
            <td>
                <em>Agency</em>
            </td>
            <td>
                <p>
                    Select the Agency to which the <em>Validation Criteria</em> applies.
                </p>
                <p>
                    Leave this field blank if the custom rule is a global validation.
                </p>
                <p>
                    If this validation is regional and only applies to a specific agency, then select the appropriate Agency.
                </p>
                <p>
                    If you are using a File Format validation, Vault will evaluate the rule only when validations are run for one of the specified File Format and Agency pairings.
                </p>
            </td>
        </tr>
        <tr>
            <td>
                <em>Conformance</em>
            </td>
            <td>
                Enter the description of the <em>Validation Criteria</em>.
            </td>
        </tr>
        <tr>
            <td>
                <em>Data Element</em>
            </td>
            <td>
                Specify the E2B element ID that the custom rule will validate.
            </td>
        </tr>
        <tr>
            <td>
                <em>Data Element Name</em>
            </td>
            <td>
                Specify the E2B element ID name that the custom rule will validate.
            </td>
        </tr>
        <tr>
            <td>
                <em>File Format</em>
            </td>
            <td>
                <p>
                    Select which standard E2B file formats the <em>Validation Criteria</em> applies to.
                </p>
                <p>
                    If you are using <strong>Case Data</strong> or <strong>Case Data - Expression</strong>, you can leave this field blank unless you are configuring the <em>Validation Criteria</em> for a specific agency or agencies.
                </p>
                <p>
                    If you are using <strong>File Format</strong>, or are configuring a <em>Validation Criteria</em> to run for a specific agency or agencies only, select the standard E2B file formats to which the <em>Validation Criteria</em> applies. This field works with the <strong>Agency</strong> field and must be aligned accordingly. For example, if you select <strong>EMA</strong> for the <strong>Agency</strong>, you must select an EMA <strong>File Format</strong>. Vault will evaluate the rule only when validations are run for one of the specified File Format and Agency pairings.
                </p>
            </td>
        </tr>
        <tr>
            <td>
                <a id="evaluation-level"></a><em>Evaluation Level</em>
            </td>
            <td>
                <p>
                    Select the levels at which Vault evaluates the <em>Validation Criteria</em> record.
                </p>
                <p>
                    For example, select <strong>Case</strong> if the rule is intended to be evaluated when validations are run from the <em>Case</em> level only.
                </p>
                <ul>
                    <li><strong>Intake</strong>:
                        If you select this option, you must specify the <em>Case</em> (<code>case__version__v</code>) object or any of its child objects as the <a href="#path-to-validating-records">path to validating records</a> in the <a href="#validation-query">Validation Query Builder</a>.
                    </li>
                    <li><strong>Case</strong></li>
                    <li><strong>Domestic Case</strong></li>
                    <li><strong>Submission</strong></li>
                </ul>
            </td>
        </tr>
        <tr>
            <td>
                <em>Result Status Type</em>
            </td>
            <td>
                <p>
                    Select whether Vault should treat a rule violation as a <strong>Warning</strong>, <strong>Fail</strong>, or <strong>Hard Fail</strong>.
                </p>
                <p>
                    This field is directly tied to the <em>Validation Status</em> field of the associated <em>Validation Result</em> object.
                </p>
                <ul class="uk-list uk-list-bullet">
                    <li>
                        Either a <em>Fail</em> or <em>Hard Fail</em> result will prevent an auto-submission to a gateway.
                    </li>
                    <li>
                        Only a <em>Hard Fail</em> result will prevent you from triggering the <em>Submit to Gateway</em> action.
                    </li>
                </ul>
            </td>
        </tr>
        <tr>
            <td>
                <em>Vault Object</em>
            </td>
            <td>
                Enter the API name of the relevant object for the validated E2B field. When validation results are generated, they will contain a link to the specified object. For example, <code>case_drug_history__v</code>.
            </td>
        </tr>
        <tr>
            <td>
                <em>Vault Field</em>
            </td>
            <td>
                Enter the API name of the relevant field for the validated E2B field. When validation results are generated, they will contain a link to the specified object. For example, <code>mpid_version__v</code>.
            </td>
        </tr>
        <tr>
            <td>
                <em>Rule Version</em>
            </td>
            <td>
                Enter the version number of the <em>Validation Criteria</em>.
                <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>: If there are multiple <em>Validation Criteria</em> records with the same name, only the latest version of the rule will be evaluated.</p>
    </div>
  </div>
</div>


            </td>
        </tr>
        <tr>
            <td>
                <em>Rule Formula Format</em>
            </td>
            <td>
                <p>
                    Select whether to use <strong>File Format</strong>, <strong>Case Data</strong>, or <strong>Case Data - Expression</strong> for formula execution:
                </p>
                <ul>
                    <li>
                        <strong>File Format</strong>: A JSON schema validation based on <em>Case</em> data that is specific to an E2B format
                    </li>
                    <li>
                        <strong>Case Data</strong>: A JSON schema validation based on <em>Case</em> data that is not specific to an E2B format
                    </li>
                    <li>
                        <strong>Case Data - Expression</strong>: A <a href="#validation-expression-language">Vault Expression Language</a>-based validation based on <em>Case</em> data that is not specific to an E2B format
                    </li>
                </ul>
                <p>
                    If left blank, Vault defaults to <em>File Format</em>.
                </p>
                <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>: <em>File Format</em> is used for all standard ICH E2B(R3) <em>Validation Criteria</em>.</p>
    </div>
  </div>
</div>


            </td>
        </tr>
        <tr>
            <td>
                <a id="validation-query"></a><em>Validation Query Builder</em>
            </td>
            <td>
                Enter the <a href="#validation-expression-language">formula</a> used to validate against the specified E2B files.
            </td>
        </tr>
        <tr>
            <td>
                <em>Supersedes</em>
            </td>
            <td>
                If this <em>Validation Criteria</em> supersedes an existing <em>Validation Criteria</em>, select the name of the superseded rule in this field.
                <p>
                    If this rule and the superseded rule are both due to be evaluated, Vault evaluates this rule instead of the superseded rule.
                </p>
            </td>
        </tr>
        <tr>
            <td>
                <em>API Name</em>
            </td>
            <td>
                Enter a unique <code>__c</code> API name for this <em>Validation Criteria</em>.
            </td>
        </tr>
    </tbody>
</table>


## Write Custom Validation Criteria Rule Formulas {#validation-expression-language}

When writing the [Validation Query][1] for a custom _Validation Criteria_ with a _Rule Formula Format_ of _Case Data - Expression_, use either of the following methods:

1. `VS_LET(var, path_to_validating_records, expression)`: Using this method, you can select any Safety object as the beginning of the <a href="#path-to-validating-records">path to the validating records</a> (the top-level object).
2. `expression`: With this method, the top-level object is either a _Case_ or a _Transmission_.


### Path to Validating Records {#path-to-validating-records}

The `path_to_validating_records` tells the Safety Reporting Rule Engine where to find the set of records to evaluate relative to the top-level object. The Rule Engine performs the `expression` defined in the _Rule Formula_ field on each record to obtain a set of pass and fail results. Vault stores these results in the _Validation Results_ and _Validation Results Summary_ for the _Case_.

 It is important to use the correct <a href="/en/lr/42857/">object relationship</a> names when specifying this path. To obtain the relationship names for an object, navigate to **Admin > Configuration > Objects > [object] > Relationships**.

Example: `case_version__v.case_products_case_version__vr` returns all of the _Case Products_ associated with the _Case_.

You can also specify _Case Documents_ (`case_documents__v`) as the top-level object to validate attachment descriptions (**Case > Source > Attachments**) and literature references (**Case > Source > Literature**).

Example: `VS_LET(cd, case_documents__v, IF(cd.classification__v = "Literature", not(isblank(cd.reference_text__v)), true))` validates that any _Case Document_ classified as _Literature_ does not have a blank _Reference_ field.


### Rule Formula Expression

When writing the [Validation Query][1] for your custom _Validation Criteria_ (either as a standalone `expression` or as a `VS_LET` statement), you can use any of the operators and functions in the <a href="/en/lr/52324/">Vault Formula Reference Guide</a> and the Safety-specific functions detailed in <a href="/en/lr/861364/">Create Formula Expressions</a>.

See [Appendix: Example Expressions][0] for examples of how you can build expressions to use in your rule formulas.

<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 Validation Expression Language does not currently provide an <em>at least one of</em> function (for example, <em>at least one of the Case Products has an expiration</em>). This function will be added in a future release. If you require this function now, you must use either JSON or the SDK.</p>
    </div>
  </div>
</div>



## Troubleshoot Validation Criteria

If Vault encounters any validation errors when running the **Evaluate Regulatory Conformance** action for an _Inbox item_, a _Case_, or a _Submission_, the _Validation Status_ field of the _Validation Results Summary_ record changes to _Error_.


<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>: 
Vault requires the configuration of custom validation criteria to evaluate <em>Inbox Item</em> records. For more information, see <a href="/en/lr/01202/#add-validation-criteria">Manage Transmission Profiles</a>.</p>
    </div>
  </div>
</div>



Common _Validation Criteria_ errors include the following:

* A missing or incorrect Vault object
* A missing or incorrect Vault field
* An incorrect Rule Formula (including invalid references and null pointer exceptions)
* An invalid JSON schema

To help diagnose the error, Vault provides Validation Error logs in CSV format for individual [_Cases_ and _Submissions_][2], and for individual _Validation Criteria_. Once you have diagnosed and fixed all validation errors, run the **Evaluate Regulatory Conformance** action on the object to clear the _Error_.


### Validation Error Logs for Cases and Submissions {#cases-and-submissions-logs}

The Validation Error Log for a _Case_ or _Submission_ lists all the _Validation Criteria_ that failed for that record.

You can obtain the Validation Error Log for a _Case_ or _Submission_ by navigating to the **Validations Results (Failures & Warnings)** section and selecting the **Validation Results Summary** record. The _Validation Status_ field of this record shows _Error_. From the **Validation Results Summary** record, select the **Download Validation Error Log** action from the **All Actions** menu.

<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 <code class="language-plaintext highlighter-rouge">transmission_id</code> column is populated only for <em>Transmission</em> (<em>Submission</em> or <em>Distribution</em>) records and is left blank for <em>Case</em> records.</p>
    </div>
  </div>
</div>




### Validation Error Logs for Validation Criteria

The Validation Error Log for a _Validation Criteria_ record lists all _Case_ or _Submission_ records where the _Validation Criteria_ failed. _Validation Criteria_ records that caused an error are in the _Error_ lifecycle state.

You can obtain the Validation Error Log for a _Validation Criteria_ record by navigating to **Business Admin > Objects > Validation Criteria** and selecting the **Validation Criteria** record. From the **Validation Criteria** record, select the **Download Validation Error Log** action from the **All Actions** menu.

## Appendix: Example Expressions {#example-expressions}

The following table contains example expressions that illustrate how to use the `VS_LET` and `VS_ANYOF` functions to test _Case_ data.

<table>
    <thead>
        <tr>
           <th>Example Expression</th>
           <th>Description</th>
        </tr>
    </thead>
        <tr>
            <td><code>VS_ANYOF(case_version__v.case_assessments_case_version__vr.rank__v, LAMBDA(element, element = 1))</code></td>
            <td rowspan="2" >
                <p>
                    These examples illustrate how to specify the <code>path_to_validating_records</code> in an expression.
                </p>
                <p>
                    The first expression performs this using a single <code>VS_ANYOF</code> function that specifies the <code>path_to_validating_records</code>, and the operation to perform on those records (<code>LAMBDA</code>).
                </p>
                <p>
                    The second expression uses the <code>VS_LET</code> function to set <code>ca</code> as an alias for <code>case_version__v</code>. The following <code>VS_ANYOF</code> function uses this alias as the starting point of its <code>path_to_validating_records</code>.
                </p>
                <p>
                    Both of these expressions return true if any <em>Case Assessment</em> on the <em>Case</em> has a <em>Rank</em> value of <em>1</em>.
                </p>
                <p>
                    The <code>VS_LET</code> function is useful if the subsequent logic uses multiple functions that refer to the same <code>path_to_validating_records</code>.
                </p>
            </td>
        </tr>
        <tr>
            <td><code>VS_LET(ca, case_version__v, VS_ANYOF(ca.case_assessments_case_version__vr.rank__v, LAMBDA(element, element = 1)))</code></td>
        </tr>
        <tr>
            <td><code>VS_ANYOF(case_version__v.case_assessments_case_version__vr, LAMBDA(element, element.rank__v = 1))</code></td>
            <td rowspan="2" >
                <p>
                    These examples illustrate that you can specify the <code>path_to_validating_records</code> partially in the <code>VS_LET</code> or <code>VS_ANYOF</code> function and partially in the <code>LAMBDA</code> function.
                </p>
                <p>
                    These expressions perform the same operation on the same set of records as the expression above, but the full <code>path_to_validating_records</code> is specified partially by the <code>VS_ANYOF</code> or <code>VS_LET</code> function and partially by the <code>LAMBDA</code> function.
                </p>
                <p>
                    This technique is useful if the expression has multiple functions that operate on different sets of records which are based on a common <code>path_to_validating_records</code>.
                </p>
            </td>
        </tr>
        <tr>
            <td><code>VS_LET(ca, case_version__v, VS_ANYOF(ca.case_assessments_case_version__vr, LAMBDA(element, element.rank__v = 1)))</code></td>
        </tr>
        <tr>
            <td><code>VS_LET(ca, case_version__v,  VS_ANYOF(ca.case_products_case_version__vr, LAMBDA(element, element.mpid__v = "mpid1")))</code></td>
            <td>This example returns true if any of the <em>Case Products</em> on the <em>Case</em> has a <em>Medicinal Product Identifier</em> value of <em>mpid1</em>.</td>
        </tr>

        <tr>
            <td><code>VS_LET(cv, case_version__v, NOT(VS_ANYOF(cv.transmissions_case_version__vr, LAMBDA(t, t.object_type__vr.api_name__v = 'inbound_transmission__v'  && t.origin__vr.api_name__v = 'ema__v'))))</code></td>
            <td>This example illustrates how to reference an <em>Inbound Transmission</em> in an expression. The expression returns false if the <em>Inbound Transmission</em> on the <em>Case</em> originated from the EMA.</td>
        </tr>
        <tr>
            <td><code>VS_LET(ca, case_version__v,  VS_ANYOF(ca.case_assessments_case_version__vr, LAMBDA(element, element.rank__v = 1)) || ca.patient_first_name__v = " any_name__v 123 ")</code></td>
            <td>
                <p>
                   This example demonstrates using multiple operations within a <code>VS_LET</code> function.
                </p>
                <p>
                    The expression uses the logical OR (<code>||</code>) operator and returns true if either of the following conditions is true:
                </p>
                <ul>
                    <li>Any <em>Case Assessment</em> on the <em>Case</em> has a <em>Rank</em> value of <em>1</em>.</li>
                    <li>The <em>Patient First Name</em> field on the <em>Case</em> matches the specified string.</li>
                </ul>
            </td>
        </tr>
        <tr>
            <td><code>VS_LET(ca, case_version__v,  VS_ANYOF(ca.case_adverse_events_case_version__vr, LAMBDA(element, element.days_hospitalized__v = 2)))</code></td>
            <td rowspan="3" >
                <p>
                    These examples demonstrate using multiple operations inside of the <code>LAMBDA</code> function.
                </p>
                <p>
                    The first expression returns true if any <em>Case Adverse Event</em> on the <em>Case</em> has a <em>Days Hospitalized</em> value of <em>2</em>.
                </p>
                <p>
                    The second expression returns true if any <em>Case Adverse Event</em> on the <em>Case</em> has a <em>Days Hospitalized</em> value of <em>2</em> OR (<code>||</code>) is blank.
                </p>
                <p>
                    The third expression returns true if any <em>Case Adverse Event</em> on the <em>Case</em> has a <em>Days Hospitalized</em> value of <em>2</em> AND (<code>&&</code>) the <em>Days Hospitalized</em> value is greater than the <em>Minimum Days Hospitalized</em> value of the <em>Organization</em> associated with the <em>Case</em>. In this example, <em>Minimum Days Hospitalized</em> is a <a href="/en/lr/15057/#how-to-customize-standard-objects">custom field</a> on the <em>Organization</em> object.
                </p>
            </td>
        </tr>
        <tr>
            <td><code>VS_LET(ca, case_version__v,  VS_ANYOF(ca.case_adverse_events_case_version__vr, LAMBDA(element, element.days_hospitalized__v = 2 || ISBLANK(element.days_hospitalized__v) )))</code></td>
        </tr>
        <tr>
            <td><code>VS_LET(ca, case_version__v,  VS_ANYOF(ca.case_adverse_events_case_version__vr, LAMBDA(element, element.days_hospitalized__v = 2 && element.days_hospitalized__v >= ca.organization__vr.min_days_hospitalized__c )))</code></td>
        </tr>
    <tbody>
    </tbody>
</table>

## Appendix: Custom Validation Criteria Using JSON {#json-method}

If required, you can use JSON instead of the Vault Expression Language to create custom _Validation Criteria_. However, we recommend using the Vault Expression Language described above as it is considerably quicker and easier to configure than the JSON method. The JSON method will continue to be supported but will not be enhanced in future releases.

The JSON method is similar to that described in <a href="#create-custom-validation-criteria">Create Custom Validation Criteria</a> above, except that the code you enter in the <em>Rule Formula</em> field must be valid JSON.

When E2B files are generated for standard (non-custom) file formats, all of the relevant E2B data is exposed in structured JSON for validation purposes. The following files are examples of the structured JSON for the standard formats that can be used for reference:

* E2B(R2): <a class="download-link " href="https://platform.veevavault.help/assets/downloads/saf-sample-full-e2br2-json.json" target="_blank" rel="noopener">sample-full-e2br2-json.json<i class="fa fa-download" aria-hidden="true"></i></a>
* FDA E2B(R2): <a class="download-link " href="https://platform.veevavault.help/assets/downloads/saf-sample-full-fda-e2br2-json.json" target="_blank" rel="noopener">sample-full-fda-e2br2-json.json<i class="fa fa-download" aria-hidden="true"></i></a>
* HC E2B(R2): <a class="download-link " href="https://platform.veevavault.help/assets/downloads/saf-sample-full-hc-e2br2-json.json" target="_blank" rel="noopener">sample-full-hc-e2br2-json.json<i class="fa fa-download" aria-hidden="true"></i></a>
* E2B(R3): <a class="download-link " href="https://platform.veevavault.help/assets/downloads/saf-sample-full-e2br3-json.json" target="_blank" rel="noopener">sample-full-e2br3-json.json<i class="fa fa-download" aria-hidden="true"></i></a>
* EMA E2B(R3): <a class="download-link " href="https://platform.veevavault.help/assets/downloads/saf-sample-full-ema-e2br3-json.json" target="_blank" rel="noopener">sample-full-ema-e2br3-json.json<i class="fa fa-download" aria-hidden="true"></i></a>
* FDA VAERS E2B(R3): <a class="download-link " href="https://platform.veevavault.help/assets/downloads/saf-sample-full-fda-e2br3-json.json" target="_blank" rel="noopener">sample-full-fda-e2br3-json.json<i class="fa fa-download" aria-hidden="true"></i></a>
* PMDA E2B(R3): <a class="download-link " href="https://platform.veevavault.help/assets/downloads/saf-sample-full-pmda-e2br3-json.json" target="_blank" rel="noopener">sample-full-pmda-e2br3-json.json<i class="fa fa-download" aria-hidden="true"></i></a>
* Case Data: <a class="download-link " href="https://platform.veevavault.help/assets/downloads/saf-sample-full-case.json" target="_blank" rel="noopener">sample-full-case.json<i class="fa fa-download" aria-hidden="true"></i></a>

You can find validation criteria types, including syntax and limitations, on the <a class="external-link " href="https://json-schema.org/" target="_blank" rel="noopener">JSON Schema<i class="fa fa-external-link" aria-hidden="true"></i></a> website.


<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>: Unlike standard JSON schema, the validation JSON schema must have a top-level description annotation. This annotation must contain the JSON path to the validated element (for example, <code class="language-plaintext highlighter-rouge">"description": "#/sectionC/sectionC2Rs"</code>) and will determine how the associated validation results are generated.</p>
    </div>
  </div>
</div>



### Custom Validation Criteria Examples

Consider the following examples of custom _Validation Criteria_ configured in Safety and the JSON syntax for each:


#### Example 1: Simple Rule

* **File Format**: HC E2B(R2)
* **Agency**: Health Canada
* **Data Element**: A.2.1.2f
* **Data Element Name**: Reporter's Postcode
* **Conformance**: "This field is required."
* **Vault Object**: `case_contact__v`
* **Vault Field**: `postalcode_value__v`
* **Rule Formula**: <a class="download-link " href="https://platform.veevavault.help/assets/downloads/saf-simple-rule-formula.json" target="_blank" rel="noopener">simple-rule-formula.json<i class="fa fa-download" aria-hidden="true"></i></a>


#### Example 2: Complex Rule

* **File Format**: FDA VAERS E2B(R3)
* **Agency**: FDA
* **Data Element**: D.2.1
* **Data Element Name**: Date of Birth
* **Conformance**: "FDA requires that at least one of the data elements in the Age Information section (Date of Birth (D.2.1), Age at Time of Vaccination (FDA.D.2.1a/b), Age at time of Onset of Reaction (D.2.2a/b), Gestation Period When Reaction / Event Was Observed in the Foetus (D.2.2.1a/b), and Patient Age Group (D.2.3)) be populated, preferably Date of Birth and Age at the Time of Vaccination. If Local Criteria Report Type = Malfunction Only (No AE), then all age fields are optional."
* **Vault Object**: `case_version__v`
* **Vault Field**: `dob_idate__v`
* **Rule Formula**: <a class="download-link " href="https://platform.veevavault.help/assets/downloads/saf-complex-rule-formula.json" target="_blank" rel="noopener">complex-rule-formula.json<i class="fa fa-download" aria-hidden="true"></i></a>


#### Example 3: Detailed JSON Structure Example

* **File Format**: FDA VAERS E2B(R3)
* **Agency**: FDA
* **Data Element**: D.10.8.r.2a
* **Data Element Name**: MPID Version Date / Number
* **Conformance**: "This field is required when Medicinal Product Identifier (MPID) (D.10.8.r.2b) is populated."
* **Vault Object**: `case_drug_history__v`
* **Vault Field**: `mpid_version__v`
* **Rule Formula**:
<pre>
 1 {
 2  "$schema": "http://json-schema.org/draft-07/schema#",
 3  "type": "object",
 4  "description": "#/sectionD/d_10_patientParent/d_10_8_r_parentDrugHistory",
 5  "definitions": {
 6    "d_10_8_r_2b_POPULATED": {
 7      "properties": {
 8        "_2b_MPID": {
 9          "type": "string",
10          "minLength": 1
11        }
12      },
13      "required": ["_2b_MPID"]
14    },
15    "d_10_8_r_2a_EXISTS": {
16      "properties": {
17        "_2a_MPIDVersionDataNumber": {
18          "type": "string",
19          "minLength": 1
20        }
21      },
22      "required": ["_2a_MPIDVersionDataNumber"]
23    }
24  },
25  "properties": {
26    "sectionD": {
27      "type": "object",
28      "properties": {
29        "d_10_patientParent": {
30          "type": "object",
31          "properties": {
32            "d_10_8_r_parentDrugHistory": {
33              "type": "array",
34              "items": {
35                "type": "object",
36                "if": {
37                  "$ref": "#/definitions/d_10_8_r_2b_POPULATED"
38                },
39                "then": {
40                  "$ref": "#/definitions/d_10_8_r_2a_EXISTS"
41                }
42              }
43            }
44          }
45        }
46      }
47    }
48  }
49 }
</pre>

<strong>Line #2: "$schema" key</strong>

Specifies the URI for the desired JSON schema version. We recommend using `"http://json-schema.org/draft-07/schema#"`.

<strong>Line #3: "type" key</strong>

Specifies the data type for a schema. The top-level JSON element in the structured JSON is always type `"object"`.

<strong>Line #4: "description" key</strong>

Specifies the JSON path to the validated JSON element. In this case, the validated JSON element `"_2a_MPIDVersionDataNumber"` is located in `"sectionD → d_10_patientParent → d_10_8_r_parentDrugHistory"`.

<strong>Lines #5-24: "definitions"</strong>

Specifies a map of JSON schemas. Each of the schemas defined in this map can be referenced and evaluated by using the `"$ref"` keyword. While not required, definitions can help increase readability when there are multiple schemas (to help describe what each one is validating) and/or for defining a schema that will be used multiple times.

<strong>Line #6-14: "d_10_8_r_2b_POPULATED" schema</strong>

Specifies the schema for ensuring that D.10.8.r.2b (`"_2b_MPID"`) is populated. This schema is referenced later using the `"$ref"` keyword, within the schema for `"d_10_8_r_parentDrugHistory"`.

* `"type": "string"`  → Enforces a string value
* `"minlength": "1"`  → Enforces a non-blank value
* `"required" : ["_2b_MPID"]`  → Enforces the element's existence

<strong>Line #15-24: "d_10_8_r_2a_EXISTS" schema</strong>

Specifies the schema for ensuring that D.10.8.r.2a (`"_2a_MPIDVersionDataNumber"`) is populated. This schema is referenced later using the `"$ref"` keyword, within the schema for `"d_10_8_r_parentDrugHistory"`.

* `"type": "string"`  → Enforces a string value
* `"minlength": "1"`  → Enforces a non-blank value
* `"required" : ["_2a_MPIDVersionDataNumber"]`  → Enforces the element's existence

<strong>Lines #25-48: "properties" (top-level)</strong>

Specifies the properties of the top-level JSON object. The value of the `"properties"` is an object where each key is the name of a property or element and each value is a schema used to validate that element.

<strong>Lines #26-47: "sectionD" schema</strong>

Specifies the JSON schema for the `"sectionD"` object.

<strong>Line #27: "type": "object"</strong>
Specifies the type of `"sectionD"`, which is an object containing key-value pairs (properties).

<strong>Line #28: "properties" (sectionD)</strong>

Specifies the properties of the `"sectionD"` JSON object. It contains key-value pairs where each key is the name of a property/element under `"sectionD"` and the value is a schema used to validate that property.

<strong>Lines #29-45: "d_10_patientParent" schema</strong>

Specifies the JSON schema for the `"d_10_patientParent"` property.

<strong>Line #30: "type": "object"</strong>

Specifies the type of `"d_10_patientParent"`, which is an object containing key-value pairs (properties).

<strong>Line #31: "properties" (d_10_patientParent)</strong>

Specifies the properties of the `"d_10_patientParent"` JSON object. It contains key-value pairs where each key is the name of a property/element under `"d_10_patientParent"` and the value is a schema used to validate that property.

<strong>Lines #32-43: "d_10_8_r_parentDrugHistory" schema</strong>

Specifies the JSON schema for the `"d_10_8_r_parentDrugHistory"` property:

<strong>Line #33: "type": "array"</strong>

Specifies the type of `"d_10_8_r_parentDrugHistory"`, which is an array containing ordered elements.

<strong>Lines #34-42: "items" (d_10_8_r_parentDrugHistory)</strong>

Specifies a single schema that will be used to validate against all items in the `"d_10_8_r_parentDrugHistory"` array.

<strong>Lines #36-41: "if" → "then"</strong>

Specifies that the evaluation of a schema (`"then"`) is dependent on the outcome of the evaluation of another schema (`"if"`). In this case, the E2B field D.10.8.r.2a is required (then) only when the E2B field D.10.8.r.2b is populated (if).

<strong>Line #36-38: "if" schema</strong>

Specifies the `"if"` schema. In this case, the schema is `"#/definitions/d_10_8_r_2b_POPULATED"`, which was defined earlier and is being referenced using the `"$ref"` keyword.

<strong>Line #39-41: "then" schema</strong>

Specifies the `"then"` schema. In this case, the schema is `"#/definitions/d_10_8_r_2a_EXISTS"` which was defined earlier and is being referenced using the `"$ref"` keyword.

#### Example 4: Case Data JSON Structure Examples

* **File Format**: N/A
* <a class="download-link " href="https://platform.veevavault.help/assets/downloads/saf-sample-global-case-data-json-schema.json" target="_blank" rel="noopener">sample-global-case-data-json-schema.json<i class="fa fa-download" aria-hidden="true"></i></a>
* <a class="download-link " href="https://platform.veevavault.help/assets/downloads/saf-sample-global-case-and-reason-omitted.json" target="_blank" rel="noopener">sample-global-case-and-reason-omitted.json<i class="fa fa-download" aria-hidden="true"></i></a>
* <a class="download-link " href="https://platform.veevavault.help/assets/downloads/saf-sample-global-case-child-data-json-schema.json" target="_blank" rel="noopener">sample-global-case-child-data-json-schema.json<i class="fa fa-download" aria-hidden="true"></i></a>
* <a class="download-link " href="https://platform.veevavault.help/assets/downloads/saf-sample-global-case-grandchild-data-json-schema.json" target="_blank" rel="noopener">sample-global-case-grandchild-data-json-schema.json<i class="fa fa-download" aria-hidden="true"></i></a>
* <a class="download-link " href="https://platform.veevavault.help/assets/downloads/saf-sample-global-localized-case-child-data-json-schema.json" target="_blank" rel="noopener">sample-global-localized-case-child-data-json-schema.json<i class="fa fa-download" aria-hidden="true"></i></a>
* <a class="download-link " href="https://platform.veevavault.help/assets/downloads/saf-sample-global-localized-case-grandchild-data-json-schema.json" target="_blank" rel="noopener">sample-global-localized-case-grandchild-data-json-schema.json<i class="fa fa-download" aria-hidden="true"></i></a>
* <a class="download-link " href="https://platform.veevavault.help/assets/downloads/saf-sample-global-transmission-json-schema.json" target="_blank" rel="noopener">sample-global-transmission-json-schema.json<i class="fa fa-download" aria-hidden="true"></i></a>

[0]: #example-expressions
[1]: #validation-query
[2]: #cases-and-submissions-logs