Class: Stupidedi::Config::TransactionSetConfig

Inherits:
Object
  • Object
show all
Includes:
Inspect
Defined in:
lib/stupidedi/config/transaction_set_config.rb

Overview

The implementation version specified in GS08 and ST03 indicates which implementation guide governs the transaction. Because each guide may define multiple transaction sets (eg X212 and X279), the functional code and transaction set code are needed to lookup a definition.

In english, we can’t just look at ST01 and link “837” to our definition of 837P from the HIPAA guide.

Instance Method Summary collapse

Methods included from Inspect

#inspect

Constructor Details

#initializeTransactionSetConfig

Returns a new instance of TransactionSetConfig.



16
17
18
# File 'lib/stupidedi/config/transaction_set_config.rb', line 16

def initialize
  @table = Hash.new
end

Instance Method Details

#at(version, function, transaction) ⇒ TransactionSetDef

Returns:

  • (TransactionSetDef)


65
66
67
68
# File 'lib/stupidedi/config/transaction_set_config.rb', line 65

def at(version, function, transaction)
  x = @table[Array[version, nil, transaction]]
  x.is_a?(Proc) ? x.call : x
end

#defined_at?(version, function, transaction) ⇒ Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/stupidedi/config/transaction_set_config.rb', line 70

def defined_at?(version, function, transaction)
  @table.defined_at?([version, nil, transaction])
end

#pretty_print(q) ⇒ void

This method returns an undefined value.



75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/stupidedi/config/transaction_set_config.rb', line 75

def pretty_print(q)
  q.text "TransactionSetConfig"
  q.group(2, "(", ")") do
    q.breakable ""
    @table.keys.each do |e|
      unless q.current_group.first?
        q.text ","
        q.breakable
      end
      q.pp e
    end
  end
end

#register(version, function, transaction, definition = nil, &constructor) ⇒ void

This method returns an undefined value.

Examples:

table = TransactionSetConfig.new

table.register("005010X212", "HR", "276") { Hipaa::X212::HR276 }
table.register("005010X212", "HN", "277") { Hipaa::X212::HN277 }

table.register("005010X217", "HI", "278") { Hipaa::X217::HI278 }
table.register("005010X218", "RA", "820") { Hipaa::X218::RA820 }
table.register("005010X220", "BE", "834") { Hipaa::X220::BE834 }
table.register("005010X221", "HP", "835") { Hipaa::X221::HP835 }

table.register("005010X222", "HC", "837") { Hipaa::X222::HC837 }
table.register("005010X223", "HC", "837") { Hipaa::X223::HC837 }
table.register("005010X224", "HC", "837") { Hipaa::X224::HC837 }

table.register("005010X230", "FA", "997") { Hipaa::X230::FA997 }
table.register("005010X231", "FA", "999") { Hipaa::X231::FA999 }

table.register("005010X279", "HS", "270") { Hipaa::X279::HS270 }
table.register("005010X279", "HB", "271") { Hipaa::X279::HB271 }

table.register("005010", "HR", "276") { Standards::HR276 }
table.register("005010", "HS", "270") { Standards::HS270 }
table.register("005010", "HB", "271") { Standards::HB271 }
table.register("005010", "HN", "277") { Standards::HN277 }
table.register("005010", "HI", "278") { Standards::HI278 }
table.register("005010", "RA", "820") { Standards::RA820 }
table.register("005010", "BE", "834") { Standards::BE834 }
table.register("005010", "HP", "835") { Standards::HP835 }
table.register("005010", "HC", "837") { Standards::HC837 }
table.register("005010", "FA", "997") { Standards::FA997 }
table.register("005010", "FA", "999") { Standards::FA999 }


56
57
58
59
60
61
62
# File 'lib/stupidedi/config/transaction_set_config.rb', line 56

def register(version, function, transaction, definition = nil, &constructor)
  if block_given?
    @table[Array[version, nil, transaction]] = constructor
  else
    @table[Array[version, nil, transaction]] = definition
  end
end