openphar 0.1.1 → 0.2.0

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: 280d70f7579d3cb228333df16ec115b82188d187cc1048ac36175306deb776ac
4
- data.tar.gz: 758ea9d16267bbe17b97bfee72b2822ef94099ea306e3f6adf3c74fe1bd30a02
3
+ metadata.gz: 5dd4f17d1b59a9bdc713b0fa937db90801e73d0f55d9cb24004896d7bb66ea34
4
+ data.tar.gz: c502340959befd898a1d5c9cbad4378d66641249727f3e1389e57f814a33507a
5
5
  SHA512:
6
- metadata.gz: d16970a8e1c456ca1218b84167f9bd8d9882f0bca5882380ea63d6521df404ec66b34c95fb764ba1c8181f2be83e1ab0850bf7624b67c074db8fc6268ce5b5d2
7
- data.tar.gz: 6cf813f872155cbf7f767bf1393c8c199a9f1c0c86fbb16597a748a3f84f18a1380e52c4f1631ec7298dfc306290661b0c157c3447041e766aade3e71cf8ac39
6
+ metadata.gz: e8c67e7a899c88463d3d9e9e999c719b3983d9f2453694aac56d828245bcf4368246830131749442752c3ace8ab66228625b704b3eb1596a157272016bd2b164
7
+ data.tar.gz: 83e18e3668f09cc0e6fa430e81687a8cb96bddf3f4f7fb779eb93f2b3eaef991cea9608b539163311fc0d67e5b99ad7e955e3ed0d70d3a21b2efecc044d1b0c6
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Openphar
4
+ # Frozen set of recognized harmonized type names.
5
+ #
6
+ # Every publisher subclass's `harmonized_type` (when non-nil) must be in
7
+ # this list. Specs verify that. Catches typos at definition time.
8
+ #
9
+ module HarmonizedTypeRegistry
10
+ RECOGNIZED = %w[
11
+ Monograph
12
+ CrudeDrug
13
+ ChemicalDrug
14
+ Formulation
15
+ BiologicalSubstance
16
+ Vitamin
17
+ AminoAcid
18
+ MineralSubstance
19
+ Radiopharmaceutical
20
+ DosageForm
21
+ TestMethod
22
+ Reagent
23
+ ReferenceSubstance
24
+ GeneralChapter
25
+ ].freeze
26
+
27
+ class << self
28
+ def valid?(type)
29
+ return false if type.nil?
30
+
31
+ RECOGNIZED.include?(type.to_s)
32
+ end
33
+
34
+ def assert!(type)
35
+ return if valid?(type)
36
+
37
+ raise ArgumentError, "unknown harmonized type: #{type.inspect}. " \
38
+ "Must be one of: #{RECOGNIZED.join(', ')}"
39
+ end
40
+
41
+ def all
42
+ RECOGNIZED.dup
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Openphar
4
+ module Migrators
5
+ module JP
6
+ # Single dispatch point mapping a JP record's type string to the
7
+ # correct Openphar::Models::JP::* subclass.
8
+ #
9
+ # JP's HTML parser already produces a type string (e.g.,
10
+ # "CrudeDrugMonograph"); the classifier trusts it and maps to the
11
+ # JP-specific subclass. Falls back to JP::Monograph for unknown
12
+ # type strings.
13
+ #
14
+ # MECE invariant: every type string in TYPE_MAP classifies to
15
+ # exactly one subclass; every other input falls back to the base.
16
+ #
17
+ class Classifier
18
+ TYPE_MAP = {
19
+ 'CrudeDrugMonograph' => 'CrudeDrug',
20
+ 'ChemicalDrugMonograph' => 'ChemicalDrug',
21
+ 'FormulationMonograph' => 'Formulation',
22
+ 'BiologicalSubstanceMonograph' => 'Biological',
23
+ 'VitaminMonograph' => 'Vitamin',
24
+ 'AminoAcidMonograph' => 'AminoAcid',
25
+ 'MineralSubstanceMonograph' => 'Mineral',
26
+ }.freeze
27
+
28
+ FINAL_FALLBACK = 'Monograph'.freeze
29
+
30
+ class << self
31
+ # @param type_string [String, nil] Harmonized type string from the parser.
32
+ # @param name [String, nil] Monograph name (for name-based heuristics, deferred).
33
+ # @return [Class] a subclass of Openphar::Models::JP::Monograph
34
+ def classify(type_string:, name: nil)
35
+ klass_name = TYPE_MAP.fetch(type_string, FINAL_FALLBACK)
36
+ Openphar::Models::JP.const_get(klass_name)
37
+ end
38
+
39
+ def all_types
40
+ %i[CrudeDrug ChemicalDrug Formulation Biological
41
+ Excipient Vitamin AminoAcid Mineral].map do |k|
42
+ Openphar::Models::JP.const_get(k)
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Openphar
4
+ module Migrators
5
+ # Japan Pharmacopoeia migrator namespace.
6
+ #
7
+ module JP
8
+ autoload :Classifier, 'openphar/migrators/jp/classifier'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,74 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Openphar
4
+ module Migrators
5
+ module PhInt
6
+ # Single dispatch point mapping a Ph.Int. record's section_id to the
7
+ # correct Openphar::Models::PhInt::* subclass.
8
+ #
9
+ # Ph.Int. is organized by section number:
10
+ # 1 preface
11
+ # 4 general notices
12
+ # 5 abbreviations
13
+ # 6.1 pharmaceutical substances (chemical)
14
+ # 6.2 dosage forms
15
+ # 6.3 radiopharmaceuticals (specific)
16
+ # 7 methods
17
+ # 8 radiopharmaceuticals (general)
18
+ # 9 reagents / reference substances
19
+ # 10 supplementary
20
+ #
21
+ class Classifier
22
+ SECTION_PATTERNS = [
23
+ { regex: %r{\A6\.1\.}, klass: 'DosageFormMonograph' }, # default for 6.1 — overridden below
24
+ { regex: %r{\A6\.2\.1\.}, klass: 'DosageFormMonograph' },
25
+ { regex: %r{\A6\.2\.2\.}, klass: 'DosageFormMonograph' },
26
+ { regex: %r{\A6\.3\.}, klass: 'RadiopharmaceuticalMonograph' },
27
+ { regex: %r{\A7\.}, klass: 'TestMethod' },
28
+ { regex: %r{\A8\.}, klass: 'RadiopharmaceuticalMonograph' },
29
+ { regex: %r{\A9\.}, klass: 'Reagent' },
30
+ ].freeze
31
+
32
+ SECTION_DEFAULTS = {
33
+ '6.1' => 'DosageFormMonograph', # Ph.Int. substances are typically 6.1.x
34
+ }.freeze
35
+
36
+ FINAL_FALLBACK = 'Monograph'.freeze
37
+
38
+ class << self
39
+ # @param section_id [String, nil] e.g., "6.1.1", "7.1", "9.1"
40
+ # @param entity_type [String, nil] Optional explicit type hint
41
+ # @return [Class] a subclass of Openphar::Models::PhInt's namespaces
42
+ def classify(section_id:, entity_type: nil)
43
+ return Openphar::Models::Monograph if section_id.nil? || section_id.empty?
44
+
45
+ klass_name = resolve(section_id)
46
+ # Ph.Int. classes live under Openphar::Models::PhInt::*
47
+ return Openphar::Models::PhInt.const_get(klass_name) if Openphar::Models::PhInt.const_defined?(klass_name)
48
+
49
+ Openphar::Models::Monograph
50
+ rescue NameError
51
+ Openphar::Models::Monograph
52
+ end
53
+
54
+ def all_types
55
+ %i[RadiopharmaceuticalMonograph DosageFormMonograph
56
+ TestMethod Reagent TestSolution VolumetricSolution
57
+ BufferSolution ReferenceSubstance].map do |k|
58
+ Openphar::Models::PhInt.const_get(k)
59
+ end
60
+ end
61
+
62
+ private
63
+
64
+ def resolve(section_id)
65
+ SECTION_PATTERNS.each do |rule|
66
+ return rule[:klass] if section_id.match?(rule[:regex])
67
+ end
68
+ FINAL_FALLBACK
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Openphar
4
+ module Migrators
5
+ # International Pharmacopoeia (Ph.Int.) migrator namespace.
6
+ #
7
+ module PhInt
8
+ autoload :Classifier, 'openphar/migrators/ph_int/classifier'
9
+ end
10
+ end
11
+ end
@@ -11,5 +11,7 @@ module Openphar
11
11
  autoload :PhIntMigrator, 'openphar/migrators/phint_migrator'
