Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search filters for overdue patients #907

Merged
merged 45 commits into from May 13, 2020

Conversation

rsanheim
Copy link
Contributor

@rsanheim rsanheim commented Apr 27, 2020

Story card: https://www.pivotaltracker.com/n/projects/2184102/stories/172537522/

Because

We want more filtering abilities on the overdue list.

This addresses

This adds search filters to the overdue listing. I ended up extracting to a small query class to keep things a bit cleaner.

Because there are two different filters w/ different forms on the page, we needed to add hidden field tags to maintain state. See the inline code comments for details. It isn't ideal, but combining the forms was beyond my bootstrap / layout abilities.

TODO

  • Extract the filtering piece out of the controller
  • ask about auto applying filters vs having a button
  • Use form attribute to resolve two forms problem
  • Fix up mobile view filter display
  • Extract the filters to a helper or some other better place
  • Handle the 'has phone number' and 'no phone number' case

This adds https://github.com/guard/guard-rspec, which wire up guard and
guard-rspec to get continual, fast testing while working locally.
This is all generated by the guard-rspec setup, we can modify it as we
see fit to match our project and conventions.
Allows running just specific specs by changing "it" to "fit" in rspec
@harimohanraj89 harimohanraj89 temporarily deployed to simple-search-filters-f-wng34h April 27, 2020 21:05 Inactive
@harimohanraj89 harimohanraj89 temporarily deployed to simple-search-filters-f-wng34h April 28, 2020 13:34 Inactive
Need this for the new sidebar with search filters
@harimohanraj89 harimohanraj89 temporarily deployed to simple-search-filters-f-wng34h April 28, 2020 19:15 Inactive
@harimohanraj89 harimohanraj89 temporarily deployed to simple-search-filters-f-wng34h April 28, 2020 21:00 Inactive
Removing unused filters; adjusting copy
@harimohanraj89 harimohanraj89 temporarily deployed to simple-search-filters-f-wng34h April 28, 2020 21:25 Inactive
This is tricky because they are in different forms, so we need to use
hidden fields to keep the state.

We should probably just merge the forms if at all possible here.
@harimohanraj89 harimohanraj89 temporarily deployed to simple-search-filters-f-wng34h April 28, 2020 22:18 Inactive
Ugh this was gnarly.  Forms that are GETs ignore the query string in
their action, so we *have* to pass around the state via hidden field
tags.
@harimohanraj89 harimohanraj89 temporarily deployed to simple-search-filters-f-wng34h April 29, 2020 17:26 Inactive
@harimohanraj89 harimohanraj89 temporarily deployed to simple-search-filters-f-wng34h April 29, 2020 17:27 Inactive
This all should be another object, but not until we know where else
these filters are going to be used
@harimohanraj89 harimohanraj89 temporarily deployed to simple-search-filters-f-wng34h April 29, 2020 17:39 Inactive
@harimohanraj89 harimohanraj89 temporarily deployed to simple-search-filters-f-wng34h April 29, 2020 17:44 Inactive
Copy link
Contributor Author

@rsanheim rsanheim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is more to do here, but I'd like to get an early review from some folks. Leaving some notes here for context.

app/controllers/appointments_controller.rb Show resolved Hide resolved
@@ -38,6 +41,37 @@ def update

private

def apply_search_filters
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the query logic - eventually I'd like to have this in a PatientSummarySearch object or something, but want to know where else we are going to be searching patients like this w/ other dashboards.

app/controllers/appointments_controller.rb Outdated Show resolved Hide resolved
@@ -0,0 +1,99 @@
<% content_for(:content) do %>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new layout was mostly modeled after the my facilities layout, which has a similar sidebar.

app/views/layouts/overdue.html.erb Outdated Show resolved Hide resolved
app/views/shared/_paginate_and_filter_by_facility.html.erb Outdated Show resolved Hide resolved
@@ -11,6 +11,9 @@
RSpec.configure do |config|
SimpleCov.start

config.filter_run focus: true
config.run_all_when_everything_filtered = true
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just making rspec smarter so it respects focused specs. Makes guard much nicer to use.

@rsanheim rsanheim requested review from harimohanraj89, timcheadle and kitallis and removed request for kitallis May 1, 2020 19:32
@harimohanraj89 harimohanraj89 temporarily deployed to simple-search-filters-f-wng34h May 1, 2020 19:32 Inactive
Copy link
Contributor

@harimohanraj89 harimohanraj89 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks awesome! I've left my feedback below. One big suggestion around using some JS, and a smattering of smaller things.

app/controllers/appointments_controller.rb Show resolved Hide resolved
app/controllers/appointments_controller.rb Show resolved Hide resolved
app/controllers/appointments_controller.rb Outdated Show resolved Hide resolved
where(status: 'scheduled')
.where(arel_table[:scheduled_date].lt(Date.current))
.where(arel_table[:remind_on].eq(nil).or(arel_table[:remind_on].lteq(Date.current)))
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that we've got this in here, I'd love to update the overdue spec to use this one.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other option related to this conversation is that we introduce a lost_to_followup scope, and we union or or the scopes based on checkbox selections.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rsanheim, <bump>, should we update the overdue scope to use this method?

app/queries/patient_summary_query.rb Outdated Show resolved Hide resolved
spec/controllers/appointments_controller_spec.rb Outdated Show resolved Hide resolved
spec/controllers/appointments_controller_spec.rb Outdated Show resolved Hide resolved
spec/queries/patient_summary_query_spec.rb Show resolved Hide resolved
spec/queries/patient_summary_query_spec.rb Show resolved Hide resolved
And simplify the default search filter logic in appointments controller
@harimohanraj89 harimohanraj89 temporarily deployed to simple-search-filters-f-wng34h May 5, 2020 17:22 Inactive
@harimohanraj89 harimohanraj89 temporarily deployed to simple-search-filters-f-wng34h May 5, 2020 17:23 Inactive
@harimohanraj89 harimohanraj89 temporarily deployed to simple-search-filters-f-wng34h May 5, 2020 18:58 Inactive
app/views/layouts/overdue.html.erb Outdated Show resolved Hide resolved
app/views/layouts/overdue.html.erb Outdated Show resolved Hide resolved
app/queries/patient_summary_query.rb Show resolved Hide resolved
@rsanheim
Copy link
Contributor Author

rsanheim commented May 6, 2020 via email

This overrides the facility / pagination select forms so that they post
to the search filters form when on the Overdue listing. This means
everything goes through the same form for this page, which makes
managing the state much easier, and we don't need hidden fields leaking
into both forms.

This also fixes up the filters to work more better in the mobile view.
these cancel each other out, effectively
Copy link
Contributor

@timcheadle timcheadle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! I tested locally and it looks great. Definitely want to see how it performs in sandbox.

Copy link
Contributor

@harimohanraj89 harimohanraj89 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only one outstanding comment from me. Pre-emptive approval for unblockage 🚀

These should really be renamed soon if we agree on the "lost to follow
up" terminology
@rsanheim
Copy link
Contributor Author

Only one outstanding comment from me. Pre-emptive approval for unblockage 🚀

Ah yup, took care of that. 👍

@rsanheim rsanheim merged commit dd3721e into master May 13, 2020
@rsanheim rsanheim deleted the search-filters-for-overdue-patients branch May 13, 2020 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants