Module: ConceptQL::Provenanceable

Included in:
Operators::OneInTwoOut, Operators::Provenance
Defined in:
lib/conceptql/behaviors/provenanceable.rb

Instance Method Summary collapse

Instance Method Details

#concept_idsObject



18
19
20
# File 'lib/conceptql/behaviors/provenanceable.rb', line 18

def concept_ids
  @concept_ids ||= Psych.load_file(config_dir + 'provenance.yml')
end

#config_dirObject



22
23
24
# File 'lib/conceptql/behaviors/provenanceable.rb', line 22

def config_dir
  Pathname.new(__FILE__).dirname + '..' + '..' + '..' + 'config'
end

#needs_adjustment?(ctype) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/conceptql/behaviors/provenanceable.rb', line 26

def needs_adjustment?(ctype)
  ctype =~ /^outpatient/ || ctype =~ /^carrier/
end

#to_concept_id(ctype) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/conceptql/behaviors/provenanceable.rb', line 3

def to_concept_id(ctype)
  ctype = ctype.to_s.downcase
  return ctype.to_i unless ctype.to_i.zero?
  position = nil
  if ctype =~ /(\d|_primary)$/ && ctype.count('_') > 1
    parts = ctype.split('_')
    position = parts.pop.to_i
    position -= 1 if needs_adjustment?(ctype)
    ctype = parts.join('_')
  end
  retval = concept_ids[ctype.to_sym]
  return retval[position] if position
  return retval
end