Skip to content

Commit

Permalink
[DBX-97082] Add Behavioral Changes Pages for 0781 Paper Sync (#33838)
Browse files Browse the repository at this point in the history
* [DBX-97082] Add Behavioral Changes Pages for 0781 Paper Sync

* general save

* general save
  • Loading branch information
SamStuckey authored Jan 13, 2025
1 parent 753c78b commit f71f74b
Show file tree
Hide file tree
Showing 11 changed files with 503 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@ import * as workflowChoicePage from '../../pages/form0781/workflowChoicePage';
import * as mentalHealthSupport from '../../pages/form0781/mentalHealthSupport';
import * as traumaticEventsIntro from '../../pages/form0781/traumaticEventsIntro';
import * as eventType from '../../pages/form0781/traumaticEventTypes';
import * as consentPage from '../../pages/form0781/consentPage';
import * as additionalInformationPage from '../../pages/form0781/additionalInformationPage';
import * as behaviorIntroPage from '../../pages/form0781/behaviorIntroPage';
import * as behaviorIntroCombatPage from '../../pages/form0781/behaviorIntroCombatPage';
import * as behaviorListPage from '../../pages/form0781/behaviorListPage';

import {
showForm0781Pages,
isCompletingForm0781,
showForm0781Pages,
isRelatedToMST,
showBehaviorIntroPage,
showBehaviorIntroCombatPage,
showBehaviorListPage,
} from '../../utils/form0781';
import * as consentPage from '../../pages/form0781/consentPage';
import * as additionalInformationPage from '../../pages/form0781/additionalInformationPage';

/**
* Configuration for our modern 0781 paper sync (2024/2025)
Expand Down Expand Up @@ -43,16 +50,35 @@ export const form0781PagesConfig = {
uiSchema: eventType.uiSchema,
schema: eventType.schema,
},
consentPage: {
path: 'additional-forms/mental-health-statement/consent',
depends: formData => isRelatedToMST(formData),
uiSchema: consentPage.uiSchema,
schema: consentPage.schema,
},
additionalInformationPage: {
path: 'additional-forms/mental-health-statement/additional-information',
depends: formData => isCompletingForm0781(formData),
uiSchema: additionalInformationPage.uiSchema,
schema: additionalInformationPage.schema,
},
// Behavioral Changes Pages
behaviorIntroPage: {
path: 'additional-forms/mental-health-statement/behavior-changes',
depends: formData => showBehaviorIntroPage(formData),
uiSchema: behaviorIntroPage.uiSchema,
schema: behaviorIntroPage.schema,
},
behaviorIntroCombatPage: {
path: 'additional-forms/mental-health-statement/behavior-changes-combat',
depends: formData => showBehaviorIntroCombatPage(formData),
uiSchema: behaviorIntroCombatPage.uiSchema,
schema: behaviorIntroCombatPage.schema,
},
behaviorListPage: {
path: 'additional-forms/mental-health-statement/behavior-changes-list',
depends: formData => showBehaviorListPage(formData),
uiSchema: behaviorListPage.uiSchema,
schema: behaviorListPage.schema,
},
consentPage: {
path: 'additional-forms/mental-health-statement/consent',
depends: formData => isRelatedToMST(formData),
uiSchema: consentPage.uiSchema,
schema: consentPage.schema,
},
};
26 changes: 26 additions & 0 deletions src/applications/disability-benefits/all-claims/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,3 +411,29 @@ export const TRAUMATIC_EVENT_TYPES = Object.freeze({
nonMst: 'Traumatic events related to other personal interactions',
other: 'Other traumatic events',
});

export const BEHAVIOR_CHANGES_WORK = Object.freeze({
reassignment:
'Request for a change in occupational series or duty assignment',
absences: 'Increased or decreased use of leave',
performance: 'Changes in performance or performance evaluations',
});

export const BEHAVIOR_CHANGES_HEALTH = Object.freeze({
consultations:
'Increased or decreased visits to a healthcare professional, counselor, or treatment facility',
episodes: 'Episodes of depression, panic attacks, or anxiety',
medications: 'Increased or decreased use of prescription medications',
selfMedication: 'Increased or decreased use of over-the-counter medications',
substances: 'Increased or decreased use of alcohol or drugs',
appetite:
'Changes in eating habits, such as overeating or undereating, or significant changes in weight',
pregnancy: 'Pregnancy tests around the time of the traumatic experiences',
screenings: 'Tests for sexually transmitted infections',
});

export const BEHAVIOR_CHANGES_OTHER = Object.freeze({
socialEconomic: 'Economic or social behavioral changes',
relationships: 'Changes in or breakup of a significant relationship',
misconduct: 'Disciplinary or legal difficulties',
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';

export const BEHAVIOR_LIST_DESCRIPTION = (
<p>
Did you experience any of these behavioral changes after your traumatic
experiences? It’s also okay if you don’t report any behavioral changes. You
can skip this question if you don’t feel comfortable answering.
</p>
);

export const BEHAVIOR_LIST_BEHAVIORS_TITLE =
'Behavioral changes related to work';

export const BEHAVIOR_INTRO_COMBAT_DESCRIPTION = (
<p>Placholder content for combat intro description</p>
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {
radioUI,
radioSchema,
} from 'platform/forms-system/src/js/web-component-patterns';

import { BEHAVIOR_INTRO_COMBAT_DESCRIPTION } from '../../content/form0781/behaviorListPages';

export const uiSchema = {
'ui:description': BEHAVIOR_INTRO_COMBAT_DESCRIPTION,
'view:answerCombatBehaviorQuestions': {
...radioUI({
title: 'Do you want to answer additional questions?',
required: () => true,
labels: {
true: 'true',
false: 'false',
},
}),
},
};

export const schema = {
type: 'object',
properties: {
'view:answerCombatBehaviorQuestions': radioSchema(['true', 'false']),
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const uiSchema = {
'ui:description': 'Placeholder Text for Behavior Intro',
};

export const schema = {
type: 'object',
properties: {},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import {
checkboxGroupSchema,
checkboxGroupUI,
} from 'platform/forms-system/src/js/web-component-patterns';
import {
BEHAVIOR_LIST_DESCRIPTION,
BEHAVIOR_LIST_BEHAVIORS_TITLE,
} from '../../content/form0781/behaviorListPages';
import {
BEHAVIOR_CHANGES_WORK,
BEHAVIOR_CHANGES_HEALTH,
BEHAVIOR_CHANGES_OTHER,
} from '../../constants';

const schemaKeys = Object.keys(BEHAVIOR_CHANGES_WORK).concat(
Object.keys(BEHAVIOR_CHANGES_HEALTH),
Object.keys(BEHAVIOR_CHANGES_OTHER),
);

export const uiSchema = {
'ui:description': BEHAVIOR_LIST_DESCRIPTION,
behaviors: checkboxGroupUI({
title: BEHAVIOR_LIST_BEHAVIORS_TITLE,
labels: {
...BEHAVIOR_CHANGES_WORK,
...BEHAVIOR_CHANGES_HEALTH,
...BEHAVIOR_CHANGES_OTHER,
},
required: false,
}),
otherBehaviors: {
'ui:title': 'placeholder title',
'ui:description': 'placeholde description',
},
'view:optOut': checkboxGroupUI({
title: 'None',
labels: {
none: 'no selection placeholder',
},
required: false,
}),
'ui:validations': [
(errors, field) => {
const behaviorSelected = Object.values(field.behaviors || {}).some(
selected => selected,
);
const otherProvided = Object.values(field.otherBehaviors || {}).some(
entry => !!entry,
);
const optedOut = !!Object.values(field['view:optOut'] || {}).some(
entry => !!entry,
);

if (!behaviorSelected && !otherProvided && !optedOut) {
// when a user has not selected options nor opted out
errors['view:optOut'].addError(
'selection required Error message placehoder',
);
} else if (optedOut && (behaviorSelected || otherProvided)) {
// when a user has selected options and opted out
errors['view:optOut'].addError(
'conflicting selections Error message placehoder',
);
}
},
],
};

export const schema = {
type: 'object',
properties: {
behaviors: checkboxGroupSchema(schemaKeys),
otherBehaviors: {
type: 'string',
properties: {},
},
'view:optOut': checkboxGroupSchema(['none']),
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { expect } from 'chai';
import * as behaviorIntroCombatPage from '../../../pages/form0781/behaviorIntroCombatPage';

describe('Behavior Intro Page when Combat is the only type selected', () => {
it('should define a uiSchema object', () => {
expect(behaviorIntroCombatPage.uiSchema).to.be.an('object');
});

it('should define a schema object', () => {
expect(behaviorIntroCombatPage.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 behaviorIntroPage from '../../../pages/form0781/behaviorIntroPage';

describe('Behavior Intro Page', () => {
it('should define a uiSchema object', () => {
expect(behaviorIntroPage.uiSchema).to.be.an('object');
});

it('should define a schema object', () => {
expect(behaviorIntroPage.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 behaviorListPage from '../../../pages/form0781/behaviorListPage';

describe('Behavior List Page', () => {
it('should define a uiSchema object', () => {
expect(behaviorListPage.uiSchema).to.be.an('object');
});

it('should define a schema object', () => {
expect(behaviorListPage.schema).to.be.an('object');
});
});
Loading

0 comments on commit f71f74b

Please sign in to comment.