Pre-load case data in text question input bar?

Hi All,

I currently have a “register” form that collects data about a patient, and
an “edit” form that would allow the user to edit that case data.
The “edit” form contains some hidden values that holds the case data of a
previous registered patient as well as text questions that will allow the
user to update that data.

What I would like to know can you pre-load that hidden value (case data)
inside a text question input bar?

I have tried setting the Default Data Value to “/data/prev_name” underneath
the Advanced options in form builder, but nothing displays when i run the
application. When I set the Default Data Value to a normal random string,
it perfectly displays when the applications runs.

Does anyone know if this is possible or are there any alternatives to
editing data from a form?

Thanks

Hi Simon,

Thanks for the reply.
I tried your solution, but it does not exactly worked the way I would have
liked. What I would like to do is display the “value” inside the text box
so the user wouldn’t be able to re-enter/re-register the “value” while
editing the data.

I attached an image that might help get the message across easier.

Thanks

··· On Sunday, 15 September 2013 12:38:00 UTC+2, Sheldon De Villiers wrote: > > Hi All, > > > I currently have a "register" form that collects data about a patient, and > an "edit" form that would allow the user to edit that case data. > The "edit" form contains some hidden values that holds the case data of a > previous registered patient as well as text questions that will allow the > user to update that data. > > What I would like to know can you pre-load that hidden value (case data) > inside a text question input bar? > > I have tried setting the Default Data Value to "/data/prev_name" > underneath the Advanced options in form builder, but nothing displays when > i run the application. When I set the Default Data Value to a normal random > string, it perfectly displays when the applications runs. > > Does anyone know if this is possible or are there any alternatives to > editing data from a form? > > > Thanks > > >

Hi Sheldon

This is indeed possible and quite easy in fact. What you need to do is
reference the hidden value in an ‘output’ directive like this:

There is a wiki page with more detail here:
https://confluence.dimagi.com/display/commcarepublic/Hidden+Values+Tutorial+Part+4%3A+Displaying+an+Output

Cheers
Simon

··· On Sun, Sep 15, 2013 at 12:38 PM, Sheldon De Villiers <shelo.devil@gmail.com wrote:

Hi All,

I currently have a “register” form that collects data about a patient, and
an “edit” form that would allow the user to edit that case data.
The “edit” form contains some hidden values that holds the case data of a
previous registered patient as well as text questions that will allow the
user to update that data.

What I would like to know can you pre-load that hidden value (case data)
inside a text question input bar?

I have tried setting the Default Data Value to "/data/prev_name"
underneath the Advanced options in form builder, but nothing displays when
i run the application. When I set the Default Data Value to a normal random
string, it perfectly displays when the applications runs.

Does anyone know if this is possible or are there any alternatives to
editing data from a form?

Thanks


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/groups/opt_out.


Simon Kelly
Senior Engineer | Dimagi South Africa

Hi Jeremy,

Thank you so much for your help, works just the way I wanted.

There is one more thing I would like to know. Lets say a patient is
identified by a unique key (e.g. Patient Number), and has already been
registered before. When I register a different patient with the same unique
key it should return an error message.
Is there a way to validate that a patient does not register more than once?

Thanks

··· On Sunday, 15 September 2013 12:38:00 UTC+2, Sheldon De Villiers wrote: > > Hi All, > > > I currently have a "register" form that collects data about a patient, and > an "edit" form that would allow the user to edit that case data. > The "edit" form contains some hidden values that holds the case data of a > previous registered patient as well as text questions that will allow the > user to update that data. > > What I would like to know can you pre-load that hidden value (case data) > inside a text question input bar? > > I have tried setting the Default Data Value to "/data/prev_name" > underneath the Advanced options in form builder, but nothing displays when > i run the application. When I set the Default Data Value to a normal random > string, it perfectly displays when the applications runs. > > Does anyone know if this is possible or are there any alternatives to > editing data from a form? > > > Thanks > > >

Hello, Sheldon,

It sounds like you want to “load” the previous value of a question into the
questions in your “edit” form. For reference, the basic concept for an edit
form is described here:
https://help.commcarehq.org/display/commcarepublic/General+Workflow+Suggestions

You will need to make sure that you save the answer to the case the first
time it is asked (i.e. in the registration form), which it sounds like you
are already doing. Then, in the “edit” form, you will load the case
property into the question. The concept of loading case properties into a
form is described here:
https://help.commcarehq.org/display/commcarepublic/Advanced+Case+Management+Tutorial+Part+3+-+Loading+Data+from+the+Case.
The
only difference from what you are currently doing is that you will be
loading the case data directly into the actual questions, not just the
hidden values. This will “pre-populate” the question with the answer from
the case data. All of this configuration is done on the case management tab
of the form settings, rather than within the form itself.

