ahcis-rds / study_finder

StudyFinder is a flexible and configurable application to pull studies from clinicaltrials.gov and augment the data from alternate datasources such as a clinical trials management system.
MIT License
17 stars 4 forks source link

Gracefully handle empty groups #87

Closed cdinger closed 3 years ago

cdinger commented 3 years ago

During setup and/or development a group that contains no conditions would previously cause an error (#65). This fixes the error, but also changes the behavior of empty groups.

Before this change the application would check for the no conditions case and instead return all studies. This is somewhat jarring/unexpected when you create a new group and see that it contains all studies (both in the results and the study counts). I think it makes more sense to make the default to be empty, and only include studies once matching conditions are added.

StudiesController#index was simplified a bit too during this change. I think this method had grown over time and built up some unneeded complexity. A new top-level Trial.execute_search (search is already taken by the elasticsearch gem) was introduced to handle the switch between a search with query text and a search with no query text. Eventually this model should probably be changed to include a method that builds out an appropriate search hash that can be fed to the Elasticsearch search method; there's a lot of duplication still here.

[Fixes #65]

cdinger commented 3 years ago

@johnsja it looks like I forgot to include a call to the existing replace_words method. I was going to move this into the Trial model but never did. I'll patch this up later today.