oddb2xml 1.8.5 → 1.8.6
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/Gemfile.lock +3 -3
- data/History.txt +5 -0
- data/lib/oddb2xml/builder.rb +77 -81
- data/lib/oddb2xml/cli.rb +6 -8
- data/lib/oddb2xml/extractor.rb +1 -1
- data/lib/oddb2xml/version.rb +1 -1
- data/spec/builder_spec.rb +60 -7
- data/spec/data/swissindex_pharma.xml +15 -1
- data/spec/data/zurrose_transfer.dat +1 -0
- data/spec/extractor_spec.rb +16 -11
- metadata +2 -2
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
oddb2xml (1.8.
|
4
|
+
oddb2xml (1.8.6)
|
5
5
|
archive-tar-minitar (~> 0.5.2)
|
6
6
|
mechanize (~> 2.5.1)
|
7
7
|
nokogiri (~> 1.5.10)
|
@@ -31,7 +31,7 @@ GEM
|
|
31
31
|
debugger-linecache (1.2.0)
|
32
32
|
debugger-ruby_core_source (1.3.2)
|
33
33
|
diff-lcs (1.2.5)
|
34
|
-
domain_name (0.5.
|
34
|
+
domain_name (0.5.19)
|
35
35
|
unf (>= 0.0.5, < 1.0.0)
|
36
36
|
gyoku (1.1.1)
|
37
37
|
builder (>= 2.1.2)
|
@@ -78,7 +78,7 @@ GEM
|
|
78
78
|
nokogiri (>= 1.4.4)
|
79
79
|
rubyzip (>= 1.0.0)
|
80
80
|
rubyntlm (0.3.4)
|
81
|
-
rubyzip (1.1.
|
81
|
+
rubyzip (1.1.6)
|
82
82
|
safe_yaml (1.0.3)
|
83
83
|
savon (2.4.0)
|
84
84
|
akami (~> 1.2.0)
|
data/History.txt
CHANGED
data/lib/oddb2xml/builder.rb
CHANGED
@@ -26,7 +26,7 @@ module Oddb2xml
|
|
26
26
|
class Builder
|
27
27
|
attr_accessor :subject, :index, :items, :flags, :lppvs,
|
28
28
|
:actions, :migel, :orphans, :fridges,
|
29
|
-
:infos, :packs, :
|
29
|
+
:infos, :packs, :infos_zur_rose,
|
30
30
|
:ean14, :tag_suffix,
|
31
31
|
:companies, :people,
|
32
32
|
:xsd
|
@@ -40,7 +40,7 @@ module Oddb2xml
|
|
40
40
|
@infos = {}
|
41
41
|
@packs = {}
|
42
42
|
@migel = {}
|
43
|
-
@
|
43
|
+
@infos_zur_rose = {} # zurrose
|
44
44
|
@actions = []
|
45
45
|
@orphans = []
|
46
46
|
@fridges = []
|
@@ -98,7 +98,6 @@ module Oddb2xml
|
|
98
98
|
entry = {
|
99
99
|
:ean => migel[:ean],
|
100
100
|
:pharmacode => migel[:pharmacode],
|
101
|
-
:status => 'I',
|
102
101
|
:stat_date => '',
|
103
102
|
:lang => lang.capitalize,
|
104
103
|
:desc => migel["desc_#{lang}".intern],
|
@@ -126,7 +125,7 @@ module Oddb2xml
|
|
126
125
|
}
|
127
126
|
}
|
128
127
|
Oddb2xml.log("prepare_articles extended")
|
129
|
-
@
|
128
|
+
@infos_zur_rose.each{
|
130
129
|
|ean13, info|
|
131
130
|
pharmacode = info[:pharmacode]
|
132
131
|
if @pharmacode[pharmacode]
|
@@ -147,7 +146,7 @@ module Oddb2xml
|
|
147
146
|
else
|
148
147
|
entry = {
|
149
148
|
:desc => info[:description],
|
150
|
-
:status => 'A', #
|
149
|
+
:status => info[:status] == '3' ? 'I' : 'A', # from ZurRose, we got 1,2 or 3 means aktive, aka available in trade
|
151
150
|
:atc_code => '',
|
152
151
|
:ean => ean13,
|
153
152
|
:lang => lang.capitalize,
|
@@ -605,9 +604,9 @@ module Oddb2xml
|
|
605
604
|
if no8
|
606
605
|
ppac = ((_ppac = pack_info and !_ppac[:is_tier]) ? _ppac : nil)
|
607
606
|
end
|
608
|
-
|
609
|
-
if !@
|
610
|
-
|
607
|
+
info_zur_rose = nil
|
608
|
+
if !@infos_zur_rose.empty? && ean && @infos_zur_rose[ean]
|
609
|
+
info_zur_rose = @infos_zur_rose[ean] # zurrose
|
611
610
|
end
|
612
611
|
xml.ART('DT' => '') {
|
613
612
|
xml.REF_DATA (de_idx[:refdata] || @migel[pharma_code]) ? '1' : '0'
|
@@ -629,13 +628,11 @@ module Oddb2xml
|
|
629
628
|
#xml.HOSPCD
|
630
629
|
#xml.CLINCD
|
631
630
|
#xml.ARTTYP
|
632
|
-
if
|
633
|
-
xml.VAT
|
631
|
+
if info_zur_rose
|
632
|
+
xml.VAT info_zur_rose[:vat]
|
634
633
|
end
|
635
634
|
|
636
|
-
|
637
|
-
xml.SALECD(de_idx[:status].empty? ? 'N' : de_idx[:status]) # XML_OPTIONS
|
638
|
-
end
|
635
|
+
xml.SALECD( (info_zur_rose && info_zur_rose[:cmut] != '3') ? 'A' : 'I') # XML_OPTIONS
|
639
636
|
if pac and pac[:limitation_points]
|
640
637
|
#xml.INSLIM
|
641
638
|
xml.LIMPTS pac[:limitation_points] unless pac[:limitation_points].empty?
|
@@ -684,7 +681,7 @@ module Oddb2xml
|
|
684
681
|
#xml.BAGSL
|
685
682
|
#xml.BAGSLC
|
686
683
|
#xml.LOACD
|
687
|
-
if de_idx[:
|
684
|
+
if de_idx[:stat_date]
|
688
685
|
xml.OUTSAL de_idx[:stat_date] if de_idx[:stat_date] and not de_idx[:stat_date].empty?
|
689
686
|
end
|
690
687
|
#xml.STTOX
|
@@ -728,16 +725,16 @@ module Oddb2xml
|
|
728
725
|
}
|
729
726
|
end
|
730
727
|
end
|
731
|
-
if
|
728
|
+
if info_zur_rose
|
732
729
|
xml.ARTPRI {
|
733
730
|
xml.VDAT Time.parse(datetime).strftime("%d.%m.%Y")
|
734
731
|
xml.PTYP "ZURROSE"
|
735
|
-
xml.PRICE
|
732
|
+
xml.PRICE info_zur_rose[:price]
|
736
733
|
}
|
737
734
|
xml.ARTPRI {
|
738
735
|
xml.VDAT Time.parse(datetime).strftime("%d.%m.%Y")
|
739
736
|
xml.PTYP "ZURROSEPUB"
|
740
|
-
xml.PRICE
|
737
|
+
xml.PRICE info_zur_rose[:pub_price]
|
741
738
|
}
|
742
739
|
end
|
743
740
|
#xml.ARTMIG {
|
@@ -996,71 +993,70 @@ module Oddb2xml
|
|
996
993
|
row = ''
|
997
994
|
pack_info = nil
|
998
995
|
# Oddb2tdat.parse
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
pac = ppac if ppac
|
1015
|
-
end
|
1016
|
-
row << "%#{DAT_LEN[:RECA]}s" % '11'
|
1017
|
-
row << "%#{DAT_LEN[:CMUT]}s" % if (phar = idx[:pharmacode] and phar.size > 3) # does not check expiration_date
|
1018
|
-
idx[:status] == 'I' ? '3' : '1'
|
1019
|
-
else
|
1020
|
-
'3'
|
1021
|
-
end
|
1022
|
-
row << "%0#{DAT_LEN[:PHAR]}d" % idx[:pharmacode].to_i
|
1023
|
-
abez = ( # de name
|
1024
|
-
idx[:desc].to_s + " " +
|
1025
|
-
(pac ? pac[:name_de].to_s : '') +
|
1026
|
-
(idx[:additional_desc] ? idx[:additional_desc] : '')
|
1027
|
-
).gsub(/"/, '')
|
1028
|
-
row << format_name(abez)
|
1029
|
-
row << "%#{DAT_LEN[:PRMO]}s" % (pac ? format_price(pac[:prices][:exf_price][:price].to_s) : ('0' * DAT_LEN[:PRMO]))
|
1030
|
-
row << "%#{DAT_LEN[:PRPU]}s" % (pac ? format_price(pac[:prices][:pub_price][:price].to_s) : ('0' * DAT_LEN[:PRPU]))
|
1031
|
-
row << "%#{DAT_LEN[:CKZL]}s" % if (@lppvs[ean])
|
1032
|
-
'2'
|
1033
|
-
elsif pac # sl_entry
|
1034
|
-
'1'
|
1035
|
-
else
|
1036
|
-
'3'
|
1037
|
-
end
|
1038
|
-
row << "%#{DAT_LEN[:CLAG]}s" % if ((no8 && no8.to_s =~ /(\d{5})(\d{3})/) and
|
1039
|
-
@fridges.include?($1.to_s))
|
1040
|
-
'1'
|
1041
|
-
else
|
1042
|
-
'0'
|
1043
|
-
end
|
1044
|
-
row << "%#{DAT_LEN[:CBGG]}s" % if ((pac && pac[:narcosis_flag] == 'Y') or # BAGXml
|
1045
|
-
(@flags[ean])) # ywesee BM_update
|
1046
|
-
'3'
|
1047
|
-
else
|
1048
|
-
'0'
|
1049
|
-
end
|
1050
|
-
row << "%#{DAT_LEN[:CIKS]}s" % if (no8 && pack_info && !pack_info[:is_tier]) # Packungen.xls
|
1051
|
-
pack_info[:swissmedic_category]
|
1052
|
-
else
|
1053
|
-
'0'
|
1054
|
-
end.gsub(/(\+|\s)/, '')
|
1055
|
-
row << "%0#{DAT_LEN[:ITHE]}d" % if (no8 && pack_info && !pack_info[:is_tier])
|
1056
|
-
format_date(pack_info[:ith_swissmedic])
|
1057
|
-
else
|
1058
|
-
('0' * DAT_LEN[:ITHE])
|
1059
|
-
end.to_i
|
1060
|
-
row << "%0#{DAT_LEN[:CEAN]}d" % (ean.match(/^000000/) ? 0 : ean.to_i)
|
1061
|
-
row << "%#{DAT_LEN[:CMWS]}s" % '2' # pharma
|
1062
|
-
rows << row
|
996
|
+
pac,no8 = nil,nil
|
997
|
+
if obj[:seq] and obj[:seq][:packages]
|
998
|
+
pac = obj[:seq][:packages][idx[:pharmacode]]
|
999
|
+
pac = obj[:seq][:packages][ean] unless pac
|
1000
|
+
else
|
1001
|
+
pac = @items[ean][:packages][ean] if @items and @items[ean] and @items[ean][:packages]
|
1002
|
+
end
|
1003
|
+
# :swissmedic_numbers
|
1004
|
+
if pac
|
1005
|
+
no8 = pac[:swissmedic_number8].intern
|
1006
|
+
pack_info = @packs[no8.intern] if no8
|
1007
|
+
end
|
1008
|
+
if pac and pac[:prices] == nil and no8
|
1009
|
+
ppac = ((ppac = pack_info and ppac[:is_tier]) ? ppac : nil)
|
1010
|
+
pac = ppac if ppac
|
1063
1011
|
end
|
1012
|
+
row << "%#{DAT_LEN[:RECA]}s" % '11'
|
1013
|
+
info_zur_rose = @infos_zur_rose[ean] # zurrose
|
1014
|
+
if info_zur_rose && info_zur_rose[:cmut]
|
1015
|
+
row << info_zur_rose[:cmut]
|
1016
|
+
else
|
1017
|
+
row << '1'
|
1018
|
+
end
|
1019
|
+
row << "%0#{DAT_LEN[:PHAR]}d" % idx[:pharmacode].to_i
|
1020
|
+
abez = ( # de name
|
1021
|
+
idx[:desc].to_s + " " +
|
1022
|
+
(pac ? pac[:name_de].to_s : '') +
|
1023
|
+
(idx[:additional_desc] ? idx[:additional_desc] : '')
|
1024
|
+
).gsub(/"/, '')
|
1025
|
+
row << format_name(abez)
|
1026
|
+
row << "%#{DAT_LEN[:PRMO]}s" % (pac ? format_price(pac[:prices][:exf_price][:price].to_s) : ('0' * DAT_LEN[:PRMO]))
|
1027
|
+
row << "%#{DAT_LEN[:PRPU]}s" % (pac ? format_price(pac[:prices][:pub_price][:price].to_s) : ('0' * DAT_LEN[:PRPU]))
|
1028
|
+
row << "%#{DAT_LEN[:CKZL]}s" % if (@lppvs[ean])
|
1029
|
+
'2'
|
1030
|
+
elsif pac # sl_entry
|
1031
|
+
'1'
|
1032
|
+
else
|
1033
|
+
'3'
|
1034
|
+
end
|
1035
|
+
row << "%#{DAT_LEN[:CLAG]}s" % if ((no8 && no8.to_s =~ /(\d{5})(\d{3})/) and
|
1036
|
+
@fridges.include?($1.to_s))
|
1037
|
+
'1'
|
1038
|
+
else
|
1039
|
+
'0'
|
1040
|
+
end
|
1041
|
+
row << "%#{DAT_LEN[:CBGG]}s" % if ((pac && pac[:narcosis_flag] == 'Y') or # BAGXml
|
1042
|
+
(@flags[ean])) # ywesee BM_update
|
1043
|
+
'3'
|
1044
|
+
else
|
1045
|
+
'0'
|
1046
|
+
end
|
1047
|
+
row << "%#{DAT_LEN[:CIKS]}s" % if (no8 && pack_info && !pack_info[:is_tier]) # Packungen.xls
|
1048
|
+
pack_info[:swissmedic_category]
|
1049
|
+
else
|
1050
|
+
'0'
|
1051
|
+
end.gsub(/(\+|\s)/, '')
|
1052
|
+
row << "%0#{DAT_LEN[:ITHE]}d" % if (no8 && pack_info && !pack_info[:is_tier])
|
1053
|
+
format_date(pack_info[:ith_swissmedic])
|
1054
|
+
else
|
1055
|
+
('0' * DAT_LEN[:ITHE])
|
1056
|
+
end.to_i
|
1057
|
+
row << "%0#{DAT_LEN[:CEAN]}d" % (ean.match(/^000000/) ? 0 : ean.to_i)
|
1058
|
+
row << "%#{DAT_LEN[:CMWS]}s" % '2' # pharma
|
1059
|
+
rows << row
|
1064
1060
|
end
|
1065
1061
|
end
|
1066
1062
|
rows.join("\n")
|
data/lib/oddb2xml/cli.rb
CHANGED
@@ -26,7 +26,7 @@ module Oddb2xml
|
|
26
26
|
@lppvs = {} # lppv.txt from files repo
|
27
27
|
@infos = {} # [option] FI from SwissmedicInfo
|
28
28
|
@packs = {} # [option] Packungen from Swissmedic for dat
|
29
|
-
@
|
29
|
+
@infos_zur_rose = {} # [addition] infos_zur_rose and other infos from zurrose transfer.txt
|
30
30
|
@migel = {} # [addition] additional Non Pharma products from files repo
|
31
31
|
@actions = [] # [addition] interactions from epha
|
32
32
|
@orphans = [] # [addition] Orphaned drugs from Swissmedic xls
|
@@ -58,9 +58,7 @@ module Oddb2xml
|
|
58
58
|
if @options[:nonpharma]
|
59
59
|
threads << download(:migel) # oddb2xml_files
|
60
60
|
end
|
61
|
-
|
62
|
-
threads << download(@options[:price])
|
63
|
-
end
|
61
|
+
threads << download(:zurrose)
|
64
62
|
threads << download(:package) # swissmedic
|
65
63
|
threads << download(:bm_update) # oddb2xml_files
|
66
64
|
threads << download(:lppv) # oddb2xml_files
|
@@ -118,7 +116,7 @@ module Oddb2xml
|
|
118
116
|
builder.infos = @infos
|
119
117
|
builder.packs = @packs
|
120
118
|
# additional sources
|
121
|
-
%w[actions orphans fridges migel
|
119
|
+
%w[actions orphans fridges migel infos_zur_rose].each do |addition|
|
122
120
|
builder.send("#{addition}=".intern, self.instance_variable_get("@#{addition}"))
|
123
121
|
end
|
124
122
|
end
|
@@ -249,8 +247,8 @@ module Oddb2xml
|
|
249
247
|
Oddb2xml.log("zurrose xml #{xml.size} bytes")
|
250
248
|
@mutex.synchronize do
|
251
249
|
hsh = ZurroseExtractor.new(xml, @options[:extended]).to_hash
|
252
|
-
@
|
253
|
-
Oddb2xml.log("zurrose added #{@
|
250
|
+
@infos_zur_rose = hsh
|
251
|
+
Oddb2xml.log("zurrose added #{@infos_zur_rose.size} items from xml with #{xml.size} bytes")
|
254
252
|
end
|
255
253
|
end
|
256
254
|
when :index
|
@@ -332,7 +330,7 @@ module Oddb2xml
|
|
332
330
|
end
|
333
331
|
end
|
334
332
|
if @options[:extended]
|
335
|
-
lines << sprintf("\
|
333
|
+
lines << sprintf("\tInformation items zur Rose: %i", @infos_zur_rose.length)
|
336
334
|
end
|
337
335
|
else
|
338
336
|
{
|
data/lib/oddb2xml/extractor.rb
CHANGED
@@ -193,7 +193,6 @@ module Oddb2xml
|
|
193
193
|
item[:_type] = @type.downcase.intern
|
194
194
|
item[:ean] = (gtin = pac.GTIN) ? gtin: ''
|
195
195
|
item[:pharmacode] = (phar = pac.PHAR) ? phar: ''
|
196
|
-
item[:status] = (stat = pac.STATUS) ? stat: ''
|
197
196
|
item[:stat_date] = (date = pac.SDATE) ? date: ''
|
198
197
|
item[:lang] = (lang = pac.LANG) ? lang: ''
|
199
198
|
item[:desc] = (dscr = pac.DSCR) ? dscr: ''
|
@@ -503,6 +502,7 @@ module Oddb2xml
|
|
503
502
|
:price => sprintf("%.2f", line[60,6].gsub(/(\d{2})$/, '.\1').to_f),
|
504
503
|
:pub_price => sprintf("%.2f", line[66,6].gsub(/(\d{2})$/, '.\1').to_f),
|
505
504
|
:type => :nonpharma,
|
505
|
+
:cmut => line[2],
|
506
506
|
}
|
507
507
|
@@zur_rose_items += 1
|
508
508
|
end if @io
|
data/lib/oddb2xml/version.rb
CHANGED
data/spec/builder_spec.rb
CHANGED
@@ -29,11 +29,10 @@ def check_validation_via_xsd
|
|
29
29
|
xsd.validate(doc).each do |error| error.message.should be_nil end
|
30
30
|
}
|
31
31
|
end
|
32
|
-
|
33
32
|
describe Oddb2xml::Builder do
|
34
|
-
NrExtendedArticles =
|
35
|
-
NrPharmaAndNonPharmaArticles =
|
36
|
-
NrPharmaArticles =
|
33
|
+
NrExtendedArticles = 71
|
34
|
+
NrPharmaAndNonPharmaArticles = 62
|
35
|
+
NrPharmaArticles = 5
|
37
36
|
include ServerMockHelper
|
38
37
|
before(:each) do
|
39
38
|
@savedDir = Dir.pwd
|
@@ -119,6 +118,28 @@ describe Oddb2xml::Builder do
|
|
119
118
|
end
|
120
119
|
end
|
121
120
|
|
121
|
+
context 'when -f dat is given' do
|
122
|
+
let(:cli) do
|
123
|
+
opts = {
|
124
|
+
:format => :dat,
|
125
|
+
}
|
126
|
+
Oddb2xml::Cli.new(opts)
|
127
|
+
end
|
128
|
+
|
129
|
+
it 'should contain the correct values fo CMUT from zurrose_transfer.dat' do
|
130
|
+
puts Oddb2xml::WorkDir
|
131
|
+
res = buildr_capture(:stdout){ cli.run }
|
132
|
+
res.should match(/products/)
|
133
|
+
dat_filename = File.join(Oddb2xml::WorkDir, 'oddb.dat')
|
134
|
+
File.exists?(dat_filename).should be_true
|
135
|
+
oddb_dat = IO.read(dat_filename)
|
136
|
+
oddb_dat.should match(/^..2/), "should have a record with '2' in CMUT field"
|
137
|
+
oddb_dat.should match(/^..3/), "should have a record with '3' in CMUT field"
|
138
|
+
oddb_dat.should match(/1115819012LEVETIRACETAM DESITIN Filmtabl 250 mg 30 Stk/), "should have Desitin"
|
139
|
+
# oddb_dat.should match(/^..1/), "should have a record with '1' in CMUT field" # we have no
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
122
143
|
context 'when -a nonpharma -f dat is given' do
|
123
144
|
let(:cli) do
|
124
145
|
opts = {
|
@@ -137,8 +158,17 @@ describe Oddb2xml::Builder do
|
|
137
158
|
oddb_dat.should match(/1115819012LEVETIRACETAM DESITIN Filmtabl 250 mg 30 Stk/), "should have Desitin"
|
138
159
|
# oddb_dat.should match(/001349002780100B010710076806206900842/), "should match EAN of Desitin"
|
139
160
|
end
|
140
|
-
|
161
|
+
|
162
|
+
it "should match EAN of Desitin. returns 0 at the moment" do
|
163
|
+
res = buildr_capture(:stdout){ cli.run }
|
164
|
+
res.should match(/products/)
|
165
|
+
dat_filename = File.join(Oddb2xml::WorkDir, 'oddb_with_migel.dat')
|
166
|
+
File.exists?(dat_filename).should be_true
|
167
|
+
oddb_dat = IO.read(dat_filename)
|
168
|
+
oddb_dat.should match(/76806206900842/), "should match EAN of Desitin"
|
169
|
+
end
|
141
170
|
end
|
171
|
+
|
142
172
|
context 'when option -e is given' do
|
143
173
|
let(:cli) do
|
144
174
|
opts = {
|
@@ -312,9 +342,32 @@ describe Oddb2xml::Builder do
|
|
312
342
|
product_xml.should_not match(/ZYVOXID/i)
|
313
343
|
end
|
314
344
|
doc = REXML::Document.new File.new(product_filename)
|
315
|
-
XPath.match( doc, "//PRD" ).find_all{|x| true}.size.should ==
|
316
|
-
XPath.match( doc, "//GTIN" ).find_all{|x| true}.size.should ==
|
345
|
+
XPath.match( doc, "//PRD" ).find_all{|x| true}.size.should == 4
|
346
|
+
XPath.match( doc, "//GTIN" ).find_all{|x| true}.size.should == 4
|
317
347
|
XPath.match( doc, "//PRODNO" ).find_all{|x| true}.size.should == 1
|
318
348
|
end
|
349
|
+
|
350
|
+
def checkItemForSALECD(doc, pharmacode, expected)
|
351
|
+
article = XPath.match( doc, "//ART[PHAR=#{pharmacode.to_s}]").first
|
352
|
+
name = article.elements['DSCRD'].text
|
353
|
+
salecd = article.elements['SALECD'].text
|
354
|
+
if $VERBOSE or article.elements['SALECD'].text != expected.to_s
|
355
|
+
puts "checking doc for pharmacode #{pharmacode} expected #{expected} == #{salecd}. #{name}"
|
356
|
+
puts article.text
|
357
|
+
end
|
358
|
+
article.elements['SALECD'].text.should == expected.to_s
|
359
|
+
end
|
360
|
+
it 'should generate the flag SALECD' do
|
361
|
+
res = buildr_capture(:stdout){ cli.run }
|
362
|
+
@article_xml = File.expand_path(File.join(Oddb2xml::WorkDir, 'oddb_article.xml'))
|
363
|
+
puts @article_xml
|
364
|
+
File.exists?(@article_xml).should be_true
|
365
|
+
FileUtils.cp(@article_xml, '/opt/src/oddb2xml/tst.xml', :verbose => true)
|
366
|
+
article_xml = IO.read(@article_xml)
|
367
|
+
doc = REXML::Document.new File.new(@article_xml)
|
368
|
+
XPath.match( doc, "//REF_DATA" ).size.should > 0
|
369
|
+
checkItemForSALECD(doc, "0020244", 'A') # FERRO-GRADUMET Depottabl 30 Stk
|
370
|
+
checkItemForSALECD(doc, "0598003", 'I') # SOFRADEX
|
371
|
+
end
|
319
372
|
end
|
320
373
|
end
|
@@ -59,7 +59,21 @@
|
|
59
59
|
<GLN>7601001010604</GLN>
|
60
60
|
</COMP>
|
61
61
|
</ITEM>
|
62
|
-
<
|
62
|
+
<ITEM DT="2013-12-06T00:00:00">
|
63
|
+
<GTIN>7680316950157</GTIN>
|
64
|
+
<PHAR>598003</PHAR>
|
65
|
+
<STATUS>A</STATUS>
|
66
|
+
<STDATE>2012-04-13T00:00:00</STDATE>
|
67
|
+
<LANG>DE</LANG>
|
68
|
+
<DSCR>SOFRADEX Gtt Auric</DSCR>
|
69
|
+
<ADDSCR>8 ml</ADDSCR>
|
70
|
+
<ATC>S02CA06</ATC>
|
71
|
+
<COMP>
|
72
|
+
<NAME>Sanofi-Aventis (Suisse) SA</NAME>
|
73
|
+
<GLN>7601001002340</GLN>
|
74
|
+
</COMP>
|
75
|
+
</ITEM>
|
76
|
+
<RESULT>
|
63
77
|
<OK_ERROR>OK</OK_ERROR>
|
64
78
|
<NBR_RECORD>2</NBR_RECORD>
|
65
79
|
</RESULT>
|
@@ -15,3 +15,4 @@
|
|
15
15
|
1122871472CANIPHEDRIN Tabl 50 mg ad us vet. 500 Stk 005443007580400C000000000000000000002
|
16
16
|
1132867163TOTALIN Plv ad us. vet. 5 kg 000535000900400C000000000000000000002
|
17
17
|
1138110429Forthyron 400 mcg 50 Tabl (vet) 0081120015800000000000000000000000002
|
18
|
+
1130598003SOFRADEX Gtt Auric 8 ml 000718001545300B120130076803169501572
|
data/spec/extractor_spec.rb
CHANGED
@@ -17,7 +17,7 @@ describe Oddb2xml::BagXmlExtractor do
|
|
17
17
|
dat = File.read(File.join(Oddb2xml::SpecData, 'Preparations.xml'))
|
18
18
|
Oddb2xml::BagXmlExtractor.new(dat).to_hash
|
19
19
|
end
|
20
|
-
it
|
20
|
+
it "should handle pub_price for 1699947 correctly" do
|
21
21
|
@items = subject.to_hash
|
22
22
|
with_pharma = @items['1699947']
|
23
23
|
expect(with_pharma).not_to be_nil
|
@@ -27,6 +27,9 @@ describe Oddb2xml::BagXmlExtractor do
|
|
27
27
|
expect(with_pharma[:packages].first[0]).to eq('1699947')
|
28
28
|
expect(with_pharma[:packages].first[1][:prices][:pub_price][:price]).to eq('205.3')
|
29
29
|
expect(@items.size).to eq(5)
|
30
|
+
end
|
31
|
+
it "should handle pub_price for 7680620690084 correctly" do
|
32
|
+
@items = subject.to_hash
|
30
33
|
no_pharma = @items['7680620690084']
|
31
34
|
expect(no_pharma).not_to be_nil
|
32
35
|
expect(no_pharma[:atc_code]).not_to be_nil
|
@@ -34,7 +37,7 @@ describe Oddb2xml::BagXmlExtractor do
|
|
34
37
|
expect(no_pharma[:packages].size).to eq(1)
|
35
38
|
expect(no_pharma[:packages].first[0]).to eq('7680620690084')
|
36
39
|
expect(no_pharma[:packages].first[1][:prices][:pub_price][:price]).to eq('27.8')
|
37
|
-
|
40
|
+
end
|
38
41
|
end
|
39
42
|
end
|
40
43
|
|
@@ -172,14 +175,16 @@ describe Oddb2xml::ZurroseExtractor do
|
|
172
175
|
it { expect(subject.to_hash.values.first[:price]).to eq("15.76") }
|
173
176
|
it { expect(subject.to_hash.values.first[:pub_price]).to eq("24.30") }
|
174
177
|
it { expect(subject.to_hash.values.first[:pharmacode]).to eq("0020652") }
|
175
|
-
|
178
|
+
it 'should set the correct SALECD cmut code' do expect(subject.to_hash.values.first[:cmut]).to eq("2") end
|
179
|
+
end
|
180
|
+
context 'when SOFRADEX is given' do
|
181
|
+
subject do
|
182
|
+
dat = <<-DAT
|
183
|
+
1130598003SOFRADEX Gtt Auric 8 ml 000718001545300B120130076803169501572\r\n
|
184
|
+
DAT
|
185
|
+
Oddb2xml::ZurroseExtractor.new(dat)
|
186
|
+
end
|
187
|
+
#it { expect(subject.to_hash.keys.first).to eq("7680316950157") }
|
188
|
+
it "should set the correct SALECD cmut code" do expect(subject.to_hash.values.first[:cmut]).to eq("3") end
|
176
189
|
end
|
177
|
-
|
178
|
-
x =%(
|
179
|
-
Record-Art 1 Länge 97
|
180
|
-
:vat => $2.to_s,
|
181
|
-
:price => sprintf("%.2f", line[60,6].gsub(/(\d{2})$/, '.\1').to_f),
|
182
|
-
:pub_price => sprintf("%.2f", line[66,6].gsub(/(\d{2})$/, '.\1').to_f),
|
183
|
-
=
|
184
|
-
)
|
185
190
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oddb2xml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.
|
4
|
+
version: 1.8.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-08-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rubyzip
|