예제 #1
0
    def test_should_show_previous_submissions_in_old_format_after_change_date_format(
            self):
        eid_field = TextField(label="What is associated entity?",
                              code="EID",
                              name="What is associatéd entity?",
                              entity_question_flag=True,
                              ddtype=self.ddtype)
        rp_field = DateField(label="Report date",
                             code="RD",
                             name="What is réporting date?",
                             date_format="dd.mm.yyyy",
                             event_time_field_flag=True,
                             ddtype=self.ddtype)

        form_model = FormModelBuilder(self.manager, ['clinic'],
                                      form_code='cli001').add_fields(
                                          eid_field, rp_field).build()

        self.submit_data({
            'form_code': 'cli001',
            'EID': 'cid001',
            'RD': '12.12.2012'
        })

        rp_field = DateField(label="Report date",
                             code="RD",
                             name="What is réporting date?",
                             date_format="mm.yyyy",
                             event_time_field_flag=True,
                             ddtype=self.ddtype)
        self._edit_fields(form_model, rp_field)
        self.submit_data({
            'form_code': 'cli001',
            'EID': 'cid001',
            'RD': '08.2012'
        })

        rp_field = DateField(label="Report date",
                             code="RD",
                             name="What is réporting date?",
                             date_format="mm.dd.yyyy",
                             event_time_field_flag=True,
                             ddtype=self.ddtype)
        self._edit_fields(form_model, rp_field)
        self.submit_data({
            'form_code': 'cli001',
            'EID': 'cid001',
            'RD': '12.24.2012'
        })

        submissions = successful_submissions(self.manager,
                                             form_model.form_code)
        analyzer = SubmissionAnalyzer(form_model, self.manager, self.org_id,
                                      submissions)
        values = analyzer.get_raw_values()
        reporting_periods = map(lambda value: value[2], values)

        self.assertIn('08.2012', reporting_periods)
        self.assertIn('12.12.2012', reporting_periods)
        self.assertIn('12.24.2012', reporting_periods)
예제 #2
0
    def test_should_should_get_fields_values_after_question_count_changed(
            self):
        eid_field = TextField(label="What is associated entity?",
                              code="EID",
                              name="What is associatéd entity?",
                              entity_question_flag=True,
                              ddtype=self.ddtype)
        rp_field = DateField(label="Report date",
                             code="RD",
                             name="What is réporting date?",
                             date_format="dd.mm.yyyy",
                             event_time_field_flag=True,
                             ddtype=self.ddtype)
        symptoms_field = TextField(label="Zhat are symptoms?",
                                   code="SY",
                                   name="Zhat are symptoms?",
                                   ddtype=self.ddtype)
        gps = TextField(label="What is your blood group?",
                        code="GPS",
                        name="What is your gps?",
                        ddtype=self.ddtype)
        form_model = FormModelBuilder(self.manager, ['clinic'],
                                      form_code='cli001').add_fields(
                                          eid_field, rp_field, symptoms_field,
                                          gps).build()

        self.submit_data({
            'form_code': 'cli001',
            'EID': 'cid001',
            'RD': '12.12.2012',
            'SY': 'Fever',
            'GPS': 'NewYork'
        })

        form_model.create_snapshot()
        form_model.delete_field("SY")
        form_model.save()

        self.submit_data({
            'form_code': 'cli001',
            'EID': 'cid001',
            'RD': '12.12.2012',
            'GPS': '1,1'
        })

        submissions = successful_submissions(self.manager,
                                             form_model.form_code)
        analyzer = SubmissionAnalyzer(form_model, self.manager, self.org_id,
                                      submissions)
        values = analyzer.get_raw_values()

        self.assertEqual(['1,1'], values[0][5:])
        self.assertEqual(['NewYork'], values[1][5:])
