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,54 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Drugs::TestAtc -- de.oddb.org -- 20.02.2007 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
$: << File.expand_path('../../lib', File.dirname(__FILE__))
|
5
|
+
|
6
|
+
require 'test/unit'
|
7
|
+
require 'oddb/drugs/atc'
|
8
|
+
require 'test/stub/model'
|
9
|
+
|
10
|
+
module ODDB
|
11
|
+
module Drugs
|
12
|
+
class TestAtc < Test::Unit::TestCase
|
13
|
+
def setup
|
14
|
+
@atc = Atc.new('A01AA01')
|
15
|
+
end
|
16
|
+
def test_level
|
17
|
+
l1 = Atc.new('A')
|
18
|
+
assert_equal(1, l1.level)
|
19
|
+
l2 = Atc.new('A01')
|
20
|
+
assert_equal(2, l2.level)
|
21
|
+
l3 = Atc.new('A01A')
|
22
|
+
assert_equal(3, l3.level)
|
23
|
+
l4 = Atc.new('A01AA')
|
24
|
+
assert_equal(4, l4.level)
|
25
|
+
assert_equal(5, @atc.level)
|
26
|
+
end
|
27
|
+
def test_parent
|
28
|
+
@atc.save
|
29
|
+
parent = Atc.new('A01AA')
|
30
|
+
parent.save
|
31
|
+
grandparent = Atc.new('A01A')
|
32
|
+
grandparent.save
|
33
|
+
assert_equal(parent, @atc.parent)
|
34
|
+
assert_equal(grandparent, parent.parent)
|
35
|
+
assert_nil(grandparent.parent)
|
36
|
+
end
|
37
|
+
def test_parent_code
|
38
|
+
assert_equal('A01AA', @atc.parent_code)
|
39
|
+
l4 = Atc.new('A01AA')
|
40
|
+
assert_equal('A01A', l4.parent_code)
|
41
|
+
l3 = Atc.new('A01A')
|
42
|
+
assert_equal('A01', l3.parent_code)
|
43
|
+
l2 = Atc.new('A01')
|
44
|
+
assert_equal('A', l2.parent_code)
|
45
|
+
l1 = Atc.new('A')
|
46
|
+
assert_equal(nil, l1.parent_code)
|
47
|
+
end
|
48
|
+
def test_sort
|
49
|
+
other = Atc.new('B01BC02')
|
50
|
+
assert_equal([@atc, other], [other, @atc].sort)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Drugs::TestComposition -- de.oddb.org -- 10.11.2006 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
$: << File.expand_path('../../lib', File.dirname(__FILE__))
|
5
|
+
|
6
|
+
require 'flexmock'
|
7
|
+
require 'test/unit'
|
8
|
+
require 'oddb/drugs/composition'
|
9
|
+
|
10
|
+
module ODDB
|
11
|
+
module Drugs
|
12
|
+
class TestComposition < Test::Unit::TestCase
|
13
|
+
include FlexMock::TestCase
|
14
|
+
def setup
|
15
|
+
@composition = Composition.new
|
16
|
+
end
|
17
|
+
def test_active_agent
|
18
|
+
agt1 = flexmock('agent')
|
19
|
+
agt2 = flexmock('agent')
|
20
|
+
agt1.should_receive(:substance).and_return("substance1")
|
21
|
+
agt2.should_receive(:substance).and_return("substance2")
|
22
|
+
@composition.add_active_agent(agt1)
|
23
|
+
@composition.add_active_agent(agt2)
|
24
|
+
assert_equal(agt1, @composition.active_agent("substance1"))
|
25
|
+
assert_equal(agt2, @composition.active_agent("substance2"))
|
26
|
+
end
|
27
|
+
def test_equality
|
28
|
+
other = Composition.new
|
29
|
+
third = Composition.new
|
30
|
+
assert_equal(true, other == @composition)
|
31
|
+
assert_equal(true, @composition == other)
|
32
|
+
assert_equal(true, third == @composition)
|
33
|
+
assert_equal(true, @composition == third)
|
34
|
+
|
35
|
+
gform1 = flexmock('galenic form')
|
36
|
+
@composition.galenic_form = gform1
|
37
|
+
assert_equal(false, other == @composition)
|
38
|
+
assert_equal(false, @composition == other)
|
39
|
+
|
40
|
+
other.galenic_form = gform1
|
41
|
+
assert_equal(true, other == @composition)
|
42
|
+
assert_equal(true, @composition == other)
|
43
|
+
|
44
|
+
gform2 = flexmock('other galenic form')
|
45
|
+
third.galenic_form = gform2
|
46
|
+
assert_equal(false, third == @composition)
|
47
|
+
assert_equal(false, @composition == third)
|
48
|
+
|
49
|
+
agt1 = flexmock('active agent')
|
50
|
+
agt1.should_receive(:<=>).and_return(-1)
|
51
|
+
@composition.add_active_agent(agt1)
|
52
|
+
assert_equal(false, other == @composition)
|
53
|
+
assert_equal(false, @composition == other)
|
54
|
+
|
55
|
+
other.add_active_agent(agt1)
|
56
|
+
assert_equal(true, other == @composition)
|
57
|
+
assert_equal(true, @composition == other)
|
58
|
+
|
59
|
+
agt2 = flexmock('other active agent')
|
60
|
+
agt2.should_receive(:<=>).and_return(1)
|
61
|
+
third.galenic_form = gform1
|
62
|
+
third.add_active_agent(agt2)
|
63
|
+
assert_equal(false, third == @composition)
|
64
|
+
assert_equal(false, @composition == third)
|
65
|
+
|
66
|
+
@composition.add_active_agent(agt2)
|
67
|
+
other.add_active_agent(agt2)
|
68
|
+
third.add_active_agent(agt1)
|
69
|
+
assert_equal(true, other == @composition)
|
70
|
+
assert_equal(true, @composition == other)
|
71
|
+
assert_equal(true, third == @composition)
|
72
|
+
assert_equal(true, @composition == third)
|
73
|
+
end
|
74
|
+
def test_include
|
75
|
+
sub1 = flexmock('substance')
|
76
|
+
sub2 = flexmock('substance')
|
77
|
+
assert_equal(false, @composition.include?(sub1, 10, 'mg'))
|
78
|
+
assert_equal(false, @composition.include?(sub2, 10, 'mg'))
|
79
|
+
act = flexmock('active_agent')
|
80
|
+
@composition.add_active_agent(act)
|
81
|
+
act.should_receive(:substance).and_return(sub1)
|
82
|
+
act.should_receive(:dose).and_return(Dose.new(10, 'mg'))
|
83
|
+
assert_equal(true, @composition.include?(sub1, 10, 'mg'))
|
84
|
+
assert_equal(false, @composition.include?(sub2, 10, 'mg'))
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Drugs::TestDdd -- de.oddb.org -- 12.12.2006 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
$: << File.expand_path('../../lib', File.dirname(__FILE__))
|
5
|
+
|
6
|
+
require 'test/unit'
|
7
|
+
require 'oddb/drugs/ddd'
|
8
|
+
require 'oddb/drugs/dose'
|
9
|
+
|
10
|
+
module ODDB
|
11
|
+
module Drugs
|
12
|
+
class TestDdd < Test::Unit::TestCase
|
13
|
+
def test_to_s
|
14
|
+
ddd = Ddd.new('o')
|
15
|
+
ddd.dose = Dose.new(12, 'mg')
|
16
|
+
assert_equal('o: 12 mg', ddd.to_s)
|
17
|
+
ddd.comment = 'a comment'
|
18
|
+
assert_equal('o: 12 mg (a comment)', ddd.to_s)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,190 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
# Drugs::TestDose -- de.oddb.org -- 07.11.2006 -- hwyss@ywesee.com
|
4
|
+
|
5
|
+
$: << File.expand_path('../../lib', File.dirname(__FILE__))
|
6
|
+
|
7
|
+
require 'test/unit'
|
8
|
+
require 'oddb/drugs/dose'
|
9
|
+
|
10
|
+
module ODDB
|
11
|
+
module Drugs
|
12
|
+
class TestDose < Test::Unit::TestCase
|
13
|
+
def setup
|
14
|
+
@dose = Dose.new('1,7', 'mL')
|
15
|
+
end
|
16
|
+
def test_initialize1
|
17
|
+
vals = ['Aspirin, Tabletten', '12', '500', 'mg', 'D']
|
18
|
+
dose = Dose.new(*vals[2,2])
|
19
|
+
assert_equal(500, dose.qty)
|
20
|
+
assert_equal('mg', dose.unit.to_s)
|
21
|
+
assert_equal('500 mg', dose.to_s)
|
22
|
+
end
|
23
|
+
def test_initialize2
|
24
|
+
vals = ['Hametum, Salbe', '62.5', 'mg/g', 'D']
|
25
|
+
dose = Dose.new(*vals[1,2])
|
26
|
+
assert_equal(62.5, dose.qty)
|
27
|
+
assert_equal('mg/g', dose.unit.to_s)
|
28
|
+
assert_equal('62.5 mg/g', dose.to_s)
|
29
|
+
end
|
30
|
+
def test_initialize3
|
31
|
+
dose = Dose.new('1,7', 'mL')
|
32
|
+
assert_equal(1.7, dose.qty)
|
33
|
+
assert_equal('ml', dose.unit.to_s)
|
34
|
+
assert_equal('1.7 ml', dose.to_s)
|
35
|
+
end
|
36
|
+
def test_initialize4
|
37
|
+
compare = Dose.new(6.25, 'mg/g')
|
38
|
+
vals = ['62.5', 'mg/10g']
|
39
|
+
dose = Dose.new(*vals)
|
40
|
+
assert_equal(6.25, dose.qty)
|
41
|
+
assert_equal('mg/g', dose.unit.to_s)
|
42
|
+
assert_equal('62.5mg / 10g', dose.to_s)
|
43
|
+
assert_equal(0, compare<=>dose)
|
44
|
+
assert_equal(compare, dose)
|
45
|
+
end
|
46
|
+
def test_initialize5
|
47
|
+
compare = Dose.new(0.5, 'mg/ml')
|
48
|
+
vals = [1, 'mg/2ml']
|
49
|
+
dose = Dose.new(*vals)
|
50
|
+
assert_equal(0.5, dose.qty)
|
51
|
+
assert_equal('mg/ml', dose.unit.to_s)
|
52
|
+
assert_equal('1mg / 2ml', dose.to_s)
|
53
|
+
assert_equal(0, compare<=>dose)
|
54
|
+
assert_equal(compare, dose)
|
55
|
+
end
|
56
|
+
def test_initialize6
|
57
|
+
vals = ['62.5', ' mg / 10g']
|
58
|
+
dose = Dose.new(*vals)
|
59
|
+
assert_equal(6.25, dose.qty)
|
60
|
+
assert_equal('mg/g', dose.unit.to_s)
|
61
|
+
assert_equal('62.5mg / 10g', dose.to_s)
|
62
|
+
end
|
63
|
+
def test_initialize7
|
64
|
+
dose = Dose.new('0.025', '%')
|
65
|
+
assert_equal(0.025, dose.qty)
|
66
|
+
assert_equal('%', dose.unit.to_s)
|
67
|
+
assert_equal('0.025 %', dose.to_s)
|
68
|
+
end
|
69
|
+
def test_initialize8
|
70
|
+
dose = Dose.new('40-60', 'mg')
|
71
|
+
assert_equal(50, dose.qty)
|
72
|
+
assert_equal('mg', dose.unit.to_s)
|
73
|
+
assert_equal('40-60 mg', dose.to_s)
|
74
|
+
end
|
75
|
+
def test_comparable1
|
76
|
+
dose1 = Dose.new(10, 'mg')
|
77
|
+
dose2 = Dose.new(10, 'mg')
|
78
|
+
assert_equal(dose1, dose2)
|
79
|
+
end
|
80
|
+
def test_comparable2
|
81
|
+
dose1 = Dose.new(10, 'mg')
|
82
|
+
dose2 = Dose.new(10, 'g')
|
83
|
+
assert(dose2 > dose1, "dose2 was not > dose1")
|
84
|
+
end
|
85
|
+
def test_comparable3
|
86
|
+
dose1 = Dose.new(1000, 'I.E.')
|
87
|
+
dose2 = Dose.new(500, 'I.E.')
|
88
|
+
assert(dose2 < dose1, "dose2 was not < dose1")
|
89
|
+
end
|
90
|
+
def test_comparable4
|
91
|
+
dose1 = Dose.new(1000, 'mg')
|
92
|
+
dose2 = Dose.new(500, 'I.E.')
|
93
|
+
assert_equal(-1, dose2 <=> dose1, "dose2 was not < dose1")
|
94
|
+
end
|
95
|
+
def test_comparable5
|
96
|
+
dose1 = Dose.new(1000, 'mg')
|
97
|
+
dose2 = Dose.new(500, 'l')
|
98
|
+
assert_equal(-1, dose2 <=> dose1, "dose2 was not < dose1")
|
99
|
+
end
|
100
|
+
def test_comparable6
|
101
|
+
dose1 = Dose.new(1000, 'mg')
|
102
|
+
dose2 = Dose.new(1, 'g')
|
103
|
+
assert(dose2 == dose1, "dose2 was not == dose1")
|
104
|
+
end
|
105
|
+
def test_comparable7
|
106
|
+
dose1 = Dose.new('400-600', 'mg')
|
107
|
+
dose2 = Dose.new('0.4-0.6', 'g')
|
108
|
+
assert(dose2 == dose1, "dose2 was not == dose1")
|
109
|
+
end
|
110
|
+
def test_comparable8
|
111
|
+
dose1 = Dose.new('1000', 'µg')
|
112
|
+
dose2 = Dose.new('1', 'mg')
|
113
|
+
assert(dose2 == dose1, "dose2 was not == dose1")
|
114
|
+
end
|
115
|
+
def test_comparable9
|
116
|
+
dose1 = Dose.new(1000)
|
117
|
+
assert(dose1 == 1000, "Dose was not equal to equivalent Fixnum")
|
118
|
+
assert(1000 == dose1, "Fixnum was not equal to equivalent Dose")
|
119
|
+
end
|
120
|
+
def test_comparable10
|
121
|
+
dose1 = Dose.new(1000)
|
122
|
+
dose2 = Dose.new(1000, 'mg')
|
123
|
+
dose3 = Dose.new(500)
|
124
|
+
dose4 = Dose.new(1000)
|
125
|
+
assert_equal(-1, dose1 <=> dose2)
|
126
|
+
assert_equal(1, dose2 <=> dose1)
|
127
|
+
assert_equal(-1, dose3 <=> dose1)
|
128
|
+
assert_equal(1, dose1 <=> dose3)
|
129
|
+
assert_equal(0, dose1 <=> dose4)
|
130
|
+
end
|
131
|
+
def test_complex_unit
|
132
|
+
dose = nil
|
133
|
+
assert_nothing_raised {
|
134
|
+
dose = Dose.new(20.0, 'mg/5ml')
|
135
|
+
}
|
136
|
+
end
|
137
|
+
def test_from_quanty
|
138
|
+
quanty = Quanty.new(1,'mg')
|
139
|
+
result = Dose.from_quanty(quanty)
|
140
|
+
assert_instance_of(Dose, result)
|
141
|
+
assert_equal(Dose.new(1, 'mg'), result)
|
142
|
+
end
|
143
|
+
def test_addition
|
144
|
+
dose1 = Dose.new(7,'ml')
|
145
|
+
dose2 = Dose.new(1,'cl')
|
146
|
+
assert_equal(Dose.new(1.7, 'cl'), dose1 + dose2)
|
147
|
+
end
|
148
|
+
def test_subtraction
|
149
|
+
dose1 = Dose.new(1,'cl')
|
150
|
+
dose2 = Dose.new(7,'ml')
|
151
|
+
assert_equal(Dose.new(0.3, 'cl'), dose1 - dose2)
|
152
|
+
end
|
153
|
+
def test_multiplication
|
154
|
+
dose1 = Dose.new(1,'ml')
|
155
|
+
dose2 = Dose.new(1.7,'kg')
|
156
|
+
assert_equal(Dose.new(1.7, 'ml kg'), dose1 * dose2)
|
157
|
+
end
|
158
|
+
def test_division
|
159
|
+
dose1 = Dose.new(0.2,'g')
|
160
|
+
dose2 = Dose.new(100,'ml')
|
161
|
+
assert_equal(Dose.new(2, 'mg/ml'), dose1 / dose2)
|
162
|
+
end
|
163
|
+
def test_robust_initalizer
|
164
|
+
assert_nothing_raised {
|
165
|
+
Dose.new(12)
|
166
|
+
}
|
167
|
+
end
|
168
|
+
def test_range
|
169
|
+
dose = nil
|
170
|
+
assert_nothing_raised {
|
171
|
+
dose = Dose.new(1..5, 'mg')
|
172
|
+
}
|
173
|
+
assert_equal('1-5 mg', dose.to_s)
|
174
|
+
end
|
175
|
+
def test_robust_to_f
|
176
|
+
dose = Dose.new(12, 'mg')
|
177
|
+
assert_nothing_raised {
|
178
|
+
dose.to_f
|
179
|
+
}
|
180
|
+
end
|
181
|
+
def test_robust_to_i
|
182
|
+
dose = Dose.new(12, 'mg')
|
183
|
+
assert_nothing_raised {
|
184
|
+
dose.to_i
|
185
|
+
}
|
186
|
+
assert_equal(12, dose.to_i)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Drugs::TestGalenicForm -- de.oddb.org -- 21.02.2007 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
$: << File.expand_path('../../lib', File.dirname(__FILE__))
|
5
|
+
|
6
|
+
require 'test/unit'
|
7
|
+
require 'oddb/drugs/galenic_form'
|
8
|
+
|
9
|
+
module ODDB
|
10
|
+
module Drugs
|
11
|
+
class TestGalenicForm < Test::Unit::TestCase
|
12
|
+
def setup
|
13
|
+
@galenic_form = GalenicForm.new
|
14
|
+
end
|
15
|
+
def test_equal
|
16
|
+
other = GalenicForm.new
|
17
|
+
assert_equal(true, @galenic_form == @galenic_form)
|
18
|
+
assert_equal(false, @galenic_form == other)
|
19
|
+
assert_equal(false, other == @galenic_form)
|
20
|
+
assert_equal(false, @galenic_form == nil)
|
21
|
+
|
22
|
+
group = GalenicGroup.new('Tabletten')
|
23
|
+
@galenic_form.group = group
|
24
|
+
assert_equal(true, @galenic_form == @galenic_form)
|
25
|
+
assert_equal(false, @galenic_form == other)
|
26
|
+
assert_equal(false, other == @galenic_form)
|
27
|
+
assert_equal(false, @galenic_form == nil)
|
28
|
+
|
29
|
+
other.group = GalenicGroup.new('Salben')
|
30
|
+
assert_equal(true, @galenic_form == @galenic_form)
|
31
|
+
assert_equal(false, @galenic_form == other)
|
32
|
+
assert_equal(false, other == @galenic_form)
|
33
|
+
|
34
|
+
other.group = group
|
35
|
+
assert_equal(true, @galenic_form == @galenic_form)
|
36
|
+
assert_equal(true, @galenic_form == other)
|
37
|
+
assert_equal(true, other == @galenic_form)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,173 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Drugs::TestPackage -- de.oddb.org -- 14.11.2006 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
$: << File.expand_path('../../lib', File.dirname(__FILE__))
|
5
|
+
|
6
|
+
require 'flexmock'
|
7
|
+
require 'test/unit'
|
8
|
+
require 'oddb/drugs/package'
|
9
|
+
require 'oddb/drugs/dose'
|
10
|
+
require 'oddb/util/money'
|
11
|
+
|
12
|
+
module ODDB
|
13
|
+
module Drugs
|
14
|
+
class TestPackage < Test::Unit::TestCase
|
15
|
+
include FlexMock::TestCase
|
16
|
+
def setup
|
17
|
+
@package = Package.new
|
18
|
+
end
|
19
|
+
def test_comparable
|
20
|
+
other = Package.new
|
21
|
+
third = Package.new
|
22
|
+
|
23
|
+
## empty packages are comparable
|
24
|
+
assert_equal(true, other.comparable?(@package))
|
25
|
+
assert_equal(true, @package.comparable?(other))
|
26
|
+
assert_equal(true, third.comparable?(@package))
|
27
|
+
assert_equal(true, @package.comparable?(third))
|
28
|
+
|
29
|
+
## if the number of parts is different: not comparable
|
30
|
+
part1 = flexmock("part")
|
31
|
+
part1.should_receive(:comparable_size)\
|
32
|
+
.and_return(Dose.new(10, 'mg'))
|
33
|
+
@package.add_part(part1)
|
34
|
+
assert_equal(false, other.comparable?(@package))
|
35
|
+
assert_equal(false, @package.comparable?(other))
|
36
|
+
assert_equal(false, third.comparable?(@package))
|
37
|
+
assert_equal(false, @package.comparable?(third))
|
38
|
+
|
39
|
+
## if the comparable_size is the same: comparable
|
40
|
+
part2 = flexmock("part")
|
41
|
+
part2.should_receive(:comparable_size)\
|
42
|
+
.and_return(Dose.new(10, 'mg'))
|
43
|
+
other.add_part(part2)
|
44
|
+
assert_equal(true, other.comparable?(@package))
|
45
|
+
assert_equal(true, @package.comparable?(other))
|
46
|
+
|
47
|
+
## if the comparable_size is not the same: not comparable
|
48
|
+
part3 = flexmock("part")
|
49
|
+
part3.should_receive(:comparable_size)\
|
50
|
+
.and_return(Dose.new(20, 'mg'))
|
51
|
+
third.add_part(part3)
|
52
|
+
assert_equal(false, third.comparable?(@package))
|
53
|
+
assert_equal(false, @package.comparable?(third))
|
54
|
+
|
55
|
+
## comparable still works for multiple parts
|
56
|
+
@package.add_part(part3)
|
57
|
+
other.add_part(part3)
|
58
|
+
assert_equal(true, other.comparable?(@package))
|
59
|
+
assert_equal(true, @package.comparable?(other))
|
60
|
+
|
61
|
+
## ... but not if the order of parts is different
|
62
|
+
third.add_part(part2)
|
63
|
+
assert_equal(false, third.comparable?(@package))
|
64
|
+
assert_equal(false, @package.comparable?(third))
|
65
|
+
end
|
66
|
+
def test_comparables
|
67
|
+
part1 = flexmock("part")
|
68
|
+
part1.should_receive(:comparable_size)\
|
69
|
+
.and_return(Dose.new(10, 'mg'))
|
70
|
+
part1.should_ignore_missing
|
71
|
+
@package.add_part(part1)
|
72
|
+
|
73
|
+
sequence = flexmock('sequence')
|
74
|
+
seq1 = flexmock('sequence')
|
75
|
+
seq2 = flexmock('sequence')
|
76
|
+
sequence.should_receive(:comparables).and_return([seq1, seq2])
|
77
|
+
sequence.should_receive(:compositions).and_return([])
|
78
|
+
sequence.should_ignore_missing
|
79
|
+
@package.sequence = sequence
|
80
|
+
|
81
|
+
package1 = Package.new
|
82
|
+
package1.add_part(part1)
|
83
|
+
seq1.should_receive(:packages).and_return([package1, @package])
|
84
|
+
|
85
|
+
part2 = flexmock("part")
|
86
|
+
part2.should_receive(:comparable_size)\
|
87
|
+
.and_return(Dose.new(20, 'mg'))
|
88
|
+
package2 = Package.new
|
89
|
+
package2.add_part(part2)
|
90
|
+
seq2.should_receive(:packages).and_return([package2])
|
91
|
+
|
92
|
+
assert_equal([package1], @package.comparables)
|
93
|
+
end
|
94
|
+
def test_comparable_size
|
95
|
+
assert_equal([], @package.comparable_size)
|
96
|
+
part1 = flexmock("part")
|
97
|
+
part1.should_receive(:comparable_size)\
|
98
|
+
.and_return(Dose.new(10, 'mg'))
|
99
|
+
@package.add_part(part1)
|
100
|
+
assert_equal([Dose.new(10, 'mg')], @package.comparable_size)
|
101
|
+
part2 = flexmock("part")
|
102
|
+
part2.should_receive(:comparable_size)\
|
103
|
+
.and_return(Dose.new(20, 'mg'))
|
104
|
+
@package.add_part(part2)
|
105
|
+
assert_equal([Dose.new(10, 'mg'), Dose.new(20, 'mg')],
|
106
|
+
@package.comparable_size)
|
107
|
+
end
|
108
|
+
def test_dose_price
|
109
|
+
doses = []
|
110
|
+
|
111
|
+
sequence = flexmock('sequence')
|
112
|
+
sequence.should_receive(:add_package).with(@package)
|
113
|
+
sequence.should_receive(:save)
|
114
|
+
sequence.should_receive(:compositions).and_return([])
|
115
|
+
sequence.should_receive(:doses).and_return(doses)
|
116
|
+
@package.sequence = sequence
|
117
|
+
|
118
|
+
dose = Drugs::Dose.new(1, 'g')
|
119
|
+
assert_nil(@package.dose_price(nil))
|
120
|
+
assert_nil(@package.dose_price(dose))
|
121
|
+
|
122
|
+
price = Business::Price.new(:public, 'CH')
|
123
|
+
price.value = Util::Money.new(10)
|
124
|
+
assert(price.is_for?(:public, 'CH'))
|
125
|
+
@package.add_price(price)
|
126
|
+
assert_nil(@package.dose_price(nil))
|
127
|
+
assert_nil(@package.dose_price(dose))
|
128
|
+
|
129
|
+
doses.push(Drugs::Dose.new(10, 'mg'))
|
130
|
+
assert_nil(@package.dose_price(nil))
|
131
|
+
assert_nil(@package.dose_price(dose))
|
132
|
+
|
133
|
+
part1 = flexmock("part")
|
134
|
+
part1.should_receive(:comparable_size)\
|
135
|
+
.and_return(Dose.new(2))
|
136
|
+
part1.should_ignore_missing
|
137
|
+
@package.add_part(part1)
|
138
|
+
assert_nil(@package.dose_price(nil))
|
139
|
+
expected = Util::Money.new(500)
|
140
|
+
assert_equal(expected, @package.dose_price(dose))
|
141
|
+
end
|
142
|
+
def test_sequence_writer
|
143
|
+
part = flexmock('Part')
|
144
|
+
sequence = flexmock('Sequence')
|
145
|
+
comp = flexmock('Composition')
|
146
|
+
@package.add_part(part)
|
147
|
+
sequence.should_receive(:add_package).times(1)
|
148
|
+
sequence.should_receive(:save).times(2)
|
149
|
+
sequence.should_receive(:compositions).and_return([comp])
|
150
|
+
part.should_receive(:composition=).with(comp)\
|
151
|
+
.times(1).and_return { assert(true) }
|
152
|
+
part.should_receive(:save)
|
153
|
+
@package.sequence = sequence
|
154
|
+
|
155
|
+
sequence.should_receive(:remove_package).with(@package).times(1)
|
156
|
+
part.should_receive(:composition=).with(nil)\
|
157
|
+
.times(1).and_return { assert(true) }
|
158
|
+
@package.sequence = nil
|
159
|
+
end
|
160
|
+
def test_size
|
161
|
+
assert_equal(0, @package.size)
|
162
|
+
part1 = flexmock("part")
|
163
|
+
part1.should_receive(:comparable_size).and_return(Dose.new(1))
|
164
|
+
@package.add_part(part1)
|
165
|
+
assert_equal(1, @package.size)
|
166
|
+
part2 = flexmock("part")
|
167
|
+
part2.should_receive(:comparable_size).and_return(Dose.new(2))
|
168
|
+
@package.add_part(part2)
|
169
|
+
assert_equal(3, @package.size)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|