oddb2xml 2.7.1 → 2.7.2

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.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +1 -1
  3. data/.standard.yml +2 -0
  4. data/Gemfile +3 -3
  5. data/History.txt +8 -0
  6. data/README.md +1 -1
  7. data/Rakefile +24 -23
  8. data/bin/check_artikelstamm +11 -11
  9. data/bin/compare_v5 +23 -23
  10. data/bin/oddb2xml +14 -13
  11. data/lib/oddb2xml.rb +1 -1
  12. data/lib/oddb2xml/builder.rb +1070 -1038
  13. data/lib/oddb2xml/calc.rb +232 -233
  14. data/lib/oddb2xml/chapter_70_hack.rb +38 -32
  15. data/lib/oddb2xml/cli.rb +252 -236
  16. data/lib/oddb2xml/compare.rb +70 -59
  17. data/lib/oddb2xml/compositions_syntax.rb +448 -430
  18. data/lib/oddb2xml/compressor.rb +20 -20
  19. data/lib/oddb2xml/downloader.rb +153 -127
  20. data/lib/oddb2xml/extractor.rb +302 -289
  21. data/lib/oddb2xml/options.rb +34 -35
  22. data/lib/oddb2xml/parslet_compositions.rb +263 -269
  23. data/lib/oddb2xml/semantic_check.rb +39 -33
  24. data/lib/oddb2xml/util.rb +163 -163
  25. data/lib/oddb2xml/version.rb +1 -1
  26. data/lib/oddb2xml/xml_definitions.rb +32 -33
  27. data/oddb2xml.gemspec +31 -32
  28. data/spec/artikelstamm_spec.rb +111 -110
  29. data/spec/builder_spec.rb +489 -505
  30. data/spec/calc_spec.rb +552 -593
  31. data/spec/check_artikelstamm_spec.rb +26 -26
  32. data/spec/cli_spec.rb +173 -174
  33. data/spec/compare_spec.rb +9 -11
  34. data/spec/composition_syntax_spec.rb +390 -409
  35. data/spec/compressor_spec.rb +48 -48
  36. data/spec/data/transfer.dat +1 -0
  37. data/spec/data_helper.rb +47 -49
  38. data/spec/downloader_spec.rb +247 -260
  39. data/spec/extractor_spec.rb +171 -159
  40. data/spec/galenic_spec.rb +233 -256
  41. data/spec/options_spec.rb +116 -119
  42. data/spec/parslet_spec.rb +833 -861
  43. data/spec/spec_helper.rb +154 -153
  44. data/test_options.rb +39 -42
  45. data/tools/win_fetch_cacerts.rb +2 -3
  46. metadata +19 -3
data/spec/galenic_spec.rb CHANGED
@@ -1,322 +1,299 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
1
+ require "spec_helper"
4
2
  require "#{Dir.pwd}/lib/oddb2xml/parslet_compositions"
5
- require 'parslet/rig/rspec'
6
- require 'parslet/convenience'
7
- require 'csv'
3
+ require "parslet/rig/rspec"
4
+ require "parslet/convenience"
5
+ require "csv"
8
6
 
9
- RunAllParsingExamples = false # RunAllParsingExamples /travis|localhost/i.match(hostname) != nil # takes about one minute to run
7
+ RUN_ALL_PARSING_EXAMPLES = false # RUN_ALL_PARSING_EXAMPLES /travis|localhost/i.match(hostname) != nil # takes about one minute to run
10
8
 
11
9
  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