12
12
  autoload :Chp, 'openphar/migrators/chp'
13
13
  autoload :ChpMigrator, 'openphar/migrators/chp_migrator'
14
+ autoload :JP, 'openphar/migrators/jp'
15
+ autoload :PhInt, 'openphar/migrators/ph_int'
14
16
  end
15
17
  end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Openphar
4
+ module Models
5
+ module AHP
6
+ # American Herbal Pharmacopoeia monograph (base + stub).
7
+ #
8
+ # AHP-specific therapeutic/safety profiles are deferred; this class
9
+ # exists so AHP records classify and serialize through the standard
10
+ # openphar pipeline today.
11
+ #
12
+ class Monograph < Openphar::Models::Monograph
13
+ attribute :western_herb_name, :string
14
+ attribute :latin_name, :string
15
+
16
+ json do
17
+ map 'westernHerbName', to: :western_herb_name
18
+ map 'latinName', to: :latin_name
19
+ end
20
+
21
+ class << self
22
+ def wire_key = 'monograph'
23
+ def harmonized_type = 'CrudeDrug'
24
+ def jsonld_type = 'AhpMonograph'
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -5,9 +5,6 @@ module Openphar
5
5
  # American Herbal Pharmacopoeia (AHP) specific models.
6
6
  #
7
7
  # Contains models unique to the American Herbal Pharmacopoeia:
