Summary
This edit check verifies that for a medical history form, the chosen value of ongoing is consistent with end date.INSERT VIDEO HERE
<iframe width="640" height="336" src="https://www.loom.com/embed/590ce3bdd7c94b90a4ad9bfcdc1dc2a5%22 frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
Formal Expression
Code Block |
---|
var ONGOING_SAS_FIELD_NAME = 'MHONGO'; var endDate = itemJson.item.value; var repeatKey = itemJson.item.itemGroupRepeatKey; logger('endDate '+endDate); logger('repeatKey '+repeatKey); var ongoingItem = findFirstItemByName(formJson, null, ONGOING_SAS_FIELD_NAME, repeatKey); var ongoing = ongoingItem.value; logger('ongoing '+ongoing); var valid = true; if (ongoing.equalsIgnoreCase('true')) { if (endDate) { customErrorMessage('There can not be an end date if ongoing is true'); valid = false; } } else if (ongoing.equalsIgnoreCase('false')) { if (!endDate) { customErrorMessage('There must be an end date if ongoing is false'); valid = false; } } else { logger('unexpected ongoing value of ['+ongoing+']'); } return valid; |
...