Class: Openphar::Models::Monograph

Inherits:
BaseEntity
  • Object
show all
Defined in:
lib/openphar/models/monograph.rb

Overview

Represents a pharmacopoeia monograph

This is the base class for all monograph types. Each monograph knows how to serialize itself to Neo4j and JSON-LD formats.

Class Method Summary collapse

Instance Method Summary collapse

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_typeString?

Override in subclasses to declare the cross-publisher semantic type (e.g., "CrudeDrug", "ChemicalDrug"). Returns nil when the subclass is publisher-specific with no harmonized equivalent.

Returns:

  • (String, nil)


53
54
55
# File 'lib/openphar/models/monograph.rb', line 53

def harmonized_type
  nil
end

.jsonld_typeObject



44
45
46
# File 'lib/openphar/models/monograph.rb', line 44

def jsonld_type
  'Monograph'
end

.jsonld_typesArray<String>

Array of types to emit in JSON-LD @type. Computed from harmonized_type + jsonld_type + the base 'Monograph'.

Returns:

  • (Array<String>)


69
70
71
72
73
74
# File 'lib/openphar/models/monograph.rb', line 69

def jsonld_types
  types = ['Monograph']
  types << harmonized_type if harmonized_type
  types << jsonld_type unless jsonld_type == 'Monograph'
  types.uniq
end

.neo4j_labelsObject



40
41
42
# File 'lib/openphar/models/monograph.rb', line 40

def neo4j_labels
  ['Monograph']
end

.wire_keyString

Override in subclasses to declare the publisher-specific snake_case routing key (e.g., "tcm_crude_drug", "dravya").

Returns:

  • (String)


61
62
63
# File 'lib/openphar/models/monograph.rb', line 61

def wire_key
  'monograph'
end

Instance Method Details

#iriObject



77
78
79
# File 'lib/openphar/models/monograph.rb', line 77

def iri
  "#{Openphar.base_iri}/data/monograph/#{id}"
end

#label(lang = 'en') ⇒ Object



81
82
83
# File 'lib/openphar/models/monograph.rb', line 81

def label(lang = 'en')
  pref_label[lang] || pref_label.values.first
end