Skip to content

Adding a validator to the Inspector

bill edited this page Jan 16, 2020 · 1 revision

Adding a validator to the Inspector

This discusses adding a validator to the Inspector which assumes there is already an event available in the Proxy logs. This is different from writing a validator where you must first go out and fetch the resource to be validated. That task is described here.

Inspector based validators are written in TestScript and FHIRPATH. They are written in the style of a client test, the TestScript contains no actions, only assertions.

How the existing PDB Validations works

This option is present in the event viewer and serves as the prototype for this type of validator.

Right now the display logic is a little messy and needs refactoring. It currently uses multiple booleans instead of a single variable and switch statement. This code begins at line 46 in LogItem.vue.

Overall, the logic offering selection choices of Request, Response, Inspect, and PDB Validations. I would think that other specialty validations would be listed after PDB Validation on the same line.

The logic is broken up into two pieces: selection and display. Selection sets a boolean and display uses the boolean to display some detail. There are multiple booleans.

Selection logic

        <!-- Inspect Validations -->
        <div class="vdivider"></div>
        <div>
            <span v-bind:class="{
                    selected: displayInspector,
                    'not-selected': !displayInspector
                    }"
                  @click="displayRequest = false; displayResponse = false; displayInspector = true; displayValidations = false">
                Inspect
            </span>
            <div class="divider"></div>
            <span v-bind:class="{
                selected: displayValidations,
                'not-selected': !displayValidations
                }" @click="displayRequest = false; displayResponse = false; displayInspector = false; displayValidations = true">
                PDB Validations
            </span>
        </div>

The variables displayInspector and displayValidations are used to trigger the display logic.

Display logic

    <div v-if="!displayInspector && !displayValidations && getEvent()">
        <div v-if="displayRequest" class="event-details">
                        <pre>{{ requestHeader }}
                        </pre>
            <pre>{{ requestBody }}</pre>
        </div>
        <div v-if="!displayRequest" class="event-details">
                        <pre>{{ responseHeader }}
                        </pre>
            <pre>{{responseBody}}</pre>
        </div>
    </div>
    <div v-if="displayInspector" class="request-response">
                <log-analysis-report
                        :session-id="sessionId"
                        :channel-id="channelId"
                        :event-id="eventId"></log-analysis-report>
    </div>
    <div v-if="displayValidations" class="request-response">
        <eval-details
            :session-id="sessionId"
            :channel-id="channelId"
            :event-id="eventId"
            :test-id="'bundle_eval'"
            :test-collection="'Internal'"
            :run-eval="true"></eval-details>
    </div>

The displayValidations logic uses the Vue component EvalDetails.vue (here) for the detailed display.

It is invoked by

<eval-details
            :session-id="sessionId"
            :channel-id="channelId"
            :event-id="eventId"
            :test-id="'bundle_eval'"
            :test-collection="'Internal'"
            :run-eval="true"></eval-details>

The parameters sessionId, channelId, eventId are easy to understand. TestId and testCollection identify the test to be evaluated (actually a client-type TestScript). For now runEval is always true.

Adding new validation options

This involves no server code. The selection and display areas of EvalDetails.vue must be updated with the new linkage and the client test (TestScript.xml) must be written. I suggest that all on-screen validators be put in the Internal test collection.

Clone this wiki locally