diff --git a/dist/21-526EZ-ALLCLAIMS-schema.json b/dist/21-526EZ-ALLCLAIMS-schema.json index 856e5e555..dd4516dae 100644 --- a/dist/21-526EZ-ALLCLAIMS-schema.json +++ b/dist/21-526EZ-ALLCLAIMS-schema.json @@ -543,6 +543,21 @@ "to" ] }, + "minimumYearDateRange": { + "type": "object", + "properties": { + "startDate": { + "$ref": "#/definitions/minimumYearDate" + }, + "endDate": { + "$ref": "#/definitions/minimumYearDate" + } + } + }, + "minimumYearDate": { + "pattern": "^(?:19|20)[0-9][0-9]-(0[1-9]|1[0-2]|XX)-(0[1-9]|[1-2][0-9]|3[0-1]|XX)$", + "type": "string" + }, "ratedDisabilities": { "type": "array", "maxItems": 100, @@ -771,6 +786,145 @@ } } }, + "toxicExposure": { + "type": "object", + "properties": { + "gulfWar1990Details": { + "type": "object", + "properties": { + "afghanistan": { + "$ref": "#/definitions/minimumYearDateRange" + }, + "bahrain": { + "$ref": "#/definitions/minimumYearDateRange" + }, + "egypt": { + "$ref": "#/definitions/minimumYearDateRange" + }, + "iraq": { + "$ref": "#/definitions/minimumYearDateRange" + }, + "israel": { + "$ref": "#/definitions/minimumYearDateRange" + }, + "jordan": { + "$ref": "#/definitions/minimumYearDateRange" + }, + "kuwait": { + "$ref": "#/definitions/minimumYearDateRange" + }, + "neutralzone": { + "$ref": "#/definitions/minimumYearDateRange" + }, + "oman": { + "$ref": "#/definitions/minimumYearDateRange" + }, + "qatar": { + "$ref": "#/definitions/minimumYearDateRange" + }, + "saudiarabia": { + "$ref": "#/definitions/minimumYearDateRange" + }, + "somalia": { + "$ref": "#/definitions/minimumYearDateRange" + }, + "syria": { + "$ref": "#/definitions/minimumYearDateRange" + }, + "uae": { + "$ref": "#/definitions/minimumYearDateRange" + }, + "turkey": { + "$ref": "#/definitions/minimumYearDateRange" + }, + "waters": { + "$ref": "#/definitions/minimumYearDateRange" + }, + "airspace": { + "$ref": "#/definitions/minimumYearDateRange" + } + } + }, + "gulfWar2001Details": { + "type": "object", + "properties": { + "djibouti": { + "$ref": "#/definitions/minimumYearDateRange" + }, + "lebanon": { + "$ref": "#/definitions/minimumYearDateRange" + }, + "uzbekistan": { + "$ref": "#/definitions/minimumYearDateRange" + }, + "yemen": { + "$ref": "#/definitions/minimumYearDateRange" + }, + "airspace": { + "$ref": "#/definitions/minimumYearDateRange" + } + } + }, + "herbicideDetails": { + "type": "object", + "properties": { + "cambodia": { + "$ref": "#/definitions/minimumYearDateRange" + }, + "guam": { + "$ref": "#/definitions/minimumYearDateRange" + }, + "koreandemilitarizedzone": { + "$ref": "#/definitions/minimumYearDateRange" + }, + "johnston": { + "$ref": "#/definitions/minimumYearDateRange" + }, + "laos": { + "$ref": "#/definitions/minimumYearDateRange" + }, + "c123": { + "$ref": "#/definitions/minimumYearDateRange" + }, + "thailand": { + "$ref": "#/definitions/minimumYearDateRange" + }, + "vietnam": { + "$ref": "#/definitions/minimumYearDateRange" + } + } + }, + "otherExposuresDetails": { + "type": "object", + "properties": { + "asbestos": { + "$ref": "#/definitions/minimumYearDateRange" + }, + "chemical": { + "$ref": "#/definitions/minimumYearDateRange" + }, + "mos": { + "$ref": "#/definitions/minimumYearDateRange" + }, + "mustardgas": { + "$ref": "#/definitions/minimumYearDateRange" + }, + "radiation": { + "$ref": "#/definitions/minimumYearDateRange" + }, + "water": { + "$ref": "#/definitions/minimumYearDateRange" + } + } + }, + "otherHerbicideLocations": { + "$ref": "#/definitions/minimumYearDateRange" + }, + "specifyOtherExposures": { + "$ref": "#/definitions/minimumYearDateRange" + } + } + }, "serviceInformation": { "type": "object", "required": [ diff --git a/dist/definitions.json b/dist/definitions.json index d401a7381..9c6d05f6d 100644 --- a/dist/definitions.json +++ b/dist/definitions.json @@ -1039,6 +1039,21 @@ "null" ] }, + "minimumYearDate": { + "pattern": "^(?:19|20)[0-9][0-9]-(0[1-9]|1[0-2]|XX)-(0[1-9]|[1-2][0-9]|3[0-1]|XX)$", + "type": "string" + }, + "minimumYearDateRange": { + "type": "object", + "properties": { + "startDate": { + "$ref": "#/definitions/minimumYearDate" + }, + "endDate": { + "$ref": "#/definitions/minimumYearDate" + } + } + }, "requiredDate": { "type": "string", "pattern": "^\\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$" diff --git a/package.json b/package.json index d694ec0ee..de74d6fad 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vets-json-schema", - "version": "24.3.3", + "version": "24.4.0", "license": "CC0-1.0", "repository": { "type": "git", diff --git a/src/common/definitions.js b/src/common/definitions.js index 99717508d..fa0eec8ca 100644 --- a/src/common/definitions.js +++ b/src/common/definitions.js @@ -484,6 +484,18 @@ const dateRange = { }, }; +const minimumYearDateRange = { + type: 'object', + properties: { + startDate: { + $ref: '#/definitions/minimumYearDate', + }, + endDate: { + $ref: '#/definitions/minimumYearDate', + }, + }, +}; + const date = { pattern: '^(\\d{4}|XXXX)-(0[1-9]|1[0-2]|XX)-(0[1-9]|[1-2][0-9]|3[0-1]|XX)$', type: 'string', @@ -494,6 +506,16 @@ const nullableDate = { type: ['string', 'null'], }; +// currently being used primarily by the 526EZ app for toxic exposure dates, +// which technically require either just YYYY or YYYY-MM. Partial dates are not +// yet supported in the FE, but dates with X's still occasionally get through. +// Since the BE knows how to parse XX for the month and day, the below regex +// still allows XX for them- however, the year MUST be valid and with no X's +const minimumYearDate = { + pattern: '^(?:19|20)[0-9][0-9]-(0[1-9]|1[0-2]|XX)-(0[1-9]|[1-2][0-9]|3[0-1]|XX)$', + type: 'string', +}; + // XXXX-XX-XX not allowed const requiredDate = { type: 'string', @@ -987,6 +1009,8 @@ export default { dateRange, date, nullableDate, + minimumYearDate, + minimumYearDateRange, requiredDate, rejectOnlyWhitespace, dischargeType, diff --git a/src/schemas/21-526EZ-allclaims/schema.js b/src/schemas/21-526EZ-allclaims/schema.js index 45f5a2ffe..7d17ec8ca 100644 --- a/src/schemas/21-526EZ-allclaims/schema.js +++ b/src/schemas/21-526EZ-allclaims/schema.js @@ -139,6 +139,8 @@ const schema = { vaTreatmentCenterAddress: vaTreatmentCenterAddressDef, dateRange: definitions.dateRange, dateRangeAllRequired: _.set('required', ['from', 'to'], definitions.dateRange), + minimumYearDateRange: definitions.minimumYearDateRange, + minimumYearDate: definitions.minimumYearDate, ratedDisabilities: _.merge(disabilitiesBaseDef, { minItems: 1, items: { @@ -275,6 +277,145 @@ const schema = { }, }, }, + toxicExposure: { + type: 'object', + properties: { + gulfWar1990Details: { + type: 'object', + properties: { + afghanistan: { + $ref: '#/definitions/minimumYearDateRange' + }, + bahrain: { + $ref: '#/definitions/minimumYearDateRange' + }, + egypt: { + $ref: '#/definitions/minimumYearDateRange' + }, + iraq: { + $ref: '#/definitions/minimumYearDateRange' + }, + israel: { + $ref: '#/definitions/minimumYearDateRange' + }, + jordan: { + $ref: '#/definitions/minimumYearDateRange' + }, + kuwait: { + $ref: '#/definitions/minimumYearDateRange' + }, + neutralzone: { + $ref: '#/definitions/minimumYearDateRange' + }, + oman: { + $ref: '#/definitions/minimumYearDateRange' + }, + qatar: { + $ref: '#/definitions/minimumYearDateRange' + }, + saudiarabia: { + $ref: '#/definitions/minimumYearDateRange' + }, + somalia: { + $ref: '#/definitions/minimumYearDateRange' + }, + syria: { + $ref: '#/definitions/minimumYearDateRange' + }, + uae: { + $ref: '#/definitions/minimumYearDateRange' + }, + turkey: { + $ref: '#/definitions/minimumYearDateRange' + }, + waters: { + $ref: '#/definitions/minimumYearDateRange' + }, + airspace: { + $ref: '#/definitions/minimumYearDateRange' + } + } + }, + gulfWar2001Details: { + type: 'object', + properties: { + djibouti: { + $ref: '#/definitions/minimumYearDateRange' + }, + lebanon: { + $ref: '#/definitions/minimumYearDateRange' + }, + uzbekistan: { + $ref: '#/definitions/minimumYearDateRange' + }, + yemen: { + $ref: '#/definitions/minimumYearDateRange' + }, + airspace: { + $ref: '#/definitions/minimumYearDateRange' + } + } + }, + herbicideDetails: { + type: 'object', + properties: { + cambodia: { + $ref: '#/definitions/minimumYearDateRange' + }, + guam: { + $ref: '#/definitions/minimumYearDateRange' + }, + koreandemilitarizedzone: { + $ref: '#/definitions/minimumYearDateRange' + }, + johnston: { + $ref: '#/definitions/minimumYearDateRange' + }, + laos: { + $ref: '#/definitions/minimumYearDateRange' + }, + c123: { + $ref: '#/definitions/minimumYearDateRange' + }, + thailand: { + $ref: '#/definitions/minimumYearDateRange' + }, + vietnam: { + $ref: '#/definitions/minimumYearDateRange' + } + } + }, + otherExposuresDetails: { + type: 'object', + properties: { + asbestos: { + $ref: '#/definitions/minimumYearDateRange' + }, + chemical: { + $ref: '#/definitions/minimumYearDateRange' + }, + mos: { + $ref: '#/definitions/minimumYearDateRange' + }, + mustardgas: { + $ref: '#/definitions/minimumYearDateRange' + }, + radiation: { + $ref: '#/definitions/minimumYearDateRange' + }, + water: { + $ref: '#/definitions/minimumYearDateRange' + } + } + }, + otherHerbicideLocations: { + $ref: '#/definitions/minimumYearDateRange' + }, + specifyOtherExposures: { + $ref: '#/definitions/minimumYearDateRange' + } + } + }, serviceInformation: { type: 'object', required: ['servicePeriods'], diff --git a/test/common/definitions.spec.js b/test/common/definitions.spec.js index 9150ec035..26b4d2944 100644 --- a/test/common/definitions.spec.js +++ b/test/common/definitions.spec.js @@ -490,4 +490,25 @@ describe('schema definitions', () => { valid: ['a@a.com', 'a@a.net', 'a+2@a.com', 'Foo@foo.com', 'foo.bar@foo.org'], invalid: ['@', 'foo', 'foo.com', 'a@a', 'a@a.', '@a.com'], }); + + testValidAndInvalidDefinitions('minimumYearDateRange', { + valid: [ + { startDate: '2009-03-22', endDate: '2010-06-22'}, + { startDate: '2009-03-22'}, + { endDate: '2010-06-22'}, + { startDate: '2009-03-XX', endDate: '2010-06-22'}, + { startDate: '2009-03-22', endDate: '2010-06-XX'}, + { startDate: '2009-XX-XX', endDate: '2010-06-22'}, + { startDate: '2009-03-22', endDate: '2010-XX-XX'}, + { startDate: '2009-XX-XX'}, + { endDate: '2010-XX-XX'}, + { startDate: '2009-XX-22', endDate: '2010-XX-22'}, + ], + invalid: [ + { startDate: 'XXXX-01-02' }, + { endDate: '79-01-02' }, + { startDate: '2009-03-22', endDate: 'XXXX-01-02' }, + { startDate: '79-01-02', endDate: '2009-03-XX' }, + ] + }); }); diff --git a/test/schemas/21-526EZ/schema.spec.js b/test/schemas/21-526EZ/schema.spec.js index 9487e6a09..dc85cf1c5 100644 --- a/test/schemas/21-526EZ/schema.spec.js +++ b/test/schemas/21-526EZ/schema.spec.js @@ -125,6 +125,102 @@ const data = { { from: 'bar', to: fixtures.dateRange }, ], }, + minimumYearDateRange: { + valid: testData.minimumYearDateRange.data.valid, + invalid: [ + { startDate: 'XXXX-01-02' }, + { endDate: '79-01-02' }, + { startDate: fixtures.minimumYearDateRange.startDate, endDate: 'XXXX-01-02' }, + { startDate: '79-01-02', endDate: fixtures.minimumYearDateRange.endDate }, + ], + }, + gulfWar1990Details: { + valid: [ + { afghanistan: fixtures.minimumYearDateRange }, + { bahrain: fixtures.minimumYearDateRange }, + { egypt: fixtures.minimumYearDateRange }, + { iraq: fixtures.minimumYearDateRange }, + { israel: fixtures.minimumYearDateRange }, + { jordan: fixtures.minimumYearDateRange }, + { kuwait: fixtures.minimumYearDateRange }, + { neutralzone: fixtures.minimumYearDateRange }, + { oman: fixtures.minimumYearDateRange }, + { qatar: fixtures.minimumYearDateRange }, + { saudiarabia: fixtures.minimumYearDateRange }, + { somalia: fixtures.minimumYearDateRange }, + { syria: fixtures.minimumYearDateRange }, + { uae: fixtures.minimumYearDateRange }, + { turkey: fixtures.minimumYearDateRange }, + { waters: fixtures.minimumYearDateRange }, + { airspace: fixtures.minimumYearDateRange }, + { airspace: fixtures.minimumYearDateRange, jordan: fixtures.minimumYearDateRange }, + { airspace: fixtures.minimumYearDateRange, jordan: fixtures.minimumYearDateRange, syria: fixtures.minimumYearDateRange }, + ], + invalid: [ + { afghanistan: { startDate: 'XXXX-01-01', endDate: '79-01-02' } }, + { turkey: { startDate: '79-01-02' } }, + { qatar: { startDate: 'XXXX-01-02', endDate: '1999-01-02' } }, + { qatar: { startDate: 'XXXX-01-02', endDate: '1999-01-02' }, turkey: { startDate: '1999-01-02' } }, + ] + }, + gulfWar2001Details: { + valid: [ + { djibouti: fixtures.minimumYearDateRange }, + { lebanon: fixtures.minimumYearDateRange }, + { uzbekistan: fixtures.minimumYearDateRange }, + { yemen: fixtures.minimumYearDateRange }, + { airspace: fixtures.minimumYearDateRange }, + { airspace: fixtures.minimumYearDateRange, uzbekistan: fixtures.minimumYearDateRange }, + { airspace: fixtures.minimumYearDateRange, uzbekistan: fixtures.minimumYearDateRange, djibouti: fixtures.minimumYearDateRange }, + ], + invalid: [ + { yemen: { startDate: 'XXXX-01-01', endDate: '79-01-02' } }, + { djibouti: { startDate: '79-01-02' } }, + { lebanon: { startDate: 'XXXX-01-02', endDate: '1999-01-02' } }, + { lebanon: { startDate: '1999-01-02', endDate: '79-01-02' }, turkey: { startDate: '1999-01-02' } }, + { lebanon: { startDate: 'XXXX-01-02', endDate: '1999-01-02' }, turkey: { endDate: '1999-01-02' } }, + ] + }, + herbicideDetails: { + valid: [ + { cambodia: fixtures.minimumYearDateRange }, + { guam: fixtures.minimumYearDateRange }, + { koreandemilitarizedzone: fixtures.minimumYearDateRange }, + { johnston: fixtures.minimumYearDateRange }, + { laos: fixtures.minimumYearDateRange }, + { c123: fixtures.minimumYearDateRange }, + { thailand: fixtures.minimumYearDateRange }, + { vietnam: fixtures.minimumYearDateRange }, + { vietnam: fixtures.minimumYearDateRange, laos: fixtures.minimumYearDateRange }, + { vietnam: fixtures.minimumYearDateRange, laos: fixtures.minimumYearDateRange, koreandemilitarizedzone: fixtures.minimumYearDateRange }, + ], + invalid: [ + { guam: { startDate: 'XXXX-01-01', endDate: '79-01-02' } }, + { koreandemilitarizedzone: { startDate: '79-01-02' } }, + { laos: { startDate: 'XXXX-01-02', endDate: '1999-01-02' } }, + { laos: { startDate: '1999-01-02', endDate: '79-01-02' }, turkey: { endDate: '1999-01-02' } }, + { laos: { startDate: 'XXXX-01-02', endDate: '1999-01-02' }, turkey: { startDate: '1999-01-02' } }, + ] + }, + otherExposuresDetails: { + valid: [ + { asbestos: fixtures.minimumYearDateRange }, + { chemical: fixtures.minimumYearDateRange }, + { mos: fixtures.minimumYearDateRange }, + { mustardgas: fixtures.minimumYearDateRange }, + { radiation: fixtures.minimumYearDateRange }, + { water: fixtures.minimumYearDateRange }, + { water: fixtures.minimumYearDateRange, mos: fixtures.minimumYearDateRange }, + { water: fixtures.minimumYearDateRange, mos: fixtures.minimumYearDateRange, chemical: fixtures.minimumYearDateRange }, + ], + invalid: [ + { water: { startDate: 'XXXX-01-01', endDate: '79-01-02' } }, + { mustardgas: { startDate: '79-01-02' } }, + { asbestos: { startDate: 'XXXX-01-02', endDate: '1999-01-02' } }, + { asbestos: { startDate: '1999-01-02', endDate: '79-01-02' }, radiation: { endDate: '1999-01-02' } }, + { asbestos: { startDate: 'XXXX-01-02', endDate: '1999-01-02' }, radiation: { startDate: '1999-01-02' } }, + ] + }, alternateNames: { valid: [ [{ first: 'john', last: 'doe' }], @@ -582,6 +678,7 @@ describe('21-526-ALLCLAIMS schema', () => { testValidAndInvalidDefinitions('vaTreatmentCenterAddress'); testValidAndInvalidDefinitions('dateRange'); testValidAndInvalidDefinitions('dateRangeAllRequired'); + testValidAndInvalidDefinitions('minimumYearDateRange'); testValidAndInvalidDefinitions('ratedDisabilities'); testValidAndInvalidDefinitions('newDisabilities'); testValidAndInvalidDefinitions('unitAssigned', data.string(100)); @@ -613,6 +710,12 @@ describe('21-526-ALLCLAIMS schema', () => { testValidAndInvalid('serviceInformation.servicePeriods', data.servicePeriods); testValidAndInvalid('serviceInformation.separationLocation', data.separationLocation); testValidAndInvalid('serviceInformation.reservesNationalGuardService', data.reservesNationalGuardService); + testValidAndInvalid('toxicExposure.gulfWar1990Details', data.gulfWar1990Details); + testValidAndInvalid('toxicExposure.gulfWar2001Details', data.gulfWar2001Details); + testValidAndInvalid('toxicExposure.herbicideDetails', data.herbicideDetails); + testValidAndInvalid('toxicExposure.otherExposuresDetails', data.otherExposuresDetails); + testValidAndInvalid('toxicExposure.otherHerbicideLocations', testData.minimumYearDateRange.data); + testValidAndInvalid('toxicExposure.specifyOtherExposures', testData.minimumYearDateRange.data); testValidAndInvalid('confinements'); testValidAndInvalid('militaryRetiredPayBranch', data.branch); diff --git a/test/support/fixtures.js b/test/support/fixtures.js index e71ae695e..867a588b2 100644 --- a/test/support/fixtures.js +++ b/test/support/fixtures.js @@ -9,6 +9,10 @@ export default { from: '2000-01-01', to: '2000-01-02' }, + minimumYearDateRange: { + startDate: '2000-01-01', + endDate: '2000-01-02' + }, address: { street: '123 a rd', city: 'abc', diff --git a/test/support/test-data.js b/test/support/test-data.js index f048b350c..989f685a8 100644 --- a/test/support/test-data.js +++ b/test/support/test-data.js @@ -379,6 +379,16 @@ export default { ], }, }, + minimumYearDateRange: { + data: { + valid: [fixtures.minimumYearDateRange], + invalid: [ + { + startDate: 'XXXX-01-02', + }, + ], + }, + }, postHighSchoolTrainings: { data: { valid: [