Class: ODDB::FiParse::PatinfoHpricot

Inherits:
TextinfoHpricot show all
Defined in:
ext/fiparse/src/patinfo_hpricot.rb

Instance Attribute Summary collapse

Attributes inherited from TextinfoHpricot

#company, #name

Instance Method Summary collapse

Methods inherited from TextinfoHpricot

#chapter, #extract

Instance Attribute Details

#amendmentsObject (readonly)

Returns the value of attribute amendments.



10
11
12
# File 'ext/fiparse/src/patinfo_hpricot.rb', line 10

def amendments
  @amendments
end

#amzvObject (readonly)

Returns the value of attribute amzv.



10
11
12
# File 'ext/fiparse/src/patinfo_hpricot.rb', line 10

def amzv
  @amzv
end

#compositionObject (readonly)

Returns the value of attribute composition.



10
11
12
# File 'ext/fiparse/src/patinfo_hpricot.rb', line 10

def composition
  @composition
end

#contra_indicationsObject (readonly)

Returns the value of attribute contra_indications.



10
11
12
# File 'ext/fiparse/src/patinfo_hpricot.rb', line 10

def contra_indications
  @contra_indications
end

#dateObject (readonly)

Returns the value of attribute date.



10
11
12
# File 'ext/fiparse/src/patinfo_hpricot.rb', line 10

def date
  @date
end

#distributionObject (readonly)

Returns the value of attribute distribution.



10
11
12
# File 'ext/fiparse/src/patinfo_hpricot.rb', line 10

def distribution
  @distribution
end

#effectsObject (readonly)

Returns the value of attribute effects.



10
11
12
# File 'ext/fiparse/src/patinfo_hpricot.rb', line 10

def effects
  @effects
end

#fabricationObject (readonly)

Returns the value of attribute fabrication.



10
11
12
# File 'ext/fiparse/src/patinfo_hpricot.rb', line 10

def fabrication
  @fabrication
end

#galenic_formObject (readonly)

Returns the value of attribute galenic_form.



10
11
12
# File 'ext/fiparse/src/patinfo_hpricot.rb', line 10

def galenic_form
  @galenic_form
end

#general_adviceObject (readonly)

Returns the value of attribute general_advice.



10
11
12
# File 'ext/fiparse/src/patinfo_hpricot.rb', line 10

def general_advice
  @general_advice
end

#iksnrsObject (readonly)

Returns the value of attribute iksnrs.



10
11
12
# File 'ext/fiparse/src/patinfo_hpricot.rb', line 10

def iksnrs
  @iksnrs
end

#packagesObject (readonly)

Returns the value of attribute packages.



10
11
12
# File 'ext/fiparse/src/patinfo_hpricot.rb', line 10

def packages
  @packages
end

#precautionsObject (readonly)

Returns the value of attribute precautions.



10
11
12
# File 'ext/fiparse/src/patinfo_hpricot.rb', line 10

def precautions
  @precautions
end

#pregnancyObject (readonly)

Returns the value of attribute pregnancy.



10
11
12
# File 'ext/fiparse/src/patinfo_hpricot.rb', line 10

def pregnancy
  @pregnancy
end

#unwanted_effectsObject (readonly)

Returns the value of attribute unwanted_effects.



10
11
12
# File 'ext/fiparse/src/patinfo_hpricot.rb', line 10

def unwanted_effects
  @unwanted_effects
end

#usageObject (readonly)

Returns the value of attribute usage.



10
11
12
# File 'ext/fiparse/src/patinfo_hpricot.rb', line 10

def usage
  @usage
end

Instance Method Details

#identify_chapter(code, chapter) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'ext/fiparse/src/patinfo_hpricot.rb', line 14

def identify_chapter(code, chapter)
  case code
  when '7600'
    @amzv = chapter
  when '2000', '7620'
    @effects = chapter
  when '2500', '7640'
    @amendments = chapter
  when '3000', '7625', '7660', '7680'
    @contra_indications = chapter
  when '3500', '7700'
    @precautions = chapter
  when '4000', '7720'
    @pregnancy = chapter
  when '4500', '7740'
    @usage = chapter
  when '5000', '7760'
    @unwanted_effects = chapter
  when '5500', '7780'
    @general_advice = chapter
  when '6000', '7840'
    @composition = chapter
  when '7860'
    @iksnrs = chapter
  when '6500', '7880'
    @packages = chapter
  when '7000', '7900'
    @distribution = chapter
  when '7920'
    @fabrication = chapter
  when '7930'
    @delivery = chapter
  when '7520', '7940', '7950'
    if(@date) # we are overwriting an existing @date
      chapter.sections = @date.sections
    end
    @date = chapter
  when nil # special chapers without heading
    case chapter.to_s
    when /^\d{5}/u
      @iksnrs = chapter
    when /\b\d{4}\b/u
      @date = chapter
    end
  else
    raise "Unknown chapter-code #{code}, while parsing #{@name}"
  end
end

#to_textinfoObject



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'ext/fiparse/src/patinfo_hpricot.rb', line 62

def to_textinfo
  pat = if(@amzv)
    pat = PatinfoDocument2001.new
    pat.amzv = @amzv
    pat.iksnrs = @iksnrs
    pat
  else
    pat = PatinfoDocument.new
    pat
  end
  pat.name = @name
  pat.company = @company
  pat.galenic_form = @galenic_form
  pat.effects = @effects
  pat.amendments = @amendments
  pat.contra_indications = @contra_indications
  pat.precautions = @precautions
  pat.pregnancy = @pregnancy
  pat.usage	= @usage
  pat.unwanted_effects = @unwanted_effects
  pat.general_advice	= @general_advice
  #pat.other_advice = @other_advice ## not identified yet.
  pat.composition	= @composition
  pat.packages = @packages
  pat.distribution = @distribution
  pat.fabrication = @fabrication
  pat.date = @date
  pat
end