Hope that helps!

Jeremy

··· On Sun, Sep 15, 2013 at 8:35 AM, Sheldon De Villiers wrote:

Hi Simon,

Thanks for the reply.
I tried your solution, but it does not exactly worked the way I would have
liked. What I would like to do is display the “value” inside the text box
so the user wouldn’t be able to re-enter/re-register the “value” while
editing the data.

I attached an image that might help get the message across easier.

Thanks

On Sunday, 15 September 2013 12:38:00 UTC+2, Sheldon De Villiers wrote:

Hi All,

I currently have a “register” form that collects data about a patient,
and an “edit” form that would allow the user to edit that case data.
The “edit” form contains some hidden values that holds the case data of a
previous registered patient as well as text questions that will allow the
user to update that data.

What I would like to know can you pre-load that hidden value (case data)
inside a text question input bar?

I have tried setting the Default Data Value to "/data/prev_name"
underneath the Advanced options in form builder, but nothing displays when
i run the application. When I set the Default Data Value to a normal random
string, it perfectly displays when the applications runs.

Does anyone know if this is possible or are there any alternatives to
editing data from a form?

Thanks


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/groups/opt_out.


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

Hi Sheldon,

Unfortunately with a tool that works offline like CommCare does, there’s
really no way to 100% guarantee you are entering a Patient Number that has
never been entered before. If you’re offline, you can’t check against a
case that a different mobile worker has just created somewhere else.

However, CommCare can check the Patient Number against all the cases open
on your phone. The logic below is looking at all the cases in your case
list and counting the number that have a case property "patient_number"
that is the same as the current question, “/data/patient_number”. The count
must equal 0. You can enter the logic below into the validation condition
for patient number:

count(instance(‘casedb’)/casedb/case[patient_number =
/data/patient_number]) = 0

Hope this helps!
Amelia

··· On Mon, Sep 16, 2013 at 6:31 AM, Sheldon De Villiers wrote:

Hi Jeremy,

Thank you so much for your help, works just the way I wanted.

There is one more thing I would like to know. Lets say a patient is
identified by a unique key (e.g. Patient Number), and has already been
registered before. When I register a different patient with the same unique
key it should return an error message.
Is there a way to validate that a patient does not register more than once?

Thanks

On Sunday, 15 September 2013 12:38:00 UTC+2, Sheldon De Villiers wrote:

Hi All,

I currently have a “register” form that collects data about a patient,
and an “edit” form that would allow the user to edit that case data.
The “edit” form contains some hidden values that holds the case data of a
previous registered patient as well as text questions that will allow the
user to update that data.

What I would like to know can you pre-load that hidden value (case data)
inside a text question input bar?

I have tried setting the Default Data Value to "/data/prev_name"
underneath the Advanced options in form builder, but nothing displays when
i run the application. When I set the Default Data Value to a normal random
string, it perfectly displays when the applications runs.

Does anyone know if this is possible or are there any alternatives to
editing data from a form?

Thanks


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/groups/opt_out.

Hi Amelia,

I would like to try to use this to prevent duplicated ID numbers (and since
they can only be duplicated on one phone and not across phones this should
work for me).

I copied in the code you pasted below and changed it to mother_unique_id
instead of patient_number so now I have the following in my validation
condition for a question that occurs after the case has been created:

count(instance(‘casedb’)/casedb/case[mother_unique_id
=/data/mother_unique_id]) = 0

However, on testing on the phone I get the following error message:

There is a bug in one of your form’s XPath Expressions. XPath evaluation:
Instance referenced by (casedb)/casedb/case does not exist

Any idea what I’ve done wrong?

Thanks

Jenny

··· On Monday, September 16, 2013 10:42:26 PM UTC+1, Amelia Sagoff wrote: > > Hi Sheldon, > > Unfortunately with a tool that works offline like CommCare does, there's > really no way to 100% guarantee you are entering a Patient Number that has > never been entered before. If you're offline, you can't check against a > case that a different mobile worker has just created somewhere else. > > However, CommCare can check the Patient Number against all the cases open > on your phone. The logic below is looking at all the cases in your case > list and counting the number that have a case property "patient_number" > that is the same as the current question, "/data/patient_number". The count > must equal 0. You can enter the logic below into the validation condition > for patient number: > > count(instance('casedb')/casedb/case[patient_number = > /data/patient_number]) = 0 > > Hope this helps! > Amelia > > >

