Class: ViewModel::Cepc71::AcReport

Inherits:
CommonSchema show all
Defined in:
lib/view_model/cepc71/ac_report.rb

Instance Method Summary collapse

Methods inherited from CommonSchema

#address_id, #address_line1, #address_line2, #address_line3, #address_line4, #all_energy_types, #all_reason_types, #all_start_dates, #assessment_id, #assessor_email, #assessor_name, #assessor_telephone, #building_level, #calculation_tool, #company_address, #company_name, #date_of_assessment, #date_of_expiry, #date_of_issue, #date_of_registration, #inspection_type, #or_assessment_end_date, #postcode, #report_type, #scheme_assessor_id, #town

Methods inherited from BaseViewModel

#initialize, #xpath

Constructor Details

This class inherits a constructor from ViewModel::BaseViewModel

Instance Method Details

#air_handling_systemsObject



142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/view_model/cepc71/ac_report.rb', line 142

def air_handling_systems
  @xml_doc
    .search("ACI-Air-Handling-System")
    .map do |node|
      {
        equipment: {
          unit: node.at("System-Number")&.content,
          component: node.at("System-Component-Identifier")&.content,
          systems_served:
            node.at("ACI-Air-Handling-System-Equipment/Systems-Served")
              &.content,
          manufacturer:
            node.at("ACI-Air-Handling-System-Equipment/Manufacturer")
              &.content,
          year_installed:
            node.at("ACI-Air-Handling-System-Equipment/Year-Installed")
              &.content,
          location:
            node.at("ACI-Air-Handling-System-Equipment/Location")
              &.content,
          areas_served:
            node.at("ACI-Air-Handling-System-Equipment/Area-Served")
              &.content,
          discrepancy:
            node.at("ACI-Air-Handling-System-Equipment/Discrepancy-Note")
              &.content,
        },
        inspection: {
          filters: {
            filter_condition:
              extract_inspection_item(node.at("Filter-Condition-OK")),
            change_frequency:
              extract_inspection_item(
                node.at("Filter-Change-Frequency-OK"),
              ),
            differential_pressure_gauge:
              extract_inspection_item(
                node.at("Differential-Pressure-Gauge-OK"),
              ),
          },
          heat_exchangers: {
            condition:
              extract_inspection_item(node.at("Heat-Exchangers-OK")),
          },
          refrigeration: {
            leaks: extract_inspection_item(node.at("Refrigeration-Leak")),
          },
          fan_rotation: {
            direction:
              extract_inspection_item(node.at("Fan-Rotation-OK")),
            modulation:
              extract_inspection_item(node.at("Fan-Modulation-OK")),
          },
          fan_control: {
            setting:
              extract_inspection_item(node.at("Fan-Control-Setting")),
          },
          heat_recovery: {
            energy_conservation:
              extract_inspection_item(
                node.at("Energy-Conservation-Features"),
              ),
          },
          air_leakage: {
            condition: extract_inspection_item(node.at("Air-Leakage")),
          },
          outdoor_inlets: {
            condition:
              extract_inspection_item(node.at("Outdoor-Air-Inlets")),
          },
          fan_power: {
            condition: extract_inspection_item(node.at("Fan-Power-OK")),
            sfp_calculation: xpath(%w[SFP-Calculation], node),
          },
        },
      }
    end
end

#checklist_values(checklist) ⇒ Object



78
79
80
81
82
83
84
85
86
87
# File 'lib/view_model/cepc71/ac_report.rb', line 78

def checklist_values(checklist)
  results =
    checklist&.element_children&.map { |node|
      checklist_item = node.name.underscore.to_sym
      value = node.content == "Yes"
      { checklist_item => value }
    }&.inject(&:merge)

  results.nil? ? {} : results
end

#cooling_plantsObject



112
113
114
115
116
117
118
# File 'lib/view_model/cepc71/ac_report.rb', line 112

def cooling_plants
  extraction_helper = Helper::AcReportExtraction.new

  @xml_doc
    .search("Air-Conditioning-Inspection-Report/ACI-Cooling-Plant")
    .map { |node| extraction_helper.cooling_plant(node) }
end

#executive_summaryObject



8
9
10
# File 'lib/view_model/cepc71/ac_report.rb', line 8

def executive_summary
  xpath(%w[Executive-Summary])
end

#extract_aci_recommendations(nodes) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/view_model/cepc71/ac_report.rb', line 12

def extract_aci_recommendations(nodes)
  nodes.filter_map do |node|
    unless node.at("Text").content.nil? || node.at("Text").content.empty?
      {
        sequence: node.at("Seq-Number").content&.to_i,
        text: node.at("Text").content,
      }
    end
  end
end

#extract_inspection_item(node) ⇒ Object



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/view_model/cepc71/ac_report.rb', line 124

def extract_inspection_item(node)
  inspection_item = {
    note: node&.at("Note")&.content,
    recommendations:
      if node.respond_to?(:search)
        extract_aci_recommendations(node.search("ACI-Recommendation"))
      else
        []
      end,
  }

  if node.respond_to?(:at) && node.at("Flag")
    inspection_item[:flag] = node.at("Flag").content == "Yes"
  end

  inspection_item
end

#key_recommendations_controlObject



39
40
41
42
43
44
45
# File 'lib/view_model/cepc71/ac_report.rb', line 39

def key_recommendations_control
  extract_aci_recommendations(
    @xml_doc.search(
      "ACI-Key-Recommendations/Alternative-Solutions/ACI-Recommendation",
    ),
  )
end

#key_recommendations_efficiencyObject



23
24
25
26
27
28
29
# File 'lib/view_model/cepc71/ac_report.rb', line 23

