Setting the default value of date questions using the sum of two other variables

Dear CommCare users,

I am trying to set a default value for questions that ask for a date. This
date question is within a repeat group, and I would like the default value
to be sum of the repeat count number, and the date inputted in a different
question (i.e. the patient’s date of admission).

So far, I have been able to get the default value to display the date of
the patient’s admission by setting the default value to:
date(#form/form_id/hiddenValue_id); where hiddenValue_id is:
int(#form/form_id/dateQuestion_id). I have also been able to calculate the
repeat count using: count(#form/form_id/repeat_id).

So to reiterate the question: how do I set the default value of my date
question to the sum of the repeat count and the date of the patient’s
admission?

Thanks in advance,

Dominic

Hi Dominic,

I will let my colleagues chime in here if I’m incorrect but I’m not
confident what you are describing is possible. My understanding is that
default values are calculated when a form is opened and are not
recalculated so I’m not sure that one could be set by data enteried in a
repeat group in the form. You can see a more detailed discussion here:
https://groups.google.com/d/msg/commcare-users/aKkD2Hr97Dc/8XXFXy6FBQAJ

Jeremy

··· On Tue, Sep 6, 2016 at 3:02 PM, Dominic Wang wrote:

Dear CommCare users,

I am trying to set a default value for questions that ask for a date. This
date question is within a repeat group, and I would like the default value
to be sum of the repeat count number, and the date inputted in a different
question (i.e. the patient’s date of admission).

So far, I have been able to get the default value to display the date of
the patient’s admission by setting the default value to: date(#form/form_id/hiddenValue_id);
where hiddenValue_id is: int(#form/form_id/dateQuestion_id). I have also
been able to calculate the repeat count using:
count(#form/form_id/repeat_id).

So to reiterate the question: how do I set the default value of my date
question to the sum of the repeat count and the date of the patient’s
admission?

Thanks in advance,

Dominic


You received this message because you are subscribed to the Google Groups
"commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to commcare-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Jeremy Wacksman
Dimagi http://www.dimagi.com, Inc.

Hi Jeremy,

Thank you yes that clears things up. I am a little disappointed there is no
method of doing this, but it seems that the default values are
unfortunately quite restricted. Thanks again for your help.

All the best,
Dominic

··· On Tuesday, September 6, 2016 at 3:02:08 PM UTC-4, Dominic Wang wrote: > > Dear CommCare users, > > > I am trying to set a default value for questions that ask for a date. This > date question is within a repeat group, and I would like the default value > to be sum of the repeat count number, and the date inputted in a different > question (i.e. the patient’s date of admission). > > > So far, I have been able to get the default value to display the date of > the patient’s admission by setting the default value to: > date(#form/form_id/hiddenValue_id); where hiddenValue_id is: > int(#form/form_id/dateQuestion_id). I have also been able to calculate the > repeat count using: count(#form/form_id/repeat_id). > > > So to reiterate the question: how do I set the default value of my date > question to the sum of the repeat count and the date of the patient’s > admission? > > > Thanks in advance, > > Dominic > >

Hi Jeremy,

Thanks for your reply!

This comes as a bit of a surprise to me since I have been able to set the
the default value of a question to a value the user inputs. Specifically,
the user inputs a date of admission for the patient, then that date becomes
the default date that appears in subsequent questions (which also ask for a
date).

Dominic

··· On Saturday, September 10, 2016 at 10:54:47 AM UTC-4, Jeremy Wacksman wrote: > > Hi Dominic, > > I will let my colleagues chime in here if I'm incorrect but I'm not > confident what you are describing is possible. My understanding is that > default values are calculated when a form is opened and are not > recalculated so I'm not sure that one could be set by data enteried in a > repeat group in the form. You can see a more detailed discussion here: > https://groups.google.com/d/msg/commcare-users/aKkD2Hr97Dc/8XXFXy6FBQAJ > > Jeremy > > On Tue, Sep 6, 2016 at 3:02 PM, Dominic Wang <domini...@gmail.com > wrote: > >> Dear CommCare users, >> >> >> I am trying to set a default value for questions that ask for a date. >> This date question is within a repeat group, and I would like the default >> value to be sum of the repeat count number, and the date inputted in a >> different question (i.e. the patient’s date of admission). >> >> >> So far, I have been able to get the default value to display the date of >> the patient’s admission by setting the default value to: >> date(#form/form_id/hiddenValue_id); where hiddenValue_id is: >> int(#form/form_id/dateQuestion_id). I have also been able to calculate the >> repeat count using: count(#form/form_id/repeat_id). >> >> >> So to reiterate the question: how do I set the default value of my date >> question to the sum of the repeat count and the date of the patient’s >> admission? >> >> >> Thanks in advance, >> >> Dominic >> >> -- >> You received this message because you are subscribed to the Google Groups >> "commcare-users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to commcare-user...@googlegroups.com . >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > Jeremy Wacksman > Dimagi , Inc. > >

Hi Dominic,

I should clarify that repeat groups are a bit different - those default
values are set when each repeat group is created, not when the form is open

  • does that explain the behavior you are seeing? If the question you are
    trying to set a default for is in the repeat group along with the group
    that populates it, it may be because the default does not get reset after
    the repeat group is created.

Jeremy

··· On Sun, Sep 11, 2016 at 10:41 AM, Dominic Wang wrote:

Hi Jeremy,

Thanks for your reply!

This comes as a bit of a surprise to me since I have been able to set the
the default value of a question to a value the user inputs. Specifically,
the user inputs a date of admission for the patient, then that date becomes
the default date that appears in subsequent questions (which also ask for a
date).

Dominic

On Saturday, September 10, 2016 at 10:54:47 AM UTC-4, Jeremy Wacksman wrote:

Hi Dominic,

I will let my colleagues chime in here if I’m incorrect but I’m not
confident what you are describing is possible. My understanding is that
default values are calculated when a form is opened and are not
recalculated so I’m not sure that one could be set by data enteried in a
repeat group in the form. You can see a more detailed discussion here:
https://groups.google.com/d/msg/commcare-users/aKkD2Hr97Dc/8XXFXy6FBQAJ

Jeremy

On Tue, Sep 6, 2016 at 3:02 PM, Dominic Wang domini...@gmail.com wrote:

Dear CommCare users,

I am trying to set a default value for questions that ask for a date.
This date question is within a repeat group, and I would like the default
value to be sum of the repeat count number, and the date inputted in a
different question (i.e. the patient’s date of admission).

So far, I have been able to get the default value to display the date of
the patient’s admission by setting the default value to:
date(#form/form_id/hiddenValue_id); where hiddenValue_id is:
int(#form/form_id/dateQuestion_id). I have also been able to calculate
the repeat count using: count(#form/form_id/repeat_id).

So to reiterate the question: how do I set the default value of my date
question to the sum of the repeat count and the date of the patient’s
admission?

Thanks in advance,

Dominic


You received this message because you are subscribed to the Google
Groups “commcare-users” group.
To unsubscribe from this group and stop receiving emails from it, send
an email to commcare-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Jeremy Wacksman
Dimagi http://www.dimagi.com, Inc.


You received this message because you are subscribed to the Google Groups
"commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to commcare-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.