8
- # - Western herbal monographs with comprehensive therapeutic information
9
- # - Safety and efficacy profiles
10
- # - Detailed analytical methods for botanicals
11
8
  #
12
9
  # @example
13
10
  # # Access AHP models
@@ -15,11 +12,6 @@ module Openphar
15
12
  #
16
13
  # @see https://www.herbal-ahp.org/
17
14
  module AHP
18
- # Placeholder for AHP-specific models
19
- # Will include:
20
- # - HerbalMonograph (Western herbal medicine)
21
- # - TherapeuticProfile
22
- # - SafetyProfile
23
- end
15
+ autoload :Monograph, 'openphar/models/ahp/monograph' end
24
16
  end
25
17
  end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Openphar
4
+ module Models
5
+ module API
6
+ # Ayurvedic Pharmacopoeia of India monograph (base + stub).
7
+ #
8
+ # Ayurveda-specific properties (rasa, guna, virya, vipaka, karma) are
9
+ # deferred; this class exists so API records classify and serialize
10
+ # through the standard openphar pipeline today.
11
+ #
12
+ class Monograph < Openphar::Models::Monograph
13
+ attribute :sanskrit_name, :string
14
+ attribute :ayurvedic_category, :string
15
+
16
+ json do
17
+ map 'sanskritName', to: :sanskrit_name
18
+ map 'ayurvedicCategory', to: :ayurvedic_category
19
+ end
20
+
21
+ class << self
22
+ def wire_key = 'monograph'
23
+ def harmonized_type = 'CrudeDrug'
24
+ def jsonld_type = 'ApiMonograph'
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -5,9 +5,6 @@ module Openphar
5
5
  # Ayurvedic Pharmacopoeia of India (API) specific models.
6
6
  #
7
7
  # Contains models unique to the Ayurvedic Pharmacopoeia of India:
8
- # - Dravya (Ayurvedic substances) with Rasa/Guna/Virya/Vipaka/Karma properties
9
- # - Traditional Ayurvedic formulations (Asava, Arishta, Bhasma, etc.)
10
- # - Classical preparation methods
11
8
  #
12
9
  # @example
13
10
  # # Access API models
@@ -16,14 +13,6 @@ module Openphar
16
13
  #
17
14
  # @see https://main.ayush.gov.in/
18
15
  module API
19
- # Placeholder for API-specific models
20
- # Will include:
21
- # - DravyaMonograph (Ayurvedic substances)
22
- # - AyurvedicFormula (classical formulations)
23
- # - Rasa (taste properties)
24
- # - Guna (quality properties)
25
- # - Virya (potency)
26
- # - Vipaka (post-digestive effect)
27
- end
16
+ autoload :Monograph, 'openphar/models/api/monograph' end
28
17
  end
29
18
  end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Openphar