-
10
+ "1001 Blattgrün Dragées" => {prepation_name: "1001 Blattgrün ", galenic_form: "Dragées"},
11
+ "3TC 150 mg, Filmtabletten" => {prepation_name: "3TC 150 mg", galenic_form: "Filmtabletten"},
12
+ "Acetocaustin, Lösung" => {prepation_name: "Acetocaustin", galenic_form: "Lösung"},
13
+ "Alustal 3-Bäume, Injektionssuspension" => {prepation_name: "Alustal 3-Bäume", galenic_form: "Injektionssuspension"},
14
+ "Alustal Bäume, Injektionssuspension" => {prepation_name: "Alustal Bäume", galenic_form: "Injektionssuspension"},
15
+ "Amoxicillin Streuli, Granulat zur Herstellung einer Suspension" => {prepation_name: "Amoxicillin Streuli", galenic_form: "Granulat zur Herstellung einer Suspension"},
16
+ "Arkocaps Passiflore/Passionsblume, 300 mg, capsules" => {prepation_name: "Arkocaps Passiflore/Passionsblume", galenic_form: "capsules"},
17
+ "Atenativ, Antithrombin III 500 I.E., Injektionspräparat" => {prepation_name: "Atenativ", galenic_form: "Injektionspräparat"},
18
+ "Atorvastatin Helvepharm, 10 mg Filmtabletten" => {prepation_name: "Atorvastatin Helvepharm", galenic_form: "Filmtabletten"},
19
+ "Atorvastax-Drossapharm 20 mg" => {prepation_name: "Atorvastax-Drossapharm 20 mg", galenic_form: nil},
20
+ "Co-Losartan Spirig HC 50/12,5 mg" => {prepation_name: "Co-Losartan Spirig HC 50/12,5 mg", galenic_form: nil},
21
+ "Dicloabak 0,1% Augentropfen" => {prepation_name: "Dicloabak 0,1% ", galenic_form: "Augentropfen"},
22
+ "Kaliumchlorid 14,9 % B. Braun, Zusatzampullen" => {prepation_name: "Kaliumchlorid 14,9 % B. Braun", galenic_form: "Zusatzampullen"},
23
+ "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"},
24
+ "Nitroderm TTS 10" => {prepation_name: "Nitroderm TTS 10", galenic_form: nil},
25
+ "Ondansetron Labatec, 8mg/4ml, concentré pour perfusion" => {prepation_name: "Ondansetron Labatec", galenic_form: "concentré pour perfusion"},
26
+ "Paronex 20, Filmtabletten" => {prepation_name: "Paronex 20", galenic_form: "Filmtabletten"},
27
+ "Physioneal 35 Clear-Flex 3,86 % Peritonealdialyselösung" => {prepation_name: "Physioneal 35 Clear-Flex 3,86 % ", galenic_form: "Peritonealdialyselösung"},
28
+ "Phytopharma foie et bile capsules/Leber-Galle Kapseln" => {prepation_name: "Phytopharma foie et bile capsules", galenic_form: "Leber-Galle Kapseln"},
29
+ "Plak-out Spray 0,1 %" => {prepation_name: "Plak-out Spray 0,1 %", galenic_form: nil},
30
+ "Sandostatin 0,2 mg/mL, Injektionslösung" => {prepation_name: "Sandostatin 0,2 mg/mL", galenic_form: "Injektionslösung"},
31
+ "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"},
32
+ "Tramal 100, Injektionslösung (i.m., i.v.)" => {prepation_name: "Tramal 100", galenic_form: "Injektionslösung (i.m., i.v.)"},
33
+ "Uman Albumin Kedrion 20%" => {prepation_name: "Uman Albumin Kedrion 20%", galenic_form: nil}
34
+ }
35
+ x = %(
36
+ Testlösung zur Allergiediagnose Teomed Kaninchen (Fell) Lösung
37
+ Testlösung zur Allergiediagnose Teomed Hund (Haare) Lösung
38
+ Pandemrix (Pandemic Influenza Vaccine H1N1)
39
+ Phytopharma dragées pour la détente et le sommeil / Entspannungs- und Schlafdragées
40
+ Phytopharma dragées pour le coeur / Herz Dragées
41
+ Best Friend Katzenhalsband / Katzenhalsband Reflex ad us.vet.
42
+ Amlodipin Helvepharm 10 Tabletten
43
+ Salbu Orion Easyhaler 100 ug Inhalationspulver
44
+ TISSEEL 10 ml 2 Fertigspritzen
45
+ TISSEEL 2 ml 2 Fertigspritzen
46
+ TISSEEL 4 ml 2 Fertigspritzen
47
+ Norprolac Starter-pack 25 ug + 50 ug, Tabletten
48
+ Phostal 5-Gräser 4-Getreidemischung 10IR, Injektionssuspension
49
+ Alustal 5-Gräser 4-Getreidemischung Kombipackung, Injektionssuspension
50
+ Staloral Beifuss 5-Gräser 100IR, Injektionssuspension
51
+ Phostal Beifuss 5-Gräser 10IR, Injektionssuspension
52
+ Alustal Beifuss 5-Gräser 10IR, Injektionssuspension
53
+ Seebri Breezhaler 50 Mikrogramm, Pulver zur Inhalation, Hartkapseln
54
+ Nplate 500 mcg Pulver und Lösungsmittel zur Herstellung einer Injektionslösung
55
+ Bayvantage ad us.vet. 80 für Katzen, Lösung
56
+ Ondansetron-Teva 8mg, Filmtabletten
57
+ Soluprick SQ 3-Bäumemischung (Alnus glutinosa Betula verrucosa, Corylus avellana), Lösung
58
+ BicaVera 2,3% Glucose Calcium, Peritonealdialyselösung
59
+ Telfastin Allergo 120 comprimés pelliculés 120 mg
60
+ Multaq comprimés pelliculés de 400 mg de dronédarone
61
+ KCL 7,45% Sintetica concentrato per soluzione per infusione (fiala di 20 ml)
62
+ Alk7 Frühblühermischung Depotsuspension zur s.c. Injektion "1 Flasche B"
63
+ Alk7 Gräsermischung und Roggen Depotsuspension zur s.c. Injektion "1 Flasche B"
64
+ Relenza 5 mg Disk (Pulverinhalation)
65
+ Ventolin Dosier-Aerosol (FCKW-frei)
66
+ Axotide 0,125 mg Dosier-Aerosol (FCKW-frei)
67
+ Axotide 0,250 mg Dosier-Aerosol (FCKW-frei)
68
+ Axotide 0,050 mg Dosier-Aerosol (FCKW-frei)
69
+ Serevent Dosier-Aerosol FCKW-frei
70
+ Bronchialpastillen Dr. Welti
71
+ Conoxia Druckgasflasche 300 bar
72
+ Staloral Pollen 3-Bäume Esche 100IR, Lösung zur sublingualen Anwendung
73
+ Staloral Pollen Birke Esche 100IR, Lösung zur sublingualen Anwendung
74
+ Phostal Birke Esche 10IR, Injektionssuspension
75
+ Alustal Birke Esche 10IR, Injektionssuspension
76
+ Alustal 3-Bäume Esche Kombipackung , Injektionssuspension
77
+ Phostal 3-Bäume Esche Kombipackung, Injektionssuspension
78
+ Fisherman's Friend Eucalyptus-Menthol, sans sucre, avec sorbitol, nouvelle formule, pastilles
79
+ Victoza 6 mg/ml Fertigpen (Triple-Dose)
80
+ Fluimucil Erkältungshusten Fertigsirup mit Himbeergeschmack
81
+ Rebif Neue Formulierung 22 Fertigspritzen, Injektionslösung
82
+ Rebif Neue Formulierung 44 Fertigspritzen, Injektionslösung
83
+ Rebif Neue Formulierung 8.8 Fertigspritzen, Injektionslösung
84
+ Bonherba rocks Kräuterzucker, Kräuterbonbon 2,7 g
85
+ Ricola Kräuter, Kräuterbonbons ohne Zucker, 2,5 g
86
+ Testlösung zur Allergiediagnose Teomed Ei ganz, Lösung
87
+ Helena's Fenchelfruchttee ganze Droge
88
+ Intron A 10 Mio. I.E./1 mL gebrauchsfertige, HSA-freie Injektionslösung
89
+ Picato Gel 500 mcg/g
90
+ Duodopa Gel zur intestinalen Anwendung
91
+ Weleda Arnica-Gel Gel, anthroposophisches Arzneimittel
92
+ Burgerstein Vitamin E-Kapseln 400 I.E.
93
+ Solmucol 10 % local i.v., i.m., soluzione iniettabile
94
+ Synacthen (i.m. i.v.), Injektionslösung
95
+ Nutriflex Lipid plus ohne Elektrolyte Infusionsemulsion 1250ml
96
+ Nutriflex Omega plus Infusionsemulsion 1875 ml
97
+ SmofKabiven Infusionsemulsion 1970 ml
98
+ SmofKabiven EF Infusionsemulsion 1970 ml
99
+ Nutriflex Omega special Infusionsemulsion 2500 ml
100
+ Nutriflex Lipid special ohne Elektrolyte Infusionsemulsion 2500ml
101
+ Nutriflex Lipid peri Infusionsemulsion, 1250ml
102
+ Nutriflex Lipid plus Infusionsemulsion, 1250ml
103
+ Nutriflex Lipid special Infusionsemulsion, 1250ml
104
+ Dexdor Infusionskonzentrat 1000ug/10ml
105
+ Peditrace Infusionskonzentrat, Zusatzampulle
106
+ M Classic Eucalyptus Gummipastillen zuckerfrei
107
+ M Classic Halsbonbons zuckerfrei
108
+ Salbisan Halspastillen zuckerfrei
109
+ Madopar LIQ 125 Tabletten zur Herstellung einer Suspension zum Einnehmen
110
+ Anginazol forte tablettes à sucer
111
+ Tisane provençale No 1 tisane laxative, plantes coupées
112
+ )
113
+ puts "Have #{x.split("\n").size} more examples toDO"
118
114
  describe ParseGalenicForm do
