oddb2xml 2.0.9 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/spec/calc_spec.rb CHANGED
@@ -159,7 +159,6 @@ if RunAllTests
159
159
  specify { expect(result.selling_units).to eq 10 }
160
160
  specify { expect(result.measure).to eq 'ml' }
161
161
  end
162
-
163
162
  context 'should return correct value for Diamox, comprimés' do
164
163
  pkg_size_L = '1 x 25'
165
164
  einheit_M = 'Tablette(n)'
@@ -241,29 +240,16 @@ if RunAllTests
241
240
  specify { expect(info.galenic_group.description).to eq 'Injektion/Infusion' }
242
241
  specify { expect(info.pkg_size).to eq '1 x 5 x 100' }
243
242
  skip { expect(info.measure).to eq '100 ml' }
244
- # specify { expect(info.count).to eq 5 }
245
- # specify { expect(info.multi).to eq 1 }
246
- # specify { expect(info.addition).to eq 0 }
247
- # specify { expect(info.scale).to eq 1 }
248
243
  end
249
244
 
250
245
  context 'find correct result for Inflora, capsule' do
251
246
  info = Calc.new(tst_infloran.name_C, tst_infloran.package_size_L, tst_infloran.einheit_M, tst_infloran.active_substance_0, tst_infloran.composition_P)
252
247
  specify { expect(tst_infloran.url).to eq 'http://ch.oddb.org/de/gcc/drug/reg/00679/seq/02/pack/012' }
253
- specify { expect(info.galenic_form.description).to eq 'capsule' }
254
- skip { expect(info.galenic_group.description).to eq 'Injektion/Infusion' }
248
+ specify { expect(info.galenic_form.description).to eq 'Kapseln' }
249
+ specify { expect(info.galenic_group.description).to eq 'Tabletten' }
255
250
  specify { expect(info.pkg_size).to eq '2x10' }
256
251
  specify { expect(info.selling_units).to eq 20 }
257
- skip { expect(info.measure).to eq '0' }
258
- # specify { expect(info.count).to eq 5 }
259
- # specify { expect(info.multi).to eq 1 }
260
- # specify { expect(info.addition).to eq 0 }
261
- # specify { expect(info.scale).to eq 1 }
262
- end
263
-
264
- context 'convert mg/l into ml/mg for solutions' do
265
- result = Calc.new('50', 'g/l')
266
- skip { expect(result.measure).to eq 50 }
252
+ specify { expect(info.measure).to eq 'Kapsel(n)' }
267
253
  end
268
254
 
269
255
  run_time_options = '--calc --skip-download'
@@ -296,8 +282,6 @@ if RunAllTests
296
282
  xsd = Nokogiri::XML::Schema(File.read(oddb_calc_xsd))
297
283
  doc = Nokogiri::XML(File.read(xml_file_name))
298
284
  xsd.validate(doc).each do |error| expect(error).to be_nil end
299
- m = />.* /.match(xml)
300
- m.should eq nil
301
285
  doc = REXML::Document.new xml
302
286
  # puts xml; binding.pry
303
287
  gtin = '7680540151009'
@@ -325,7 +309,9 @@ if RunAllTests
325
309
  matri_name = 'Matricariae Extractum Isopropanolicum Liquidum'
326
310
  XPath.match( doc, "//ARTICLE[GTIN='7680545250363']/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/SUBSTANCE_NAME").
327
311
  find{|x| x.text.eql?("Alprostadilum")}.text.should eq 'Alprostadilum'
312
+ # XPath.match( doc, "//ARTICLE[GTIN='7680458820202']/NAME").last.text.should eq 'Magnesiumchlorid 0,5 molar B. Braun'
328
313
  XPath.match( doc, "//ARTICLE[GTIN='7680458820202']/NAME").last.text.should eq 'Magnesiumchlorid 0,5 molar B. Braun, Zusatzampulle für Infusionslösungen'
314
+ XPath.match( doc, "//ARTICLE[GTIN='7680458820202']/GALENIC_FORM").last.text.should match /Ampulle/i
329
315
  XPath.match( doc, "//ARTICLE[GTIN='7680555940018']/COMPOSITIONS/COMPOSITION/LABEL").first.text.should eq 'I'
