Created
April 15, 2018 13:36
-
-
Save rafbm/a6c331ceb79fcfc2cd58b83fc1778b3f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def call | |
scope = base_relation.joins(:care_periods) | |
if params.care_provider_id.present? | |
scope = scope | |
.where(care_periods: { care_provider_id: params.care_provider_id }) | |
end | |
if params.hospital_id.present? | |
scope = scope | |
.where(care_periods: { hospital_id: params.hospital_id }) | |
end | |
if params.discharge_period.present? | |
scope = scope.joins(:hospital_visit) | |
.where(hospital_visits: { end_on: params.discharge_period } | |
end | |
scope | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment