Skip to content

Commit

Permalink
Api 24833 526 v2 section 6 service info validation part 2 v2 (#12790)
Browse files Browse the repository at this point in the history
* Service Information validation - Part 1
API-24833 - Part 1 AC points 9 - 21
* Adds RSpec tests for validating service information elements for AC points 9 - 21
* Adds methods in validation file for validating service information elements
* Updates 526 schema, and related JSON files, with unitPhone regex patterns and updated example with alternate name values
 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 2
API-24833 - Part 1 AC points 10 - 21
Alters the AC points covered, now part 2 covers 10 - 21 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

* Making sure to update swagger dev file with any merges

* Merges master and fixes tests

* Removes ensured newline at save that was added into 526_json_api file
  • Loading branch information
rockwellwindsor-va authored Jun 1, 2023
1 parent b49c503 commit 589af8f
Show file tree
Hide file tree
Showing 7 changed files with 474 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,17 @@ def validate_form_526_service_information!
detail: 'Service information is required'
)
end
if activation_date_not_afterduty_begin_date?
raise ::Common::Exceptions::UnprocessableEntity.new(
detail: 'The title 10 activation date must be after the earliest service period active duty begin date.'
)
end

validate_service_periods!
validate_confinements!
validate_anticipated_seperation_date!
validate_alternate_names!
validate_reserves_tos_dates!
end

def validate_service_periods!
Expand Down Expand Up @@ -424,6 +432,60 @@ def validate_confinements!
end
end
end

def validate_anticipated_seperation_date!
service_information = form_attributes['serviceInformation']

anticipated_seperation_date =
service_information['reservesNationalGuardService']['title10Activation']['anticipatedSeparationDate']

if Date.parse(anticipated_seperation_date) < Time.zone.now
raise ::Common::Exceptions::UnprocessableEntity.new(
detail: 'The anticipated separation date must be a date in the future.'
)
end
end

def validate_alternate_names!
alternate_names = form_attributes['serviceInformation']['alternateNames']
return if alternate_names.blank?

# clean them up to compare
alternate_names = alternate_names.map(&:strip).map(&:downcase)

# returns nil unless there are duplicate names
duplicate_names_check = alternate_names.detect { |e| alternate_names.rindex(e) != alternate_names.index(e) }

unless duplicate_names_check.nil?
raise ::Common::Exceptions::UnprocessableEntity.new(
detail: 'Names entered as an alternate name must be unique.'
)
end
end

def activation_date_not_afterduty_begin_date?
service_information = form_attributes['serviceInformation']
service_periods = service_information['servicePeriods']
activation_date =
service_information['reservesNationalGuardService']['title10Activation']['title10ActivationDate']

earliest_active_duty_begin_date = service_periods.max_by { |a| Date.parse(a['activeDutyBeginDate']) }

# return true if activationDate is an earlier date
Date.parse(activation_date) < Date.parse(earliest_active_duty_begin_date['activeDutyBeginDate'])
end

def validate_reserves_tos_dates!
service_information = form_attributes['serviceInformation']

