Sha256: 3926f61ded02440361fc1bee334eeead865885c269d6bf545f72a36a27e637fc
Contents?: true
Size: 1.17 KB
Versions: 7
Compression:
Stored size: 1.17 KB
Contents
# frozen_string_literal: true module Renalware module HD # Form object to help us map chosen input values in the HD MDM patient list filters form # into ransack predicates. Used in this instance because mapping the form's # schedule_definition_ids dropdown value in the format of e.g "[1, 3, 6]" into the # integer arry [1, 3, 6] is not something Ransack can do - hence this intermediate form object # to do the mapping. class MDMPatientsForm include ActiveModel::Model include Virtus::Model attribute :hospital_unit_id, Integer attribute :schedule_definition_ids, String # an Integer array in string form e.g. "[1 ,2]" # The hash returned here is passed into the Ransack #search method later i the ouery object. def ransacked_parameters { hd_profile_hospital_unit_id_eq: hospital_unit_id, hd_profile_schedule_definition_id_in: schedule_definition_ids_array } end private # Convert e.g. "[1,2,3]" to [1,2,3] def schedule_definition_ids_array return if schedule_definition_ids.blank? schedule_definition_ids.scan(/\d+/).map(&:to_i) end end end end
Version data entries
7 entries across 7 versions & 1 rubygems