4
+ module Models
5
+ module HKCMMS
6
+ # Hong Kong Chinese Materia Medica Standards monograph (base + stub).
7
+ #
8
+ # TCM-specific properties (nature, flavor, meridian) are deferred;
9
+ # this class exists so HKCMMS records classify and serialize today.
10
+ #
11
+ class Monograph < Openphar::Models::Monograph
12
+ attribute :chinese_name, :string
13
+ attribute :english_name, :string
14
+
15
+ json do
16
+ map 'chineseName', to: :chinese_name
17
+ map 'englishName', to: :english_name
18
+ end
19
+
20
+ class << self
21
+ def wire_key = 'monograph'
22
+ def harmonized_type = 'CrudeDrug'
23
+ def jsonld_type = 'HkcmmsMonograph'
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -5,9 +5,6 @@ module Openphar
5
5
  # Hong Kong Chinese Medicine (HKCMMS) specific models.
6
6
  #
7
7
  # Contains models unique to the Hong Kong Chinese Materia Medica Standards:
8
- # - Traditional Chinese Medicine monographs
9
- # - Bilingual (Chinese/English) content
10
- # - TCM-specific properties (nature, flavor, meridian)
11
8
  #
12
9
  # @example
13
10
  # # Access HKCMMS models
@@ -15,12 +12,6 @@ module Openphar
15
12
  #
16
13
  # @see https://www.cmchk.org.hk/
17
14
  module HKCMMS
18
- # Placeholder for HKCMMS-specific models
19
- # Will include:
20
- # - TcmMonograph (Traditional Chinese Medicine)
21
- # - TcmNature (thermal nature: hot/warm/neutral/cool/cold)
22
- # - TcmFlavor (five flavors)
23
- # - TcmMeridian (meridian tropism)
24
- end
15
+ autoload :Monograph, 'openphar/models/hkcmms/monograph' end
25
16
  end
26
17
  end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Openphar
4
+ module Models
5
+ module JP
6
+ # Amino acid monograph.
7
+ #
8
+ class AminoAcid < Monograph
9
+ class << self
10
+ def wire_key = 'amino_acid'
11
+ def harmonized_type = 'AminoAcid'
12
+ def jsonld_type = 'JpAminoAcid'
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Openphar
4
+ module Models
5
+ module JP
6
+ # Biological substance monograph.
7
+ #
8
+ class Biological < Monograph
9
+ class << self
10
+ def wire_key = 'biological'
11
+ def harmonized_type = 'BiologicalSubstance'
12
+ def jsonld_type = 'JpBiological'
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Openphar
4
+ module Models
5
+ module JP
6
+ # Chemical drug monograph (substance or preparation).
7
+ #
8
+ class ChemicalDrug < Monograph
9
+ class << self
10
+ def wire_key = 'chemical_drug'
11
+ def harmonized_type = 'ChemicalDrug'
12
+ def jsonld_type = 'JpChemicalDrug'
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Openphar
4
+ module Models
5
+ module JP
6
+ # Crude drug (herbal medicine) monograph.
7
+ #
8
+ class CrudeDrug < Monograph
9
+ class << self
10
+ def wire_key = 'crude_drug'
11
+ def harmonized_type = 'CrudeDrug'
12
+ def jsonld_type = 'JpCrudeDrug'
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Openphar
4
+ module Models
5
+ module JP
6
+ # Excipient monograph. No dedicated harmonized base class yet —
7
+ # excipients are an emerging category that may get a dedicated
8
+ # type in a future ontology revision.
9
+ #
10
+ class Excipient < Monograph
11
+ class << self
12
+ def wire_key = 'excipient'
13
+ def harmonized_type = nil
14
+ def jsonld_type = 'JpExcipient'
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Openphar
4
+ module Models
5
+ module JP
6
+ # Formulation (finished product) monograph.
7
+ #
8
+ class Formulation < Monograph
9
+ class << self
10
+ def wire_key = 'formulation'
11
+ def harmonized_type = 'Formulation'
12
+ def jsonld_type = 'JpFormulation'
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Openphar
4
+ module Models
5
+ module JP
6
+ # Mineral substance monograph.
7
+ #
8
+ class Mineral < Monograph
9
+ class << self
10
+ def wire_key = 'mineral'
11
+ def harmonized_type = 'MineralSubstance'
12
+ def jsonld_type = 'JpMineral'
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Openphar
4
+ module Models
5
+ module JP
6
+ # Base class for all Japan Pharmacopoeia monographs.
7
+ #
8
+ # Carries JP-specific identity (japanese_name, english_name, category)
9
+ # on top of the harmonized Openphar::Models::Monograph. Concrete
10
+ # subclasses declare their semantic @type via class methods.
11
+ #
12
+ class Monograph < Openphar::Models::Monograph
13
+ attribute :japanese_name, :string
14
+ attribute :english_name, :string
15
+ attribute :category, :string
16
+
17
+ json do
18
+ map 'japaneseName', to: :japanese_name
19
+ map 'englishName', to: :english_name
20
+ map 'category', to: :category
21
+ end
22
+
23
+ class << self
24
+ def wire_key
25
+ 'monograph'
26
+ end
27
+
28
+ def harmonized_type
29
+ nil
30
+ end
31
+
32
+ def jsonld_type
33
+ 'JpMonograph'
34
+ end
35
+
36
+ def jsonld_types
37
+ types = ['Monograph']
38
+ types << harmonized_type if harmonized_type
39
+ types << jsonld_type unless jsonld_type == 'Monograph'
40
+ types.uniq
41
+ end
42
+
43
+ def neo4j_labels
44
+ labels = %w[Monograph JP]
45
+ labels << harmonized_type if harmonized_type
46
+ labels << name&.split('::')&.last
47
+ labels.compact.uniq
48
+ end
49
+ end
50
+
51
+ def iri
52
+ ed = (edition || 'jp18').to_s.downcase.gsub(/[^a-z0-9]/, '-')
53
+ "#{Openphar.base_iri}/data/jp/#{ed}/#{monograph_id}"
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Openphar
4
+ module Models
5
+ module JP
6
+ # Vitamin monograph.
7
+ #
8
+ class Vitamin < Monograph
9
+ class << self
10
+ def wire_key = 'vitamin'
11
+ def harmonized_type = 'Vitamin'
12
+ def jsonld_type = 'JpVitamin'
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -15,7 +15,15 @@ module Openphar
15
15
  # @see https://www.mhlw.go.jp/topics/bukyoku/iyaku/yakkyoku/