330
316
  XPath.match( doc, "//ARTICLE[GTIN='7680555940018']/COMPOSITIONS/COMPOSITION/LABEL_DESCRIPTION").first.text.should eq 'Glucoselösung'
331
317
  XPath.match( doc, "//ARTICLE[GTIN='7680555940018']/COMPOSITIONS/COMPOSITION/LABEL").each{ |x| puts x.text }
@@ -334,7 +320,9 @@ if RunAllTests
334
320
 
335
321
  XPath.match( doc, "//ARTICLE[GTIN='7680434541015']/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/SUBSTANCE_NAME").
336
322
  find{|x| x.text.eql?(matri_name)}.text.should eq matri_name
323
+ # XPath.match( doc, "//ARTICLE[GTIN='7680434541015']/NAME").last.text.should eq 'Kamillin Medipharm'
337
324
  XPath.match( doc, "//ARTICLE[GTIN='7680434541015']/NAME").last.text.should eq 'Kamillin Medipharm, Bad'
325
+ XPath.match( doc, "//ARTICLE[GTIN='7680434541015']/GALENIC_FORM").last.text.should eq 'Bad'
338
326
  XPath.match( doc, "//ARTICLE[GTIN='7680434541015']/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/QTY").first.text.should eq '98.9'
339
327
  XPath.match( doc, "//ARTICLE[GTIN='7680300150105']/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/SUBSTANCE_NAME").first.text.should eq 'Lidocaini Hydrochloridum'
340
328
  XPath.match( doc, "//ARTICLE[GTIN='7680300150105']/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/UNIT").first.text.should eq 'mg/ml'
@@ -346,13 +334,19 @@ if RunAllTests
346
334
 
347
335
  XPath.match( doc, "//ARTICLE[GTIN='7680446250592']/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/SALTS/SALT/SUBSTANCE_NAME").first.text.should eq 'Ceftriaxonum Natricum'
348
336
 
337
+ # XPath.match( doc, "//ARTICLE[GTIN='7680611860045']/NAME").first.text.should eq 'Nutriflex Omega special'
349
338
  XPath.match( doc, "//ARTICLE[GTIN='7680611860045']/NAME").first.text.should eq 'Nutriflex Omega special, Infusionsemulsion 2500 ml'
339
+ XPath.match( doc, "//ARTICLE[GTIN='7680611860045']/GALENIC_FORM").first.text.should eq 'Infusionsemulsion'
350
340
  XPath.match( doc, "//ARTICLE[GTIN='7680611860045']/SELLING_UNITS").first.text.should eq '5'
351
341
 
352
342
  XPath.match( doc, "//ARTICLE[GTIN='7680165980114']/COMPOSITIONS/COMPOSITION/EXCIPIENS/SUBSTANCE_NAME").first.text.should eq 'Excipiens ad solutionem'
353
343
  XPath.match( doc, "//ARTICLE[GTIN='7680165980114']/COMPOSITIONS/COMPOSITION/EXCIPIENS/QTY").first.text.should eq '1'
354
344
  XPath.match( doc, "//ARTICLE[GTIN='7680165980114']/COMPOSITIONS/COMPOSITION/EXCIPIENS/UNIT").first.text.should eq 'ml'
355
345
  XPath.match( doc, "//ARTICLE[GTIN='7680165980114']/NAME").first.text.should eq 'W-Tropfen'
346
+ XPath.match( doc, "//ARTICLE[GTIN='7680165980114']/GALENIC_FORM").last.text.should eq 'Tropfen'
347
+
348
+ XPath.match( doc, "//ARTICLE[GTIN='7680589430011']/NAME").first.text.should eq 'Apligraf'
349
+ XPath.match( doc, "//ARTICLE[GTIN='7680589430011']/GALENIC_FORM").last.text.should eq 'Unbekannt' # TODO?? 'Scheibe(n)/disque(s)'
356
350
  end
357
351
  end
358
352
 
@@ -390,8 +384,10 @@ if RunAllTests
390
384
  context 'should handle CFU' do
