oddb2xml 3.0.25 → 3.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/spec/fhir_spec.rb CHANGED
@@ -87,6 +87,19 @@ describe "FHIR Indikationscode support" do
87
87
  pkg = item[:packages].values.first
88
88
  expect(pkg[:indication_codes]).to eq(item[:indication_codes])
89
89
  end
90
+
91
+ it "carries the indication code (INDCD) and validity dates on each package limitation" do
92
+ data = described_class.new(cyramza_fixture).to_hash
93
+ pkg = data.values.first[:packages].values.first
94
+ by_code = pkg[:limitations].each_with_object({}) { |l, h| h[l[:code]] = l }
95
+
96
+ # INDCD is the BAG Indikationscode, independent of the CUD id (= LIMCD).
97
+ expect(by_code["CYRAMZA.01"][:indcd]).to eq("20403.01")
98
+ expect(by_code["CYRAMZA.02"][:indcd]).to eq("20403.02")
99
+ # Validity dates feed <VDAT>/<VTDAT> in the v6 <ARTSL> block.
100
+ expect(by_code["CYRAMZA.01"][:vdate]).to eq("2024-10-01")
101
+ expect(by_code["CYRAMZA.02"][:vtdate]).to eq("2027-09-30")
102
+ end
90
103
  end
91
104
 
92
105
  describe Oddb2xml::FhirExtractor, "limitation text resolution" do
@@ -209,4 +222,90 @@ describe "FHIR Indikationscode support" do
209
222
  expect(xml).to include("In Kombination mit FOLFIRI")
210
223
  end
211
224
  end
