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