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
data/spec/builder_spec.rb
CHANGED
@@ -1,41 +1,38 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'spec_helper'
|
1
|
+
require "spec_helper"
|
4
2
|
require "rexml/document"
|
5
|
-
require
|
6
|
-
include REXML
|
3
|
+
require "webmock/rspec"
|
7
4
|
RUN_ALL = true
|
8
5
|
|
9
6
|
# TODO: Add articles which contain these values
|
10
7
|
# not done, because it was easy to verify this by running on the command line grep 'LIMPTS' oddb_article.xml | sort | uniq
|
11
|
-
ARTICLE_ATTRIBUTE_TESTS =
|
12
|
-
[
|
13
|
-
[
|
14
|
-
[
|
15
|
-
[
|
16
|
-
[
|
8
|
+
ARTICLE_ATTRIBUTE_TESTS = [
|
9
|
+
["ARTICLE", "CREATION_DATETIME", Oddb2xml::DATE_REGEXP],
|
10
|
+
["ARTICLE", "PROD_DATE", Oddb2xml::DATE_REGEXP],
|
11
|
+
["ARTICLE", "VALID_DATE", Oddb2xml::DATE_REGEXP],
|
12
|
+
["ARTICLE/ART", "SHA256", /[a-f0-9]{32}/],
|
13
|
+
["ARTICLE/ART", "DT", /\d{4}-\d{2}-\d{2}/]
|
17
14
|
]
|
18
15
|
|
19
|
-
ARTICLE_MISSING_ELEMENTS =
|
20
|
-
[
|
21
|
-
[
|
22
|
-
[
|
23
|
-
[
|
24
|
-
[
|
25
|
-
[
|
26
|
-
[
|
27
|
-
[
|
16
|
+
ARTICLE_MISSING_ELEMENTS = [
|
17
|
+
["ARTICLE/ART/LIMPTS", "10"],
|
18
|
+
["ARTICLE/ART/LIMPTS", "30"],
|
19
|
+
["ARTICLE/ART/LIMPTS", "40"],
|
20
|
+
["ARTICLE/ART/LIMPTS", "50"],
|
21
|
+
["ARTICLE/ART/LIMPTS", "60"],
|
22
|
+
["ARTICLE/ART/LIMPTS", "80"],
|
23
|
+
["ARTICLE/ART/LIMPTS", "100"],
|
24
|
+
["ARTICLE/ART/SLOPLUS", "1"]
|
28
25
|
]
|
29
26
|
|
30
|
-
ARTICLE_ZURROSE_ELEMENTS =
|
31
|
-
[
|
32
|
-
[
|
33
|
-
[
|
34
|
-
[
|
35
|
-
[
|
36
|
-
[
|
37
|
-
[
|
38
|
-
[
|
27
|
+
ARTICLE_ZURROSE_ELEMENTS = [
|
28
|
+
["ARTICLE/ART/REF_DATA", "0"],
|
29
|
+
["ARTICLE/ART/ARTCOMP/COMPNO", "7601001000896"],
|
30
|
+
["ARTICLE/ART/ARTPRI/PTYP", "PEXF"],
|
31
|
+
["ARTICLE/ART/ARTPRI/PTYP", "PPUB"],
|
32
|
+
["ARTICLE/ART/ARTPRI/PTYP", "ZURROSE"],
|
33
|
+
["ARTICLE/ART/ARTPRI/PTYP", "ZURROSEPUB"],
|
34
|
+
["ARTICLE/ART/ARTINS/NINCD", "13"],
|
35
|
+
["ARTICLE/ART/ARTINS/NINCD", "20"]
|
39
36
|
]
|
40
37
|
|
41
38
|
ARTICLE_NAROPIN = %(<REF_DATA>1</REF_DATA>
|
@@ -59,275 +56,268 @@ ARTICLE_NAROPIN = %(<REF_DATA>1</REF_DATA>
|
|
59
56
|
</ARTBAR>
|
60
57
|
</ART>)
|
61
58
|
|
62
|
-
ARTICLE_COMMON_ELEMENTS =
|
63
|
-
[
|
64
|
-
[
|
65
|
-
[
|
66
|
-
[
|
67
|
-
[
|
68
|
-
[
|
69
|
-
[
|
70
|
-
[
|
71
|
-
[
|
72
|
-
[
|
73
|
-
[
|
74
|
-
[
|
75
|
-
[
|
76
|
-
[
|
77
|
-
[
|
78
|
-
[
|
79
|
-
[
|
80
|
-
[
|
81
|
-
[
|
82
|
-
[
|
83
|
-
[
|
84
|
-
[
|
85
|
-
[
|
86
|
-
[
|
87
|
-
[
|
59
|
+
ARTICLE_COMMON_ELEMENTS = [
|
60
|
+
["ARTICLE/ART/REF_DATA", "1"],
|
61
|
+
["ARTICLE/ART/SMCAT", "A"],
|
62
|
+
["ARTICLE/ART/SMCAT", "B"],
|
63
|
+
["ARTICLE/ART/SMCAT", "C"],
|
64
|
+
["ARTICLE/ART/SMCAT", "D"],
|
65
|
+
["ARTICLE/ART/GEN_PRODUCTION", "X"],
|
66
|
+
["ARTICLE/ART/DRUG_INDEX", "d"],
|
67
|
+
["ARTICLE/ART/INSULIN_CATEGORY", "Insulinanalog: schnell wirkend"],
|
68
|
+
["ARTICLE/ART/SMNO", "16105058"],
|
69
|
+
["ARTICLE/ART/PRODNO", "1610501"],
|
70
|
+
["ARTICLE/ART/VAT", "2"],
|
71
|
+
["ARTICLE/ART/SALECD", "A"],
|
72
|
+
["ARTICLE/ART/SALECD", "I"],
|
73
|
+
["ARTICLE/ART/COOL", "1"],
|
74
|
+
["ARTICLE/ART/LIMPTS", "20"],
|
75
|
+
["ARTICLE/ART/CDBG", "Y"],
|
76
|
+
["ARTICLE/ART/CDBG", "N"],
|
77
|
+
["ARTICLE/ART/BG", "Y"],
|
78
|
+
["ARTICLE/ART/BG", "N"],
|
79
|
+
["ARTICLE/ART/ARTBAR/BC", Oddb2xml::ORPHAN_GTIN.to_s],
|
80
|
+
["ARTICLE/ART/ARTBAR/BC", Oddb2xml::FRIDGE_GTIN.to_s],
|
81
|
+
["ARTICLE/ART/SYN1D", "Hirudoid"],
|
82
|
+
["ARTICLE/ART/SYN1F", "Hirudoid"],
|
83
|
+
["ARTICLE/ART/SLOPLUS", "2"],
|
84
|
+
["ARTICLE/ART/ARTINS/NINCD", "10"]
|
88
85
|
]
|
89
86
|
|
90
|
-
CODE_ATTRIBUTE_TESTS =
|
91
|
-
[
|
92
|
-
[
|
93
|
-
[
|
94
|
-
[
|
87
|
+
CODE_ATTRIBUTE_TESTS = [
|
88
|
+
["CODE", "CREATION_DATETIME", Oddb2xml::DATE_REGEXP],
|
89
|
+
["CODE", "PROD_DATE", Oddb2xml::DATE_REGEXP],
|
90
|
+
["CODE", "VALID_DATE", Oddb2xml::DATE_REGEXP],
|
91
|
+
["CODE/CD", "DT", ""]
|
95
92
|
]
|
96
93
|
|
97
|
-
CODE_MISSING_ELEMENT_TESTS = [
|
98
|
-
]
|
94
|
+
CODE_MISSING_ELEMENT_TESTS = []
|
99
95
|
|
100
96
|
CODE_ELEMENT_TESTS = [
|
101
|
-
[
|
102
|
-
[
|
103
|
-
[
|
104
|
-
[
|
105
|
-
[
|
106
|
-
[
|
107
|
-
[
|
108
|
-
[
|
109
|
-
[
|
110
|
-
[
|
111
|
-
[
|
112
|
-
[
|
113
|
-
[
|
114
|
-
[
|
115
|
-
[
|
116
|
-
[
|
97
|
+
["CODE/CD/CDTYP", "11"],
|
98
|
+
["CODE/CD/CDTYP", "13"],
|
99
|
+
["CODE/CD/CDTYP", "14"],
|
100
|
+
["CODE/CD/CDTYP", "15"],
|
101
|
+
["CODE/CD/CDTYP", "16"],
|
102
|
+
["CODE/CD/CDVAL", "A"],
|
103
|
+
["CODE/CD/CDVAL", "B"],
|
104
|
+
["CODE/CD/CDVAL", "C"],
|
105
|
+
["CODE/CD/CDVAL", "D"],
|
106
|
+
["CODE/CD/CDVAL", "X"],
|
107
|
+
["CODE/CD/DSCRSD", "Kontraindiziert"],
|
108
|
+
["CODE/CD/DSCRSD", "Kombination meiden"],
|
109
|
+
["CODE/CD/DSCRSD", "Monitorisieren"],
|
110
|
+
["CODE/CD/DSCRSD", "Vorsichtsmassnahmen"],
|
111
|
+
["CODE/CD/DSCRSD", "keine Massnahmen"],
|
112
|
+
["CODE/CD/DEL", "false"]
|
117
113
|
]
|
118
114
|
|
119
|
-
INTERACTION_ATTRIBUTE_TESTS =
|
120
|
-
[
|
121
|
-
[
|
122
|
-
[
|
123
|
-
[
|
124
|
-
[
|
115
|
+
INTERACTION_ATTRIBUTE_TESTS = [
|
116
|
+
["INTERACTION", "CREATION_DATETIME", Oddb2xml::DATE_REGEXP],
|
117
|
+
["INTERACTION", "PROD_DATE", Oddb2xml::DATE_REGEXP],
|
118
|
+
["INTERACTION", "VALID_DATE", Oddb2xml::DATE_REGEXP],
|
119
|
+
["INTERACTION/IX", "SHA256", /[a-f0-9]{32}/],
|
120
|
+
["INTERACTION/IX", "DT", ""]
|
125
121
|
]
|
126
122
|
|
127
123
|
INTERACTION_MISSING_ELEMENT_TESTS = [
|
128
|
-
[
|
129
|
-
[
|
130
|
-
[
|
131
|
-
[
|
132
|
-
[
|
124
|
+
["INTERACTION/IX/EFFD", "Kombination meiden"],
|
125
|
+
["INTERACTION/IX/EFFD", "Kontraindiziert"],
|
126
|
+
["INTERACTION/IX/EFFD", "Monitorisieren"],
|
127
|
+
["INTERACTION/IX/EFFD", "Vorsichtsmassnahmen"],
|
128
|
+
["INTERACTION/IX/DEL", "true"] # Never found???
|
133
129
|
]
|
134
130
|
|
135
131
|
INTERACTION_ELEMENT_TESTS = [
|
136
|
-
[
|
137
|
-
[
|
138
|
-
[
|
139
|
-
[
|
140
|
-
[
|
141
|
-
[
|
142
|
-
[
|
143
|
-
[
|
144
|
-
|
145
|
-
|
146
|
-
LIMITATION_ATTRIBUTE_TESTS =
|
147
|
-
[
|
148
|
-
[
|
149
|
-
[
|
150
|
-
[
|
151
|
-
[
|
132
|
+
["INTERACTION/IX/IXNO", "2"],
|
133
|
+
["INTERACTION/IX/TITD", "Keine Interaktion"],
|
134
|
+
["INTERACTION/IX/GRP1D", "N06AB06"],
|
135
|
+
["INTERACTION/IX/GRP2D", "M03BX02"],
|
136
|
+
["INTERACTION/IX/EFFD", "Keine Interaktion."],
|
137
|
+
["INTERACTION/IX/MECHD", /Tizanidin wird über CYP1A2 metabolisiert/],
|
138
|
+
["INTERACTION/IX/MEASD", /Die Kombination aus Sertralin und Tizanidin/],
|
139
|
+
["INTERACTION/IX/DEL", "false"]
|
140
|
+
]
|
141
|
+
|
142
|
+
LIMITATION_ATTRIBUTE_TESTS = [
|
143
|
+
["LIMITATION", "CREATION_DATETIME", Oddb2xml::DATE_REGEXP],
|
144
|
+
["LIMITATION", "PROD_DATE", Oddb2xml::DATE_REGEXP],
|
145
|
+
["LIMITATION", "VALID_DATE", Oddb2xml::DATE_REGEXP],
|
146
|
+
["LIMITATION/LIM", "SHA256", /[a-f0-9]{32}/],
|
147
|
+
["LIMITATION/LIM", "DT", ""]
|
152
148
|
]
|
153
149
|
|
154
150
|
# Found by grep LIMTYP oddb_limitation.xml | sort | uniq
|
155
151
|
LIMITATION_MISSING_ELEMENT_TESTS = [
|
156
|
-
[
|
157
|
-
[
|
158
|
-
[
|
159
|
-
[
|
160
|
-
[
|
152
|
+
["LIMITATION/LIM/SwissmedicNo8", "62089002"],
|
153
|
+
["LIMITATION/LIM/Pharmacode", "0"],
|
154
|
+
["LIMITATION/LIM/LIMTYP", "AUD"],
|
155
|
+
["LIMITATION/LIM/LIMTYP", "KOM"],
|
156
|
+
["LIMITATION/LIM/LIMTYP", "ZEI"]
|
161
157
|
]
|
162
158
|
|
163
159
|
LIMITATION_ELEMENT_TESTS = [
|
164
|
-
[
|
165
|
-
[
|
166
|
-
[
|
167
|
-
[
|
168
|
-
[
|
169
|
-
[
|
170
|
-
[
|
171
|
-
[
|
172
|
-
[
|
173
|
-
[
|
174
|
-
[
|
175
|
-
[
|
176
|
-
[
|
177
|
-
[
|
178
|
-
[
|
179
|
-
[
|
180
|
-
[
|
181
|
-
]
|
182
|
-
|
183
|
-
SUBSTANCE_ATTRIBUTE_TESTS = [
|
184
|
-
['SUBSTANCE', 'CREATION_DATETIME', Oddb2xml::DATE_REGEXP],
|
185
|
-
['SUBSTANCE', 'PROD_DATE', Oddb2xml::DATE_REGEXP],
|
186
|
-
['SUBSTANCE', 'VALID_DATE', Oddb2xml::DATE_REGEXP],
|
187
|
-
['SUBSTANCE/SB', 'SHA256', /[a-f0-9]{32}/],
|
188
|
-
['SUBSTANCE/SB', 'DT', ''],
|
160
|
+
["LIMITATION/LIM/LIMVAL", "10"],
|
161
|
+
["LIMITATION/LIM/LIMVAL", "20"],
|
162
|
+
["LIMITATION/LIM/LIMVAL", "30"],
|
163
|
+
["LIMITATION/LIM/LIMVAL", "40"],
|
164
|
+
["LIMITATION/LIM/LIMVAL", "50"],
|
165
|
+
["LIMITATION/LIM/LIMVAL", "60"],
|
166
|
+
["LIMITATION/LIM/LIMVAL", "80"],
|
167
|
+
["LIMITATION/LIM/LIMVAL", "100"],
|
168
|
+
["LIMITATION/LIM/IT", "07.02.40."],
|
169
|
+
["LIMITATION/LIM/LIMTYP", "DIA"],
|
170
|
+
["LIMITATION/LIM/LIMTYP", "PKT"],
|
171
|
+
["LIMITATION/LIM/LIMNAMEBAG", "070240"],
|
172
|
+
["LIMITATION/LIM/LIMNIV", "IP"],
|
173
|
+
["LIMITATION/LIM/VDAT", /\d{2}\.\d{2}\.\d{4}/],
|
174
|
+
["LIMITATION/LIM/DSCRD", /Therapiedauer/],
|
175
|
+
["LIMITATION/LIM/DSCRF", /Traitement de la pneumonie/],
|
176
|
+
["LIMITATION/LIM/SwissmedicNo5", "28486"]
|
189
177
|
]
|
190
178
|
|
191
|
-
|
179
|
+
SUBSTANCE_ATTRIBUTE_TESTS = [
|
180
|
+
["SUBSTANCE", "CREATION_DATETIME", Oddb2xml::DATE_REGEXP],
|
181
|
+
["SUBSTANCE", "PROD_DATE", Oddb2xml::DATE_REGEXP],
|
182
|
+
["SUBSTANCE", "VALID_DATE", Oddb2xml::DATE_REGEXP],
|
183
|
+
["SUBSTANCE/SB", "SHA256", /[a-f0-9]{32}/],
|
184
|
+
["SUBSTANCE/SB", "DT", ""]
|
192
185
|
]
|
193
186
|
|
187
|
+
SUBSTANCE_MISSING_ELEMENT_TESTS = []
|
188
|
+
|
194
189
|
SUBSTANCE_ELEMENT_TESTS = [
|
195
|
-
[
|
196
|
-
[
|
190
|
+
["SUBSTANCE/SB/SUBNO", "1"],
|
191
|
+
["SUBSTANCE/SB/NAML", "Linezolidum"]
|
197
192
|
]
|
198
193
|
|
199
194
|
# Betriebe and Medizinalpersonen don't work at the moment
|
200
|
-
BETRIEB_ATTRIBUTE_TESTS =
|
201
|
-
[
|
202
|
-
[
|
203
|
-
[
|
204
|
-
[
|
195
|
+
BETRIEB_ATTRIBUTE_TESTS = [
|
196
|
+
["Betriebe", "CREATION_DATETIME", Oddb2xml::DATE_REGEXP],
|
197
|
+
["Betriebe", "PROD_DATE", Oddb2xml::DATE_REGEXP],
|
198
|
+
["Betriebe", "VALID_DATE", Oddb2xml::DATE_REGEXP],
|
199
|
+
["Betriebe/Betrieb", "DT", ""]
|
205
200
|
]
|
206
201
|
|
207
|
-
BETRIEB_MISSING_ELEMENT_TESTS = [
|
208
|
-
]
|
202
|
+
BETRIEB_MISSING_ELEMENT_TESTS = []
|
209
203
|
|
210
204
|
BETRIEB_ELEMENT_TESTS = [
|
211
|
-
[
|
212
|
-
[
|
213
|
-
[
|
214
|
-
[
|
215
|
-
[
|
216
|
-
[
|
217
|
-
[
|
218
|
-
[
|
219
|
-
[
|
220
|
-
[
|
221
|
-
[
|
205
|
+
["Betriebe/Betrieb/GLN_Betrieb", "974633"],
|
206
|
+
["Betriebe/Betrieb/Betriebsname_1", "Betriebsname_1"],
|
207
|
+
["Betriebe/Betrieb/Betriebsname_2", "Betriebsname_2"],
|
208
|
+
["Betriebe/Betrieb/Strasse", "Strasse"],
|
209
|
+
["Betriebe/Betrieb/Nummer", "Nummer"],
|
210
|
+
["Betriebe/Betrieb/PLZ", "PLZ"],
|
211
|
+
["Betriebe/Betrieb/Ort", "Ort"],
|
212
|
+
["Betriebe/Betrieb/Bewilligungskanton", "Bewilligungskanton"],
|
213
|
+
["Betriebe/Betrieb/Land", "Land"],
|
214
|
+
["Betriebe/Betrieb/Betriebstyp", "Betriebstyp"],
|
215
|
+
["Betriebe/Betrieb/BTM_Berechtigung", "BTM_Berechtigung"]
|
222
216
|
]
|
223
217
|
|
224
|
-
MEDIZINALPERSON_ATTRIBUTE_TESTS =
|
225
|
-
[
|
226
|
-
[
|
227
|
-
[
|
228
|
-
[
|
218
|
+
MEDIZINALPERSON_ATTRIBUTE_TESTS = [
|
219
|
+
["Personen", "CREATION_DATETIME", Oddb2xml::DATE_REGEXP],
|
220
|
+
["Personen", "PROD_DATE", Oddb2xml::DATE_REGEXP],
|
221
|
+
["Personen", "VALID_DATE", Oddb2xml::DATE_REGEXP],
|
222
|
+
["Personen/Person", "DT", ""]
|
229
223
|
]
|
230
224
|
|
231
|
-
MEDIZINALPERSON_MISSING_ELEMENT_TESTS = [
|
232
|
-
]
|
225
|
+
MEDIZINALPERSON_MISSING_ELEMENT_TESTS = []
|
233
226
|
|
234
227
|
MEDIZINALPERSON_ELEMENT_TESTS = [
|
235
|
-
[
|
236
|
-
[
|
237
|
-
[
|
238
|
-
[
|
239
|
-
[
|
240
|
-
[
|
241
|
-
[
|
242
|
-
[
|
243
|
-
[
|
244
|
-
[
|
228
|
+
["Personen/Person/GLN_Person", "56459"],
|
229
|
+
["Personen/Person/Name", "Name"],
|
230
|
+
["Personen/Person/Vorname", "Vorname"],
|
231
|
+
["Personen/Person/PLZ", "PLZ"],
|
232
|
+
["Personen/Person/Ort", "Ort"],
|
233
|
+
["Personen/Person/Bewilligungskanton", "Bewilligungskanton"],
|
234
|
+
["Personen/Person/Land", "Land"],
|
235
|
+
["Personen/Person/Bewilligung_Selbstdispensation", "Bewilligung_Selbstdispensation"],
|
236
|
+
["Personen/Person/Diplom", "Diplom"],
|
237
|
+
["Personen/Person/BTM_Berechtigung", "BTM_Berechtigung"]
|
245
238
|
]
|
246
239
|
|
247
240
|
def check_result(inhalt, nbr_record)
|
248
|
-
[
|
241
|
+
["<NBR_RECORD>",
|
249
242
|
"<OK_ERROR>",
|
250
|
-
|
251
|
-
].each do |what|
|
243
|
+
"<OK_ERROR>OK</OK_ERROR>"].each do |what|
|
252
244
|
expect(inhalt.scan(what).size).to eq 1
|
253
245
|
end
|
254
|
-
expect(inhalt.index(
|
255
|
-
expect(inhalt.index(
|
246
|
+
expect(inhalt.index("<OK_ERROR>OK</OK_ERROR>")).to be > 0
|
247
|
+
expect(inhalt.index("<ERROR_CODE/>")).to be > 0
|
256
248
|
m = /<NBR_RECORD>(\d+)<\/NBR_RECORD>/.match(inhalt)
|
257
249
|
expect(m).not_to be nil
|
258
|
-
expect(m[1].to_i).to eq
|
250
|
+
expect(m[1].to_i).to eq nbr_record
|
259
251
|
end
|
260
252
|
|
261
|
-
[
|
253
|
+
["article", "betrieb", "code", "interaction", "limitation", "medizinalperson", "product", "substance"].each do |cat|
|
262
254
|
eval "
|
263
255
|
def oddb_#{cat}_xml
|
264
|
-
File.expand_path(File.join(Oddb2xml::
|
256
|
+
File.expand_path(File.join(Oddb2xml::WORK_DIR, 'oddb_#{cat}.xml'))
|
265
257
|
end
|
266
258
|
"
|
267
259
|
end
|
268
260
|
|
269
|
-
def check_article_IGM_format(line, price_kendural=825, add_80_percents=false)
|
270
|
-
typ
|
271
|
-
name
|
272
|
-
ckzl
|
273
|
-
ciks
|
274
|
-
price_exf
|
261
|
+
def check_article_IGM_format(line, price_kendural = 825, add_80_percents = false)
|
262
|
+
typ = line[0..1]
|
263
|
+
name = line[10..59]
|
264
|
+
ckzl = line[72]
|
265
|
+
ciks = line[75]
|
266
|
+
price_exf = line[60..65].to_i
|
275
267
|
price_reseller = line[66..71].to_i
|
276
|
-
price_public
|
277
|
-
expect(typ).to
|
268
|
+
price_public = line[66..71].to_i
|
269
|
+
expect(typ).to eq "11"
|
278
270
|
puts "check_article_IGM_format: #{price_exf} #{price_public} CKZL is #{ckzl} CIKS is #{ciks} name #{name} " if $VERBOSE
|
279
|
-
|
280
|
-
|
271
|
+
found_sl = false
|
272
|
+
found_non_sl = false
|
281
273
|
|
282
|
-
if /7680353660163\d$/.match(line) # KENDURAL Depottabl 30 Stk
|
283
|
-
puts "
|
284
|
-
|
285
|
-
expect(line[60..65]).to eq
|
274
|
+
if /7680353660163\d$/.match?(line) # KENDURAL Depottabl 30 Stk
|
275
|
+
puts "found_sl for #{line}" if $VERBOSE
|
276
|
+
found_sl = true
|
277
|
+
expect(line[60..65]).to eq "000496"
|
286
278
|
expect(price_exf).to eq 496
|
287
|
-
expect(ckzl).to eq
|
288
|
-
expect(price_public).to eq price_kendural
|
289
|
-
expect(line[66..71]).to eq
|
279
|
+
expect(ckzl).to eq "1"
|
280
|
+
expect(price_public).to eq price_kendural # this is a SL-product. Therefore we may not have a price increase
|
281
|
+
expect(line[66..71]).to eq "000" + sprintf("%03d", price_kendural) # the dat format requires leading zeroes and not point
|
290
282
|
end
|
291
283
|
|
292
|
-
if /7680403330459\d$/.match(line) # CARBADERM
|
293
|
-
|
294
|
-
puts "
|
295
|
-
expect(ckzl).to eq
|
284
|
+
if /7680403330459\d$/.match?(line) # CARBADERM
|
285
|
+
found_non_sl = true
|
286
|
+
puts "found_non_sl for #{line}" if $VERBOSE
|
287
|
+
expect(ckzl).to eq "3"
|
296
288
|
if add_80_percents
|
297
|
-
expect(price_reseller).to eq
|
298
|
-
expect(line[66..71]).to eq
|
289
|
+
expect(price_reseller).to eq 2919 # = 1545*1.8 this is a non SL-product. Therefore we must increase its price as requsted
|
290
|
+
expect(line[66..71]).to eq "002919" # dat format requires leading zeroes and not poin
|
299
291
|
else
|
300
|
-
expect(price_reseller).to eq
|
301
|
-
expect(line[66..71]).to eq
|
292
|
+
expect(price_reseller).to eq 2770 # this is a non SL-product, but no price increase was requested
|
293
|
+
expect(line[66..71]).to eq "002770" # the dat format requires leading zeroes and not point
|
302
294
|
end
|
303
|
-
expect(line[60..65]).to eq
|
304
|
-
expect(price_exf).to eq
|
295
|
+
expect(line[60..65]).to eq "001622" # the dat format requires leading zeroes and not point
|
296
|
+
expect(price_exf).to eq 1622 # this is a non SL-product, but no price increase was requested
|
305
297
|
end
|
306
|
-
|
298
|
+
[found_sl, found_non_sl]
|
307
299
|
end
|
308
300
|
|
309
301
|
def validate_via_xsd(xsd_file, xml_file)
|
310
|
-
xsd =open(xsd_file).read
|
302
|
+
xsd = File.open(xsd_file).read
|
311
303
|
xsd_rtikelstamm_xml = Nokogiri::XML::Schema(xsd)
|
312
304
|
doc = Nokogiri::XML(File.read(xml_file))
|
313
|
-
xsd_rtikelstamm_xml.validate(doc).each do
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
expect(error.message).to be_nil, msg
|
305
|
+
xsd_rtikelstamm_xml.validate(doc).each do |error|
|
306
|
+
if error.message
|
307
|
+
puts "Failed validating #{xml_file} with #{File.size(xml_file)} bytes using XSD from #{xsd_file}"
|
308
|
+
puts "CMD: xmllint --noout --schema #{xsd_file} #{xml_file}"
|
309
|
+
end
|
310
|
+
msg = "expected #{error.message} to be nil\nfor #{xml_file}"
|
311
|
+
puts msg
|
312
|
+
expect(error.message).to be_nil, msg
|
322
313
|
end
|
323
314
|
end
|
324
315
|
|
325
316
|
def check_validation_via_xsd
|
326
|
-
files = Dir.glob(
|
327
|
-
files.each{
|
328
|
-
|
329
|
-
|
330
|
-
xsd2use = /oddb_calc/.match(file) ? @oddb_calc_xsd : @oddb2xml_xsd
|
317
|
+
files = Dir.glob("*.xml")
|
318
|
+
files.each { |file|
|
319
|
+
next if /#{Time.now.year}/.match?(file)
|
320
|
+
xsd2use = /oddb_calc/.match?(file) ? @oddb_calc_xsd : @oddb2xml_xsd
|
331
321
|
validate_via_xsd(xsd2use, File.expand_path(file))
|
332
322
|
}
|
333
323
|
end
|
@@ -358,33 +348,33 @@ def checkPrices(increased = false)
|
|
358
348
|
end
|
359
349
|
end
|
360
350
|
|
361
|
-
def checkAndGetArticleXmlName(tst=nil)
|
362
|
-
article_xml = File.expand_path(File.join(Oddb2xml::
|
363
|
-
expect(File.
|
364
|
-
FileUtils.cp(article_xml, File.join(Oddb2xml::
|
351
|
+
def checkAndGetArticleXmlName(tst = nil)
|
352
|
+
article_xml = File.expand_path(File.join(Oddb2xml::WORK_DIR, "oddb_article.xml"))
|
353
|
+
expect(File.exist?(article_xml)).to eq true
|
354
|
+
FileUtils.cp(article_xml, File.join(Oddb2xml::WORK_DIR, "tst-#{tst}.xml")) if tst
|
365
355
|
article_xml
|
366
356
|
end
|
367
357
|
|
368
358
|
def checkAndGetProductWithGTIN(doc, gtin)
|
369
|
-
products = XPath.match(
|
370
|
-
gtins
|
359
|
+
products = REXML::XPath.match(doc, "//PRD[GTIN=#{gtin}]")
|
360
|
+
gtins = REXML::XPath.match(doc, "//PRD[GTIN=#{gtin}]/GTIN")
|
371
361
|
expect(gtins.size).to eq 1
|
372
362
|
expect(gtins.first.text).to eq gtin.to_s
|
373
363
|
# return product
|
374
|
-
|
364
|
+
products.size == 1 ? products.first : nil
|
375
365
|
end
|
376
366
|
|
377
367
|
def checkAndGetArticleWithGTIN(doc, gtin)
|
378
|
-
articles = XPath.match(
|
379
|
-
gtins
|
368
|
+
articles = REXML::XPath.match(doc, "//ART[ARTBAR/BC=#{gtin}]")
|
369
|
+
gtins = REXML::XPath.match(doc, "//ART[ARTBAR/BC=#{gtin}]/ARTBAR/BC")
|
380
370
|
expect(gtins.size).to eq 1
|
381
371
|
expect(gtins.first.text).to eq gtin.to_s
|
382
372
|
gtins.first
|
383
373
|
# return article
|
384
|
-
|
374
|
+
articles.size == 1 ? articles.first : nil
|
385
375
|
end
|
386
376
|
|
387
|
-
def checkArticleXml(
|
377
|
+
def checkArticleXml(check_erythrocin = true)
|
388
378
|
article_filename = checkAndGetArticleXmlName
|
389
379
|
|
390
380
|
# check articles
|
@@ -394,101 +384,101 @@ def checkArticleXml(checkERYTHROCIN = true)
|
|
394
384
|
desitin = checkAndGetArticleWithGTIN(doc, Oddb2xml::LEVETIRACETAM_GTIN)
|
395
385
|
expect(desitin).not_to eq nil
|
396
386
|
# TODO: why is this now nil? desitin.elements['ATC'].text.should == 'N03AX14'
|
397
|
-
expect(desitin.elements[
|
398
|
-
expect(desitin.elements[
|
399
|
-
expect(desitin.elements[
|
400
|
-
expect(desitin.elements[
|
401
|
-
expect(desitin.elements[
|
402
|
-
expect(desitin.elements[
|
403
|
-
expect(desitin.elements[
|
404
|
-
expect(desitin.elements[
|
405
|
-
expect(desitin.elements[
|
406
|
-
expect(desitin.elements[
|
407
|
-
expect(desitin.elements[
|
408
|
-
|
409
|
-
erythrocin_gtin =
|
387
|
+
expect(desitin.elements["DSCRD"].text).to eq("LEVETIRACETAM DESITIN Mini Filmtab 250 mg 30 Stk")
|
388
|
+
expect(desitin.elements["DSCRF"].text).to eq("LEVETIRACETAM DESITIN mini cpr pel 250 mg 30 pce")
|
389
|
+
expect(desitin.elements["REF_DATA"].text).to eq("1")
|
390
|
+
expect(desitin.elements["PHAR"].text).to eq("5819012")
|
391
|
+
expect(desitin.elements["SMCAT"].text).to eq("B")
|
392
|
+
expect(desitin.elements["SMNO"].text).to eq("62069008")
|
393
|
+
expect(desitin.elements["VAT"].text).to eq("2")
|
394
|
+
expect(desitin.elements["PRODNO"].text).to eq("6206901")
|
395
|
+
expect(desitin.elements["SALECD"].text).to eq("A")
|
396
|
+
expect(desitin.elements["CDBG"].text).to eq("N")
|
397
|
+
expect(desitin.elements["BG"].text).to eq("N")
|
398
|
+
|
399
|
+
erythrocin_gtin = "7680202580475" # picked up from zur rose
|
410
400
|
erythrocin = checkAndGetArticleWithGTIN(doc, erythrocin_gtin)
|
411
|
-
expect(erythrocin.elements[
|
401
|
+
expect(erythrocin.elements["DSCRD"].text).to eq("ERYTHROCIN i.v. Trockensub 1000 mg Amp") if check_erythrocin
|
412
402
|
|
413
403
|
lansoyl = checkAndGetArticleWithGTIN(doc, Oddb2xml::LANSOYL_GTIN)
|
414
|
-
expect(lansoyl.elements[
|
415
|
-
expect(lansoyl.elements[
|
416
|
-
expect(lansoyl.elements[
|
417
|
-
expect(lansoyl.elements[
|
418
|
-
expect(lansoyl.elements[
|
404
|
+
expect(lansoyl.elements["DSCRD"].text).to eq "LANSOYL Gel 225 g"
|
405
|
+
expect(lansoyl.elements["REF_DATA"].text).to eq "1"
|
406
|
+
expect(lansoyl.elements["SMNO"].text).to eq "32475019"
|
407
|
+
expect(lansoyl.elements["PHAR"].text).to eq "0023722"
|
408
|
+
expect(lansoyl.elements["ARTCOMP/COMPNO"].text).to eq("7601001002012")
|
419
409
|
|
420
410
|
zyvoxid = checkAndGetArticleWithGTIN(doc, Oddb2xml::ZYVOXID_GTIN)
|
421
|
-
expect(zyvoxid.elements[
|
411
|
+
expect(zyvoxid.elements["DSCRD"].text).to eq "ZYVOXID Filmtabl 600 mg 10 Stk"
|
422
412
|
|
423
|
-
expect(XPath.match(
|
413
|
+
expect(REXML::XPath.match(doc, "//LIMPTS").size).to be >= 1
|
424
414
|
# TODO: desitin.elements['QTY'].text.should eq '250 mg'
|
425
415
|
end
|
426
416
|
|
427
417
|
def checkProductXml(nbr_record = -1)
|
428
|
-
product_filename = File.expand_path(File.join(Oddb2xml::
|
429
|
-
expect(File.
|
418
|
+
product_filename = File.expand_path(File.join(Oddb2xml::WORK_DIR, "oddb_product.xml"))
|
419
|
+
expect(File.exist?(product_filename)).to eq true
|
430
420
|
|
431
421
|
# check products
|
432
422
|
content = IO.read(product_filename)
|
433
423
|
doc = REXML::Document.new content
|
434
424
|
check_result(content, nbr_record)
|
435
|
-
expect(nbr_record).to eq
|
425
|
+
expect(nbr_record).to eq content.scan(/<PRD/).size if nbr_record != -1
|
436
426
|
|
437
427
|
desitin = checkAndGetProductWithGTIN(doc, Oddb2xml::LEVETIRACETAM_GTIN)
|
438
|
-
expect(desitin.elements[
|
439
|
-
expect(desitin.elements[
|
440
|
-
expect(desitin.elements[
|
441
|
-
expect(desitin.elements[
|
442
|
-
expect(desitin.elements[
|
443
|
-
expect(desitin.elements[
|
444
|
-
expect(desitin.elements[
|
445
|
-
expect(desitin.elements[
|
446
|
-
expect(desitin.elements[
|
447
|
-
expect(desitin.elements[
|
448
|
-
expect(desitin.elements[
|
449
|
-
expect(desitin.elements[
|
450
|
-
expect(desitin.elements[
|
428
|
+
expect(desitin.elements["ATC"].text).to eq("N03AX14")
|
429
|
+
expect(desitin.elements["DSCRD"].text).to eq("LEVETIRACETAM DESITIN Mini Filmtab 250 mg 30 Stk")
|
430
|
+
expect(desitin.elements["DSCRF"].text).to eq("LEVETIRACETAM DESITIN mini cpr pel 250 mg 30 pce")
|
431
|
+
expect(desitin.elements["PRODNO"].text).to eq "6206901"
|
432
|
+
expect(desitin.elements["IT"].text).to eq "01.07.1."
|
433
|
+
expect(desitin.elements["PackGrSwissmedic"].text).to eq "30"
|
434
|
+
expect(desitin.elements["EinheitSwissmedic"].text).to eq "Tablette(n)"
|
435
|
+
expect(desitin.elements["SubstanceSwissmedic"].text).to eq "levetiracetamum"
|
436
|
+
expect(desitin.elements["CompositionSwissmedic"].text).to eq "levetiracetamum 250 mg, excipiens pro compressi obducti pro charta."
|
437
|
+
expect(desitin.elements["CPT/CPTCMP/LINE"].text).to eq "0"
|
438
|
+
expect(desitin.elements["CPT/CPTCMP/SUBNO"].text).to eq "13"
|
439
|
+
expect(desitin.elements["CPT/CPTCMP/QTY"].text).to eq "250"
|
440
|
+
expect(desitin.elements["CPT/CPTCMP/QTYU"].text).to eq "mg"
|
451
441
|
|
452
442
|
checkAndGetProductWithGTIN(doc, Oddb2xml::THREE_TC_GTIN)
|
453
443
|
checkAndGetProductWithGTIN(doc, Oddb2xml::ZYVOXID_GTIN)
|
454
444
|
if $VERBOSE
|
455
445
|
puts "checkProductXml #{product_filename} #{File.size(product_filename)} #{File.mtime(product_filename)}"
|
456
|
-
puts "checkProductXml has #{XPath.match(
|
457
|
-
puts "checkProductXml has #{XPath.match(
|
458
|
-
puts "checkProductXml has #{XPath.match(
|
446
|
+
puts "checkProductXml has #{REXML::XPath.match(doc, "//PRD").count { |x| true }} packages"
|
447
|
+
puts "checkProductXml has #{REXML::XPath.match(doc, "//GTIN").count { |x| true }} GTIN"
|
448
|
+
puts "checkProductXml has #{REXML::XPath.match(doc, "//PRODNO").count { |x| true }} PRODNO"
|
459
449
|
end
|
460
450
|
hirudoid = checkAndGetProductWithGTIN(doc, Oddb2xml::HIRUDOID_GTIN)
|
461
|
-
expect(hirudoid.elements[
|
451
|
+
expect(hirudoid.elements["ATC"].text).to eq("C05BA01") # modified by atc.csv!
|
462
452
|
end
|
463
453
|
|
454
|
+
NR_EXTENDED_ARTICLES = 80
|
455
|
+
NR_SUBSTANCES = 28
|
456
|
+
NR_LIMITATIONS = 15
|
457
|
+
|
458
|
+
NR_INTERACTIONS = 2
|
459
|
+
NR_CODES = 5
|
460
|
+
NR_PRODNO = 31
|
461
|
+
NR_PACKAGES = 46
|
462
|
+
NR_PRODUCTS = 40
|
463
|
+
REG_EXP_DESITIN = /1120000000LEVETIRACETAM DESITIN Mini Filmtab 250 mg 30 Stk/
|
464
464
|
describe Oddb2xml::Builder do
|
465
|
-
NrExtendedArticles = 80
|
466
|
-
NrSubstances = 28
|
467
|
-
NrLimitations = 15
|
468
|
-
|
469
|
-
NrInteractions = 2
|
470
|
-
NrCodes = 5
|
471
|
-
NrProdno = 31
|
472
|
-
NrPackages = 46
|
473
|
-
NrProducts = 40
|
474
|
-
RegExpDesitin = /1120000000LEVETIRACETAM DESITIN Mini Filmtab 250 mg 30 Stk/
|
475
465
|
include ServerMockHelper
|
476
466
|
def common_run_init(options = {})
|
477
|
-
@
|
478
|
-
@oddb2xml_xsd = File.expand_path(File.join(File.dirname(__FILE__),
|
479
|
-
@oddb_calc_xsd = File.expand_path(File.join(File.dirname(__FILE__),
|
467
|
+
@saved_dir = Dir.pwd
|
468
|
+
@oddb2xml_xsd = File.expand_path(File.join(File.dirname(__FILE__), "..", "oddb2xml.xsd"))
|
469
|
+
@oddb_calc_xsd = File.expand_path(File.join(File.dirname(__FILE__), "..", "oddb_calc.xsd"))
|
480
470
|
expect(File.exist?(@oddb2xml_xsd)).to eq true
|
481
471
|
expect(File.exist?(@oddb_calc_xsd)).to eq true
|
482
472
|
cleanup_directories_before_run
|
483
|
-
FileUtils.makedirs(Oddb2xml::
|
484
|
-
Dir.chdir(Oddb2xml::
|
473
|
+
FileUtils.makedirs(Oddb2xml::WORK_DIR)
|
474
|
+
Dir.chdir(Oddb2xml::WORK_DIR)
|
485
475
|
mock_downloads
|
486
476
|
end
|
487
477
|
|
488
478
|
after(:all) do
|
489
|
-
Dir.chdir @
|
479
|
+
Dir.chdir @saved_dir if @saved_dir && File.directory?(@saved_dir)
|
490
480
|
end
|
491
|
-
context
|
481
|
+
context "when default options are given" do
|
492
482
|
before(:all) do
|
493
483
|
common_run_init
|
494
484
|
Oddb2xml::Cli.new({}).run # to debug
|
@@ -497,87 +487,87 @@ describe Oddb2xml::Builder do
|
|
497
487
|
@rexml = REXML::Document.new File.read(oddb_article_xml)
|
498
488
|
end
|
499
489
|
|
500
|
-
it
|
501
|
-
expect(File.
|
490
|
+
it "should produce a oddb_article.xml" do
|
491
|
+
expect(File.exist?(oddb_article_xml)).to eq true
|
502
492
|
end
|
503
493
|
|
504
|
-
it
|
505
|
-
check_result(@inhalt,
|
494
|
+
it "should have a correct NBR_RECORD in oddb_article.xml" do
|
495
|
+
check_result(@inhalt, NR_PRODUCTS)
|
506
496
|
end
|
507
497
|
|
508
|
-
it
|
509
|
-
oddb_product_xml = oddb_article_xml.sub(
|
498
|
+
it "should have a correct NBR_RECORD in oddb_products.xml" do
|
499
|
+
oddb_product_xml = oddb_article_xml.sub("oddb_article.xml", "oddb_product.xml")
|
510
500
|
check_result(File.read(oddb_product_xml), 46)
|
511
501
|
end
|
512
502
|
|
513
|
-
it
|
514
|
-
expect(XPath.match(@rexml, "//ART"
|
515
|
-
expect(XPath.match(@rexml, "//ART"
|
503
|
+
it "oddb_article.xml should contain a SHA256" do
|
504
|
+
expect(REXML::XPath.match(@rexml, "//ART").first.attributes["SHA256"].size).to eq 64
|
505
|
+
expect(REXML::XPath.match(@rexml, "//ART").size).to eq REXML::XPath.match(@rexml, "//ART").size
|
516
506
|
end
|
517
507
|
|
518
|
-
it
|
508
|
+
it "should be possible to verify the oddb_article.xml" do
|
519
509
|
result = Oddb2xml.verify_sha256(oddb_article_xml)
|
520
510
|
expect(result)
|
521
511
|
end
|
522
512
|
|
523
|
-
it
|
513
|
+
it "should be possible to verify all xml files against our XSD" do
|
524
514
|
check_validation_via_xsd
|
525
515
|
end
|
526
516
|
|
527
517
|
check_attributes(oddb_article_xml, ARTICLE_ATTRIBUTE_TESTS)
|
528
518
|
check_elements(oddb_article_xml, ARTICLE_COMMON_ELEMENTS)
|
529
519
|
|
530
|
-
it
|
520
|
+
it "should validate XSD article" do
|
531
521
|
@inhalt = File.read(oddb_article_xml)
|
532
522
|
# This fails on Ruby < 2.4 as NAROPIN INJ LÖS 0.2 % 10 is wrongly encoded
|
533
523
|
expect(File.read(oddb_article_xml).scan(ARTICLE_NAROPIN).size).to eq 1
|
534
524
|
end
|
535
525
|
|
536
|
-
context
|
537
|
-
skip
|
526
|
+
context "XSD betrieb" do
|
527
|
+
skip "At the moment downloading and extractiong the medreg is broken!"
|
538
528
|
# check_attributes(oddb_betrieb_xml, BETRIEB_ATTRIBUTE_TESTS)
|
539
529
|
# check_elements(oddb_betrieb_xml, BETRIEB_COMMON_ELEMENTS)
|
540
530
|
end
|
541
531
|
|
542
|
-
context
|
543
|
-
skip
|
532
|
+
context "XSD medizinalperson" do
|
533
|
+
skip "At the moment downloading and extractiong the medreg is broken!"
|
544
534
|
# check_attributes(oddb_medizinalperson_xml, MEDIZINAPERSON_ATTRIBUTE_TESTS)
|
545
535
|
# check_elements(oddb_medizinalperson_xml, MEDIZINAPERSON_COMMON_ELEMENTS)
|
546
536
|
end
|
547
537
|
|
548
|
-
it
|
538
|
+
it "should have a correct insulin (gentechnik) for 7680532900196" do
|
549
539
|
expect(@inhalt.match(/.*<BC>7680532900196<\/BC>.*/).class).to be MatchData
|
550
|
-
expect(XPath.match(
|
551
|
-
expect(XPath.match(
|
552
|
-
expect(XPath.match(
|
553
|
-
expect(XPath.match(
|
540
|
+
expect(REXML::XPath.match(@rexml, "//ART//GEN_PRODUCTION").size).to be >= 1
|
541
|
+
expect(REXML::XPath.match(@rexml, "//ART//GEN_PRODUCTION").first.text).to eq "X"
|
542
|
+
expect(REXML::XPath.match(@rexml, "//ART//INSULIN_CATEGORY").size).to eq 1
|
543
|
+
expect(REXML::XPath.match(@rexml, "//ART//INSULIN_CATEGORY").first.text).to eq "Insulinanalog: schnell wirkend"
|
554
544
|
end
|
555
545
|
|
556
|
-
it
|
546
|
+
it "should flag fridge drugs correctly" do
|
557
547
|
doc = REXML::Document.new IO.read(checkAndGetArticleXmlName)
|
558
548
|
checkAndGetArticleWithGTIN(doc, Oddb2xml::FRIDGE_GTIN)
|
559
|
-
expect(XPath.match(
|
549
|
+
expect(REXML::XPath.match(doc, "//COOL=").size).to eq 1
|
550
|
+
expect(REXML::XPath.match(doc, "//COOL").first.text).to eq "1"
|
560
551
|
end
|
561
552
|
|
562
553
|
ean_with_drug_index = 7680555610041
|
563
554
|
it "should have a correct drug information for #{ean_with_drug_index}" do
|
564
|
-
|
555
|
+
REXML::Document.new IO.read(checkAndGetArticleXmlName)
|
565
556
|
expect(@inhalt.match(/.*<BC>#{ean_with_drug_index}<\/BC>.*/).class).to be MatchData
|
566
|
-
expect(XPath.match(
|
567
|
-
expect(XPath.match(
|
557
|
+
expect(REXML::XPath.match(@rexml, "//ART//DRUG_INDEX").size).to eq 1
|
558
|
+
expect(REXML::XPath.match(@rexml, "//ART//DRUG_INDEX").first.text).to eq "d"
|
568
559
|
found = false
|
569
|
-
XPath.match(
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
end
|
560
|
+
REXML::XPath.match(@rexml, "//ART//CDBG").each { |flag|
|
561
|
+
if flag.text.eql?("Y")
|
562
|
+
found = true
|
563
|
+
break
|
564
|
+
end
|
575
565
|
}
|
576
566
|
expect(found)
|
577
567
|
end
|
578
568
|
|
579
|
-
it
|
580
|
-
oddb_product_xml = IO.read(File.join(Oddb2xml::
|
569
|
+
it "should generate ATC for 7680002770014" do
|
570
|
+
oddb_product_xml = IO.read(File.join(Oddb2xml::WORK_DIR, "oddb_product.xml"))
|
581
571
|
text = %(<GTIN>7680002770014</GTIN>
|
582
572
|
<PRODNO>0027701</PRODNO>
|
583
573
|
<DSCRD>SEROCYTOL Herz-Gefässe Supp 3 Stk</DSCRD>
|
@@ -588,8 +578,8 @@ describe Oddb2xml::Builder do
|
|
588
578
|
expect(oddb_product_xml.index(text)).to be >= 1
|
589
579
|
end
|
590
580
|
|
591
|
-
it
|
592
|
-
oddb_product_xml = IO.read(File.join(Oddb2xml::
|
581
|
+
it "should generate ATC for 7680002770021" do
|
582
|
+
oddb_product_xml = IO.read(File.join(Oddb2xml::WORK_DIR, "oddb_product.xml"))
|
593
583
|
text2 = %( <GTIN>7680002770021</GTIN>
|
594
584
|
<PRODNO>0027701</PRODNO>
|
595
585
|
<DSCRD>Coeur-Vaisseaux Sérocytol, suppositoire</DSCRD>
|
@@ -600,401 +590,396 @@ describe Oddb2xml::Builder do
|
|
600
590
|
expect(oddb_product_xml.index(text2)).to be >= 1
|
601
591
|
end
|
602
592
|
|
603
|
-
it
|
604
|
-
expect(IO.read(oddb_article_xml).index(
|
593
|
+
it "should generate SALECD A for swissmedic packages" do
|
594
|
+
expect(IO.read(oddb_article_xml).index("<SALECD>A<!--Overriding status I nincd 10 for 7680658560014 as in refdata_pharma--></SALECD>")).to be >= 1
|
605
595
|
end
|
606
|
-
|
607
596
|
end
|
608
597
|
|
609
|
-
context
|
598
|
+
context "when -o for fachinfo is given" do
|
610
599
|
before(:all) do
|
611
600
|
common_run_init
|
612
|
-
@oddb_fi_xml
|
613
|
-
@oddb_fi_product_xml
|
614
|
-
options = Oddb2xml::Options.parse([
|
601
|
+
@oddb_fi_xml = File.expand_path(File.join(Oddb2xml::WORK_DIR, "oddb_fi.xml"))
|
602
|
+
@oddb_fi_product_xml = File.expand_path(File.join(Oddb2xml::WORK_DIR, "oddb_fi_product.xml"))
|
603
|
+
options = Oddb2xml::Options.parse(["-o", "--log"])
|
615
604
|
# @res = buildr_capture(:stdout){ Oddb2xml::Cli.new(options).run }
|
616
605
|
Oddb2xml::Cli.new(options).run
|
617
606
|
end
|
618
607
|
|
619
|
-
it
|
620
|
-
check_result(
|
608
|
+
it "should have a correct NBR_RECORD in oddb_fi_product.xml" do
|
609
|
+
check_result(File.read("oddb_fi_product.xml"), 0)
|
621
610
|
end
|
622
611
|
|
623
|
-
it
|
624
|
-
check_result(
|
612
|
+
it "should have a correct NBR_RECORD in oddb_fi.xml" do
|
613
|
+
check_result(File.read("oddb_fi.xml"), 2)
|
625
614
|
end
|
626
615
|
|
627
|
-
it
|
628
|
-
expect(File.
|
616
|
+
it "should return produce a correct oddb_fi.xml" do
|
617
|
+
expect(File.exist?(@oddb_fi_xml)).to eq true
|
629
618
|
inhalt = IO.read(@oddb_fi_xml)
|
630
|
-
expect(/<KMP/.match(inhalt.to_s).to_s).to eq
|
631
|
-
expect(/<style><!\[CDATA\[p{margin-top/.match(inhalt.to_s).to_s).to eq
|
619
|
+
expect(/<KMP/.match(inhalt.to_s).to_s).to eq "<KMP"
|
620
|
+
expect(/<style><!\[CDATA\[p{margin-top/.match(inhalt.to_s).to_s).to eq "<style><![CDATA[p{margin-top"
|
632
621
|
m = /<paragraph><!\[CDATA\[(.+)\n(.*)/.match(inhalt.to_s)
|
633
622
|
expect(m[1]).to eq '<?xml version="1.0" encoding="utf-8"?><div xmlns="http://www.w3.org/1999/xhtml">'
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
inhalt = IO.read(@oddb_fi_product_xml)
|
623
|
+
skip { m[2].should eq '<p class="s4" id="section1"><span class="s2"><span>Zyvoxid</span></span><sup class="s3"><span>®</span></sup></p>' }
|
624
|
+
expect(File.exist?(@oddb_fi_product_xml)).to eq true
|
625
|
+
IO.read(@oddb_fi_product_xml)
|
638
626
|
end
|
639
627
|
|
640
|
-
it
|
628
|
+
it "should produce valid xml files" do
|
641
629
|
skip "Niklaus does not know how to create a valid oddb_fi_product.xml"
|
642
630
|
# check_validation_via_xsd
|
643
631
|
end
|
644
632
|
|
645
|
-
it
|
633
|
+
it "should generate a valid oddb_product.xml" do
|
646
634
|
expect(@res).to match(/products/) if @res
|
647
|
-
checkProductXml(
|
635
|
+
checkProductXml(NR_PACKAGES)
|
648
636
|
end
|
649
|
-
|
650
637
|
end
|
651
638
|
|
652
|
-
context
|
639
|
+
context "when -f dat is given" do
|
653
640
|
before(:all) do
|
654
641
|
common_run_init
|
655
|
-
options = Oddb2xml::Options.parse(
|
656
|
-
@res = buildr_capture(:stdout){ Oddb2xml::Cli.new(options).run }
|
642
|
+
options = Oddb2xml::Options.parse("-f dat --log")
|
643
|
+
@res = buildr_capture(:stdout) { Oddb2xml::Cli.new(options).run }
|
657
644
|
# Oddb2xml::Cli.new(options).run # to debug
|
658
645
|
end
|
659
646
|
|
660
|
-
it
|
647
|
+
it "should contain the correct values fo CMUT from transfer.dat" do
|
661
648
|
expect(@res).to match(/products/)
|
662
|
-
dat_filename = File.join(Oddb2xml::
|
663
|
-
expect(File.
|
649
|
+
dat_filename = File.join(Oddb2xml::WORK_DIR, "oddb.dat")
|
650
|
+
expect(File.exist?(dat_filename)).to eq true
|
664
651
|
oddb_dat = IO.read(dat_filename)
|
665
652
|
expect(oddb_dat).to match(/^..2/), "should have a record with '2' in CMUT field"
|
666
653
|
expect(oddb_dat).to match(/^..3/), "should have a record with '3' in CMUT field"
|
667
|
-
expect(oddb_dat).to match(
|
668
|
-
IO.readlines(dat_filename).each{ |line| check_article_IGM_format(line, 0) }
|
654
|
+
expect(oddb_dat).to match(REG_EXP_DESITIN), "should have Desitin"
|
655
|
+
IO.readlines(dat_filename).each { |line| check_article_IGM_format(line, 0) }
|
669
656
|
m = /.+KENDURAL Depottabl 30 Stk.*7680353660163.+/.match(oddb_dat)
|
670
657
|
expect(m[0].size).to eq 97 # size of IGM 1 record
|
671
|
-
expect(m[0][74]).to eq
|
658
|
+
expect(m[0][74]).to eq "3"
|
672
659
|
end
|
673
660
|
end
|
674
661
|
|
675
|
-
context
|
662
|
+
context "when --append -f dat is given" do
|
676
663
|
before(:all) do
|
677
664
|
common_run_init
|
678
|
-
options = Oddb2xml::Options.parse(
|
679
|
-
@res = buildr_capture(:stdout){ Oddb2xml::Cli.new(options).run }
|
665
|
+
options = Oddb2xml::Options.parse("--append -f dat")
|
666
|
+
@res = buildr_capture(:stdout) { Oddb2xml::Cli.new(options).run }
|
680
667
|
end
|
681
668
|
|
682
|
-
it
|
683
|
-
dat_filename = File.join(Oddb2xml::
|
684
|
-
expect(File.
|
669
|
+
it "should generate a valid oddb_with_migel.dat" do
|
670
|
+
dat_filename = File.join(Oddb2xml::WORK_DIR, "oddb_with_migel.dat")
|
671
|
+
expect(File.exist?(dat_filename)).to eq true
|
685
672
|
oddb_dat = IO.read(dat_filename)
|
686
|
-
expect(oddb_dat).to match(
|
673
|
+
expect(oddb_dat).to match(REG_EXP_DESITIN), "should have Desitin"
|
687
674
|
expect(@res).to match(/products/)
|
688
675
|
end
|
689
676
|
|
690
677
|
it "should match EAN 76806206900842 of Desitin" do
|
691
|
-
dat_filename = File.join(Oddb2xml::
|
692
|
-
expect(File.
|
678
|
+
dat_filename = File.join(Oddb2xml::WORK_DIR, "oddb_with_migel.dat")
|
679
|
+
expect(File.exist?(dat_filename)).to eq true
|
693
680
|
oddb_dat = IO.read(dat_filename)
|
694
681
|
expect(oddb_dat).to match(/76806206900842/), "should match EAN of Desitin"
|
695
682
|
end
|
696
683
|
end
|
697
684
|
|
698
|
-
context
|
685
|
+
context "when --append -I 80 -e is given" do
|
699
686
|
before(:all) do
|
700
687
|
common_run_init
|
701
|
-
options = Oddb2xml::Options.parse(
|
688
|
+
options = Oddb2xml::Options.parse("--append -I 80 -e")
|
702
689
|
Oddb2xml::Cli.new(options).run
|
703
690
|
# @res = buildr_capture(:stdout){ Oddb2xml::Cli.new(options).run }
|
704
691
|
end
|
705
692
|
|
706
|
-
it "oddb_article with stuf from ZurRose", :
|
693
|
+
it "oddb_article with stuf from ZurRose", skip: "ZurRose contains ERYTHROCIN i.v. Troc*esteekensub 1000 mg Amp [!]" do
|
707
694
|
checkArticleXml
|
708
695
|
end
|
709
696
|
|
710
|
-
|
711
|
-
it
|
697
|
+
# Zeno used oddb2xml -e -I 45 -c zip for oddb_arcticle for artikelstamm 7680172330414 3605520301605
|
698
|
+
it "should add GTIN 7680172330414 which is marked as inactive in transfer.dat" do
|
712
699
|
@inhalt = IO.read(oddb_article_xml)
|
713
|
-
expect(@inhalt.index(
|
700
|
+
expect(@inhalt.index("7680172330414")).not_to be nil
|
714
701
|
end
|
715
702
|
|
716
|
-
it
|
703
|
+
it "should add GTIN 3605520301605 Armani Attitude which is marked as inactive in transfer.dat" do
|
717
704
|
@inhalt = IO.read(oddb_article_xml)
|
718
705
|
# <SALECD>I</SALECD>
|
719
706
|
|
720
|
-
expect(@inhalt.index(
|
707
|
+
expect(@inhalt.index("3605520301605")).not_to be nil
|
721
708
|
end
|
722
709
|
|
723
|
-
context
|
710
|
+
context "XSD" do
|
724
711
|
check_attributes(oddb_article_xml, ARTICLE_ATTRIBUTE_TESTS)
|
725
712
|
check_elements(oddb_article_xml, ARTICLE_COMMON_ELEMENTS)
|
726
713
|
check_elements(oddb_article_xml, ARTICLE_ZURROSE_ELEMENTS)
|
727
|
-
it
|
714
|
+
it "should contain NAROPIN" do
|
728
715
|
# This fails on Ruby < 2.4 as NAROPIN INJ LÖS 0.2 % 10 is wrongly encoded
|
729
716
|
expect(File.read(oddb_article_xml).scan(ARTICLE_NAROPIN).size).to eq 1
|
730
717
|
end
|
731
718
|
end
|
732
719
|
|
733
|
-
it
|
720
|
+
it "should emit a correct oddb_article.xml" do
|
734
721
|
checkArticleXml(false)
|
735
722
|
end
|
736
723
|
|
737
|
-
it
|
738
|
-
expect(@res).to match(/products/)
|
739
|
-
checkProductXml(
|
724
|
+
it "should generate a valid oddb_product.xml" do
|
725
|
+
expect(@res).to match(/products/) unless @res.nil?
|
726
|
+
checkProductXml(NR_PACKAGES)
|
740
727
|
end
|
741
728
|
|
742
|
-
it
|
729
|
+
it "should contain the correct (increased) prices" do
|
743
730
|
checkPrices(true)
|
744
731
|
end
|
745
732
|
end
|
746
733
|
|
747
|
-
context
|
734
|
+
context "when option -e is given" do
|
748
735
|
before(:all) do
|
749
736
|
common_run_init
|
750
|
-
options = Oddb2xml::Options.parse(
|
737
|
+
options = Oddb2xml::Options.parse("-e")
|
751
738
|
puts options
|
752
739
|
@cli = Oddb2xml::Cli.new(options)
|
753
740
|
if RUN_ALL
|
754
|
-
@res = buildr_capture(:stdout){ @cli.run }
|
741
|
+
@res = buildr_capture(:stdout) { @cli.run }
|
755
742
|
else
|
756
743
|
@cli.run
|
757
744
|
end
|
758
745
|
end
|
759
746
|
|
760
|
-
context
|
747
|
+
context "XSD limitation" do
|
761
748
|
check_attributes(oddb_limitation_xml, LIMITATION_ATTRIBUTE_TESTS)
|
762
749
|
check_elements(oddb_limitation_xml, LIMITATION_ELEMENT_TESTS)
|
763
750
|
end
|
764
751
|
|
765
|
-
context
|
752
|
+
context "XSD code" do
|
766
753
|
check_attributes(oddb_code_xml, CODE_ATTRIBUTE_TESTS)
|
767
754
|
check_elements(oddb_code_xml, CODE_ELEMENT_TESTS)
|
768
755
|
end
|
769
756
|
|
770
|
-
it
|
771
|
-
check_result(File.read(oddb_code_xml),
|
757
|
+
it "should have a correct NBR_RECORD in oddb_code.xml" do
|
758
|
+
check_result(File.read(oddb_code_xml), NR_CODES)
|
772
759
|
end
|
773
760
|
|
774
|
-
context
|
761
|
+
context "XSD interaction" do
|
775
762
|
check_attributes(oddb_interaction_xml, INTERACTION_ATTRIBUTE_TESTS)
|
776
763
|
check_elements(oddb_interaction_xml, INTERACTION_ELEMENT_TESTS)
|
777
764
|
end
|
778
765
|
|
779
|
-
it
|
780
|
-
check_result(File.read(oddb_interaction_xml),
|
766
|
+
it "should have a correct NBR_RECORD in oddb_interaction.xml" do
|
767
|
+
check_result(File.read(oddb_interaction_xml), NR_INTERACTIONS)
|
781
768
|
end
|
782
769
|
|
783
|
-
context
|
770
|
+
context "XSD substance" do
|
784
771
|
check_attributes(oddb_substance_xml, SUBSTANCE_ATTRIBUTE_TESTS)
|
785
772
|
check_elements(oddb_substance_xml, SUBSTANCE_ELEMENT_TESTS)
|
786
773
|
end
|
787
774
|
|
788
|
-
it
|
789
|
-
check_result(File.read(
|
775
|
+
it "should have a correct NBR_RECORD in oddb_substance.xml" do
|
776
|
+
check_result(File.read("oddb_substance.xml"), NR_SUBSTANCES)
|
790
777
|
end
|
791
778
|
|
792
|
-
it
|
779
|
+
it "should emit a correct oddb_article.xml" do
|
793
780
|
checkArticleXml
|
794
781
|
end
|
795
782
|
|
796
|
-
it
|
797
|
-
checkProductXml(
|
783
|
+
it "should produce a correct oddb_product.xml" do
|
784
|
+
checkProductXml(NR_PACKAGES)
|
798
785
|
end
|
799
786
|
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
787
|
+
if RUN_ALL
|
788
|
+
it "should report correct output on stdout" do
|
789
|
+
expect(@res).to match(/\sPharma products: \d+/)
|
790
|
+
expect(@res).to match(/\sNonPharma products: \d+/)
|
791
|
+
end
|
792
|
+
end
|
804
793
|
|
805
|
-
it
|
794
|
+
it "should contain the correct (normal) prices" do
|
806
795
|
checkPrices(false)
|
807
796
|
end
|
808
797
|
|
809
|
-
it
|
798
|
+
it "should generate the flag ORPH for orphan" do
|
810
799
|
doc = REXML::Document.new File.new(oddb_product_xml)
|
811
800
|
orphan = checkAndGetProductWithGTIN(doc, Oddb2xml::ORPHAN_GTIN)
|
812
801
|
expect(orphan).not_to eq nil
|
813
|
-
expect(orphan.elements[
|
802
|
+
expect(orphan.elements["ORPH"].text).to eq("true")
|
814
803
|
end
|
815
804
|
|
816
|
-
it
|
817
|
-
doc = REXML::Document.new File.new(checkAndGetArticleXmlName(
|
818
|
-
expect(XPath.match(
|
805
|
+
it "should generate the flag non-refdata" do
|
806
|
+
doc = REXML::Document.new File.new(checkAndGetArticleXmlName("non-refdata"))
|
807
|
+
expect(REXML::XPath.match(doc, "//REF_DATA").size).to eq NR_EXTENDED_ARTICLES
|
819
808
|
end
|
820
809
|
|
821
|
-
it
|
810
|
+
it "should generate SALECD A for migel (NINCD 13)" do
|
822
811
|
doc = REXML::Document.new File.new(checkAndGetArticleXmlName)
|
823
|
-
article = XPath.match(
|
824
|
-
expect(article.elements[
|
825
|
-
expect(article.elements[
|
812
|
+
article = REXML::XPath.match(doc, "//ART[DSCRD='ACTICOAT Flex 7 Wundverband 10x12.5cm 5 Stk']").first
|
813
|
+
expect(article.elements["SALECD"].text).to eq("A")
|
814
|
+
expect(article.elements["ARTINS/NINCD"].text).to eq("13")
|
826
815
|
end
|
827
816
|
|
828
|
-
it
|
817
|
+
it "should pass validating via oddb2xml.xsd" do
|
829
818
|
check_validation_via_xsd
|
830
819
|
end
|
831
820
|
|
832
|
-
it
|
821
|
+
it "should not contain veterinary iksnr 47066 CANIPHEDRIN" do
|
833
822
|
doc = REXML::Document.new File.new(checkAndGetArticleXmlName)
|
834
|
-
|
835
|
-
expect(XPath.match(
|
836
|
-
expect(XPath.match(
|
823
|
+
REXML::XPath.match(doc, "//ART")
|
824
|
+
expect(REXML::XPath.match(doc, "//BC").count { |x| x.text.match("47066") }).to eq(0)
|
825
|
+
expect(REXML::XPath.match(doc, "//DSCRD").count { |x| x.text.match(/CANIPHEDRIN/) }).to eq(0)
|
837
826
|
end
|
838
827
|
|
839
|
-
it
|
828
|
+
it "should handle not duplicate pharmacode 5366964" do
|
840
829
|
doc = REXML::Document.new File.new(checkAndGetArticleXmlName)
|
841
|
-
dscrds = XPath.match(
|
842
|
-
expect(XPath.match(
|
843
|
-
expect(dscrds.size).to eq(
|
844
|
-
expect(XPath.match(
|
845
|
-
expect(XPath.match(
|
846
|
-
expect(XPath.match(
|
830
|
+
dscrds = REXML::XPath.match(doc, "//ART")
|
831
|
+
expect(REXML::XPath.match(doc, "//PHAR").count { |x| x.text.match("5366964") }).to eq(1)
|
832
|
+
expect(dscrds.size).to eq(NR_EXTENDED_ARTICLES)
|
833
|
+
expect(REXML::XPath.match(doc, "//PRODNO").count { |x| true }.size).to be >= 1
|
834
|
+
expect(REXML::XPath.match(doc, "//PRODNO").count { |x| x.text.match("0027701") }).to eq(1)
|
835
|
+
expect(REXML::XPath.match(doc, "//PRODNO").count { |x| x.text.match("6206901") }).to eq(1)
|
847
836
|
end
|
848
837
|
|
849
|
-
it
|
838
|
+
it "should load correct number of nonpharma" do
|
850
839
|
puts checkAndGetArticleXmlName
|
851
840
|
doc = REXML::Document.new File.new(checkAndGetArticleXmlName)
|
852
|
-
dscrds = XPath.match(
|
853
|
-
expect(dscrds.size).to eq(
|
854
|
-
expect(XPath.match(
|
855
|
-
expect(XPath.match(
|
841
|
+
dscrds = REXML::XPath.match(doc, "//ART")
|
842
|
+
expect(dscrds.size).to eq(NR_EXTENDED_ARTICLES)
|
843
|
+
expect(REXML::XPath.match(doc, "//PHAR").count { |x| x.text.match("0000000") }).to eq(0) # 0 is not a valid pharmacode
|
844
|
+
expect(REXML::XPath.match(doc, "//PHAR").count { |x| x.text.match(/\d+/) }).to eq 66
|
856
845
|
end
|
857
846
|
|
858
|
-
it
|
859
|
-
check_result(File.read(
|
847
|
+
it "should have a correct NBR_RECORD in oddb_limitation.xml" do
|
848
|
+
check_result(File.read("oddb_limitation.xml"), NR_LIMITATIONS)
|
860
849
|
end
|
861
850
|
|
862
|
-
it
|
851
|
+
it "should emit a correct oddb_limitation.xml" do
|
863
852
|
# check limitations
|
864
|
-
limitation_filename = File.expand_path(File.join(Oddb2xml::
|
865
|
-
expect(File.
|
853
|
+
limitation_filename = File.expand_path(File.join(Oddb2xml::WORK_DIR, "oddb_limitation.xml"))
|
854
|
+
expect(File.exist?(limitation_filename)).to eq true
|
866
855
|
doc = REXML::Document.new File.new(limitation_filename)
|
867
|
-
limitations = XPath.match(
|
868
|
-
expect(limitations.size).to eql
|
869
|
-
expect(XPath.match(
|
870
|
-
expect(XPath.match(
|
871
|
-
expect(XPath.match(
|
872
|
-
expect(XPath.match(
|
873
|
-
expect(XPath.match(
|
856
|
+
limitations = REXML::XPath.match(doc, "//LIM")
|
857
|
+
expect(limitations.size).to eql NR_LIMITATIONS
|
858
|
+
expect(REXML::XPath.match(doc, "//SwissmedicNo5").count { |x| x.text.match("28486") }).to eq(1)
|
859
|
+
expect(REXML::XPath.match(doc, "//LIMNAMEBAG").count { |x| x.text.match("ZYVOXID") }).to eq(2)
|
860
|
+
expect(REXML::XPath.match(doc, "//LIMNAMEBAG").count { |x| x.text.match("070240") }).to be >= 1
|
861
|
+
expect(REXML::XPath.match(doc, "//DSCRD").count { |x| x.text.match(/^Gesamthaft zugelassen/) }).to be >= 1
|
862
|
+
expect(REXML::XPath.match(doc, "//DSCRD").count { |x| x.text.match(/^Behandlung nosokomialer Pneumonien/) }).to be >= 1
|
874
863
|
end
|
875
864
|
|
876
|
-
it
|
877
|
-
doc = REXML::Document.new File.new(File.join(Oddb2xml::
|
878
|
-
names = XPath.match(
|
879
|
-
expect(names.size).to eq(
|
880
|
-
expect(names.
|
865
|
+
it "should emit a correct oddb_substance.xml" do
|
866
|
+
doc = REXML::Document.new File.new(File.join(Oddb2xml::WORK_DIR, "oddb_substance.xml"))
|
867
|
+
names = REXML::XPath.match(doc, "//NAML")
|
868
|
+
expect(names.size).to eq(NR_SUBSTANCES)
|
869
|
+
expect(names.count { |x| x.text.match("Lamivudinum") }).to eq(1)
|
881
870
|
end
|
882
871
|
|
883
|
-
it
|
884
|
-
doc = REXML::Document.new File.new(File.join(Oddb2xml::
|
885
|
-
titles = XPath.match(
|
872
|
+
it "should emit a correct oddb_interaction.xml" do
|
873
|
+
doc = REXML::Document.new File.new(File.join(Oddb2xml::WORK_DIR, "oddb_interaction.xml"))
|
874
|
+
titles = REXML::XPath.match(doc, "//TITD")
|
886
875
|
expect(titles.size).to eq 2
|
887
|
-
expect(titles.
|
888
|
-
expect(titles.
|
876
|
+
expect(titles.count { |x| x.text.match("Keine Interaktion") }).to be >= 1
|
877
|
+
expect(titles.count { |x| x.text.match("Erhöhtes Risiko für Myopathie und Rhabdomyolyse") }).to eq(1)
|
889
878
|
end
|
890
879
|
|
891
880
|
def checkItemForSALECD(doc, ean13, expected)
|
892
|
-
article = XPath.match(
|
893
|
-
name
|
894
|
-
salecd
|
895
|
-
if $VERBOSE
|
881
|
+
article = REXML::XPath.match(doc, "//ART[ARTBAR/BC=#{ean13}]").first
|
882
|
+
name = article.elements["DSCRD"].text
|
883
|
+
salecd = article.elements["SALECD"].text
|
884
|
+
if $VERBOSE || (article.elements["SALECD"].text != expected.to_s)
|
896
885
|
puts "checking doc for ean13 #{ean13} expected #{expected} == #{salecd}. #{name}"
|
897
886
|
puts article.text
|
898
887
|
end
|
899
|
-
expect(article.elements[
|
888
|
+
expect(article.elements["SALECD"].text).to eq(expected.to_s)
|
900
889
|
end
|
901
890
|
|
902
|
-
it
|
903
|
-
expect(File.
|
904
|
-
FileUtils.cp(oddb_article_xml, File.join(Oddb2xml::
|
905
|
-
article_xml = IO.read(oddb_article_xml)
|
891
|
+
it "should generate the flag SALECD" do
|
892
|
+
expect(File.exist?(oddb_article_xml)).to eq true
|
893
|
+
FileUtils.cp(oddb_article_xml, File.join(Oddb2xml::WORK_DIR, "tst-SALECD.xml"))
|
906
894
|
doc = REXML::Document.new File.new(oddb_article_xml)
|
907
|
-
expect(XPath.match(
|
908
|
-
checkItemForSALECD(doc, Oddb2xml::FERRO_GRADUMET_GTIN,
|
909
|
-
checkItemForSALECD(doc, Oddb2xml::SOFRADEX_GTIN,
|
895
|
+
expect(REXML::XPath.match(doc, "//REF_DATA").size).to be > 0
|
896
|
+
checkItemForSALECD(doc, Oddb2xml::FERRO_GRADUMET_GTIN, "A") # FERRO-GRADUMET Depottabl 30 Stk
|
897
|
+
checkItemForSALECD(doc, Oddb2xml::SOFRADEX_GTIN, "I") # SOFRADEX
|
910
898
|
end
|
911
899
|
end
|
912
|
-
context
|
900
|
+
context "testing -e -I 80 option" do
|
913
901
|
before(:all) do
|
914
902
|
common_run_init
|
915
|
-
options = Oddb2xml::Options.parse(
|
903
|
+
options = Oddb2xml::Options.parse("-e -I 80 --log")
|
916
904
|
# @res = buildr_capture(:stdout){ Oddb2xml::Cli.new(options).run }
|
917
905
|
@res = Oddb2xml::Cli.new(options).run
|
918
906
|
end
|
919
907
|
|
920
|
-
it
|
921
|
-
expect(File.
|
922
|
-
FileUtils.cp(oddb_article_xml, File.join(Oddb2xml::
|
908
|
+
it "should add 80 percent to zur_rose pubbprice" do
|
909
|
+
expect(File.exist?(oddb_article_xml)).to eq true
|
910
|
+
FileUtils.cp(oddb_article_xml, File.join(Oddb2xml::WORK_DIR, "tst-e80.xml"))
|
923
911
|
checkArticleXml
|
924
912
|
checkPrices(true)
|
925
913
|
end
|
926
914
|
|
927
|
-
it
|
928
|
-
expect(File.
|
915
|
+
it "should generate an article for EPIMINERAL" do
|
916
|
+
expect(File.exist?(oddb_article_xml)).to eq true
|
929
917
|
doc = REXML::Document.new IO.read(oddb_article_xml)
|
930
|
-
article = XPath.match(
|
931
|
-
expect(article.elements[
|
918
|
+
article = REXML::XPath.match(doc, "//ART[PHAR=5822801]").first
|
919
|
+
expect(article.elements["DSCRD"].text).to match(/EPIMINERAL/i)
|
932
920
|
end
|
933
921
|
|
934
|
-
it
|
935
|
-
checkProductXml(
|
922
|
+
it "should generate a correct number of packages in oddb_product.xml" do
|
923
|
+
checkProductXml(NR_PACKAGES)
|
936
924
|
end
|
937
925
|
|
938
|
-
it
|
926
|
+
it "should generate an article with the COOL (fridge) attribute" do
|
939
927
|
doc = REXML::Document.new File.new(oddb_article_xml)
|
940
928
|
fridge_product = checkAndGetArticleWithGTIN(doc, Oddb2xml::FRIDGE_GTIN)
|
941
|
-
expect(fridge_product.elements[
|
929
|
+
expect(fridge_product.elements["COOL"].text).to eq("1")
|
942
930
|
end
|
943
931
|
|
944
|
-
it
|
932
|
+
it "should generate a correct oddb_article.xml" do
|
945
933
|
checkArticleXml
|
946
934
|
end
|
947
935
|
end
|
948
936
|
|
949
|
-
context
|
937
|
+
context "when -f dat -p is given" do
|
950
938
|
before(:all) do
|
951
939
|
common_run_init
|
952
|
-
options = Oddb2xml::Options.parse(
|
953
|
-
@res = buildr_capture(:stdout){ Oddb2xml::Cli.new(options).run }
|
940
|
+
options = Oddb2xml::Options.parse("-f dat -p")
|
941
|
+
@res = buildr_capture(:stdout) { Oddb2xml::Cli.new(options).run }
|
954
942
|
end
|
955
943
|
|
956
|
-
it
|
944
|
+
it "should report correct number of items" do
|
957
945
|
expect(@res).to match(/products/)
|
958
946
|
end
|
959
947
|
|
960
|
-
it
|
961
|
-
dat_filename = File.join(Oddb2xml::
|
962
|
-
expect(File.
|
948
|
+
it "should contain the correct values fo CMUT from transfer.dat" do
|
949
|
+
dat_filename = File.join(Oddb2xml::WORK_DIR, "oddb.dat")
|
950
|
+
expect(File.exist?(dat_filename)).to eq true
|
963
951
|
oddb_dat = IO.read(dat_filename)
|
964
952
|
expect(oddb_dat).to match(/^..2/), "should have a record with '2' in CMUT field"
|
965
953
|
expect(oddb_dat).to match(/^..3/), "should have a record with '3' in CMUT field"
|
966
|
-
expect(oddb_dat).to match(
|
967
|
-
IO.readlines(dat_filename).each{ |line| check_article_IGM_format(line, 0) }
|
954
|
+
expect(oddb_dat).to match(REG_EXP_DESITIN), "should have Desitin"
|
955
|
+
IO.readlines(dat_filename).each { |line| check_article_IGM_format(line, 0) }
|
968
956
|
# oddb_dat.should match(/^..1/), "should have a record with '1' in CMUT field" # we have no
|
969
957
|
end
|
970
958
|
end
|
971
959
|
|
972
|
-
context
|
960
|
+
context "when -f dat -I 80 is given" do
|
973
961
|
before(:all) do
|
974
962
|
common_run_init
|
975
|
-
options = Oddb2xml::Options.parse(
|
976
|
-
@res = buildr_capture(:stdout){ Oddb2xml::Cli.new(options).run }
|
963
|
+
options = Oddb2xml::Options.parse("-f dat -I 80")
|
964
|
+
@res = buildr_capture(:stdout) { Oddb2xml::Cli.new(options).run }
|
977
965
|
end
|
978
966
|
|
979
|
-
it
|
967
|
+
it "should report correct number of items" do
|
980
968
|
expect(@res).to match(/products/)
|
981
969
|
end
|
982
970
|
|
983
|
-
it
|
984
|
-
dat_filename = File.join(Oddb2xml::
|
985
|
-
expect(File.
|
986
|
-
|
987
|
-
oddb_dat_lines = IO.readlines(dat_filename)
|
988
|
-
IO.readlines(dat_filename).each{ |line| check_article_IGM_format(line, 892, true) }
|
971
|
+
it "should contain the corect prices" do
|
972
|
+
dat_filename = File.join(Oddb2xml::WORK_DIR, "oddb.dat")
|
973
|
+
expect(File.exist?(dat_filename)).to eq true
|
974
|
+
IO.readlines(dat_filename).each { |line| check_article_IGM_format(line, 892, true) }
|
989
975
|
end
|
990
976
|
end
|
991
|
-
context
|
992
|
-
it
|
993
|
-
lines = IO.readlines(File.join(Oddb2xml::SpecData,
|
977
|
+
context "when utf-8 to iso-8859 fails" do
|
978
|
+
it "should return a correct 8859 line" do
|
979
|
+
lines = IO.readlines(File.join(Oddb2xml::SpecData, "problems.txt"))
|
994
980
|
out = Oddb2xml.convert_to_8859_1(lines.first)
|
995
|
-
expect(out.encoding.to_s).to eq
|
996
|
-
expect(out.chomp).to eq
|
981
|
+
expect(out.encoding.to_s).to eq "ISO-8859-1"
|
982
|
+
expect(out.chomp).to eq "<NAME_DE>SENSURA Mio 1t Uro 10-33 midi con lig so op 10 Stk</NAME_DE>"
|
997
983
|
end
|
998
984
|
end
|
999
|
-
|
1000
985
|
end
|