ruby: drug_select_partials = Hash.new("default").tap do |h| h["Renalware::PD::PeritonitisEpisode"] = "peritonitis_episode" h["Renalware::PD::ExitSiteInfection"] = "exit_site_infection" end .document(data-controller="prescriptions") br = simple_form_for prescription, url: url, html: { class: "prescription-form", autocomplete: "off" }, remote: true, wrapper: :horizontal_form do |f| = render "renalware/shared/errors", model: f.object .med-form.content id=("edit-meds-#{f.object.id}" ) = render "renalware/medications/prescriptions/drug_select/#{drug_select_partials[f.object.treatable_type]}_fields", f: f = hidden_field_tag :treatable_type, treatable.class.name = f.input :dose_amount, wrapper: :horizontal_small = f.input :dose_unit, wrapper: :horizontal_small = f.association :medication_route, collection: medication_routes, label_method: :code, prompt: :translate, wrapper: :horizontal_medium = f.input :route_description , wrapper: :horizontal_medium = f.input :frequency, wrapper: :horizontal_small = f.input :administer_on_hd, wrapper: :horizontal_small = f.input :notes, wrapper: :horizontal_medium = f.input :prescribed_on, as: :date_picker, wrapper: :horizontal_datepicker - if f.object.new_record? = f.simple_fields_for(:termination) do |tf| = tf.input :terminated_on, as: :date_picker, required: false, wrapper: :horizontal_datepicker span(data-target= "prescriptions.providers") = f.input :provider, collection: provider_codes, as: :inline_radio_buttons, label_method: :to_label, wrapper: :horizontal_medium, input_html: { data: { action: "change->prescriptions#toggleDeliveryDates", target: "prescriptions.providers"} } / Only show this if home_delivery provider is active/selected. See prescriptions stimulus controller. .home_delivery_dates(style="display:none" data-target="prescriptions.homeDeliveryDates") .row .small-12.medium-4.large-3.columns .small-12.medium-8.large-9.columns label.right.inline Last home prescription date: b= l(f.object.last_delivery_date) .row .small-12.medium-4.large-3.columns .small-12.medium-8.large-9.columns label.right.inline Next home prescription date: b= l(f.object.next_delivery_date) .row.actions .small-9.columns = f.button :submit, "Save" span= " or " = link_to "cancel", patient_prescriptions_path(patient, treatable), remote: true