Module: Extensions::HL7::Segments::PID::InstanceMethods

Defined in:
lib/core_ext/segments/pid.rb

Instance Method Summary collapse

Instance Method Details

#genderObject



16
17
18
# File 'lib/core_ext/segments/pid.rb', line 16

def gender
  to_hash["sex"]
end

#mrnObject



12
13
14
# File 'lib/core_ext/segments/pid.rb', line 12

def mrn 
  to_hash["internalId"]["id"]
end

#to_hashObject



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

def to_hash
  return @hash if @hash
  
  patient_name = self.patient_name.split("^") rescue Array.new(10) {|i| "" }
  address = self.address.split("^") rescue Array.new(10) {|i| "" }
  patientAccountNumber = self..split("^") rescue Array.new(10) {|i| "" }
  internalId = self.patient_id_list.split("^") rescue Array.new(10) {|i| "" }

  @hash = {"setId" => self.set_id,
           "externalId" => self.patient_id, 
           "internalId" => {"id" => internalId[0], "check_digit" => internalId[1], "check_digit_scheme" => internalId[2], 
                            "assigning_authority" => internalId[3], "type" => internalId[4], "assigning_facility" => internalId[5]}, 
           "alternateId" => self.alt_patient_id, 
           "patientName" => {"lastName" => patient_name[0], "firstName" => patient_name[1], "middleInitOrName"=> patient_name[2]}, 
           "mothersMaidenName" => self.mother_maiden_name, 
           "dateTimeBirth" => self.patient_dob, 
           "sex" => self.admin_sex, 
           "alias" => self.patient_alias, 
           "race" => self.race, 
           "address"=>{"streetAddress"=>address[0], "otherDesignation"=>address[1], "city"=>address[2], "state"=>address[3], "postalCode"=>address[4], "country"=>address[5], "addressType"=>address[6]}, 
           "countyCode"=> self.country_code, 
           "phoneNumbers"=>{"home"=>self.phone_home, "business"=>self.phone_business}, 
           "homePhone"=>{"number" => "","useCode" => "", "equipmentType" => "", "email" => "", "countryCode" => "", "areaCode" => "", "phoneNumber" => ""},
           "primaryLanguage"=>self.primary_language, 
           "maritalStatus"=>self.marital_status, 
           "religion"=>self.religion, 
           "patientAccountNumber"=>{"id"=>patientAccountNumber[0], "checkDigit"=>patientAccountNumber[1], "codeIdCheck"=>patientAccountNumber[2], "assigningAuth"=>patientAccountNumber[3], "idTypeCode"=>patientAccountNumber[4], "assigningFacility"=>patientAccountNumber[5]},
           "ssn"=>self.social_security_num, 
           "driversLicenseNumber"=>self.driver_license_num, 
           "mothersId"=>self.mothers_id, 
           "ethnicGroup"=>self.ethnic_group, 
           "birthPlace"=>self.birthplace, 
           "multipleBirthIndicator"=>self.multi_birth, 
           "birthOrder"=>self.birth_order, 
           "citizenship"=>self.citizenship, 
           "veteranStatus"=>self.vet_status, 
           "nationality"=>self.nationality, 
           "deathDateTime"=>self.death_date, 
           "deathIndicator"=>self.death_indicator}
end