Case list filtering

Hi,

Can anyone help me understand why my case list filter is not working?

pn_complete='yes' and pn6_complete_mother!='yes' and
(today()>=baby_dob+183) and today()<=baby_dob+274)) or (miscarriage='yes'
and today()>=(date_pn1+120))

(which should mean that the postnatal form has been completed but the 6
month postnatal form has not been completed and the baby is 6-9 months old
or there was a miscarriage and it is at least 4 months since the woman was
last visited.)

I'm wondering if it's because I'm using dates, but according to wiki help
pages for case filtering you just use the property as is (they don't
explicitly say that but it is what is in the example). I did try this as
well

pn_complete='yes' and pn6_complete_mother!='yes' and
(today()>=(date(baby_dob)+183) and today()<=(date(baby_dob)+274)) or
(miscarriage='yes' and today()>=(date(date_pn1)+120))

but it also doesn't work - with both I end up with no cases showing at all!

I have 'reported an issue' from the web page but that was almost a week ago
and I haven't heard anything so if anyone has any ideas that would be great!

Thanks

Jenny

Hi Jenny,

You should use the latter option you suggested (casting the baby_dob and
date_pn1 to date). To be safe your may want to wrap the entire
calculation inside a date function. So instead of using (date(baby_dob) +
183)
, use *date(date(baby_dob) + 183) *for any places where you're using a
date calculation.

It also looks like you're missing a set of brackets in your filter.
Currently you have (to paraphrase):
pn_complete and pn_6_not_complete and (baby_between_6_9_months) or
(baby_deceased and no_mother_pn1_visit)

You want:
pn_complete and pn_6_not_complete and ((baby_between_6_9_months) or
(baby_deceased and no_mother_pn1_visit))

So your statement would become:
pn_complete='yes' and pn6_complete_mother!='yes' and
((today()>=date(date(baby_dob)+183) and today()<=date(date(baby_dob)+274))
or (miscarriage='yes' and today()>=date(date(date_pn1)+120)))

If possible, can you check your Case List (Reports tab -> Case List) to
verify that you cases that meet the above criteria with the case properties
correctly set?

Thanks,
Sheel

··· On Tue, Feb 18, 2014 at 7:54 AM, Jennifer Hall wrote:

Hi,

Can anyone help me understand why my case list filter is not working?

pn_complete='yes' and pn6_complete_mother!='yes' and
(today()>=baby_dob+183) and today()<=baby_dob+274)) or (miscarriage='yes'
and today()>=(date_pn1+120))

(which should mean that the postnatal form has been completed but the 6
month postnatal form has not been completed and the baby is 6-9 months old
or there was a miscarriage and it is at least 4 months since the woman was
last visited.)

I'm wondering if it's because I'm using dates, but according to wiki help
pages for case filtering you just use the property as is (they don't
explicitly say that but it is what is in the example). I did try this as
well

pn_complete='yes' and pn6_complete_mother!='yes' and
(today()>=(date(baby_dob)+183) and today()<=(date(baby_dob)+274)) or
(miscarriage='yes' and today()>=(date(date_pn1)+120))

but it also doesn't work - with both I end up with no cases showing at all!

I have 'reported an issue' from the web page but that was almost a week
ago and I haven't heard anything so if anyone has any ideas that would be
great!

Thanks

Jenny

--
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
m: +1.781.428.5419 | skype: sheel_shah

Hi Sheel,

Thanks for looking at this. I had tried double casting the dates in one of
the many iterations of this I have tried but that also did not work. I've
just copied your logic into the case filter but still it is filtering all
the cases out.

I'm not sure how to use the case filter in the way that you suggest (if I
try putting the whole filter there it says the syntax is invalid and when I
looked up the advanced case filter help it doesn't tell you how to search
on specific case properties). So I downloaded the case list to double
check and all the cases who have had the first postnatal visit done have
all the case properties saved (pn_complete, baby_dob, miscarriage and
date_pn1). None have the pn6_complete case property (actually called
pn6_complete_mother) yet as this is only added in the 6 month form. It is
set up to be saved as a case property there and I just did a test form that
did save it as a case property. So all the cases who have had the first
postnatal done, and where the baby is 6-9 months old, or there was a
miscarriage and the visit was more than 4 months ago, should be showing on
the 6 month list but none of them are!

Jenny

