Class: XDS::SourcePatientInfo

Inherits:
Object
  • Object
show all
Includes:
Helper
Defined in:
lib/xds/source_patient_info.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helper

#create_classification, #create_external_identifier, #create_extrinsic_object, #create_localized_string, #create_name, #create_slot, #get_external_identifier_value, #get_slot_value, #get_slot_values, #with_classification

Constructor Details

#initialize(args = {}) ⇒ SourcePatientInfo

Returns a new instance of SourcePatientInfo.



7
8
9
10
11
12
13
# File 'lib/xds/source_patient_info.rb', line 7

def initialize(args={})
    @source_patient_identifier = args[:source_patient_identifier] || ""
    @name = args[:name] || ""
    @gender = args[:gender] || ""
    @date_of_birth = args[:date_of_birth] || ""
    @address = args[:address]
end

Instance Attribute Details

#addressObject

These fields will need to be entered in HL7v2 format by the user



5
6
7
# File 'lib/xds/source_patient_info.rb', line 5

def address
  @address
end

#date_of_birthObject

These fields will need to be entered in HL7v2 format by the user



5
6
7
# File 'lib/xds/source_patient_info.rb', line 5

def date_of_birth
  @date_of_birth
end

#genderObject

These fields will need to be entered in HL7v2 format by the user



5
6
7
# File 'lib/xds/source_patient_info.rb', line 5

def gender
  @gender
end

#nameObject

These fields will need to be entered in HL7v2 format by the user



5
6
7
# File 'lib/xds/source_patient_info.rb', line 5

def name
  @name
end

#source_patient_identifierObject

These fields will need to be entered in HL7v2 format by the user



5
6
7
# File 'lib/xds/source_patient_info.rb', line 5

def source_patient_identifier
  @source_patient_identifier
end

Instance Method Details

#from_extrinsic_object(eo_node) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/xds/source_patient_info.rb', line 19

def from_extrinsic_object(eo_node)
  patient_values = get_slot_values(eo_node, 'sourcePatientInfo')
  @source_patient_identifier = match_and_strip(patient_values, 'PID-3')
  @name = match_and_strip(patient_values, 'PID-5')
  @gender = match_and_strip(patient_values, 'PID-8')
  @date_of_birth = match_and_strip(patient_values, 'PID-7')
  @address = match_and_strip(patient_values, 'PID-11')
end

#match_and_strip(slot_values, pid_segment) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/xds/source_patient_info.rb', line 37

def match_and_strip(slot_values, pid_segment)
  slot_value = slot_values.find {|field_value| field_value.match("^#{pid_segment}\\|.*")}
  if slot_value
    md = slot_value.match("^#{pid_segment}\\|(.+)")
    if md
      return md[1]
    else
      return nil
    end
  else
    return nil
  end
end

#to_soap(builder) ⇒ Object



15
16
17
# File 'lib/xds/source_patient_info.rb', line 15

def to_soap(builder)         
    create_slot(builder,"sourcePatientInfo",value_list)
end

#value_listObject



28
29
30
31
32
33
34
35
# File 'lib/xds/source_patient_info.rb', line 28

def value_list
  ["PID-3|#{@source_patient_identifier}", 
      "PID-5|#{@name}",
      "PID-8|#{@gender}",
      "PID-7|#{@date_of_birth}",
      "PID-11|#{@address}"]
      
end