Class: Openphar::Migrators::PhIntMigrator
- Inherits:
-
Object
- Object
- Openphar::Migrators::PhIntMigrator
- Defined in:
- lib/openphar/migrators/phint_migrator.rb
Overview
Migrates International Pharmacopoeia data from data-international-pharmacopoeia to Open Pharmacopoeia ontology format
This class reads existing Ph.Int. JSON-LD files and transforms them to the OP ontology structure, preserving radiopharmaceutical data and other Ph.Int.-specific extensions.
Constant Summary collapse
- CATEGORIES =
Category mapping for organizing monographs
{ "pharmaceutical-substances" => "pharmaceutical-substances", "radiopharmaceuticals" => "radiopharmaceuticals", "crude-drugs" => "crude-drugs", "reagents" => "reagents", "methods" => "methods", "test-solutions" => "reagents/test-solutions", "volumetric-solutions" => "reagents/volumetric-solutions", "buffer-solutions" => "reagents/buffer-solutions", "reference-substances" => "reagents/reference-substances" }.freeze
Instance Attribute Summary collapse
-
#edition_id ⇒ Object
readonly
Returns the value of attribute edition_id.
-
#output_dir ⇒ Object
readonly
Returns the value of attribute output_dir.
-
#source_dir ⇒ Object
readonly
Returns the value of attribute source_dir.
Instance Method Summary collapse
-
#initialize(source_dir:, output_dir:, edition_id: "https://www.openphar.org/data/edition/phint/phint13") ⇒ PhIntMigrator
constructor
A new instance of PhIntMigrator.
-
#run ⇒ Hash
Run the migration.
Constructor Details
#initialize(source_dir:, output_dir:, edition_id: "https://www.openphar.org/data/edition/phint/phint13") ⇒ PhIntMigrator
Returns a new instance of PhIntMigrator.
33 34 35 36 37 38 39 |
# File 'lib/openphar/migrators/phint_migrator.rb', line 33 def initialize(source_dir:, output_dir:, edition_id: "https://www.openphar.org/data/edition/phint/phint13") @source_dir = source_dir @output_dir = output_dir @edition_id = edition_id @monographs = [] @stats = { total: 0, success: 0, failed: 0, categories: Hash.new(0) } end |
Instance Attribute Details
#edition_id ⇒ Object (readonly)
Returns the value of attribute edition_id.
15 16 17 |
# File 'lib/openphar/migrators/phint_migrator.rb', line 15 def edition_id @edition_id end |
#output_dir ⇒ Object (readonly)
Returns the value of attribute output_dir.
15 16 17 |
# File 'lib/openphar/migrators/phint_migrator.rb', line 15 def output_dir @output_dir end |
#source_dir ⇒ Object (readonly)
Returns the value of attribute source_dir.
15 16 17 |
# File 'lib/openphar/migrators/phint_migrator.rb', line 15 def source_dir @source_dir end |
Instance Method Details
#run ⇒ Hash
Run the migration
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/openphar/migrators/phint_migrator.rb', line 43 def run puts "Starting Ph.Int. migration..." puts " Source: #{source_dir}" puts " Output: #{output_dir}" # Ensure output directories exist ensure_output_directories # Process JSON-LD files process_jsonld_files # Generate aggregate files generate_aggregate_files # Print statistics print_statistics @stats end |