Skip to content

Commit

Permalink
Accept 10-10CG Submissions without a Primary Caregiver (#5264)
Browse files Browse the repository at this point in the history
* Reference new schema requirements for 10-10cg (secondary only applications)

* Update 10-10CG data pipeline to support applications with no primary caregiver

* Fix typos

* Update vets_json_schema gem

* Update lib/carma/README.md

Co-authored-by: Keifer Furzland <kfrz@users.noreply.github.com>

* Fix indentation in carma lib for rubocop

* Update lib/carma/README.md

Co-authored-by: Keifer Furzland <kfrz@users.noreply.github.com>

* Update Gemfile

Co-authored-by: Keifer Furzland <kfrz@users.noreply.github.com>

Co-authored-by: Keifer Furzland <kfrz@users.noreply.github.com>
  • Loading branch information
kevinmirc and kfrz authored Nov 20, 2020
1 parent a8b3c83 commit 9e2ce67
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 53 deletions.
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ GIT

GIT
remote: https://github.com/department-of-veterans-affairs/vets-json-schema
revision: 4f2d386700245582301ae2b04ddd629e422697a0
branch: master
revision: 17c2992bce1572a67490d76193e0568177810399
branch: 10-10cg-new-version
specs:
vets_json_schema (17.3.3)
vets_json_schema (18.0.0)
multi_json (~> 1.0)
script_utils (= 0.0.4)

Expand Down
2 changes: 1 addition & 1 deletion app/services/form1010cg/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def assert_veteran_status
# is_veteran: true | false | nil,
# icn: String | nil
# },
# primaryCaregiver: { icn: String | nil },
# primaryCaregiver?: { icn: String | nil },
# secondaryCaregiverOne?: { icn: String | nil },
# secondaryCaregiverTwo?: { icn: String | nil }
# }
Expand Down
12 changes: 6 additions & 6 deletions lib/carma/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
CARMA (Caregiver Record Management Application)

## Description
CARMA (Caregiver Record Management Application) is a Salesforce application that the VA's Caregivers Program uses to intake, track, and process 10-10CG submissions.
CARMA is a Salesforce application that the VA's Caregivers Program uses to track and process 10-10CG submissions.

This CARMA service/module is used to submit valid, online, 10-10CG submissions (CaregiversAssistanceClaim) to CARMA. It includes models that map to the Salesforce API interface and an http client.
This library is used to submit valid, online, 10-10CG submissions (CaregiversAssistanceClaim) to CARMA. It includes an HTTP client and models that map to the CARMA domain.

## Design

Expand All @@ -16,7 +16,7 @@ This is an http client used to communicate with CARMA. It contains configuration

## Example

### Simple Submission
### Simple Submission (with implicit client)
```
claim = CaregiversAssistanceClaim.new
Expand All @@ -31,7 +31,7 @@ submission.metadata = {
submission.submit!(CARMA::Client::Client.new)
```

### Submission with Attachments
### Submission with Attachments (with explicit client)
```
carma_client = CARMA::Client::Client.new
claim = SavedClaim::CaregiversAssistanceClaim.new
Expand All @@ -56,7 +56,7 @@ attachments = CARMA::Models::Attachments.new(
attachments.add('10-10CG', 'tmp/pdfs/10-10CG-claim-guid.pdf')
attachments.add('POA', 'tmp/pdfs/POA-claim-guid.pdf')
attachments.submit!(carma_client)
attachments.submit!(carma_client) # Pass the same client used for the submission request, so another auth request isn't made
```

## Data Contract
Expand All @@ -68,7 +68,7 @@ attachments.submit!(carma_client)
claimGuid: string;
claimId: number | null;
veteran: { icn: string | null; isVeteran?: true | false; },
primaryCaregiver: { icn: string | null; isVeteran?: true | false; },
primaryCaregiver?: { icn: string | null; isVeteran?: true | false; },
secondaryCaregiverOne?: { icn: string | null; isVeteran?: true | false; },
secondaryCaregiverTwo?: { icn: string | null; isVeteran?: true | false; },
}
Expand Down
28 changes: 16 additions & 12 deletions lib/carma/models/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def initialize(args = {})
@claim_guid = args[:claim_guid]