16
16
  module JP
17
17
  # Kampo formulas (Japanese traditional medicine)
18
- autoload :KampoFormula, 'openphar/models/jp/kampo_formula'
19
- end
18
+ autoload :KampoFormula, "openphar/models/jp/kampo_formula"
19
+ autoload :Monograph, "openphar/models/jp/monograph"
20
+ autoload :CrudeDrug, "openphar/models/jp/crude_drug"
21
+ autoload :ChemicalDrug, "openphar/models/jp/chemical_drug"
22
+ autoload :Formulation, "openphar/models/jp/formulation"
23
+ autoload :Biological, "openphar/models/jp/biological"
24
+ autoload :Excipient, "openphar/models/jp/excipient"
25
+ autoload :Vitamin, "openphar/models/jp/vitamin"
26
+ autoload :AminoAcid, "openphar/models/jp/amino_acid"
27
+ autoload :Mineral, "openphar/models/jp/mineral" end
20
28
  end
21
29
  end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Openphar
4
+ module Models
5
+ module THP
6
+ # Thai Herbal Pharmacopoeia monograph (base + stub).
7
+ #
8
+ # Thai-specific traditional-medicine properties are deferred; this
9
+ # class exists so THP records classify and serialize today.
10
+ #
11
+ class Monograph < Openphar::Models::Monograph
12
+ attribute :thai_name, :string
13
+ attribute :english_name, :string
14
+
15
+ json do
16
+ map 'thaiName', to: :thai_name
17
+ map 'englishName', to: :english_name
18
+ end
19
+
20
+ class << self
21
+ def wire_key = 'monograph'
22
+ def harmonized_type = 'CrudeDrug'
23
+ def jsonld_type = 'ThpMonograph'
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -5,9 +5,6 @@ module Openphar
5
5
  # Thai Herbal Pharmacopoeia (THP) specific models.
6
6
  #
7
7
  # Contains models unique to the Thai Herbal Pharmacopoeia:
8
- # - Thai traditional medicine monographs
9
- # - Bilingual (Thai/English) content
10
- # - Cannabis monographs (legal in Thailand)
11
8
  #
