ramaze.ch.oddb.org 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -0
- data/LICENSE +339 -0
- data/Manifest.txt +285 -0
- data/README.txt +45 -0
- data/Rakefile +28 -0
- data/bin/admin +69 -0
- data/bin/exportd +63 -0
- data/bin/migrate +461 -0
- data/bin/oddbd +62 -0
- data/data/fulltext/data/dicts/french/fulltext.aff +1057 -0
- data/data/fulltext/data/dicts/french/fulltext.dict +91189 -0
- data/data/fulltext/data/dicts/french/fulltext.stop +135 -0
- data/data/fulltext/data/dicts/german/fulltext.aff +1233 -0
- data/data/fulltext/data/dicts/german/fulltext.dict +287574 -0
- data/data/fulltext/data/dicts/german/fulltext.stop +133 -0
- data/data/fulltext/data/german_compound/README +15 -0
- data/data/fulltext/data/german_compound/compound.pl +63 -0
- data/data/fulltext/data/german_compound/german.stop +20 -0
- data/data/fulltext/data/ispell-german-compound.tar.gz +0 -0
- data/data/fulltext/redist/dict_french/Makefile +12 -0
- data/data/fulltext/redist/dict_french/README.french +1 -0
- data/data/fulltext/redist/dict_french/dict_french.sql.in +7 -0
- data/data/fulltext/redist/dict_french/dict_snowball.c +56 -0
- data/data/fulltext/redist/dict_french/french_stem.c +1222 -0
- data/data/fulltext/redist/dict_french/french_stem.h +16 -0
- data/data/fulltext/redist/dict_french/subinclude.h +2 -0
- data/data/fulltext/redist/dict_german/Makefile +12 -0
- data/data/fulltext/redist/dict_german/README.german +1 -0
- data/data/fulltext/redist/dict_german/dict_german.sql.in +7 -0
- data/data/fulltext/redist/dict_german/dict_snowball.c +56 -0
- data/data/fulltext/redist/dict_german/german_stem.c +527 -0
- data/data/fulltext/redist/dict_german/german_stem.h +16 -0
- data/data/fulltext/redist/dict_german/subinclude.h +1 -0
- data/data/fulltext/redist/french_stem.c +1222 -0
- data/data/fulltext/redist/french_stem.h +16 -0
- data/data/fulltext/redist/german_stem.c +527 -0
- data/data/fulltext/redist/german_stem.h +16 -0
- data/lib/fixes/ruby19.rb +21 -0
- data/lib/fixes/selenium.rb +20 -0
- data/lib/fixes/singular.rb +8 -0
- data/lib/fixes/yaml.rb +13 -0
- data/lib/oddb.rb +11 -0
- data/lib/oddb/business/company.rb +18 -0
- data/lib/oddb/business/invoice.rb +75 -0
- data/lib/oddb/business/price.rb +60 -0
- data/lib/oddb/config.rb +73 -0
- data/lib/oddb/drugs.rb +16 -0
- data/lib/oddb/drugs/active_agent.rb +37 -0
- data/lib/oddb/drugs/atc.rb +53 -0
- data/lib/oddb/drugs/composition.rb +41 -0
- data/lib/oddb/drugs/ddd.rb +24 -0
- data/lib/oddb/drugs/dose.rb +107 -0
- data/lib/oddb/drugs/galenic_form.rb +21 -0
- data/lib/oddb/drugs/galenic_group.rb +17 -0
- data/lib/oddb/drugs/package.rb +87 -0
- data/lib/oddb/drugs/part.rb +56 -0
- data/lib/oddb/drugs/product.rb +25 -0
- data/lib/oddb/drugs/sequence.rb +61 -0
- data/lib/oddb/drugs/substance.rb +31 -0
- data/lib/oddb/drugs/substance_group.rb +13 -0
- data/lib/oddb/drugs/unit.rb +12 -0
- data/lib/oddb/export.rb +4 -0
- data/lib/oddb/export/csv.rb +89 -0
- data/lib/oddb/export/l10n_sessions.rb +30 -0
- data/lib/oddb/export/rss.rb +44 -0
- data/lib/oddb/export/server.rb +58 -0
- data/lib/oddb/export/xls.rb +119 -0
- data/lib/oddb/export/yaml.rb +123 -0
- data/lib/oddb/html/state/drugs/admin/package.rb +189 -0
- data/lib/oddb/html/state/drugs/admin/product.rb +56 -0
- data/lib/oddb/html/state/drugs/admin/sequence.rb +259 -0
- data/lib/oddb/html/state/drugs/ajax/explain_ddd_price.rb +19 -0
- data/lib/oddb/html/state/drugs/ajax/explain_price.rb +19 -0
- data/lib/oddb/html/state/drugs/ajax/global.rb +18 -0
- data/lib/oddb/html/state/drugs/ajax/package_infos.rb +19 -0
- data/lib/oddb/html/state/drugs/ajax/remote_infos.rb +19 -0
- data/lib/oddb/html/state/drugs/atc_browser.rb +39 -0
- data/lib/oddb/html/state/drugs/atc_guidelines.rb +21 -0
- data/lib/oddb/html/state/drugs/compare.rb +52 -0
- data/lib/oddb/html/state/drugs/download_export.rb +18 -0
- data/lib/oddb/html/state/drugs/fachinfo.rb +21 -0
- data/lib/oddb/html/state/drugs/feedback.rb +94 -0
- data/lib/oddb/html/state/drugs/global.rb +266 -0
- data/lib/oddb/html/state/drugs/init.rb +18 -0
- data/lib/oddb/html/state/drugs/login.rb +17 -0
- data/lib/oddb/html/state/drugs/package.rb +32 -0
- data/lib/oddb/html/state/drugs/patinfo.rb +21 -0
- data/lib/oddb/html/state/drugs/products.rb +51 -0
- data/lib/oddb/html/state/drugs/result.rb +125 -0
- data/lib/oddb/html/state/global.rb +165 -0
- data/lib/oddb/html/state/global_predefine.rb +17 -0
- data/lib/oddb/html/state/limit.rb +17 -0
- data/lib/oddb/html/state/login.rb +56 -0
- data/lib/oddb/html/state/paypal/checkout.rb +130 -0
- data/lib/oddb/html/state/paypal/collect.rb +46 -0
- data/lib/oddb/html/state/paypal/redirect.rb +18 -0
- data/lib/oddb/html/state/register_export.rb +38 -0
- data/lib/oddb/html/state/register_poweruser.rb +17 -0
- data/lib/oddb/html/state/viral/admin.rb +76 -0
- data/lib/oddb/html/state/viral/poweruser.rb +16 -0
- data/lib/oddb/html/util/annotated_list.rb +39 -0
- data/lib/oddb/html/util/know_it_all.rb +28 -0
- data/lib/oddb/html/util/known_user.rb +55 -0
- data/lib/oddb/html/util/lookandfeel.rb +554 -0
- data/lib/oddb/html/util/need_all_input.rb +29 -0
- data/lib/oddb/html/util/session.rb +88 -0
- data/lib/oddb/html/util/sort.rb +72 -0
- data/lib/oddb/html/util/unsaved_helper.rb +20 -0
- data/lib/oddb/html/util/validator.rb +54 -0
- data/lib/oddb/html/view/ajax/json.rb +22 -0
- data/lib/oddb/html/view/alpha_header.rb +28 -0
- data/lib/oddb/html/view/document.rb +126 -0
- data/lib/oddb/html/view/drugs/admin/package.rb +237 -0
- data/lib/oddb/html/view/drugs/admin/product.rb +104 -0
- data/lib/oddb/html/view/drugs/admin/sequence.rb +312 -0
- data/lib/oddb/html/view/drugs/ajax/explain_ddd_price.rb +87 -0
- data/lib/oddb/html/view/drugs/ajax/explain_price.rb +61 -0
- data/lib/oddb/html/view/drugs/ajax/package_infos.rb +105 -0
- data/lib/oddb/html/view/drugs/ajax/remote_infos.rb +44 -0
- data/lib/oddb/html/view/drugs/atc_browser.rb +68 -0
- data/lib/oddb/html/view/drugs/atc_guidelines.rb +94 -0
- data/lib/oddb/html/view/drugs/compare.rb +95 -0
- data/lib/oddb/html/view/drugs/download_export.rb +28 -0
- data/lib/oddb/html/view/drugs/fachinfo.rb +46 -0
- data/lib/oddb/html/view/drugs/feedback.rb +231 -0
- data/lib/oddb/html/view/drugs/init.rb +51 -0
- data/lib/oddb/html/view/drugs/legend.rb +24 -0
- data/lib/oddb/html/view/drugs/package.rb +398 -0
- data/lib/oddb/html/view/drugs/patinfo.rb +46 -0
- data/lib/oddb/html/view/drugs/products.rb +97 -0
- data/lib/oddb/html/view/drugs/result.rb +296 -0
- data/lib/oddb/html/view/drugs/search.rb +33 -0
- data/lib/oddb/html/view/drugs/template.rb +15 -0
- data/lib/oddb/html/view/foot.rb +52 -0
- data/lib/oddb/html/view/google.rb +23 -0
- data/lib/oddb/html/view/google_ads.rb +40 -0
- data/lib/oddb/html/view/head.rb +78 -0
- data/lib/oddb/html/view/limit.rb +109 -0
- data/lib/oddb/html/view/list.rb +59 -0
- data/lib/oddb/html/view/login.rb +38 -0
- data/lib/oddb/html/view/navigation.rb +67 -0
- data/lib/oddb/html/view/offset_header.rb +35 -0
- data/lib/oddb/html/view/paypal/collect.rb +84 -0
- data/lib/oddb/html/view/paypal/redirect.rb +51 -0
- data/lib/oddb/html/view/paypal/register_form.rb +106 -0
- data/lib/oddb/html/view/register_export.rb +29 -0
- data/lib/oddb/html/view/register_poweruser.rb +29 -0
- data/lib/oddb/html/view/rss/feedback.rb +64 -0
- data/lib/oddb/html/view/rss_preview.rb +54 -0
- data/lib/oddb/html/view/search.rb +104 -0
- data/lib/oddb/html/view/snapback.rb +24 -0
- data/lib/oddb/html/view/template.rb +56 -0
- data/lib/oddb/import/excel.rb +45 -0
- data/lib/oddb/import/import.rb +39 -0
- data/lib/oddb/import/rtf.rb +410 -0
- data/lib/oddb/import/whocc.rb +173 -0
- data/lib/oddb/import/xml.rb +15 -0
- data/lib/oddb/model.rb +179 -0
- data/lib/oddb/persistence/odba.rb +33 -0
- data/lib/oddb/persistence/odba/business/company.rb +13 -0
- data/lib/oddb/persistence/odba/business/invoice.rb +15 -0
- data/lib/oddb/persistence/odba/drugs/atc.rb +15 -0
- data/lib/oddb/persistence/odba/drugs/galenic_form.rb +18 -0
- data/lib/oddb/persistence/odba/drugs/galenic_group.rb +13 -0
- data/lib/oddb/persistence/odba/drugs/package.rb +25 -0
- data/lib/oddb/persistence/odba/drugs/product.rb +13 -0
- data/lib/oddb/persistence/odba/drugs/sequence.rb +21 -0
- data/lib/oddb/persistence/odba/drugs/substance.rb +21 -0
- data/lib/oddb/persistence/odba/drugs/substance_group.rb +13 -0
- data/lib/oddb/persistence/odba/drugs/unit.rb +13 -0
- data/lib/oddb/persistence/odba/export.rb +26 -0
- data/lib/oddb/persistence/odba/model.rb +68 -0
- data/lib/oddb/persistence/odba/regulatory/authority.rb +13 -0
- data/lib/oddb/persistence/odba/regulatory/registration.rb +13 -0
- data/lib/oddb/persistence/odba/text/document.rb +11 -0
- data/lib/oddb/persistence/odba/util/code.rb +11 -0
- data/lib/oddb/persistence/odba/util/m10l_document.rb +13 -0
- data/lib/oddb/persistence/og.rb +16 -0
- data/lib/oddb/persistence/og/drugs/composition.rb +14 -0
- data/lib/oddb/persistence/og/drugs/product.rb +14 -0
- data/lib/oddb/persistence/og/drugs/sequence.rb +15 -0
- data/lib/oddb/persistence/og/model.rb +25 -0
- data/lib/oddb/persistence/og/util/multilingual.rb +13 -0
- data/lib/oddb/redist/rtf_tools/reader.rb +139 -0
- data/lib/oddb/regulatory/authority.rb +14 -0
- data/lib/oddb/regulatory/registration.rb +15 -0
- data/lib/oddb/remote/business/company.rb +23 -0
- data/lib/oddb/remote/drugs/active_agent.rb +27 -0
- data/lib/oddb/remote/drugs/atc.rb +32 -0
- data/lib/oddb/remote/drugs/dose.rb +8 -0
- data/lib/oddb/remote/drugs/galenic_form.rb +25 -0
- data/lib/oddb/remote/drugs/package.rb +126 -0
- data/lib/oddb/remote/drugs/part.rb +30 -0
- data/lib/oddb/remote/drugs/product.rb +19 -0
- data/lib/oddb/remote/drugs/sequence.rb +46 -0
- data/lib/oddb/remote/drugs/substance.rb +20 -0
- data/lib/oddb/remote/drugs/unit.rb +19 -0
- data/lib/oddb/remote/object.rb +36 -0
- data/lib/oddb/remote/text/document.rb +20 -0
- data/lib/oddb/remote/util/m10l_document.rb +22 -0
- data/lib/oddb/text/chapter.rb +27 -0
- data/lib/oddb/text/document.rb +43 -0
- data/lib/oddb/text/format.rb +37 -0
- data/lib/oddb/text/paragraph.rb +58 -0
- data/lib/oddb/text/picture.rb +93 -0
- data/lib/oddb/text/table.rb +68 -0
- data/lib/oddb/util.rb +8 -0
- data/lib/oddb/util/annotated_list.rb +37 -0
- data/lib/oddb/util/code.rb +69 -0
- data/lib/oddb/util/comparison.rb +36 -0
- data/lib/oddb/util/exporter.rb +8 -0
- data/lib/oddb/util/feedback.rb +23 -0
- data/lib/oddb/util/ipn.rb +48 -0
- data/lib/oddb/util/m10l_document.rb +38 -0
- data/lib/oddb/util/mail.rb +73 -0
- data/lib/oddb/util/money.rb +60 -0
- data/lib/oddb/util/multilingual.rb +70 -0
- data/lib/oddb/util/quanty.rb +4 -0
- data/lib/oddb/util/quanty/fact.rb +229 -0
- data/lib/oddb/util/quanty/main.rb +160 -0
- data/lib/oddb/util/quanty/parse.rb +853 -0
- data/lib/oddb/util/quanty/units.dump +0 -0
- data/lib/oddb/util/server.rb +117 -0
- data/lib/oddb/util/updater.rb +41 -0
- data/lib/oddb/util/ydim.rb +110 -0
- data/lib/oddb/util/yus.rb +46 -0
- data/test/business/test_company.rb +29 -0
- data/test/business/test_price.rb +46 -0
- data/test/drugs/test_active_agent.rb +53 -0
- data/test/drugs/test_atc.rb +54 -0
- data/test/drugs/test_composition.rb +88 -0
- data/test/drugs/test_ddd.rb +22 -0
- data/test/drugs/test_dose.rb +190 -0
- data/test/drugs/test_galenic_form.rb +41 -0
- data/test/drugs/test_package.rb +173 -0
- data/test/drugs/test_part.rb +32 -0
- data/test/drugs/test_product.rb +31 -0
- data/test/drugs/test_sequence.rb +140 -0
- data/test/drugs/test_substance.rb +51 -0
- data/test/drugs/test_substance_group.rb +27 -0
- data/test/export/test_rss.rb +94 -0
- data/test/export/test_server.rb +117 -0
- data/test/export/test_xls.rb +152 -0
- data/test/export/test_yaml.rb +120 -0
- data/test/import/data/html/whocc/A.html +56 -0
- data/test/import/data/html/whocc/A03.html +48 -0
- data/test/import/data/html/whocc/A03AB.html +48 -0
- data/test/import/data/html/whocc/A06AA.html +47 -0
- data/test/import/data/html/whocc/C03.html +47 -0
- data/test/import/data/html/whocc/login.html +77 -0
- data/test/import/data/xml/ATC_2006.xml +47 -0
- data/test/import/data/xml/ATC_2006_ddd.xml +35 -0
- data/test/import/test_excel.rb +34 -0
- data/test/import/test_rtf.rb +40 -0
- data/test/import/test_whocc.rb +315 -0
- data/test/remote/drugs/test_active_agent.rb +36 -0
- data/test/selenium/selenium-server.jar +0 -0
- data/test/selenium/test_atc_browser.rb +122 -0
- data/test/selenium/test_atc_guidelines.rb +96 -0
- data/test/selenium/test_collect.rb +138 -0
- data/test/selenium/test_compare.rb +206 -0
- data/test/selenium/test_fachinfo.rb +130 -0
- data/test/selenium/test_feedback.rb +196 -0
- data/test/selenium/test_init.rb +52 -0
- data/test/selenium/test_limit.rb +305 -0
- data/test/selenium/test_login.rb +67 -0
- data/test/selenium/test_package.rb +512 -0
- data/test/selenium/test_patinfo.rb +131 -0
- data/test/selenium/test_product.rb +80 -0
- data/test/selenium/test_products.rb +142 -0
- data/test/selenium/test_search.rb +715 -0
- data/test/selenium/test_sequence.rb +543 -0
- data/test/selenium/unit.rb +185 -0
- data/test/stub/http_server.rb +169 -0
- data/test/stub/model.rb +173 -0
- data/test/suite.rb +15 -0
- data/test/test_model.rb +83 -0
- data/test/util/test_code.rb +74 -0
- data/test/util/test_ipn.rb +117 -0
- data/test/util/test_mail.rb +86 -0
- data/test/util/test_multilingual.rb +97 -0
- data/test/util/test_server.rb +48 -0
- data/test/util/test_updater.rb +353 -0
- data/test/util/test_ydim.rb +115 -0
- data/test/util/test_yus.rb +79 -0
- metadata +418 -0
@@ -0,0 +1,237 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
# Html::View::Drugs::Admin::Package -- de.oddb.org -- 29.10.2007 -- hwyss@ywesee.com
|
4
|
+
|
5
|
+
require 'htmlgrid/errormessage'
|
6
|
+
require 'htmlgrid/inputcheckbox'
|
7
|
+
require 'htmlgrid/select'
|
8
|
+
require 'oddb/html/view/drugs/package'
|
9
|
+
|
10
|
+
module ODDB
|
11
|
+
module Html
|
12
|
+
module View
|
13
|
+
module Drugs
|
14
|
+
module Admin
|
15
|
+
class CompositionSelect < HtmlGrid::AbstractSelect
|
16
|
+
def selection(context)
|
17
|
+
lang = @session.language
|
18
|
+
@selected ||= (comp = @model.composition) && comp.to_s(lang)
|
19
|
+
res = []
|
20
|
+
@model.sequence.compositions.each_with_index { |composition, idx|
|
21
|
+
comp = composition.to_s(lang)
|
22
|
+
attribs = { "value" => idx }
|
23
|
+
attribs.store("selected", 1) if(comp == selected)
|
24
|
+
res << context.option(attribs) { comp }
|
25
|
+
}
|
26
|
+
res
|
27
|
+
end
|
28
|
+
end
|
29
|
+
class SequenceSelect < HtmlGrid::AbstractSelect
|
30
|
+
def compositions(model)
|
31
|
+
lang = @session.language
|
32
|
+
res = model.compositions.collect { |comp|
|
33
|
+
comp.active_agents.collect { |act|
|
34
|
+
[act.substance.name.send(lang), act.dose].join(' ')
|
35
|
+
}.join(', ')
|
36
|
+
}.join(' + ')
|
37
|
+
if(res.length > 72)
|
38
|
+
res[0,69] << '...'
|
39
|
+
else
|
40
|
+
res
|
41
|
+
end
|
42
|
+
end
|
43
|
+
def selection(context)
|
44
|
+
lang = @session.language
|
45
|
+
@selected ||= (seq = @model.sequence) && seq.uid
|
46
|
+
res = []
|
47
|
+
@model.product.sequences.each_with_index { |sequence, idx|
|
48
|
+
uid = sequence.uid
|
49
|
+
attribs = { "value" => uid }
|
50
|
+
attribs.store("selected", 1) if(uid == selected)
|
51
|
+
res << context.option(attribs) { compositions(sequence) }
|
52
|
+
}
|
53
|
+
res
|
54
|
+
end
|
55
|
+
end
|
56
|
+
class Parts < List
|
57
|
+
class << self
|
58
|
+
def input_text(*keys)
|
59
|
+
keys.each { |key|
|
60
|
+
define_method(key) { |model|
|
61
|
+
input = HtmlGrid::Input.new(name(key), model, @session, self)
|
62
|
+
input.value = model.send(key) if model
|
63
|
+
input
|
64
|
+
}
|
65
|
+
}
|
66
|
+
end
|
67
|
+
end
|
68
|
+
COMPONENTS = {
|
69
|
+
[0,0] => :delete,
|
70
|
+
[1,0] => :multi,
|
71
|
+
[2,0] => "x",
|
72
|
+
[3,0] => :size,
|
73
|
+
[4,0] => :unit,
|
74
|
+
[5,0] => "à",
|
75
|
+
[6,0] => :quantity,
|
76
|
+
[7,0] => :composition,
|
77
|
+
}
|
78
|
+
COMPONENT_CSS_MAP = {
|
79
|
+
[1,0,3] => "short right",
|
80
|
+
[6,0] => "short right",
|
81
|
+
}
|
82
|
+
CSS_ID = 'parts'
|
83
|
+
DEFAULT_CLASS = HtmlGrid::InputText
|
84
|
+
EMPTY_LIST = true
|
85
|
+
OMIT_HEADER = true
|
86
|
+
input_text :multi, :size, :unit, :quantity
|
87
|
+
def add(model)
|
88
|
+
if(@model.empty? || @model.last.saved?)
|
89
|
+
link = HtmlGrid::Link.new(:plus, model, @session, self)
|
90
|
+
link.set_attribute('title', @lookandfeel.lookup(:create_part))
|
91
|
+
link.css_class = 'create square'
|
92
|
+
args = [ :code_cid, @session.state.model.code(:cid) ]
|
93
|
+
url = @session.lookandfeel.event_url(:ajax_create_part, args)
|
94
|
+
link.onclick = "replace_element('#{css_id}', '#{url}');"
|
95
|
+
link
|
96
|
+
end
|
97
|
+
end
|
98
|
+
def compose_footer(offset)
|
99
|
+
if(@model.empty? || @model.last.saved?)
|
100
|
+
@grid.add add(@model), *offset
|
101
|
+
end
|
102
|
+
end
|
103
|
+
def composition(model)
|
104
|
+
CompositionSelect.new(name("composition"), model, @session, self)
|
105
|
+
end
|
106
|
+
def delete(model)
|
107
|
+
if(@model.size > 1)
|
108
|
+
link = HtmlGrid::Link.new(:minus, model, @session, self)
|
109
|
+
link.set_attribute('title', @lookandfeel.lookup(:delete))
|
110
|
+
link.css_class = 'delete square'
|
111
|
+
args = [ :code_cid, @session.state.model.code(:cid), :part, @list_index ]
|
112
|
+
url = @session.lookandfeel.event_url(:ajax_delete_part, args)
|
113
|
+
link.onclick = "replace_element('#{css_id}', '#{url}');"
|
114
|
+
link
|
115
|
+
end
|
116
|
+
end
|
117
|
+
def name(part)
|
118
|
+
"#{part}[#@list_index]"
|
119
|
+
end
|
120
|
+
def unsaved(model)
|
121
|
+
@lookandfeel.lookup(:unsaved) unless model.saved?
|
122
|
+
end
|
123
|
+
end
|
124
|
+
class PackageInnerForm < Drugs::PackageInnerComposite
|
125
|
+
class << self
|
126
|
+
def input_text(*keys)
|
127
|
+
keys.each { |key|
|
128
|
+
define_method(key) { |model|
|
129
|
+
input = HtmlGrid::InputText.new(key, model, @session, self)
|
130
|
+
value = super model
|
131
|
+
if(value.is_a? HtmlGrid::Component)
|
132
|
+
input.value = value.value
|
133
|
+
else
|
134
|
+
input.value = value
|
135
|
+
end
|
136
|
+
if input.value.to_s.empty?
|
137
|
+
input.value = @session.user_input key
|
138
|
+
end
|
139
|
+
input
|
140
|
+
}
|
141
|
+
}
|
142
|
+
end
|
143
|
+
end
|
144
|
+
include HtmlGrid::ErrorMessage
|
145
|
+
COMPONENTS = {
|
146
|
+
[0,0] => :name,
|
147
|
+
## google's third parameter ensures that its link is written before
|
148
|
+
# the name - this allows a float: right in css to work correctly
|
149
|
+
[1,0,0] => :google,
|
150
|
+
[2,0] => :code_cid,
|
151
|
+
[0,1] => :company,
|
152
|
+
[2,1] => :atc,
|
153
|
+
[0,2] => :price_exfactory,
|
154
|
+
[2,2] => :price_public,
|
155
|
+
[2,3] => :price_festbetrag,
|
156
|
+
[0,4] => :code_festbetragsstufe,
|
157
|
+
[2,4] => :code_festbetragsgruppe,
|
158
|
+
[0,5] => :code_zuzahlungsbefreit,
|
159
|
+
[2,5] => :sequence,
|
160
|
+
[0,6] => :code_prescription,
|
161
|
+
[1,7,0] => :submit,
|
162
|
+
[1,7,1] => :delete,
|
163
|
+
}
|
164
|
+
SYMBOL_MAP = {
|
165
|
+
:name => HtmlGrid::InputText,
|
166
|
+
}
|
167
|
+
input_text :code_cid, :price_public, :price_festbetrag, :code_festbetragsstufe,
|
168
|
+
:code_festbetragsgruppe, :equivalence_factor, :price_exfactory
|
169
|
+
def init
|
170
|
+
super
|
171
|
+
error_message
|
172
|
+
end
|
173
|
+
def code_boolean(model, key)
|
174
|
+
box = HtmlGrid::InputCheckbox.new("code_#{key}", model, @session, self)
|
175
|
+
box.set_attribute('checked', (code = model.code(key)) && code.value)
|
176
|
+
box
|
177
|
+
end
|
178
|
+
def delete(model)
|
179
|
+
button = HtmlGrid::Button.new(:delete, model, @session, self)
|
180
|
+
script = "this.form.event.value = 'delete'; this.form.submit();"
|
181
|
+
if(model.saved?)
|
182
|
+
confirm = @lookandfeel.lookup(:delete_package_confirm)
|
183
|
+
script = "if(confirm('#{confirm}')) { #{script} };"
|
184
|
+
end
|
185
|
+
button.onclick = script
|
186
|
+
button
|
187
|
+
end
|
188
|
+
def sequence(model)
|
189
|
+
SequenceSelect.new("sequence", model, @session, self)
|
190
|
+
end
|
191
|
+
end
|
192
|
+
class PackageForm < HtmlGrid::DivComposite
|
193
|
+
include HtmlGrid::FormMethods
|
194
|
+
EVENT = :update
|
195
|
+
COMPONENTS = {
|
196
|
+
[0,0] => PackageInnerForm,
|
197
|
+
[0,1] => :parts,
|
198
|
+
[0,2] => :parts_form
|
199
|
+
}
|
200
|
+
CSS_MAP = { 1 => 'divider' }
|
201
|
+
def parts(model)
|
202
|
+
key = model.parts.size > 1 ? :parts : :package_and_substances
|
203
|
+
@lookandfeel.lookup(key)
|
204
|
+
end
|
205
|
+
def parts_form(model)
|
206
|
+
Parts.new(model.parts, @session, self)
|
207
|
+
end
|
208
|
+
end
|
209
|
+
class PackageComposite < Drugs::PackageComposite
|
210
|
+
COMPONENTS = {
|
211
|
+
[0,0] => :snapback,
|
212
|
+
[0,1] => InlineSearch,
|
213
|
+
[0,2] => :name,
|
214
|
+
[0,3] => PackageForm,
|
215
|
+
}
|
216
|
+
CSS_MAP = { 0 => 'before-searchbar' }
|
217
|
+
def breadcrumbs(model)
|
218
|
+
div = @lookandfeel.lookup(:breadcrumb_divider)
|
219
|
+
seq = HtmlGrid::Link.new(:sequence, model, @session, self)
|
220
|
+
seq.href = @lookandfeel._event_url(:sequence, :uid => model.sequence.uid)
|
221
|
+
prd = HtmlGrid::Link.new(:product, model, @session, self)
|
222
|
+
prd.href = @lookandfeel._event_url(:product, :uid => model.product.uid)
|
223
|
+
[ prd, div, seq, div ].concat super
|
224
|
+
end
|
225
|
+
def partline(part, idx)
|
226
|
+
# here in the Admin-Section we want the parts displayed differently, through Parts
|
227
|
+
end
|
228
|
+
end
|
229
|
+
class Package < Drugs::Package
|
230
|
+
CONTENT = PackageComposite
|
231
|
+
JAVASCRIPTS = ['admin']
|
232
|
+
end
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Html::View::Drugs::Admin::Package -- de.oddb.org -- 04.04.2008 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
require 'htmlgrid/errormessage'
|
5
|
+
require 'htmlgrid/form'
|
6
|
+
require 'oddb/html/view/drugs/template'
|
7
|
+
require 'oddb/html/view/list'
|
8
|
+
|
9
|
+
module ODDB
|
10
|
+
module Html
|
11
|
+
module View
|
12
|
+
module Drugs
|
13
|
+
module Admin
|
14
|
+
class Sequences < View::List
|
15
|
+
include HtmlGrid::FormMethods
|
16
|
+
COMPONENTS = {
|
17
|
+
[0,0] => :uid,
|
18
|
+
[1,0] => :compositions,
|
19
|
+
}
|
20
|
+
EVENT = :new_sequence
|
21
|
+
OMIT_HEADER = true
|
22
|
+
def compositions(model)
|
23
|
+
lang = @session.language
|
24
|
+
model.compositions.collect { |comp|
|
25
|
+
comp.active_agents.collect { |act|
|
26
|
+
[act.substance.name.send(lang), act.dose].join(' ')
|
27
|
+
}.join(', ')
|
28
|
+
}.join(' + ')
|
29
|
+
end
|
30
|
+
def compose_footer(offset)
|
31
|
+
@grid.add submit(@model), *offset
|
32
|
+
end
|
33
|
+
def hidden_fields(context)
|
34
|
+
super << context.hidden("uid", @container.model.uid)
|
35
|
+
end
|
36
|
+
def uid(model)
|
37
|
+
link = HtmlGrid::Link.new(:uid, model, @session, self)
|
38
|
+
link.href = @lookandfeel._event_url(:sequence, :uid => model.uid)
|
39
|
+
link.value = model.uid
|
40
|
+
link
|
41
|
+
end
|
42
|
+
end
|
43
|
+
class ProductForm < HtmlGrid::Form
|
44
|
+
include HtmlGrid::ErrorMessage
|
45
|
+
COMPONENTS = {
|
46
|
+
[0,0] => :name,
|
47
|
+
[0,1] => :company,
|
48
|
+
[1,2] => :submit,
|
49
|
+
}
|
50
|
+
EVENT = :update
|
51
|
+
LABELS = true
|
52
|
+
LEGACY_INTERFACE = false
|
53
|
+
SYMBOL_MAP = {
|
54
|
+
# Product@name is used to identify imported Products
|
55
|
+
# and should therefore not be modified
|
56
|
+
:name => HtmlGrid::Value,
|
57
|
+
}
|
58
|
+
def init
|
59
|
+
super
|
60
|
+
error_message
|
61
|
+
end
|
62
|
+
def hidden_fields(context)
|
63
|
+
super << context.hidden("uid", @model.uid)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
class ProductComposite < HtmlGrid::DivComposite
|
67
|
+
include Snapback
|
68
|
+
COMPONENTS = {
|
69
|
+
[0,0] => :snapback,
|
70
|
+
[0,1] => InlineSearch,
|
71
|
+
[0,2] => :name,
|
72
|
+
[0,3] => ProductForm,
|
73
|
+
[0,4] => "sequences",
|
74
|
+
[0,5] => :sequences,
|
75
|
+
}
|
76
|
+
CSS_ID_MAP = [ 'snapback', 'result-search', 'title' ]
|
77
|
+
CSS_MAP = { 0 => 'before-searchbar', 4 => 'divider' }
|
78
|
+
def name(model)
|
79
|
+
name = [model.name]
|
80
|
+
if(company = model.company)
|
81
|
+
name.push(' - ', company.name)
|
82
|
+
end
|
83
|
+
name
|
84
|
+
end
|
85
|
+
def sequences(model)
|
86
|
+
Sequences.new(model.sequences, @session, self)
|
87
|
+
end
|
88
|
+
def snapback(model)
|
89
|
+
[ super, @lookandfeel.lookup(:breadcrumb_divider),
|
90
|
+
@lookandfeel.lookup(:product_details_for,
|
91
|
+
model.name.send(@session.language)) ]
|
92
|
+
end
|
93
|
+
end
|
94
|
+
class Product < Template
|
95
|
+
CONTENT = ProductComposite
|
96
|
+
def _title
|
97
|
+
super.push(@model.uid)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,312 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Html::View::Drugs::Admin::Package -- de.oddb.org -- 04.04.2008 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
require 'htmlgrid/errormessage'
|
5
|
+
require 'htmlgrid/button'
|
6
|
+
require 'htmlgrid/divlist'
|
7
|
+
require 'htmlgrid/form'
|
8
|
+
require 'oddb/html/view/drugs/template'
|
9
|
+
require 'oddb/html/view/drugs/package'
|
10
|
+
require 'oddb/html/view/list'
|
11
|
+
|
12
|
+
module ODDB
|
13
|
+
module Html
|
14
|
+
module View
|
15
|
+
module Drugs
|
16
|
+
module Admin
|
17
|
+
class ActiveAgents < View::List
|
18
|
+
COMPONENTS = {
|
19
|
+
[0,0] => :delete,
|
20
|
+
[1,0] => :substance,
|
21
|
+
[2,0,0] => :dose,
|
22
|
+
[2,0,1] => :unsaved,
|
23
|
+
}
|
24
|
+
COMPONENT_CSS_MAP = { [2,0] => 'short right' }
|
25
|
+
DEFAULT_CLASS = HtmlGrid::InputText
|
26
|
+
EMPTY_LIST = true
|
27
|
+
STRIPED_BG = false
|
28
|
+
def add(model)
|
29
|
+
link = HtmlGrid::Link.new(:plus, model, @session, self)
|
30
|
+
link.set_attribute('title', @lookandfeel.lookup(:create_active_agent))
|
31
|
+
link.css_class = 'create square'
|
32
|
+
args = [ :uid, @session.state.model.uid, :composition, composition ]
|
33
|
+
url = @session.lookandfeel.event_url(:ajax_create_active_agent, args)
|
34
|
+
link.onclick = "replace_element('#{css_id}', '#{url}');"
|
35
|
+
link
|
36
|
+
end
|
37
|
+
def compose_footer(offset)
|
38
|
+
if(@model.empty? || @model.last)
|
39
|
+
@grid.add add(@model), *offset
|
40
|
+
offset[0] += 1
|
41
|
+
@grid.add delete_composition(@model), *offset
|
42
|
+
@grid.add_style 'right', *offset
|
43
|
+
@grid.set_colspan offset.at(0), offset.at(1)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
def compose_header(offset)
|
47
|
+
comp = if act = @model.first
|
48
|
+
act.composition
|
49
|
+
end
|
50
|
+
input = galenic_form(comp)
|
51
|
+
label = HtmlGrid::SimpleLabel.new(:galenic_form, input, @session, self)
|
52
|
+
pos = *offset.dup
|
53
|
+
pos[0] += 1
|
54
|
+
@grid.add [label, input], *pos
|
55
|
+
pos.push 2
|
56
|
+
@grid.set_colspan *pos
|
57
|
+
offset[1] += 1
|
58
|
+
offset
|
59
|
+
end
|
60
|
+
def composition
|
61
|
+
@container ? @container.list_index : @session.user_input(:composition)
|
62
|
+
end
|
63
|
+
def css_id
|
64
|
+
@css_id ||= "active-agents-#{composition}"
|
65
|
+
end
|
66
|
+
def delete(model)
|
67
|
+
unless(@model.first.nil?)
|
68
|
+
link = HtmlGrid::Link.new(:minus, model, @session, self)
|
69
|
+
link.set_attribute('title', @lookandfeel.lookup(:delete))
|
70
|
+
link.css_class = 'delete square'
|
71
|
+
args = [ :uid, @session.state.model.uid, :composition, composition,
|
72
|
+
:active_agent, @list_index ]
|
73
|
+
url = @session.lookandfeel.event_url(:ajax_delete_active_agent, args)
|
74
|
+
link.onclick = "replace_element('#{css_id}', '#{url}');"
|
75
|
+
link
|
76
|
+
end
|
77
|
+
end
|
78
|
+
def delete_composition(model)
|
79
|
+
link = HtmlGrid::Link.new(:delete_composition, model, @session, self)
|
80
|
+
link.css_class = 'ajax'
|
81
|
+
args = [ :uid, @session.state.model.uid, :composition, composition ]
|
82
|
+
url = @session.lookandfeel.event_url(:ajax_delete_composition, args)
|
83
|
+
link.onclick = "replace_element('composition-list', '#{url}');"
|
84
|
+
link
|
85
|
+
end
|
86
|
+
def dose(model)
|
87
|
+
input = HtmlGrid::InputText.new(name("dose"), model, @session, self)
|
88
|
+
input.value = model.dose.to_s if model
|
89
|
+
input
|
90
|
+
end
|
91
|
+
def galenic_form(model)
|
92
|
+
input = HtmlGrid::InputText.new("galenic_form[#{composition}]",
|
93
|
+
model, @session, self)
|
94
|
+
if model && gf = model.galenic_form
|
95
|
+
input.value = gf.description.send @session.language
|
96
|
+
end
|
97
|
+
input
|
98
|
+
end
|
99
|
+
def name(part)
|
100
|
+
"#{part}[#{composition}][#@list_index]"
|
101
|
+
end
|
102
|
+
def substance(model)
|
103
|
+
input = HtmlGrid::InputText.new(name("substance"), model, @session, self)
|
104
|
+
input.value = model.substance.name.send(@session.language) if model
|
105
|
+
input
|
106
|
+
end
|
107
|
+
def unsaved(model)
|
108
|
+
@lookandfeel.lookup(:unsaved) if model.nil?
|
109
|
+
end
|
110
|
+
end
|
111
|
+
class CompositionList < HtmlGrid::DivList
|
112
|
+
COMPONENTS = { [0,0] => :composition }
|
113
|
+
OFFSET_STEP = [1,0]
|
114
|
+
OMIT_HEADER = true
|
115
|
+
attr_reader :list_index
|
116
|
+
def add(model)
|
117
|
+
link = HtmlGrid::Link.new(:create_composition, model, @session, self)
|
118
|
+
link.css_class = 'ajax'
|
119
|
+
args = [ :uid, @session.state.model.uid ]
|
120
|
+
url = @session.lookandfeel.event_url(:ajax_create_composition, args)
|
121
|
+
link.onclick = "replace_element('composition-list', '#{url}');"
|
122
|
+
link
|
123
|
+
end
|
124
|
+
def compose
|
125
|
+
super
|
126
|
+
comp = @model.last
|
127
|
+
@grid.push [add(@model)] if comp.nil? || !comp.active_agents.compact.empty?
|
128
|
+
end
|
129
|
+
def composition(model)
|
130
|
+
ActiveAgents.new(model.active_agents, @session, self)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
class Compositions < HtmlGrid::DivComposite
|
134
|
+
COMPONENTS = { [0,0] => CompositionList }
|
135
|
+
CSS_ID = 'composition-list'
|
136
|
+
end
|
137
|
+
class Packages < View::List
|
138
|
+
include HtmlGrid::FormMethods
|
139
|
+
include PackageMethods
|
140
|
+
COMPONENTS = {
|
141
|
+
[0,0] => :cid,
|
142
|
+
[1,0] => :name,
|
143
|
+
[2,0] => :size,
|
144
|
+
}
|
145
|
+
EVENT = :new_package
|
146
|
+
OMIT_HEADER = true
|
147
|
+
def compose_footer(offset)
|
148
|
+
@grid.add submit(@model), *offset
|
149
|
+
end
|
150
|
+
def hidden_fields(context)
|
151
|
+
super << context.hidden("uid", @container.model.uid)
|
152
|
+
end
|
153
|
+
def cid(model)
|
154
|
+
code = model.code(:cid)
|
155
|
+
link = HtmlGrid::Link.new(:cid, model, @session, self)
|
156
|
+
link.href = @lookandfeel._event_url(:package, :cid => code)
|
157
|
+
link.value = code
|
158
|
+
link
|
159
|
+
end
|
160
|
+
end
|
161
|
+
class SequenceInnerForm < HtmlGrid::Composite
|
162
|
+
include HtmlGrid::ErrorMessage
|
163
|
+
COLSPAN_MAP = {
|
164
|
+
=begin ## temporarily disabled: this should be recoded to work with swiss infos
|
165
|
+
# in 2.0
|
166
|
+
[1,3] => 3,
|
167
|
+
[1,4] => 3,
|
168
|
+
=end
|
169
|
+
}
|
170
|
+
COMPONENTS = {
|
171
|
+
[0,0] => :atc,
|
172
|
+
[2,0] => :show_atc_name,
|
173
|
+
[0,1] => :registration,
|
174
|
+
[1,2,0] => :submit,
|
175
|
+
[1,2,1] => :delete,
|
176
|
+
=begin ## temporarily disabled: this should be recoded to work with swiss infos
|
177
|
+
# in 2.0
|
178
|
+
[1,2,0] => :fachinfo_link,
|
179
|
+
[1,2,1] => :patinfo_link,
|
180
|
+
[0,3] => :fachinfo_url,
|
181
|
+
[0,4] => :patinfo_url,
|
182
|
+
[1,5,0] => :submit,
|
183
|
+
[1,5,1] => :delete,
|
184
|
+
=end
|
185
|
+
}
|
186
|
+
COMPONENT_CSS_MAP = {
|
187
|
+
=begin ## temporarily disabled: this should be recoded to work with swiss infos
|
188
|
+
# in 2.0
|
189
|
+
[1,3] => 'url',
|
190
|
+
[1,4] => 'url',
|
191
|
+
=end
|
192
|
+
}
|
193
|
+
LABELS = true
|
194
|
+
LEGACY_INTERFACE = false
|
195
|
+
def init
|
196
|
+
if(@session.errors.any? { |err| err.message == "e_unknown_atc" })
|
197
|
+
components.store([2,0], :atc_name)
|
198
|
+
end
|
199
|
+
super
|
200
|
+
error_message
|
201
|
+
end
|
202
|
+
def atc_name(model)
|
203
|
+
HtmlGrid::InputText.new(:atc_name, model, @session, self)
|
204
|
+
end
|
205
|
+
def delete(model)
|
206
|
+
button = HtmlGrid::Button.new(:delete, model, @session, self)
|
207
|
+
script = "this.form.event.value = 'delete'; this.form.submit();"
|
208
|
+
if(model.saved?)
|
209
|
+
confirm = @lookandfeel.lookup(:delete_sequence_confirm)
|
210
|
+
script = "if(confirm('#{confirm}')) { #{script} };"
|
211
|
+
end
|
212
|
+
button.onclick = script
|
213
|
+
button
|
214
|
+
end
|
215
|
+
def fachinfo_link(model)
|
216
|
+
url = if model.respond_to?(:fachinfo) \
|
217
|
+
&& model.fachinfo.send(@session.language)
|
218
|
+
@lookandfeel._event_url(:fachinfo, [:uid, model.uid])
|
219
|
+
elsif model.respond_to?(:fachinfo_url)
|
220
|
+
model.fachinfo_url
|
221
|
+
end
|
222
|
+
if url
|
223
|
+
link = HtmlGrid::Link.new(:square_fachinfo, model, @session, self)
|
224
|
+
link.css_class = 'square fachinfo'
|
225
|
+
link.href = url
|
226
|
+
link
|
227
|
+
end
|
228
|
+
end
|
229
|
+
def patinfo_link(model)
|
230
|
+
url = if model.respond_to?(:patinfo) && model.patinfo.send(@session.language)
|
231
|
+
@lookandfeel._event_url(:patinfo, [:uid, model.uid])
|
232
|
+
elsif model.respond_to?(:patinfo_url)
|
233
|
+
model.patinfo_url
|
234
|
+
end
|
235
|
+
if url
|
236
|
+
link = HtmlGrid::Link.new(:square_patinfo, model, @session, self)
|
237
|
+
link.css_class = 'square patinfo'
|
238
|
+
link.href = url
|
239
|
+
link
|
240
|
+
end
|
241
|
+
end
|
242
|
+
def show_atc_name(model)
|
243
|
+
if(atc = model.atc)
|
244
|
+
value = HtmlGrid::Value.new(:atc_name, atc, @session, self)
|
245
|
+
value.value = atc.name.de
|
246
|
+
value
|
247
|
+
end
|
248
|
+
end
|
249
|
+
end
|
250
|
+
class SequenceForm < HtmlGrid::DivForm
|
251
|
+
COMPONENTS = {
|
252
|
+
[0,0] => SequenceInnerForm,
|
253
|
+
[0,1] => "compositions",
|
254
|
+
[0,2] => :compositions,
|
255
|
+
}
|
256
|
+
CSS_ID_MAP = { 2 => 'compositions' }
|
257
|
+
CSS_MAP = { 1 => 'divider' }
|
258
|
+
EVENT = :update
|
259
|
+
def compositions(model)
|
260
|
+
Compositions.new(model.compositions, @session, self)
|
261
|
+
end
|
262
|
+
def hidden_fields(context)
|
263
|
+
super << context.hidden("uid", @model.uid)
|
264
|
+
end
|
265
|
+
end
|
266
|
+
class SequenceComposite < HtmlGrid::DivComposite
|
267
|
+
include Snapback
|
268
|
+
COMPONENTS = {
|
269
|
+
[0,0] => :snapback,
|
270
|
+
[0,1] => InlineSearch,
|
271
|
+
[0,2] => :name,
|
272
|
+
[0,3] => SequenceForm,
|
273
|
+
[0,4] => "packages_admin",
|
274
|
+
[0,5] => :packages,
|
275
|
+
}
|
276
|
+
CSS_ID_MAP = [ 'snapback', 'result-search', 'title' ]
|
277
|
+
CSS_MAP = { 0 => 'before-searchbar', 4 => 'divider' }
|
278
|
+
def name(model)
|
279
|
+
name = [model.name]
|
280
|
+
if(company = model.company)
|
281
|
+
name.push(' - ', company.name)
|
282
|
+
end
|
283
|
+
name
|
284
|
+
end
|
285
|
+
def packages(model)
|
286
|
+
Packages.new(model.packages, @session, self) if(@model.saved?)
|
287
|
+
end
|
288
|
+
def snapback(model)
|
289
|
+
div = @lookandfeel.lookup(:breadcrumb_divider)
|
290
|
+
prd = HtmlGrid::Link.new(:product, model, @session, self)
|
291
|
+
prd.href = @lookandfeel._event_url(:product, :uid => model.product.uid)
|
292
|
+
[ super, div, prd, div,
|
293
|
+
@lookandfeel.lookup(:sequence_details_for,
|
294
|
+
model.name.send(@session.language)) ]
|
295
|
+
end
|
296
|
+
end
|
297
|
+
class Sequence < Template
|
298
|
+
CONTENT = SequenceComposite
|
299
|
+
JAVASCRIPTS = ['admin']
|
300
|
+
def _title
|
301
|
+
if @model.saved?
|
302
|
+
super.push(@model.uid)
|
303
|
+
else
|
304
|
+
super.push(@lookandfeel.lookup(:new_sequence))
|
305
|
+
end
|
306
|
+
end
|
307
|
+
end
|
308
|
+
end
|
309
|
+
end
|
310
|
+
end
|
311
|
+
end
|
312
|
+
end
|