def tabular_data(self, mode, case_id, start_date, end_date):#, limit=50, skip=0):
        try:
            case_doc = PactPatientCase.get(case_id)
        except ResourceNotFound:
            case_doc = None

        if case_doc is not None:
            # patient is selected
            startkey = [case_id, 'anchor_date', start_date.year, start_date.month, start_date.day]
            endkey = [case_id, 'anchor_date', end_date.year, end_date.month, end_date.day]
        elif case_doc is None:
            # patient is not selected, do all patients
            startkey = [start_date.year, start_date.month, start_date.day]
            endkey = [end_date.year, end_date.month, end_date.day]
        skip = 0
        view_results = CObservation.view(
            'pact/dots_observations',
            startkey=startkey,
            endkey=endkey,
            limit=COUCH_CHUNK_LIMIT,
            skip=skip,
            classes={None: CObservation},
        ).all()
        while len(view_results) > 0:
            if COUCH_MAX_LIMIT > skip:
                logging.error("Pact DOT admin query: Too much data returned for query %s-%s" % (startkey, endkey))
                break
            for v in view_results:
                yield v
            skip += COUCH_CHUNK_LIMIT
            view_results = CObservation.view(
                'pact/dots_observations',
                startkey=startkey,
                endkey=endkey,
                limit=COUCH_CHUNK_LIMIT,
                skip=skip,
                classes={None: CObservation},
            ).all()
dataset/ETHPy150Open dimagi/commcare-hq/custom/_legacy/pact/reports/admin_dot_reports.py/PactDOTAdminReport.tabular_data/swapped operands of `>`