Class: Openphar::Models::Chp::Monograph
- Inherits:
-
Monograph
- Object
- Lutaml::Model::Serializable
- BaseEntity
- Monograph
- Openphar::Models::Chp::Monograph
- Defined in:
- lib/openphar/models/chp/monograph.rb
Overview
Base class for all Chinese Pharmacopoeia monographs.
Adds ChP-specific identity fields (entryId from the network-edition API, bookId 1..4 for volumes I–IV, directoryTitle for the TOC node, pageNum for the printed-edition cross-reference, pinyin title) on top of the harmonized Openphar::Models::Monograph.
Concrete subclasses (TcmCrudeDrug, ChemicalSubstance, Biologic,
GeneralChapter, etc.) declare their semantic @type via class methods.
The classifier at Openphar::Migrators::Chp::Classifier is the
single dispatch point — never use case/when on type elsewhere.
Direct Known Subclasses
ChemicalPreparation, ChemicalSubstance, GeneralChapter, TcmCrudeDrug, TcmExtract, TcmFormulation
Class Method Summary collapse
-
.harmonized_type ⇒ String?
Harmonized RDF type this ChP type maps to.
- .jsonld_type ⇒ Object
-
.jsonld_types ⇒ Array<String>
Array of types to emit in JSON-LD @type.
- .neo4j_labels ⇒ Object
-
.wire_key ⇒ String
Snake_case identifier used as the JSON-LD node-directory name and as the wire-key for type routing.
Instance Method Summary collapse
Methods inherited from Monograph
Methods inherited from BaseEntity
jsonld_context, neo4j_label, neo4j_labels_string, #to_cypher, #to_cypher_match, #to_jsonld, #to_neo4j_node, #to_neo4j_properties
Class Method Details
.harmonized_type ⇒ String?
Harmonized RDF type this ChP type maps to. Override in subclasses to declare the cross-publisher semantic type (e.g., 'CrudeDrug').
66 67 68 |
# File 'lib/openphar/models/chp/monograph.rb', line 66 def harmonized_type nil end |
.jsonld_type ⇒ Object
88 89 90 |
# File 'lib/openphar/models/chp/monograph.rb', line 88 def jsonld_type 'ChpMonograph' end |
.jsonld_types ⇒ Array<String>
Array of types to emit in JSON-LD @type. Computed from jsonld_type + harmonized_type + the base 'Monograph'.
74 75 76 77 78 79 |
# File 'lib/openphar/models/chp/monograph.rb', line 74 def jsonld_types types = ['Monograph'] types << harmonized_type if harmonized_type types << jsonld_type unless jsonld_type == 'Monograph' types.uniq end |
.neo4j_labels ⇒ Object
81 82 83 84 85 86 |
# File 'lib/openphar/models/chp/monograph.rb', line 81 def neo4j_labels labels = %w[Monograph Chp] labels << harmonized_type if harmonized_type labels << name&.split('::')&.last labels.compact.uniq end |
.wire_key ⇒ String
Snake_case identifier used as the JSON-LD node-directory name and as the wire-key for type routing. Override in subclasses.
58 59 60 |
# File 'lib/openphar/models/chp/monograph.rb', line 58 def wire_key 'monograph' end |
Instance Method Details
#iri ⇒ Object
105 106 107 108 |
# File 'lib/openphar/models/chp/monograph.rb', line 105 def iri edition_tag = (edition || 'unknown').to_s.downcase.gsub(/[^a-z0-9]/, '-') "#{Openphar.base_iri}/data/chp/#{edition_tag}/entry/#{entry_id}" end |
#jsonld_filename ⇒ Object
110 111 112 |
# File 'lib/openphar/models/chp/monograph.rb', line 110 def jsonld_filename "#{slug}.jsonld" end |
#slug ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/openphar/models/chp/monograph.rb', line 93 def slug base = ( || title || "entry-#{entry_id}") .to_s .downcase .gsub(/\s+/, '-') .gsub(/[^\p{L}\p{N}\-]/, '') .gsub(/\-+/, '-') .gsub(/^\-|\-$/, '') base = "entry-#{entry_id}" if base.empty? "#{base}-#{entry_id}" end |