Summary

This article covers a script example of checking interval (X +/- n days).

Table of Contents


Description

This script checks to make sure the Day 84 Physical Exam date is 84 plus or minus 2 days after the Day 1 Physical Exam date. The script uses the addDate command to add the Day 1 Physical Exam date with the number of days for the time window and then compares that result to the target, evdt. The “:id” comparison is needed to determine that this script should only evaluate for targets with an id that is for the Physical Exam form at Day 84. Listing dependent question paths allow the script to trigger when a dependent variable existing on another form is updated with a new value.

Script

<script scriptId="pe84Ck">
    <body>
        <s:alert>
            <s:expression>
                <s:or>
                    <s:ne>
                        <s:numberPath path=":id"/>
                        <s:numberPath path="/day84/pe2sum84.evdt:id"/>
                    </s:ne>
                    <s:not>
                        <s:isSet>
                            <s:question>
                                <s:question path="day1/pe2sum1.d1evdt"/>
                            </s:question>
                        </s:isSet>
                    </s:not>
                    <s:not>
                        <s:isSet/>
                    </s:not>
                    <s:and>
                        <s:gte>
                            <s:datePath path=":value"/>
                            <s:addDate>
                                <s:date>
                                    <s:datePath path="day1/pe2sum1.d1evdt:value"/>
                                </s:date>
                                <s:days>
                                    <s:number value="82"/>
                                </s:days>
                            </s:addDate>
                        </s:gte>
                        <s:lte>
                            <s:datePath path=":value"/>
                            <s:addDate>
                                <s:date>
                                    <s:datePath path="day1/pe2sum1.d1evdt:value"/>
                                </s:date>
                                <s:days>
                                    <s:number value="86"/>
                                </s:days>
                            </s:addDate>
                        </s:lte>
                    </s:and>
                </s:or>
            </s:expression>
            <s:correction>
                <s:string value="optional"/>
            </s:correction>
            <s:text>
                <s:string value="Day 84 date is not the expected number of days (84 plus
                 or minus 2 days) after Day 1.  Please verify dates."/>
            </s:text>
        </s:alert>
</body>
<target typeId="evdt" when="preprocess" shouldReconcile="true"/>
<dependent path="day1/pe2sum1.d1evdt"/>
</script>



Need more help?

Please visit the Fountayn Contact Information page.