de.oddb 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (431) hide show
  1. data/Guide.txt +3 -0
  2. data/History.txt +5 -0
  3. data/LICENCE.txt +339 -0
  4. data/Manifest.txt +430 -0
  5. data/README +423 -0
  6. data/README.txt +25 -0
  7. data/Rakefile +28 -0
  8. data/bin/admin +71 -0
  9. data/bin/exportd +44 -0
  10. data/bin/oddbd +33 -0
  11. data/data/fulltext/data/dicts/french/fulltext.aff +1057 -0
  12. data/data/fulltext/data/dicts/french/fulltext.dict +91189 -0
  13. data/data/fulltext/data/dicts/french/fulltext.stop +135 -0
  14. data/data/fulltext/data/dicts/german/fulltext.aff +1233 -0
  15. data/data/fulltext/data/dicts/german/fulltext.dict +287574 -0
  16. data/data/fulltext/data/dicts/german/fulltext.stop +133 -0
  17. data/data/fulltext/data/german_compound/README +15 -0
  18. data/data/fulltext/data/german_compound/compound.pl +63 -0
  19. data/data/fulltext/data/german_compound/german.stop +20 -0
  20. data/data/fulltext/data/ispell-german-compound.tar.gz +0 -0
  21. data/data/fulltext/redist/dict_french/Makefile +12 -0
  22. data/data/fulltext/redist/dict_french/README.french +1 -0
  23. data/data/fulltext/redist/dict_french/dict_french.sql.in +7 -0
  24. data/data/fulltext/redist/dict_french/dict_snowball.c +56 -0
  25. data/data/fulltext/redist/dict_french/french_stem.c +1222 -0
  26. data/data/fulltext/redist/dict_french/french_stem.h +16 -0
  27. data/data/fulltext/redist/dict_french/subinclude.h +2 -0
  28. data/data/fulltext/redist/dict_german/Makefile +12 -0
  29. data/data/fulltext/redist/dict_german/README.german +1 -0
  30. data/data/fulltext/redist/dict_german/dict_german.sql.in +7 -0
  31. data/data/fulltext/redist/dict_german/dict_snowball.c +56 -0
  32. data/data/fulltext/redist/dict_german/german_stem.c +527 -0
  33. data/data/fulltext/redist/dict_german/german_stem.h +16 -0
  34. data/data/fulltext/redist/dict_german/subinclude.h +1 -0
  35. data/data/fulltext/redist/french_stem.c +1222 -0
  36. data/data/fulltext/redist/french_stem.h +16 -0
  37. data/data/fulltext/redist/german_stem.c +527 -0
  38. data/data/fulltext/redist/german_stem.h +16 -0
  39. data/jobs/export_chde_xls +20 -0
  40. data/jobs/export_csv +20 -0
  41. data/jobs/export_fachinfo_yaml +20 -0
  42. data/jobs/export_patinfo_yaml +20 -0
  43. data/jobs/export_yaml +20 -0
  44. data/jobs/import_dimdi +15 -0
  45. data/jobs/import_gkv +19 -0
  46. data/jobs/import_pharma24 +15 -0
  47. data/jobs/import_pharmnet +30 -0
  48. data/jobs/import_whocc +18 -0
  49. data/lib/fixes/singular.rb +9 -0
  50. data/lib/fixes/yaml.rb +13 -0
  51. data/lib/oddb.rb +13 -0
  52. data/lib/oddb/business/company.rb +18 -0
  53. data/lib/oddb/business/grant_download.rb +27 -0
  54. data/lib/oddb/business/invoice.rb +75 -0
  55. data/lib/oddb/config.rb +112 -0
  56. data/lib/oddb/currency.rb +6 -0
  57. data/lib/oddb/drugs.rb +16 -0
  58. data/lib/oddb/drugs/active_agent.rb +37 -0
  59. data/lib/oddb/drugs/atc.rb +53 -0
  60. data/lib/oddb/drugs/composition.rb +41 -0
  61. data/lib/oddb/drugs/ddd.rb +24 -0
  62. data/lib/oddb/drugs/dose.rb +107 -0
  63. data/lib/oddb/drugs/galenic_form.rb +21 -0
  64. data/lib/oddb/drugs/galenic_group.rb +17 -0
  65. data/lib/oddb/drugs/package.rb +111 -0
  66. data/lib/oddb/drugs/part.rb +55 -0
  67. data/lib/oddb/drugs/product.rb +25 -0
  68. data/lib/oddb/drugs/sequence.rb +68 -0
  69. data/lib/oddb/drugs/substance.rb +31 -0
  70. data/lib/oddb/drugs/substance_group.rb +13 -0
  71. data/lib/oddb/drugs/unit.rb +12 -0
  72. data/lib/oddb/export.rb +4 -0
  73. data/lib/oddb/export/csv.rb +94 -0
  74. data/lib/oddb/export/l10n_sessions.rb +30 -0
  75. data/lib/oddb/export/rss.rb +44 -0
  76. data/lib/oddb/export/server.rb +137 -0
  77. data/lib/oddb/export/xls.rb +127 -0
  78. data/lib/oddb/export/yaml.rb +212 -0
  79. data/lib/oddb/html/state/download.rb +13 -0
  80. data/lib/oddb/html/state/drugs/admin/package.rb +190 -0
  81. data/lib/oddb/html/state/drugs/admin/product.rb +56 -0
  82. data/lib/oddb/html/state/drugs/admin/sequence.rb +253 -0
  83. data/lib/oddb/html/state/drugs/ajax/explain_ddd_price.rb +19 -0
  84. data/lib/oddb/html/state/drugs/ajax/explain_price.rb +19 -0
  85. data/lib/oddb/html/state/drugs/ajax/global.rb +18 -0
  86. data/lib/oddb/html/state/drugs/ajax/package_infos.rb +19 -0
  87. data/lib/oddb/html/state/drugs/ajax/remote_infos.rb +19 -0
  88. data/lib/oddb/html/state/drugs/atc_browser.rb +39 -0
  89. data/lib/oddb/html/state/drugs/atc_guidelines.rb +21 -0
  90. data/lib/oddb/html/state/drugs/compare.rb +52 -0
  91. data/lib/oddb/html/state/drugs/download_export.rb +18 -0
  92. data/lib/oddb/html/state/drugs/downloads.rb +42 -0
  93. data/lib/oddb/html/state/drugs/fachinfo.rb +21 -0
  94. data/lib/oddb/html/state/drugs/feedback.rb +91 -0
  95. data/lib/oddb/html/state/drugs/global.rb +270 -0
  96. data/lib/oddb/html/state/drugs/init.rb +18 -0
  97. data/lib/oddb/html/state/drugs/login.rb +17 -0
  98. data/lib/oddb/html/state/drugs/package.rb +32 -0
  99. data/lib/oddb/html/state/drugs/patinfo.rb +21 -0
  100. data/lib/oddb/html/state/drugs/products.rb +51 -0
  101. data/lib/oddb/html/state/drugs/result.rb +125 -0
  102. data/lib/oddb/html/state/global.rb +206 -0
  103. data/lib/oddb/html/state/global_predefine.rb +17 -0
  104. data/lib/oddb/html/state/limit.rb +17 -0
  105. data/lib/oddb/html/state/login.rb +56 -0
  106. data/lib/oddb/html/state/paypal/checkout.rb +97 -0
  107. data/lib/oddb/html/state/paypal/collect.rb +19 -0
  108. data/lib/oddb/html/state/paypal/download.rb +61 -0
  109. data/lib/oddb/html/state/paypal/redirect.rb +18 -0
  110. data/lib/oddb/html/state/register_download.rb +24 -0
  111. data/lib/oddb/html/state/register_export.rb +38 -0
  112. data/lib/oddb/html/state/register_poweruser.rb +17 -0
  113. data/lib/oddb/html/state/viral/admin.rb +79 -0
  114. data/lib/oddb/html/state/viral/poweruser.rb +16 -0
  115. data/lib/oddb/html/util/annotated_list.rb +39 -0
  116. data/lib/oddb/html/util/know_it_all.rb +28 -0
  117. data/lib/oddb/html/util/known_user.rb +55 -0
  118. data/lib/oddb/html/util/lookandfeel.rb +698 -0
  119. data/lib/oddb/html/util/need_all_input.rb +29 -0
  120. data/lib/oddb/html/util/session.rb +84 -0
  121. data/lib/oddb/html/util/sort.rb +72 -0
  122. data/lib/oddb/html/util/unsaved_helper.rb +20 -0
  123. data/lib/oddb/html/util/validator.rb +59 -0
  124. data/lib/oddb/html/view/ajax/json.rb +22 -0
  125. data/lib/oddb/html/view/alpha_header.rb +28 -0
  126. data/lib/oddb/html/view/document.rb +117 -0
  127. data/lib/oddb/html/view/download.rb +33 -0
  128. data/lib/oddb/html/view/drugs/admin/package.rb +245 -0
  129. data/lib/oddb/html/view/drugs/admin/product.rb +104 -0
  130. data/lib/oddb/html/view/drugs/admin/sequence.rb +305 -0
  131. data/lib/oddb/html/view/drugs/ajax/explain_ddd_price.rb +87 -0
  132. data/lib/oddb/html/view/drugs/ajax/explain_price.rb +61 -0
  133. data/lib/oddb/html/view/drugs/ajax/package_infos.rb +105 -0
  134. data/lib/oddb/html/view/drugs/ajax/remote_infos.rb +44 -0
  135. data/lib/oddb/html/view/drugs/atc_browser.rb +68 -0
  136. data/lib/oddb/html/view/drugs/atc_guidelines.rb +94 -0
  137. data/lib/oddb/html/view/drugs/compare.rb +95 -0
  138. data/lib/oddb/html/view/drugs/download_export.rb +28 -0
  139. data/lib/oddb/html/view/drugs/downloads.rb +128 -0
  140. data/lib/oddb/html/view/drugs/fachinfo.rb +46 -0
  141. data/lib/oddb/html/view/drugs/feedback.rb +235 -0
  142. data/lib/oddb/html/view/drugs/init.rb +51 -0
  143. data/lib/oddb/html/view/drugs/legend.rb +24 -0
  144. data/lib/oddb/html/view/drugs/package.rb +403 -0
  145. data/lib/oddb/html/view/drugs/patinfo.rb +46 -0
  146. data/lib/oddb/html/view/drugs/products.rb +97 -0
  147. data/lib/oddb/html/view/drugs/result.rb +296 -0
  148. data/lib/oddb/html/view/drugs/search.rb +33 -0
  149. data/lib/oddb/html/view/drugs/template.rb +15 -0
  150. data/lib/oddb/html/view/foot.rb +52 -0
  151. data/lib/oddb/html/view/google.rb +23 -0
  152. data/lib/oddb/html/view/google_ads.rb +40 -0
  153. data/lib/oddb/html/view/head.rb +78 -0
  154. data/lib/oddb/html/view/limit.rb +109 -0
  155. data/lib/oddb/html/view/list.rb +59 -0
  156. data/lib/oddb/html/view/login.rb +38 -0
  157. data/lib/oddb/html/view/navigation.rb +67 -0
  158. data/lib/oddb/html/view/offset_header.rb +35 -0
  159. data/lib/oddb/html/view/paypal/collect.rb +95 -0
  160. data/lib/oddb/html/view/paypal/redirect.rb +51 -0
  161. data/lib/oddb/html/view/paypal/register_form.rb +149 -0
  162. data/lib/oddb/html/view/register_download.rb +29 -0
  163. data/lib/oddb/html/view/register_export.rb +29 -0
  164. data/lib/oddb/html/view/register_poweruser.rb +29 -0
  165. data/lib/oddb/html/view/rss/feedback.rb +64 -0
  166. data/lib/oddb/html/view/rss_preview.rb +61 -0
  167. data/lib/oddb/html/view/search.rb +104 -0
  168. data/lib/oddb/html/view/snapback.rb +24 -0
  169. data/lib/oddb/html/view/template.rb +56 -0
  170. data/lib/oddb/import/dimdi.rb +583 -0
  171. data/lib/oddb/import/excel.rb +45 -0
  172. data/lib/oddb/import/gkv.rb +463 -0
  173. data/lib/oddb/import/importer.rb +36 -0
  174. data/lib/oddb/import/pharma24.rb +211 -0
  175. data/lib/oddb/import/pharmnet.rb +1186 -0
  176. data/lib/oddb/import/rtf.rb +409 -0
  177. data/lib/oddb/import/whocc.rb +148 -0
  178. data/lib/oddb/import/xml.rb +15 -0
  179. data/lib/oddb/model.rb +179 -0
  180. data/lib/oddb/persistence.rb +22 -0
  181. data/lib/oddb/persistence/odba.rb +32 -0
  182. data/lib/oddb/persistence/odba/business/company.rb +13 -0
  183. data/lib/oddb/persistence/odba/business/grant_download.rb +14 -0
  184. data/lib/oddb/persistence/odba/business/invoice.rb +15 -0
  185. data/lib/oddb/persistence/odba/drugs/atc.rb +15 -0
  186. data/lib/oddb/persistence/odba/drugs/galenic_form.rb +18 -0
  187. data/lib/oddb/persistence/odba/drugs/galenic_group.rb +13 -0
  188. data/lib/oddb/persistence/odba/drugs/package.rb +25 -0
  189. data/lib/oddb/persistence/odba/drugs/product.rb +13 -0
  190. data/lib/oddb/persistence/odba/drugs/sequence.rb +21 -0
  191. data/lib/oddb/persistence/odba/drugs/substance.rb +21 -0
  192. data/lib/oddb/persistence/odba/drugs/substance_group.rb +13 -0
  193. data/lib/oddb/persistence/odba/drugs/unit.rb +13 -0
  194. data/lib/oddb/persistence/odba/export.rb +26 -0
  195. data/lib/oddb/persistence/odba/model.rb +68 -0
  196. data/lib/oddb/persistence/odba/text/document.rb +11 -0
  197. data/lib/oddb/persistence/odba/util/code.rb +11 -0
  198. data/lib/oddb/persistence/odba/util/m10l_document.rb +13 -0
  199. data/lib/oddb/persistence/og.rb +16 -0
  200. data/lib/oddb/persistence/og/drugs/composition.rb +14 -0
  201. data/lib/oddb/persistence/og/drugs/product.rb +14 -0
  202. data/lib/oddb/persistence/og/drugs/sequence.rb +15 -0
  203. data/lib/oddb/persistence/og/model.rb +25 -0
  204. data/lib/oddb/persistence/og/util/multilingual.rb +13 -0
  205. data/lib/oddb/redist/rtf_tools/reader.rb +139 -0
  206. data/lib/oddb/remote/business/company.rb +17 -0
  207. data/lib/oddb/remote/drugs/active_agent.rb +27 -0
  208. data/lib/oddb/remote/drugs/atc.rb +31 -0
  209. data/lib/oddb/remote/drugs/dose.rb +8 -0
  210. data/lib/oddb/remote/drugs/galenic_form.rb +24 -0
  211. data/lib/oddb/remote/drugs/package.rb +128 -0
  212. data/lib/oddb/remote/drugs/part.rb +30 -0
  213. data/lib/oddb/remote/drugs/substance.rb +20 -0
  214. data/lib/oddb/remote/drugs/unit.rb +20 -0
  215. data/lib/oddb/remote/object.rb +36 -0
  216. data/lib/oddb/text/chapter.rb +23 -0
  217. data/lib/oddb/text/document.rb +42 -0
  218. data/lib/oddb/text/format.rb +37 -0
  219. data/lib/oddb/text/paragraph.rb +53 -0
  220. data/lib/oddb/text/picture.rb +89 -0
  221. data/lib/oddb/text/table.rb +68 -0
  222. data/lib/oddb/util.rb +9 -0
  223. data/lib/oddb/util/annotated_list.rb +37 -0
  224. data/lib/oddb/util/code.rb +69 -0
  225. data/lib/oddb/util/comparison.rb +36 -0
  226. data/lib/oddb/util/download.rb +17 -0
  227. data/lib/oddb/util/exporter.rb +8 -0
  228. data/lib/oddb/util/feedback.rb +23 -0
  229. data/lib/oddb/util/ipn.rb +53 -0
  230. data/lib/oddb/util/job.rb +23 -0
  231. data/lib/oddb/util/logger.rb +20 -0
  232. data/lib/oddb/util/m10l_document.rb +41 -0
  233. data/lib/oddb/util/mail.rb +87 -0
  234. data/lib/oddb/util/money.rb +64 -0
  235. data/lib/oddb/util/multilingual.rb +70 -0
  236. data/lib/oddb/util/quanty.rb +3 -0
  237. data/lib/oddb/util/quanty/fact.rb +242 -0
  238. data/lib/oddb/util/quanty/main.rb +164 -0
  239. data/lib/oddb/util/quanty/parse.rb +872 -0
  240. data/lib/oddb/util/quanty/units.dump +0 -0
  241. data/lib/oddb/util/server.rb +150 -0
  242. data/lib/oddb/util/smtp_tls.rb +58 -0
  243. data/lib/oddb/util/updater.rb +161 -0
  244. data/lib/oddb/util/ydim.rb +110 -0
  245. data/lib/oddb/util/yus.rb +46 -0
  246. data/test/business/test_company.rb +29 -0
  247. data/test/business/test_grant_download.rb +29 -0
  248. data/test/drugs/test_active_agent.rb +53 -0
  249. data/test/drugs/test_atc.rb +54 -0
  250. data/test/drugs/test_composition.rb +88 -0
  251. data/test/drugs/test_ddd.rb +22 -0
  252. data/test/drugs/test_dose.rb +189 -0
  253. data/test/drugs/test_galenic_form.rb +41 -0
  254. data/test/drugs/test_package.rb +172 -0
  255. data/test/drugs/test_part.rb +32 -0
  256. data/test/drugs/test_product.rb +31 -0
  257. data/test/drugs/test_sequence.rb +140 -0
  258. data/test/drugs/test_substance.rb +51 -0
  259. data/test/drugs/test_substance_group.rb +27 -0
  260. data/test/export/test_rss.rb +86 -0
  261. data/test/export/test_server.rb +163 -0
  262. data/test/export/test_xls.rb +146 -0
  263. data/test/export/test_yaml.rb +120 -0
  264. data/test/import/data/csv/products.csv +11 -0
  265. data/test/import/data/html/dimdi_index.html +400 -0
  266. data/test/import/data/html/gkv/Befreiungsliste_Arzneimittel_Versicherte.gkvnet +508 -0
  267. data/test/import/data/html/pharma24/1337397.html +754 -0
  268. data/test/import/data/html/pharma24/842756.html +570 -0
  269. data/test/import/data/html/pharma24/ac-page-10.html +2999 -0
  270. data/test/import/data/html/pharma24/ac-page-11.html +2999 -0
  271. data/test/import/data/html/pharma24/ac-page-12.html +2999 -0
  272. data/test/import/data/html/pharma24/ac-page-13.html +2999 -0
  273. data/test/import/data/html/pharma24/ac-page-14.html +2999 -0
  274. data/test/import/data/html/pharma24/ac-page-15.html +3011 -0
  275. data/test/import/data/html/pharma24/ac-page-16.html +3050 -0
  276. data/test/import/data/html/pharma24/ac-page-17.html +3285 -0
  277. data/test/import/data/html/pharma24/ac-page-18.html +3109 -0
  278. data/test/import/data/html/pharma24/ac-page-19.html +3126 -0
  279. data/test/import/data/html/pharma24/ac-page-2.html +3005 -0
  280. data/test/import/data/html/pharma24/ac-page-20.html +3007 -0
  281. data/test/import/data/html/pharma24/ac-page-21.html +2999 -0
  282. data/test/import/data/html/pharma24/ac-page-22.html +2999 -0
  283. data/test/import/data/html/pharma24/ac-page-23.html +3055 -0
  284. data/test/import/data/html/pharma24/ac-page-24.html +2999 -0
  285. data/test/import/data/html/pharma24/ac-page-25.html +3004 -0
  286. data/test/import/data/html/pharma24/ac-page-26.html +2999 -0
  287. data/test/import/data/html/pharma24/ac-page-27.html +3167 -0
  288. data/test/import/data/html/pharma24/ac-page-28.html +3236 -0
  289. data/test/import/data/html/pharma24/ac-page-29.html +3110 -0
  290. data/test/import/data/html/pharma24/ac-page-3.html +2999 -0
  291. data/test/import/data/html/pharma24/ac-page-30.html +2999 -0
  292. data/test/import/data/html/pharma24/ac-page-31.html +2999 -0
  293. data/test/import/data/html/pharma24/ac-page-32.html +2999 -0
  294. data/test/import/data/html/pharma24/ac-page-33.html +3001 -0
  295. data/test/import/data/html/pharma24/ac-page-34.html +2999 -0
  296. data/test/import/data/html/pharma24/ac-page-35.html +2999 -0
  297. data/test/import/data/html/pharma24/ac-page-36.html +2999 -0
  298. data/test/import/data/html/pharma24/ac-page-37.html +2999 -0
  299. data/test/import/data/html/pharma24/ac-page-38.html +3003 -0
  300. data/test/import/data/html/pharma24/ac-page-39.html +2999 -0
  301. data/test/import/data/html/pharma24/ac-page-4.html +2999 -0
  302. data/test/import/data/html/pharma24/ac-page-40.html +2999 -0
  303. data/test/import/data/html/pharma24/ac-page-41.html +2999 -0
  304. data/test/import/data/html/pharma24/ac-page-42.html +2999 -0
  305. data/test/import/data/html/pharma24/ac-page-43.html +2999 -0
  306. data/test/import/data/html/pharma24/ac-page-44.html +2999 -0
  307. data/test/import/data/html/pharma24/ac-page-45.html +2999 -0
  308. data/test/import/data/html/pharma24/ac-page-46.html +2999 -0
  309. data/test/import/data/html/pharma24/ac-page-47.html +2999 -0
  310. data/test/import/data/html/pharma24/ac-page-48.html +2999 -0
  311. data/test/import/data/html/pharma24/ac-page-49.html +2999 -0
  312. data/test/import/data/html/pharma24/ac-page-5.html +3168 -0
  313. data/test/import/data/html/pharma24/ac-page-50.html +2999 -0
  314. data/test/import/data/html/pharma24/ac-page-51.html +2999 -0
  315. data/test/import/data/html/pharma24/ac-page-52.html +3003 -0
  316. data/test/import/data/html/pharma24/ac-page-53.html +2999 -0
  317. data/test/import/data/html/pharma24/ac-page-54.html +3095 -0
  318. data/test/import/data/html/pharma24/ac-page-55.html +3041 -0
  319. data/test/import/data/html/pharma24/ac-page-56.html +2999 -0
  320. data/test/import/data/html/pharma24/ac-page-57.html +3001 -0
  321. data/test/import/data/html/pharma24/ac-page-58.html +3001 -0
  322. data/test/import/data/html/pharma24/ac-page-59.html +2999 -0
  323. data/test/import/data/html/pharma24/ac-page-6.html +3072 -0
  324. data/test/import/data/html/pharma24/ac-page-60.html +3001 -0
  325. data/test/import/data/html/pharma24/ac-page-61.html +3005 -0
  326. data/test/import/data/html/pharma24/ac-page-62.html +2999 -0
  327. data/test/import/data/html/pharma24/ac-page-63.html +3007 -0
  328. data/test/import/data/html/pharma24/ac-page-64.html +3007 -0
  329. data/test/import/data/html/pharma24/ac-page-65.html +2999 -0
  330. data/test/import/data/html/pharma24/ac-page-66.html +3011 -0
  331. data/test/import/data/html/pharma24/ac-page-67.html +3026 -0
  332. data/test/import/data/html/pharma24/ac-page-68.html +2999 -0
  333. data/test/import/data/html/pharma24/ac-page-69.html +3010 -0
  334. data/test/import/data/html/pharma24/ac-page-7.html +2999 -0
  335. data/test/import/data/html/pharma24/ac-page-70.html +3192 -0
  336. data/test/import/data/html/pharma24/ac-page-71.html +3133 -0
  337. data/test/import/data/html/pharma24/ac-page-72.html +2999 -0
  338. data/test/import/data/html/pharma24/ac-page-73.html +3227 -0
  339. data/test/import/data/html/pharma24/ac-page-74.html +3241 -0
  340. data/test/import/data/html/pharma24/ac-page-75.html +3227 -0
  341. data/test/import/data/html/pharma24/ac-page-76.html +3244 -0
  342. data/test/import/data/html/pharma24/ac-page-77.html +1164 -0
  343. data/test/import/data/html/pharma24/ac-page-8.html +2999 -0
  344. data/test/import/data/html/pharma24/ac-page-9.html +2999 -0
  345. data/test/import/data/html/pharma24/ac.html +2999 -0
  346. data/test/import/data/html/pharmnet/display.html +662 -0
  347. data/test/import/data/html/pharmnet/display1.html +625 -0
  348. data/test/import/data/html/pharmnet/display2.html +625 -0
  349. data/test/import/data/html/pharmnet/display3.html +625 -0
  350. data/test/import/data/html/pharmnet/display_tramal.html +634 -0
  351. data/test/import/data/html/pharmnet/empty_result.html +395 -0
  352. data/test/import/data/html/pharmnet/gate.html +246 -0
  353. data/test/import/data/html/pharmnet/index.html +258 -0
  354. data/test/import/data/html/pharmnet/paged_result_1.html +401 -0
  355. data/test/import/data/html/pharmnet/paged_result_2.html +401 -0
  356. data/test/import/data/html/pharmnet/result.html +401 -0
  357. data/test/import/data/html/pharmnet/search.html +865 -0
  358. data/test/import/data/html/pharmnet/search_filtered.html +182 -0
  359. data/test/import/data/html/whocc/A.html +56 -0
  360. data/test/import/data/html/whocc/A03.html +48 -0
  361. data/test/import/data/html/whocc/A03AB.html +48 -0
  362. data/test/import/data/html/whocc/A06AA.html +47 -0
  363. data/test/import/data/html/whocc/C03.html +47 -0
  364. data/test/import/data/html/whocc/login.html +77 -0
  365. data/test/import/data/mail/csv.mail +81 -0
  366. data/test/import/data/rtf/pharmnet/aarane.pi.rtf +648 -0
  367. data/test/import/data/rtf/pharmnet/ace_hemmer_ratio.pi.rtf +324 -0
  368. data/test/import/data/rtf/pharmnet/ace_hemmer_ratio.rtf +4816 -0
  369. data/test/import/data/rtf/pharmnet/acemetacin.pi.rtf +388 -0
  370. data/test/import/data/rtf/pharmnet/acemit.pi.rtf +240 -0
  371. data/test/import/data/rtf/pharmnet/acerbon.pi.rtf +1257 -0
  372. data/test/import/data/rtf/pharmnet/acetylcystein.pi.rtf +323 -0
  373. data/test/import/data/rtf/pharmnet/aciclo.pi.rtf +287 -0
  374. data/test/import/data/rtf/pharmnet/aciclovir.pi.rtf +236 -0
  375. data/test/import/data/rtf/pharmnet/actrapid.pi.rtf +322 -0
  376. data/test/import/data/rtf/pharmnet/amlodipin.pi.rtf +452 -0
  377. data/test/import/data/rtf/pharmnet/amlodipin.rtf +473 -0
  378. data/test/import/data/rtf/pharmnet/aspirin.pi.rtf +313 -0
  379. data/test/import/data/rtf/pharmnet/aspirin.rtf +781 -0
  380. data/test/import/data/rtf/pharmnet/baymycard.pi.rtf +447 -0
  381. data/test/import/data/rtf/pharmnet/omeprazol.pi.rtf +510 -0
  382. data/test/import/data/rtf/pharmnet/omeprazol.rtf +9216 -0
  383. data/test/import/data/rtf/pharmnet/paroxetin.pi.rtf +678 -0
  384. data/test/import/data/rtf/pharmnet/selegilin.pi.rtf +312 -0
  385. data/test/import/data/rtf/pharmnet/selegilin.rtf +683 -0
  386. data/test/import/data/rtf/pharmnet/valium.pi.rtf +387 -0
  387. data/test/import/data/txt/gkv/gkv_p1.txt +17 -0
  388. data/test/import/data/xls/darform_010706.xls +0 -0
  389. data/test/import/data/xls/fb010706.xls +0 -0
  390. data/test/import/data/xls/liste_zuzahlungsbefreite_arzneimittel_suchfunktion.xls +0 -0
  391. data/test/import/data/xls/wirkkurz_010406.xls +0 -0
  392. data/test/import/data/xml/ATC_2006.xml +47 -0
  393. data/test/import/data/xml/ATC_2006_ddd.xml +35 -0
  394. data/test/import/test_dimdi.rb +323 -0
  395. data/test/import/test_excel.rb +31 -0
  396. data/test/import/test_gkv.rb +260 -0
  397. data/test/import/test_pharma24.rb +112 -0
  398. data/test/import/test_pharmnet.rb +980 -0
  399. data/test/import/test_rtf.rb +37 -0
  400. data/test/import/test_whocc.rb +314 -0
  401. data/test/remote/drugs/test_active_agent.rb +36 -0
  402. data/test/selenium/selenium-server.jar +0 -0
  403. data/test/selenium/test_atc_browser.rb +121 -0
  404. data/test/selenium/test_atc_guidelines.rb +95 -0
  405. data/test/selenium/test_collect.rb +137 -0
  406. data/test/selenium/test_compare.rb +294 -0
  407. data/test/selenium/test_fachinfo.rb +128 -0
  408. data/test/selenium/test_feedback.rb +192 -0
  409. data/test/selenium/test_init.rb +64 -0
  410. data/test/selenium/test_limit.rb +304 -0
  411. data/test/selenium/test_login.rb +67 -0
  412. data/test/selenium/test_package.rb +516 -0
  413. data/test/selenium/test_patinfo.rb +128 -0
  414. data/test/selenium/test_product.rb +80 -0
  415. data/test/selenium/test_products.rb +141 -0
  416. data/test/selenium/test_search.rb +933 -0
  417. data/test/selenium/test_sequence.rb +513 -0
  418. data/test/selenium/unit.rb +190 -0
  419. data/test/stub/http_server.rb +144 -0
  420. data/test/stub/model.rb +173 -0
  421. data/test/suite.rb +15 -0
  422. data/test/test_model.rb +83 -0
  423. data/test/util/test_code.rb +74 -0
  424. data/test/util/test_ipn.rb +117 -0
  425. data/test/util/test_mail.rb +85 -0
  426. data/test/util/test_multilingual.rb +97 -0
  427. data/test/util/test_server.rb +94 -0
  428. data/test/util/test_updater.rb +130 -0
  429. data/test/util/test_ydim.rb +115 -0
  430. data/test/util/test_yus.rb +79 -0
  431. metadata +568 -0
