Class: HL7::Message::Segment::PD1

Inherits:
HL7::Message::Segment
  • Object
show all
Defined in:
lib/core_ext/segments/pd1.rb

Instance Method Summary collapse

Instance Method Details

#to_hashObject



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
# File 'lib/core_ext/segments/pd1.rb', line 33

def to_hash
  return @hash if @hash
  
  hash = super.to_hash
  
  if self.hash["primaryCareProvider"].blank? 
    hash["primaryCareProvider"] = {}
  else
    primaryCareProvider = self.hash["primaryCareProvider"].split("^") rescue Array.new(30) {|i|""}
    hash["primaryCareProvider"] = {"id" => primaryCareProvider[0],
                                   "lastName" => primaryCareProvider[1],
                                   "firstName" => primaryCareProvider[2],
                                   "middleInitOrName" => primaryCareProvider[3],
                                   "suffix" => primaryCareProvider[4],
                                   "prefix" => primaryCareProvider[5],
                                   "degree" => primaryCareProvider[6],
                                   "sourceTable" => primaryCareProvider[7],
                                   "assigningAuthority" => primaryCareProvider[8],
                                   "nameTypeCode" => primaryCareProvider[9],
                                   "identifierCheckDigit" => primaryCareProvider[10],
                                   "codeIdCheck" => primaryCareProvider[11],
                                   "identifierTypeCode" => primaryCareProvider[12],
                                   "assigningFacility" => primaryCareProvider[13]}
  end
 
  @hash = hash
end