From f29429f0d0288da3094e45b1d5002e789e78a167 Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Wed, 30 Dec 2020 10:04:10 -0500 Subject: [PATCH 1/3] Modified study_info do_task_validate_only so that we take the default path in ind_update workflow. --- crc/scripts/study_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crc/scripts/study_info.py b/crc/scripts/study_info.py index c4b1bffd..6bd13d3f 100644 --- a/crc/scripts/study_info.py +++ b/crc/scripts/study_info.py @@ -326,7 +326,7 @@ Returns information specific to the protocol. "IS_HGT": None, "IS_IBC": None, "IS_IDE": None, - "IS_IND": None, + "IS_IND": 1, "IS_MENTAL_IMPAIRMENT_POP": None, "IS_MINOR": None, "IS_MINOR_PARTICIPANT": None, From ede5df4df53f92cccb3a9cd4a1153fa831ef86d1 Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Wed, 30 Dec 2020 17:49:59 -0500 Subject: [PATCH 2/3] Studies can now be put on hold in the dashboard. We were overriding the status in StudyModel.update_from_protocol_builder. --- crc/models/study.py | 1 - tests/study/test_study_on_hold.py | 30 ++++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 tests/study/test_study_on_hold.py diff --git a/crc/models/study.py b/crc/models/study.py index 811ab73e..e56ef8d6 100644 --- a/crc/models/study.py +++ b/crc/models/study.py @@ -60,7 +60,6 @@ class StudyModel(db.Model): self.last_updated = pbs.DATE_MODIFIED self.irb_status = IrbStatus.incomplete_in_protocol_builder - self.status = StudyStatus.in_progress class StudyEvent(db.Model): diff --git a/tests/study/test_study_on_hold.py b/tests/study/test_study_on_hold.py new file mode 100644 index 00000000..79362974 --- /dev/null +++ b/tests/study/test_study_on_hold.py @@ -0,0 +1,30 @@ +from tests.base_test import BaseTest +from crc import session +from crc.models.study import StudyModel, StudyStatus, StudySchema +import json + + +class TestHoldStudy(BaseTest): + + def test_hold_study(self): + self.load_example_data() + + study = session.query(StudyModel).first() + self.assertEqual(study.status, StudyStatus.in_progress) + + study_schema = StudySchema().dump(study) + study_schema['status'] = 'hold' + study_schema['comment'] = 'This is my comment' + + self.app.put('/v1.0/study/%i' % study.id, + content_type="application/json", + headers=self.logged_in_headers(), + data=json.dumps(study_schema)) + + # The error happened when the dashboard reloaded, + # in particular, when we got the studies for the user + api_response = self.app.get('/v1.0/study', headers=self.logged_in_headers(), content_type="application/json") + self.assert_success(api_response) + + study_result = session.query(StudyModel).filter(StudyModel.id == study.id).first() + self.assertEqual(StudyStatus.hold, study_result.status) From 80d20095733005c66640a39356d077abb87db57f Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Thu, 31 Dec 2020 10:40:27 -0500 Subject: [PATCH 3/3] Modified the test to cover hold, abandon, and open_enrollment. These are tickets 21 and 94 --- tests/study/test_study_actions_status.py | 62 ++++++++++++++++++++++++ tests/study/test_study_on_hold.py | 30 ------------ 2 files changed, 62 insertions(+), 30 deletions(-) create mode 100644 tests/study/test_study_actions_status.py delete mode 100644 tests/study/test_study_on_hold.py diff --git a/tests/study/test_study_actions_status.py b/tests/study/test_study_actions_status.py new file mode 100644 index 00000000..4e3a4f66 --- /dev/null +++ b/tests/study/test_study_actions_status.py @@ -0,0 +1,62 @@ +from tests.base_test import BaseTest +from crc import session +from crc.models.study import StudyModel, StudyStatus, StudySchema +import json + + +class TestStudyActionsStatus(BaseTest): + + def update_study_status(self, study, study_schema): + self.app.put('/v1.0/study/%i' % study.id, + content_type="application/json", + headers=self.logged_in_headers(), + data=json.dumps(study_schema)) + + # The error happened when the dashboard reloaded, + # in particular, when we got the studies for the user + api_response = self.app.get('/v1.0/study', headers=self.logged_in_headers(), content_type="application/json") + self.assert_success(api_response) + + study_result = session.query(StudyModel).filter(StudyModel.id == study.id).first() + return study_result + + def test_hold_study(self): + self.load_example_data() + + study = session.query(StudyModel).first() + self.assertEqual(study.status, StudyStatus.in_progress) + + study_schema = StudySchema().dump(study) + study_schema['status'] = 'hold' + study_schema['comment'] = 'This is my hold comment' + + study_result = self.update_study_status(study, study_schema) + self.assertEqual(StudyStatus.hold, study_result.status) + + def test_abandon_study(self): + self.load_example_data() + + study = session.query(StudyModel).first() + self.assertEqual(study.status, StudyStatus.in_progress) + + study_schema = StudySchema().dump(study) + study_schema['status'] = 'abandoned' + study_schema['comment'] = 'This is my abandon comment' + + study_result = self.update_study_status(study, study_schema) + self.assertEqual(StudyStatus.abandoned, study_result.status) + + def test_open_enrollment_study(self): + self.load_example_data() + + study = session.query(StudyModel).first() + self.assertEqual(study.status, StudyStatus.in_progress) + + study_schema = StudySchema().dump(study) + study_schema['status'] = 'open_for_enrollment' + study_schema['comment'] = 'This is my open enrollment comment' + study_schema['enrollment_date'] = '2021-01-04T05:00:00.000Z' + + study_result = self.update_study_status(study, study_schema) + self.assertEqual(StudyStatus.open_for_enrollment, study_result.status) + diff --git a/tests/study/test_study_on_hold.py b/tests/study/test_study_on_hold.py deleted file mode 100644 index 79362974..00000000 --- a/tests/study/test_study_on_hold.py +++ /dev/null @@ -1,30 +0,0 @@ -from tests.base_test import BaseTest -from crc import session -from crc.models.study import StudyModel, StudyStatus, StudySchema -import json - - -class TestHoldStudy(BaseTest): - - def test_hold_study(self): - self.load_example_data() - - study = session.query(StudyModel).first() - self.assertEqual(study.status, StudyStatus.in_progress) - - study_schema = StudySchema().dump(study) - study_schema['status'] = 'hold' - study_schema['comment'] = 'This is my comment' - - self.app.put('/v1.0/study/%i' % study.id, - content_type="application/json", - headers=self.logged_in_headers(), - data=json.dumps(study_schema)) - - # The error happened when the dashboard reloaded, - # in particular, when we got the studies for the user - api_response = self.app.get('/v1.0/study', headers=self.logged_in_headers(), content_type="application/json") - self.assert_success(api_response) - - study_result = session.query(StudyModel).filter(StudyModel.id == study.id).first() - self.assertEqual(StudyStatus.hold, study_result.status)