예제 #3
0
    def test_should_get_old_answer_for_submissions_which_is_submitted_before_other_changed_to_other(
            self):
        """
        Function to test get old answer for submissions which is submitted before answer type changed from other type(word, number, date, GPS) to other type
        """
        eid_field = TextField(label="What is associated entity?",
                              code="EID",
                              name="What is associatéd entity?",
                              entity_question_flag=True,
                              ddtype=self.ddtype)
        rp_field = DateField(label="Report date",
                             code="RD",
                             name="What is réporting date?",
                             date_format="dd.mm.yyyy",
                             event_time_field_flag=True,
                             ddtype=self.ddtype)
        symptoms_field = TextField(label="Zhat are symptoms?",
                                   code="SY",
                                   name="Zhat are symptoms?",
                                   ddtype=self.ddtype)
        gps = TextField(label="What is your blood group?",
                        code="GPS",
                        name="What is your gps?",
                        ddtype=self.ddtype)
        national_day_field = TextField(label="national day?",
                                       code="ND",
                                       name="national day",
                                       ddtype=self.ddtype)
        form_model = FormModelBuilder(self.manager, ['clinic'],
                                      form_code='cli001').add_fields(
                                          eid_field, rp_field, symptoms_field,
                                          gps, national_day_field).build()

        self.submit_data({
            'form_code': 'cli001',
            'EID': 'cid001',
            'RD': '12.12.2012',
            'SY': 'Fever',
            'GPS': 'NewYork',
            "ND": "oct 1"
        })

        gps = GeoCodeField(label="What is your blood group?",
                           code="GPS",
                           name="What is your gps?",
                           ddtype=self.ddtype)
        symptoms_field = IntegerField(label="Zhat are symptoms?",
                                      code="SY",
                                      name="Zhat are symptoms?",
                                      ddtype=self.ddtype)
        national_day_field = DateField(label="national day?",
                                       code="ND",
                                       name="national day",
                                       ddtype=self.ddtype,
                                       date_format="dd.mm.yyyy")

        self._edit_fields(form_model, gps, national_day_field, symptoms_field)
        self.submit_data({
            'form_code': 'cli001',
            'EID': 'cid001',
            'RD': '12.12.2012',
            'SY': '100',
            'GPS': '1,1',
            "ND": "01.10.2012"
        })

        submissions = successful_submissions(self.manager,
                                             form_model.form_code)
        analyzer = SubmissionAnalyzer(form_model, self.manager, self.org_id,
                                      submissions)
        values = analyzer.get_raw_values()

        self.assertEqual(['100', '1,1', '01.10.2012'], values[0][5:])
        self.assertEqual(['Fever', 'NewYork', 'oct 1'], values[1][5:])
예제 #4
0
    def test_should_get_old_answer_for_submissions_which_is_submitted_before_other_changed_to_MC(
            self):
        """
        Function to test get old answer for submissions which is submitted before answer type changed from other type(word, number, date, GPS) to multiple choice/single choice
        """
        eid_field = TextField(label="What is associated entity?",
                              code="EID",
                              name="What is associatéd entity?",
                              entity_question_flag=True,
                              ddtype=self.ddtype)
        rp_field = DateField(label="Report date",
                             code="RD",
                             name="What is réporting date?",
                             date_format="dd.mm.yyyy",
                             event_time_field_flag=True,
                             ddtype=self.ddtype)
        symptoms_field = TextField(label="Zhat are symptoms?",
                                   code="SY",
                                   name="Zhat are symptoms?",
                                   ddtype=self.ddtype)
        blood_type_field = SelectField(label="What is your blood group?",
                                       code="BG",
                                       name="What is your blood group?",
                                       options=[("O+", "a"), ("O-", "b"),
                                                ("AB", "c"), ("B+", "d")],
                                       single_select_flag=True,
                                       ddtype=self.ddtype)

        form_model = FormModelBuilder(self.manager, ['clinic'],
                                      form_code='cli001').add_fields(
                                          eid_field, rp_field, symptoms_field,
                                          blood_type_field).build()
        self.submit_data({
            'form_code': 'cli001',
            'EID': 'cid001',
            'RD': '12.12.2012',
            'SY': 'Fever',
            'BG': 'b'
        })

        symptoms_field = SelectField(label="Zhat are symptoms?",
                                     code="SY",
                                     name="Zhat are symptoms?",
                                     options=[("Rapid weight loss", "a"),
                                              ("Dry cough", "b"),
                                              ("Pneumonia", "c"),
                                              ("Memory loss", "d"),
                                              ("Neurological disorders ", "e")
                                              ],
                                     single_select_flag=False,
                                     ddtype=self.ddtype)
        self._edit_fields(form_model, symptoms_field)
        self.submit_data({
            'form_code': 'cli001',
            'EID': 'cid001',
            'RD': '12.12.2012',
            'SY': 'ab',
            'BG': 'b'
        })

        submissions = successful_submissions(self.manager,
                                             form_model.form_code)
        analyzer = SubmissionAnalyzer(form_model, self.manager, self.org_id,
                                      submissions)
        values = analyzer.get_raw_values()

        self.assertEqual([['Rapid weight loss', 'Dry cough'], ['O-']],
                         values[0][5:])
        self.assertEqual(['Fever', ['O-']], values[1][5:])