<< | Index | >>
Experiment
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
Access
Result
Note
Next
Experiment
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
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
Answer
def price(model, session=@session) formatted_price(:price, model) end
Experiment
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
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
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
Experiment
: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
Result
Note
Next
Experiment
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
#!/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
Result
Note