12
9
  # @example
13
10
  # # Access THP models
@@ -15,10 +12,6 @@ module Openphar
15
12
  #
16
13
  # @see http://www.fda.moph.go.th/
17
14
  module THP
18
- # Placeholder for THP-specific models
19
- # Will include:
20
- # - ThaiHerbalMonograph
21
- # - CannabisMonograph (THP-specific)
22
- end
15
+ autoload :Monograph, 'openphar/models/thp/monograph' end
23
16
  end
24
17
  end
@@ -0,0 +1,93 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Openphar
4
+ # Single source of truth for "which publishers are registered."
5
+ #
6
+ # Static frozen hash — adding a publisher means one edit here AND a new
7
+ # publisher module file. Specs verify the two stay in sync.
8
+ #
9
+ module PublisherRegistry
10
+ KNOWN_PUBLISHERS = {
11
+ "ChP" => {
12
+ code: "ChP",
13
+ label: "Chinese Pharmacopoeia",
14
+ module_name: "Openphar::Models::Chp",
15
+ editions: %w[ChP-2025 ChP-2020].freeze,
16
+ homepage: "https://2025.chp.org.cn".freeze,
17
+ }.freeze,
18
+ "JP" => {
19
+ code: "JP",
20
+ label: "Japanese Pharmacopoeia",
21
+ module_name: "Openphar::Models::JP",
22
+ editions: %w[JP18].freeze,
23
+ homepage: "https://www.mhlw.go.jp/topics/bukyoku/iyaku/yakkyoku/".freeze,
24
+ }.freeze,
25
+ "PhInt" => {
26
+ code: "PhInt",
27
+ label: "International Pharmacopoeia (WHO)",
28
+ module_name: "Openphar::Models::PhInt",
29
+ editions: %w[PhInt-13].freeze,
30
+ homepage: "https://www.who.int/teams/health-product-and-policy-standards/inn-and-pharmacopoeia".freeze,
31
+ }.freeze,
32
+ "AHP" => {
33
+ code: "AHP",
34
+ label: "American Herbal Pharmacopoeia",
35
+ module_name: "Openphar::Models::AHP",
36
+ editions: [].freeze,
37
+ homepage: "https://www.herbal-ahp.org/".freeze,
38
+ }.freeze,
39
+ "API" => {
40
+ code: "API",
41
+ label: "Ayurvedic Pharmacopoeia of India",
42
+ module_name: "Openphar::Models::API",
43
+ editions: [].freeze,
44
+ homepage: "https://main.ayush.gov.in/".freeze,
45
+ }.freeze,
46
+ "HKCMMS" => {
47
+ code: "HKCMMS",
48
+ label: "Hong Kong Chinese Materia Medica Standards",
49
+ module_name: "Openphar::Models::HKCMMS",
50
+ editions: [].freeze,
51
+ homepage: "https://www.cmchk.org.hk/".freeze,
52
+ }.freeze,
53
+ "THP" => {
54
+ code: "THP",
55
+ label: "Thai Herbal Pharmacopoeia",
56
+ module_name: "Openphar::Models::THP",
57
+ editions: [].freeze,
58
+ homepage: "http://www.fda.moph.go.th/".freeze,
59
+ }.freeze,
60
+ }.freeze
61
+
62
+ class << self
63
+ def all
64
+ KNOWN_PUBLISHERS
65
+ end
66
+
67
+ def [](code)
68
+ KNOWN_PUBLISHERS[code.to_s]
69
+ end
70
+
71
+ def registered?(code)
72
+ KNOWN_PUBLISHERS.key?(code.to_s)
73
+ end
74
+
75
+ def codes
76
+ KNOWN_PUBLISHERS.keys.sort
77
+ end
78
+
79
+ def module_for(code)
80
+ entry = self[code]
81
+ return nil unless entry
82
+
83
+ entry[:module_name].safe_constantize
84
+ end
85
+ end
86
+ end
87
+
88
+ module_function
89
+
90
+ def publishers
91
+ PublisherRegistry.all
92
+ end
93
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Openphar
4
- VERSION = "0.1.1"
4
+ VERSION = "0.2.0"
5
5
  end
