Summary

This article covers a script example of checking time intervals.

Table of Contents


Description

This script fires an alert if the Day 28 Physical Exam date is not 27 days after the Day 1 Physical Exam date. It uses the “:id” attribute as a way to check the id associated with the alias of the question. This is how the scripting language knows exactly what question to fire the alert on in case the same form is reused multiple times. 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="pe28Ck">
    <body>
        <s:alert>
            <s:expression>
                <s:or>
                    <s:ne>
                        <s:numberPath path=":id"/>
                        <s:numberPath path="/day28/pe2sum28.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:eq>
                        <s:datePath path=":value"/>
                        <s:addDate>
                            <s:date>
                                <s:datePath path="/day1/pe2sum1.d1evdt:value"/>
                            </s:date>
                            <s:days>
                                <s:number value="27"/>
                            </s:days>
                        </s:addDate>
                    </s:eq>
                </s:or>
            </s:expression>
            <s:correction>
                <s:string value="optional"/>
            </s:correction>
            <s:text>
                <s:string value="Day 28 date is not the expected number of 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.