Esempio n. 1
0
    def test_dhiv_not_tested(self):
        """
        It should report the results are not available if nat is P and dhiv is NT
        """
        from aeh.earlytest.results import process
        from datetime import date
        import transaction
        from aeh.earlytest import Session, models

        site_code = '99X'
        reference_number = '12345'
        expected = site_code + reference_number

        with transaction.manager:
            Session.add(
                models.Result(site_code=site_code,
                              reference_number=reference_number,
                              test_date=date.today(),
                              draw_date=date.today(),
                              nat='P',
                              dhiv='NT',
                              file='results.txt'))

        response = self.app.post('/results', {
            'userInput1': expected,
            'userInput2': expected,
        })

        html = BeautifulSoup(response.text)
        e = html.find(class_='alert-info')
        self.assertIn('we are not able to give you your results', e.get_text())
Esempio n. 2
0
    def test_negative_not_available(self):
        """
        It should not report the patient's status before 14 days of draw date
        """
        from datetime import date
        import transaction
        from aeh.earlytest import Session, models

        site_code = '99X'
        reference_number = '12345'
        expected = site_code + reference_number

        with transaction.manager:
            Session.add(
                models.Result(site_code=site_code,
                              reference_number=reference_number,
                              test_date=date.today(),
                              draw_date=date.today(),
                              nat='N',
                              file='results.txt'))

        response = self.app.post('/results', {
            'userInput1': expected,
            'userInput2': expected,
        })

        html = BeautifulSoup(response.text)
        e = html.find(class_='alert-info')
        self.assertIn('we are not able to give you your results', e.get_text())
Esempio n. 3
0
    def test_unavailable(self):
        """
        It should not report the patient's status after 90 days
        """
        from datetime import date, timedelta
        import transaction
        from aeh.earlytest import Session, models

        site_code = '99X'
        reference_number = '12345'
        expected = site_code + reference_number

        with transaction.manager:
            Session.add(
                models.Result(site_code=site_code,
                              reference_number=reference_number,
                              test_date=date.today() - timedelta(90),
                              draw_date=date.today() - timedelta(90),
                              nat='N',
                              file='results.txt'))

        response = self.app.post('/results', {
            'userInput1': expected,
            'userInput2': expected,
        })

        html = BeautifulSoup(response.text)
        e = html.find(class_='alert-info')
        self.assertIn('has been more than 90 days', e.get_text())
Esempio n. 4
0
    def test_invalid(self):
        """
        It should fail if inputs are not equal
        """
        from datetime import date
        import transaction
        from aeh.earlytest import Session, models

        site_code = '99X'
        reference_number = '12345'
        expected = site_code + reference_number

        with transaction.manager:
            Session.add(
                models.Result(site_code=site_code,
                              reference_number=reference_number,
                              test_date=date.today(),
                              draw_date=date.today(),
                              nat='N',
                              file='results.txt'))

        response = self.app.post('/results', {
            'userInput1': expected,
            'userInput2': 'LOL' + reference_number
        })

        html = BeautifulSoup(response.text)
        e = html.find(class_='alert-danger')
        self.assertIn('test numbers entered do not match', e.get_text())
Esempio n. 5
0
    def test_positive(self):
        """
        It should not let the user know if they are HIV positive
        (This will be done in person)
        """
        from datetime import date
        import transaction
        from aeh.earlytest import Session, models

        site_code = '99X'
        reference_number = '12345'
        expected = site_code + reference_number

        with transaction.manager:
            Session.add(
                models.Result(site_code=site_code,
                              reference_number=reference_number,
                              test_date=date.today(),
                              draw_date=date.today(),
                              nat='P',
                              dhiv='P',
                              file='results.txt'))

        response = self.app.post('/results', {
            'userInput1': expected,
            'userInput2': expected,
        })

        html = BeautifulSoup(response.text)
        e = html.find(class_='alert-info')
        self.assertIn('we are not able to give you your results', e.get_text())
Esempio n. 6
0
    def test_dhiv_not_tested(self):
        """
    It should report the results are not available if nat is P and dhiv is NT
    """
        from aeh.earlytest.results import process
        from datetime import date
        from aeh.earlytest import Session, models

        site_code = '99X'
        reference_number = '12345'
        expected = site_code + reference_number

        Session.add(
            models.Result(site_code=site_code,
                          reference_number=reference_number,
                          test_date=date.today(),
                          draw_date=date.today(),
                          nat='P',
                          dhiv='NT',
                          file='results.txt'))

        request = DummyRequest({
            'userInput1':
            ' '.join(list(site_code + reference_number)),
            'userInput2':
            site_code + ' ' + reference_number
        })

        ret = process(request)
        self.assertEquals(ret['queryStatus'], 'RESULTS_NOT_AVAILABLE')
