Skip to content

Commit

Permalink
Send the claim's guid to CARMA on 10-10CG submissions (#4588)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinmirc authored Jul 31, 2020
1 parent c694346 commit ca51b3a
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3 deletions.
5 changes: 4 additions & 1 deletion lib/carma/models/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ module CARMA
module Models
class Metadata < Base
request_payload_key :claim_id,
:claim_guid,
:veteran,
:primary_caregiver,
:secondary_caregiver_one,
:secondary_caregiver_two

attr_accessor :claim_id
attr_accessor :claim_id,
:claim_guid

attr_reader :veteran,
:primary_caregiver,
Expand All @@ -22,6 +24,7 @@ class Metadata < Base

def initialize(args = {})
@claim_id = args[:claim_id]
@claim_guid = args[:claim_guid]

self.veteran = args[:veteran] || {}
self.primary_caregiver = args[:primary_caregiver] || {}
Expand Down
2 changes: 1 addition & 1 deletion lib/carma/models/submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def clear_veteran_icn(data)
def self.from_claim(claim, metadata = {})
new(
data: claim.parsed_form,
metadata: metadata.merge(claim_id: claim.id)
metadata: metadata.merge(claim_id: claim.id, claim_guid: claim.guid)
)
end

Expand Down
15 changes: 14 additions & 1 deletion spec/lib/carma/models/metadata_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
end
end

describe '#claim_guid' do
it 'is accessible' do
subject.claim_guid = 'my-uuid'
expect(subject.claim_guid).to eq('my-uuid')
end
end

describe '#veteran' do
it 'is accessible' do
subject.veteran = { icn: 'ABCD1234', is_veteran: true }
Expand Down Expand Up @@ -78,6 +85,7 @@
it 'accepts :claim_id, :veteran, :primary_caregiver, :secondary_caregiver_one, :secondary_caregiver_two' do
subject = described_class.new(
claim_id: 123,
claim_guid: 'my-uuid',
veteran: {
icn: 'VET1234',
is_veteran: true
Expand All @@ -94,6 +102,7 @@
)

expect(subject.claim_id).to eq(123)
expect(subject.claim_guid).to eq('my-uuid')
expect(subject.veteran.icn).to eq('VET1234')
expect(subject.veteran.is_veteran).to eq(true)
expect(subject.primary_caregiver.icn).to eq('PC1234')
Expand All @@ -111,6 +120,7 @@
expect(described_class.request_payload_keys).to eq(
%i[
claim_id
claim_guid
veteran
primary_caregiver
secondary_caregiver_one
Expand All @@ -123,11 +133,12 @@
describe '#to_request_payload' do
describe 'can receive :to_request_payload' do
it 'with a minimal data set' do
subject = described_class.new claim_id: 123
subject = described_class.new claim_id: 123, claim_guid: 'my-uuid'

expect(subject.to_request_payload).to eq(
{
'claimId' => 123,
'claimGuid' => 'my-uuid',
'veteran' => {
'icn' => nil,
'isVeteran' => nil
Expand All @@ -144,6 +155,7 @@
it 'with a maximum data set' do
subject = described_class.new(
claim_id: 123,
claim_guid: 'my-uuid',
veteran: {
icn: 'VET1234',
is_veteran: true
Expand All @@ -162,6 +174,7 @@
expect(subject.to_request_payload).to eq(
{
'claimId' => 123,
'claimGuid' => 'my-uuid',
'veteran' => {
'icn' => 'VET1234',
'isVeteran' => true
Expand Down
25 changes: 25 additions & 0 deletions spec/lib/carma/models/submission_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
it 'is accessible' do
subject.metadata = {
claim_id: 123,
claim_guid: 'my-uuid',
veteran: {
icn: 'VET1234',
is_veteran: true
Expand All @@ -68,6 +69,7 @@
# metadata
expect(subject.metadata).to be_instance_of(CARMA::Models::Metadata)
expect(subject.metadata.claim_id).to eq(123)
expect(subject.metadata.claim_guid).to eq('my-uuid')
# metadata.veteran
expect(subject.metadata.veteran).to be_instance_of(CARMA::Models::Veteran)
expect(subject.metadata.veteran.icn).to eq('VET1234')
Expand All @@ -92,6 +94,7 @@
# metadata
expect(subject.metadata).to be_instance_of(CARMA::Models::Metadata)
expect(subject.metadata.claim_id).to eq(nil)
expect(subject.metadata.claim_guid).to eq(nil)
# metadata.veteran
expect(subject.metadata.veteran).to be_instance_of(CARMA::Models::Veteran)
expect(subject.metadata.veteran.icn).to eq(nil)
Expand Down Expand Up @@ -120,6 +123,7 @@
data: expected[:data],
metadata: {
claim_id: 123,
claim_guid: 'my-uuid',
veteran: {
icn: 'VET1234',
is_veteran: true
Expand All @@ -142,6 +146,7 @@
# metadata
expect(subject.metadata).to be_instance_of(CARMA::Models::Metadata)
expect(subject.metadata.claim_id).to eq(123)
expect(subject.metadata.claim_guid).to eq('my-uuid')
# metadata.veteran
expect(subject.metadata.veteran).to be_instance_of(CARMA::Models::Veteran)
expect(subject.metadata.veteran.icn).to eq('VET1234')
Expand Down Expand Up @@ -171,6 +176,7 @@

expect(submission.metadata).to be_instance_of(CARMA::Models::Metadata)
expect(submission.metadata.claim_id).to eq(claim.id)
expect(submission.metadata.claim_guid).to eq(claim.guid)
end

it 'will override :claim_id when passed in metadata and use claim.id instead' do
Expand All @@ -186,6 +192,21 @@
expect(submission.metadata).to be_instance_of(CARMA::Models::Metadata)
expect(submission.metadata.claim_id).to eq(claim.id)
end

it 'will override :claim_guid when passed in metadata and use claim.guid instead' do
claim = build(:caregivers_assistance_claim)

submission = described_class.from_claim(claim, claim_guid: 'not-this-claims-guid')

expect(submission).to be_instance_of(described_class)
expect(submission.data).to eq(claim.parsed_form)
expect(submission.carma_case_id).to eq(nil)
expect(submission.submitted_at).to eq(nil)

expect(submission.metadata).to be_instance_of(CARMA::Models::Metadata)
expect(submission.metadata.claim_guid).not_to eq('not-this-claims-guid')
expect(submission.metadata.claim_guid).to eq(claim.guid)
end
end

describe '::request_payload_keys' do
Expand All @@ -206,6 +227,7 @@
},
metadata: {
claim_id: 123,
claim_guid: 'my-uuid',
veteran: {
icn: 'VET1234',
is_veteran: true
Expand All @@ -229,6 +251,7 @@
},
'metadata' => {
'claimId' => 123,
'claimGuid' => 'my-uuid',
'veteran' => {
'icn' => 'VET1234',
'isVeteran' => true
Expand All @@ -255,6 +278,7 @@
},
metadata: {
claim_id: 123,
claim_guid: 'my-uuid',
veteran: {
icn: 'VET1234',
is_veteran: false
Expand All @@ -278,6 +302,7 @@
},
'metadata' => {
'claimId' => 123,
'claimGuid' => 'my-uuid',
'veteran' => {
'icn' => nil,
'isVeteran' => false
Expand Down

0 comments on commit ca51b3a

Please sign in to comment.