Class: Oddb2xml::FhirDownloader
- Inherits:
-
Downloader
- Object
- Downloader
- Oddb2xml::FhirDownloader
- Includes:
- DownloadMethod
- Defined in:
- lib/oddb2xml/fhir_support.rb
Overview
FHIR Downloader - Downloads NDJSON from FOPH/BAG
Constant Summary collapse
- BASE_URL =
"https://epl.bag.admin.ch"- STATIC_FHIR_PATH =
"/static/fhir"- LANGUAGES =
%w[de fr it].freeze
Instance Attribute Summary
Attributes inherited from Downloader
#agent, #file2save, #type, #url
Instance Method Summary collapse
-
#download ⇒ Object
Returns either a single file path String (when –fhir_url is used) or a Hash of { “de” => path, “fr” => path, “it” => path } for per-language NDJSON files.
-
#initialize(options = {}) ⇒ FhirDownloader
constructor
A new instance of FhirDownloader.
Methods inherited from Downloader
Constructor Details
#initialize(options = {}) ⇒ FhirDownloader
Returns a new instance of FhirDownloader.
20 21 22 23 |
# File 'lib/oddb2xml/fhir_support.rb', line 20 def initialize( = {}) @options = super(, BASE_URL) end |
Instance Method Details
#download ⇒ Object
Returns either a single file path String (when –fhir_url is used) or a Hash of { “de” => path, “fr” => path, “it” => path } for per-language NDJSON files.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/oddb2xml/fhir_support.rb', line 28 def download if @options[:fhir_url] @url = @options[:fhir_url] download_one(@url) else files = {} LANGUAGES.each do |lang| url = "#{BASE_URL}#{STATIC_FHIR_PATH}/foph-sl-export-latest-#{lang}.ndjson" path = download_one(url) files[lang] = path if path end raise "FhirDownloader: no FHIR files downloaded successfully" if files.empty? files end end |