Beispiel #1
0
def get_report_for_other_cycle(report):
    prev_cycle_title = get_prev_cycle(report.cycle)
    other_report = FreeFormReport(None, prev_cycle_title)
    if Cycle.objects.filter(title=prev_cycle_title).exists():
        prev_cycle = Cycle.objects.get(title=prev_cycle_title)
        other_report = other_report.build_form_db(prev_cycle)
    return other_report
 def test_blanks(self):
     file_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                              '..', '..', 'tests', 'fixtures',
                              "new_format.xlsx")
     report = FreeFormReport(file_path, "May Jun").load()
     report.cycle = "Jul - Aug 2015"
     cases = [{
         'test': BlanksQualityCheck,
         'expected': NOT_REPORTING
     }, {
         'test': MultipleCheck,
         'expected': YES
     }, {
         'test': IsReportingCheck,
         'expected': YES
     }, {
         'test': WebBasedCheck,
         'expected': WEB
     }]
     for case in cases:
         check = case['test']()
         for combination in check.combinations:
             report.locs[0]['scores'][check.test][
                 combination[NAME]] = check.for_each_facility(
                     build_facility_data(report.locs[0], report),
                     combination)
         self.assertEquals(
             report.locs[0]["scores"][case['test'].test][DEFAULT],
             case['expected'])
 def test_web_based_results(self):
     file_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..', 'tests', 'fixtures',
                              "new_format.xlsx")
     report = FreeFormReport(file_path, "May - Jun").load()
     report.cycle = "Jul - Aug 2015"
     cases = [
         {'test': WebBasedCheck, 'expected': 96.0, 'score': WEB}
     ]
     for case in cases:
         check = case['test']()
         for combination in check.combinations:
             report.locs[0]['scores'][check.test][combination[NAME]] = check.for_each_facility(report.locs[0], combination)
         persist_scores(report)
         self.assertEquals(Score.objects.count(), 24)
         self.assertEquals(Score.objects.all()[0].WEB_BASED[DEFAULT], WEB)
 def test_blanks(self):
     file_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..', 'tests', 'fixtures',
                              "new_format.xlsx")
     report = FreeFormReport(file_path, "May Jun").load()
     report.cycle = "Jul - Aug 2015"
     cases = [
         {'test': BlanksQualityCheck, 'expected': NOT_REPORTING},
         {'test': MultipleCheck, 'expected': YES},
         {'test': IsReportingCheck, 'expected': YES},
         {'test': WebBasedCheck, 'expected': WEB}
     ]
     for case in cases:
         check = case['test']()
         for combination in check.combinations:
             report.locs[0]['scores'][check.test][combination[NAME]] = check.for_each_facility(build_facility_data(report.locs[0], report), combination)
         self.assertEquals(report.locs[0]["scores"][case['test'].test][DEFAULT], case['expected'])
 def test_web_based_results(self):
     file_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                              '..', '..', 'tests', 'fixtures',
                              "new_format.xlsx")
     report = FreeFormReport(file_path, "May - Jun").load()
     report.cycle = "Jul - Aug 2015"
     cases = [{'test': WebBasedCheck, 'expected': 96.0, 'score': WEB}]
     for case in cases:
         check = case['test']()
         for combination in check.combinations:
             report.locs[0]['scores'][check.test][
                 combination[NAME]] = check.for_each_facility(
                     report.locs[0], combination)
         persist_scores(report)
         self.assertEquals(Score.objects.count(), 24)
         self.assertEquals(Score.objects.all()[0].WEB_BASED[DEFAULT], WEB)
Beispiel #6
0
def command(cycle):
    data = Cycle.objects.filter(title=cycle)
    for cycle in data:
        report = FreeFormReport(None, cycle.title).build_form_db(cycle)
        run_checks(report)
        persist_scores(report)
    export_results()
Beispiel #7
0
def update_checks(cycle_ids):
    data = Cycle.objects.filter(id__in=cycle_ids).all()
    for cycle in data:
        report = FreeFormReport(None, cycle.title).build_form_db(cycle)
        calculate_scores_for_checks_in_cycle(report)
Beispiel #8
0
def load_report(cycle, path):
    report = FreeFormReport(path, cycle).load()
    return report
def perform_checks():
    cycle = "Sep - Oct 2015"
    data = Cycle.objects.filter(title=cycle)
    for cycle in data:
        report = FreeFormReport(None, cycle.title).build_form_db(cycle)
        run_checks(report)
        persist_scores(report)

    checks = [
        {
            'combination': F1,
            'test': STABLE_PATIENT_VOLUMES,
            'cycle': cycle,
            YES: 793,
            NO: 405,
            NOT_REPORTING: 632
        },
        {
            'combination': DEFAULT,
            'test': NNRTI_NEW_PAED,
            'cycle': cycle,
            YES: 681,
            NO: 644,
            NOT_REPORTING: 509
        },
        {
            'combination': DEFAULT,
            'test': NNRTI_NEW_ADULTS,
            'cycle': cycle,
            YES: 799,
            NO: 573,
            NOT_REPORTING: 462
        },
        {
            'combination': DEFAULT,
            'test': NNRTI_CURRENT_PAED,
            'cycle': cycle,
            YES: 548,
            NO: 780,
            NOT_REPORTING: 506
        },
        {
            'combination': DEFAULT,
            'test': NNRTI_CURRENT_ADULTS,
            'cycle': cycle,
            YES: 937,
            NO: 439,
            NOT_REPORTING: 458
        },
    ]
    for check in checks:
        if check.get('combination') == DEFAULT:
            yes_condition = {DEFAULT: YES}
            no_condition = {DEFAULT: NO}
            not_reporting_condition = {(DEFAULT): NOT_REPORTING}
        else:
            yes_condition = {check.get('combination'): YES}
            no_condition = {check.get('combination'): NO}
            not_reporting_condition = {check.get('combination'): NOT_REPORTING}
        for key, condition in {
                YES: yes_condition,
                NO: no_condition,
                NOT_REPORTING: not_reporting_condition
        }.items():
            test_description = "%s %s" % (check['test'], key)
            filter_key = "%s__icontains" % check.get('test')
            filter_by = {filter_key: make_cond(condition)}
            count = Score.objects.filter(cycle=check['cycle'],
                                         **filter_by).count()
            expected = check[key]
            actual = count
            if expected == actual:
                print colored(test_description + " Passed", "green")
            else:
                tolerance = 10
                diff = abs(float(expected) - float(actual))
                c = "yellow" if diff <= tolerance else "red"
                print colored(test_description + " Failed", c), colored(
                    "Got %s instead of %s " % (actual, expected),
                    c), colored("diff: %s" % diff, "blue")
        print "\n"