Class: ODDB::View::Ajax::DDDPriceTable

Inherits:
HtmlGrid::Composite show all
Includes:
ODDB::View::AdditionalInformation, DataFormat
Defined in:
src/view/ajax/ddd_price.rb

Constant Summary

COMPONENTS =
{
  [0,0] =>  :ddd_oral,
  [2,0] =>  :price_public,
  [0,1] =>  :dose,
  [2,1] =>  :size,
  [0,2] =>  :calculation,
}
COLSPAN_MAP =
{
  [1,2] =>  3,
}
CSS_MAP =
{ 
  [0,0,4,2] => 'list', 
  [0,2,2]   => 'list nowrap' 
}
LABELS =
true
LEGACY_INTERFACE =
false
DEFAULT_CLASS =
HtmlGrid::Value

Instance Method Summary (collapse)

Methods included from ODDB::View::AdditionalInformation

#_fachinfo, #atc_ddd_link, #atc_description, #comarketing, #complementary_type, #compositions, #ddd_price, #deductible, #fachinfo, #feedback, #google_search, #ikscat, #limitation_link, #limitation_text, #minifi, #narcotic, #notify, #patent, #patinfo, #qty_unit, #square, #twitter_share

Methods included from PartSize

#comparable_size, #part_size

Methods included from Drugs::AtcDddLink

#atc_ddd_link

Methods included from DataFormat

#breakline, #company_name, #most_precise_dose, #name_base, #price, #price_exfactory

Methods included from ExternalLinks

#contact_link, #data_declaration, #external_link, #faq_link, #generic_definition, #help_link, #legal_note, #meddrugs_update, #wiki_link

Methods inherited from HtmlGrid::Composite

event_link, #hash_insert_col, #hash_insert_row

Instance Method Details

- (Object) calculation(model)



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'src/view/ajax/ddd_price.rb', line 47

def calculation(model)
  if(model && (atc = model.atc_class) && (ddd = atc.ddd('O')))
    currency = @session.currency
    mprice = model.price_public
    mprice = convert_price(mprice, currency)
    dprice = model.ddd_price
    dprice = convert_price(dprice, currency)
    mdose = model.dose
    ddose = ddd.dose
    wanted = wanted_unit(mdose, ddose)
    mdose = model.dose.want(wanted)
    ddose = ddd.dose.want(wanted)
    curr = @session.currency
    comp = HtmlGrid::Value.new(:ddd_calculation, model, @session, self)
    if(factor = model.longevity)
      comp.value = @lookandfeel.lookup(:ddd_calc_long, factor, mprice,
                                       model.size, dprice, curr)

    elsif(mdose > ddose)
      comp.value = @lookandfeel.lookup(:ddd_calc_tablet, mprice,
                                       model.size, dprice, curr)
    else
      comp.value = @lookandfeel.lookup(:ddd_calculation, ddose,
                                       mdose, mprice, model.size,
                                       dprice, curr)
    end
    comp
  end
end

- (Object) ddd_oral(model)



31
32
33
34
35
36
37
38
# File 'src/view/ajax/ddd_price.rb', line 31

def ddd_oral(model)
  if(model && (atc = model.atc_class) && (ddd = atc.ddd('O')))
    comp = HtmlGrid::Value.new(:ddd_dose, ddd.dose, @session, self)
    ddose = ddd.dose
    comp.value = ddose.want(wanted_unit(model.dose, ddose))
    comp
  end
end

- (Object) dose(model)



39
40
41
42
43
44
45
46
# File 'src/view/ajax/ddd_price.rb', line 39

def dose(model)
  if(model && (atc = model.atc_class) && (ddd = atc.ddd('O')))
    comp = HtmlGrid::Value.new(:dose, model, @session, self)
    mdose = model.dose
    comp.value = mdose.want(wanted_unit(mdose, ddd.dose))
    comp
  end
end

- (Object) price_public(model)



76
77
78
79
80
# File 'src/view/ajax/ddd_price.rb', line 76

def price_public(model)
  item = super
  item.value += ' ' + @session.currency
  item
end

- (Object) wanted_unit(mdose, ddose)



81
82
83
# File 'src/view/ajax/ddd_price.rb', line 81

def wanted_unit(mdose, ddose)
  (mdose.fact.factor < ddose.fact.factor) ? mdose.unit : ddose.unit
end