data/lib/openphar.rb CHANGED
@@ -112,4 +112,6 @@ module Openphar
112
112
  autoload :Errors, 'openphar/errors'
113
113
  autoload :MonographMerger, 'openphar/monograph_merger'
114
114
  autoload :Registry, 'openphar/registry'
115
+ autoload :PublisherRegistry, 'openphar/publisher_registry'
116
+ autoload :HarmonizedTypeRegistry, 'openphar/harmonized_type_registry'
115
117
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openphar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - SIPM
@@ -208,6 +208,7 @@ files:
208
208
  - lib/openphar/exporters/neo4j/property_mapper.rb
209
209
  - lib/openphar/exporters/neo4j/relationship_builder.rb
210
210
  - lib/openphar/exporters/neo4j_exporter.rb
211
+ - lib/openphar/harmonized_type_registry.rb
211
212
  - lib/openphar/linkers.rb
212
213
  - lib/openphar/linkers/chp.rb
213
214
  - lib/openphar/linkers/chp/cross_edition_linker.rb
@@ -217,12 +218,18 @@ files:
217
218
  - lib/openphar/migrators/chp.rb
218
219
  - lib/openphar/migrators/chp/classifier.rb
219
220
  - lib/openphar/migrators/chp_migrator.rb
221
+ - lib/openphar/migrators/jp.rb
222
+ - lib/openphar/migrators/jp/classifier.rb
220
223
  - lib/openphar/migrators/jp_migrator.rb
224
+ - lib/openphar/migrators/ph_int.rb
225
+ - lib/openphar/migrators/ph_int/classifier.rb
221
226
  - lib/openphar/migrators/phint_migrator.rb
222
227
  - lib/openphar/models.rb
223
228
  - lib/openphar/models/ahp.rb
229
+ - lib/openphar/models/ahp/monograph.rb
224
230
  - lib/openphar/models/amino_acid_monograph.rb
225
231
  - lib/openphar/models/api.rb
232
+ - lib/openphar/models/api/monograph.rb
226
233
  - lib/openphar/models/assay_specification.rb
227
234
  - lib/openphar/models/base_entity.rb
228
235
  - lib/openphar/models/biological_substance_monograph.rb
@@ -241,9 +248,19 @@ files:
241
248
  - lib/openphar/models/edition.rb
242
249
  - lib/openphar/models/formulation_monograph.rb
243
250
  - lib/openphar/models/hkcmms.rb
251
+ - lib/openphar/models/hkcmms/monograph.rb
244
252
  - lib/openphar/models/identification_specification.rb
245
253
  - lib/openphar/models/jp.rb
254
+ - lib/openphar/models/jp/amino_acid.rb
255
+ - lib/openphar/models/jp/biological.rb
256
+ - lib/openphar/models/jp/chemical_drug.rb
257
+ - lib/openphar/models/jp/crude_drug.rb
258
+ - lib/openphar/models/jp/excipient.rb
259
+ - lib/openphar/models/jp/formulation.rb
246
260
  - lib/openphar/models/jp/kampo_formula.rb
261
+ - lib/openphar/models/jp/mineral.rb
262
+ - lib/openphar/models/jp/monograph.rb
263
+ - lib/openphar/models/jp/vitamin.rb
247
264
  - lib/openphar/models/limit.rb
248
265
  - lib/openphar/models/mineral_substance_monograph.rb
249
266
  - lib/openphar/models/monograph.rb
@@ -262,6 +279,7 @@ files:
262
279
  - lib/openphar/models/supplement.rb
263
280
  - lib/openphar/models/test_specification.rb
264
281
  - lib/openphar/models/thp.rb
282
+ - lib/openphar/models/thp/monograph.rb
265
283
  - lib/openphar/models/vitamin_monograph.rb
266
284
  - lib/openphar/monograph_merger.rb
267
285
  - lib/openphar/parsers.rb
@@ -270,6 +288,7 @@ files:
270
288
  - lib/openphar/parsers/jp_html_parser_base.rb
271
289
  - lib/openphar/parsers/jp_ja_html_parser.rb
272
290
  - lib/openphar/parsers/phint_json_parser.rb
291
+ - lib/openphar/publisher_registry.rb
273
292
  - lib/openphar/registry.rb
274
293
  - lib/openphar/registry/publisher_registry.rb
275
294
  - lib/openphar/registry/type_registry.rb