Commit Graph

46 Commits

Author SHA1 Message Date
Dan Funk cd7f67ab48 A major refactor of how we search and store files, as there was a lot of confusing bits in here.
From an API point of view you can do the following (and only the following)

/files?workflow_spec_id=x
* You can find all files associated with a workflow_spec_id, and add a file with a workflow_spec_id
/files?workflow_id=x
* You can find all files associated with a workflow_id, and add a file that is directly associated with the workflow
/files?workflow_id=x&form_field_key=y
* You can find all files associated with a form element on a running workflow, and add a new file.
   Note: you can add multiple files to the same form_field_key, IF they have different file names. If the same name, the original file is archived,
   and the new file takes its place.

The study endpoints always return a list of the file metadata associated with the study.  Removed /studies-files, but there is an
endpoint called

/studies/all  - that returns all the studies in the system, and does include their files.

On a deeper level:
 The File model no longer contains:
  - study_id,
  - task_id,
  - form_field_key

Instead, if the file is associated with workflow - then that is the one way it is connected to the study, and we use this relationship to find files for a study.
A file is never associated with a task_id, as these change when the workflow is reloaded.
The form_field_key must match the irb_doc_code, so when requesting files for a form field, we just look up the irb_doc_code.
2020-05-28 08:27:26 -04:00
Dan Funk 6cd4ef64d1 Fixing add_study api endpoint, so you can actually add a new "Study" with just some basic information.
Using the LDAP service for checking user details in development mode - even if you are using the back door.
Added a new Flask fucntion load-example-rrt-data that loads the rrt workflow, and not the CRC wrokflows.
Modified the "load-example-data" in the tests to use some test data, rather than loading up all the workflows[
in CRC each time, with a parameter to load crc data if that is required - which is enabled for just a handful of tests.
(Tests run in 1/4 the time now)
2020-05-25 12:29:05 -04:00
Dan Funk 571c1d7d24 Merge branch 'feature/rrp-endpoints' into feature/disable_protocol_builder 2020-05-22 16:18:33 -04:00
Dan Funk 503c1c8f18 Allow disabling the Protocol Builder
PB_ENABLED can be set to false in the configuration (either in a file called instance/config.py, or as an environment variable)

Added a check in the base_test, to assure that we are always running tests with the test configuration, and bail out otherwise.  Setting TESTING=true as an environment variable will get this, but so well the correct ordering of imports. Just be dead certain the first file every test file imports is base_test.py.

Aaron was right, and we call the Protocol Builder in all kinds of awful places.  But we don't do this now.  So Carlos, you should have the ability to reuse a lot of the logic in the study_service now.

I dropped the poorly named "study-update" endpoint completely.  We weren't using it. POST and PUT to Study still work just fine for doing exactly that.

All the tests now run and pass with the Protocol builder disabled. Tests that specifically check PB behavior turn it back on for the test, or mock it out.
2020-05-22 14:37:49 -04:00
Carlos Lopez 1ed7930aab Endpoint for studies with files 2020-05-22 09:46:03 -06:00
Dan Funk 2699f5c65c Refactor the stats models, and assure they are very correct across all tests with the workflow api.
I noticed we were saving the workflow every time we loaded it up, rather than only when we were making changes to it.  Refactored this to be a little more careful.
Centralized the saving of the workflow into one location in the processor, so we can make sure we update all the details about that workflow every time we save.
The workflow service has a method that will log any task action taken in a consistent way.
The stats models were removed from the API completely.  Will wait for a use case for dealing with this later.
2020-05-04 10:57:09 -04:00
Dan Funk fd0adb1d43 Updated the study status to use a different enumeration. Migration correctly handles modifying the enum.
INCOMPLETE = 'Incomplete in Protocol Builder',
  ACTIVE = 'Active / Ready to roll',
  HOLD = 'On Hold',
  OPEN = 'Open - this study is in progress',
  ABANDONED = 'Abandoned, it got deleted in Protocol Builder'
2020-04-21 17:13:30 -04:00
Dan Funk 316b9e6e8d Fixing a stupid mistake - must have typed a ' mark during commit.
Script should inherit from object.
Updating the ids so I could more easily test and assure things were working correctly.
2020-04-08 13:39:42 -04:00
Dan Funk c79415a794 throw a sensible error when study is not found on get_study (don't 500)
some ugly fixes in the file_service for improving panda output from spreadsheet processing that I need to revist.
now that the spiff-workflow handles multi-instance, we can't have random multi-instance tasks around.
Improved tests around study deletion.
2020-04-08 13:28:43 -04:00
Dan Funk 34b6ec92bf updating the API
Removing the call for study/workflows - as workflow information is returned with the study by default.
Fixing a bug in the workflow spec model schema.
2020-03-30 10:12:10 -04:00
Dan Funk 4a916c1ee3 Created a "StudyService" and moved all complex logic around study manipulation out of the study api, and this service, as things were getting complicated. The Workflow Processor no longer creates the WorkflowModel, the study object handles that, and only passes the model into the workflow processor when it is ready to start the workflow.
Created a Study object (seperate from the StudyModel) that can cronstructed on request, and contains a different data structure than we store in the DB. This allows us to return underlying Categories and Workflows in a clean way.

Added a new status to workflows called "not_started", meaning we have not yet instantiated a processor or created a BPMN, they have no version yet and no stored data, just the possiblity of being started.

The Top Level Workflow or "Master" workflow is now a part of the sample data, and loaded at all times.

Removed the ability to "add a workflow to a study" and "remove a workflow from a study", a study contains all possible workflows by definition.

Example data no longer creates users or studies, it just creates the specs.
2020-03-30 08:00:16 -04:00
Dan Funk 907e1cbbb3 minor fixes that were breaking when connecting to the front end. 2020-03-27 14:27:50 -04:00
Dan Funk b61a35f956 Merge remote-tracking branch 'origin/master' into feature/status_refactor
Fixing adding a study so all workflows are again added, will add status on those workflows based on output from the master bpmn diagram, which is coming shortly.
2020-03-27 11:55:36 -04:00
Dan Funk e2c408b70d Removed all self-referential calls in the study_api. One api endpoint should never call another api endpoint. Moved the logic for updating a study to the study Model, rather than checking and setting dictionary values which will become very hard to maintain.
The protocol builder service now returns real models, not dictionaries, forcing proper validation and fail-fast behavior.
Changed the name of the "status" spec, to "top_level_workflow" and removing any connection a workflow or study has with this specification.  It is only unused to determine status in real time, and is not reused or tracked.
Modified the required documents script to return a dictionary and not an array, making it easier to speak to specific values in the BPMN and DMN.
Working on new ways to test the top_level_workflow in the context of updates, this is still a work in progress.
Making use of several modifications to the Spiff library that enables more complex expressions in DMN models. This is evident in the new DMN models for the top_level_workflow
2020-03-26 12:51:53 -04:00
Dan Funk f4342fc785 It became impossible to use the Swagger ui when we started adding authentication to all of the calls. I discovered Connexion and Swagger have a default way of handing JTW authentication and this cleans up our code quite a bit, moves the securing of endpoints into the API Definition, which is quite nice, and removes a whole library dependency (I never get to do that!) I added a SWAGGER_AUTH_KEY that can be used in non-production environments to allow users to quickly authenticate from the Swagger ui. I also removed all api calls to simple little happy api services, because that is just mean and pointless. 2020-03-24 14:15:21 -04:00
Dan Funk 967ac65d0e Just raise the ApiError, no need to marshal it. 2020-03-23 12:22:26 -04:00
Aaron Louie f0678b43d4 Minor fixes 2020-03-18 16:58:50 -04:00
Aaron Louie f9dbbefe89 Adds status spec to study when workflow is added. 2020-03-16 08:05:30 -04:00
Aaron Louie bdd07685c6 Adds status spec when adding a study, and adds/removes workflows from study based on output data from status spec. 2020-03-15 15:54:13 -04:00
Aaron Louie 3262833102 Requires login 2020-03-11 15:27:22 -04:00
Dan Funk e91d7aff2f Fixes #11: adding a delete endpoint for studies. It won't delete studies that have workflows, you have to delete those first)
Removing the "default" error response from the api.yml, it was all noise.
2020-03-09 15:12:40 -04:00
Aaron Louie acad0023d2 Fixes a bug in get_study_workflows and adds a test covering it 2020-03-06 10:52:41 -05:00
Dan Funk 9fcd6f38f4 Merge remote-tracking branch 'origin/master' into feature/pb_services 2020-03-05 17:13:41 -05:00
Dan Funk 70611e2c1d Adding the version of the specification used to create a workflow to the workflow api endpoint. Though the exact content of this version is likely to change.
Split the API specific models out from the workflow models to help me keep this straight.
Added tests to help me understand the errors thrown the and resolution path when a workflow specification changes in the midst of a running workflow.
2020-03-05 11:18:20 -05:00
Aaron Louie f258090a0b Fixes broken unit test 2020-03-04 09:54:00 -05:00
Aaron Louie 8cbd6f892f WIP: Mocks study details PB endpoint response 2020-03-03 20:56:46 -05:00
Aaron Louie 01720a8bbf Replaces migration and fixes broken tests 2020-03-03 16:02:01 -05:00
Aaron Louie 668de6c4dc Edits Protocol Builder statuses 2020-03-03 15:46:20 -05:00
Aaron Louie 4534b0c2df Updates study model to better match Protocol Builder. Deletes all migrations and starts over, since Alembic has problems migrating changes to existing column constraints. 2020-02-28 11:14:30 -05:00
Aaron Louie 0cc59d0974 Adds study inactive flag. Sets study to inactive if not found in Protocol Builder. 2020-02-27 11:17:58 -05:00
Aaron Louie f3068e68db Adds user to example data. Requires login before adding/updating a study. 2020-02-27 10:30:16 -05:00
Aaron Louie 27d7afb656 Adds Protocol Builder models and schemas. Reorganizes and cleans up some files. 2020-02-27 09:54:46 -05:00
Aaron Louie 3ef4860391 Adds user_uid and investigator_ids fields to Study. Gets studies from protocol builder and adds them if they aren't already in the database 2020-02-26 18:06:51 -05:00
Aaron Louie 443d38a9a1 Prevents duplication of study on update. 2020-02-21 11:24:51 -05:00
Dan Funk 2cc6010c8d Protocol builder connections 2020-02-20 13:30:04 -05:00
Dan Funk 1d24ebe382 Provide a script for generating word documents from template files. Refractored file managment into a service to make it easier to programatically add files. Modified the workflow_processor to inject the study_id and workflow_id into the running workflow so that this meta-information is avialable at the task level. 2020-02-10 16:19:23 -05:00
Dan Funk 9bd93748be Returning better cleaner information about workflow with the workflow endpoint. Removes the get_all_tasks and get_user_tasks endpoints as tasks are returned with the workflow. Workflow endpoint also includes the last task and next_task, which may or may not be user tasks. The task "type" returned is now the class name of the task_spec, rather than just the word "task". 2020-02-07 11:34:44 -05:00
Dan Funk 3fb831bae4 When you create a study, all possible workflows are then associated with that study. 2020-01-30 09:11:17 -05:00
Aaron Louie a3b6e4fc7f Fixes import paths 2020-01-24 11:52:52 -05:00
Aaron Louie 50dfa561a9 Fixes import paths, which were screwing up stuff. 2020-01-24 09:29:50 -05:00
Aaron Louie fe15799ee1 Adds type hinting to db and session to fix Pycharm autocomplete. Replaces db.session with session. 2020-01-14 11:45:12 -05:00
Aaron Louie e75da611ca Adds endpoints for creating and updating a Study. 2020-01-03 11:44:24 -05:00
Dan Funk c4cbaeb64e Refactor models into seperate directories 2019-12-31 16:32:47 -05:00
Dan Funk fb465531ca Add the ability to delete a workflow. 2019-12-30 13:15:39 -05:00
Dan Funk 91a91e9677 Read workflow configuration from the database, and not from a file.
And dropping the API call in the Fact Service so we aren't hitting external apis for the time being.
2019-12-30 11:07:26 -05:00
Dan Funk 0b71833946 Adding file management. Files are stored in the database along with basic meta data. 2019-12-27 13:50:03 -05:00