Class: HQMF1::Observation

Inherits:
Object
  • Object
show all
Includes:
Utilities
Defined in:
lib/hqmf-parser/1.0/observation.rb

Overview

Represents an HQMF population criteria

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utilities

#attr_val, #check_nil_conjunction_on_child, #clean_json, #clean_json_recursive

Methods included from HQMF::Conversion::Utilities

#build_hash, #check_equality, #json_array, #openstruct_to_json

Constructor Details

#initialize(entry, doc) ⇒ Observation

Create a new population criteria from the supplied HQMF entry

Parameters:

  • the (Nokogiri::XML::Element)

    HQMF entry



12
13
14
15
16
17
# File 'lib/hqmf-parser/1.0/observation.rb', line 12

def initialize(entry, doc)
  @doc = doc
  @entry = entry
  @id = attr_val('cda:observation/cda:id/@root').upcase
  @preconditions = [Precondition.new(@entry, nil, @doc)]
end

Instance Attribute Details

#docObject (readonly)

Returns the value of attribute doc.



7
8
9
# File 'lib/hqmf-parser/1.0/observation.rb', line 7

def doc
  @doc
end

#entryObject (readonly)

Returns the value of attribute entry.



7
8
9
# File 'lib/hqmf-parser/1.0/observation.rb', line 7

def entry
  @entry
end

#hqmf_idObject

Returns the value of attribute hqmf_id.



8
9
10
# File 'lib/hqmf-parser/1.0/observation.rb', line 8

def hqmf_id
  @hqmf_id
end

#idString

Get the id for the population criteria, used elsewhere in the HQMF document to refer to this criteria

Returns:

  • (String)

    the id



28
29
30
# File 'lib/hqmf-parser/1.0/observation.rb', line 28

def id
  @id
end

#preconditionsObject (readonly)

Returns the value of attribute preconditions.



7
8
9
# File 'lib/hqmf-parser/1.0/observation.rb', line 7

def preconditions
  @preconditions
end

#stratification_idObject

Returns the value of attribute stratification_id.



8
9
10
# File 'lib/hqmf-parser/1.0/observation.rb', line 8

def stratification_id
  @stratification_id
end

Instance Method Details

#codeString

Get the code for the population criteria

Returns:

  • (String)

    the code (e.g. IPP, DEMON, NUMER, DENEX, DENEXCEP)



21
22
23
# File 'lib/hqmf-parser/1.0/observation.rb', line 21

def code
  HQMF::PopulationCriteria::OBSERV
end

#referenceObject



36
37
38
# File 'lib/hqmf-parser/1.0/observation.rb', line 36

def reference
  nil
end

#titleObject



32
33
34
# File 'lib/hqmf-parser/1.0/observation.rb', line 32

def title
  "Measure Observation"
end

#to_jsonObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/hqmf-parser/1.0/observation.rb', line 40

def to_json
  
  json = {}
  self.preconditions.compact.each do |precondition| 
    json[:preconditions] ||= []
    json[:preconditions] << precondition.to_json
  end
  json[:preconditions].each {|p| p[:conjunction] ||= "AND"}
  
  json[:id] = id
  json[:title] = title
  json[:code] = code
  json[:hqmf_id] = hqmf_id if hqmf_id
  json[:stratification_id] = stratification_id if stratification_id
  json[:reference] = reference
  
  {self.code => json}
  
end