oddb2xml 2.7.1 → 2.7.5
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.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +1 -2
- data/.standard.yml +2 -0
- data/Gemfile +3 -3
- data/History.txt +24 -0
- data/README.md +3 -3
- data/Rakefile +24 -23
- data/bin/check_artikelstamm +11 -11
- data/bin/compare_v5 +23 -23
- data/bin/oddb2xml +14 -13
- data/lib/oddb2xml/builder.rb +1070 -1038
- data/lib/oddb2xml/calc.rb +232 -233
- data/lib/oddb2xml/chapter_70_hack.rb +38 -32
- data/lib/oddb2xml/cli.rb +252 -236
- data/lib/oddb2xml/compare.rb +70 -59
- data/lib/oddb2xml/compositions_syntax.rb +451 -430
- data/lib/oddb2xml/compressor.rb +20 -20
- data/lib/oddb2xml/downloader.rb +157 -129
- data/lib/oddb2xml/extractor.rb +295 -295
- data/lib/oddb2xml/options.rb +34 -35
- data/lib/oddb2xml/parslet_compositions.rb +265 -269
- data/lib/oddb2xml/semantic_check.rb +39 -33
- data/lib/oddb2xml/util.rb +163 -163
- data/lib/oddb2xml/version.rb +1 -1
- data/lib/oddb2xml/xml_definitions.rb +32 -33
- data/lib/oddb2xml.rb +1 -1
- data/oddb2xml.gemspec +34 -34
- data/shell.nix +17 -0
- data/spec/artikelstamm_spec.rb +111 -110
- data/spec/builder_spec.rb +490 -505
- data/spec/calc_spec.rb +552 -593
- data/spec/check_artikelstamm_spec.rb +26 -26
- data/spec/cli_spec.rb +173 -174
- data/spec/compare_spec.rb +9 -11
- data/spec/composition_syntax_spec.rb +390 -409
- data/spec/compressor_spec.rb +48 -48
- data/spec/data/transfer.dat +1 -0
- data/spec/data_helper.rb +47 -49
- data/spec/downloader_spec.rb +251 -260
- data/spec/extractor_spec.rb +171 -159
- data/spec/fixtures/vcr_cassettes/oddb2xml.json +1 -1
- data/spec/galenic_spec.rb +233 -256
- data/spec/options_spec.rb +116 -119
- data/spec/parslet_spec.rb +896 -863
- data/spec/spec_helper.rb +153 -153
- data/test_options.rb +39 -42
- data/tools/win_fetch_cacerts.rb +2 -3
- metadata +42 -12
@@ -1,14 +1,19 @@
|
|
1
|
-
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require 'open-uri'
|
1
|
+
require "oddb2xml/extractor"
|
2
|
+
require "ox"
|
3
|
+
require "open-uri"
|
5
4
|
|
6
5
|
module Oddb2xml
|
7
6
|
class Chapter70xtractor < Extractor
|
8
|
-
def
|
7
|
+
def self.parse_td(elem)
|
9
8
|
begin
|
10
9
|
values = elem.is_a?(Array) ? elem : elem.values
|
11
|
-
res = values.flatten.collect{|x|
|
10
|
+
res = values.flatten.collect { |x|
|
11
|
+
if x.nil?
|
12
|
+
nil
|
13
|
+
else
|
14
|
+
x.is_a?(Hash) ? x.values : x.gsub(/\r\n/, "").strip
|
15
|
+
end
|
16
|
+
}
|
12
17
|
puts "parse_td returns: #{res}" if $VERBOSE
|
13
18
|
rescue => exc
|
14
19
|
puts "Unable to pars #{elem} #{exc}"
|
@@ -18,53 +23,54 @@ module Oddb2xml
|
|
18
23
|
res.flatten # .join("\t")
|
19
24
|
end
|
20
25
|
LIMITATIONS = {
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
26
|
+
"L" => "Kostenübernahme nur nach vorgängiger allergologischer Abklärung.",
|
27
|
+
"L1" => "Eine Flasche zu 20 ml Urtinktur einer bestimmten Pflanze pro Monat.",
|
28
|
+
"L1, L2" => "Eine Flasche zu 20 ml Urtinktur einer bestimmten Pflanze pro Monat. Für Aesculus, Carduus Marianus, Ginkgo, Hedera helix, Hypericum perforatum, Lavandula, Rosmarinus officinalis, Taraxacum officinale.",
|
29
|
+
"L3" => "Alle drei Monate wird eine Verordnung/Originalpackung pro Mittel vergütet."
|
25
30
|
}
|
26
31
|
def self.items
|
27
32
|
@@items
|
28
33
|
end
|
29
|
-
|
30
|
-
|
34
|
+
|
35
|
+
def self.parse(html_file = "http://www.spezialitaetenliste.ch/varia_De.htm")
|
36
|
+
data = Hash.new { |h, k| h[k] = [] }
|
31
37
|
Ox.default_options = {
|
32
|
-
|
33
|
-
|
34
|
-
|
38
|
+
mode: :generic,
|
39
|
+
effort: :tolerant,
|
40
|
+
smart: true
|
35
41
|
}
|
36
|
-
res = Ox.load(Oddb2xml.uri_open(html_file).read, mode: :hash_no_attrs).values.first[
|
42
|
+
res = Ox.load(Oddb2xml.uri_open(html_file).read, mode: :hash_no_attrs).values.first["body"]
|
37
43
|
result = []
|
38
44
|
idx = 0
|
39
45
|
@@items = {}
|
40
46
|
res.values.last.each do |item|
|
41
|
-
item.values.first.each do |
|
42
|
-
what =
|
47
|
+
item.values.first.each do |sub_elem|
|
48
|
+
what = Chapter70xtractor.parse_td(sub_elem)
|
43
49
|
idx += 1
|
44
50
|
puts "#{idx}: xx #{what}" if $VERBOSE
|
45
51
|
result << what
|
46
52
|
end
|
47
53
|
end
|
48
|
-
result2 = result.find_all{ |x| (x.is_a?(Array) && x.first.is_a?(String)) && x.first.to_i > 100}
|
54
|
+
result2 = result.find_all { |x| (x.is_a?(Array) && x.first.is_a?(String)) && x.first.to_i > 100 }
|
49
55
|
result2.each do |entry|
|
50
56
|
data = {}
|
51
57
|
pharma_code = entry.first
|
52
|
-
ean13 =
|
53
|
-
if entry[2].encoding.to_s.eql?(
|
54
|
-
|
58
|
+
ean13 = (Oddb2xml::FAKE_GTIN_START + pharma_code.to_s)
|
59
|
+
german = if entry[2].encoding.to_s.eql?("ASCII-8BIT")
|
60
|
+
CGI.unescape(entry[2].force_encoding("ISO-8859-1"))
|
55
61
|
else
|
56
|
-
|
62
|
+
entry[2]
|
57
63
|
end
|
58
64
|
@@items[ean13] = {
|
59
|
-
:
|
60
|
-
:
|
61
|
-
:
|
62
|
-
:
|
63
|
-
:
|
64
|
-
:
|
65
|
-
:
|
66
|
-
:
|
67
|
-
:
|
65
|
+
data_origin: "Chapter70",
|
66
|
+
line: entry.join(","),
|
67
|
+
ean13: ean13,
|
68
|
+
description: german,
|
69
|
+
quantity: entry[3],
|
70
|
+
pharmacode: pharma_code,
|
71
|
+
pub_price: entry[4],
|
72
|
+
limitation: entry[5],
|
73
|
+
type: :pharma
|
68
74
|
}
|
69
75
|
end
|
70
76
|
result2
|