From d4adcd31753c7922d4cf6f44e8ae2670f13aa1d1 Mon Sep 17 00:00:00 2001 From: Niklaus Giger Date: Wed, 9 Jul 2014 12:54:06 +0200 Subject: [PATCH] Adding debug printing prescription. Take 22 Signed-off-by: Niklaus Giger --- src/custom/lookandfeelbase.rb | 7 ++--- src/plugin/yaml.rb | 6 ++-- src/state/global.rb | 25 +++++++++------- src/util/validator.rb | 3 +- src/view/admin/entity.rb | 2 +- src/view/companies/fipi_overview.rb | 2 +- src/view/drugs/prescription.rb | 45 +++++++++++++++++++++++----- src/view/drugs/result.rb | 2 +- src/view/form.rb | 3 +- src/view/interactions/interaction_chooser.rb | 1 + src/view/searchbar.rb | 1 + 11 files changed, 67 insertions(+), 30 deletions(-) diff --git a/src/custom/lookandfeelbase.rb b/src/custom/lookandfeelbase.rb index f51b152..189b7fb 100644 --- a/src/custom/lookandfeelbase.rb +++ b/src/custom/lookandfeelbase.rb @@ -1368,7 +1368,7 @@ Zeno Davatz :prescription_quantity_evening => 'Abends', :prescription_quantity_night => 'Nachts', :prescription_method_as_necessary => 'Nach Bedarf', - :prescription_method_regulaly => 'Nach Vorschrift', + :prescription_method_regularly => 'Nach Vorschrift', :prescription_comment => 'Bemerkungen', :prescription_generic => 'Original mit Generikum in der SL', :prescription_type_generic => 'aut genericum', @@ -1576,7 +1576,6 @@ Zeno Davatz :th_connection_key => 'Verbindungsschlüssel', :th_count => '50', :th_c_type => "Komplementärprodukt", - :th_cyp450s => 'Substrat von', :th_date => 'Datum', :th_description => ' ', :th_download_link => 'Download', @@ -2810,7 +2809,7 @@ Zeno Davatz :prescription_quantity_evening => 'Soir', :prescription_quantity_night => 'Coucher', :prescription_method_as_necessary => 'à la demande', - :prescription_method_regulaly => 'strictement selon la prescription', + :prescription_method_regularly => 'strictement selon la prescription', :prescription_comment => 'Remarques', :prescription_generic => 'Original avec Générique dans LS', :prescription_type_generic => 'aut genericum', @@ -2966,7 +2965,6 @@ Zeno Davatz :th_company_url => 'Adresse internet', :th_comparable_size => 'Taille des prés.', :th_compositions => 'Composition', - :th_cyp450s => 'Substrat de', :th_ddd_price => 'CQ', :th_ddd_price_title => 'Coût quotidien', :th_deductible => 'QP', @@ -4249,7 +4247,6 @@ Zeno Davatz :th_comparable_size => 'Package Size', :th_compositions => 'Composition', :th_connection_key => 'Verbindungsschlüssel', - :th_cyp450s => 'Substrat of', :th_ddd_price => 'DC', :th_ddd_price_title => 'Daily cost', :th_de_description => 'German description', diff --git a/src/plugin/yaml.rb b/src/plugin/yaml.rb index 968570c..c6c3e42 100644 --- a/src/plugin/yaml.rb +++ b/src/plugin/yaml.rb @@ -27,11 +27,13 @@ module ODDB end def export_galenic_forms(name='galenic_forms.yaml') forms = [] - @app.each_galenic_form{|form| forms << form} + @app.each_galenic_form.sort.map { |key,value| forms << value} export_array(name, forms.values) end def export_galenic_groups(name='galenic_groups.yaml') - export_array(name, @app.galenic_groups.values) + groups = [] + @app.galenic_groups.sort.map { |key,value| groups << value } + export_array(name, groups) end def check_infos(name, group, &block) # Check missing data of fachinfo/patinfo data diff --git a/src/state/global.rb b/src/state/global.rb index 0a7fade..699c2e5 100644 --- a/src/state/global.rb +++ b/src/state/global.rb @@ -293,6 +293,9 @@ module ODDB when :user proceed_download.checkout when :drugs + x = %( +) + $stdout.puts "state.global.checkout drugs ean #{@session.user_input(:ean)} drugs #{@session.persistent_user_input(:drugs)}" export_csv.checkout end end @@ -362,7 +365,8 @@ module ODDB State::Hospitals::HospitalList.new(@session, model) end def export_csv - if(@session.zone == :drugs) + $stdout.puts "state.global.export_csv zone #{@session.zone} State::Drugs::Result #{self.search.is_a?(State::Drugs::Result)}ean #{@session.user_input(:ean)} drugs #{@session.persistent_user_input(:drugs)}" + if(@session.zone == :drugs) state = self.search if(state.is_a?(State::Drugs::Result)) state.export_csv @@ -517,15 +521,13 @@ module ODDB end end def print - ean13 = nil - pack = nil - ean13 = @session.user_input(:ean) if @session.user_input(:prescription) - pack = @session.app.package_by_ean13(ean13) if @session.user_input(:prescription) and ean13 - $stdout.puts "state.global.print prescription #{@session.user_input(:prescription).inspect} ean13 #{ean13.inspect} pack #{pack.inspect} " - if @session.user_input(:prescription) and - ean13 = @session.user_input(:ean) and - pack = @session.app.package_by_ean13(ean13) - State::Drugs::PrescriptionPrint.new(@session, pack) + $stdout.puts "state.global.print"; $stdout.flush + state = self.search + drugs = @session.persistent_user_input(:drugs) + if drugs # and state.is_a?(State::Drugs::Result) + $stdout.puts "state.global.print zone #{@session.zone} #{state.class} == State::Drugs::Result #{state.is_a?(State::Drugs::Result)} drugs #{drugs.inspect}" + $stdout.flush + State::Drugs::PrescriptionPrint.new(@session, nil) elsif @session.user_input(:pointer) self elsif iksnr = @session.user_input(:reg) and @@ -623,6 +625,7 @@ module ODDB end end def rezept + $stdout.puts "state.global rezept" State::Drugs::Prescription.new(@session, nil) end @@ -786,6 +789,7 @@ module ODDB zone = @session.zone query = @session.persistent_user_input(:search_query) if(query.is_a? RuntimeError) + $stdouts.puts "query resulted in RuntimeError for #{@session.persistent_user_input(:search_query)}" State::Exception.new(@session, query) elsif(!query.nil?) if zone == :migel @@ -844,6 +848,7 @@ module ODDB rescue ODBA::OdbaResultLimitError exception = SBSM::InvalidDataError.new(:e_huge_search_result, :search_query, query) + $stdouts.puts "query OdbaResultLimitError" State::Exception.new(@session, exception) end alias :result :search diff --git a/src/util/validator.rb b/src/util/validator.rb index 94e0628..516f081 100644 --- a/src/util/validator.rb +++ b/src/util/validator.rb @@ -357,7 +357,7 @@ module ODDB :prescription_quantity_evening, :prescription_quantity_night, :prescription_method_as_necessary, - :prescription_method_regulaly, + :prescription_method_regularly, :prescription_type_generic, :prescription_type_original, :prescription_repetition, @@ -607,6 +607,7 @@ module ODDB valid[0] end else + $stdout.puts "Raising e_invalid_#{key} for #{key} #{value} range #{range}, pad #{pad}" raise SBSM::InvalidDataError.new("e_invalid_#{key}", key, value) end end diff --git a/src/view/admin/entity.rb b/src/view/admin/entity.rb index 7e52e42..4585aca 100644 --- a/src/view/admin/entity.rb +++ b/src/view/admin/entity.rb @@ -77,7 +77,7 @@ class YusGroups < HtmlGrid::List "if(this.value == '#{txt}') this.value='';") input.set_attribute("onblur", "if(this.value == '') this.value='#{txt}';") - self.onsubmit = "if(this.valid_until.value == '#{txt}') this.valid_until.value = ''; true;" + self.onsubmit = "console.log('YusGroups'); if(this.valid_until.value == '#{txt}') this.valid_until.value = ''; true;" input.value = txt end input diff --git a/src/view/companies/fipi_overview.rb b/src/view/companies/fipi_overview.rb index 65b2665..4478046 100644 --- a/src/view/companies/fipi_overview.rb +++ b/src/view/companies/fipi_overview.rb @@ -47,7 +47,7 @@ class ExportCSV < View::Form def init super url = @lookandfeel._event_url(:export_csv) - self.onsubmit = "location.href='#{url}';return false;" + self.onsubmit = "console.log('ExportCSV:SearchBar:onsubmit: '+ url); location.href='#{url}';return false;" end end class FiPiOverviewList < HtmlGrid::List diff --git a/src/view/drugs/prescription.rb b/src/view/drugs/prescription.rb index e5508cd..1bd34b4 100644 --- a/src/view/drugs/prescription.rb +++ b/src/view/drugs/prescription.rb @@ -187,7 +187,7 @@ var month = document.getElementById('per_month_#{@index}') var repetition = document.getElementById('repetition_#{@index}') month.disabled = false; repetition.value = '1'; -repetition.disabled = true; +repetition.disabled = false; JS attrs = { 'onClick' => js, @@ -377,8 +377,6 @@ class PrescriptionDrugDiv < HtmlGrid::Div @value << PrescriptionDrug.new(drug, @session, self) } end -# was super -# was @value = PrescriptionDrug.new(@model, @session, self) end def to_html(context) html = super @@ -453,11 +451,14 @@ class PrescriptionForm < View::Form DEFAULT_CLASS = HtmlGrid::Value LABELS = true def prescription_for(model, session) + $stdout.puts "prescription_for model #{model.inspect}" fields = [] fields << @lookandfeel.lookup(:prescription_for) fields << '   ' %w[first_name family_name birth_day].each do |attr| key = "prescription_#{attr}".to_sym + $stdout.puts "prescription_for key #{key.inspect}" + $stdout.puts "prescription_for value #{@lookandfeel.lookup(key).inspect}" fields << @lookandfeel.lookup(key) fields << ' ' input = HtmlGrid::InputText.new(key, model, session, self) @@ -485,6 +486,7 @@ class PrescriptionForm < View::Form def hidden_fields(context) hidden = super # main drug + $stdout.puts "hidden_fields model #{model.inspect} ean #{@model ? @model.barcode : 'unknown'}" hidden << context.hidden('ean', @model.barcode) if @model hidden << context.hidden('prescription', true) hidden @@ -563,6 +565,7 @@ class PrescriptionPrintInnerComposite < HtmlGrid::Composite def name(model, session=@session) span = HtmlGrid::Span.new(model, session, self) span.value = '' + return span unless model span.value << model.name_with_size if price = model.price_public span.value << ' - ' @@ -579,7 +582,7 @@ class PrescriptionPrintInnerComposite < HtmlGrid::Composite fields = [] [:morning, :noon, :evening, :night].each do |at_time| key = "prescription_quantity_#{at_time.to_s}".to_sym - if quantities = session.user_input(key) and quantity = quantities[@index] and + if model and quantities = session.user_input(key) and quantity = quantities[@index] and quantity =~ /^[0-9]+$/ and !quantity.to_i.zero? fields << '
' if fields.empty? fields << HtmlGrid::LabelText.new(key, model, session, self) @@ -594,6 +597,7 @@ class PrescriptionPrintInnerComposite < HtmlGrid::Composite fields end def timing_value(model, session=@session) + return unless model timings = session.user_input(:prescription_timing) name = case timings[@index] when '1'; :prescription_timing_before_meal; @@ -608,11 +612,13 @@ class PrescriptionPrintInnerComposite < HtmlGrid::Composite end def method_value(model, session=@session) fields = [] - [:as_necessary, :regulaly].each do |method| + return fields unless model + [:as_necessary, :regularly].each do |method| key = "prescription_method_#{method.to_s}".to_sym if methods = session.user_input(key) and name = methods[@index] text = HtmlGrid::Value.new(name, model, session, self) - text.value = @lookandfeel.lookup(key) + $stdout.puts "Lookuin via key #{key} or #{name}" + text.value = @lookandfeel.lookup(name) fields << '
' if fields.empty? fields << text fields << '
' @@ -623,6 +629,7 @@ class PrescriptionPrintInnerComposite < HtmlGrid::Composite end def term_value(model, session=@session) fields = [] + return fields unless model terms = session.user_input(:prescription_term) name = case terms[@index] when '1'; :prescription_term_once; @@ -650,6 +657,7 @@ class PrescriptionPrintInnerComposite < HtmlGrid::Composite end end def comment_value(model, session=@session) + return unless model if texts = session.user_input(:prescription_comment) and comment_text = texts[@index] text = HtmlGrid::Value.new(:prescription_comment, model, session, self) @@ -684,9 +692,11 @@ class PrescriptionPrintComposite < HtmlGrid::DivComposite } def init @drugs = @session.persistent_user_input(:drugs) + $stdout.puts "PrescriptionPrintComposite.init #{@drugs}" super end def prescription_for(model, session=@session) + $stdout.puts "PrescriptionPrintComposite.prescription_for #{model.inspect}" fields = [] fields << HtmlGrid::LabelText.new(:prescription_for, model, session, self) %w[first_name family_name birth_day].each do |attr| @@ -750,10 +760,23 @@ class Prescription < View::PrivateTemplate end class PrescriptionPrint < View::PrintTemplate CONTENT = View::Drugs::PrescriptionPrintComposite + def init + @drugs = @session.persistent_user_input(:drugs) + @index = (@drugs ? @drugs.length : 0).to_s + if @model and @drugs and !@drugs.empty? + @index = @drugs.keys.index(@model.barcode).to_s + end + $stdout.puts "PrescriptionPrint.init #{@drugs} #{@index} \n@model #{@model.inspect}" + super + end def head(model, session=@session) span = HtmlGrid::Span.new(model, session, self) + drugs = @session.persistent_user_input(:drugs) + $stdout.puts "PrescriptionPrint.head #{drugs.inspect} xxx #{drugs.keys.join(',')}" + $stdout.puts "PrescriptionPrint: model #{model.inspect}" span.value = @lookandfeel.lookup(:print_of) + - @lookandfeel._event_url(:rezept, [:ean, model.barcode]) + @lookandfeel._event_url(:print, [:rezept, :ean, drugs.keys].flatten) + $stdout.puts "PrescriptionPrint: span.value #{span.value }" span end end @@ -765,6 +788,7 @@ class PrescriptionCsv < HtmlGrid::Component :company_name, ] def init + $stdout.puts "PrescriptionCsv.init" super @coder = HTMLEntities.new end @@ -774,6 +798,7 @@ class PrescriptionCsv < HtmlGrid::Component prescription_for << user_input(attr) end name = @lookandfeel.lookup(:prescription).dup + '_' + name ||= '_' unless prescription_for.empty? name << prescription_for.join('_').gsub(/[\s]+/u, '_') else @@ -888,6 +913,8 @@ class PrescriptionCsv < HtmlGrid::Component text = lookup(key) + ' ' text << quantity.to_s _value << [text] + else + _value << [] end end _value @@ -902,10 +929,12 @@ class PrescriptionCsv < HtmlGrid::Component end def method_value # checkbox _value = [] - [:as_necessary, :regulaly].each do |method| + [:as_necessary, :regularly].each do |method| key = "method_#{method}" if user_input(key) _value << [lookup(key)] + else + _value << [] end end _value diff --git a/src/view/drugs/result.rb b/src/view/drugs/result.rb index 69651c8..2d62c41 100644 --- a/src/view/drugs/result.rb +++ b/src/view/drugs/result.rb @@ -41,7 +41,7 @@ class DivExportCSV < HtmlGrid::DivForm :search_type => @session.persistent_user_input(:search_type), } url = @lookandfeel._event_url(:export_csv, data) - self.onsubmit = "location.href='#{url}';return false;" + self.onsubmit = "console.log('DivExportCSV: on_submit: '+ url); location.href='#{url}'; return false;" end def example(model) super('Inderal.Preisvergleich.csv') diff --git a/src/view/form.rb b/src/view/form.rb index 4355a8d..310eb45 100644 --- a/src/view/form.rb +++ b/src/view/form.rb @@ -44,7 +44,8 @@ module ODDB end def post_event_button(event) button = HtmlGrid::Button.new(event, @model, @session, self) - script = "this.form.event.value='"+event.to_s+"'; this.form.submit();" + script = "console.log('post_event_button: ' + event.to_s); this.form.event.value='"+event.to_s+"'; this.form.submit();" + $stdout.puts "Adding post_event_button: script #{script}" button.set_attribute("onclick", script) button end diff --git a/src/view/interactions/interaction_chooser.rb b/src/view/interactions/interaction_chooser.rb index 0a74d3f..1ad1786 100644 --- a/src/view/interactions/interaction_chooser.rb +++ b/src/view/interactions/interaction_chooser.rb @@ -173,6 +173,7 @@ class InteractionChooserDrug < HtmlGrid::Composite @attributes.store('id', 'drugs_' + @model.barcode) end self.onsubmit = <<-JS +console.log("InteractionChooserDrug:onsubmit xxx"); function get_to(url) { var form = document.createElement("form"); form.setAttribute("method", "GET"); diff --git a/src/view/searchbar.rb b/src/view/searchbar.rb index 0f0ef60..4f48b18 100644 --- a/src/view/searchbar.rb +++ b/src/view/searchbar.rb @@ -173,6 +173,7 @@ class SearchBar < HtmlGrid::InputText # because location stops gif animation. param = @lookandfeel.disabled?(:best_result) ? nil : " + '#best_result'" self.onsubmit = <<-JS +console.log("SearchBar:onsubmit xxx"); #{GET_TO_JS} if (#{@name}.value!='#{val}') { #{timer} -- 2.0.0