def test_enrolled_in_localized(self):
        """localized should include baseline but not indefinite"""
        self.bless_with_basics(local_metastatic='localized')
        user = db.session.merge(self.test_user)

        a_s = QB_Status(user=user, as_of_date=now)
        assert a_s.enrolled_in_classification('baseline')
        assert not a_s.enrolled_in_classification('indefinite')
Пример #2
0
    def test_enrolled_in_localized(self):
        """localized should include baseline but not indefinite"""
        self.bless_with_basics(local_metastatic='localized')
        user = db.session.merge(self.test_user)

        a_s = QB_Status(user=user, as_of_date=now)
        assert a_s.enrolled_in_classification('baseline')
        assert not a_s.enrolled_in_classification('indefinite')
 def test_no_start_date(self):
     # W/O a biopsy (i.e. event start date), no questionnaries
     self.promote_user(role_name=ROLE.PATIENT.value)
     # toggle default setup - set biopsy false for test user
     self.login()
     self.test_user = db.session.merge(self.test_user)
     self.test_user.save_observation(
         codeable_concept=CC.BIOPSY, value_quantity=CC.FALSE_VALUE,
         audit=Audit(user_id=TEST_USER_ID, subject_id=TEST_USER_ID),
         status='final', issued=now)
     qstats = QB_Status(self.test_user, now)
     assert not qstats.current_qbd()
     assert not qstats.enrolled_in_classification("baseline")
Пример #4
0
 def test_no_start_date(self):
     # W/O a biopsy (i.e. event start date), no questionnaries
     self.promote_user(role_name=ROLE.PATIENT.value)
     # toggle default setup - set biopsy false for test user
     self.login()
     self.test_user = db.session.merge(self.test_user)
     self.test_user.save_observation(
         codeable_concept=CC.BIOPSY, value_quantity=CC.FALSE_VALUE,
         audit=Audit(user_id=TEST_USER_ID, subject_id=TEST_USER_ID),
         status='final', issued=now)
     qstats = QB_Status(self.test_user, now)
     assert not qstats.current_qbd()
     assert not qstats.enrolled_in_classification("baseline")
Пример #5
0
    def test_early(self):
        # Prior to days passing, no message should be generated
        mock_communication_request('symptom_tracker', '{"days": 90}')

        self.promote_user(role_name=ROLE.PATIENT.value)
        self.login()
        self.add_required_clinical_data(backdate=relativedelta(days=89))
        self.test_user = db.session.merge(self.test_user)

        # Confirm test user qualifies for ST QB
        qbstatus = QB_Status(self.test_user, as_of_date=datetime.utcnow())
        assert qbstatus.enrolled_in_classification('baseline')

        # Being a day short, shouldn't fire
        update_patient_loop(update_cache=False, queue_messages=True)
        expected = Communication.query.first()
        assert not expected
    def test_early(self):
        # Prior to days passing, no message should be generated
        mock_communication_request('symptom_tracker', '{"days": 90}')

        self.promote_user(role_name=ROLE.PATIENT.value)
        self.login()
        self.add_required_clinical_data(backdate=relativedelta(days=89))
        self.test_user = db.session.merge(self.test_user)

        # Confirm test user qualifies for ST QB
        qbstatus = QB_Status(self.test_user, as_of_date=datetime.utcnow())
        assert qbstatus.enrolled_in_classification('baseline')

        # Being a day short, shouldn't fire
        update_patient_loop(update_cache=False, queue_messages=True)
        expected = Communication.query.first()
        assert not expected
Пример #7
0
    def test_procedure_update(self):
        # Newer procedure should alter trigger date and suspend message
        mock_communication_request('symptom_tracker', '{"days": 90}')

        self.promote_user(role_name=ROLE.PATIENT.value)
        self.login()
        self.add_required_clinical_data(backdate=relativedelta(days=91))
        self.test_user = db.session.merge(self.test_user)

        # Confirm test user qualifies for ST QB
        qbstatus = QB_Status(self.test_user, as_of_date=datetime.utcnow())
        assert qbstatus.enrolled_in_classification('baseline')

        # Add fresh procedure
        self.add_procedure('4', 'External beam radiation therapy', ICHOM)

        # New procedure date should suspend message
        update_patient_loop(update_cache=False, queue_messages=True)
        expected = Communication.query.first()
        assert not expected
