Skip to content
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

76255 travel claims oh templates 2 #15812

Merged
merged 8 commits into from
Mar 18, 2024
6 changes: 6 additions & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1288,6 +1288,12 @@ vanotify:
claim_submission_success_text: fake_template_id
claim_submission_duplicate_text: fake_template_id
claim_submission_error_text: fake_template_id
oracle_health:
sms_sender_id: fake_secret
template_id:
claim_submission_success_text: fake_template_id
claim_submission_duplicate_text: fake_template_id
claim_submission_error_text: fake_template_id
mock: false
links:
connected_applications: https://www.va.gov/profile/connected-applications
Expand Down
16 changes: 11 additions & 5 deletions config/settings/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,17 @@ vanotify:
disconnection_template: fake_template_id
check_in:
api_key: check-in_aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa-bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb
sms_sender_id: fake_sms_sender_id
sms_sender_id: cie_fake_sms_sender_id
template_id:
claim_submission_success_text: fake_success_template_id
claim_submission_duplicate_text: fake_duplicate_template_id
claim_submission_error_text: fake_error_template_id
claim_submission_success_text: cie_fake_success_template_id
claim_submission_duplicate_text: cie_fake_duplicate_template_id
claim_submission_error_text: cie_fake_error_template_id
oracle_health:
sms_sender_id: oh_fake_sms_sender_id
template_id:
claim_submission_success_text: oh_fake_success_template_id
claim_submission_duplicate_text: oh_fake_duplicate_template_id
claim_submission_error_text: oh_fake_error_template_id

veteran_readiness_and_employment:
base_url: https://fake_url.com
Expand Down Expand Up @@ -225,7 +231,7 @@ lighthouse:
client_id: abc123456
rsa_key: path/to/key
use_mocks: false
benefits_education:
benefits_education:
host: https://sandbox-api.va.gov
use_mocks: true
access_token:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,72 +9,109 @@

sidekiq_options retry: false

SUCCESS_TEMPLATE_ID = Settings.vanotify.services.check_in.template_id.claim_submission_success_text
DUPLICATE_TEMPLATE_ID = Settings.vanotify.services.check_in.template_id.claim_submission_duplicate_text
ERROR_TEMPLATE_ID = Settings.vanotify.services.check_in.template_id.claim_submission_error_text

SMS_SENDER_ID = Settings.vanotify.services.check_in.sms_sender_id

# settings for travel claims for vista appts
STATSD_NOTIFY_ERROR = 'worker.checkin.travel_claim.notify.error'
STATSD_NOTIFY_SUCCESS = 'worker.checkin.travel_claim.notify.success'

STATSD_BTSSS_SUCCESS = 'worker.checkin.travel_claim.btsss.success'
STATSD_BTSSS_ERROR = 'worker.checkin.travel_claim.btsss.error'
STATSD_BTSSS_DUPLICATE = 'worker.checkin.travel_claim.btsss.duplicate'
CIE_SUCCESS_TEMPLATE_ID = Settings.vanotify.services.check_in.template_id.claim_submission_success_text
CIE_DUPLICATE_TEMPLATE_ID = Settings.vanotify.services.check_in.template_id.claim_submission_duplicate_text
CIE_ERROR_TEMPLATE_ID = Settings.vanotify.services.check_in.template_id.claim_submission_error_text

CIE_SMS_SENDER_ID = Settings.vanotify.services.check_in.sms_sender_id

CIE_STATSD_BTSSS_SUCCESS = 'worker.checkin.travel_claim.btsss.success'
CIE_STATSD_BTSSS_ERROR = 'worker.checkin.travel_claim.btsss.error'
CIE_STATSD_BTSSS_DUPLICATE = 'worker.checkin.travel_claim.btsss.duplicate'

# settings for travel claims for oracle health settings
OH_SUCCESS_TEMPLATE_ID = Settings.vanotify.services.oracle_health.template_id.claim_submission_success_text
OH_DUPLICATE_TEMPLATE_ID = Settings.vanotify.services.oracle_health.template_id.claim_submission_duplicate_text
OH_ERROR_TEMPLATE_ID = Settings.vanotify.services.oracle_health.template_id.claim_submission_error_text

OH_SMS_SENDER_ID = Settings.vanotify.services.oracle_health.sms_sender_id

OH_STATSD_BTSSS_SUCCESS = 'worker.oracle_health.travel_claim.btsss.success'
OH_STATSD_BTSSS_ERROR = 'worker.oracle_health.travel_claim.btsss.error'
OH_STATSD_BTSSS_DUPLICATE = 'worker.oracle_health.travel_claim.btsss.duplicate'

def perform(uuid, appointment_date)
redis_client = TravelClaim::RedisClient.build
mobile_phone = redis_client.patient_cell_phone(uuid:)
station_number = redis_client.station_number(uuid:)
facility_type = redis_client.facility_type(uuid:)

