Date validation as per previous date entered

Hi Team,

I have my question for validation rule in DOB and another subsequent question about TB in past years.
So I want to put validation that the TB in past year entered should be more than DOB.

(For more clarity, If DOB of my patient is 01.01.2010, then my past TB entered should be less than the age of the patient, i.e. should be less than 2010.
Requesting you to kindly help on this.
Thank you.

@Priyanka, you could do it as oultined in the image shared below:

In the survey tab of your XLSForm:


Data entry screen as seen in Enketo:

Data entry screen as seen in Enketo:

Reference XLSForm:

Date Constraint Check.xlsx (8.7 KB)

Hi Kalyan!

Thank you for your reply. The code is working, the only problem is DOB question is in yyyy-dd-mm format however TB date is just yyyy input to be added manually. Any solution for this?

Hi @Kal_Lam any solution for this?

@Priyanka, did you mean one of your variables just has the YYYY (and nothing else)?

Yes thats true.

Yes, One of the variable have only year to mention manually, i.e eg 2024 (YYYY)

@Priyanka, there could be two options for you if this is your case:

  1. The user must input month as 1 and day as 1.
  2. The second option is that you will need to calculate where you will need to extract the year from the DOB and subtract it from the TB ever variable date (that only has the YYYY).

Hi Kalyan,

Thank you for the possible solutions.
I tried option 2 for extracting only year, format-date(${date}, ‘%Y’) but for some reason it’s not working.

Thank you.

Hi Kalyan,

Any updates on the query.

Thank you for your time.