119
115
  context "parse_column_c should work" do
120
- name, gal_form = ParseGalenicForm.from_string(galenic_tests.first.first)
116
+ name, gal_form = ParseGalenicForm.from_string(galenic_tests.first.first)
121
117
  specify { expect(name).to eq galenic_tests.first.last[:prepation_name].strip }
122
118
  specify { expect(gal_form).to eq galenic_tests.first.last[:galenic_form] }
123
119
  end
124
120
 
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
121
+ galenic_tests.each { |string, expected|
122
+ context "should handle #{string}" do
123
+ name, form = ParseGalenicForm.from_string(string)
124
+ specify { expect(name).to eq expected[:prepation_name].strip }
125
+ specify { expect(form).to eq expected[:galenic_form] }
126
+ end
132
127
  }
133
128
 
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
129
+ {"Phytopharma dragées pour le coeur / Herz Dragées" =>
130
+ {prepation_name: "Phytopharma dragées pour le coeur", galenic_form: "Herz Dragées"}}.each { |string, expected|
131
+ context "should handle #{string}" do
132
+ name, form = ParseGalenicForm.from_string(string)
133
+ specify { expect(name).to eq expected[:prepation_name].strip }
134
+ specify { expect(form).to eq expected[:galenic_form] }
135
+ end
143
136
  }
