Unable to pull a date into XLSform and then use decimal-date-time()

1. What is the problem? Be very detailed.

We are working on a project which includes repeated anthropometric measures of infants across multiple time periods. We are currently developing a draft version of the form which will allow users to record these measurements. At our company we have developed a data platform system that can allow us to work with ODK forms using essentially a case management system. Therefore we will have CSV files providing information about the children and mothers for which new measurements are being recorded.

Our issue is that we need to supply the ODK form with the child's date of birth as this is necessary for calculating measures such as Z-scores for the childs height-for-age, weight-for-age etc. Therefore we need to calculate the difference between their date of birth and the date of measurement in days. The date of birth would preferably be pulled into the form using a pulldata(). However, when we try to do this, later performing decimal-date-time() on that child's date of birth, the form fails and does not even deploy.

We pull the date in using (${child_dob_b}) : pulldata('children', 'dob', 'id', ${child_id})
It is coalesced with a user inputted date if the child is new to the study (${child_dob}: coalesce(${child_dob_a},${child_dob_b})
We calculate the age in days (${age_days}) using: round(decimal-date-time(${dom})-decimal-date-time(${child_dob}))

Instead when trying to validate we receive the following error. 'children' being the name of the csv from which the date of birth is pulled. We do not fully understand why this would happen.

image

2. What app or server are you using and on what device and operating system? Include version numbers.

We intend to use ODK collect (Most up to date when collection starts hopefully) from KoboToolBox as the server. We cannot yet say exactly what devices the data would collected on.

3. What you have you tried to fix the problem?

format-date on the pulled in date did not work, nor specifying this as a string before trying format-date.

There is nothing else called children in the xslform to avoid confusion.

4. What steps can we take to reproduce the problem?

Try to pull an ISO formatted date into an ODK form then try to subtract that date from a user inputted date to get the difference in number of days. That is the crux of the issue but it is preventing the form from even being able to deploy on any server.

5. Anything else we should know or have? If you have a test form or screenshots or logs, attach below.

All dates in the csv are ISO formatted (e.g. 2021_09_29)

Hi @alex_thomson

Welcome to the getODK community and forum. When you get a chance please introduce yourself. You are encouraged to use a real picture of yourself as your avatar

Please have a look at the pre-loading csv manual

Are you in a position to share the form or subsection of the form and CSV file you are pulling data from?

Hi Ronald,

Believe we may have fixed the issue through other means. Seems that if we store the date in the csv as number of days since Jan 1 1970 (unix epoch) then we can treat the date in the same way as if we had performed a decimal-date-time() on the answer to a date question. Thereby cutting out the middle man as it were. We haven't tested to be sure but the form is at least deployable now.

Alex