view · edit · sidebar · attach · print · history

20110810-migel-search-oddb_org

<< | Index | >>


  1. Make look and feel more nicely

Goal/Estimate/Evaluation
  • Migel look and feel / 100% / 100%
  • Migel sort function / 80% / 80%
Milestones
  • How to make stripe
  • subheading (for Höchstvergütungsbetrag)
  • set Höchstvergütungsbetrag value
  • snapback
  • sort function
  • reverse function
  • import function
Summary
Commits
ToDo Tomorrow
  • sort function (2nd and 3rd key sorting)
  • reverse function
  • import function

Make look and feel more nicely

Stripe

Experiment

  • src/view/migel/searched_table.rb
class SearchedList < HtmlGrid::List
  CSS_CLASS = 'composite'
  def init
    @components = {
      [0,0]   =>  :pharmacode,
      [1,0]   =>  :article_name,
      [2,0]   =>  :companyname,
      [3,0]   =>  :ppha,
      [4,0]   =>  :ppub,
      [5,0]   =>  :factor,
      [6,0]   =>  :pzr,
    }
    @css_map = {
      [0,0]   => 'list',
      [1,0]   => 'list',
      [2,0]   => 'list',
      [3,0]   => 'list',
      [4,0]   => 'list',
      [5,0]   => 'list',
      [6,0]   => 'list',
    }
...

Run

  • bin/oddbd
  • bin/currencyd
  • bin/yusd
  • bin/swissindex_nonpharmad

Access

Result

Note

  • This @css_map is usually set in the 'reorganize_component' method that is related to CSS_MAP constant

Next

  • Subheader (Höchstvergütungsbetrag)

Subheader

Experiment

  • src/view/migel/searched_table.rb
class SubHeader < HtmlGrid::Composite
  COMPONENTS = {
    [0,0,0] => 'Höchstvergütungsbetrag: ',
  }
  CSS_CLASS = 'composite'
  CSS_MAP = {
    [0,0] => 'list atc',
  }
  def init
    components.store([0,0,1], :edit)
    super
  end
  def edit(model, session=@session)
    model.compensation
  end
end
class SearchedList < HtmlGrid::List
  CSS_CLASS = 'composite'
  def init
    @components = {
      [0,0]   =>  :pharmacode,
      [1,0]   =>  :article_name,
      [2,0]   =>  :companyname,
      [3,0]   =>  :ppha,
      [4,0]   =>  :ppub,
      [5,0]   =>  :factor,
      [6,0]   =>  :pzr,
    }
    @css_map = {
      [0,0]   => 'list',
      [1,0]   => 'list',
      [2,0]   => 'list',
      [3,0]   => 'list',
      [4,0]   => 'list',
      [5,0]   => 'list',
      [6,0]   => 'list',
    }
    super
  end
  def compose_list(model = @model, offset=[0,0])
    item = nil
    model.each do |i|
      item = i
    end
    subheader = SubHeader.new(item, @session, self)
    @grid.add(subheader, *offset)
    @grid.set_colspan(offset.at(0), offset.at(1), full_colspan)
    offset = resolve_offset(offset, self::class::OFFSET_STEP)
    super(model, offset)
  end
end

Result

Next

  • set the actual value of Höchstvergütungsbetrag

Get and set Höchstvergütungsbetrag

Experiment

 masa@masa ~/ywesee/oddb.org $ bin/admin
 ch.oddb> search_migel_products('151003011','de')[0]
 -> Einmalblasenkatheter mit Gleitmittel, mit Beutel
 Limitation: bei erhöhter Infektionsgefahr
 ch.oddb> search_migel_products('151003011','de')[0].migel_code
 -> 15.10.03.01.1
 ch.oddb> search_migel_products('151003011','de')[0].price
 -> 990
 ch.oddb> search_migel_products('151003011','de')[0].unit
 -> Stück
 ch.oddb> search_migel_products('151003011','de')[0].qty
 -> 1

Qeustion

  • Why are they different?

Answer

      def price(model, session=@session)
        formatted_price(:price, model)
      end

