Module: ODDB::Html::View::Drugs::PackageMethods

Instance Method Summary collapse

Instance Method Details

#active_agents(model) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/oddb/html/view/drugs/package.rb', line 16

def active_agents(model)
  link = HtmlGrid::Link.new(:no_active_agents, model, @session, self)
  if(code = model.code(:cid, ODDB.config.country))
    link.href = @lookandfeel._event_url(:package, [:cid, code.value])
  elsif model.is_a?(ODDB::Drugs::Sequence)
    link.href = @lookandfeel._event_url(:sequence, [:uid, model.uid])
  elsif model.is_a?(ODDB::Drugs::Product)
    link.href = @lookandfeel._event_url(:product, [:uid, model.uid])
  else
    link = HtmlGrid::Value.new(:no_active_agents, model, @session ,self)
  end
  agents = model.active_agents.collect { |agent|
    [
      agent.substance.name.send(@session.language), ' ',
      agent.dose, "\n",
    ]
  }
  size = agents.size
  if(size == 1)
    link.value = agents.first
  elsif size > 1
    link.value = @lookandfeel.lookup(:active_agents, size)
    link.css_id = "sub_#{model.atc}_#@list_index"
    link.dojo_title = agents
  end
  link
end

#adjust_price(money) ⇒ Object



43
44
45
# File 'lib/oddb/html/view/drugs/package.rb', line 43

def adjust_price(money)
  money * @lookandfeel.price_factor if(money)
end

#code_boolean(model, key) ⇒ Object



46
47
48
49
50
51
52
53
54
# File 'lib/oddb/html/view/drugs/package.rb', line 46

def code_boolean(model, key)
  if code = model.code(key)
    if code.value
      @lookandfeel.lookup(:yes)
    else
      @lookandfeel.lookup(:no)
    end
  end
end

#code_festbetragsgruppe(model) ⇒ Object



55
56
57
# File 'lib/oddb/html/view/drugs/package.rb', line 55

def code_festbetragsgruppe(model)
  model.code(:festbetragsgruppe, ODDB.config.country)
end

#code_festbetragsstufe(model) ⇒ Object



58
59
60
# File 'lib/oddb/html/view/drugs/package.rb', line 58

def code_festbetragsstufe(model)
  model.code(:festbetragsstufe)
end

#code_prescription(model) ⇒ Object



61
62
63
# File 'lib/oddb/html/view/drugs/package.rb', line 61

def code_prescription(model)
  code_boolean(model, :prescription)
end

#code_registration(model) ⇒ Object



64
65
66
# File 'lib/oddb/html/view/drugs/package.rb', line 64

def code_registration(model)
  model.registration
end

#code_zuzahlungsbefreit(model) ⇒ Object



67
68
69
# File 'lib/oddb/html/view/drugs/package.rb', line 67

def code_zuzahlungsbefreit(model)
  code_boolean(model, :zuzahlungsbefreit)
end

#ddd_prices(model) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/oddb/html/view/drugs/package.rb', line 70

def ddd_prices(model)
  ddds = []
  model.ddds.each_with_index { |ddd, idx|
    if(price = adjust_price model.dose_price(ddd.dose))
      span = HtmlGrid::Span.new(model, @session, self)
      span.value = price
      code = model.code(:cid)
      span.css_id = "ddd_price_#{code}.#{idx}"
      args = [:cid, code, :offset, idx]
      span.dojo_tooltip = @lookandfeel._event_url(:explain_ddd_price,
                                                  args)
                                                  
      ddds.push span
    end
  }
  val = HtmlGrid::Value.new(:ddd_prices, model, @session, self)
  val.value = ddds.zip(Array.new([ddds.size - 1, 0].max, ' / '))
  val
end


89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/oddb/html/view/drugs/package.rb', line 89

def fachinfo_link(model)
  url = if model.respond_to?(:fachinfo) \
          && model.fachinfo.send(@session.language)
          @lookandfeel._event_url(:fachinfo, [:uid, model.sequence.uid])
        elsif model.respond_to?(:fachinfo_url)
          model.fachinfo_url
        end
  if url
    link = HtmlGrid::Link.new(:square_fachinfo, model, @session, self)
    link.css_class = 'square fachinfo'
    link.href = url
    link
  end
end

#feedback(model) ⇒ Object



103
104
105
106
107
108
109
110
111
112
# File 'lib/oddb/html/view/drugs/package.rb', line 103

def feedback(model)
  if(@lookandfeel.enabled?(:feedback) && (code = model.code(:cid, ODDB.config.country)))
    link = HtmlGrid::Link.new(:feedback_short, model, @session, self)
    link.href = @lookandfeel._event_url(:feedback, [:cid, code.value])
    link.css_class = 'feedback square'
    link.set_attribute('title', @lookandfeel.lookup(:feedback_alt, 
      model.name))
    link
  end
end


113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/oddb/html/view/drugs/package.rb', line 113

