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
data/lib/oddb/export.rb
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Export::Csv -- de.oddb.org -- 22.07.2008 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
require 'csv'
|
5
|
+
|
6
|
+
module ODDB
|
7
|
+
module Export
|
8
|
+
module Csv
|
9
|
+
class Packages
|
10
|
+
def self.export(packages, components, language = :de)
|
11
|
+
atcs = partition packages
|
12
|
+
CSV.generate { |csv|
|
13
|
+
atcs.each { |list|
|
14
|
+
csv << atc_line(list.atc, language)
|
15
|
+
list.each { |pac|
|
16
|
+
csv << package_line(pac, components, language)
|
17
|
+
}
|
18
|
+
}
|
19
|
+
}
|
20
|
+
end
|
21
|
+
def self.atc_line(atc, language)
|
22
|
+
if atc
|
23
|
+
result = [atc.code]
|
24
|
+
if name = atc.name
|
25
|
+
result.push name.send(language)
|
26
|
+
end
|
27
|
+
result
|
28
|
+
else
|
29
|
+
['ATC-Code nicht bekannt']
|
30
|
+
end
|
31
|
+
end
|
32
|
+
def self.active_agents(package, lang)
|
33
|
+
package.active_agents.join('|')
|
34
|
+
end
|
35
|
+
def self.ddd_prices(package, language)
|
36
|
+
ddds = []
|
37
|
+
package.ddds.each_with_index { |ddd, idx|
|
38
|
+
ddds.push sprintf("%s (%s)", package.dose_price(ddd.dose),
|
39
|
+
ddd.administration)
|
40
|
+
}
|
41
|
+
ddds.join '|'
|
42
|
+
end
|
43
|
+
def self.package_line(package, components, language)
|
44
|
+
components.collect { |key|
|
45
|
+
value = if respond_to?(key)
|
46
|
+
self.send key, package, language
|
47
|
+
elsif package.respond_to?(key)
|
48
|
+
package.send key
|
49
|
+
end
|
50
|
+
case value
|
51
|
+
when Util::Multilingual
|
52
|
+
value.send language
|
53
|
+
else
|
54
|
+
value
|
55
|
+
end
|
56
|
+
}
|
57
|
+
end
|
58
|
+
def self.partition(packages)
|
59
|
+
atcs = {}
|
60
|
+
packages.each { |package|
|
61
|
+
code = (atc = package.atc) ? atc.code : 'X'
|
62
|
+
(atcs[code] ||= Util::AnnotatedList.new(:atc => atc)).push(package)
|
63
|
+
}
|
64
|
+
atcs.sort.collect { |code, packages|
|
65
|
+
packages
|
66
|
+
}
|
67
|
+
end
|
68
|
+
def self.price_exfactory(package, lang)
|
69
|
+
package.price(:exfactory)
|
70
|
+
end
|
71
|
+
def self.price_festbetrag(package, lang)
|
72
|
+
package.price(:festbetrag)
|
73
|
+
end
|
74
|
+
def self.price_public(package, lang)
|
75
|
+
package.price(:public)
|
76
|
+
end
|
77
|
+
def self.product(package, language)
|
78
|
+
(product = package.product) && product.name
|
79
|
+
end
|
80
|
+
def self.pzn(package, lang)
|
81
|
+
package.code(:cid)
|
82
|
+
end
|
83
|
+
def self.size(package, language)
|
84
|
+
package.parts.collect { |part| part.to_s(language) }.join('+')
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Export::SessionStub -- de.oddb.org -- 11.12.2007 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
require 'oddb/html/util/lookandfeel'
|
5
|
+
require 'oddb/html/util/session'
|
6
|
+
|
7
|
+
module ODDB
|
8
|
+
module Export
|
9
|
+
class SessionStub
|
10
|
+
attr_reader :flavor, :http_protocol, :default_language, :server_name
|
11
|
+
attr_accessor :language, :lookandfeel
|
12
|
+
def initialize
|
13
|
+
@flavor = Html::Util::Session::DEFAULT_FLAVOR
|
14
|
+
@http_protocol = 'http'
|
15
|
+
@default_language = 'de'
|
16
|
+
@server_name = ODDB.config.server_name
|
17
|
+
end
|
18
|
+
def method_missing(*args)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
def Export.l10n_sessions(&block)
|
22
|
+
stub = SessionStub.new
|
23
|
+
Html::Util::Lookandfeel::DICTIONARIES.each_key { |lang|
|
24
|
+
stub.language = lang
|
25
|
+
stub.lookandfeel = Html::Util::Lookandfeel.new(stub)
|
26
|
+
block.call(stub)
|
27
|
+
}
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Export::Rss -- de.oddb.org -- 10.12.2007 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
require 'oddb/util/feedback'
|
5
|
+
require 'oddb/export/l10n_sessions'
|
6
|
+
|
7
|
+
module ODDB
|
8
|
+
module Export
|
9
|
+
module Rss
|
10
|
+
class Exporter
|
11
|
+
def initialize
|
12
|
+
@rss_dir = File.join(ODDB.config.var, 'rss')
|
13
|
+
@name = self.class.name[/[^:]+$/]
|
14
|
+
@filename = @name.downcase + ".rss"
|
15
|
+
end
|
16
|
+
def export
|
17
|
+
items = sorted_items
|
18
|
+
return if(items.empty?)
|
19
|
+
Export.l10n_sessions { |session|
|
20
|
+
dir = File.join(@rss_dir, session.language)
|
21
|
+
FileUtils.mkdir_p(dir)
|
22
|
+
path = File.join(dir, @filename)
|
23
|
+
tmp = File.join(dir, '.' << @filename)
|
24
|
+
File.open(tmp, 'w') { |io|
|
25
|
+
io.puts rss(items, session)
|
26
|
+
}
|
27
|
+
File.rename(tmp, path)
|
28
|
+
}
|
29
|
+
end
|
30
|
+
def rss items, session
|
31
|
+
require "oddb/html/view/rss/#{@name.downcase}"
|
32
|
+
klass = Html::View::Rss.const_get @name
|
33
|
+
view = klass.new(items, session, nil)
|
34
|
+
view.to_html(CGI.new('html4'))
|
35
|
+
end
|
36
|
+
end
|
37
|
+
class Feedback < Exporter
|
38
|
+
def sorted_items
|
39
|
+
Util::Feedback.newest(:all)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Export::Server -- de.oddb.org -- 10.10.2007 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
require 'date'
|
5
|
+
require 'drb'
|
6
|
+
require 'oddb/config'
|
7
|
+
require 'oddb/export/xls'
|
8
|
+
require 'oddb/export/yaml'
|
9
|
+
require 'oddb/util/mail'
|
10
|
+
|
11
|
+
module ODDB
|
12
|
+
module Export
|
13
|
+
module Server
|
14
|
+
def Server.remote_export_chde
|
15
|
+
if(uri = ODDB.config.remote_databases.first)
|
16
|
+
remote = DRb::DRbObject.new(nil, uri)
|
17
|
+
safe_export(Export::Xls::ComparisonDeCh) { |exporter|
|
18
|
+
remote.remote_export("chde.xls") { |path|
|
19
|
+
File.open(path, 'w+') { |io| exporter.export(uri, io) }
|
20
|
+
}
|
21
|
+
}
|
22
|
+
end
|
23
|
+
end
|
24
|
+
def Server.remote_export_yaml
|
25
|
+
if(uri = ODDB.config.remote_databases.first)
|
26
|
+
remote = DRb::DRbObject.new(nil, uri)
|
27
|
+
safe_export(Export::Yaml::Drugs) { |exporter|
|
28
|
+
remote.remote_export("de.oddb.yaml") { |path|
|
29
|
+
File.open(path, 'w') { |io| exporter.export(io) }
|
30
|
+
}
|
31
|
+
}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
def Server.run(today = Date.today)
|
35
|
+
on_monthday(1, today) {
|
36
|
+
remote_export_chde
|
37
|
+
}
|
38
|
+
end
|
39
|
+
def Server.on_monthday(day, today = Date.today, &block)
|
40
|
+
if(today.day == day)
|
41
|
+
block.call
|
42
|
+
end
|
43
|
+
end
|
44
|
+
def Server.safe_export(exporter, &block)
|
45
|
+
block.call(exporter.new)
|
46
|
+
rescue StandardError => err
|
47
|
+
subject = sprintf("%s: %s",
|
48
|
+
Time.now.strftime('%c'), exporter)
|
49
|
+
lines = [
|
50
|
+
sprintf("%s: %s#export",
|
51
|
+
Time.now.strftime('%c'), exporter)
|
52
|
+
]
|
53
|
+
lines.push(err.class, err.message, *err.backtrace)
|
54
|
+
Util::Mail.notify_admins(subject, lines)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
# Export::Xls -- de.oddb.org -- 13.03.2007 -- hwyss@ywesee.com
|
4
|
+
|
5
|
+
require 'fileutils'
|
6
|
+
require 'spreadsheet/excel'
|
7
|
+
require 'oddb/remote/drugs/package'
|
8
|
+
require 'oddb/util/comparison'
|
9
|
+
|
10
|
+
module ODDB
|
11
|
+
module Export
|
12
|
+
module Xls
|
13
|
+
class ComparisonDeCh
|
14
|
+
@@iconv = Iconv.new('latin1//IGNORE//TRANSLIT', 'utf8')
|
15
|
+
def export(drb_uri, io)
|
16
|
+
write_xls(io, collect_comparables(drb_uri))
|
17
|
+
end
|
18
|
+
def adjust_price(price)
|
19
|
+
price * currency_rate * tax_factor
|
20
|
+
end
|
21
|
+
def collect_comparables(drb_uri)
|
22
|
+
data = []
|
23
|
+
DRb::DRbObject.new(nil, drb_uri).remote_each_package { |remote|
|
24
|
+
package = Remote::Drugs::Package.new(drb_uri, remote,
|
25
|
+
1.0 / currency_rate,
|
26
|
+
tax_factor)
|
27
|
+
if(package.price(:public) \
|
28
|
+
&& (comparable = package.local_comparables.select { |pac|
|
29
|
+
pac.price(:public)
|
30
|
+
}.sort_by { |pac|
|
31
|
+
pac.price(:public)
|
32
|
+
}.first))
|
33
|
+
data.push [comparable, package]
|
34
|
+
end
|
35
|
+
nil # don't return data from the block across drb
|
36
|
+
}
|
37
|
+
data
|
38
|
+
end
|
39
|
+
def collect_cell(local, remote, format = "%s (%s)", &block)
|
40
|
+
lval = block.call(local) rescue StandardError
|
41
|
+
rval = block.call(remote) rescue StandardError
|
42
|
+
lval == rval ? lval : sprintf(format, lval, rval)
|
43
|
+
end
|
44
|
+
def currency_rate
|
45
|
+
@currency_rate ||= Currency.rate('EUR', 'CHF')
|
46
|
+
end
|
47
|
+
def tax_factor
|
48
|
+
1.076 / 1.19
|
49
|
+
end
|
50
|
+
def write_row(worksheet, idx, local, remote)
|
51
|
+
comparison = Util::Comparison.new(local, remote)
|
52
|
+
lexf = local.price(:exfactory)
|
53
|
+
rexf = remote.price(:exfactory)
|
54
|
+
data = [
|
55
|
+
collect_cell(local, remote) { |x|
|
56
|
+
x.name.de || x.product.name.de },
|
57
|
+
collect_cell(local, remote) { |x|
|
58
|
+
size, _ = x.comparable_size
|
59
|
+
size.to_s
|
60
|
+
},
|
61
|
+
adjust_price(local.price(:public)).to_s,
|
62
|
+
collect_cell(local, remote) { |x| x.company.name.de },
|
63
|
+
local.code(:cid).to_s,
|
64
|
+
remote.code(:ean).to_s,
|
65
|
+
collect_cell(local, remote) { |x|
|
66
|
+
x.galenic_forms.first.description.de },
|
67
|
+
collect_cell(local, remote) { |x|
|
68
|
+
x.active_agents.first.dose.to_s },
|
69
|
+
collect_cell(local, remote) { |x|
|
70
|
+
x.active_agents.first.substance.name.de },
|
71
|
+
remote.atc.code,
|
72
|
+
remote.ikscat,
|
73
|
+
remote.sl_entry ? 'SL' : '',
|
74
|
+
sprintf("%+4.2f", adjust_price(comparison.absolute)),
|
75
|
+
sprintf("%+4.2f%%", comparison.difference),
|
76
|
+
sprintf("%4.2f", comparison.factor),
|
77
|
+
(adjust_price(lexf) if lexf).to_s,
|
78
|
+
(adjust_price(rexf) if rexf).to_s,
|
79
|
+
]
|
80
|
+
if(lexf && rexf)
|
81
|
+
data.push sprintf("%+4.2f", adjust_price(comparison.absolute_exfactory)),
|
82
|
+
sprintf("%+4.2f%%", comparison.difference_exfactory)
|
83
|
+
end
|
84
|
+
worksheet.write idx, 0, data
|
85
|
+
end
|
86
|
+
def write_xls(io, data)
|
87
|
+
workbook = Spreadsheet::Excel.new(io)
|
88
|
+
worksheet = workbook.add_worksheet('Preisvergleich')
|
89
|
+
fmt_title = Spreadsheet::Format.new(:bold => true)
|
90
|
+
workbook.add_format(fmt_title)
|
91
|
+
worksheet.write 0, 0, [
|
92
|
+
"Name DE (Name CH)",
|
93
|
+
"Pkg Grösse DE (Pkg Grösse CH)",
|
94
|
+
"AVP inkl. Mwst in CHF nach Abzug und Zuschlag",
|
95
|
+
"Hersteller DE (Hersteller CH)",
|
96
|
+
"PZN", "EAN",
|
97
|
+
"Gal Form DE (gal. Form CH)",
|
98
|
+
"Stärke (Schreibweise CH)",
|
99
|
+
"Wirkstoff (Schreibweise CH)",
|
100
|
+
"ATC-Code", "Abgabekategorie CH", "SL Schweiz",
|
101
|
+
"Preisunterschied inkl. Mwst. in CHF",
|
102
|
+
"Preisunterschied in % (normalisiert)",
|
103
|
+
"Packungsäquivalenzfaktor",
|
104
|
+
"FAP DE exkl. MwSt (errechnet)",
|
105
|
+
"FAP CH exkl. MwSt",
|
106
|
+
"Preisunterschied FAP in CHF ",
|
107
|
+
"Preisunterschied FAP in % (normalisiert)",
|
108
|
+
], fmt_title
|
109
|
+
data.sort_by { |local, remote|
|
110
|
+
local.name.de || local.product.name.de
|
111
|
+
}.each_with_index { |(local, remote), idx|
|
112
|
+
write_row(worksheet, idx.next, local, remote)
|
113
|
+
}
|
114
|
+
workbook.close
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Export::Yaml -- de.oddb.org -- 09.10.2007 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
require 'fixes/yaml'
|
5
|
+
require 'oddb/business/company'
|
6
|
+
require 'oddb/drugs'
|
7
|
+
|
8
|
+
module ODDB
|
9
|
+
module OddbUri
|
10
|
+
YAML_URI = '!de.oddb.org,2007'
|
11
|
+
yaml_as YAML_URI
|
12
|
+
def to_yaml_type
|
13
|
+
"#{YAML_URI}/#{self.class}"
|
14
|
+
end
|
15
|
+
def to_yaml( opts = {} )
|
16
|
+
YAML::quick_emit( self.object_id, opts ) { |out|
|
17
|
+
out.map( taguri ) { |map|
|
18
|
+
to_yaml_map(map)
|
19
|
+
}
|
20
|
+
}
|
21
|
+
end
|
22
|
+
def to_yaml_map(map)
|
23
|
+
if(respond_to?(:oid) && id = oid)
|
24
|
+
map.add("oid", id)
|
25
|
+
end
|
26
|
+
to_yaml_properties.each { |m|
|
27
|
+
map.add( m[1..-1], instance_variable_get( m ) )
|
28
|
+
}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
module Yaml
|
32
|
+
include OddbUri
|
33
|
+
def to_yaml_properties
|
34
|
+
super - self.class.connections - self.class.connectors
|
35
|
+
end
|
36
|
+
def Yaml.append_features(mod)
|
37
|
+
super
|
38
|
+
mod.module_eval {
|
39
|
+
class << self
|
40
|
+
def export(*args)
|
41
|
+
define_method(:to_yaml_properties) {
|
42
|
+
super().push(*args).uniq.reject { |name|
|
43
|
+
instance_variable_get(name).nil? }
|
44
|
+
}
|
45
|
+
end
|
46
|
+
end
|
47
|
+
}
|
48
|
+
end
|
49
|
+
end
|
50
|
+
class Model
|
51
|
+
include Yaml
|
52
|
+
end
|
53
|
+
module Util
|
54
|
+
class Code
|
55
|
+
include OddbUri
|
56
|
+
def to_yaml_map(map)
|
57
|
+
super
|
58
|
+
map.add('value', value)
|
59
|
+
end
|
60
|
+
def to_yaml_properties
|
61
|
+
super - [:@values]
|
62
|
+
end
|
63
|
+
end
|
64
|
+
class Multilingual
|
65
|
+
include OddbUri
|
66
|
+
end
|
67
|
+
end
|
68
|
+
module Business
|
69
|
+
class Company
|
70
|
+
export :@name
|
71
|
+
end
|
72
|
+
end
|
73
|
+
module Drugs
|
74
|
+
class ActiveAgent
|
75
|
+
export :@substance
|
76
|
+
end
|
77
|
+
class Atc
|
78
|
+
export :@ddds
|
79
|
+
end
|
80
|
+
class Composition
|
81
|
+
export :@active_agents, :@parts
|
82
|
+
end
|
83
|
+
class Dose
|
84
|
+
include OddbUri
|
85
|
+
def to_yaml_properties
|
86
|
+
[ :@val, :@unit ]
|
87
|
+
end
|
88
|
+
end
|
89
|
+
class GalenicForm
|
90
|
+
export :@group
|
91
|
+
end
|
92
|
+
class Package
|
93
|
+
def to_yaml_map(map)
|
94
|
+
super
|
95
|
+
map.add('prices', self.prices.inject({}) { |memo, price|
|
96
|
+
memo.store(price.type, price.to_f)
|
97
|
+
memo
|
98
|
+
} )
|
99
|
+
end
|
100
|
+
def to_yaml_properties
|
101
|
+
(super - [:@prices]).push(:@parts)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
class Product
|
105
|
+
export :@company, :@sequences
|
106
|
+
end
|
107
|
+
class Sequence
|
108
|
+
export :@atc, :@compositions, :@packages
|
109
|
+
end
|
110
|
+
class Substance
|
111
|
+
export :@group
|
112
|
+
end
|
113
|
+
end
|
114
|
+
module Export
|
115
|
+
module Yaml
|
116
|
+
class Drugs
|
117
|
+
def export(io)
|
118
|
+
ODDB::Drugs::Product.all { |product| io.puts product.to_yaml }
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|