Esempio n. 7
0
    def test_unavailable(self):
        """
    It should not report the patient's status after 90 days
    """
        from aeh.earlytest.results import process
        from datetime import date, timedelta
        from aeh.earlytest import Session, models

        site_code = '99X'
        reference_number = '12345'
        expected = site_code + reference_number

        Session.add(
            models.Result(site_code=site_code,
                          reference_number=reference_number,
                          test_date=date.today() - timedelta(90),
                          draw_date=date.today() - timedelta(90),
                          nat='N',
                          file='results.txt'))

        request = DummyRequest({
            'userInput1': expected,
            'userInput2': expected,
        })

        ret = process(request)
        self.assertEquals(ret['queryStatus'], 'RESULTS_OUT_OF_DATE')
Esempio n. 8
0
    def test_negative_available(self):
        """
    It should report the patient's status after 14 days of draw date
    """
        from aeh.earlytest.results import process
        from datetime import date, timedelta
        from aeh.earlytest import Session, models

        site_code = '99X'
        reference_number = '12345'
        expected = site_code + reference_number

        result = models.Result(site_code=site_code,
                               reference_number=reference_number,
                               test_date=date.today() - timedelta(14),
                               draw_date=date.today() - timedelta(14),
                               nat='N',
                               file='results.txt')
        Session.add(result)

        request = DummyRequest({
            'userInput1': expected,
            'userInput2': expected,
        })

        ret = process(request)
        self.assertEquals(ret['queryStatus'], 'RESULTS_NEGATIVE')
Esempio n. 9
0
    def test_positive(self):
        """
    It should not let the user know if they are HIV positive
    (This will be done in person)
    """
        from aeh.earlytest.results import process
        from datetime import date
        from aeh.earlytest import Session, models

        site_code = '99X'
        reference_number = '12345'
        expected = site_code + reference_number

        Session.add(
            models.Result(site_code=site_code,
                          reference_number=reference_number,
                          test_date=date.today(),
                          draw_date=date.today(),
                          nat='P',
                          dhiv='P',
                          file='results.txt'))

        request = DummyRequest({
            'userInput1': expected,
            'userInput2': expected,
        })

        ret = process(request)
        self.assertEquals(ret['queryStatus'], 'RESULTS_NOT_AVAILABLE')
Esempio n. 10
0
    def test_invalid(self):
        """
    It should fail if inputs are not equal
    """
        from aeh.earlytest.results import process
        from datetime import date
        from aeh.earlytest import Session, models

        site_code = '99X'
        reference_number = '12345'

        Session.add(
            models.Result(site_code=site_code,
                          reference_number=reference_number,
                          test_date=date.today(),
                          draw_date=date.today(),
                          nat='N',
                          file='results.txt'))

        request = DummyRequest({
            'userInput1': site_code + reference_number,
            'userInput2': 'LOL' + ' ' + reference_number
        })

        ret = process(request)
        self.assertEquals(ret['queryStatus'], 'QUERY_INVALID')
Esempio n. 11
0
    def test_valid(self):
        """
    It should be able to parse a number with whitespace in it
    """
        from aeh.earlytest.results import process
        from datetime import date
        from aeh.earlytest import Session, models

        site_code = '99X'
        reference_number = '12345'
        expected = site_code + reference_number

        Session.add(
            models.Result(site_code=site_code,
                          reference_number=reference_number,
                          test_date=date.today(),
                          draw_date=date.today(),
                          nat='N',
                          file='results.txt'))

        request = DummyRequest({
            'userInput1':
            ' '.join(list(site_code + reference_number)),
            'userInput2':
            site_code + ' ' + reference_number
        })

        ret = process(request)
        self.assertEquals(ret['defaultNumber'], expected)
        self.assertEquals(ret['cleanNumber1'], expected)
        self.assertEquals(ret['cleanNumber2'], expected)
Esempio n. 12
0
    def test_valid_entry_update_result_draw_date(self):
        """
    Should pass, save entry in draw table, and update draw date in corresponding result
    entry in result table
    """
        from aeh.earlytest.draw_input import process
        from datetime import date
        from datetime import datetime
        from aeh.earlytest import Session, models

        site_code = '76C'
        reference_number = '55555'
        expected = site_code + reference_number
        draw_date = '2015-01-01'

        Session.add(
            models.Result(site_code=site_code,
                          reference_number=reference_number,
                          test_date=date.today(),
                          nat='N',
                          file='results.txt'))

        request = DummyRequest({
            'redcrossid-entry': expected,
            'drawdate-input': draw_date,
            'rcidform.submitted': True,
        })

        ret = process(request)
        self.assertEquals(ret['errorStatus'], 'rcidAccepted')

        draw = Session.query(models.Draw)\
           .filter(models.Draw.site_code == site_code)\
           .filter(models.Draw.reference_number == reference_number).first()

        self.assertEquals(draw.site_code, site_code)
        self.assertEquals(draw.reference_number, reference_number)
        self.assertEquals(
            draw.draw_date,
            datetime.date(datetime.strptime(draw_date, "%Y-%m-%d")))

        result = Session.query(models.Result)\
           .filter(models.Result.site_code == site_code)\
           .filter(models.Result.reference_number == reference_number).first()

        self.assertEquals(
            result.draw_date,
            datetime.date(datetime.strptime(draw_date, "%Y-%m-%d")))