I am authoring a survey with Survey123 XLSForms and I cannot quite get where I want with choice filters and the relevant field.
The form has a question, "date_drit_test" that the user can leave blank (if no test occurred) or fill out (if a test occurred):
If the user selects a date, then another question, 'drit_test_result' should appear to indicate test results (which was hidden if no date was selected):
However, I do not want any null values in the 'drit_test_result' column. If a user does not select a date for the DRIT test, I want the value of 'drit_test_result' to be filled with "Not tested"/"NT".
I've got everything working save the last bit. I also suspect I could make my choice filter without the "helper" column 'date_drit_result' but couldn't figure out how to do it - any thoughts there?
Relevant worksheets & fields:
survey worksheet | | | | | |
type | name | label | calculation | choice_filter | relevant |
date | date_drit_test | Date of DRIT test | | | |
hidden | date_drit_result | Was there a DRIT test date? | if(string-length(${date_drit_test})>0, "test_date_present", "test_date_absent") | | |
select_one test_result | drit_test_result | DRIT test result | | test_filter=${date_drit_result} | string-length(${date_drit_test})>0 |
| | | | | |
choices worksheet | | | | | |
list_name | name | label | test_filter | | |
test_result | INC | Inconclusive | test_date_present | | |
test_result | N | Negative | test_date_present | | |
test_result | P | Positive | test_date_present | | |
test_result | NT | Not Tested | test_date_absent | | |
test_result | RT | Retested | test_date_present | | |
test_result | F | Failed (PCR) | test_date_present | | |