Skip to content

Commit

Permalink
Api 24833 526 v2 section 6 service info validation part 1 v2 (#12789)
Browse files Browse the repository at this point in the history
* Service Information validation - Part 1
API-24833 - Part 1 AC points 1 - 12
* Adds RSpec tests for validating service information elements for AC points 1 - 12
* Adds methods in validation file for validating service information elements
* Updates 526 schema, and related JSON files, for the updated type for confinements
Changes to be committed:
	modified:   modules/claims_api/app/controllers/concerns/claims_api/v2/disability_compensation_validation.rb
	modified:   modules/claims_api/app/swagger/claims_api/v2/dev/swagger.json
	modified:   modules/claims_api/config/schemas/v2/526.json
	modified:   modules/claims_api/config/schemas/v2/request_bodies/disability_compensation/example.json
	modified:   modules/claims_api/config/schemas/v2/request_bodies/disability_compensation/request.json
	modified:   modules/claims_api/spec/fixtures/v2/veterans/disability_compensation/form_526_json_api.json
	modified:   modules/claims_api/spec/requests/v2/veterans/disability_compensation_request_spec.rb
	modified:   spec/support/schemas/claims_api/v2/forms/disability/submission.json

* Service Information validation - Part 1
API-24833 - Part 1 AC points 1 - 12
Alters the AC points covered, now part 1 covers 1 - 9 and adjusts RSpec and validation file in line with that.
 Changes to be committed:
	modified:   modules/claims_api/app/controllers/concerns/claims_api/v2/disability_compensation_validation.rb
	modified:   modules/claims_api/spec/requests/v2/veterans/disability_compensation_request_spec.rb

* Removes RSpec tests that moved over to part 2

* Fixes my misunderstood structure for confinements

* Removes a log out and gets the brakeman update
  • Loading branch information
rockwellwindsor-va authored May 30, 2023
1 parent 1b9cf59 commit 4c73db4
Show file tree
Hide file tree
Showing 8 changed files with 476 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ def validate_form_526_submission_values!
validate_form_526_veteran_homelessness!
# ensure treament centers information is valid
validate_form_526_treatments!
# ensure service information is valid
validate_form_526_service_information!
end

def validate_form_526_submission_claim_date!
Expand Down Expand Up @@ -165,6 +167,51 @@ def collect_primary_secondary_disability_names(disabilities)
end
names
end

def validate_form_526_service_information!
service_information = form_attributes['serviceInformation']

if service_information.blank?
raise ::Common::Exceptions::UnprocessableEntity.new(
detail: 'Service information is required'
)
end

validate_service_periods!
validate_confinements!
end

def validate_service_periods!
service_information = form_attributes['serviceInformation']

service_information['servicePeriods'].each do |sp|
if Date.parse(sp['activeDutyBeginDate']) > Date.parse(sp['activeDutyEndDate'])
raise ::Common::Exceptions::UnprocessableEntity.new(
detail: 'Active Duty End Date needs to be after Active Duty Start Date'
)
end

if Date.parse(sp['activeDutyEndDate']) > Time.zone.now && sp['separationLocationCode'].empty?
raise ::Common::Exceptions::UnprocessableEntity.new(
detail: 'If Active Duty End Date is in the future a Separation Location Code is required.'
)
end
end
end

def validate_confinements!
service_information = form_attributes['serviceInformation']

service_information['confinements'].each do |confinement|
approximate_begin_date = confinement['approximateBeginDate']
approximate_end_date = confinement['approximateEndDate']
if Date.parse(approximate_begin_date) > Date.parse(approximate_end_date)
raise ::Common::Exceptions::UnprocessableEntity.new(
detail: 'Approximate end date must be after approximate begin date.'
)
end
end
end
end
end
end
135 changes: 91 additions & 44 deletions modules/claims_api/app/swagger/claims_api/v2/dev/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2109,15 +2109,20 @@
"example": "2018-03-02"
},
"treatedDisabilityNames": {
"description": "Names of disability treated.",
"description": "Name(s) of Disabilities treated in this time frame.",
"type": "array",
"minItems": 1,
"maxItems": 101,
"uniqueItems": true,
"items": {
"description": "Name of Disabilities Veteran was Treated for.",
"type": "string",
"example": "PTSD (post traumatic stress disorder)"
"additionalProperties": false,
"properties": {
"type": "string",
"example": [
"PTSD (post traumatic stress disorder)",
"Trauma"
]
}
}
},
"center": {
Expand Down Expand Up @@ -2247,30 +2252,64 @@
}
},
"confinements": {
"type": "object",
"type": "array",
"description": "",
"properties": {
"approximateBeginDate": {
"pattern": "^(\\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$",
"type": "string",
"example": "2018-06-04"
},
"approximateEndDate": {
"pattern": "^(\\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$",
"type": "string",
"example": "2018-06-04"
"uniqueItems": true,
"items": {
"type": "object",
"additionalProperties": false,
"properties": {
"confinement": {
"type": "object",
"additionalProperties": false,
"required": [
"approximateBeginDate",
"approximateEndDate"
],
"properties": {
"approximateBeginDate": {
"pattern": "^(\\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$",
"type": "string",
"example": "2018-06-04"
},
"approximateEndDate": {
"pattern": "^(\\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$",
"type": "string",
"example": "2018-08-04"
}
}
}
}
}
},
"reservesNationalGuardService": {
"type": "object",
"additionalProperties": false,
"required": [
"obligationTermOfServiceFromDate",
"obligationTermOfServiceToDate",
"obligationTermsOfService",
"unitName"
],
"properties": {
"obligationTermsOfService": {
"type": "object",
"additionalProperties": false,
"required": [
"startDate",
"endDate"
],
"properties": {
"startDate": {
"pattern": "^(\\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$",
"type": "string",
"example": "2018-06-04"
},
"endDate": {
"pattern": "^(\\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$",
"type": "string",
"example": "2018-06-04"
}
}
},
"component": {
"type": "array",
"description": "",
Expand Down Expand Up @@ -2301,14 +2340,6 @@
}
}
},
"obligationTermOfServiceFromDate": {
"type": "string",
"pattern": "^(\\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$"
},
"obligationTermOfServiceToDate": {
"type": "string",
"pattern": "^(\\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$"
},
"unitName": {
"type": "string",
"pattern": "([a-zA-Z0-9\\-'.,# ][a-zA-Z0-9\\-'.,# ]?)*$"
Expand Down Expand Up @@ -3390,18 +3421,27 @@
}
},
"confinements": {
"type": "object",
"type": "array",
"description": "",
"properties": {
"approximateBeginDate": {
"pattern": "^(\\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$",
"type": "string",
"example": "2018-06-04"
},
"approximateEndDate": {
"pattern": "^(\\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$",
"type": "string",
"example": "2018-06-04"
"uniqueItems": true,
"items": {
"additionalProperties": false,
"type": "object",
"required": [
"approximateBeginDate",
"approximateEndDate"
],
"properties": {
"approximateBeginDate": {
"pattern": "^(\\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$",
"type": "string",
"example": "2018-06-04"
},
"approximateEndDate": {
"pattern": "^(\\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$",
"type": "string",
"example": "2018-08-04"
}
}
}
},
Expand Down Expand Up @@ -3816,7 +3856,7 @@
"exposureOrEventOrInjury": ""
}
],
"isRelatedToToxicExposure": true,
"isRelatedToToxicExposure": false,
"exposureOrEventOrInjury": ""
}
],
Expand Down Expand Up @@ -3855,10 +3895,16 @@
"separationLocationCode": "V01D"
}
],
"confinements": {
"approximateBeginDate": "2016-11-06",
"approximateEndDate": "2016-11-09"
},
"confinements": [
{
"approximateBeginDate": "2016-11-06",
"approximateEndDate": "2016-11-09"
},
{
"approximateBeginDate": "2019-11-06",
"approximateEndDate": "2019-11-09"
}
],
"reservesNationalGuardService": {
"obligationTermsOfService": {
"startDate": "2016-11-24",
Expand All @@ -3877,7 +3923,8 @@
"receivingInactiveDutyTrainingPay": true
},
"alternateNames": [
"John Jacob Jingleheimer-Schmidt"
"John Jacob Jingleheimer-Schmidt",
"Johnathon"
],
"servedInActiveCombatSince911": false
},
Expand Down Expand Up @@ -4547,8 +4594,8 @@
"id": "1",
"type": "intent_to_file",
"attributes": {
"creationDate": "2023-05-22",
"expirationDate": "2024-05-22",
"creationDate": "2023-05-24",
"expirationDate": "2024-05-24",
"type": "compensation",
"status": "active"
}
Expand Down
33 changes: 21 additions & 12 deletions modules/claims_api/config/schemas/v2/526.json
Original file line number Diff line number Diff line change
Expand Up @@ -784,21 +784,30 @@
}
},
"confinements": {
"type": "object",
"type": "array",
"description": "",
"properties": {
"approximateBeginDate": {
"pattern": "^(\\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$",
"type": "string",
"example": "2018-06-04"
},
"approximateEndDate": {
"pattern": "^(\\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$",
"type": "string",
"example": "2018-06-04"
"uniqueItems": true,
"items": {
"additionalProperties": false,
"type": "object",
"required": [
"approximateBeginDate",
"approximateEndDate"
],
"properties": {
"approximateBeginDate": {
"pattern": "^(\\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$",
"type": "string",
"example": "2018-06-04"
},
"approximateEndDate": {
"pattern": "^(\\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$",
"type": "string",
"example": "2018-08-04"
}
}
}
},
},
"reservesNationalGuardService": {
"type": "object",
"additionalProperties": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,16 @@
"separationLocationCode": "V01D"
}
],
"confinements": {
"confinements": [
{
"approximateBeginDate": "2016-11-06",
"approximateEndDate": "2016-11-09"
},
},
{
"approximateBeginDate": "2019-11-06",
"approximateEndDate": "2019-11-09"
}
],
"reservesNationalGuardService": {
"obligationTermsOfService": {
"startDate":"2016-11-24",
Expand All @@ -163,7 +169,8 @@
"receivingInactiveDutyTrainingPay": true
},
"alternateNames": [
"John Jacob Jingleheimer-Schmidt"
"John Jacob Jingleheimer-Schmidt",
"Johnathon"
],
"servedInActiveCombatSince911": false
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -785,18 +785,27 @@
}
},
"confinements": {
"type": "object",
"type": "array",
"description": "",
"properties": {
"approximateBeginDate": {
"pattern": "^(\\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$",
"type": "string",
"example": "2018-06-04"
},
"approximateEndDate": {
"pattern": "^(\\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$",
"type": "string",
"example": "2018-06-04"
"uniqueItems": true,
"items": {
"additionalProperties": false,
"type": "object",
"required": [
"approximateBeginDate",
"approximateEndDate"
],
"properties": {
"approximateBeginDate": {
"pattern": "^(\\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$",
"type": "string",
"example": "2018-06-04"
},
"approximateEndDate": {
"pattern": "^(\\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$",
"type": "string",
"example": "2018-08-04"
}
}
}
},
Expand Down
Loading

0 comments on commit 4c73db4

Please sign in to comment.