@@ -23,29 +23,30 @@ def base_amount_cents
2323 cbhpm_procedure = find_cbhpm_procedure
2424 return 0 unless cbhpm_procedure
2525
26- port_value = find_port_value ( cbhpm_procedure )
27- return value_for_anesthetic_port_zero ( event_procedure ) unless port_value
26+ port_value = find_port_value ( cbhpm_procedure . anesthetic_port )
27+ return value_for_anesthetic_port_zero unless port_value
2828
2929 port_value . amount_cents . to_i
3030 end
3131
32- def value_for_anesthetic_port_zero ( event_procedure )
33- port = event_procedure . cbhpm . port_values . find do |pv |
34- pv . anesthetic_port == ANESTHETIC_PORT_ZERO_AMOUNT
35- end
36- port &.amount_cents . to_i
32+ def value_for_anesthetic_port_zero
33+ port_values_by_anesthetic_port [ ANESTHETIC_PORT_ZERO_AMOUNT ] &.amount_cents . to_i
3734 end
3835
3936 def find_cbhpm_procedure
40- event_procedure . procedure . cbhpm_procedures . find do |cp |
41- cp . cbhpm_id == event_procedure . cbhpm_id
42- end
37+ cbhpm_procedures_by_cbhpm_id [ event_procedure . cbhpm_id ]
4338 end
4439
45- def find_port_value ( cbhpm_procedure )
46- event_procedure . cbhpm . port_values . find do |pv |
47- pv . anesthetic_port == cbhpm_procedure . anesthetic_port
48- end
40+ def find_port_value ( anesthetic_port )
41+ port_values_by_anesthetic_port [ anesthetic_port ]
42+ end
43+
44+ def cbhpm_procedures_by_cbhpm_id
45+ @cbhpm_procedures_by_cbhpm_id ||= event_procedure . procedure . cbhpm_procedures . index_by ( &:cbhpm_id )
46+ end
47+
48+ def port_values_by_anesthetic_port
49+ @port_values_by_anesthetic_port ||= event_procedure . cbhpm . port_values . index_by ( &:anesthetic_port )
4950 end
5051
5152 def apartment_multiplier
0 commit comments