Hi Jenny,

Unfortunately you need to do a bit of hand editing of your form to add an
special block that will let you access the CaseDB.

Open the form XML (through Tools -> Edit Source XML) and then add the
following line to your form above the existing instance block.

Hope this fixes the issue.

Thanks,
Sheel

··· On Mon, Sep 30, 2013 at 11:30 AM, Jennifer Hall wrote:

Hi Amelia,

I would like to try to use this to prevent duplicated ID numbers (and
since they can only be duplicated on one phone and not across phones this
should work for me).

I copied in the code you pasted below and changed it to mother_unique_id
instead of patient_number so now I have the following in my validation
condition for a question that occurs after the case has been created:

count(instance(‘casedb’)/casedb/case[mother_unique_id
=/data/mother_unique_id]) = 0

However, on testing on the phone I get the following error message:

There is a bug in one of your form’s XPath Expressions. XPath evaluation:
Instance referenced by (casedb)/casedb/case does not exist

Any idea what I’ve done wrong?

Thanks

Jenny

On Monday, September 16, 2013 10:42:26 PM UTC+1, Amelia Sagoff wrote:

Hi Sheldon,

Unfortunately with a tool that works offline like CommCare does, there’s
really no way to 100% guarantee you are entering a Patient Number that has
never been entered before. If you’re offline, you can’t check against a
case that a different mobile worker has just created somewhere else.

However, CommCare can check the Patient Number against all the cases open
on your phone. The logic below is looking at all the cases in your case
list and counting the number that have a case property "patient_number"
that is the same as the current question, “/data/patient_number”. The count
must equal 0. You can enter the logic below into the validation condition
for patient number:

count(instance(‘casedb’)/**casedb/case[patient_number =
/data/patient_number]) = 0

Hope this helps!
Amelia


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/groups/opt_out.


Sheel Shah
Project Manager | Dimagi India
t: +91 1146704670 | m: +91 9560187282

Thanks Sheel, it’s working now.

Jenny

··· On Monday, September 30, 2013 4:59:15 PM UTC+1, Sheel Shah wrote: > > Hi Jenny, > > Unfortunately you need to do a bit of hand editing of your form to add an > special block that will let you access the CaseDB. > > Open the form XML (through Tools -> Edit Source XML) and then add the > following line to your form above the existing instance block. > > > > > > > Hope this fixes the issue. > > > > Thanks, > Sheel > > > > On Mon, Sep 30, 2013 at 11:30 AM, Jennifer Hall <jenny_...@yahoo.co.uk wrote: > >> Hi Amelia, >> >> I would like to try to use this to prevent duplicated ID numbers (and >> since they can only be duplicated on one phone and not across phones this >> should work for me). >> >> I copied in the code you pasted below and changed it to mother_unique_id >> instead of patient_number so now I have the following in my validation >> condition for a question that occurs after the case has been created: >> >> count(instance('casedb')/casedb/case[mother_unique_id >> =/data/mother_unique_id]) = 0 >> >> However, on testing on the phone I get the following error message: >> >> There is a bug in one of your form's XPath Expressions. XPath >> evaluation: Instance referenced by (casedb)/casedb/case does not exist >> >> Any idea what I've done wrong? >> >> Thanks >> >> Jenny >> >> >> On Monday, September 16, 2013 10:42:26 PM UTC+1, Amelia Sagoff wrote: >>> >>> Hi Sheldon, >>> >>> Unfortunately with a tool that works offline like CommCare does, there's >>> really no way to 100% guarantee you are entering a Patient Number that has >>> never been entered before. If you're offline, you can't check against a >>> case that a different mobile worker has just created somewhere else. >>> >>> However, CommCare can check the Patient Number against all the cases >>> open on your phone. The logic below is looking at all the cases in your >>> case list and counting the number that have a case property >>> "patient_number" that is the same as the current question, >>> "/data/patient_number". The count must equal 0. You can enter the logic >>> below into the validation condition for patient number: >>> >>> count(instance('casedb')/**casedb/case[patient_number = >>> /data/patient_number]) = 0 >>> >>> Hope this helps! >>> Amelia >>> >>> >>> -- >> 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/groups/opt_out. >> > > > > -- > Sheel Shah > Project Manager | Dimagi India > t: +91 1146704670 | m: +91 9560187282 > > >