Skip to content

Commit

Permalink
Generate additionalAppointmentDetails from appointment request reason…
Browse files Browse the repository at this point in the history
…code.text (#17541)

* Generate additionalAppointmentDetails from appointment request reasoncode.text

* Address an update for contact field
  • Loading branch information
JunTaoLuo authored Jul 16, 2024
1 parent c64e1c2 commit dfacf3e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@ def extract_reason_code_fields(appointment)
# Extract contact fields from hash
if reason_code_hash.key?('phone number') || reason_code_hash.key?('email')
contact_info = []
contact_info.push({ system: 'phone', value: reason_code_hash['phone number'] })
contact_info.push({ system: 'email', value: reason_code_hash['email'] })
contact_info.push({ type: 'phone', value: reason_code_hash['phone number'] })
contact_info.push({ type: 'email', value: reason_code_hash['email'] })
appointment[:contact] = { telecom: contact_info }
end

# Extract additionalAppointmentDetails from hash
appointment[:additional_appointment_details] = reason_code_hash['comments'] if reason_code_hash.key?('comments')
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,36 @@
appt = FactoryBot.build(:appointment_form_v2, :va_proposed_base).attributes
subject.extract_reason_code_fields(appt)
expect(appt[:contact]).to eq({})
expect(appt[:additional_appointment_details]).to be_nil
end

it 'returns without modification if no valid reason code text fields exists' do
appt = FactoryBot.build(:appointment_form_v2, :va_proposed_invalid_reason_code_text).attributes
subject.extract_reason_code_fields(appt)
expect(appt[:contact]).to eq({})
expect(appt[:additional_appointment_details]).to be_nil
end

it 'returns without modification for cc request' do
appt = FactoryBot.build(:appointment_form_v2, :community_cares_valid_reason_code_text).attributes
subject.extract_reason_code_fields(appt)
expect(appt[:contact]).to eq({})
expect(appt[:additional_appointment_details]).to be_nil
end

it 'returns without modification for va booked' do
appt = FactoryBot.build(:appointment_form_v2, :va_booked_valid_reason_code_text).attributes
subject.extract_reason_code_fields(appt)
expect(appt[:contact]).to eq({})
expect(appt[:additional_appointment_details]).to be_nil
end

it 'extract valid reason text for va request' do
appt = FactoryBot.build(:appointment_form_v2, :va_proposed_valid_reason_code_text).attributes
subject.extract_reason_code_fields(appt)
expect(appt[:contact][:telecom][0]).to eq({ system: 'phone', value: '6195551234' })
expect(appt[:contact][:telecom][1]).to eq({ system: 'email', value: 'myemail72585885@unattended.com' })
expect(appt[:contact][:telecom][0]).to eq({ type: 'phone', value: '6195551234' })
expect(appt[:contact][:telecom][1]).to eq({ type: 'email', value: 'myemail72585885@unattended.com' })
expect(appt[:additional_appointment_details]).to eq('test')
end
end
end

0 comments on commit dfacf3e

Please sign in to comment.