tos_start_date = service_information['reservesNationalGuardService']['obligationTermsOfService']['startDate']
tos_end_date = service_information['reservesNationalGuardService']['obligationTermsOfService']['endDate']
if Date.parse(tos_start_date) > Date.parse(tos_end_date)
raise ::Common::Exceptions::UnprocessableEntity.new(
detail: 'Terms of service Start date must be before the terms of service end date.'
)
end
end
end
end
end
132 changes: 68 additions & 64 deletions modules/claims_api/app/swagger/claims_api/v2/dev/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2256,28 +2256,22 @@
"description": "",
"uniqueItems": true,
"items": {
"type": "object",
"additionalProperties": false,
"type": "object",
"required": [
"approximateBeginDate",
"approximateEndDate"
],
"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"
}
}
"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 @@ -2354,11 +2348,15 @@
"properties": {
"areaCode": {
"type": "string",
"maxLength": 3
"maxLength": 3,
"pattern": "^\\d{3}$",
"example": "688"
},
"phoneNumber": {
"type": "string",
"maxLength": 7
"maxLength": 7,
"pattern": "^\\d{7}$",
"example": "8675309"
}
}
},
Expand Down Expand Up @@ -3286,44 +3284,41 @@
"items": {
"type": "string",
"additionalProperties": false,
"properties": {
"type": "string",
"example": [
"PTSD (post traumatic stress disorder)",
"Trauma"
]
}
"examples": [
"PTSD (post traumatic stress disorder)",
"Trauma"
]
}
},
"center": {
"description": "VA Medical Center(s) and Department of Defense Military Treatment Facilities where the Veteran received treatment after discharge for any claimed disabilities.",
"type": "object",
"additionalProperties": false,
"required": [
"name",
"state"
],
"properties": {
"name": {
"description": "Name of facility Veteran was treated in. The /treatment-centers endpoint on the [Benefits Reference Data API](https://developer.va.gov/explore/benefits/docs/benefits_reference_data?version=current) may be used to retrieve possible treatment center names.",
"type": "string",
"pattern": "(?!(?: )$)([a-zA-Z0-9\"\\/&\\(\\)\\-'.,# ]([a-zA-Z0-9(\\)\\-'.,# ])?)+$",
"example": "Private Facility 2",
"minLength": 1,
"maxLength": 100
},
"city": {
"description": "City of treatment facility.",
"type": "string",
"pattern": "^([-a-zA-Z0-9'.#]([-a-zA-Z0-9'.# ])?)+$",
"example": "Portland"
},
"state": {
"description": "State of treatment facility.",
"type": "string",
"pattern": "^[a-z,A-Z]{2}$",
"example": "OR"
}
}
},
"center": {
"description": "VA Medical Center(s) and Department of Defense Military Treatment Facilities where the Veteran received treatment after discharge for any claimed disabilities.",
"type": "object",
"additionalProperties": false,
"required": [
"name",
"state"
],
"properties": {
"name": {
"description": "Name of facility Veteran was treated in. The /treatment-centers endpoint on the [Benefits Reference Data API](https://developer.va.gov/explore/benefits/docs/benefits_reference_data?version=current) may be used to retrieve possible treatment center names.",
"type": "string",
"pattern": "(?!(?: )$)([a-zA-Z0-9\"\\/&\\(\\)\\-'.,# ]([a-zA-Z0-9(\\)\\-'.,# ])?)+$",
"example": "Private Facility 2",
"minLength": 1,
"maxLength": 100
},
"city": {
"description": "City of treatment facility.",
"type": "string",
"pattern": "^([-a-zA-Z0-9'.#]([-a-zA-Z0-9'.# ])?)+$",
"example": "Portland"
},
"state": {
"description": "State of treatment facility.",
"type": "string",
"pattern": "^[a-z,A-Z]{2}$",
"example": "OR"
}
}
}
Expand Down Expand Up @@ -3507,6 +3502,10 @@
"type": "string",
"pattern": "([a-zA-Z0-9\\-'.,# ][a-zA-Z0-9\\-'.,# ]?)*$"
},
"unitAddress": {
"type": "string",
"pattern": "^([-a-zA-Z0-9'.,&#]([-a-zA-Z0-9'.,&# ])?)+$"
},
"unitPhone": {
"type": "object",
"additionalProperties": false,
Expand All @@ -3517,11 +3516,15 @@
"properties": {
"areaCode": {
"type": "string",
"maxLength": 3
"maxLength": 3,
"pattern": "^\\d{3}?$",
"example": "688"
},
"phoneNumber": {
"type": "string",
"maxLength": 7
"maxLength": 7,
"pattern": "^\\d{7}$",
"example": "8675309"
}
}
},
Expand Down Expand Up @@ -3911,14 +3914,15 @@
"endDate": "2017-11-17"
},
"unitName": "DonkeyPants",
"unitAddress": "1243 pine court",
"component": "National Guard",
"title10Activation": {
"anticipatedSeparationDate": "2017-10-03",
"title10ActivationDate": "2018-02-11"
},
"unitPhone": {
"areaCode": "123",
"phoneNumber": "456-7890"
"phoneNumber": "4567890"
},
"receivingInactiveDutyTrainingPay": true
},
Expand Down Expand Up @@ -4592,8 +4596,8 @@
"id": "1",
"type": "intent_to_file",
"attributes": {
"creationDate": "2023-05-26",
"expirationDate": "2024-05-26",
"creationDate": "2023-05-31",
"expirationDate": "2024-05-31",
"type": "compensation",
"status": "active"
}
Expand Down
10 changes: 7 additions & 3 deletions modules/claims_api/config/schemas/v2/526.json
Original file line number Diff line number Diff line change
Expand Up @@ -873,11 +873,15 @@
"properties": {
"areaCode": {
"type": "string",
"maxLength": 3
"pattern": "^\\d{3}?$",
"maxLength": 3,
"example": "688"
},
"phoneNumber": {
"type": "string",
"maxLength": 7
"pattern": "^\\d{7}$",
"maxLength": 7,
"example": "8675309"
}
}
},
Expand Down Expand Up @@ -1085,4 +1089,4 @@
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
},
"unitPhone": {
"areaCode": "123",
"phoneNumber": "456-7890"
"phoneNumber": "4567890"
},
"receivingInactiveDutyTrainingPay": true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -805,8 +805,7 @@
}
}
}
}
},
},
"reservesNationalGuardService": {
"type": "object",
"additionalProperties": false,
Expand Down Expand Up @@ -873,11 +872,15 @@
"properties": {
"areaCode": {
"type": "string",
"maxLength": 3
"maxLength": 3,
"pattern": "^\\d{3}?$",
"example": "688"
},
"phoneNumber": {
"type": "string",
"maxLength": 7
"maxLength": 7,
"pattern": "^\\d{7}$",
"example": "8675309"
}
}
},
Expand All @@ -902,6 +905,7 @@
"description": "Did Veteran serve in a combat zone since 9-11-2001?",
"example": true
}
}
},
"servicePay": {
"type": "object",
Expand Down
Loading

0 comments on commit 589af8f

Please sign in to comment.