391
385
  result = Calc.new(nil, nil, nil, 'lactobacillus acidophilus cryodesiccatus, bifidobacterium infantis',
392
386
  'lactobacillus acidophilus cryodesiccatus min. 10^9 CFU, bifidobacterium infantis min. 10^9 CFU, color.: E 127, E 132, E 104, excipiens pro capsula.')
393
- skip "Infloran, capsule mit cryodesiccatus min. 10^9 CFU"
387
+ specify { expect(result.compositions.first.substances.first.name).to eq 'Lactobacillus Acidophilus Cryodesiccatus' }
388
+ specify { expect(result.compositions.first.substances.first.dose.to_s).to eq '10^9 CFU' }
394
389
  end
390
+
395
391
  context 'find correct result compositions' do
396
392
  result = Calc.new(nil, nil, nil, 'rutosidum trihydricum, aescinum', 'rutosidum trihydricum 20 mg, aescinum 25 mg, aromatica, excipiens pro compresso.')
397
393
  specify { expect(result.compositions.first.substances.first.name).to eq 'Rutosidum Trihydricum' }
@@ -405,20 +401,21 @@ if RunAllTests
405
401
  context 'find correct result for Inflora, capsule' do
406
402
  info = Calc.new(tst_infloran.name_C, tst_infloran.package_size_L, tst_infloran.einheit_M, tst_infloran.active_substance_0, tst_infloran.composition_P)
407
403
  # specify { expect(tst_infloran.url).to eq 'http://ch.oddb.org/de/gcc/drug/reg/00679/seq/02/pack/012' }
408
- specify { expect(info.galenic_form.description).to eq 'capsule' }
409
- skip { expect(info.galenic_group.description).to eq 'Injektion/Infusion' }
404
+ specify { expect(info.galenic_form.oid).to eq 24 }
405
+ specify { expect(info.galenic_form.description).to eq 'Kapseln' }
406
+ specify { expect(info.galenic_group.description).to eq 'Tabletten' }
410
407
  specify { expect(info.pkg_size).to eq '2x10' }
411
408
  specify { expect(info.selling_units).to eq 20 }
412
- skip { expect(info.measure).to eq '0' }
409
+ specify { expect(info.measure).to eq 'Kapsel(n)' }
413
410
  bifidobacterium = info.compositions.first.substances.find{ |x| x.name.match(/Bifidobacterium/i) }
414
411
  specify { expect(bifidobacterium).not_to eq nil}
415
412
  if bifidobacterium
416
413
  specify { expect(bifidobacterium.name).to eq 'Bifidobacterium Infantis' }
417
- skip { expect(bifidobacterium.qty.to_f).to eq '10^9'}
418
- skip { expect(bifidobacterium.unit).to eq 'CFU'}
414
+ specify { expect(bifidobacterium.dose.to_s).to eq '10^9 CFU'}
415
+ specify { expect(bifidobacterium.unit).to eq 'CFU'}
419
416
  end
420
417
  e_127 = info.compositions.first.substances.find{ |x| x.name.match(/E 127/i) }
421
- skip { expect(e_127).not_to eq nil}
418
+ specify { expect(e_127).not_to eq nil}
422
419
  if e_127
423
420
  specify { expect(e_127.name).to eq 'E 127' }
424
421
  specify { expect(e_127.unit).to eq nil}
@@ -431,7 +428,8 @@ end
431
428
  specify { expect(info.galenic_group.description).to eq 'unbekannt' }
432
429
  specify { expect(info.pkg_size).to eq '3' }
433
430
  specify { expect(info.selling_units).to eq 3 }
434
- specify { expect(info.name).to eq 'Cardio-Pulmo-Rénal Sérocytol, suppositoire'}
431
+ specify { expect(info.column_c).to eq tst_cardio_pumal.name_C }
432
+ specify { expect(info.name).to eq 'Cardio-Pulmo-Rénal Sérocytol'}
435
433
  specify { expect(info.measure).to eq 'Suppositorien' }
436
434
  globulina = info.compositions.first.substances.find{ |x| x.name.match(/porcins|globulina/i) }
437
435
  specify { expect(globulina).not_to eq nil}
