diff --git a/crc/services/workflow_service.py b/crc/services/workflow_service.py index 74d70408..c481a0a8 100644 --- a/crc/services/workflow_service.py +++ b/crc/services/workflow_service.py @@ -143,20 +143,37 @@ class WorkflowService(object): @staticmethod def get_random_data_for_field(field, task): - if field.type == "enum": + has_ldap_lookup = field.has_property(Task.PROP_LDAP_LOOKUP) + has_file_lookup = field.has_property(Task.PROP_OPTIONS_FILE_NAME) + has_data_lookup = field.has_property(Task.PROP_OPTIONS_DATA_NAME) + has_lookup = has_ldap_lookup or has_file_lookup or has_data_lookup + + if field.type == "enum" and not has_lookup: + # If it's a normal enum field with no lookup, + # return a random option. if len(field.options) > 0: random_choice = random.choice(field.options) if isinstance(random_choice, dict): - return random.choice(field.options)['id'] + choice = random.choice(field.options) + return { + 'value': choice['id'], + 'label': choice['name'] + } else: # fixme: why it is sometimes an EnumFormFieldOption, and other times not? - return random_choice.id ## Assume it is an EnumFormFieldOption + # Assume it is an EnumFormFieldOption + return { + 'value': random_choice.id, + 'label': random_choice.name + } else: raise ApiError.from_task("invalid_enum", "You specified an enumeration field (%s)," " with no options" % field.id, task) - elif field.type == "autocomplete": + elif field.type == "autocomplete" or field.type == "enum": + # If it has a lookup, get the lookup model from the spreadsheet or task data, then return a random option + # from the lookup model lookup_model = LookupService.get_lookup_model(task, field) - if field.has_property(Task.PROP_LDAP_LOOKUP): # All ldap records get the same person. + if has_ldap_lookup: # All ldap records get the same person. return { "label": "dhf8r", "value": "Dan Funk", @@ -172,9 +189,7 @@ class WorkflowService(object): elif lookup_model: data = db.session.query(LookupDataModel).filter( LookupDataModel.lookup_file_model == lookup_model).limit(10).all() - options = [] - for d in data: - options.append({"id": d.value, "label": d.label}) + options = [{"value": d.value, "label": d.label, "data": d.data} for d in data] return random.choice(options) else: raise ApiError.from_task("unknown_lookup_option", "The settings for this auto complete field " diff --git a/crc/static/bpmn/ind_supplement/decision_ind_check.dmn b/crc/static/bpmn/ind_supplement/decision_ind_check.dmn deleted file mode 100644 index 9104121b..00000000 --- a/crc/static/bpmn/ind_supplement/decision_ind_check.dmn +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - StudyInfo.details.IS_IND - - - - - StudyInfo.details.IND_1 - - - - - StudyInfo.details.IND_2 - - - - - StudyInfo.details.IND_3 - - - - - - 1 - - - not('') - - - - - - - - - true - - - - - 1 - - - - - - not('') - - - - - - true - - - - - 1 - - - - - - - - - not('') - - - true - - - - - - - - - - - - - - - - - false - - - - - diff --git a/crc/static/bpmn/ind_supplement/ind_supplement.bpmn b/crc/static/bpmn/ind_supplement/ind_supplement.bpmn deleted file mode 100644 index b25e080b..00000000 --- a/crc/static/bpmn/ind_supplement/ind_supplement.bpmn +++ /dev/null @@ -1,127 +0,0 @@ - - - - - SequenceFlow_1dhb8f4 - - - - SequenceFlow_1yhv1qz - SequenceFlow_1enco3g - - - SequenceFlow_1dhb8f4 - SequenceFlow_1uzcl1f - StudyInfo details - - - - SequenceFlow_1lazou8 - SequenceFlow_1yb1vma - SequenceFlow_011l5xt - - - ind_supplement == True - - - ind_supplement == False - - - The use of an Investigational New Drug (IND) was indicated in Protocol Builder, but no IND number was entered. Please enter up to three numbers in the Supplemental section of Protocol Builder so supplemental information can be entered here. - SequenceFlow_011l5xt - SequenceFlow_1yhv1qz - - - - SequenceFlow_1uzcl1f - SequenceFlow_1lazou8 - - - - IND No.: {{StudyInfo.details.IND_1}} - - - - - - - - - - - - - - - - SequenceFlow_1yb1vma - SequenceFlow_1enco3g - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/crc/static/bpmn/ind_update/SponsorList.xls b/crc/static/bpmn/ind_update/SponsorList.xls new file mode 100644 index 00000000..df1cf0d7 Binary files /dev/null and b/crc/static/bpmn/ind_update/SponsorList.xls differ diff --git a/crc/static/bpmn/ind_update/decision_ind_check.dmn b/crc/static/bpmn/ind_update/decision_ind_check.dmn new file mode 100644 index 00000000..658f02ab --- /dev/null +++ b/crc/static/bpmn/ind_update/decision_ind_check.dmn @@ -0,0 +1,220 @@ + + + + + + + StudyInfo.details.IS_IND + + + + + StudyInfo.details.IND_1 + + + + + StudyInfo.details.IND_2 + + + + + StudyInfo.details.IND_3 + + + + + + + + 3 IND #s + + 1 + + + not('') + + + not('') + + + not('') + + + true + + + "three" + + + "Three IND #s entered" + + + + + + + 2 IND #s + + 1 + + + not('') + + + not('') + + + "" + + + true + + + "two" + + + "Two IND #s entered" + + + + + + + 3 IND#s, missing #2 + + 1 + + + not('') + + + "" + + + not('') + + + true + + + "two" + + + "Two IND #s entered" + + + + + + + 3 IND#s, missing #1 + + 1 + + + "" + + + not('') + + + not('') + + + true + + + "two" + + + "Two IND #s entered" + + + + + + + 1 IND # + + 1 + + + not('') + + + "" + + + "" + + + true + + + "one" + + + "One IND # entered" + + + StudyInfo.details.IND_1 + + + + No + + 1 + + + + + + + + + + + + true + + + "na" + + + "No IND Numbers Entered in PB" + + + "" + + + + No IND, PB Q#56 answered as No, should not be needed, but here as stopgap in case memu check failed + + 0 + + + + + + + + + + + + false + + + + + + + + + + + + + + diff --git a/crc/static/bpmn/ind_update/ind_update.bpmn b/crc/static/bpmn/ind_update/ind_update.bpmn new file mode 100644 index 00000000..15845111 --- /dev/null +++ b/crc/static/bpmn/ind_update/ind_update.bpmn @@ -0,0 +1,276 @@ + + + + + SequenceFlow_1dhb8f4 + + + + Flow_0jqdolk + Flow_OneOnly + + + SequenceFlow_1dhb8f4 + SequenceFlow_1uzcl1f + StudyInfo details + + + + SequenceFlow_1uzcl1f + SequenceFlow_1cwibmt + + + IND No.: {{ StudyInfo.details.IND_1 }} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Flow_1bn0jp7 + Flow_10rb7gb + + + IND No.: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Flow_TwoOrThree + Flow_1p563xr + + + IND No.: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Flow_1p563xr + Flow_0jqdolk + + + + {{ ind_message }} + + + + + + + + + + + + + + + + + + + SequenceFlow_1cwibmt + Flow_1bn0jp7 + + + + + + + Flow_10rb7gb + Flow_TwoOrThree + Flow_OneOnly + + + IND_CntEntered != "value_one" + + + IND_CntEntered == "value_one" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/example_data.py b/example_data.py index 98746c50..efdfe3b3 100644 --- a/example_data.py +++ b/example_data.py @@ -93,8 +93,8 @@ class ExampleDataLoader: description="Supplemental information for the IDE number entered in Protocol Builder", category_id=0, display_order=3) - self.create_spec(id="ind_supplement", - name="ind_supplement", + self.create_spec(id="ind_update", + name="ind_update", display_name="IND Supplement Info", description="Supplement information for the Investigational New Drug(s) specified in Protocol Builder", category_id=0, diff --git a/tests/workflow/test_workflow_service.py b/tests/workflow/test_workflow_service.py index 748dcedc..f208eecb 100644 --- a/tests/workflow/test_workflow_service.py +++ b/tests/workflow/test_workflow_service.py @@ -1,4 +1,5 @@ import json +import unittest from tests.base_test import BaseTest @@ -88,6 +89,7 @@ class TestWorkflowService(BaseTest): WorkflowService.populate_form_with_random_data(task, task_api, required_only=False) self.assertTrue(isinstance(task.data["sponsor"], dict)) + @unittest.skip("RRT no longer needs to be supported") def test_fix_legacy_data_model_for_rrt(self): ExampleDataLoader().load_rrt() # Make sure the research_rampup is loaded, as it's not a test spec. workflow = self.create_workflow('research_rampup') diff --git a/tests/workflow/test_workflow_spec_validation_api.py b/tests/workflow/test_workflow_spec_validation_api.py index d79986cf..2a5b5455 100644 --- a/tests/workflow/test_workflow_spec_validation_api.py +++ b/tests/workflow/test_workflow_spec_validation_api.py @@ -1,4 +1,5 @@ import json +import unittest from unittest.mock import patch from tests.base_test import BaseTest @@ -51,6 +52,7 @@ class TestWorkflowSpecValidation(BaseTest): app.config['PB_ENABLED'] = True self.validate_all_loaded_workflows() + @unittest.skip("RRT no longer needs to be supported") def test_successful_validation_of_rrt_workflows(self): self.load_example_data(use_rrt_data=True) self.validate_all_loaded_workflows()