144
137
  end
145
138
 
146
139
  def test_one_string(parser, string, expected)
147
140
  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}"; binding.pry
141
+ res1&.delete(:qty)
142
+ res1&.delete(:unit)
143
+ stringified = res1 ? res1.to_s.gsub(/@\d+/, "") : nil
144
+ if res1.nil? || !stringified.eql?(expected.to_s)
145
+ puts "Failed testing: #{string}"
153
146
  end
154
147
  expect(stringified).to eq expected.to_s if expected
155
148
  end
156
149
 
157
- if true then describe GalenicFormParser do
150
+ describe GalenicFormParser do
158
151
  let(:parser) { GalenicFormParser.new }
159
152
  context "identifier parsing" do
160
153
  let(:galenic_parser) { parser.galenic }
161
154
  let(:qty_unit_parser) { parser.qty_unit }
162
155
 
163
- galenic_tests.each{
164
- |string, expected|
165
- puts string
166
- it "parses galenic #{string}" do
167
- test_one_string(galenic_parser, string, expected)
168
- end
156
+ galenic_tests.each { |string, expected|
157
+ puts string
158
+ it "parses galenic #{string}" do
159
+ test_one_string(galenic_parser, string, expected)
160
+ end
169
161
  }
170
162
  end
171
- end end
163
+ end
172
164
 
173
- if RunAllParsingExamples then describe GalenicFormParser do
165
+ if RUN_ALL_PARSING_EXAMPLES then describe GalenicFormParser do
174
166
  context "should parse all lines in #{File.basename(AllColumn_C_Lines)}" do
175
167
  let(:galenic_parser) { GalenicFormParser.new.galenic }
176
168
  ausgabe = {}
177
169
  count = 0
178
170
  galenic_parser = GalenicFormParser.new.galenic
179
- IO.readlines(AllColumn_C_Lines).each {
180
- |string|
181
- count += 1
182
- # break if count > 100
183
- puts string.strip
184
- it "parses galenic #{string}" do
185
- res1 = galenic_parser.parse_with_debug(string.strip)
186
- if res1
187
- ausgabe[res1[:prepation_name].to_s] = res1[:galenic_form] if res1
188
- else
189
- puts "Failed testing: #{string}"
190
- pp res1
191
- # binding.pry
192
- end
171
+ IO.readlines(AllColumn_C_Lines).each { |string|
172
+ count += 1
173
+ # break if count > 100
174
+ puts string.strip
175
+ it "parses galenic #{string}" do
176
+ res1 = galenic_parser.parse_with_debug(string.strip)
177
+ if res1
178
+ ausgabe[res1[:prepation_name].to_s] = res1[:galenic_form] if res1
179
+ else
180
+ puts "Failed testing: #{string}"
181
+ pp res1
182
+ # binding.pry
193
183
  end
184
+ end
194
185
  }
195
- csv_name = File.join(Oddb2xml::WorkDir, 'galenic.csv')
196
- at_exit do CSV.open(csv_name, "w+", :col_sep => ';') do |csv|
186
+ csv_name = File.join(Oddb2xml::WORK_DIR, "galenic.csv")
187
+ at_exit do
188
+ CSV.open(csv_name, "w+", col_sep: ";") do |csv|
197
189
  ausgabe.each do |key, value|
198
- csv << [key, value]
190
+ csv << [key, value]
199
191
  end
200
192
  end
201
193
  end
202
194
  end
203
- end end
195
+ end
196
+ end
204
197
 
205
198
  describe GalenicFormParser do
206
199
  let(:parser) { GalenicFormParser.new }
207
200
  context "gal_form parsing" do
208
201
  let(:gal_form_parser) { parser.gal_form }
209
202
 
210
- should_pass = [
211
- ', Lösung',
212
- ', 100mg Lösung',
213
- 'Lösung',
214
- '100mg Lösung',
215
- 'Injektionslösung (i.m., i.v.)',
216
- ].each {
217
- |id|
218
- it "parses gal_form #{id}" do
219
- expect(gal_form_parser).to parse(id)
220
- end
221
- }
222
- should_not_pass = [
223
- ].each {
224
- |id|
225
- it "parses gal_form #{id}" do
226
- expect(gal_form_parser).to_not parse(id)
227
- end
228
- }
203
+ [
204
+ ", Lösung",
205
+ ", 100mg Lösung",
206
+ "Lösung",
207
+ "100mg Lösung",
208
+ "Injektionslösung (i.m., i.v.)"
209
+ ].each { |id|
210
+ it "parses gal_form #{id}" do
211
+ expect(gal_form_parser).to parse(id)
212
+ end
213
+ }
214
+ [].each { |id|
215
+ it "parses gal_form #{id}" do
216
+ expect(gal_form_parser).to_not parse(id)
217
+ end
218
+ }
229
219
  end
230
220
  context "name_gal_form parsing" do
231
221
  let(:name_gal_form_parser) { parser.name_gal_form }
232
222
 
233
- should_pass = [
234
- 'Dicloabak 0,1% Augentropfen',
235
- '35 Clear-Flex 3,86 % Peritonealdialyselösung',
236
- 'Esmeron 100mg/10ml Injektionslösung',
237
- ].each {
238
- |id|
239
- it "parses name_gal_form #{id}" do
240
- expect(name_gal_form_parser).to parse(id)
241
- end
242
- }
243
- should_not_pass = [
244
- ].each {
245
- |id|
246
- it "parses name_gal_form #{id}" do
247
- expect(name_gal_form_parser).to_not parse(id)
248
- end
249
- }
223
+ [
224
+ "Dicloabak 0,1% Augentropfen",
225
+ "35 Clear-Flex 3,86 % Peritonealdialyselösung",
226
+ "Esmeron 100mg/10ml Injektionslösung"
227
+ ].each { |id|
228
+ it "parses name_gal_form #{id}" do
229
+ expect(name_gal_form_parser).to parse(id)
230
+ end
231
+ }
232
+ [].each { |id|
233
+ it "parses name_gal_form #{id}" do
234
+ expect(name_gal_form_parser).to_not parse(id)
235
+ end
236
+ }
250
237
  end
251
238
 
252
239
  context "prepation_name parsing" do
253
240
  let(:prepation_name_parser) { parser.prepation_name }
254
241
 
255
- should_pass = [
256
- 'name',
257
- 'name more',
258
- 'name more and more',
259
- 'Dicloabak 0,1% Augentropfen',
260
- ].each {
261
- |id|
262
- it "parses prepation_name #{id}" do
263
- expect(prepation_name_parser).to parse(id)
264
- end
265
- }
266
- should_not_pass = [
267
- ].each {
268
- |id|
269
- it "parses prepation_name #{id}" do
270
- expect(prepation_name_parser).to_not parse(id)
271
- end
272
- }
242
+ [
243
+ "name",
244
+ "name more",
245
+ "name more and more",
246
+ "Dicloabak 0,1% Augentropfen"
247
+ ].each { |id|
248
+ it "parses prepation_name #{id}" do
249
+ expect(prepation_name_parser).to parse(id)
250
+ end
251
+ }
252
+ [].each { |id|
253
+ it "parses prepation_name #{id}" do
254
+ expect(prepation_name_parser).to_not parse(id)
255
+ end
256
+ }
273
257
  end
274
258
  context "standard_galenic parsing" do
275
259
  let(:standard_galenic_parser) { parser.standard_galenic }
276
260
 
277
- should_pass = [
278
- 'Antithrombin III 500 I.E., Injektionspräparat',
279
- 'Ondansetron Labatec, 8mg/4ml, concentré pour perfusion',
280
- ].each {
281
- |id|
282
- it "parses standard_galenic #{id}" do
283
- expect(standard_galenic_parser).to parse(id)
284
- end
285
- }
286
- should_not_pass = [
287
- 'Dicloabak 0,1% Augentropfen',
288
- '35 Clear-Flex 3,86 % Peritonealdialyselösung',
289
- 'Esmeron 100mg/10ml Injektionslösung',
290
- ].each {
291
- |id|
292
- it "parses standard_galenic #{id}" do
293
- expect(standard_galenic_parser).to_not parse(id)
294
- end
295
- }
261
+ [
262
+ "Antithrombin III 500 I.E., Injektionspräparat",
263
+ "Ondansetron Labatec, 8mg/4ml, concentré pour perfusion"
264
+ ].each { |id|
265
+ it "parses standard_galenic #{id}" do
266
+ expect(standard_galenic_parser).to parse(id)
267
+ end
268
+ }
269
+ [
270
+ "Dicloabak 0,1% Augentropfen",
271
+ "35 Clear-Flex 3,86 % Peritonealdialyselösung",
272
+ "Esmeron 100mg/10ml Injektionslösung"
273
+ ].each { |id|
274
+ it "parses standard_galenic #{id}" do
275
+ expect(standard_galenic_parser).to_not parse(id)
276
+ end
277
+ }
296
278
  end
297
279
  context "dose_with_pro parsing" do
298
280
  let(:dose_with_pro_parser) { parser.dose_with_pro }
299
281
 
300
- should_pass = [
301
- '100mg/10ml',
302
- '8mg/4ml',
303
- ].each {
304
- |id|
305
- it "parses dose_with_pro #{id}" do
306
- expect(dose_with_pro_parser).to parse(id)
307
- end
308
- }
309
- should_not_pass = [
310
- '100mgx10ml',
311
- '8mgX4ml',
312
- ].each {
313
- |id|
314
- it "parses dose_with_pro #{id}" do
315
- expect(dose_with_pro_parser).to_not parse(id)
316
- end
317
- }
282
+ [
283
+ "100mg/10ml",
284
+ "8mg/4ml"
285
+ ].each { |id|
286
+ it "parses dose_with_pro #{id}" do
287
+ expect(dose_with_pro_parser).to parse(id)
288
+ end
289
+ }
290
+ [
291
+ "100mgx10ml",
292
+ "8mgX4ml"
293
+ ].each { |id|
294
+ it "parses dose_with_pro #{id}" do
295
+ expect(dose_with_pro_parser).to_not parse(id)
296
+ end
297
+ }
318
298
  end
319
-
320
-
321
299
  end
322
-