-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Write hearing type to VACOLS when converting legacy hearings #15184
Changes from 5 commits
8cbd5a9
fa0c1e8
ca8e190
d3b1acb
a584589
adaa387
3d7cbd2
4a30d35
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,8 @@ def update | |
|
||
add_virtual_hearing_alert if show_virtual_hearing_progress_alerts? | ||
end | ||
|
||
after_update_hearing | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense for this to happen inside the transaction block? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good call. moved it in adaa387 |
||
end | ||
|
||
def hearing_alerts | ||
|
@@ -46,6 +48,8 @@ def virtual_hearing_alert | |
|
||
def update_hearing; end | ||
|
||
def after_update_hearing; end | ||
|
||
def hearing_updates; end | ||
|
||
# Whether or not the hearing has been updated by the form. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,15 @@ class LegacyHearing < CaseflowRecord | |
# scheduled_for is the correct hearing date and time in Eastern Time for travel | ||
# board and video hearings, or in the user's (Hearing Coordinator) time zone for | ||
# central hearings; the transformation happens in HearingMapper.datetime_based_on_type | ||
vacols_attr_accessor :scheduled_for, :request_type, :venue_key, :vacols_record, :disposition | ||
vacols_attr_accessor :scheduled_for | ||
|
||
# request_type is the current value of HEARSCHED.HEARING_TYPE in VACOLS, but one | ||
# should use original_request_type or readable_request_type to make sure we | ||
# consistently get the value we expect, as we are now writing to this field in | ||
# VACOLS when we convert a legacy hearing to and from virtual. | ||
vacols_attr_accessor :request_type | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if it would be possible to semi-enforce this by making the Also, the naming of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That makes sense, I agree it's confusing. I removed the recommendation to use As for making |
||
|
||
vacols_attr_accessor :venue_key, :vacols_record, :disposition | ||
vacols_attr_accessor :aod, :hold_open, :transcript_requested, :notes, :add_on | ||
vacols_attr_accessor :transcript_sent_date, :appeal_vacols_id | ||
vacols_attr_accessor :representative_name, :hearing_day_vacols_id | ||
|
@@ -120,8 +128,8 @@ def external_id | |
end | ||
|
||
def hearing_day_id_refers_to_vacols_row? | ||
(request_type == HearingDay::REQUEST_TYPES[:central] && scheduled_for.to_date < Date.new(2019, 1, 1)) || | ||
(request_type == HearingDay::REQUEST_TYPES[:video] && scheduled_for.to_date < Date.new(2019, 4, 1)) | ||
(original_request_type == HearingDay::REQUEST_TYPES[:central] && scheduled_for.to_date < Date.new(2019, 1, 1)) || | ||
(original_request_type == HearingDay::REQUEST_TYPES[:video] && scheduled_for.to_date < Date.new(2019, 4, 1)) | ||
end | ||
|
||
def hearing_day_id | ||
|
@@ -147,15 +155,15 @@ def hearing_day | |
# There is a constraint within the `HearingRepository` context that means that calling | ||
# `LegacyHearing#regional_office_Key` triggers an unnecessary call to VACOLS. | ||
def regional_office_key | ||
if request_type == HearingDay::REQUEST_TYPES[:travel] || hearing_day.nil? | ||
if original_request_type == HearingDay::REQUEST_TYPES[:travel] || hearing_day.nil? | ||
return (venue_key || appeal&.regional_office_key) | ||
end | ||
|
||
hearing_day&.regional_office || "C" | ||
end | ||
|
||
def request_type_location | ||
if request_type == HearingDay::REQUEST_TYPES[:central] | ||
if original_request_type == HearingDay::REQUEST_TYPES[:central] | ||
"Board of Veterans' Appeals in Washington, DC" | ||
elsif venue | ||
venue[:label] | ||
|
@@ -225,16 +233,33 @@ def update_caseflow_and_vacols(hearing_hash) | |
end | ||
end | ||
|
||
def update_request_type_in_vacols(new_request_type) | ||
if VACOLS::CaseHearing::HEARING_TYPES.exclude? new_request_type | ||
fail HearingMapper::InvalidRequestTypeError, "\"#{new_request_type}\" is not a valid request type." | ||
end | ||
|
||
# update original_vacols_request_type if request_type is not virtual | ||
if request_type != VACOLS::CaseHearing::HEARING_TYPE_LOOKUP[:virtual] | ||
update!(original_vacols_request_type: request_type) | ||
end | ||
|
||
update_caseflow_and_vacols(request_type: new_request_type) | ||
end | ||
|
||
def readable_location | ||
if request_type == LegacyHearing::CO_HEARING | ||
if original_request_type == HearingDay::REQUEST_TYPES[:central] | ||
return "Washington, DC" | ||
end | ||
|
||
regional_office_name | ||
end | ||
|
||
def readable_request_type | ||
Hearing::HEARING_TYPES[request_type.to_sym] | ||
Hearing::HEARING_TYPES[original_request_type.to_sym] | ||
end | ||
|
||
def original_request_type | ||
original_vacols_request_type.presence || request_type | ||
end | ||
|
||
cache_attribute :cached_number_of_documents do | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddOriginalVacolsRequestTypeToLegacyHearing < Caseflow::Migration | ||
def change | ||
add_column :legacy_hearings, :original_vacols_request_type, :string, comment: "The original request type of the hearing in VACOLS, before it was changed to Virtual" | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make more sense to put this in the
VACOLS::CaseHearing
model validation?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking of moving the definition of the
InvalidRequestTypeError
there, because I use it here and inLegacyHearing
, but I think it makes sense to keep an actual validation here, consistent with how the other fields are transformed and validated.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It just occurred to me that
InvalidRequestTypeError
might overlap withInvalidRequestTypeCode
in Stephen's PR: https://github.com/department-of-veterans-affairs/caseflow/pull/14251/files? Something to think about 🤔There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch; I plan to go back to that PR this week, and I'll make sure there's no duplication 😫