Class: Openphar::Migrators::PhInt::Classifier
- Inherits:
-
Object
- Object
- Openphar::Migrators::PhInt::Classifier
- Defined in:
- lib/openphar/migrators/ph_int/classifier.rb
Overview
Single dispatch point mapping a Ph.Int. record's section_id to the correct Openphar::Models::PhInt::* subclass.
Ph.Int. is organized by section number:
1 preface
4 general notices
5 abbreviations
6.1 pharmaceutical substances (chemical)
6.2 dosage forms
6.3 radiopharmaceuticals (specific)
7 methods
8 radiopharmaceuticals (general)
9 reagents / reference substances
10 supplementary
Constant Summary collapse
- SECTION_PATTERNS =
[ { regex: %r{\A6\.1\.}, klass: 'DosageFormMonograph' }, # default for 6.1 — overridden below { regex: %r{\A6\.2\.1\.}, klass: 'DosageFormMonograph' }, { regex: %r{\A6\.2\.2\.}, klass: 'DosageFormMonograph' }, { regex: %r{\A6\.3\.}, klass: 'RadiopharmaceuticalMonograph' }, { regex: %r{\A7\.}, klass: 'TestMethod' }, { regex: %r{\A8\.}, klass: 'RadiopharmaceuticalMonograph' }, { regex: %r{\A9\.}, klass: 'Reagent' }, ].freeze
- SECTION_DEFAULTS =
{ '6.1' => 'DosageFormMonograph', # Ph.Int. substances are typically 6.1.x }.freeze
- FINAL_FALLBACK =
'Monograph'.freeze
Class Method Summary collapse
- .all_types ⇒ Object
-
.classify(section_id:, entity_type: nil) ⇒ Class
A subclass of Openphar::Models::PhInt's namespaces.
Class Method Details
.all_types ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/openphar/migrators/ph_int/classifier.rb', line 54 def all_types %i[RadiopharmaceuticalMonograph DosageFormMonograph TestMethod Reagent TestSolution VolumetricSolution BufferSolution ReferenceSubstance].map do |k| Openphar::Models::PhInt.const_get(k) end end |
.classify(section_id:, entity_type: nil) ⇒ Class
Returns a subclass of Openphar::Models::PhInt's namespaces.
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/openphar/migrators/ph_int/classifier.rb', line 42 def classify(section_id:, entity_type: nil) return Openphar::Models::Monograph if section_id.nil? || section_id.empty? klass_name = resolve(section_id) # Ph.Int. classes live under Openphar::Models::PhInt::* return Openphar::Models::PhInt.const_get(klass_name) if Openphar::Models::PhInt.const_defined?(klass_name) Openphar::Models::Monograph rescue NameError Openphar::Models::Monograph end |