def patinfo_link(model)
  url = if model.respond_to?(:patinfo) && model.patinfo.send(@session.language)
          @lookandfeel._event_url(:patinfo, [:uid, model.sequence.uid])
        elsif model.respond_to?(:patinfo_url)
          model.patinfo_url
        end
  if url
    link = HtmlGrid::Link.new(:square_patinfo, model, @session, self)
    link.css_class = 'square patinfo'
    link.href = url
    link
  end
end

#price_difference(model) ⇒ Object



137
138
139
140
141
# File 'lib/oddb/html/view/drugs/package.rb', line 137

def price_difference(model)
  if((pf = model.price(:festbetrag)) && (pp = model.price(:public)))
    sprintf("%+1.2f", adjust_price(pp - pf))
  end
end

#price_exfactory(model) ⇒ Object



142
143
144
# File 'lib/oddb/html/view/drugs/package.rb', line 142

def price_exfactory(model)
  adjust_price model.price(:exfactory)
end

#price_festbetrag(model) ⇒ Object



126
127
128
129
130
131
132
133
134
135
136
# File 'lib/oddb/html/view/drugs/package.rb', line 126

def price_festbetrag(model)
  @price_id ||= 0
  @price_id += 1
  span = HtmlGrid::Span.new(model, @session, self)
  span.css_id = "price_festbetrag#{@price_id}"
  span.value = adjust_price model.price(:festbetrag)
  span.dojo_title = sprintf("%s: %s",
    @lookandfeel.lookup(:price_difference), price_difference(model))
  span.label = true
  span
end

#price_public(model) ⇒ Object



145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/oddb/html/view/drugs/package.rb', line 145

def price_public(model)
  price = adjust_price model.price(:public)
  if(!@lookandfeel.enabled?(:explain_price, false) \
     || model.is_a?(Remote::Drugs::Package))
    price
  elsif(price && (code = model.code(:cid)))
    span = HtmlGrid::Span.new(model, @session, self)
    span.value = price
    span.css_id = "explain_price#{code}"
    span.dojo_tooltip = @lookandfeel._event_url(:explain_price,
                                                [:cid, code])
    span.label = true
    span
  end
end

#price_zuzahlung(model) ⇒ Object



160
161
162
# File 'lib/oddb/html/view/drugs/package.rb', line 160

def price_zuzahlung(model)
  adjust_price model.price(:zuzahlung)
end

#product(model) ⇒ Object



163
164
165
166
167
168
169
# File 'lib/oddb/html/view/drugs/package.rb', line 163

def product(model)
  if(model.is_a?(Remote::Drugs::Package))
    product_remote(model)
  else
    product_local(model)
  end
end

#product_local(model) ⇒ Object



170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/oddb/html/view/drugs/package.rb', line 170

def product_local(model)
  link = nil
  if(model.atc && (code = model.code(:cid, ODDB.config.country)))
    link = HtmlGrid::Link.new(:compare, model, @session, self)
    link.href = @lookandfeel._event_url(:compare, [:cid, code.value])
  else
    link = HtmlGrid::Span.new(model, @session, self)
  end
  link.value = model.name.send(@session.language) \
    || ((prod = model.product) && prod.name.send(@session.language))
  link.css_id = "cid_#{model.atc}_#@list_index"
  link.dojo_title = @lookandfeel.lookup(:cid, model.code(:cid, ODDB.config.country))
  link
end

#product_remote(model) ⇒ Object



184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# File 'lib/oddb/html/view/drugs/package.rb', line 184

def product_remote(model)
  link = nil
  atc = model.atc
  if(atc && (model.active_agents.size == 1))
    link = HtmlGrid::Link.new(:compare, model, @session, self)
    link.href = @lookandfeel._event_url(:compare_remote, 
                                        [:uid, model.uid])
  else
    link = HtmlGrid::Span.new(model, @session, self)
  end
  link.value = model.name.send(@session.language)
  code = atc && atc.code
  link.css_id = "cid_#{code}_#@list_index"#"cid_#@list_index"
  link.dojo_title = @lookandfeel.lookup(:ean, model.code(:ean))
  link
end

#row_css(model, bg_flag) ⇒ Object



200
201
202
203
204
205
206
207
208
# File 'lib/oddb/html/view/drugs/package.rb', line 200

def row_css(model, bg_flag)
  css = super
  if(model.is_a?(Remote::Drugs::Package))
    css = ['remote', css].compact.join(' ')
  elsif((code = model.code(:zuzahlungsbefreit)) && code.value)
    css = ['zuzahlungsbefreit', css].compact.join(' ')
  end
  css
end

#size(model) ⇒ Object



209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
# File 'lib/oddb/html/view/drugs/package.rb', line 209

def size(model)
  model.parts.collect { |part|
    parts = [] 
    multi = part.multi.to_i
    if(multi > 1)
      parts.push multi, 'x'
    end
	size = part.size.to_i
	if(size > 1)
		parts.push(size)
	end
    if(unit = part.unit)
      parts.push(unit.name.send(@session.language))
    end
    if(quantity = part.quantity)
      parts.push 'à', quantity
    end
    parts.join(' ')
  }.join(' + ')
end