episphere / quest

experimenting with the idea of a questionnaire markup
https://episphere.github.io/quest/
2 stars 11 forks source link

Year Moved Out, for each home in Module 4 #415

Closed huip-ims closed 1 year ago

huip-ims commented 1 year ago

@danielruss Hi Daniel – For each reported home, we are trying to add a check for year moved out. Currently, the MIN check is set at birth year using expression “difference(difference(#currentYear,isDefined(AGE,age)),1)”. However, this check will allow a participant to enter a year moved out prior to year moved in. How would you code a MIN check to see first if year moved out is at least year moved in (i.e., HOMEMOVEIN1) if it exists, otherwise year moved out is at least birth year? Note that HOMEMOVEIN1 does not require a response, so it could have a null value. For reference, see HOMEMOVEIN1 & HOMEMOVEOUT1 in Module 4.

danielruss commented 1 year ago

@huip-ims try this...

min=valueOrDefault("HOMEMOVEIN1",#currentYear-valueOrDefault("AGE","age",100))

What is it doing? If HOMEMOVEIN1 exists, HOMEMOVEOUT must be at least HOMEMOVEIN1. If it does not exist, it is the currentYear - (the AGE, or age if AGE does not exist, or 100 if neither AGE or age exist)

danielruss commented 1 year ago

Try this....

[YIN1] Year 1 |__|__|min=1970 max=2020|

[YOUT] Year 2 |__|__|min=valueOrDefault('YIN1',#currentYear-valueOrDefault('AGE','age',100))|
danielruss commented 1 year ago

If you MUST have lived in your place at least 1 year... notice the +1 (but -1 to the currentYear)

[YIN1] Year 1 |__|__|min=1970 max=2020|

[YOUT] Year 2 |__|__|min=valueOrDefault('YIN1',#currentYear-1-valueOrDefault('AGE','age',100))+1|
danielruss commented 1 year ago

@huip-ims ok to close?

huip-ims commented 1 year ago

Yes, thanks Daniel.