def key_recommendations_efficiency
  extract_aci_recommendations(
    @xml_doc.search(
      "ACI-Key-Recommendations/Sub-System-Efficiency-Capacity-Cooling-Loads/ACI-Recommendation",
    ),
  )
end

#key_recommendations_maintenanceObject



31
32
33
34
35
36
37
# File 'lib/view_model/cepc71/ac_report.rb', line 31

def key_recommendations_maintenance
  extract_aci_recommendations(
    @xml_doc.search(
      "ACI-Key-Recommendations/Improvement-Options/ACI-Recommendation",
    ),
  )
end

#key_recommendations_managementObject



47
48
49
50
51
52
53
# File 'lib/view_model/cepc71/ac_report.rb', line 47

def key_recommendations_management
  extract_aci_recommendations(
    @xml_doc.search(
      "ACI-Key-Recommendations/Other-Recommendations/ACI-Recommendation",
    ),
  )
end

#pre_inspection_checklistObject



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/view_model/cepc71/ac_report.rb', line 89

def pre_inspection_checklist
  {
    essential:
      checklist_values(
        @xml_doc.at(
          "ACI-Pre-Inspection-Information/ACI-Pre-Inspection-Essential",
        ),
      ),
    desirable:
      checklist_values(
        @xml_doc.at(
          "ACI-Pre-Inspection-Information/ACI-Pre-Inspection-Desirable",
        ),
      ),
    optional:
      checklist_values(
        @xml_doc.at(
          "ACI-Pre-Inspection-Information/ACI-Pre-Inspection-Optional",
        ),
      ),
  }
end


4
5
6
# File 'lib/view_model/cepc71/ac_report.rb', line 4

def related_party_disclosure
  xpath(%w[ACI-Related-Party-Disclosure])
end


120
121
122
# File 'lib/view_model/cepc71/ac_report.rb', line 120

def related_rrn
  xpath(%w[Related-RRN])
end

#sub_systemsObject



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/view_model/cepc71/ac_report.rb', line 55

def sub_systems
  @xml_doc
    .search("ACI-Sub-Systems/ACI-Sub-System")
    .map do |node|
      {
        volume_definitions:
          node.at("Sub-System-Volume-Definitions")&.content,
        id: node.at("Sub-System-ID")&.content,
        description: node.at("Sub-System-Description")&.content,
        cooling_output: node.at("Sub-System-Cooling-Output")&.content,
        area_served:
          node.at("Sub-System-Area-Served-Description")&.content,
        inspection_date: node.at("Sub-System-Inspection-Date")&.content,
        cooling_plant_count:
          node.at("Sub-System-Cooling-Plant-Count")&.content,
        ahu_count: node.at("Sub-System-AHU-Count")&.content,
        terminal_units_count:
          node.at("Sub-System-Terminal-Units-Count")&.content,
        controls_count: node.at("Sub-System-Controls-Count")&.content,
      }
    end
end

#system_controlsObject



276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
# File 'lib/view_model/cepc71/ac_report.rb', line 276

def system_controls
  @xml_doc
    .search("ACI-System-Control")
    .map do |node|
      {
        sub_system_id: xpath(%w[Sub-System-ID], node),
        component: xpath(%w[System-Component-Identifier], node),
        inspection: {
          zoning: extract_inspection_item(node.at("Zoning-Assessment")),
          time:
            extract_inspection_item(node.at("Current-Indicated-Time")),
          set_on_period:
            extract_inspection_item(node.at("Set-On-Period")),
          timer_shortfall:
            extract_inspection_item(node.at("Timer-Shortfall")),
          sensors:
            extract_inspection_item(node.at("Sensors-Appropriate")),
          set_temperature:
            extract_inspection_item(node.at("Set-Temperature")),
          dead_band: extract_inspection_item(node.at("Dead-Band-Set")),
          capacity:
            extract_inspection_item(node.at("Equipment-Capacity")),
          airflow: extract_inspection_item(node.at("Airflow-Modulation")),
          guidance_controls:
            extract_inspection_item(node.at("Use-Guidance-Or-Controls")),
        },
      }
    end
end

#terminal_unitsObject



221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
# File 'lib/view_model/cepc71/ac_report.rb', line 221

def terminal_units
  @xml_doc
    .search("ACI-Terminal-Unit")
    .map do |node|
      {
        equipment: {
          unit: node.at("System-Number")&.content,
          component: node.at("System-Component-Identifier")&.content,
          description: node.at("System-Identifier")&.content,
          cooling_plant: node.at("Systems-Served")&.content,
          manufacturer: node.at("Manufacturer")&.content,
          year_installed: node.at("Year-Installed")&.content,
          area_served: node.at("Area-Served")&.content,
          discrepancy: node.at("Discrepancy-Note")&.content,
        },
        inspection: {
          insulation: {
            pipework:
              extract_inspection_item(node.at("Pipe-Insulation-OK")),
            ductwork:
              extract_inspection_item(node.at("Ductwork-Insulated-OK")),
          },
          unit: {
            condition:
              extract_inspection_item(node.at("Unit-Condition-OK")),
          },
          grilles_air_flow: {
            distribution:
              extract_inspection_item(
                node.at("Air-Flow-Distribution-OK"),
              ),
            tampering:
              extract_inspection_item(
                node.at("Air-Flow-Tampering-Issues"),
              ),
            water_supply:
              extract_inspection_item(node.at("Water-Supply-OK")),
            complaints:
              extract_inspection_item(node.at("Air-Flow-Issues")),
          },
          diffuser_positions: {
            position_issues:
              extract_inspection_item(
                node.at("Diffuser-Positions-Issues"),
              ),
            partitioning_issues:
              extract_inspection_item(node.at("Partitioning-Issues")),
            control_operation:
              extract_inspection_item(node.at("Control-Operation-OK")),
          },
        },
      }
    end
end