Having difficulty with functions

Hi, everyone.

In module one of my application, I have formulario de registo (registration form) where I register patients as either apoio ou reforco a adesão: apoio ou reforco a adesão are types of patients. When updating the registration in actualizar registo (update registration), a patient registered as apoio can after some time change to reforco a adesão and vice-versa.

In module II, I follow up with patients registered as apoio in the form: visita de apoio - A patient registered as apoio receives 2nd visit 60 days after first visit.

Here I have a hidden value that calculate the number of days for the second visit:

Apoio: Data da proxima visita (next_visit_date_apoio):

if(format-date(date(today() + 60), “%a”) = “Sun” or format-date(date(today() + 60), “%a”) = “Sat”, date(today() + 62), date(today() + 62))

Patients registered as reforco a adesão are followed up in the form: reforco a adesão - they receive a 2nd visit 37 days after first visit.

Here I have another hidden value that calculate the number of days for the second visit

Reforco a adesao: Data da proxima visita(next_visit_date_adesao):

if(format-date(date(today () + 37), “%a”) = “Sun” or format-date(date(today() + 37), “%a”) = “Sat”, date(today() + 37), date(today() + 39))

I have another hidden value: proxima_visita

proxima_visita = cond(tipo_de caso="apoio",next_visit_date_apoio, tipo_de_caso="next_visit_date_adesao", "") which is in the case list.

In the image below I have registered Agira Chitsipa first as apoio (formulario de rgisto) and it shows that the 2nd visit will be after 37 days which is ok, but when Agira Chitsipa changes to reforco a adesao in actualizar formulario, it still shows 37 days but it should change to 60 days.
image

Iam looking for ideas and any suggestions on how I can configure this are welcome.

Thanks in advance

Hi,

It sounds like there are a number of conditions and sources for confusion in your form.

Have you tried inspecting and testing how these expressions are working with a tool like web apps data preview? It can make it much easier to understand the inner workings of the expressions

-Clayton

Hi, Clayton.

What I see in my app building window is only the app summary. I think my description was not clear.

To summarize, what I want is that when CASE A (apoio) - whose second visit is after 60 days - changes to CASE B (reforco a adesao), the next_visit_date (which is a hidden value in the case detail) should show 37 days which are are the days for the case B second visit, i.e it shouldn't still show 60 days because there has been a case update.

I agree there must be confusion on my approach. Iam wondering if you could help me sort this out. I have deleted the third hidden value and there are only the hidden values below which work fine.

Apoio: if(format-date(date(today() + 60), “%a”) = “Sun” or format-date(date(today() + 60), “%a”) = “Sat”, date(today() + 62), date(today() + 62))

Reforco a adesao: if(format-date(date(today () + 37), “%a”) = “Sun” or format-date(date(today() + 37), “%a”) = “Sat”, date(today() + 37), date(today() + 39))