oddb2xml 3.0.3 → 3.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 25c142b0dfeb3bb43d540e7d9837b5199d5e2eb7c5afbd07fe278f8e4b40516e
4
- data.tar.gz: d9dad26c7d08193bc3af27262ebfd32f0edce7d4c56e457d6d3cfabf845900c7
3
+ metadata.gz: 3a0a4cbd5ff288013064ffb6d756ed0961fd98e52b6960fbfd32b4328a039369
4
+ data.tar.gz: 60c9943c0a7f344ecf87e04f16314da1b8a29e0801a8d7e814d265932f89e443
5
5
  SHA512:
6
- metadata.gz: bd8480feba005844d3d2dd46f31a69bce0cdf076a75c041eeed53808a66733cb821cdc6633ae82cbba4a1347822ec123bf2ed594609145ceb8c3227ab06f7433
7
- data.tar.gz: ebee25f81ef3c9f56c748175fca7d8c12c1894a3ba5db1d94d4c494f0deb223192af0f727cf567921981ce00e99f412789ba92a1cd5ae11f8c80d745dba99cfa
6
+ metadata.gz: 75abbcde0acf8e33b8489dd03fc06e6bd8796f571444b0a7f7eb3cded37a25f0938d8db07a7ef6ef0023412e3ab2336c046be3447fb5dc371dd02f06c5950e12
7
+ data.tar.gz: 9cf7e4c5eecd5d708dea61b4c6e17a206f6f4eaa65742ae2ee0c7ea3a49d0b4e4ae2dad7d9ffd3c2e61191e8703693ea29b3aa194d517226f828282ff5b3f891
data/CLAUDE.md CHANGED
@@ -37,7 +37,7 @@ The system follows a **download → extract → build → compress** pipeline:
37
37
 
38
38
  1. **CLI** (`lib/oddb2xml/cli.rb`) — Entry point. Parses options via Optimist (`options.rb`), orchestrates the pipeline, manages multi-threaded downloads.
39
39
 
40
- 2. **Downloaders** (`lib/oddb2xml/downloader.rb`) — 11 subclasses of `Downloader`, each fetching from a specific Swiss data source. Files cached in `./downloads/`.
40
+ 2. **Downloaders** — 11 subclasses of `Downloader`, each fetching from a specific Swiss data source. 10 live in `lib/oddb2xml/downloader.rb`; the FHIR downloader lives in `lib/oddb2xml/fhir_support.rb`. Files cached in `./downloads/`.
41
41
 
42
42
  3. **Extractors** (`lib/oddb2xml/extractor.rb`) — Matching extractor classes that parse downloaded files into Ruby hashes. Formats include XML (nokogiri/sax-machine), XLSX (rubyXL), CSV, and fixed-width text. Refdata uses the new SwissReg XML format from a zip download (`files.refdata.ch`).
43
43
 
@@ -47,6 +47,8 @@ The system follows a **download → extract → build → compress** pipeline:
47
47
 
48
48
  6. **Compressor** (`lib/oddb2xml/compressor.rb`) — Optional ZIP/TAR.GZ output compression.
49
49
 
50
+ 7. **FHIR support** (`lib/oddb2xml/fhir_support.rb`) — Self-contained module providing `FhirDownloader` and FHIR NDJSON parsing. Activated via `--fhir` (or `--fhir-url=<URL>`). Downloads per-language NDJSON files (`foph-sl-export-latest-{de,fr,it}.ndjson`) from `epl.bag.admin.ch` to populate French and Italian product names/descriptions. Maps legal status codes `756005022007` and `756005022008` to Swissmedic category D.
51
+
50
52
  ### Key data identifiers
51
53
  - **GTIN/EAN13**: Primary article identifier (13-digit barcode)
52
54
  - **Pharmacode**: Swiss pharmacy code
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- oddb2xml (3.0.3)
4
+ oddb2xml (3.0.4)
5
5
  htmlentities
6
6
  httpi
7
7
  mechanize (>= 2.8.5)