@@ -0,0 +1,128 @@
1
+ #!/usr/bin/env ruby
2
+ # Selenium::TestPatinfo -- de.oddb.org -- 18.04.2008 -- hwyss@ywesee.com
3
+
4
+
5
+ $: << File.expand_path('..', File.dirname(__FILE__))
6
+
7
+ require 'selenium/unit'
8
+ require 'stub/model'
9
+ require 'oddb/drugs'
10
+ require 'oddb/util'
11
+
12
+ module ODDB
13
+ module Selenium
14
+ class TestPatinfo < Test::Unit::TestCase
15
+ include Selenium::TestCase
16
+ def setup
17
+ Drugs::Package.instances.clear
18
+ super
19
+ end
20
+ def setup_package(pzn='12345')
21
+ product = Drugs::Product.new
22
+ company = Business::Company.new
23
+ company.name.de = 'Producer AG'
24
+ product.company = company
25
+ product.name.de = "Amantadin by Producer"
26
+ company.save
27
+ sequence = Drugs::Sequence.new
28
+ sequence.atc = Drugs::Atc.new('N04BB01')
29
+ sequence.atc.name.de = 'Amantadin'
30
+ ddd = Drugs::Ddd.new('O')
31
+ ddd.dose = Drugs::Dose.new(5, 'mg')
32
+ sequence.atc.add_ddd(ddd)
33
+ sequence.product = product
34
+ composition = Drugs::Composition.new
35
+ composition.equivalence_factor = '44.6'
36
+ sequence.add_composition(composition)
37
+ substance = Drugs::Substance.new
38
+ substance.name.de = "Amantadin"
39
+ dose = Drugs::Dose.new(100, 'mg')
40
+ active_agent = Drugs::ActiveAgent.new(substance, dose)
41
+ composition.add_active_agent(active_agent)
42
+ package = Drugs::Package.new
43
+ code = Util::Code.new(:festbetragsstufe, 3, 'DE')
44
+ package.add_code(code)
45
+ code = Util::Code.new(:zuzahlungsbefreit, true, 'DE')
46
+ package.add_code(code)
47
+ code = Util::Code.new(:prescription, true, 'DE')
48
+ package.add_code(code)
49
+ code = Util::Code.new(:cid, pzn, 'DE')
50
+ package.add_code(code)
51
+ part = Drugs::Part.new
52
+ part.composition = composition
53
+ part.package = package
54
+ part.size = 5
55
+ unit = Drugs::Unit.new
56
+ unit.name.de = 'Ampullen'
57
+ part.unit = unit
58
+ part.quantity = Drugs::Dose.new(20, 'ml')
59
+ package.name.de = 'Amantadin by Producer'
60
+ package.sequence = sequence
61
+ package.add_price(Util::Money.new(6, :public, 'DE'))
62
+ package.add_price(Util::Money.new(10, :festbetrag, 'DE'))
63
+ package.save
64
+ package
65
+ end
66
+ def setup_patinfo
67
+ document = Text::Document.new
68
+ chapter = Text::Chapter.new('name')
69
+ paragraph = Text::Paragraph.new
70
+ paragraph.set_format("b")
71
+ paragraph << "1. Bezeichnung"
72
+ chapter.add_paragraph paragraph
73
+ paragraph = Text::Paragraph.new
74
+ paragraph << "Amantadin Product"
75
+ chapter.add_paragraph paragraph
76
+ document.add_chapter(chapter)
77
+ chapter = Text::Chapter.new('composition')
78
+ paragraph = Text::Paragraph.new
79
+ paragraph.set_format("b")
80
+ paragraph << "2. Zusammensetzung"
81
+ chapter.add_paragraph paragraph
82
+ table = Text::Table.new
83
+ table << "Für Kinder"
84
+ table.next_cell!
85
+ table << "Für Erwachsene"
86
+ table.next_row!
87
+ table << "10 mg Amantadin pro Tablette"
88
+ table.next_cell!
89
+ table << "100 mg Amantadin pro Tablette"
90
+ chapter.add_paragraph table
91
+ document.add_chapter(chapter)
92
+ chapter = Text::Chapter.new('packaging')
93
+ paragraph = Text::Paragraph.new
94
+ paragraph.set_format("b")
95
+ paragraph << "6.1"
96
+ paragraph.set_format()
97
+ paragraph << " Behältnis"
98
+ chapter.add_paragraph paragraph
99
+ picture = Text::Picture.new
100
+ flexmock(picture).should_receive(:path).and_return('/resources/oddb/logo.png')
101
+ flexmock(picture).should_receive(:filename).and_return('logo.png')
102
+ chapter.add_paragraph picture
103
+ document.add_chapter(chapter)
104
+ document
105
+ end
106
+ def test_patinfo
107
+ package = setup_package
108
+ package.patinfo.de = setup_patinfo
109
+ open "/de/drugs/patinfo/uid/#{package.sequence.uid}"
110
+ assert_equal "DE - ODDB.org | Medikamente | Gebrauchsinformation | Amantadin by Producer | Open Drug Database", get_title
111
+ assert is_text_present("1. Bezeichnung\nAmantadin Product")
112
+ end
113
+ def test_patinfo__limited
114
+ ODDB.config.query_limit = 1
115
+ package = setup_package
116
+ package.patinfo.de = setup_patinfo
117
+ open "/de/drugs/patinfo/uid/#{package.sequence.uid}"
118
+ assert_equal "DE - ODDB.org | Medikamente | Gebrauchsinformation | Amantadin by Producer | Open Drug Database", get_title
119
+ open "/de/drugs/patinfo/uid/#{package.sequence.uid}"
120
+ assert_equal 'DE - ODDB.org | Medikamente | Open Drug Database',
121
+ get_title
122
+ assert is_text_present("Abfragebeschränkung")
123
+ ensure
124
+ ODDB.config.query_limit = 20
125
+ end
126
+ end
127
+ end
128
+ end
@@ -0,0 +1,80 @@
1
+ #!/usr/bin/env ruby
2
+ # Selenium::TestProduct -- de.oddb.org -- 18.04.2008 -- hwyss@ywesee.com
3
+
4
+ $: << File.expand_path('..', File.dirname(__FILE__))
5
+
6
+ require 'selenium/unit'
7
+ require 'stub/model'
8
+ require 'oddb/drugs'
9
+ require 'oddb/util'
10
+
11
+ module ODDB
12
+ module Selenium
13
+ class TestAdminProduct < Test::Unit::TestCase
14
+ include Selenium::TestCase
15
+ def setup
16
+ Drugs::ActiveAgent.instances.clear
17
+ Drugs::Composition.instances.clear
18
+ Drugs::Sequence.instances.clear
19
+ Drugs::Product.instances.clear
20
+ Business::Company.instances.clear
21
+ super
22
+ end
23
+ def setup_product
24
+ product = Drugs::Product.new
25
+ product.name.de = "Product"
26
+ company = Business::Company.new
27
+ company.name.de = 'Producer AG'
28
+ product.company = company
29
+ company.save
30
+ product.save
31
+ product
32
+ end
33
+ def test_product
34
+ product = setup_product
35
+ user = login_admin
36
+ uid = product.uid
37
+ open "/de/drugs/product/uid/#{uid}"
38
+ assert_equal "DE - ODDB.org | Medikamente | Produkt | #{uid} | Open Drug Database", get_title
39
+ assert is_element_present("company")
40
+ assert is_text_present("Product")
41
+ assert_equal 'Producer AG', get_value('company')
42
+ end
43
+ def test_product__update__success
44
+ product = setup_product
45
+ user = login_admin
46
+ company = Business::Company.new
47
+ company.name.de = 'New Company'
48
+ company.save
49
+ uid = product.uid
50
+ open "/de/drugs/product/uid/#{uid}"
51
+ assert_equal "DE - ODDB.org | Medikamente | Produkt | #{uid} | Open Drug Database", get_title
52
+ type 'company', 'New Company'
53
+ click 'update'
54
+ wait_for_page_to_load "30000"
55
+
56
+ assert_equal "DE - ODDB.org | Medikamente | Produkt | #{uid} | Open Drug Database", get_title
57
+ assert_equal 'New Company', get_value('company')
58
+
59
+ assert_equal company, product.company
60
+ end
61
+ def test_product__update__error
62
+ product = setup_product
63
+ previous = product.company
64
+ user = login_admin
65
+ uid = product.uid
66
+ open "/de/drugs/product/uid/#{uid}"
67
+ assert_equal "DE - ODDB.org | Medikamente | Produkt | #{uid} | Open Drug Database", get_title
68
+ type 'company', 'New Company'
69
+ click 'update'
70
+ wait_for_page_to_load "30000"
71
+
72
+ assert is_text_present('Der Zulassungsinhaber "New Company" ist nicht bekannt.')
73
+ assert_equal "DE - ODDB.org | Medikamente | Produkt | #{uid} | Open Drug Database", get_title
74
+ assert_equal 'Producer AG', get_value('company')
75
+
76
+ assert_equal previous, product.company
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,141 @@
1
+ #!/usr/bin/env ruby
2
+ # Selenium::TestInit -- de.oddb.org -- 21.11.2006 -- hwyss@ywesee.com
3
+
4
+
5
+ $: << File.expand_path('..', File.dirname(__FILE__))
6
+
7
+ require 'selenium/unit'
8
+ require 'stub/model'
9
+ require 'oddb/drugs'
10
+ require 'oddb/util'
11
+
12
+ module ODDB
13
+ module Selenium
14
+ class TestProducts < Test::Unit::TestCase
15
+ include Selenium::TestCase
16
+ def setup
17
+ Drugs::Product.instances.clear
18
+ super
19
+ end
20
+ def setup_product(name)
21
+ product = Drugs::Product.new
22
+ sequence = Drugs::Sequence.new
23
+ sequence.product = product
24
+ sequence.atc = Drugs::Atc.new('N04BB01')
25
+ company = Business::Company.new
26
+ company.name.de = 'Producer AG'
27
+ product.company = company
28
+ company.save
29
+ product.name.de = name
30
+ product.save
31
+ end
32
+ def test_products
33
+ ODDB.config.query_limit = 20
34
+ setup_product("Amantadin by Producer")
35
+ setup_product("Amantadin by someone Else")
36
+ setup_product("4N Pflaster")
37
+ @selenium.open "/"
38
+ assert_equal "DE - ODDB.org | Medikamente | Home | Open Drug Database", @selenium.get_title
39
+ @selenium.click "link=Arzneimittel A-Z"
40
+ @selenium.wait_for_page_to_load "30000"
41
+ assert_equal "DE - ODDB.org | Medikamente | Arzneimittel A-Z | Open Drug Database",
42
+ @selenium.get_title
43
+ assert @selenium.is_text_present("Bitte wählen Sie den anzuzeigenden Bereich")
44
+ assert @selenium.is_element_present("link=A")
45
+ assert @selenium.is_element_present("link=0-9")
46
+
47
+ @selenium.click "link=A"
48
+ @selenium.wait_for_page_to_load "30000"
49
+ assert_equal "DE - ODDB.org | Medikamente | Arzneimittel A-Z | Open Drug Database",
50
+ @selenium.get_title
51
+ assert @selenium.is_text_present('Amantadin by Producer')
52
+ assert @selenium.is_text_present('Amantadin by someone Else')
53
+ assert !@selenium.is_text_present('4N Pflaster')
54
+ assert @selenium.is_text_present('Producer AG')
55
+ assert @selenium.is_text_present('N04BB01')
56
+
57
+ flexstub(@server['test:preset-session-id']).should_receive(:pagelength).and_return(1)
58
+
59
+ @selenium.refresh
60
+ @selenium.wait_for_page_to_load "30000"
61
+ assert_equal "DE - ODDB.org | Medikamente | Arzneimittel A-Z | Open Drug Database",
62
+ @selenium.get_title
63
+ assert @selenium.is_text_present('Amantadin by Producer')
64
+ assert !@selenium.is_text_present('Amantadin by someone Else')
65
+ assert !@selenium.is_text_present('4N Pflaster')
66
+ assert @selenium.is_text_present('1 - 1')
67
+ assert @selenium.is_text_present('2 - 2')
68
+ assert !@selenium.is_text_present('3 - 2')
69
+
70
+ @selenium.click "link=2 - 2"
71
+ @selenium.wait_for_page_to_load "30000"
72
+ assert_equal "DE - ODDB.org | Medikamente | Arzneimittel A-Z | Open Drug Database",
73
+ @selenium.get_title
74
+ assert !@selenium.is_text_present('Amantadin by Producer')
75
+ assert @selenium.is_text_present('Amantadin by someone Else')
76
+ assert !@selenium.is_text_present('4N Pflaster')
77
+ assert @selenium.is_text_present('1 - 1')
78
+ assert @selenium.is_text_present('2 - 2')
79
+ assert !@selenium.is_text_present('3 - 2')
80
+
81
+ @selenium.click "link=0-9"
82
+ @selenium.wait_for_page_to_load "30000"
83
+ assert_equal "DE - ODDB.org | Medikamente | Arzneimittel A-Z | Open Drug Database",
84
+ @selenium.get_title
85
+ assert !@selenium.is_text_present('Amantadin by Producer')
86
+ assert !@selenium.is_text_present('Amantadin by someone Else')
87
+ assert @selenium.is_text_present('4N Pflaster')
88
+
89
+ @selenium.click "link=4N Pflaster"
90
+ @selenium.wait_for_page_to_load "30000"
91
+ assert_equal "DE - ODDB.org | Medikamente | Suchen | 4N Pflaster | Markenname | Open Drug Database",
92
+ @selenium.get_title
93
+ end
94
+ def test_products__sort
95
+ setup_product("Amantadin by Producer")
96
+ setup_product("Amantadin by someone Else")
97
+ setup_product("4N Pflaster")
98
+ @selenium.open "/"
99
+ assert_equal "DE - ODDB.org | Medikamente | Home | Open Drug Database", @selenium.get_title
100
+ @selenium.click "link=Arzneimittel A-Z"
101
+ @selenium.wait_for_page_to_load "30000"
102
+ assert_equal "DE - ODDB.org | Medikamente | Arzneimittel A-Z | Open Drug Database",
103
+ @selenium.get_title
104
+ assert @selenium.is_text_present("Bitte wählen Sie den anzuzeigenden Bereich")
105
+ assert @selenium.is_element_present("link=A")
106
+ assert @selenium.is_element_present("link=0-9")
107
+
108
+ @selenium.click "link=A"
109
+ @selenium.wait_for_page_to_load "30000"
110
+ assert_equal "DE - ODDB.org | Medikamente | Arzneimittel A-Z | Open Drug Database",
111
+ @selenium.get_title
112
+ assert @selenium.is_text_present('Amantadin by Producer')
113
+ assert @selenium.is_text_present('Amantadin by someone Else')
114
+
115
+ @selenium.click "link=ATC-Code"
116
+ @selenium.wait_for_page_to_load "30000"
117
+ assert_equal "DE - ODDB.org | Medikamente | Arzneimittel A-Z | Open Drug Database",
118
+ @selenium.get_title
119
+ @selenium.click "link=Hersteller"
120
+ @selenium.wait_for_page_to_load "30000"
121
+ assert_equal "DE - ODDB.org | Medikamente | Arzneimittel A-Z | Open Drug Database",
122
+ @selenium.get_title
123
+ end
124
+ def test_products__limited
125
+ ODDB.config.query_limit = 1
126
+ setup_product("Amantadin by Producer")
127
+ setup_product("Amantadin by someone Else")
128
+ setup_product("4N Pflaster")
129
+ open "/de/drugs/products"
130
+ assert_equal "DE - ODDB.org | Medikamente | Arzneimittel A-Z | Open Drug Database",
131
+ @selenium.get_title
132
+ open "/de/drugs/products"
133
+ assert_equal 'DE - ODDB.org | Medikamente | Open Drug Database',
134
+ get_title
135
+ assert is_text_present("Abfragebeschränkung")
136
+ ensure
137
+ ODDB.config.query_limit = 20
138
+ end
139
+ end
140
+ end
141
+ end
@@ -0,0 +1,933 @@
1
+ #!/usr/bin/env ruby
2
+ # Selenium::TestSearch -- de.oddb.org -- 21.11.2006 -- hwyss@ywesee.com
3
+
4
+ $: << File.expand_path('..', File.dirname(__FILE__))
5
+
6
+ require 'selenium/unit'
7
+ require 'odba/drbwrapper'
8
+ require 'odba'
9
+ require 'oddb/drugs'
10
+ require 'oddb/util'
11
+ require 'stub/model'
12
+
13
+ module ODDB
14
+ module Selenium
15
+ class TestSearch < Test::Unit::TestCase
16
+ include Selenium::TestCase
17
+ def setup
18
+ Drugs::Package.instances.clear
19
+ Drugs::Product.instances.clear
20
+ Business::Company.instances.clear
21
+ @cache = flexstub(ODBA.cache)
22
+ flexstub(Currency).should_receive(:rate)\
23
+ .with('EUR', 'CHF').and_return(1.5)
24
+ currency = flexmock('Currency')
25
+ @currency = DRb.start_service('druby://localhost:0', currency)
26
+ ODDB.config.currency_rates = @currency.uri
27
+ currency.should_receive(:rate).with('EUR', 'CHF').and_return(1.6)
28
+ super
29
+ end
30
+ def setup_autosession(yus)
31
+ session = flexmock('session')
32
+ yus.should_receive(:autosession).and_return { |domain, block|
33
+ assert_equal 'org.oddb.de', domain
34
+ block.call session
35
+ }
36
+ session
37
+ end
38
+ def setup_package(name="Amantadin by Producer", atccode='N04BB01')
39
+ product = Drugs::Product.new
40
+ company = Business::Company.new
41
+ company.name.de = 'Producer AG'
42
+ product.company = company
43
+ company.save
44
+ sequence = Drugs::Sequence.new
45
+ sequence.product = product
46
+ atc = Drugs::Atc.new(atccode)
47
+ atc.name.de = 'Amantadin'
48
+ ddd = Drugs::Ddd.new('O')
49
+ ddd.dose = Drugs::Dose.new(10, 'mg')
50
+ atc.add_ddd(ddd)
51
+ sequence.atc = atc
52
+ composition = Drugs::Composition.new
53
+ galform = Drugs::GalenicForm.new
54
+ galform.description.de = 'Tabletten'
55
+ composition.galenic_form = galform
56
+ grp = Drugs::GalenicGroup.new('Tabletten')
57
+ grp.administration = 'O'
58
+ galform.group = grp
59
+ sequence.add_composition(composition)
60
+ substance = Drugs::Substance.new
61
+ substance.name.de = 'Amantadin'
62
+ dose = Drugs::Dose.new(100, 'mg')
63
+ active_agent = Drugs::ActiveAgent.new(substance, dose)
64
+ composition.add_active_agent(active_agent)
65
+ package = Drugs::Package.new
66
+ code = Util::Code.new(:cid, '12345', 'DE')
67
+ package.add_code(code)
68
+ code = Util::Code.new(:festbetragsstufe, 3, 'DE')
69
+ package.add_code(code)
70
+ code = Util::Code.new(:festbetragsgruppe, 4, 'DE')
71
+ package.add_code(code)
72
+ code = Util::Code.new(:zuzahlungsbefreit, true, 'DE')
73
+ package.add_code(code)
74
+ part = Drugs::Part.new
75
+ part.package = package
76
+ part.size = 5
77
+ part.composition = composition
78
+ unit = Drugs::Unit.new
79
+ unit.name.de = 'Ampullen'
80
+ part.unit = unit
81
+ part.quantity = Drugs::Dose.new(20, 'ml')
82
+ package.name.de = name
83
+ package.sequence = sequence
84
+ package.add_price(Util::Money.new(6, :public, 'DE'))
85
+ package.add_price(Util::Money.new(10, :festbetrag, 'DE'))
86
+ package.save
87
+ package
88
+ end
89
+ def setup_remote_package(name, uid='55555', price=12, ikscat='B')
90
+ rpackage = flexmock('Remote Package')
91
+ rpackage.should_receive(:barcode).and_return("7680#{uid}0012")
92
+ rpackage.should_receive(:name_base).and_return(name)
93
+ rpackage.should_receive(:price_public).and_return {
94
+ price
95
+ }
96
+ rpackage.should_receive(:ikscat).and_return(ikscat)
97
+ rpackage.should_receive(:sl_entry).and_return(true)
98
+ rpackage.should_receive(:comparable_size)\
99
+ .and_return(Drugs::Dose.new(100, 'ml'))
100
+ rpackage.should_receive(:__drbref).and_return(uid)
101
+ rcompany = flexmock('Remote Company')
102
+ rpackage.should_receive(:company).and_return(rcompany)
103
+ rcompany.should_receive(:name).and_return('Producer (Schweiz) AG')
104
+ ratc = flexmock('Remote Atc Class')
105
+ ratc.should_receive(:ddds).and_return []
106
+ rpackage.should_receive(:atc_class).and_return(ratc)
107
+ ratc.should_receive(:code).and_return('N04BB01')
108
+ ratc.should_receive(:parent_code).and_return('N04BB')
109
+ flexmock(Drugs::Atc).should_receive(:find_by_code)
110
+ ratc.should_receive(:name).and_return("Rem\366tadine")
111
+ #ratc.should_receive(:de).and_return('Amantadine')
112
+ ragent = flexmock('Remote ActiveAgent')
113
+ rpackage.should_receive(:active_agents).and_return([ragent])
114
+ rsubstance = flexmock('Remote Substance')
115
+ ragent.should_receive(:dose).and_return(Drugs::Dose.new(100, 'mg'))
116
+ ragent.should_receive(:substance).and_return(rsubstance)
117
+ rsubstance.should_receive(:de).and_return('Amantadinum')
118
+ rgalform = flexmock('Remote Galenic Form')
119
+ rpackage.should_receive(:galenic_forms).and_return([rgalform])
120
+ rgalform.should_receive(:de).and_return('Tropfen')
121
+ rgroup = flexmock('Remote Galenic Group')
122
+ rgroup.should_receive(:de).and_return('Unbekannt')
123
+ rgalform.should_receive(:galenic_group).and_return(rgroup)
124
+ rpart = flexmock('Remote Part')
125
+ rpart.should_receive(:comparable_size)\
126
+ .and_return(Drugs::Dose.new(4))
127
+ rpart.should_ignore_missing
128
+ rpackage.should_receive(:parts).and_return [rpart]
129
+ @cache.should_receive(:fetch).with(uid.to_i).and_return(rpackage)
130
+ rpackage.should_ignore_missing
131
+ rpackage
132
+ end
133
+ def teardown
134
+ super
135
+ ODDB.config.remote_databases = []
136
+ @currency.stop_service
137
+ end
138
+ def test_search
139
+ ODDB.config.query_limit = 20
140
+ package = setup_package
141
+ open "/"
142
+ assert_equal "DE - ODDB.org | Medikamente | Home | Open Drug Database", get_title
143
+ type "query", "Amantadin"
144
+ click "//input[@type='submit']"
145
+ wait_for_page_to_load "30000"
146
+ assert_equal "DE - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database",
147
+ get_title
148
+ assert is_text_present('Amantadin (N04BB01) - 1 Präparate')
149
+ assert is_text_present('Amantadin by Producer')
150
+ assert is_text_present('100 mg')
151
+ assert is_text_present('5 Ampullen à 20 ml')
152
+ assert is_text_present('6.00')
153
+ assert is_text_present('10.00')
154
+ assert is_text_present('-4.00')
155
+ assert is_text_present('3')
156
+ assert is_text_present('Ja')
157
+ assert is_text_present('N04BB01')
158
+ assert is_text_present('Producer AG')
159
+ assert is_text_present('FB')
160
+
161
+ ## State::Drugs::Result does not re-search if the query is the same
162
+ package2 = Drugs::Package.new
163
+ package2.sequence = package.sequence
164
+ package2.save
165
+ package2.add_price(Util::Money.new(999999, :public, 'DE'))
166
+ open('/de/drugs/search/query/Amantadin')
167
+ wait_for_page_to_load "30000"
168
+ assert_equal "DE - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database",
169
+ get_title
170
+ assert is_text_present('Amantadin by Producer')
171
+ assert !is_text_present('999999.00')
172
+
173
+ ## Sort result
174
+ click "//a[@name='th_package_infos']"
175
+ wait_for_page_to_load "30000"
176
+ assert_equal "DE - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database",
177
+ get_title
178
+
179
+ click "//a[@name='th_package_infos']"
180
+ wait_for_page_to_load "30000"
181
+ assert_equal "DE - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database",
182
+ get_title
183
+
184
+ click "//a[@name='th_ddd_prices']"
185
+ wait_for_page_to_load "30000"
186
+ assert_equal "DE - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database",
187
+ get_title
188
+
189
+ click "//a[@name='th_company']"
190
+ wait_for_page_to_load "30000"
191
+ assert_equal "DE - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database",
192
+ get_title
193
+
194
+ click "//a[@name='th_price_festbetrag']"
195
+ wait_for_page_to_load "30000"
196
+ assert_equal "DE - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database",
197
+ get_title
198
+
199
+ ## an empty Result:
200
+ type "query", "Gabapentin"
201
+ select "dstype", "Inhaltsstoff"
202
+ wait_for_page_to_load "30000"
203
+ assert_equal "DE - ODDB.org | Medikamente | Suchen | Gabapentin | Inhaltsstoff | Open Drug Database",
204
+ get_title
205
+ expected = <<-EOS
206
+ Ihr Such-Stichwort hat zu keinem Suchergebnis geführt. Bitte überprüfen Sie die Schreibweise und versuchen Sie es noch einmal.
207
+ EOS
208
+ assert is_text_present(expected.chop)
209
+ end
210
+ def test_search__ajax
211
+ setup_package
212
+ open "/"
213
+ assert_equal "DE - ODDB.org | Medikamente | Home | Open Drug Database", get_title
214
+ type "query", "Producer"
215
+ select 'dstype', 'Preisvergleich'
216
+ # no click necessary
217
+ # click "//input[@type='submit']"
218
+ wait_for_page_to_load "30000"
219
+ assert_equal "DE - ODDB.org | Medikamente | Suchen | Producer | Preisvergleich | Open Drug Database",
220
+ get_title
221
+ assert is_text_present('Amantadin by Producer')
222
+ mouse_over 'package_infos12345'
223
+ assert !60.times {
224
+ break if (is_element_present("//body/div[5]/table") rescue false)
225
+ sleep 1
226
+ }
227
+ assert is_text_present('Festbetragsgruppe')
228
+ assert is_text_present('Festbetragsstufe')
229
+ assert is_text_present('3: Arzneimittel mit therapeutisch vergleichbarer Wirkung, insbesondere Arzneimittelkombinationen')
230
+ assert is_text_present('Zuzahlungsbefreit')
231
+ assert is_text_present('Ja')
232
+ assert is_text_present('Rezeptpflichtig')
233
+ assert is_text_present('Nein')
234
+ mouse_over 'ddd_price_12345.0'
235
+ assert !60.times {
236
+ break if (is_element_present("//body/div[6]/table") rescue false)
237
+ sleep 1
238
+ }
239
+ assert is_text_present('Verabreichungsform')
240
+ assert is_text_present('Oral')
241
+ assert is_text_present('Anmerkung')
242
+ assert is_text_present('Tagesdosis')
243
+ assert is_text_present('10 mg')
244
+ assert is_text_present('Apothekenverkaufspreis')
245
+ assert is_text_present('6.00')
246
+ assert is_text_present('Stärke')
247
+ assert is_text_present('100 mg')
248
+ assert is_text_present('Packungsgrösse')
249
+ assert is_text_present('5 Ampullen à 20 ml')
250
+ assert is_text_present('Berechnung')
251
+ assert is_text_present('( 10 mg / 100 mg ) x ( 6.00 / 5 Ampullen à 20 ml ) = EUR 0.01 / Tag')
252
+ end
253
+ def test_search__company
254
+ setup_package
255
+ open "/"
256
+ assert_equal "DE - ODDB.org | Medikamente | Home | Open Drug Database", get_title
257
+ type "query", "Producer"
258
+ select 'dstype', 'Zulassungsinhaber'
259
+ # no click necessary
260
+ # click "//input[@type='submit']"
261
+ wait_for_page_to_load "30000"
262
+ assert_equal "DE - ODDB.org | Medikamente | Suchen | Producer | Zulassungsinhaber | Open Drug Database",
263
+ get_title
264
+ assert is_text_present('Amantadin by Producer')
265
+ assert is_text_present('100 mg')
266
+ assert is_text_present('5 Ampullen à 20 ml')
267
+ assert is_text_present('6.00')
268
+ assert is_text_present('10.00')
269
+ assert is_text_present('-4.00')
270
+ assert is_text_present('3')
271
+ assert is_text_present('Ja')
272
+ assert is_text_present('N04BB01')
273
+ assert is_text_present('Producer AG')
274
+ end
275
+ def test_search__compare
276
+ setup_package
277
+ open "/"
278
+ assert_equal "DE - ODDB.org | Medikamente | Home | Open Drug Database", get_title
279
+ type "query", "amantadin"
280
+ select 'dstype', 'Preisvergleich'
281
+ # no click necessary
282
+ # click "//input[@type='submit']"
283
+ wait_for_page_to_load "30000"
284
+ assert_equal "DE - ODDB.org | Medikamente | Suchen | amantadin | Preisvergleich | Open Drug Database",
285
+ get_title
286
+ assert is_text_present('Amantadin by Producer')
287
+ assert is_text_present('100 mg')
288
+ assert is_text_present('5 Ampullen à 20 ml')
289
+ assert is_text_present('6.00')
290
+ assert is_text_present('10.00')
291
+ assert is_text_present('-4.00')
292
+ assert is_text_present('3')
293
+ assert is_text_present('Ja')
294
+ assert is_text_present('N04BB01')
295
+ assert is_text_present('Producer AG')
296
+ end
297
+ def test_search__details
298
+ package = setup_package
299
+ package.add_code(Util::Code.new(:cid, '12345', 'DE'))
300
+ open "/"
301
+ assert_equal "DE - ODDB.org | Medikamente | Home | Open Drug Database", get_title
302
+ type "query", "Amantadin"
303
+ click "//input[@type='submit']"
304
+ wait_for_page_to_load "30000"
305
+ assert_equal "DE - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database",
306
+ get_title
307
+ assert is_text_present('Amantadin by Producer')
308
+
309
+ ## click through to Details
310
+ click "link=Amantadin 100 mg"
311
+ wait_for_page_to_load "30000"
312
+ assert_equal "DE - ODDB.org | Medikamente | Details | Amantadin by Producer | Open Drug Database",
313
+ get_title
314
+
315
+ ## click back to Result
316
+ click "link=Suchresultat"
317
+ wait_for_page_to_load "30000"
318
+ assert_equal "DE - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database",
319
+ get_title
320
+ end
321
+ def test_search__direct_sort
322
+ setup_package("Amonamon")
323
+ setup_package("Nomamonamon")
324
+ open "/de/drugs/search/query/Producer/dstype/compare/sortvalue/product"
325
+ wait_for_page_to_load "30000"
326
+ assert_equal "DE - ODDB.org | Medikamente | Suchen | Producer | Preisvergleich | Open Drug Database",
327
+ get_title
328
+
329
+ assert_match(/^Nomamonamon/, get_text("cid_N04BB01_0"))
330
+ assert_match(/^Amonamon/, get_text("cid_N04BB01_1"))
331
+ end
332
+ def test_search__feedback
333
+ package = setup_package
334
+ package.add_code(Util::Code.new(:cid, '12345', 'DE'))
335
+ open "/"
336
+ assert_equal "DE - ODDB.org | Medikamente | Home | Open Drug Database", get_title
337
+ type "query", "Amantadin"
338
+ click "//input[@type='submit']"
339
+ wait_for_page_to_load "30000"
340
+ assert_equal "DE - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database",
341
+ get_title
342
+ assert is_text_present('Amantadin by Producer')
343
+
344
+ ## click through to Feedback
345
+ assert is_element_present("link=FB")
346
+ click "//a[@name='feedback_short']"
347
+ wait_for_page_to_load "30000"
348
+ assert_equal "DE - ODDB.org | Medikamente | Feedback | Amantadin by Producer | Open Drug Database",
349
+ get_title
350
+
351
+ ## click back to Result
352
+ click "link=Suchresultat"
353
+ wait_for_page_to_load "30000"
354
+ assert_equal "DE - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database",
355
+ get_title
356
+ end
357
+ def test_search__limited
358
+ ODDB.config.query_limit = 1
359
+ package = setup_package
360
+ open "/de/drugs/search/query/Amantadin"
361
+ assert_equal "DE - ODDB.org | Medikamente | Suchen | Amantadin | Preisvergleich | Open Drug Database",
362
+ get_title
363
+ open "/de/drugs/search/query/Amantadin"
364
+ assert_equal 'DE - ODDB.org | Medikamente | Open Drug Database',
365
+ get_title
366
+ assert is_text_present("Abfragebeschränkung")
367
+ ensure
368
+ ODDB.config.query_limit = 20
369
+ end
370
+ def test_search__admin_not_limited
371
+ ODDB.config.query_limit = 1
372
+ package = setup_package
373
+ user = login_admin
374
+ 2.times {
375
+ open "/de/drugs/search/query/Amantadin"
376
+ assert_equal "DE - ODDB.org | Medikamente | Suchen | Amantadin | Preisvergleich | Open Drug Database",
377
+ get_title
378
+ }
379
+ ensure
380
+ ODDB.config.query_limit = 20
381
+ end
382
+ def test_search__admin_atc
383
+ existing = setup_package
384
+ package = setup_package
385
+ package.sequence.atc = nil
386
+ user = login_admin
387
+ open "/de/drugs/search/query/Amantadin"
388
+ assert_equal "DE - ODDB.org | Medikamente | Suchen | Amantadin | Preisvergleich | Open Drug Database",
389
+ get_title
390
+ assert is_text_present('Amantadin (N04BB01) - 1 Präparate')
391
+ assert is_text_present('ATC-Code nicht bekannt - 1 Präparate')
392
+ assert is_element_present("atc-assign")
393
+ assert is_element_present("atc-assign-toggle")
394
+ assert is_element_present("atc-assign-form")
395
+ assert !is_visible("atc-assign")
396
+ click "link=ATC zuweisen"
397
+ assert is_visible("atc-assign")
398
+
399
+ type "atc-assign", "N04BB02"
400
+ submit "atc-assign-form"
401
+ wait_for_page_to_load "30000"
402
+
403
+ assert is_text_present('Der ATC-Code "N04BB02" ist nicht bekannt.')
404
+ assert is_text_present('Amantadin (N04BB01) - 1 Präparate')
405
+ assert is_text_present('ATC-Code nicht bekannt - 1 Präparate')
406
+ assert is_element_present("atc-assign")
407
+ assert is_element_present("atc-assign-toggle")
408
+ assert is_element_present("atc-assign-form")
409
+ assert is_visible("atc-assign")
410
+
411
+ type "atc-assign", "N04BB01"
412
+ submit "atc-assign-form"
413
+ wait_for_page_to_load "30000"
414
+
415
+ assert is_text_present('Amantadin (N04BB01) - 2 Präparate')
416
+ assert !is_text_present('ATC-Code nicht bekannt')
417
+ assert !is_element_present("atc-assign")
418
+ assert !is_element_present("atc-assign-toggle")
419
+ assert !is_element_present("atc-assign-form")
420
+ ensure
421
+ ODDB.config.query_limit = 20
422
+ end
423
+ def test_search__with_fachinfo
424
+ package = setup_package
425
+ package.fachinfo.de = "Fachinfo-Document"
426
+ open "/"
427
+ assert_equal "DE - ODDB.org | Medikamente | Home | Open Drug Database", get_title
428
+ type "query", "Amantadin"
429
+ click "//input[@type='submit']"
430
+ wait_for_page_to_load "30000"
431
+ assert_equal "DE - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database",
432
+ get_title
433
+ assert is_text_present('FI')
434
+ assert is_text_present('Amantadin by Producer')
435
+ assert is_text_present('100 mg')
436
+ assert is_text_present('5 Ampullen à 20 ml')
437
+ assert is_text_present('6.00')
438
+ assert is_text_present('10.00')
439
+ assert is_text_present('-4.00')
440
+ assert is_text_present('3')
441
+ assert is_text_present('Ja')
442
+ assert is_text_present('N04BB01')
443
+ assert is_text_present('Producer AG')
444
+ end
445
+ def test_search__multiple_substances
446
+ package = setup_package
447
+ substance = Drugs::Substance.new
448
+ substance.name.de = "Propranolol"
449
+ dose = Drugs::Dose.new(50, 'mg')
450
+ active_agent = Drugs::ActiveAgent.new(substance, dose)
451
+ package.sequence.compositions.first.add_active_agent(active_agent)
452
+ open "/"
453
+ assert_equal "DE - ODDB.org | Medikamente | Home | Open Drug Database", get_title
454
+ type "query", "Amantadin"
455
+ click "//input[@type='submit']"
456
+ wait_for_page_to_load "30000"
457
+ assert_equal "DE - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database",
458
+ get_title
459
+ assert is_text_present('Amantadin by Producer')
460
+ assert is_text_present('2 Wirkstoffe')
461
+ end
462
+ def test_search__paged
463
+ pack = setup_package
464
+ other = setup_package('Amantadin Ophtal', 'S01AA01')
465
+ open "/"
466
+ assert_equal "DE - ODDB.org | Medikamente | Home | Open Drug Database", get_title
467
+ flexstub(@server['test:preset-session-id']).should_receive(:pagelength).and_return(1)
468
+ type "query", "Amantadin"
469
+ click "//input[@type='submit']"
470
+ wait_for_page_to_load "30000"
471
+ assert_equal "DE - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database",
472
+ get_title
473
+ assert is_text_present('Alle Präparate anzeigen')
474
+ assert !is_text_present('Zur ATC-Übersicht')
475
+ assert !is_text_present('<< 1 2 >>')
476
+ assert is_text_present('Amantadin (N04BB01) - 1 Präparate')
477
+ assert !is_text_present('Amantadin by Producer')
478
+ assert is_text_present('Amantadin (S01AA01) - 1 Präparate')
479
+ assert !is_text_present('Amantadin Ophtal')
480
+
481
+ click 'link=Alle Präparate anzeigen'
482
+ wait_for_page_to_load "30000"
483
+ assert !is_text_present('Alle Präparate anzeigen')
484
+ assert is_text_present('Zur ATC-Übersicht')
485
+ assert is_text_present('<< 1 2 >>')
486
+ assert is_text_present('Amantadin (N04BB01) - 1 Präparate')
487
+ assert is_text_present('Amantadin by Producer')
488
+ assert !is_text_present('Amantadin (S01AA01) - 1 Präparate')
489
+ assert !is_text_present('Amantadin Ophtal')
490
+
491
+ click 'link=>>'
492
+ wait_for_page_to_load "30000"
493
+ assert !is_text_present('Alle Präparate anzeigen')
494
+ assert is_text_present('Zur ATC-Übersicht')
495
+ assert is_text_present('<< 1 2 >>')
496
+ assert !is_text_present('Amantadin (N04BB01) - 1 Präparate')
497
+ assert !is_text_present('Amantadin by Producer')
498
+ assert is_text_present('Amantadin (S01AA01) - 1 Präparate')
499
+ assert is_text_present('Amantadin Ophtal')
500
+
501
+ click 'link=Zur ATC-Übersicht'
502
+ wait_for_page_to_load "30000"
503
+ assert is_text_present('Alle Präparate anzeigen')
504
+ assert !is_text_present('Zur ATC-Übersicht')
505
+ assert !is_text_present('<< 1 2 >>')
506
+ assert is_text_present('Amantadin (N04BB01) - 1 Präparate')
507
+ assert !is_text_present('Amantadin by Producer')
508
+ assert is_text_present('Amantadin (S01AA01) - 1 Präparate')
509
+ assert !is_text_present('Amantadin Ophtal')
510
+
511
+ click 'link=Amantadin (N04BB01) - 1 Präparate'
512
+ wait_for_page_to_load "30000"
513
+ assert is_text_present('Alle Präparate anzeigen')
514
+ assert !is_text_present('Zur ATC-Übersicht')
515
+ assert !is_text_present('<< 1 2 >>')
516
+ assert is_text_present('Amantadin (N04BB01) - 1 Präparate')
517
+ assert is_text_present('Amantadin by Producer')
518
+ assert is_text_present('Amantadin (S01AA01) - 1 Präparate')
519
+ assert !is_text_present('Amantadin Ophtal')
520
+
521
+ click 'link=Amantadin (S01AA01) - 1 Präparate'
522
+ wait_for_page_to_load "30000"
523
+ assert is_text_present('Alle Präparate anzeigen')
524
+ assert !is_text_present('Zur ATC-Übersicht')
525
+ assert !is_text_present('<< 1 2 >>')
526
+ assert is_text_present('Amantadin (N04BB01) - 1 Präparate')
527
+ assert !is_text_present('Amantadin by Producer')
528
+ assert is_text_present('Amantadin (S01AA01) - 1 Präparate')
529
+ assert is_text_present('Amantadin Ophtal')
530
+ end
531
+ def test_search__remote_not_enabled
532
+ remote = flexmock('Remote')
533
+ drb = DRb.start_service('druby://localhost:0', remote)
534
+ ODDB.config.remote_databases = [drb.uri]
535
+
536
+ package = setup_package
537
+ open "/"
538
+ assert_equal "DE - ODDB.org | Medikamente | Home | Open Drug Database", get_title
539
+ type "query", "Amantadin"
540
+ click "//input[@type='submit']"
541
+ wait_for_page_to_load "30000"
542
+ assert_equal "DE - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database", get_title
543
+ assert_match(/^Amantadin by Producer/, get_text("cid_N04BB01_0"))
544
+ assert !is_element_present("//a[@id='cid_N04BB01_1']")
545
+ assert is_text_present('Gelb = Zuzahlungsbefreit')
546
+ assert !is_text_present('Rot = CH - Produkte')
547
+ ensure
548
+ drb.stop_service
549
+ end
550
+ def test_search__remote
551
+ remote = flexmock('Remote')
552
+ drb = DRb.start_service('druby://localhost:0', remote)
553
+ ODDB.config.remote_databases = [drb.uri]
554
+
555
+ remote.should_receive(:get_currency_rate).with('EUR').and_return 0.6
556
+ rpackage = setup_remote_package 'Remotadin'
557
+ remote.should_receive(:remote_packages).and_return([rpackage])
558
+
559
+ package = setup_package
560
+ # switch to mm-flavor
561
+ open "/de/drugs/home/flavor/mm"
562
+ assert_equal "CH | DE - ODDB.org | Medikamente | Home | Open Drug Database", get_title
563
+ type "query", "Amantadin"
564
+ click "//input[@type='submit']"
565
+ wait_for_page_to_load "30000"
566
+ assert_equal "CH | DE - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database", get_title
567
+ assert_match(/^Amantadin by Producer/, get_text("cid_N04BB01_0"))
568
+ assert is_element_present("//a[@id='cid_N04BB01_1']")
569
+ assert_match(/^Remotadin/, get_text("cid_N04BB01_1"))
570
+ assert is_text_present('Producer (Schweiz) AG')
571
+ assert is_text_present('10.80')
572
+ assert_equal 'groupheader', get_attribute('//tr[2]@class')
573
+ assert_equal 'zuzahlungsbefreit', get_attribute('//tr[3]@class')
574
+ assert_equal 'remote bg', get_attribute('//tr[4]@class')
575
+
576
+ ## ensure sortable
577
+ click "link=Präparat"
578
+ wait_for_page_to_load "30000"
579
+ assert_equal "CH | DE - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database", get_title
580
+ assert_match(/^Remotadin/, get_text("cid_N04BB01_0"))
581
+ assert_match(/^Amantadin by Producer/, get_text("cid_N04BB01_1"))
582
+ assert_equal 'groupheader', get_attribute('//tr[2]@class')
583
+ assert_equal 'remote', get_attribute('//tr[3]@class')
584
+ assert_equal 'zuzahlungsbefreit bg', get_attribute('//tr[4]@class')
585
+
586
+ click "link=Wirkstoff"
587
+ wait_for_page_to_load "30000"
588
+ assert_equal "CH | DE - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database", get_title
589
+ assert_match(/^Amantadin by Producer/, get_text("cid_N04BB01_0"))
590
+ assert_match(/^Remotadin/, get_text("cid_N04BB01_1"))
591
+ assert_equal 'groupheader', get_attribute('//tr[2]@class')
592
+ assert_equal 'zuzahlungsbefreit', get_attribute('//tr[3]@class')
593
+ assert_equal 'remote bg', get_attribute('//tr[4]@class')
594
+
595
+ assert is_text_present('Gelb = Zuzahlungsbefreit')
596
+ assert is_text_present('Rot = CH - Produkte')
597
+ ensure
598
+ drb.stop_service
599
+ end
600
+ def test_search__remote__ajax
601
+ remote = flexmock('Remote')
602
+ DRb.install_id_conv(ODBA::DRbIdConv.new)
603
+ drb = DRb.start_service('druby://localhost:0', remote)
604
+ ODDB.config.remote_databases = [drb.uri]
605
+
606
+ remote.should_receive(:get_currency_rate).with('EUR').and_return 0.6
607
+ rpackage = setup_remote_package('Remotadin')
608
+ rotc = setup_remote_package('Remotadin OTC', '55556', 24, 'D')
609
+ remote.should_receive(:remote_packages).and_return([rpackage, rotc])
610
+
611
+ package = setup_package
612
+ # switch to mm-flavor
613
+ open "/de/drugs/home/flavor/mm"
614
+ assert_equal "CH | DE - ODDB.org | Medikamente | Home | Open Drug Database", get_title
615
+ type "query", "Amantadin"
616
+ click "//input[@type='submit']"
617
+ wait_for_page_to_load "30000"
618
+ assert_equal "CH | DE - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database", get_title
619
+ assert_match(/^Remotadin/, get_text("cid_N04BB01_1"))
620
+ mouse_over 'package_infos0.55555'
621
+ assert !60.times {
622
+ break if (is_element_present("//body/div[5]/table") rescue false)
623
+ sleep 1
624
+ }
625
+ assert is_text_present('B : Abgabe auf ärztliche Verschreibung')
626
+
627
+ mouse_over 'explain_price12345'
628
+ assert !60.times {
629
+ break if (is_element_present("//body/div[6]/table") rescue false)
630
+ sleep 1
631
+ }
632
+ assert is_text_present('Preis Deutschland (CHF)')
633
+ assert is_text_present('9.00')
634
+ assert is_text_present('MwSt. Deutschland (19%)')
635
+ assert is_text_present('- 1.44')
636
+ assert is_text_present('MwSt. Schweiz (7.6%)')
637
+ assert is_text_present('+ 0.57')
638
+ assert is_text_present('Preis Schweiz (CHF)')
639
+ assert is_text_present('8.14')
640
+
641
+ assert_match(/^Remotadin/, get_text("cid_N04BB01_2"))
642
+ mouse_over 'package_infos0.55556'
643
+ assert !60.times {
644
+ break if (is_element_present("//body/div[7]/table") rescue false)
645
+ sleep 1
646
+ }
647
+ assert is_text_present('D : Abgabe nach Fachberatung')
648
+
649
+ ensure
650
+ drb.stop_service
651
+ end
652
+ def test_search__remote__no_link
653
+ remote = flexmock('Remote')
654
+ drb = DRb.start_service('druby://localhost:0', remote)
655
+ ODDB.config.remote_databases = [drb.uri]
656
+
657
+ remote.should_receive(:get_currency_rate).with('EUR').and_return 0.6
658
+ rpackage = flexmock('Remote Package')
659
+ remote.should_receive(:remote_packages).and_return([rpackage])
660
+ rpackage.should_receive(:barcode).and_return('Barcode')
661
+ rpackage.should_receive(:name_base).and_return('Remotadin')
662
+ rpackage.should_receive(:price_public).and_return(1200)
663
+ rpackage.should_receive(:comparable_size)\
664
+ .and_return(Drugs::Dose.new(100, 'ml'))
665
+ rpackage.should_receive(:__drbref).and_return("55555")
666
+ rpackage.should_receive(:comform)
667
+ rcompany = flexmock('Remote Company')
668
+ rpackage.should_receive(:company).and_return(rcompany)
669
+ rcompany.should_receive(:name).and_return('Producer (Schweiz) AG')
670
+ ratc = flexmock('Remote Atc Class')
671
+ rpackage.should_receive(:atc_class).and_return(ratc)
672
+ ratc.should_receive(:ddds).and_return []
673
+ ratc.should_receive(:code).and_return('N04BB01')
674
+ ratc.should_receive(:de).and_return('Amantadine')
675
+ ragent = flexmock('Remote ActiveAgent')
676
+ rpackage.should_receive(:active_agents).and_return([ragent, ragent])
677
+ rsubstance = flexmock('Remote Substance')
678
+ ragent.should_receive(:dose).and_return(Drugs::Dose.new(100, 'mg'))
679
+ ragent.should_receive(:substance).and_return(rsubstance)
680
+ rpart = flexmock('Remote Part')
681
+ rpart.should_receive(:comparable_size)\
682
+ .and_return(Drugs::Dose.new(4))
683
+ rpart.should_ignore_missing
684
+ rpackage.should_receive(:parts).and_return [rpart]
685
+ rpackage.should_receive(:galenic_forms).and_return []
686
+ rsubstance.should_receive(:de).and_return('Amantadinum')
687
+ rpackage.should_ignore_missing
688
+
689
+ package = setup_package
690
+ # switch to mm-flavor
691
+ open "/de/drugs/home/flavor/mm"
692
+ assert_equal "CH | DE - ODDB.org | Medikamente | Home | Open Drug Database", get_title
693
+ type "query", "Amantadin"
694
+ click "//input[@type='submit']"
695
+ wait_for_page_to_load "30000"
696
+ assert_equal "CH | DE - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database", get_title
697
+ assert !is_element_present("//a[@id='cid_N04BB01_1']")
698
+ ensure
699
+ drb.stop_service
700
+ end
701
+ def test_search__remote__only_remote
702
+ remote = flexmock('Remote')
703
+ drb = DRb.start_service('druby://localhost:0', remote)
704
+ ODDB.config.remote_databases = [drb.uri]
705
+
706
+ remote.should_receive(:get_currency_rate).with('EUR').and_return 0.6
707
+ rpackage = setup_remote_package 'Remotadin'
708
+ remote.should_receive(:remote_packages).and_return([rpackage])
709
+
710
+ # switch to mm-flavor
711
+ open "/de/drugs/home/flavor/mm"
712
+ assert_equal "CH | DE - ODDB.org | Medikamente | Home | Open Drug Database", get_title
713
+ type "query", "Amantadin"
714
+ click "//input[@type='submit']"
715
+ wait_for_page_to_load "30000"
716
+ assert_equal "CH | DE - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database", get_title
717
+ assert is_element_present("//a[@id='cid_N04BB01_0']")
718
+ assert_match(/^Remotadin/, get_text("cid_N04BB01_0"))
719
+ assert is_text_present('Remötadin')
720
+ assert is_text_present('Producer (Schweiz) AG')
721
+ assert is_text_present('10.80')
722
+
723
+ ensure
724
+ drb.stop_service
725
+ end
726
+ def test_search__remote__connection_error
727
+ ODDB.config.remote_databases = ['druby://localhost:999999']
728
+
729
+ package = setup_package
730
+ # switch to mm-flavor
731
+ open "/de/drugs/home/flavor/mm"
732
+ assert_equal "CH | DE - ODDB.org | Medikamente | Home | Open Drug Database", get_title
733
+ type "query", "Amantadin"
734
+ click "//input[@type='submit']"
735
+ wait_for_page_to_load "30000"
736
+ assert_equal "CH | DE - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database", get_title
737
+ assert_match(/^Amantadin by Producer/, get_text("cid_N04BB01_0"))
738
+ assert !is_element_present("//a[@id='cid_N04BB01_1']")
739
+ assert !is_text_present('Producer (Schweiz) AG')
740
+ assert !is_text_present('7.20')
741
+ end
742
+ def test_search__short
743
+ open "/"
744
+ assert_equal "DE - ODDB.org | Medikamente | Home | Open Drug Database", get_title
745
+ type "query", "A"
746
+ click "//input[@type='submit']"
747
+ wait_for_page_to_load "30000"
748
+ assert_equal "DE - ODDB.org | Medikamente | Suchen | A | Markenname | Open Drug Database",
749
+ get_title
750
+ expected = 'Ihr Such-Stichwort ergibt ein sehr grosses Resultat. Bitte verwenden Sie mindestens 3 Buchstaben.'
751
+ assert is_text_present(expected)
752
+ end
753
+ def test_search__substance
754
+ pack = setup_package
755
+ flexstub(pack).should_receive(:substance).and_return('Amantadin')
756
+ open "/"
757
+ assert_equal "DE - ODDB.org | Medikamente | Home | Open Drug Database", get_title
758
+ type "query", "amantadin"
759
+ select 'dstype', 'Inhaltsstoff'
760
+ # no click necessary
761
+ # click "//input[@type='submit']"
762
+ wait_for_page_to_load "30000"
763
+ assert_equal "DE - ODDB.org | Medikamente | Suchen | amantadin | Inhaltsstoff | Open Drug Database",
764
+ get_title
765
+ assert is_text_present('Amantadin by Producer')
766
+ assert is_text_present('100 mg')
767
+ assert is_text_present('5 Ampullen à 20 ml')
768
+ assert is_text_present('6.00')
769
+ assert is_text_present('10.00')
770
+ assert is_text_present('-4.00')
771
+ assert is_text_present('3')
772
+ assert is_text_present('Ja')
773
+ assert is_text_present('N04BB01')
774
+ assert is_text_present('Producer AG')
775
+ end
776
+ def test_search__export_csv
777
+ pack = setup_package
778
+ ODDB.config.query_limit = 20
779
+ package = setup_package
780
+ open "/"
781
+ assert_equal "DE - ODDB.org | Medikamente | Home | Open Drug Database", get_title
782
+ type "query", "Amantadin"
783
+ click "//input[@type='submit']"
784
+ wait_for_page_to_load "30000"
785
+ assert_equal "DE - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database",
786
+ get_title
787
+ assert is_element_present '//input[@name="export_csv"]'
788
+ click '//input[@name="export_csv"]'
789
+ wait_for_page_to_load "30000"
790
+ assert_equal "DE - ODDB.org | Medikamente | CSV-Export | Amantadin | Markenname | Open Drug Database",
791
+ get_title
792
+
793
+ assert is_text_present("CSV-Export Datenerfassung")
794
+ assert is_text_present('Bitte geben Sie Ihre persönlichen Angaben ein und wählen Sie einen Benutzernamen und ein Passwort.')
795
+
796
+ assert_equal "E-Mail", get_text("//label[@for='email']")
797
+ assert is_element_present("email")
798
+ assert_equal "Passwort", get_text("//label[@for='pass']")
799
+ assert is_element_present("pass")
800
+ assert_equal "Bestätigung", get_text("//label[@for='confirm_pass']")
801
+ assert is_element_present("confirm_pass")
802
+ assert_equal "Anrede", get_text("//label[@for='salutation']")
803
+ assert is_element_present("salutation")
804
+ assert_equal "Nachname", get_text("//label[@for='name_last']")
805
+ assert is_element_present("name_last")
806
+ assert_equal "Vorname", get_text("//label[@for='name_first']")
807
+ assert is_element_present("name_first")
808
+
809
+ assert is_text_present("2 x")
810
+ assert is_text_present("Amantadin_tradename.csv")
811
+
812
+ refresh
813
+ wait_for_page_to_load "30000"
814
+ assert_equal "DE - ODDB.org | Medikamente | CSV-Export | Amantadin | Markenname | Open Drug Database",
815
+ get_title
816
+
817
+ assert is_text_present("CSV-Export Datenerfassung")
818
+ assert is_text_present('Bitte geben Sie Ihre persönlichen Angaben ein und wählen Sie einen Benutzernamen und ein Passwort.')
819
+
820
+ assert_equal "E-Mail", get_text("//label[@for='email']")
821
+ assert is_element_present("email")
822
+ assert_equal "Passwort", get_text("//label[@for='pass']")
823
+ assert is_element_present("pass")
824
+ assert_equal "Bestätigung", get_text("//label[@for='confirm_pass']")
825
+ assert is_element_present("confirm_pass")
826
+ assert_equal "Anrede", get_text("//label[@for='salutation']")
827
+ assert is_element_present("salutation")
828
+ assert_equal "Nachname", get_text("//label[@for='name_last']")
829
+ assert is_element_present("name_last")
830
+ assert_equal "Vorname", get_text("//label[@for='name_first']")
831
+ assert is_element_present("name_first")
832
+
833
+ assert is_text_present("2 x")
834
+ assert is_text_present("Amantadin_tradename.csv")
835
+
836
+ end
837
+ def test_search__export_csv__step2_error
838
+ pack = setup_package
839
+ ODDB.config.query_limit = 20
840
+ package = setup_package
841
+ open "/"
842
+ assert_equal "DE - ODDB.org | Medikamente | Home | Open Drug Database", get_title
843
+ type "query", "Amantadin"
844
+ click "//input[@type='submit']"
845
+ wait_for_page_to_load "30000"
846
+ assert_equal "DE - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database",
847
+ get_title
848
+ assert is_element_present '//input[@name="export_csv"]'
849
+ click '//input[@name="export_csv"]'
850
+ wait_for_page_to_load "30000"
851
+ assert_equal "DE - ODDB.org | Medikamente | CSV-Export | Amantadin | Markenname | Open Drug Database",
852
+ get_title
853
+
854
+ assert is_text_present("CSV-Export Datenerfassung")
855
+ assert is_text_present('Bitte geben Sie Ihre persönlichen Angaben ein und wählen Sie einen Benutzernamen und ein Passwort.')
856
+
857
+ @auth.should_receive(:login).and_return { raise Yus::UnknownEntityError }
858
+ click "//input[@type='submit']"
859
+ wait_for_page_to_load "30000"
860
+ assert_equal "DE - ODDB.org | Medikamente | CSV-Export | Amantadin | Markenname | Open Drug Database",
861
+ get_title
862
+ assert is_text_present("Bitte füllen Sie alle Felder aus.")
863
+ %w{email pass confirm_pass salutation name_last name_first}.each { |key|
864
+ assert_equal "error", get_attribute("//label[@for='#{key}']@class")
865
+ }
866
+ end
867
+ def test_search__export_csv__step2
868
+ yus = flexmock("yus-server")
869
+ remote = DRb.start_service('druby://localhost:0', yus)
870
+ yus_session = setup_autosession(yus)
871
+ yus_session.should_receive(:get_entity_preferences).and_return({})
872
+ email = "downloader@oddb.org"
873
+ ODDB.config.auth_server = remote.uri
874
+
875
+ pack = setup_package
876
+ ODDB.config.query_limit = 20
877
+ package = setup_package
878
+ open "/"
879
+ assert_equal "DE - ODDB.org | Medikamente | Home | Open Drug Database", get_title
880
+ type "query", "Amantadin"
881
+ click "//input[@type='submit']"
882
+ wait_for_page_to_load "30000"
883
+ assert_equal "DE - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database",
884
+ get_title
885
+ assert is_element_present '//input[@name="export_csv"]'
886
+ click '//input[@name="export_csv"]'
887
+ wait_for_page_to_load "30000"
888
+ assert_equal "DE - ODDB.org | Medikamente | CSV-Export | Amantadin | Markenname | Open Drug Database",
889
+ get_title
890
+
891
+ assert is_text_present("CSV-Export Datenerfassung")
892
+ assert is_text_present('Bitte geben Sie Ihre persönlichen Angaben ein und wählen Sie einen Benutzernamen und ein Passwort.')
893
+
894
+ @auth.should_receive(:login).and_return { raise Yus::UnknownEntityError }
895
+ type "email", email
896
+ type "pass", "secret"
897
+ type "confirm_pass", "secret"
898
+ select "//select[@name='salutation']", "Herr"
899
+ type "name_last", "Test"
900
+ type "name_first", "Fritz"
901
+
902
+ yus_session.should_receive(:create_entity).with(email, "5ebe2294ecd0e0f08eab7690d2a6ee69")
903
+ user = mock_user email
904
+ ODDB.server = server = flexmock("server")
905
+ server.should_receive(:login).and_return(user)
906
+ @auth.should_receive(:login).and_return(user)
907
+
908
+ click "//input[@type='submit']"
909
+ wait_for_page_to_load "30000"
910
+
911
+ output = @http_server.redirected_output
912
+ assert_match /www.sandbox.paypal.com/, output
913
+ end
914
+ def test_search__export_csv__direct
915
+ pack = setup_package
916
+ user = login 'test.export@oddb.org', ['download', 'org.oddb.de.Amantadin_tradename.csv']
917
+ ODDB.config.query_limit = 20
918
+ package = setup_package
919
+ open "/"
920
+ assert_equal "DE - ODDB.org | Medikamente | Home | Open Drug Database", get_title
921
+ type "query", "Amantadin"
922
+ click "//input[@type='submit']"
923
+ wait_for_page_to_load "30000"
924
+ assert_equal "DE - ODDB.org | Medikamente | Suchen | Amantadin | Markenname | Open Drug Database",
925
+ get_title
926
+ assert is_element_present '//input[@name="export_csv"]'
927
+ click '//input[@name="export_csv"]'
928
+
929
+ assert @http_server.attachment
930
+ end
931
+ end
932
+ end
933
+ end