Module: Extensions::HL7::Segments::OBR::InstanceMethods

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

Instance Method Summary collapse

Instance Method Details

#obx_listObject



25
26
27
28
29
30
31
# File 'lib/core_ext/segments/obr.rb', line 25

def obx_list
  obx_l = []
  self.children.each do |c|
    obx_l << c if c.segment_name == "OBX"
  end
  obx_l
end

#ordering_provider_hashObject



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

def ordering_provider_hash
  to_hash["orderingProvider"]
end

#ordering_provider_nameObject



16
17
18
19
20
21
22
23
# File 'lib/core_ext/segments/obr.rb', line 16

def ordering_provider_name
  last_name = to_hash["orderingProvider"]["lastName"]
  if last_name
    "#{@hash["orderingProvider"]["lastName"]}, #{@hash["orderingProvider"]["firstName"]}#{@hash["orderingProvider"]["middleInitOrName"].blank? ? "" : " #{@hash["orderingProvider"]["middleInitOrName"]}"}"
  else
    nil
  end
end

#to_hashObject

def obx_list

# a = @hash["OBX"]["array"].collect {|obr| ::HL7::Message::Segment.from_hash("OBX", obr)}
# a.to_enum(:each)
@hash["OBX"]["segment_array"].to_enum(:each)

end



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/core_ext/segments/obr.rb', line 39

def to_hash
  return @hash if @hash
  
  @hash = super.to_hash
  
  universalServiceId = self.universal_service_id.split("^") rescue Array.new(10) {|i|""}
  collectionVolume = self.collection_volume.split("^") rescue Array.new(10) {|i|""}
  orderingProvider = self.ordering_provider.split("^") rescue Array.new(20) {|i|""}
  quantityTiming = self.quantity_timing.split("^") rescue Array.new(10) {|i|""}
  resultCopiesTo = self.result_copies_to.split("^") rescue Array.new(10) {|i|""}
  parent = self.parent.split("^") rescue Array.new(10) {|i|""}
    
  @hash.merge!({"setId" => self.set_id,
               "placerOrderNumber" => self.placer_order_number,
               "fillerOrderNumber" => self.filler_order_number,
               "universalServiceId" => {"id" => universalServiceId[0],
                                        "text" => universalServiceId[1],
                                        "coddingSystem" => universalServiceId[2],
                                        "alternateId" => universalServiceId[3],
                                        "alternateText" => universalServiceId[4]},
               "priority" => self.priority,
               "requestedDateTime" => self.requested_date,
               "observationDateTime" => self.observation_date,
               "observationEndDate" => self.observation_end_date,
               "collectionVolume" => {"quantity" => collectionVolume[0], "units" => collectionVolume[1]},
               "collectorIdentifier" => self.collector_identifier,
               "specimenActionCode" => self.specimen_action_code,
               "dangerCode" => self.danger_code,
               "relevantClinicalInfo" => self.relevant_clinical_info,
               "specimenReceivedDateTime" => self.specimen_received_date,
               "specimenSource" => self.specimen_source,
               "orderingProvider" => 
                    {
                      "id" => orderingProvider[0],
                      "lastName" => orderingProvider[1],
                      "firstName" => orderingProvider[2],
                      "middleInitOrName" => orderingProvider[3],
                      "suffix" => orderingProvider[4],
                      "prefix" => orderingProvider[5],
                      "degree" => orderingProvider[6],
                      "sourceTable" => orderingProvider[7],
                      "assigningAuthority" => orderingProvider[8],
                      "nameTypeCode" => orderingProvider[9],
                      "identifierCheckDigit" => orderingProvider[10],
                      "checkDigitScheme" => orderingProvider[11],
                      "idTypeCode" => orderingProvider[12],
                      "isTypeCode" => orderingProvider[13],
                      "assigningFacility" => orderingProvider[14],
                      "providerType" => "OP",
                      "identifierTypeCode" => orderingProvider[12]
                    },
                "orderCallBackNumber" => self.order_callback_phone_number,
                "placerField1" => self.placer_field_1,
                "placerField2" => self.placer_field_2,
                "fillerField1" => self.filler_field_1,
                "fillerField2" => self.filler_field_2,
                "rptStatusChangeDate" => self.results_status_change_date,
                "chargeToPractice" => self.charge_to_practice,
                "diagnosticServiceSectId" => self.diagnostic_serv_sect_id,
                "resultStatus" => self.result_status,
                "linkedResults" => self.parent_result,
                "quantityTiming" => {
                    "quantity" => quantityTiming[0],
                    "interval" => quantityTiming[1],
                    "duration" => quantityTiming[2],
                    "startDateTime" => quantityTiming[3],
                    "endDateTime" => quantityTiming[4],
                    "priority" => quantityTiming[5]
                  },
                  "resultCopiesTo" => [
                    {
                      "id" => resultCopiesTo[0],
                      "lastName" => resultCopiesTo[1],
                      "firstName" => resultCopiesTo[2],
                      "middleInitOrName" => resultCopiesTo[3]
                    }
                  ],
                  "parent" => {
                    "placerOrderNumber" => parent[0],
                    "fillerOrderNumber" => parent[1]
                  },
                  "transportationMode" => self.transport_mode,
                  "reasonForStudy" => self.reason_for_study,
                  "principalResultInterpreter" => self.principal_result_interpreter,
                  "assistantResultInterpreter" => self.assistant_result_interpreter,
                  "technician" => self.technician,
                  "transcriptionist" => self.transcriptionist,
                  "scheduledDate" => self.scheduled_date,
                  "number_of_sample_containers" => self.number_of_sample_containers,
                  "transport_logistics_of_sample" => self.transport_logistics_of_sample,
                  "collectors_comment" => self.collectors_comment,
                  "transport_arrangement_responsibility" => self.transport_arrangement_responsibility,
                  "transport_arranged" => self.transport_arranged,
                  "escort_required" => self.escort_required,
                  "planned_patient_transport_comment" => self.planned_patient_transport_comment,
                  "procedure_code" => self.procedure_code,
                  "procedure_code_modifier" => self.procedure_code_modifier,
                  "placer_supplemental_service_info" => self.placer_supplemental_service_info,
                  "filler_supplemental_service_info" => self.filler_supplemental_service_info,
                  "medically_necessary_dup_procedure_reason" => self.medically_necessary_dup_procedure_reason,
                  "result_handling" => self.result_handling,
                  "parent_universal_service_identifier" => self.parent_universal_service_identifier})
                  
  @hash
end