@@ -516,8 +514,8 @@ if RunAllTests
516
514
  specify { expect(info.compositions.size).to eq 2 }
517
515
  specify { expect(info.compositions.first.substances.size).to eq 6 }
518
516
  poloxamerum = info.compositions.first.substances.find{ |x| x.name.match(/poloxamerum/i) }
519
- skip { expect(poloxamerum.name).to eq 'Poloxamerum 238' }
520
- skip { expect(poloxamerum.qty.to_f).to eq "" }
517
+ specify { expect(poloxamerum.name).to eq 'Poloxamerum 238' }
518
+ specify { expect(poloxamerum.qty).to eq nil}
521
519
  specify { expect(poloxamerum.unit).to eq nil }
522
520
  end
523
521
 
@@ -670,4 +668,4 @@ Die HILFSSTOFFE sind Aqua ad iniectabilia und Natrii chloridum.
670
668
  end
671
669
  end
672
670
  end
673
- end
671
+ end
@@ -0,0 +1,324 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+ require "#{Dir.pwd}/lib/oddb2xml/parslet_compositions"
5
+ require 'parslet/rig/rspec'
6
+ require 'parslet/convenience'
7
+ require 'csv'
8
+
9
+ RunAllParsingExamples = false # RunAllParsingExamples /travis|localhost/i.match(hostname) != nil # takes about one minute to run
10
+
11
+ galenic_tests = {
12
+
13
+ '1001 Blattgrün Dragées' => { :prepation_name=>'1001 Blattgrün ', :galenic_form=> 'Dragées' },
14
+ '3TC 150 mg, Filmtabletten' => { :prepation_name=>'3TC 150 mg', :galenic_form=>'Filmtabletten' },
15
+ 'Acetocaustin, Lösung' => { :prepation_name=>'Acetocaustin', :galenic_form=>'Lösung' },
16
+ 'Alustal 3-Bäume, Injektionssuspension' => {:prepation_name=>'Alustal 3-Bäume', :galenic_form=> 'Injektionssuspension' },
17
+ 'Alustal Bäume, Injektionssuspension' => {:prepation_name=>'Alustal Bäume', :galenic_form=> 'Injektionssuspension' },
18
+ 'Amoxicillin Streuli, Granulat zur Herstellung einer Suspension' => { :prepation_name=>'Amoxicillin Streuli', :galenic_form=> 'Granulat zur Herstellung einer Suspension', },
19
+ 'Arkocaps Passiflore/Passionsblume, 300 mg, capsules'=> { :prepation_name=>'Arkocaps Passiflore/Passionsblume', :galenic_form=>'capsules' },
20
+ 'Atenativ, Antithrombin III 500 I.E., Injektionspräparat' => { :prepation_name=>'Atenativ', :galenic_form=>'Injektionspräparat' },
21
+ 'Atorvastatin Helvepharm, 10 mg Filmtabletten' => {:prepation_name=>'Atorvastatin Helvepharm', :galenic_form=> 'Filmtabletten' },
22
+ 'Atorvastax-Drossapharm 20 mg' => {:prepation_name=> 'Atorvastax-Drossapharm 20 mg', :galenic_form=> nil},
23
+ 'Co-Losartan Spirig HC 50/12,5 mg' => { :prepation_name=>'Co-Losartan Spirig HC 50/12,5 mg', :galenic_form=> nil, },
24
+ 'Dicloabak 0,1% Augentropfen' => { :prepation_name=>'Dicloabak 0,1% ', :galenic_form=>'Augentropfen' },
25
+ 'Kaliumchlorid 14,9 % B. Braun, Zusatzampullen'=> { :prepation_name=>'Kaliumchlorid 14,9 % B. Braun', :galenic_form=>'Zusatzampullen' },
26
+ 'Methrexx 7.5 mg / 0.75 ml,Injektionslösung in Fertigspritzen'=> { :prepation_name=>'Methrexx 7.5 mg / 0.75 ml', :galenic_form=> 'Injektionslösung in Fertigspritzen' },
27
+ 'Nitroderm TTS 10' => { :prepation_name=>'Nitroderm TTS 10', :galenic_form=> nil },
28
+ 'Ondansetron Labatec, 8mg/4ml, concentré pour perfusion' => {:prepation_name=>'Ondansetron Labatec', :galenic_form=> 'concentré pour perfusion' },
29
+ 'Paronex 20, Filmtabletten'=> { :prepation_name=>'Paronex 20', :galenic_form=>'Filmtabletten' },
30
+ 'Physioneal 35 Clear-Flex 3,86 % Peritonealdialyselösung' => { :prepation_name=>'Physioneal 35 Clear-Flex 3,86 % ', :galenic_form=>'Peritonealdialyselösung' },
31
+ 'Phytopharma foie et bile capsules/Leber-Galle Kapseln' => { :prepation_name=>'Phytopharma foie et bile capsules', :galenic_form=> 'Leber-Galle Kapseln' },
32
+ 'Plak-out Spray 0,1 %' => { :prepation_name=>'Plak-out Spray 0,1 %', :galenic_form=> nil },
33
+ 'Sandostatin 0,2 mg/mL, Injektionslösung' => { :prepation_name=>'Sandostatin 0,2 mg/mL', :galenic_form=>'Injektionslösung' },
34
+ 'Sulfure de Rhénium (186Re)-RE-186-MM-1 Cis bio International, Suspension' => { :prepation_name=>'Sulfure de Rhénium (186Re)-RE-186-MM-1 Cis bio International', :galenic_form=> 'Suspension' },
35
+ 'Tramal 100, Injektionslösung (i.m., i.v.)' => { :prepation_name=>'Tramal 100', :galenic_form=>'Injektionslösung (i.m., i.v.)' },
36
+ 'Uman Albumin Kedrion 20%' => { :prepation_name=>'Uman Albumin Kedrion 20%', :galenic_form=> nil },
37
+ }
38
+
39
+ todo = %(
40
+ Testlösung zur Allergiediagnose Teomed Kaninchen (Fell) Lösung
41
+ Testlösung zur Allergiediagnose Teomed Hund (Haare) Lösung
42
+ Pandemrix (Pandemic Influenza Vaccine H1N1)
43
+ Phytopharma dragées pour la détente et le sommeil / Entspannungs- und Schlafdragées
44
+ Phytopharma dragées pour le coeur / Herz Dragées
45
+ Best Friend Katzenhalsband / Katzenhalsband Reflex ad us.vet.
46
+ Amlodipin Helvepharm 10 Tabletten
47
+ Salbu Orion Easyhaler 100 ug Inhalationspulver
48
+ TISSEEL 10 ml 2 Fertigspritzen
49
+ TISSEEL 2 ml 2 Fertigspritzen
50
+ TISSEEL 4 ml 2 Fertigspritzen
51
+ Norprolac Starter-pack 25 ug + 50 ug, Tabletten
52
+ Phostal 5-Gräser 4-Getreidemischung 10IR, Injektionssuspension
53
+ Alustal 5-Gräser 4-Getreidemischung Kombipackung, Injektionssuspension
54
+ Staloral Beifuss 5-Gräser 100IR, Injektionssuspension
55
+ Phostal Beifuss 5-Gräser 10IR, Injektionssuspension
56
+ Alustal Beifuss 5-Gräser 10IR, Injektionssuspension
57
+ Seebri Breezhaler 50 Mikrogramm, Pulver zur Inhalation, Hartkapseln
58
+ Nplate 500 mcg Pulver und Lösungsmittel zur Herstellung einer Injektionslösung
59
+ Bayvantage ad us.vet. 80 für Katzen, Lösung
60
+ Ondansetron-Teva 8mg, Filmtabletten
61
+ Soluprick SQ 3-Bäumemischung (Alnus glutinosa Betula verrucosa, Corylus avellana), Lösung
62
+ BicaVera 2,3% Glucose Calcium, Peritonealdialyselösung
63
+ Telfastin Allergo 120 comprimés pelliculés 120 mg
64
+ Multaq comprimés pelliculés de 400 mg de dronédarone
65
+ KCL 7,45% Sintetica concentrato per soluzione per infusione (fiala di 20 ml)
66
+ Alk7 Frühblühermischung Depotsuspension zur s.c. Injektion "1 Flasche B"
67
+ Alk7 Gräsermischung und Roggen Depotsuspension zur s.c. Injektion "1 Flasche B"
68
+ Relenza 5 mg Disk (Pulverinhalation)
69
+ Ventolin Dosier-Aerosol (FCKW-frei)
70
+ Axotide 0,125 mg Dosier-Aerosol (FCKW-frei)
71
+ Axotide 0,250 mg Dosier-Aerosol (FCKW-frei)
72
+ Axotide 0,050 mg Dosier-Aerosol (FCKW-frei)
73
+ Serevent Dosier-Aerosol FCKW-frei
74
+ Bronchialpastillen Dr. Welti
75
+ Conoxia Druckgasflasche 300 bar
76
+ Staloral Pollen 3-Bäume Esche 100IR, Lösung zur sublingualen Anwendung
77
+ Staloral Pollen Birke Esche 100IR, Lösung zur sublingualen Anwendung
78
+ Phostal Birke Esche 10IR, Injektionssuspension
79
+ Alustal Birke Esche 10IR, Injektionssuspension
80
+ Alustal 3-Bäume Esche Kombipackung , Injektionssuspension
81
+ Phostal 3-Bäume Esche Kombipackung, Injektionssuspension
82
+ Fisherman's Friend Eucalyptus-Menthol, sans sucre, avec sorbitol, nouvelle formule, pastilles
83
+ Victoza 6 mg/ml Fertigpen (Triple-Dose)
84
+ Fluimucil Erkältungshusten Fertigsirup mit Himbeergeschmack
85
+ Rebif Neue Formulierung 22 Fertigspritzen, Injektionslösung
86
+ Rebif Neue Formulierung 44 Fertigspritzen, Injektionslösung
87
+ Rebif Neue Formulierung 8.8 Fertigspritzen, Injektionslösung
88
+ Bonherba rocks Kräuterzucker, Kräuterbonbon 2,7 g
89
+ Ricola Kräuter, Kräuterbonbons ohne Zucker, 2,5 g
90
+ Testlösung zur Allergiediagnose Teomed Ei ganz, Lösung
91
+ Helena's Fenchelfruchttee ganze Droge
92
+ Intron A 10 Mio. I.E./1 mL gebrauchsfertige, HSA-freie Injektionslösung
93
+ Picato Gel 500 mcg/g
94
+ Duodopa Gel zur intestinalen Anwendung
95
+ Weleda Arnica-Gel Gel, anthroposophisches Arzneimittel
96
+ Burgerstein Vitamin E-Kapseln 400 I.E.
97
+ Solmucol 10 % local i.v., i.m., soluzione iniettabile
98
+ Synacthen (i.m. i.v.), Injektionslösung
99
+ Nutriflex Lipid plus ohne Elektrolyte Infusionsemulsion 1250ml
100
+ Nutriflex Omega plus Infusionsemulsion 1875 ml
101
+ SmofKabiven Infusionsemulsion 1970 ml
102
+ SmofKabiven EF Infusionsemulsion 1970 ml
103
+ Nutriflex Omega special Infusionsemulsion 2500 ml
104
+ Nutriflex Lipid special ohne Elektrolyte Infusionsemulsion 2500ml
105
+ Nutriflex Lipid peri Infusionsemulsion, 1250ml
106
+ Nutriflex Lipid plus Infusionsemulsion, 1250ml
107
+ Nutriflex Lipid special Infusionsemulsion, 1250ml
108
+ Dexdor Infusionskonzentrat 1000ug/10ml
109
+ Peditrace Infusionskonzentrat, Zusatzampulle
110
+ M Classic Eucalyptus Gummipastillen zuckerfrei
111
+ M Classic Halsbonbons zuckerfrei
112
+ Salbisan Halspastillen zuckerfrei
113
+ Madopar LIQ 125 Tabletten zur Herstellung einer Suspension zum Einnehmen
114
+ Anginazol forte tablettes à sucer
115
+ Tisane provençale No 1 tisane laxative, plantes coupées
116
+ )
117
+
118
+ describe ParseGalenicForm do
119
+ context "parse_column_c should work" do
120
+ name, gal_form = ParseGalenicForm.from_string(galenic_tests.first.first)
121
+ specify { expect(name).to eq galenic_tests.first.last[:prepation_name].strip }
122
+ specify { expect(gal_form).to eq galenic_tests.first.last[:galenic_form] }
123
+ end
124
+
125
+ galenic_tests.each{
126
+ |string, expected|
127
+ context "should handle #{string}" do
128
+ name, form = ParseGalenicForm.from_string(string)
129
+ specify { expect(name).to eq expected[:prepation_name].strip }
130
+ specify { expect(form).to eq expected[:galenic_form] }
131
+ end
132
+ }
133
+
134
+ { 'Phytopharma dragées pour le coeur / Herz Dragées' =>
135
+ { :prepation_name=>'Phytopharma dragées pour le coeur', :galenic_form=> 'Herz Dragées' },
136
+ }.each {
137
+ |string, expected|
138
+ context "should handle #{string}" do
139
+ name, form = ParseGalenicForm.from_string(string)
140
+ specify { expect(name).to eq expected[:prepation_name].strip }
141
+ specify { expect(form).to eq expected[:galenic_form] }
142
+ end
143
+ }
144
+ end
145
+
146
+ def test_one_string(parser, string, expected)
147
+ res1 = parser.parse_with_debug(string)
148
+ res1.delete(:qty) if res1
149
+ res1.delete(:unit) if res1
150
+ stringified = res1 ? res1.to_s.gsub(/@\d+/, '') : nil
151
+ if res1 == nil or ! stringified.eql? expected.to_s
152
+ puts "Failed testing: #{string}"
153
+ pp res1
154
+ binding.pry
155
+ end
156
+ expect(stringified).to eq expected.to_s if expected
157
+ end
158
+
159
+ if true then describe GalenicFormParser do
160
+ let(:parser) { GalenicFormParser.new }
161
+ context "identifier parsing" do
162
+ let(:galenic_parser) { parser.galenic }
163
+ let(:qty_unit_parser) { parser.qty_unit }
164
+
165
+ galenic_tests.each{
166
+ |string, expected|
167
+ puts string
168
+ it "parses galenic #{string}" do
169
+ test_one_string(galenic_parser, string, expected)
170
+ end
171
+ }
172
+ end
173
+ end end
174
+
175
+ if RunAllParsingExamples then describe GalenicFormParser do
176
+ context "should parse all lines in #{File.basename(AllColumn_C_Lines)}" do
177
+ let(:galenic_parser) { GalenicFormParser.new.galenic }
178
+ ausgabe = {}
179
+ count = 0
180
+ galenic_parser = GalenicFormParser.new.galenic
181
+ IO.readlines(AllColumn_C_Lines).each {
182
+ |string|
183
+ count += 1
184
+ # break if count > 100
185
+ puts string.strip
186
+ it "parses galenic #{string}" do
187
+ res1 = galenic_parser.parse_with_debug(string.strip)
188
+ if res1
189
+ ausgabe[res1[:prepation_name].to_s] = res1[:galenic_form] if res1
190
+ else
191
+ puts "Failed testing: #{string}"
192
+ pp res1
193
+ # binding.pry
194
+ end
195
+ end
196
+ }
197
+ csv_name = File.join(Oddb2xml::WorkDir, 'galenic.csv')
198
+ at_exit do CSV.open(csv_name, "w+", :col_sep => ';') do |csv|
199
+ ausgabe.each do |key, value|
200
+ csv << [key, value]
201
+ end
202
+ end
203
+ end
204
+ end
205
+ end end
206
+
207
+ describe GalenicFormParser do
208
+ let(:parser) { GalenicFormParser.new }
209
+ context "gal_form parsing" do
210
+ let(:gal_form_parser) { parser.gal_form }
211
+
212
+ should_pass = [
213
+ ', Lösung',
214
+ ', 100mg Lösung',
215
+ 'Lösung',
216
+ '100mg Lösung',
217
+ 'Injektionslösung (i.m., i.v.)',
218
+ ].each {
219
+ |id|
220
+ it "parses gal_form #{id}" do
221
+ expect(gal_form_parser).to parse(id)
222
+ end
223
+ }
224
+ should_not_pass = [
225
+ ].each {
226
+ |id|
227
+ it "parses gal_form #{id}" do
228
+ expect(gal_form_parser).to_not parse(id)
229
+ end
230
+ }
231
+ end
232
+ context "name_gal_form parsing" do
233
+ let(:name_gal_form_parser) { parser.name_gal_form }
234
+
235
+ should_pass = [
236
+ 'Dicloabak 0,1% Augentropfen',
237
+ '35 Clear-Flex 3,86 % Peritonealdialyselösung',
238
+ 'Esmeron 100mg/10ml Injektionslösung',
239
+ ].each {
240
+ |id|
241
+ it "parses name_gal_form #{id}" do
242
+ expect(name_gal_form_parser).to parse(id)
243
+ end
244
+ }
245
+ should_not_pass = [
246
+ ].each {
247
+ |id|
248
+ it "parses name_gal_form #{id}" do
249
+ expect(name_gal_form_parser).to_not parse(id)
250
+ end
251
+ }
252
+ end
253
+
254
+ context "prepation_name parsing" do
255
+ let(:prepation_name_parser) { parser.prepation_name }
256
+
257
+ should_pass = [
258
+ 'name',
259
+ 'name more',
260
+ 'name more and more',
261
+ 'Dicloabak 0,1% Augentropfen',
262
+ ].each {
263
+ |id|
264
+ it "parses prepation_name #{id}" do
265
+ expect(prepation_name_parser).to parse(id)
266
+ end
267
+ }
268
+ should_not_pass = [
269
+ ].each {
270
+ |id|
271
+ it "parses prepation_name #{id}" do
272
+ expect(prepation_name_parser).to_not parse(id)
273
+ end
274
+ }
275
+ end
276
+ context "standard_galenic parsing" do
277
+ let(:standard_galenic_parser) { parser.standard_galenic }
278
+
279
+ should_pass = [
280
+ 'Antithrombin III 500 I.E., Injektionspräparat',
281
+ 'Ondansetron Labatec, 8mg/4ml, concentré pour perfusion',
282
+ ].each {
283
+ |id|
284
+ it "parses standard_galenic #{id}" do
285
+ expect(standard_galenic_parser).to parse(id)
286
+ end
287
+ }
288
+ should_not_pass = [
289
+ 'Dicloabak 0,1% Augentropfen',
290
+ '35 Clear-Flex 3,86 % Peritonealdialyselösung',
291
+ 'Esmeron 100mg/10ml Injektionslösung',
292
+ ].each {
293
+ |id|
294
+ it "parses standard_galenic #{id}" do
295
+ expect(standard_galenic_parser).to_not parse(id)
296
+ end
297
+ }
298
+ end
299
+ context "dose_with_pro parsing" do
300
+ let(:dose_with_pro_parser) { parser.dose_with_pro }
301
+
302
+ should_pass = [
303
+ '100mg/10ml',
304
+ '8mg/4ml',
305
+ ].each {
306
+ |id|
307
+ it "parses dose_with_pro #{id}" do
308
+ expect(dose_with_pro_parser).to parse(id)
309
+ end
310
+ }
311
+ should_not_pass = [
312
+ '100mgx10ml',
313
+ '8mgX4ml',
314
+ ].each {
315
+ |id|
316
+ it "parses dose_with_pro #{id}" do
317
+ expect(dose_with_pro_parser).to_not parse(id)
318
+ end
319
+ }
320
+ end
321
+
322
+
323
+ end
324
+
data/spec/spec_helper.rb CHANGED
@@ -30,6 +30,7 @@ module Oddb2xml
30
30
  end
31
31
 
32
32
  AllCompositionLines = File.expand_path("#{__FILE__}/../data/compositions.txt")
33
+ AllColumn_C_Lines = File.expand_path("#{__FILE__}/../data/column_c.txt")
33
34
 
34
35
  require 'oddb2xml'
35
36