data/History.txt CHANGED
@@ -1,3 +1,6 @@
1
+ === 3.0.4 / 24.04.2026
2
+ * Firstbase: switch -b/--firstbase from the deprecated pillbox.oddb.org XLSX to the GS1 Switzerland CSV at https://id.gs1.ch/01/07612345000961 (full firstbase barcode registry, ~189k items). Downloaded file is now firstbase.csv; FirstbaseExtractor now parses CSV with headers instead of XLSX.
3
+
1
4
  === 3.0.3 / 24.04.2026
2
5
  * FHIR: download per-language NDJSON files (foph-sl-export-latest-{de,fr,it}.ndjson) so French and Italian product names/descriptions are populated
3
6
  * FHIR: map legal status code 756005022008 to Swissmedic category D (in addition to 756005022007)
data/README.md CHANGED
@@ -51,7 +51,7 @@ HIN (http://hin.ch) creates daily the actual file. They can be downloaded from `
51
51
  see `--help`.
52
52
 
53
53
  ```
54
- /opt/src/oddb2xml_v5/bin/oddb2xml version 2.4.3
54
+ /opt/src/oddb2xml/bin/oddb2xml version 3.0.4
55
55
  Usage:
56
56
  oddb2xml [option]
57
57
  produced files are found under data
@@ -61,6 +61,10 @@ see `--help`.
61
61
  -e, --extended pharma, non-pharma plus prices and non-pharma from zurrose.
62
62
  Products without EAN-Code will also be listed.
63
63
  File oddb_calc.xml will also be generated
64
+ --fhir Use FHIR NDJSON format from FOPH/BAG instead of XML
65
+ from Spezialitätenliste. Downloads per-language
66
+ NDJSON files (de, fr, it) from epl.bag.admin.ch.
67
+ --fhir-url=<s> Specific FHIR NDJSON URL to download (implies --fhir)
64
68
  -f, --format=<s> File format F, default is xml. {xml|dat}
65
69
  If F is given, -o option is ignored. (Default: xml)
66
70
  -i, --include Include target option for ean14 for 'dat' format.
@@ -80,6 +84,8 @@ see `--help`.
80
84
  Downloaded files are saved under downloads
81
85
  --log log important actions
82
86
  -u, --use-ra11zip=<s> Use the ra11.zip (a zipped transfer.dat from Galexis)
87
+ -b, --firstbase Build all NONPHARMA articles on firstbase
88
+ (GS1 Switzerland CSV from id.gs1.ch)
83
89
  -v, --version Print version and exit
84
90
  -h, --help Show this message
85
91
  ```
@@ -106,8 +112,8 @@ FR
106
112
 
107
113
  ## Supported ruby version
108
114
 
109
- We run tests on travis-ci.org for the Ruby versions mentioned in the .travis.yml file. You will need ruby > 2.5 to work correctly.
110
- Look at the github actions to see the spec test results. We ignore errors against ruby head, as it is sometimes unstable.
115
+ You will need ruby >= 2.5 to work correctly. Current development happens on Ruby 3.2 (`.ruby-version`).
116
+ CI runs on Ruby 3.0, 3.1 and 3.2 via GitHub Actions see the badge above for the latest spec results.
111
117
 
112
118
 
113
119
  ## XSD files
@@ -283,6 +289,8 @@ We use the following files:
283
289
  * http://download.swissmedicinfo.ch/ (AipsDownload)
284
290
  * https://raw.githubusercontent.com/zdavatz/oddb2xml_files/master/LPPV.txt
285
291
  * https://raw.githubusercontent.com/zdavatz/cpp2sqlite/master/input/atc_codes_multi_lingual.txt
292
+ * https://epl.bag.admin.ch/static/fhir/foph-sl-export-latest-{de,fr,it}.ndjson (FHIR NDJSON, used with `--fhir`)
293
+ * https://id.gs1.ch/01/07612345000961 (GS1 Switzerland firstbase CSV — full barcode registry, used with `-b`/`--firstbase`)
286
294
 
287
295
  ## Rules for matching GTIN (aka EAN13), product number and IKSNR
288
296
 
@@ -342,14 +342,14 @@ module Oddb2xml
342
342
  end
343
343
 
344
344
  class FirstbaseDownloader < Downloader
345
- BASE_URL = "http://pillbox.oddb.org"
345
+ BASE_URL = "https://id.gs1.ch/01/07612345000961"
346
346
  include DownloadMethod
347
347
  def initialize(type = :orphan, options = {})
348
- @url = BASE_URL + "/firstbase.xlsx"
348
+ @url = BASE_URL
349
349
  end
350
350
 
351
351
  def download
352
- @file2save = File.join(DOWNLOADS, "firstbase.xlsx")
352
+ @file2save = File.join(DOWNLOADS, "firstbase.csv")
353
353
  report_download(@url, @file2save)
354
354
  begin
355
355
  download_as(@file2save, "w+")
@@ -608,32 +608,28 @@ module Oddb2xml
608
608
 
609
609
  class FirstbaseExtractor < Extractor
610
610
  def initialize(file)
611
- @sheet = RubyXL::Parser.parse(file).worksheets[0]
611
+ @file = file
612
612
  end
613
613
 
614
614
  def to_hash
615
615
  data = {}
616
- return data unless @sheet
617
- @sheet.each_with_index do |row, i|
618
- next if i <= 1
619
- if row.nil?
620
- puts "Empty row (#{i}) in firstbase"
621
- next
622
- end
623
- gtin = row[0].value.to_s.gsub(/^0+/, '')
616
+ return data unless @file && File.exist?(@file)
617
+ CSV.foreach(@file, headers: true, encoding: "UTF-8") do |row|
618
+ gtin = row["Gtin"].to_s.gsub(/^0+/, "")
619
+ next if gtin.empty?
624
620
  data[gtin] = {
625
621
  gtin: gtin,
626
- gln: row[1].value.to_s,
627
- target_market: row[2] ? row[2].value.to_s: "",
628
- gpc: row[3] ? row[3].value.to_s: "",
629
- trade_item_description_de: row[4] ? row[4].value.to_s: "",
630
- trade_item_description_en: row[5] ? row[5].value.to_s: "",
631
- trade_item_description_fr: row[6] ? row[6].value.to_s: "",
632
- trade_item_description_it: row[7] ? row[7].value.to_s: "",
633
- manufacturer_name: row[8] ? row[8].value.to_s: "",
634
- start_availability_date: row[9] ? row[9].value.to_s: "",
635
- gross_weight: row[10] ? row[10].value.to_s: "",
636
- net_weight: row[11] ? row[11].value.to_s: "",
622
+ gln: row["InformationProviderGln"].to_s,
623
+ target_market: row["TargetMarketCountryCode"].to_s,
624
+ gpc: row["GpcCategoryCode"].to_s,
625
+ trade_item_description_de: row["TradeItemDescription_DE"].to_s,
626
+ trade_item_description_en: "",
627
+ trade_item_description_fr: row["TradeItemDescription_FR"].to_s,
628
+ trade_item_description_it: row["TradeItemDescription_IT"].to_s,
629
+ manufacturer_name: row["InformationProviderPartyName"].to_s,
630
+ start_availability_date: row["Date_Created_Batch"].to_s,
631
+ gross_weight: "",
632
+ net_weight: "",
637
633
  }
638
634
  end
639
635
  data
@@ -45,7 +45,7 @@ module Oddb2xml
45
45
  opt :log, "log important actions", short: :none
46
46
  opt :use_ra11zip, "Use the ra11.zip (a zipped transfer.dat from Galexis)",
47
47
  default: File.exist?("ra11.zip") ? "ra11.zip" : nil, type: :string
48
- opt :firstbase, "Build all NONPHARMA articles on firstbase", short: "b", default: false
48
+ opt :firstbase, "Build all NONPHARMA articles on firstbase (GS1 Switzerland CSV from id.gs1.ch)", short: "b", default: false
49
49
  end
50
50
 
51
51
  @opts[:percent] = @opts[:increment]
@@ -1,3 +1,3 @@
1
1
  module Oddb2xml
2
- VERSION = "3.0.3"
2
+ VERSION = "3.0.4"
3
3
  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.3
4
+ version: 3.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yasuhiro Asaka, Zeno R.R. Davatz, Niklaus Giger