Skip to content

Commit

Permalink
Api 33824 claim date added to generate pdf (#15332)
Browse files Browse the repository at this point in the history
* Changes to be committed:
	modified:   modules/claims_api/app/controllers/claims_api/v2/veterans/disability_compensation_controller.rb
	modified:   modules/claims_api/app/swagger/claims_api/v2/dev/swagger.json
	modified:   modules/claims_api/config/schemas/v2/526.json
	new file:   modules/claims_api/config/schemas/v2/generate_pdf_526.json
	new file:   modules/claims_api/config/schemas/v2/request_bodies/disability_compensation/generate_pdf_example.json
	modified:   modules/claims_api/lib/claims_api/v2/disability_compensation_pdf_mapper.rb
	new file:   modules/claims_api/spec/fixtures/v2/veterans/disability_compensation/form_526_generate_pdf_json_api.json
	modified:   modules/claims_api/spec/requests/v2/veterans/disability_compensation_request_spec.rb
	modified:   modules/claims_api/spec/requests/v2/veterans/rswag_disability_compensation_request_spec.rb
	modified:   modules/claims_api/spec/support/swagger_shared_components/v2.rb

* API-33824 claim date added to generate pdf

* Allows generate_pdf endpoint to accept a form witha claimDate value
	* Creates generate_pdf_526.json as schema for endpoint
	* Creates generate_pdf_example.json as example request for endpoint
	* Creates form_526_generate_pdf_json_api.json as request example used in tests for endpoint
* Reverts before actions changes from previous generatePDF update since this now uses its own JSON validation
* Recompiles dev and prod swagger docs
	* Removes character limit, previously added from Docker container OAS valdations, on state objects in 526 and generate_pdf_526 json files since it is capped at 2, character limit is not needed
 Changes to be committed:
	modified:   modules/claims_api/app/swagger/claims_api/v2/dev/swagger.json
	modified:   modules/claims_api/app/swagger/claims_api/v2/production/swagger.json

* Fxes missed merge resolution

* API-33824 claim date added to generate pdf

* Reverts changes made previously to 526.json, which will not be used as the schema for the generate PDF endpoint now
* Adds JSON files for the generate PDF endpoint, validations should be inline with firefly updates OAS
	* schema - generate_pdf_526.json
	* example file for docs - generate_pdf_example.json
	* example file for tests - form_526_generate_pdf_json_api.json
* Generates swagger docs to reflect updates/changes
* Adds one more test in RSpec to handle difference in phone numbers that is currently only for generate PDF
Changes to be committed:
	modified:   modules/claims_api/app/swagger/claims_api/v2/dev/swagger.json
	modified:   modules/claims_api/app/swagger/claims_api/v2/production/swagger.json
	modified:   modules/claims_api/config/schemas/v2/526.json
	modified:   modules/claims_api/config/schemas/v2/generate_pdf_526.json
	modified:   modules/claims_api/config/schemas/v2/request_bodies/disability_compensation/generate_pdf_example.json
	modified:   modules/claims_api/spec/fixtures/v2/veterans/disability_compensation/form_526_generate_pdf_json_api.json
	modified:   modules/claims_api/spec/requests/v2/veterans/disability_compensation_request_spec.rb

* Updates swagger docs to show money with no decimal for generatePDF examples

* Reverts phone number update, going to ignore Firefly OAS for this value, also fixes a 526.json phone number that only had 8 characters in example but requires 10
  • Loading branch information
rockwellwindsor-va authored Feb 1, 2024
1 parent ddf5362 commit 49722c5
Show file tree
Hide file tree
Showing 11 changed files with 1,710 additions and 378 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ class DisabilityCompensationController < ClaimsApi::V2::Veterans::Base
FORM_NUMBER = '526'

skip_before_action :validate_json_format, only: [:attachments]
# Custom validations for 526 submission, we must check this first
before_action :custom_validation, :file_number_check, only: %i[submit validate]
before_action :validate_json_schema, only: %i[submit validate generate_pdf]
# If all we have are custom validation errors we raise them here, after validating JSON above
before_action :check_for_custom_validation_errors, only: %i[submit validate]
before_action :shared_validation, :file_number_check, only: %i[submit validate]

def submit
auto_claim = ClaimsApi::AutoEstablishedClaim.create(
Expand Down Expand Up @@ -81,6 +77,8 @@ def attachments

# Returns filled out 526EZ form as PDF
def generate_pdf # rubocop:disable Metrics/MethodLength
validate_json_schema('GENERATE_PDF_526')

mapped_claim = generate_pdf_mapper_service(
form_attributes,
get_pdf_data_wrapper,
Expand Down Expand Up @@ -149,11 +147,12 @@ def flashes
veteran_flashes
end

def custom_validation
def shared_validation
# Custom validations for 526 submission, we must check this first
@disability_compensation_validation_errors = validate_form_526_submission_values!(target_veteran)
end

def check_for_custom_validation_errors
# JSON validations for 526 submission, will combine with previously captured errors and raise
validate_json_schema
# if we get here there were only validations file errors
if @disability_compensation_validation_errors
raise ::ClaimsApi::Common::Exceptions::Lighthouse::JsonDisabilityCompensationValidationError,
@disability_compensation_validation_errors
Expand Down
297 changes: 109 additions & 188 deletions modules/claims_api/app/swagger/claims_api/v2/dev/swagger.json

Large diffs are not rendered by default.

181 changes: 53 additions & 128 deletions modules/claims_api/app/swagger/claims_api/v2/production/swagger.json

Large diffs are not rendered by default.

67 changes: 21 additions & 46 deletions modules/claims_api/config/schemas/v2/526.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"required": [
"mailingAddress",
"currentVaEmployee"
],
],
"properties": {
"serviceNumber": {
"type": ["null", "string"],
Expand All @@ -38,7 +38,7 @@
"description": "Veteran's phone number.",
"type": ["string", "null"],
"pattern": "^\\d{10}?$",
"example": "5555555",
"example": "5555555555",
"minLength": 10,
"maxLength": 10,
"nullable": true
Expand Down Expand Up @@ -89,21 +89,18 @@
"description": "City for the Veteran's current mailing address.",
"type": "string",
"pattern": "^([-a-zA-Z0-9'.#]([-a-zA-Z0-9'.# ])?)+$",
"example": "Portland",
"maxLength": 1000
"example": "Portland"
},
"state": {
"description": "State for the Veteran's current mailing address.",
"type": "string",
"pattern": "^[a-z,A-Z]{2}$",
"example": "OR",
"maxLength": 1000
"example": "OR"
},
"country": {
"description": "Country for the Veteran's current mailing address. Must match the values returned by the /countries endpoint on the [Benefits Reference Data API](https://developer.va.gov/explore/benefits/docs/benefits_reference_data?version=current).",
"type": "string",
"example": "USA",
"maxLength": 1000
"example": "USA"
},
"zipFirstFive": {
"description": "Zip code (First 5 digits) for the Veteran's current mailing address.",
Expand Down Expand Up @@ -185,21 +182,18 @@
"description": "City for the Veteran's new address.",
"type": "string",
"pattern": "^$|^([-a-zA-Z0-9'.#]([-a-zA-Z0-9'.# ])?)+$",
"example": "Portland",
"maxLength": 1000
"example": "Portland"
},
"state": {
"description": "State for the Veteran's new address.",
"type": "string",
"pattern": "^$|^[a-z,A-Z]{2}$",
"example": "OR",
"maxLength": 1000
"example": "OR"
},
"country": {
"description": "Country for the Veteran's new address. Value must match the values returned by the /countries endpoint on the [Benefits Reference Data API](https://developer.va.gov/explore/benefits/docs/benefits_reference_data?version=current).",
"type": "string",
"example": "USA",
"maxLength": 1000
"example": "USA"
},
"zipFirstFive": {
"description": "Zip code (First 5 digits) for the Veteran's new address.",
Expand Down Expand Up @@ -320,8 +314,7 @@
"description": "International phone of point of contact.",
"type": ["string", "null"],
"example": "+44 20 1234 5678",
"nullable": true,
"maxLength": 1000
"nullable": true
}
}
}
Expand Down Expand Up @@ -380,8 +373,7 @@
"type": ["string", "null"],
"nullable": true,
"pattern": "^([-a-zA-Z0-9'.,&#]([-a-zA-Z0-9'.,&# ])?)+$",
"description": "Other location(s) where Veteran served.",
"maxLength": 5000
"description": "Other location(s) where Veteran served."
},
"serviceDates": {
"description": "Date range for exposure in herbicide hazard location.",
Expand Down Expand Up @@ -416,7 +408,6 @@
"type": ["array", "null"],
"nullable": true,
"uniqueItems": true,
"maxItems": 5000,
"items": {
"type": "string",
"additionalProperties": false,
Expand All @@ -436,8 +427,7 @@
"type": ["string", "null"],
"nullable": true,
"pattern": "^([-a-zA-Z0-9'.,&#]([-a-zA-Z0-9'.,&# ])?)+$",
"description": "Exposure to asbestos.",
"maxLength": 5000
"description": "Exposure to asbestos."
},
"exposureDates": {
"type": ["object", "null"],
Expand Down Expand Up @@ -465,7 +455,6 @@
"multipleExposures": {
"type": ["array", "null"],
"nullable": true,
"maxItems": 5000,
"minItems": 1,
"uniqueItems": true,
"items": {
Expand Down Expand Up @@ -513,7 +502,6 @@
"disabilities": {
"description": "Any current disabilities or symptoms the Veteran is claiming are related to their military service and/or are service-connected.",
"type": "array",
"maxItems": 5000,
"minItems": 1,
"items": {
"type": "object",
Expand All @@ -531,15 +519,13 @@
"type": ["string", "null"],
"description": "What caused the disability?",
"nullable": true,
"examples": ["Agent Orange", "radiation", "burn pits"],
"maxLength": 1000
"examples": ["Agent Orange", "radiation", "burn pits"]
},
"serviceRelevance": {
"description": "Explanation of how the disability(ies) relates to the in-service event/exposure/injury. If the disabilityActionType is 'NEW', the serviceRelevance is required.",
"type": ["string", "null"],
"nullable": true,
"example": "Heavy equipment operator in service.",
"maxLength": 1000
"example": "Heavy equipment operator in service."
},
"approximateDate": {
"description": "Approximate date disability began. Date must be in the past. \n Format can be either YYYY-MM-DD or YYYY-MM or YYYY",
Expand Down Expand Up @@ -597,15 +583,13 @@
"type": ["string", "null"],
"description": "What caused the disability?",
"nullable": true,
"examples": ["Agent Orange", "radiation", "burn pits"],
"maxLength": 1000
"examples": ["Agent Orange", "radiation", "burn pits"]
},
"serviceRelevance": {
"description": "Explanation of how the disability(ies) relates to the in-service event/exposure/injury.",
"type": ["string", "null"],
"nullable": true,
"example": "Heavy equipment operator in service.",
"maxLength": 1000
"example": "Heavy equipment operator in service."
},
"disabilityActionType": {
"description": "The status of the secondary disability.",
Expand Down Expand Up @@ -637,7 +621,6 @@
"type": ["array", "null"],
"nullable": true,
"uniqueItems": true,
"maxItems": 5000,
"items": {
"type": "object",
"additionalProperties": false,
Expand Down Expand Up @@ -713,7 +696,6 @@
"servicePeriods": {
"description": "Identifies the Service dates and Branch the Veteran served in.",
"type": "array",
"maxItems": 5000,
"minItems": 1,
"uniqueItems": true,
"items": {
Expand All @@ -723,8 +705,7 @@
"serviceBranch": {
"description": "Branch of service during period. The /service-branches endpoint on the [Benefits Reference Data API](https://developer.va.gov/explore/benefits/docs/benefits_reference_data?version=current) may be used to retrieve list of possible service branches.",
"type": "string",
"example": "Air Force",
"maxLength": 1000
"example": "Air Force"
},
"serviceComponent": {
"type": "string",
Expand Down Expand Up @@ -792,13 +773,11 @@
},
"unitName": {
"type": ["string", "null"],
"maxLength": 1000,
"nullable": true,
"pattern": "^$|([a-zA-Z0-9\\-'.,# ][a-zA-Z0-9\\-'.,# ]?)*$"
},
"unitAddress": {
"type": ["string", "null"],
"maxLength": 1000,
"pattern": "^$|^([-a-zA-Z0-9'.,&#]([-a-zA-Z0-9'.,&# ])?)+$",
"nullable": true
},
Expand Down Expand Up @@ -855,7 +834,6 @@
"type": ["array", "null"],
"nullable": true,
"uniqueItems": true,
"maxItems": 5000,
"items": {
"additionalProperties": false,
"type": "object",
Expand Down Expand Up @@ -901,8 +879,7 @@
"description": "Explains why future pay will be received.",
"type": ["string", "null"],
"example": "Will be retiring soon.",
"nullable": true,
"maxLength": 1000
"nullable": true
},
"militaryRetiredPay": {
"type": ["object", "null"],
Expand All @@ -913,7 +890,6 @@
"description": "Branch of service. The /service-branches endpoint on the [Benefits Reference Data API](https://developer.va.gov/explore/benefits/docs/benefits_reference_data?version=current) may be used to retrieve list of possible service branches.",
"type": ["string", "null"],
"nullable": true,
"maxLength": 1000,
"example": "Air Force"
},
"monthlyAmount": {
Expand All @@ -939,8 +915,8 @@
},
"favorMilitaryRetiredPay": {
"description": "Is the Veteran waiving VA benefits to retain military retired pay? See item 26 on form 21-526EZ for more details.",
"type": ["boolean", "null"],
"nullable": true,
"type": ["boolean", "null"],
"nullable": true,
"example": true,
"default": false
},
Expand All @@ -965,7 +941,6 @@
"branchOfService": {
"description": "Branch of service. The /service-branches endpoint on the [Benefits Reference Data API](https://developer.va.gov/explore/benefits/docs/benefits_reference_data?version=current) may be used to retrieve list of possible service branches.",
"type": ["string", "null"],
"maxLength": 1000,
"nullable": true,
"example": "Air Force"
},
Expand All @@ -981,8 +956,8 @@
},
"favorTrainingPay": {
"description": "Is the Veteran waiving VA benefits to retain training pay? See item 28 on form 21-526EZ for more details. ",
"type": ["boolean", "null"],
"nullable": true,
"type": ["boolean", "null"],
"nullable": true,
"example": true,
"default": false
}
Expand Down
Loading

0 comments on commit 49722c5

Please sign in to comment.