··· On Wednesday, February 19, 2014 12:32:33 AM UTC+2, Sheel Shah wrote: > > Hi Jenny, > > You should use the latter option you suggested (casting the baby_dob and > date_pn1 to date). To be safe your may want to wrap the entire > calculation inside a date function. So instead of using *(date(baby_dob) > + 183)*, use *date(date(baby_dob) + 183) *for any places where you're > using a date calculation. > > It also looks like you're missing a set of brackets in your filter. > Currently you have (to paraphrase): > pn_complete and pn_6_not_complete and (baby_between_6_9_months) or > (baby_deceased and no_mother_pn1_visit) > > You want: > pn_complete and pn_6_not_complete and *(*(baby_between_6_9_m*o*nths) or > (baby_deceased and no_mother_pn1_visit)*)* > > So your statement would become: > pn_complete='yes' and pn6_complete_mother!='yes' and > ((today()>=date(date(baby_dob)+183) and today()<=date(date(baby_dob)+274)) > or (miscarriage='yes' and today()>=date(date(date_pn1)+120))) > > If possible, can you check your Case List (Reports tab -> Case List) to > verify that you cases that meet the above criteria with the case properties > correctly set? > > Thanks, > Sheel > > > > > On Tue, Feb 18, 2014 at 7:54 AM, Jennifer Hall <jenny_...@yahoo.co.uk wrote: > >> Hi, >> >> Can anyone help me understand why my case list filter is not working? >> >> pn_complete='yes' and pn6_complete_mother!='yes' and >> (today()>=baby_dob+183) and today()<=baby_dob+274)) or (miscarriage='yes' >> and today()>=(date_pn1+120)) >> >> (which should mean that the postnatal form has been completed but the 6 >> month postnatal form has not been completed and the baby is 6-9 months old >> or there was a miscarriage and it is at least 4 months since the woman was >> last visited.) >> >> I'm wondering if it's because I'm using dates, but according to wiki help >> pages for case filtering you just use the property as is (they don't >> explicitly say that but it is what is in the example). I did try this as >> well >> >> pn_complete='yes' and pn6_complete_mother!='yes' and >> (today()>=(date(baby_dob)+183) and today()<=(date(baby_dob)+274)) or >> (miscarriage='yes' and today()>=(date(date_pn1)+120)) >> >> but it also doesn't work - with both I end up with no cases showing at >> all! >> >> I have 'reported an issue' from the web page but that was almost a week >> ago and I haven't heard anything so if anyone has any ideas that would be >> great! >> >> Thanks >> >> Jenny >> >> -- >> 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 > m: +1.781.428.5419 | skype: sheel_shah > > >

Hi Jenny,

Lets discuss this off the main mailing list.

Thanks,
Sheel

··· On Thu, Feb 20, 2014 at 3:31 AM, Jennifer Hall wrote:

Hi Sheel,

Thanks for looking at this. I had tried double casting the dates in one
of the many iterations of this I have tried but that also did not work.
I've just copied your logic into the case filter but still it is filtering
all the cases out.

I'm not sure how to use the case filter in the way that you suggest (if I
try putting the whole filter there it says the syntax is invalid and when I
looked up the advanced case filter help it doesn't tell you how to search
on specific case properties). So I downloaded the case list to double
check and all the cases who have had the first postnatal visit done have
all the case properties saved (pn_complete, baby_dob, miscarriage and
date_pn1). None have the pn6_complete case property (actually called
pn6_complete_mother) yet as this is only added in the 6 month form. It is
set up to be saved as a case property there and I just did a test form that
did save it as a case property. So all the cases who have had the first
postnatal done, and where the baby is 6-9 months old, or there was a
miscarriage and the visit was more than 4 months ago, should be showing on
the 6 month list but none of them are!

Jenny

On Wednesday, February 19, 2014 12:32:33 AM UTC+2, Sheel Shah wrote:

Hi Jenny,

You should use the latter option you suggested (casting the baby_dob and
date_pn1 to date). To be safe your may want to wrap the entire
calculation inside a date function. So instead of using *(date(baby_dob)

  • 183)*, use *date(date(baby_dob) + 183) *for any places where you're
    using a date calculation.

It also looks like you're missing a set of brackets in your filter.
Currently you have (to paraphrase):
pn_complete and pn_6_not_complete and (baby_between_6_9_months) or
(baby_deceased and no_mother_pn1_visit)

You want:
pn_complete and pn_6_not_complete and ((baby_between_6_9_months) or
(baby_deceased and no_mother_pn1_visit))

So your statement would become:
pn_complete='yes' and pn6_complete_mother!='yes' and
((today()>=date(date(baby_dob)+183) and today()<=date(date(baby_dob)+274))
or (miscarriage='yes' and today()>=date(date(date_pn1)+120)))

If possible, can you check your Case List (Reports tab -> Case List) to
verify that you cases that meet the above criteria with the case properties
correctly set?

Thanks,
Sheel

On Tue, Feb 18, 2014 at 7:54 AM, Jennifer Hall jenny_...@yahoo.co.ukwrote:

Hi,

Can anyone help me understand why my case list filter is not working?

pn_complete='yes' and pn6_complete_mother!='yes' and
(today()>=baby_dob+183) and today()<=baby_dob+274)) or (miscarriage='yes'
and today()>=(date_pn1+120))

(which should mean that the postnatal form has been completed but the 6
month postnatal form has not been completed and the baby is 6-9 months old
or there was a miscarriage and it is at least 4 months since the woman was
last visited.)

I'm wondering if it's because I'm using dates, but according to wiki
help pages for case filtering you just use the property as is (they don't
explicitly say that but it is what is in the example). I did try this as
well

pn_complete='yes' and pn6_complete_mother!='yes' and
(today()>=(date(baby_dob)+183) and today()<=(date(baby_dob)+274)) or
(miscarriage='yes' and today()>=(date(date_pn1)+120))

but it also doesn't work - with both I end up with no cases showing at
all!

I have 'reported an issue' from the web page but that was almost a week
ago and I haven't heard anything so if anyone has any ideas that would be
great!

Thanks

Jenny

--
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
m: +1.781.428.5419 | skype: sheel_shah

--
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
m: +1.781.428.5419 | skype: sheel_shah