Creating a counter on a follow up form


We have been struggling to create a form counter for our follow up form for quite some time. We’ve been reading the advice on the forum; however, with every option we try, the value for the form number will either be nonexistent or 1.

We are developing an application to document the care of malnourished children by community nurses, and it’s essential for a form counter to be available to document how many times the patient has been seen, as well tying the visit count to certain questions (e.g. on visit 4, vitamin A and deworming is due).

We’ve tried using the “coalesce” formula from the wiki commcare “incrementing a counter” as well as ideas posted on this forum.

We have prev_visit_count and visit_count as our two hidden figures… but are completely stuck. This is also somehow time sensitive.

What we do a simple workaround is to order based on the timestamps and than create a index on that. But we do that outside Commcare.
If you would need the info in Commcare itself and based on what you describe above. I guess you would need to write a counter to each case characteristics.

  1. when you register a case make a hidden figure with value 0 or 1 (depending on where you want to start counting). Make sure to write this value to the case characteristics
  2. when opening a follow up form recall the case characteristic counter value (e.g. as prev_visit_count)
  3. calculate new count by prev count + 1 and write to case characteristics.

Note: Only be aware that if there would be a second followup form submitted before the first followup form was synced to the server the counting is not working.

Okay we will also try this method, and see what happens within the commcare system. If not will investigate other options, like doing a workaround from outside of commcare. Thanks for the response! I will let you know if it doesn’t work.

The idea of using hidden variables and using case property will work. But you have to use the Case Management. Becuase passing value between forms is possible only through Case Poperties. We are using it regularly

Thanks for the reassurance. I think the issue was sometimes we accidentally used “forms” instead of “cases” and that is what confused the system. But we cleared the forms up and it’s working now. Thanks for your input!