Skip to content

Commit

Permalink
[DBX-97063] 0781 Paper Sync boilerplate (#33210)
Browse files Browse the repository at this point in the history
* [DBX-97062/97063] Add flipper protected entrypoint for modern 0781 sync

* general save

* general save

* general save

* general save

* general save

* general save

* general save
  • Loading branch information
SamStuckey authored Dec 9, 2024
1 parent 0307061 commit d1e2169
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/applications/disability-benefits/all-claims/config/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import {
isUploadingSTR,
needsToEnter781,
needsToEnter781a,
showAdditionalFormsChapter,
showPtsdCombat,
showPtsdNonCombat,
showSeparationLocation,
Expand Down Expand Up @@ -109,7 +110,10 @@ import {
veteranInfo,
workBehaviorChanges,
} from '../pages';
import * as additionalFormsChapterWrapper from '../pages/additionalFormsChapterWrapper';

import { toxicExposurePages } from '../pages/toxicExposure/toxicExposurePages';
import { form0781PagesConfig } from './form0781/index';

import { ancillaryFormsWizardDescription } from '../content/ancillaryFormsWizardIntro';

Expand Down Expand Up @@ -617,6 +621,19 @@ const formConfig = {
},
},
},
additionalForms: {
title: 'Additional Forms',
pages: {
additionalFormsChapterWrapper: {
title: 'Additional forms to support your claim',
path: 'additional-forms',
depends: formData => showAdditionalFormsChapter(formData),
uiSchema: additionalFormsChapterWrapper.uiSchema,
schema: additionalFormsChapterWrapper.schema,
},
...form0781PagesConfig,
},
},
supportingEvidence: {
title: 'Supporting evidence',
pages: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import * as workflowChoicePage from '../../pages/form0781/workflowChoicePage';
import { showForm0781Pages } from '../../utils/form0781';

/**
* Configuration for our modern 0781 paper sync (2024/2025)
*
* @returns Object
*/
export const form0781PagesConfig = {
workflowChoicePage: {
path: 'additional-forms/mental-health-statement',
depends: formData => showForm0781Pages(formData),
uiSchema: workflowChoicePage.uiSchema,
schema: workflowChoicePage.schema,
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const additionalFormsTitle = 'Additional Forms';
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// TODO: this is a placeholder. Structure will be added to this page in this ticket #97065
export const uiSchema = {
'ui:description': 'Placeholder Text for Start Page',
};

export const schema = {
type: 'object',
properties: {},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// TODO: this is a placeholder. Structure will be added to this page in this ticket #97067
export const uiSchema = {
'ui:description': 'Placeholder Text for workflow choice page',
};

export const schema = {
type: 'object',
properties: {},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { expect } from 'chai';

import { form0781PagesConfig } from '../../config/form0781/index';

describe('the form0781PagesConfig entry point object', () => {
it('should return a config object', () => {
expect(form0781PagesConfig).to.be.an('object');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { expect } from 'chai';
import * as additionalFormsChapterWrapper from '../../pages/additionalFormsChapterWrapper';

describe('Additional Forms chapter wrapper page', () => {
it('should define a uiSchema object', () => {
expect(additionalFormsChapterWrapper.uiSchema).to.be.an('object');
});

it('should define a schema object', () => {
expect(additionalFormsChapterWrapper.schema).to.be.an('object');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { expect } from 'chai';
import * as workflowChoicePage from '../../../pages/form0781/workflowChoicePage';

describe('Form 0781 workflow choice page', () => {
it('should define a uiSchema object', () => {
expect(workflowChoicePage.uiSchema).to.be.an('object');
});

it('should define a schema object', () => {
expect(workflowChoicePage.schema).to.be.an('object');
});
});
25 changes: 25 additions & 0 deletions src/applications/disability-benefits/all-claims/utils/form0781.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// All flippers for the 0781 Papersync should be added to this file
import { isClaimingNew } from '.';

/**
* Checks if the modern 0781 flow should be shown if the flipper is active for this veteran
* All 0781 page-specific flippers should include a check against this top level flipper
*
* @returns
* TRUE if
* - is set on form via the backend
* - Veteran is claiming a new disability
* - Veteran has selected connected condition choices on 'screener page'
* else
* - returns false
*/
export function showForm0781Pages(formData) {
const conditions = formData?.mentalHealth?.conditions || {};
return (
formData?.syncModern0781Flow === true &&
isClaimingNew(formData) &&
Object.entries(conditions).some(
([key, value]) => key !== 'none' && value === true,
)
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,11 @@ export const hasNewPtsdDisability = formData =>
isDisabilityPtsd(disability.condition),
);

// NOTE: this will need to be updated or removed when we have a usecase for the
// Additional Forms chapter beyond the new 0781 flow
export const showAdditionalFormsChapter = formData =>
formData?.syncModern0781Flow === true;

export const showPtsdCombat = formData =>
hasNewPtsdDisability(formData) &&
_.get('view:selectablePtsdTypes.view:combatPtsdType', formData, false);
Expand Down

0 comments on commit d1e2169

Please sign in to comment.