= render layout: "renalware/shared/fieldset", locals: { legend: "HD Drugs", name: "hd_prescriptions" } do .hd-drug-administrations = f.simple_fields_for :prescription_administrations, prescription_administrations do |fpa| - prescription = Renalware::Medications::PrescriptionPresenter.new(fpa.object.prescription) - administration = fpa.object / There are three possible states for a drug administration: / 1. administration.administered == nil -> no decision has been made / 2. administration.administered == false -> drug was not administered / 3. administration.administered == true -> drug was administered ruby: administration_klass = case administration.administered when true then "administered" when false then "not-administered" else "undecided" end # administration_klass = "not-administered" unless administration.administered? #- administration_klass = "undecided" if administration.administered.nil? .hd-drug-administration( data-token-count="#{'2' if administration.administrator_authorised? && administration.witness_authorised?}" class="#{administration_klass}" ) .summary .hd-drug .hd-drug--name= prescription.drug_name .hd-drug--dose= prescription.dose .hd-drug--route= prescription.route_code .hd-drug--frequency= prescription.frequency .hd-drug--prescribed-on= l(prescription.prescribed_on) .hd-drug--prescriber-name= prescription.updated_by - if prescription.terminated_on.present? .hd-drug--termination | Terminates .hd-drug--termination-date= l(prescription.terminated_on) .hd-drug-administered = fpa.input :administered, as: :inline_radio_buttons = fpa.input :prescription_id, as: :hidden .notes = fpa.label :notes = fpa.input :notes, label: false, wrapper: :zilch, input_html: { rows: 2 } .reason-why-not-administered = fpa.label :reason_id = fpa.association :reason, wrapper: :zilch .authentication( class="#{'disabled-with-faded-overlay' unless administration.administered?}" data-authentication-url=renalware.hd_prescription_administration_authorisations_path ) / Output username and password fields for administrator and witness - { administrator: :administered, witness: :witnessed }.each do |user_role, prefix| - authorised = administration.public_send(:"#{user_role}_authorised?") - token_symbol = :"#{user_role}_authorisation_token" .user-and-password( class="user-and-password--#{user_role} #{'authorised' if authorised} #{'error' if fpa.object.errors[token_symbol].any?}" ) = fpa.hidden_field token_symbol, class: "authentication-token" = fpa.label :"#{prefix}_by" = fpa.association :"#{prefix}_by", as: :user_picker, collection: Renalware::User.ordered, wrapper: :zilch, label: false, input_html: { class: "authentication-user-id" } / Password is only visible as long as the user has not been authenticated = password_field_tag :"#{prefix}_by_password", "", placeholder: "Password", class: "user-password", autocomplete: :off small.error.invalid-password Invalid password .confirmed i.fas.fa-check-circle = link_to "Clear", "#", class: "user-and-password--clear"