Пример #8
0
    def test_st_done(self):
        # Symptom Tracker QB with completed shouldn't fire
        mock_communication_request('symptom_tracker', '{"days": 90}')

        self.promote_user(role_name=ROLE.PATIENT.value)
        self.login()
        self.add_required_clinical_data(backdate=relativedelta(days=91))
        self.test_user = db.session.merge(self.test_user)

        # Confirm test user qualifies for ST QB
        qbstatus = QB_Status(self.test_user, as_of_date=datetime.utcnow())
        assert qbstatus.enrolled_in_classification('baseline')

        for instrument in symptom_tracker_instruments:
            mock_qr(instrument_id=instrument)

        # With all q's done, shouldn't generate a message
        update_patient_loop(update_cache=False, queue_messages=True)
        expected = Communication.query.first()
        assert not expected
    def test_procedure_update(self):
        # Newer procedure should alter trigger date and suspend message
        mock_communication_request('symptom_tracker', '{"days": 90}')

        self.promote_user(role_name=ROLE.PATIENT.value)
        self.login()
        self.add_required_clinical_data(backdate=relativedelta(days=91))
        self.test_user = db.session.merge(self.test_user)

        # Confirm test user qualifies for ST QB
        qbstatus = QB_Status(self.test_user, as_of_date=datetime.utcnow())
        assert qbstatus.enrolled_in_classification('baseline')

        # Add fresh procedure
        self.add_procedure('4', 'External beam radiation therapy', ICHOM)

        # New procedure date should suspend message
        update_patient_loop(update_cache=False, queue_messages=True)
        expected = Communication.query.first()
        assert not expected
    def test_st_done(self):
        # Symptom Tracker QB with completed shouldn't fire
        mock_communication_request('symptom_tracker', '{"days": 90}')

        self.promote_user(role_name=ROLE.PATIENT.value)
        self.login()
        self.add_required_clinical_data(backdate=relativedelta(days=91))
        self.test_user = db.session.merge(self.test_user)

        # Confirm test user qualifies for ST QB
        qbstatus = QB_Status(self.test_user, as_of_date=datetime.utcnow())
        assert qbstatus.enrolled_in_classification('baseline')

        for instrument in symptom_tracker_instruments:
            mock_qr(instrument_id=instrument)

        # With all q's done, shouldn't generate a message
        update_patient_loop(update_cache=False, queue_messages=True)
        expected = Communication.query.first()
        assert not expected
    def test_st_metastatic(self):
        # Symptom Tracker QB on metastatic patient shouldn't qualify
        mock_communication_request('symptom_tracker', '{"days": 90}')

        self.promote_user(role_name=ROLE.PATIENT.value)
        self.login()
        self.add_required_clinical_data(backdate=relativedelta(days=91))
        self.test_user = db.session.merge(self.test_user)
        self.test_user.save_observation(
            codeable_concept=CC.PCaLocalized, value_quantity=CC.FALSE_VALUE,
            audit=Audit(user_id=TEST_USER_ID, subject_id=TEST_USER_ID),
            status='final', issued=None)

        # Confirm test user doesn't qualify for ST QB
        qbstatus = QB_Status(self.test_user, as_of_date=datetime.utcnow())
        assert not qbstatus.enrolled_in_classification('baseline')

        # shouldn't generate a message either
        update_patient_loop(update_cache=False, queue_messages=True)
        expected = Communication.query.first()
        assert not expected
Пример #12
0
    def test_st_metastatic(self):
        # Symptom Tracker QB on metastatic patient shouldn't qualify
        mock_communication_request('symptom_tracker', '{"days": 90}')

        self.promote_user(role_name=ROLE.PATIENT.value)
        self.login()
        self.add_required_clinical_data(backdate=relativedelta(days=91))
        self.test_user = db.session.merge(self.test_user)
        self.test_user.save_observation(codeable_concept=CC.PCaLocalized,
                                        value_quantity=CC.FALSE_VALUE,
                                        audit=Audit(user_id=TEST_USER_ID,
                                                    subject_id=TEST_USER_ID),
                                        status='final',
                                        issued=None)

        # Confirm test user doesn't qualify for ST QB
        qbstatus = QB_Status(self.test_user, as_of_date=datetime.utcnow())
        assert not qbstatus.enrolled_in_classification('baseline')

        # shouldn't generate a message either
        update_patient_loop(update_cache=False, queue_messages=True)
        expected = Communication.query.first()
        assert not expected
Пример #13
0
    def test_st_undone(self):
        # Symptom Tracker QB with incompleted should generate communication
        mock_communication_request('symptom_tracker', '{"days": 30}')

        self.app.config['NO_CHALLENGE_WO_DATA'] = False
        self.promote_user(role_name=ROLE.PATIENT.value)
        self.login()
        self.add_required_clinical_data(backdate=relativedelta(days=31))
        self.test_user = db.session.merge(self.test_user)
        self.test_user.birthdate = '1969-07-16'

        # Confirm test user qualifies for ST QB
        qstats = QB_Status(self.test_user, as_of_date=datetime.utcnow())
        assert qstats.enrolled_in_classification('baseline')

        # With most q's undone, should generate a message
        mock_qr(instrument_id='epic26')
        invalidate_users_QBT(TEST_USER_ID)
        self.test_user = db.session.merge(self.test_user)
        qstats = QB_Status(self.test_user, as_of_date=datetime.utcnow())
        assert OverallStatus.in_progress == qstats.overall_status
        update_patient_loop(update_cache=False, queue_messages=True)
        expected = Communication.query.first()
        assert expected
    def test_st_undone(self):
        # Symptom Tracker QB with incompleted should generate communication
        mock_communication_request('symptom_tracker', '{"days": 30}')

        self.app.config['NO_CHALLENGE_WO_DATA'] = False
        self.promote_user(role_name=ROLE.PATIENT.value)
        self.login()
        self.add_required_clinical_data(backdate=relativedelta(days=31))
        self.test_user = db.session.merge(self.test_user)
        self.test_user.birthdate = '1969-07-16'

        # Confirm test user qualifies for ST QB
        qstats = QB_Status(self.test_user, as_of_date=datetime.utcnow())
        assert qstats.enrolled_in_classification('baseline')

        # With most q's undone, should generate a message
        mock_qr(instrument_id='epic26')
        invalidate_users_QBT(TEST_USER_ID)
        self.test_user = db.session.merge(self.test_user)
        qstats = QB_Status(self.test_user, as_of_date=datetime.utcnow())
        assert OverallStatus.in_progress == qstats.overall_status
        update_patient_loop(update_cache=False, queue_messages=True)
        expected = Communication.query.first()
        assert expected