logger.info({
message: "Submitting travel claim for #{uuid}, #{appointment_date}, #{station_number}",
message: "Submitting travel claim for #{uuid}, #{appointment_date}, " \
"#{station_number}, #{facility_type}",
uuid:,
appointment_date:,
station_number:
station_number:,
facility_type:
})

claim_number, template_id = submit_claim(uuid:, appointment_date:, station_number:)
claim_number, template_id = submit_claim(uuid:, appointment_date:, station_number:, facility_type:)

send_notification(mobile_phone:, appointment_date:, template_id:, claim_number:)
send_notification(mobile_phone:, appointment_date:, template_id:, claim_number:, facility_type:)
StatsD.increment(STATSD_NOTIFY_SUCCESS)
end

def submit_claim(opts = {})
check_in_session = CheckIn::V2::Session.build(data: { uuid: opts[:uuid] })

claims_resp = TravelClaim::Service.build(
check_in: check_in_session,
params: { appointment_date: opts[:appointment_date] }
).submit_claim

handle_response(claims_resp:)
rescue Common::Exceptions::BackendServiceException => e
handle_response(claims_resp:, facility_type: opts[:facility_type])
rescue => e
logger.error({ message: "Error calling BTSSS Service: #{e.message}" }.merge(opts))
StatsD.increment(STATSD_BTSSS_ERROR)
[nil, ERROR_TEMPLATE_ID]
if 'oh'.casecmp?(opts[:facility_type])
StatsD.increment(OH_STATSD_BTSSS_ERROR)
template_id = OH_ERROR_TEMPLATE_ID
else
StatsD.increment(CIE_STATSD_BTSSS_ERROR)
template_id = CIE_ERROR_TEMPLATE_ID
end
[nil, template_id]
end

def handle_response(claims_resp:)
claim_number = claims_resp&.dig(:data, :claimNumber)&.last(4)
template_id =
case claims_resp&.dig(:data, :code)
when TravelClaim::Response::CODE_SUCCESS
StatsD.increment(STATSD_BTSSS_SUCCESS)
SUCCESS_TEMPLATE_ID
when TravelClaim::Response::CODE_CLAIM_EXISTS
StatsD.increment(STATSD_BTSSS_DUPLICATE)
DUPLICATE_TEMPLATE_ID
else
StatsD.increment(STATSD_BTSSS_ERROR)
ERROR_TEMPLATE_ID
end
# rubocop:disable Metrics/MethodLength
def handle_response(opts = {})
claim_number = opts[:claims_resp]&.dig(:data, :claimNumber)&.last(4)
code = opts[:claims_resp]&.dig(:data, :code)
facility_type = opts[:facility_type] || ''

statsd_metric, template_id = case facility_type.downcase
when 'oh'

Check failure on line 86 in modules/check_in/app/sidekiq/check_in/travel_claim_submission_worker.rb

View workflow job for this annotation

GitHub Actions / Linting and Security

Layout/CaseIndentation: Indent `when` as deep as `case`.
case code
when TravelClaim::Response::CODE_SUCCESS
[OH_STATSD_BTSSS_SUCCESS, OH_SUCCESS_TEMPLATE_ID]
when TravelClaim::Response::CODE_CLAIM_EXISTS
[OH_STATSD_BTSSS_DUPLICATE, OH_DUPLICATE_TEMPLATE_ID]
else
[OH_STATSD_BTSSS_ERROR, OH_ERROR_TEMPLATE_ID]
end
else
case code
when TravelClaim::Response::CODE_SUCCESS
[CIE_STATSD_BTSSS_SUCCESS, CIE_SUCCESS_TEMPLATE_ID]
when TravelClaim::Response::CODE_CLAIM_EXISTS
[CIE_STATSD_BTSSS_DUPLICATE, CIE_DUPLICATE_TEMPLATE_ID]
else
[CIE_STATSD_BTSSS_ERROR, CIE_ERROR_TEMPLATE_ID]
end
end

Check failure on line 104 in modules/check_in/app/sidekiq/check_in/travel_claim_submission_worker.rb

View workflow job for this annotation

GitHub Actions / Linting and Security

Layout/EndAlignment: `end` at 104, 38 is not aligned with `case` at 85, 35.

StatsD.increment(statsd_metric)
[claim_number, template_id]
end
# rubocop:enable Metrics/MethodLength

def send_notification(opts = {})
notify_client = VaNotify::Service.new(Settings.vanotify.services.check_in.api_key)

phone_last_four = opts[:mobile_phone].delete('^0-9').last(4)

logger.info({
message: "Sending travel claim notification to #{phone_last_four}, #{opts[:template_id]}",
phone_last_four:,
Expand All @@ -85,7 +122,7 @@
notify_client.send_sms(
phone_number: opts[:mobile_phone],
template_id: opts[:template_id],
sms_sender_id: SMS_SENDER_ID,
sms_sender_id: 'oh'.casecmp?(opts[:facility_type]) ? OH_SMS_SENDER_ID : CIE_SMS_SENDER_ID,
personalisation: {
claim_number: opts[:claim_number],
appt_date: appt_date_in_mmm_dd_format
Expand Down
Loading
Loading