self.veteran = args[:veteran] || {}
self.primary_caregiver = args[:primary_caregiver] || {}
self.primary_caregiver = args[:primary_caregiver]
self.secondary_caregiver_one = args[:secondary_caregiver_one]
self.secondary_caregiver_two = args[:secondary_caregiver_two]
end
Expand All @@ -37,23 +37,27 @@ def veteran=(veteran_data_hash)
end

def primary_caregiver=(pc_metadata_hash)
@primary_caregiver = Caregiver.new(pc_metadata_hash)
@primary_caregiver = if pc_metadata_hash.nil?
nil
else
Caregiver.new(pc_metadata_hash)
end
end

def secondary_caregiver_one=(sc_one_metadata_hash)
@secondary_caregiver_one = if sc_one_metadata_hash.nil?
nil
else
Caregiver.new(sc_one_metadata_hash)
end
@secondary_caregiver_one = if sc_one_metadata_hash.nil?
nil
else
Caregiver.new(sc_one_metadata_hash)
end
end

def secondary_caregiver_two=(sc_two_metadata_hash)
@secondary_caregiver_two = if sc_two_metadata_hash.nil?
nil
else
Caregiver.new(sc_two_metadata_hash)
end
@secondary_caregiver_two = if sc_two_metadata_hash.nil?
nil
else
Caregiver.new(sc_two_metadata_hash)
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,15 @@
)
expect(res_body['errors'][0]['code']).to eq('100')
expect(res_body['errors'][0]['status']).to eq('422')
expect(res_body['errors'][1]['title']).to include(
"did not contain a required property of 'primaryCaregiver'"
expect(res_body['errors'][1]['title'].split("\n")).to eq(
[
"Form The property '#/' of type object did not match one or more of the required schemas. The schema specific errors were:", # rubocop:disable Layout/LineLength
'',
'- anyOf #0:',
" - The property '#/' did not contain a required property of 'primaryCaregiver'",
'- anyOf #1:',
" - The property '#/' did not contain a required property of 'secondaryCaregiverOne'"
]
)
expect(res_body['errors'][1]['code']).to eq('100')
expect(res_body['errors'][1]['status']).to eq('422')
Expand Down
90 changes: 66 additions & 24 deletions spec/lib/carma/models/metadata_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
expect(subject.primary_caregiver).to be_instance_of(CARMA::Models::Caregiver)
expect(subject.primary_caregiver.icn).to eq('ABCD1234')
end

it 'can be set to nil' do
subject.primary_caregiver = nil
expect(subject.primary_caregiver).to eq(nil)
end
end

describe '#secondary_caregiver_one' do
Expand All @@ -45,7 +50,7 @@
expect(subject.secondary_caregiver_one.icn).to eq('ABCD1234')
end

it 'is can be set to nil' do
it 'can be set to nil' do
subject.secondary_caregiver_one = nil
expect(subject.secondary_caregiver_one).to eq(nil)
end
Expand All @@ -59,7 +64,7 @@
expect(subject.secondary_caregiver_two.icn).to eq('ABCD1234')
end

it 'is can be set to nil' do
it 'can be set to nil' do
subject.secondary_caregiver_two = nil
expect(subject.secondary_caregiver_two).to eq(nil)
end
Expand All @@ -72,9 +77,8 @@
expect(subject.veteran.icn).to eq(nil)
expect(subject.veteran.is_veteran).to eq(nil)

# Should default to empty described_class::Caregiver
expect(subject.primary_caregiver).to be_instance_of(CARMA::Models::Caregiver)
expect(subject.primary_caregiver.icn).to eq(nil)
# Should default to nil
expect(subject.primary_caregiver).to eq(nil)

# Should default to nil
expect(subject.secondary_caregiver_one).to eq(nil)
Expand Down Expand Up @@ -132,28 +136,66 @@
end

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, claim_guid: 'my-uuid'
context 'with a minimal required data set' do
context 'only containing primaryCaregiver' do
it 'can receive :to_request_payload' do
subject = described_class.new(
claim_id: 123,
claim_guid: 'my-uuid',
primary_caregiver: {
icn: 'PC1234'
}
)

expect(subject.to_request_payload).to eq(
{
'claimId' => 123,
'claimGuid' => 'my-uuid',
'veteran' => {
'icn' => nil,
'isVeteran' => nil
},
'primaryCaregiver' => {
'icn' => 'PC1234'
},
'secondaryCaregiverOne' => nil,
'secondaryCaregiverTwo' => nil
}
)
end
end

expect(subject.to_request_payload).to eq(
{
'claimId' => 123,
'claimGuid' => 'my-uuid',
'veteran' => {
'icn' => nil,
'isVeteran' => nil
},
'primaryCaregiver' => {
'icn' => nil
},
'secondaryCaregiverOne' => nil,
'secondaryCaregiverTwo' => nil
}
)
context 'only containing secondaryCaregiverOne' do
it 'can receive :to_request_payload' do
subject = described_class.new(
claim_id: 123,
claim_guid: 'my-uuid',
secondary_caregiver_one: {
icn: 'SCO1234'
}
)

expect(subject.to_request_payload).to eq(
{
'claimId' => 123,
'claimGuid' => 'my-uuid',
'veteran' => {
'icn' => nil,
'isVeteran' => nil
},
'primaryCaregiver' => nil,
'secondaryCaregiverOne' => {
'icn' => 'SCO1234'
},
'secondaryCaregiverTwo' => nil
}
)
end
end
end

it 'with a maximum data set' do
context 'with a maximum data set' do
it 'can receive :to_request_payload' do
subject = described_class.new(
claim_id: 123,
claim_guid: 'my-uuid',
Expand Down
3 changes: 1 addition & 2 deletions spec/lib/carma/models/submission_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@
expect(subject.metadata.veteran.icn).to eq(nil)
expect(subject.metadata.veteran.is_veteran).to eq(nil)
# metadata.primary_caregiver
expect(subject.metadata.primary_caregiver).to be_instance_of(CARMA::Models::Caregiver)
expect(subject.metadata.primary_caregiver.icn).to eq(nil)
expect(subject.metadata.primary_caregiver).to eq(nil)
# metadata.secondary_caregiver_one
expect(subject.metadata.secondary_caregiver_one).to eq(nil)
# metadata.secondary_caregiver_two
Expand Down
12 changes: 9 additions & 3 deletions spec/models/saved_claim/caregivers_assistance_claim_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,24 @@

claim_3 = described_class.new(form: {
"veteran": {},
"primaryCaregiver": {},
"secondaryCaregiverOne": {}
}.to_json)
expect(claim_3.form_subjects).to eq(%w[veteran primaryCaregiver secondaryCaregiverOne])
expect(claim_3.form_subjects).to eq(%w[veteran secondaryCaregiverOne])

claim_4 = described_class.new(form: {
"veteran": {},
"primaryCaregiver": {},
"secondaryCaregiverOne": {}
}.to_json)
expect(claim_4.form_subjects).to eq(%w[veteran primaryCaregiver secondaryCaregiverOne])

claim_5 = described_class.new(form: {
"veteran": {},
"primaryCaregiver": {},
"secondaryCaregiverOne": {},
"secondaryCaregiverTwo": {}
}.to_json)
expect(claim_4.form_subjects).to eq(%w[veteran primaryCaregiver secondaryCaregiverOne secondaryCaregiverTwo])
expect(claim_5.form_subjects).to eq(%w[veteran primaryCaregiver secondaryCaregiverOne secondaryCaregiverTwo])
end

context 'when no subjects are present' do
Expand Down

0 comments on commit 9e2ce67

Please sign in to comment.