require "inline_image" require "git_commit_sha" module Renalware module ApplicationHelper def patient_search ::Renalware::Patients::PatientSearch.call(params) end # For use in layouts def page_title(separator = Renalware.config.page_title_spearator) [ content_for(:page_title), Renalware.config.site_name ].compact.join(separator) end def breadcrumb_for(title, url) Renalware::Breadcrumb.new(title: title, anchor: link_to(title, url)) end def flash_messages flash.to_hash.reject{ |key| key.to_sym == :timedout } end # For use in pages def page_heading(title) content_for(:page_title){ title.html_safe } end def t?(key) t(key, cascade: false, raise: false, default: "").present? end def back_link_to(text, path) capture do link_to(path) do concat " ".html_safe concat text end end end def errors_css_class(model, attr) " field_with_errors" if model.errors.key?(attr) end def yes_no(bool) bool ? "Yes" : "No" end def default_for_associated(assoc, method, msg) assoc.present? ? assoc.public_send(method) : msg end def default_for_blank(val, msg) val.blank? ? msg : val end def default_for_blank_date(date, msg) date.blank? ? msg : l(date) end def default_for_blank_units(val, unit, msg) val.blank? ? msg : "#{val} #{unit}" end def medication_and_route(med_route) if med_route.blank? "No medication prescribed" else other_route = "Route: Other (Please specify in notes)" safe_join( med_route.map do |m| route = if m.medication_route.name == other_route m.medication_route.full_name else m.medication_route.name end "