225
+
226
+ describe Oddb2xml::Builder, "v6 ARTSL/INDCD emission" do
227
+ def artsl_xml(limitations)
228
+ builder = described_class.new
229
+ Nokogiri::XML::Builder.new(encoding: "utf-8") do |xml|
230
+ builder.send(:append_artsl, xml, limitations)
231
+ end.to_xml
232
+ end
233
+
234
+ it "emits an <ARTSL> block with one <ARTLIM> per indication code" do
235
+ data = Oddb2xml::FhirExtractor.new(cyramza_fixture).to_hash
236
+ lims = data.values.first[:packages].values.first[:limitations]
237
+ xml = artsl_xml(lims)
238
+
239
+ expect(xml).to include("<ARTSL>")
240
+ # PM is true because the BAG indication code is required only for SL
241
+ # price-model drugs, which is exactly what reaches this block.
242
+ expect(xml).to include("<PM>true</PM>")
243
+ expect(xml).to include("<LIMCD>CYRAMZA.01</LIMCD>")
244
+ expect(xml).to include("<INDCD>20403.01</INDCD>")
245
+ expect(xml).to include("<VDAT>2024-10-01T00:00:00</VDAT>")
246
+ expect(xml).to include("<LIMCD>CYRAMZA.02</LIMCD>")
247
+ expect(xml).to include("<INDCD>20403.02</INDCD>")
248
+ # End date present only for CYRAMZA.02 -> only that ARTLIM gets a <VTDAT>.
249
+ expect(xml).to include("<VTDAT>2027-09-30T00:00:00</VTDAT>")
250
+ expect(xml.scan("<VTDAT>").size).to eq(1)
251
+ end
252
+
253
+ it "omits <ARTSL> when no limitation carries an indication code" do
254
+ expect(artsl_xml([{code: "X", indcd: "", vdate: "2020-01-01"}])).not_to include("<ARTSL>")
255
+ expect(artsl_xml([])).not_to include("<ARTSL>")
256
+ expect(artsl_xml(nil)).not_to include("<ARTSL>")
257
+ end
258
+ end
259
+
260
+ describe Oddb2xml::Builder, "per-article INDICATION_CODE (-e / -b feed)" do
261
+ def indication_xml(limitations)
262
+ builder = described_class.new
263
+ Nokogiri::XML::Builder.new(encoding: "utf-8") do |xml|
264
+ xml.ART do
265
+ builder.send(:append_indication_codes, xml, limitations)
266
+ end
267
+ end.to_xml
268
+ end
269
+
270
+ it "emits one <INDICATION_CODE> per indication with limcd + validity dates" do
271
+ data = Oddb2xml::FhirExtractor.new(cyramza_fixture).to_hash
272
+ lims = data.values.first[:packages].values.first[:limitations]
273
+ xml = indication_xml(lims)
274
+
275
+ expect(xml.scan("<INDICATION_CODE").size).to eq(2)
276
+ expect(xml).to include('code="20403.01"')
277
+ expect(xml).to include('cud_id="CYRAMZA.01"')
278
+ expect(xml).to include('limcd="CYRAMZA.01"')
279
+ expect(xml).to include('vdat="2024-10-01T00:00:00"')
280
+ # CYRAMZA.02 has an end date -> non-empty vtdat; CYRAMZA.01 has none.
281
+ expect(xml).to include('vtdat="2027-09-30T00:00:00"')
282
+ expect(xml).to include('vtdat=""')
283
+ # The limitation text travels in the element body.
284
+ expect(xml).to include("In Kombination mit Paclitaxel")
285
+ end
286
+
287
+ it "emits nothing when no limitation carries an indication code" do
288
+ expect(indication_xml([{code: "X", indcd: "", vdate: "2020-01-01"}])).not_to include("<INDICATION_CODE")
289
+ expect(indication_xml(nil)).not_to include("<INDICATION_CODE")
290
+ end
291
+
292
+ it "produces an oddb_article.xml that validates against oddb2xml.xsd" do
293
+ items = Oddb2xml::FhirExtractor.new(cyramza_fixture).to_hash
294
+ builder = described_class.new
295
+ {
296
+ "@items" => items, "@refdata" => {}, "@packs" => {}, "@migel" => {},
297
+ "@interactions" => [], "@flags" => {}, "@orphan" => [], "@firstbase" => {},
298
+ "@substances" => [], "@codes" => {}, "@missing" => [], "@tag_suffix" => nil,
299
+ "@infos_zur_rose" => {}, "@lppvs" => {}, "@articles" => nil, "@weleda_sl" => {}
300
+ }.each { |k, v| builder.instance_variable_set(k.to_sym, v) }
301
+
302
+ xml = builder.send(:build_article)
303
+ expect(xml.scan("<INDICATION_CODE").size).to be >= 1
304
+
305
+ xsd_path = File.expand_path(File.join(File.dirname(__FILE__), "..", "oddb2xml.xsd"))
306
+ xsd = Nokogiri::XML::Schema(File.read(xsd_path))
307
+ errors = xsd.validate(Nokogiri::XML(xml))
308
+ expect(errors.map(&:message)).to eq([])
309
+ end
310
+ end
212
311
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oddb2xml
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.25
4
+ version: 3.0.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yasuhiro Asaka, Zeno R.R. Davatz, Niklaus Giger
@@ -449,6 +449,7 @@ files:
449
449
  - CLAUDE.md
450
450
  - Elexis_Artikelstamm_v003.xsd
451
451
  - Elexis_Artikelstamm_v5.xsd
452
+ - Elexis_Artikelstamm_v6.xsd
452
453
  - Gemfile
453
454
  - Gemfile.lock
454
455
  - History.txt
@@ -496,8 +497,12 @@ files:
496
497
  - oddb2xml.gemspec
497
498
  - oddb2xml.xsd
498
499
  - oddb_calc.xsd
500
+ - scripts/generate_index_html.sh
499
501
  - scripts/run_oddb2xml.sh
502
+ - scripts/setup_mediupdatexml_web.sh
503
+ - scripts/swissmedic_watch.sh
500
504
  - scripts/transfer.sh
505
+ - scripts/visitor_stats.py
501
506
  - spec/artikelstamm_spec.rb
502
507
  - spec/builder_spec.rb
503
508
  - spec/calc_spec.rb