

@property
def case_filter(self):
    now = datetime.datetime.utcnow()
    fromdate = (now - timedelta(days=42))
    filters = BaseHNBCReport.base_filters(self)
    filters.append({
        'term': {
            'pp_case_filter.#value': '1',
        },
    })
    filters.append({
        'range': {
            'date_birth.#value': {
                'gte': json_format_date(fromdate),
            },
        },
    })
    status = self.request_params.get('PNC_status', '')
    or_stmt = []
    if status:
        if (status == 'On Time'):
            for i in range(1, 8):
                filters.append({
                    'term': {
                        ('case_pp_%s_done.#value' % i): 'yes',
                    },
                })
        else:
            for i in range(1, 8):
                or_stmt.append({
                    'not': {
                        'term': {
                            ('case_pp_%s_done.#value' % i): 'yes',
                        },
                    },
                })
            or_stmt = {
                'or': or_stmt,
            }
            filters.append(or_stmt)
    return ({
        'and': filters,
    } if filters else {
        
    })

dataset/ETHPy150Open dimagi/commcare-hq/custom/apps/crs_reports/reports.py HBNCMotherReport.case_filter/original