Experiment

  • src/state/global.rb
      def migel_search
        if migel_code = @session.user_input(:migel_code)
          product = if migel_products = @session.search_migel_products(migel_code) and !migel_products.empty?
                    migel_products[0]
                  end
          ODDB::State::Migel::SearchedTable.new(@session, ODDB::Migel::SearchedTable.new(@session, migel_code, product))
        else
          self
        end
      end
  • src/model/migel/searched_table.rb
module ODDB
  module Migel

class SearchedTable
  class Record
    attr_reader :pharmacode, :article_name, :companyname, :ppha, :ppub, :factor, :pzr
    def initialize(record, container)
      @pharmacode, @article_name, @companyname, @ppha, @ppub, @factor, @pzr = *record
      @container = container
    end
    def price
      @container.price
    end
    def qty
      @container.qty
    end
    def unit
      @container.unit
    end
  end
  attr_reader :price, :qty, :unit
  def initialize(session, migel_code, migel_product)
    plugin = ODDB::SwissindexNonpharmaPlugin.new(session.app)
    @table = plugin.search_migel_table(migel_code).map do |record|
      Record.new(record, self)
    end
    @price = migel_product.price
    @qty = migel_product.qty
    @unit = migel_product.unit
  end
  def empty?
    @table.empty?
  end
  def sort_by
    @table.sort_by do |record|
      yield record
    end
  end
  def each_with_index
    @table.each do |record|
      yield record
    end
  end

end
   end
end
  • src/view/migel/searched_table.rb
require 'htmlgrid/list'
require 'view/additional_information'
require 'view/dataformat'

module ODDB
  module View
    module Migel

class SubHeader < HtmlGrid::Composite
  include View::AdditionalInformation
  include View::DataFormat
  COMPONENTS = {
    [0,0,0] => 'Höchstvergütungsbetrag: ',
    [0,0,1] => :price,
    [0,0,2] => :qty_unit,
  }
  CSS_CLASS = 'composite'
  CSS_MAP = {
    [0,0] => 'list atc',
  }
end

Result

Next

  • snapback

Snapback

Experiment

  • src/model/migel/searched_table.rb attr_reader :price, :qty, :unit, :pointer_descr def initialize(session, migel_code, migel_product)
    plugin = ODDB::SwissindexNonpharmaPlugin.new(session.app)
    @table = plugin.search_migel_table(migel_code).map do |record|
      Record.new(record, self)
    end
    @price = migel_product.price
    @qty = migel_product.qty
    @unit = migel_product.unit
    @pointer_descr = migel_product.migel_code
end

Result

Note

  • Actually, the snapback link is created in compose_list and compose_footer methods of src/view/pointerstep.rb

Next

  • sorting

Sorting

Experiment

  • src/model/migel/searched_table.rb
class SearchedTable
  def sort_by
    @table.sort_by do |record|
      #yield record
      record.pharmacode
    end
  end
  def sort!
    @table.sort! do |a,b|
      yield(a,b)
    end
  end
  def each_with_index
    @table.each do |record|
      yield record
    end
  end
  def at(index)
    @table[index]
  end
  • src/state/migel/searched_table.rb
#!/usr/bin/env ruby
#  ODDB::State::Migel:Test -- oddb.org -- 09.08.2011 -- mhatakeyama@ywesee.com

require 'state/global_predefine'
require 'view/migel/searched_table'

module ODDB
  module State
    module Migel
class SearchedTable < State::Migel::Global
  VIEW = ODDB::View::Migel::SearchedTable
  def sort
    sortby = get_sortby!
    @model.sort! do |a,b|
      a.send(sortby[0]) <=> b.send(sortby[0])
    end
    self
  end
end
    end
  end
end

Note

  • Ruby 1.8 does not have 'sort_by!' method

Result

  • Default (sorted by pharmacode)
  • Sorted by Artikelname (Click 'Artikel')

Note

  • Sort by the 2nd and 3rd keys is not yet considered (tomorrow)
view · edit · sidebar · attach · print · history
Page last modified on August 10, 2011, at 04:49 PM