src/applications/discharge-wizard/constants/display-conditions.js
import { range } from 'lodash';
import { months } from 'platform/static-data/options-for-select';
import { RESPONSES } from './question-data-map';
const get15YearsPast = () => `${new Date().getFullYear() - 15}`;
const currentYear = new Date().getFullYear();
const yearResponses = range(currentYear - 1991).map(i => {
const year = currentYear - i;
return year.toString();
});
// This accounts for the before 1992 answer for the Discharge Year question.
yearResponses.push('Before 1992');
const validYearsForNonOldDischarge = yearResponses.filter(year => {
return currentYear - year < 15;
});
const determineMonths = months.reduce((newArray, month) => {
const currentMonth = new Date().getMonth() + 1;
if (currentMonth <= month.value) {
newArray.push(month.value.toString());
}
return newArray;
}, []);
const year15Yearsago = (new Date().getFullYear() - 15).toString();
const {
ARMY,
NAVY,
AIR_FORCE,
COAST_GUARD,
MARINE_CORPS,
REASON_PTSD,
REASON_TBI,
REASON_SEXUAL_ORIENTATION,
REASON_SEXUAL_ASSAULT,
REASON_TRANSGENDER,
REASON_DD215_UPDATE_TO_DD214,
REASON_ERROR,
REASON_UNJUST,
COURT_MARTIAL_YES,
COURT_MARTIAL_NO,
NOT_SURE,
INTENTION_NO,
YES,
NO,
DISCHARGE_DISHONORABLE,
PREV_APPLICATION_BEFORE_2014,
PREV_APPLICATION_BEFORE_2011,
PREV_APPLICATION_BEFORE_2017,
PREV_APPLICATION_AFTER_2014,
PREV_APPLICATION_AFTER_2011,
PREV_APPLICATION_AFTER_2017,
PREV_APPLICATION_BCMR,
PREV_APPLICATION_BCNR,
PREV_APPLICATION_DRB_DOCUMENTARY,
PREV_APPLICATION_DRB_PERSONAL,
FAILURE_TO_EXHAUST_BCMR_YES,
FAILURE_TO_EXHAUST_BCMR_NO,
FAILURE_TO_EXHAUST_BCNR_YES,
FAILURE_TO_EXHAUST_BCNR_NO,
} = RESPONSES;
export const DISPLAY_CONDITIONS = Object.freeze({
SERVICE_BRANCH: {},
DISCHARGE_YEAR: {
SERVICE_BRANCH: [ARMY, NAVY, AIR_FORCE, COAST_GUARD, MARINE_CORPS],
},
DISCHARGE_MONTH: {
SERVICE_BRANCH: [ARMY, NAVY, AIR_FORCE, COAST_GUARD, MARINE_CORPS],
DISCHARGE_YEAR: [get15YearsPast()],
},
REASON: {
SERVICE_BRANCH: [ARMY, NAVY, AIR_FORCE, COAST_GUARD, MARINE_CORPS],
DISCHARGE_YEAR: yearResponses,
DISCHARGE_MONTH: [],
},
DISCHARGE_TYPE: {
SERVICE_BRANCH: [ARMY, NAVY, AIR_FORCE, COAST_GUARD, MARINE_CORPS],
DISCHARGE_YEAR: yearResponses,
DISCHARGE_MONTH: [],
REASON: [REASON_SEXUAL_ORIENTATION],
},
INTENTION: {
SERVICE_BRANCH: [ARMY, NAVY, AIR_FORCE, COAST_GUARD, MARINE_CORPS],
DISCHARGE_YEAR: yearResponses,
DISCHARGE_MONTH: [],
REASON: [
REASON_PTSD,
REASON_TBI,
REASON_SEXUAL_ORIENTATION,
REASON_SEXUAL_ASSAULT,
REASON_ERROR,
REASON_UNJUST,
],
},
COURT_MARTIAL: {
SERVICE_BRANCH: [ARMY, NAVY, AIR_FORCE, COAST_GUARD, MARINE_CORPS],
DISCHARGE_YEAR: yearResponses,
DISCHARGE_MONTH: [],
REASON: [
REASON_TRANSGENDER,
REASON_PTSD,
REASON_TBI,
REASON_SEXUAL_ORIENTATION,
REASON_SEXUAL_ASSAULT,
REASON_ERROR,
REASON_UNJUST,
],
},
PREV_APPLICATION: {
SERVICE_BRANCH: [ARMY, NAVY, AIR_FORCE, COAST_GUARD, MARINE_CORPS],
DISCHARGE_YEAR: yearResponses,
DISCHARGE_MONTH: [],
REASON: [
REASON_TRANSGENDER,
REASON_PTSD,
REASON_TBI,
REASON_SEXUAL_ORIENTATION,
REASON_SEXUAL_ASSAULT,
REASON_ERROR,
REASON_UNJUST,
],
COURT_MARTIAL: [COURT_MARTIAL_YES, COURT_MARTIAL_NO, NOT_SURE],
},
PREV_APPLICATION_YEAR: {
SERVICE_BRANCH: [ARMY, NAVY, AIR_FORCE, COAST_GUARD, MARINE_CORPS],
DISCHARGE_YEAR: yearResponses,
DISCHARGE_MONTH: [],
REASON: [
REASON_PTSD,
REASON_TBI,
REASON_SEXUAL_ORIENTATION,
REASON_SEXUAL_ASSAULT,
],
COURT_MARTIAL: [COURT_MARTIAL_YES, COURT_MARTIAL_NO, NOT_SURE],
PREV_APPLICATION: [YES],
},
PREV_APPLICATION_TYPE: {
FORK: {
0: {
SERVICE_BRANCH: [ARMY, NAVY, AIR_FORCE, COAST_GUARD, MARINE_CORPS],
DISCHARGE_YEAR: yearResponses,
DISCHARGE_MONTH: [],
REASON: [REASON_DD215_UPDATE_TO_DD214],
},
1: {
SERVICE_BRANCH: [ARMY, NAVY, AIR_FORCE, COAST_GUARD, MARINE_CORPS],
DISCHARGE_YEAR: yearResponses,
DISCHARGE_MONTH: [],
REASON: [REASON_TRANSGENDER, REASON_ERROR, REASON_UNJUST],
PREV_APPLICATION: [YES],
},
2: {
SERVICE_BRANCH: [ARMY, NAVY, AIR_FORCE, COAST_GUARD, MARINE_CORPS],
DISCHARGE_YEAR: yearResponses,
DISCHARGE_MONTH: [],
REASON: [
REASON_PTSD,
REASON_TBI,
REASON_SEXUAL_ORIENTATION,
REASON_SEXUAL_ASSAULT,
REASON_TRANSGENDER,
REASON_ERROR,
REASON_UNJUST,
],
PREV_APPLICATION_YEAR: [
PREV_APPLICATION_AFTER_2014,
PREV_APPLICATION_AFTER_2011,
PREV_APPLICATION_AFTER_2017,
],
},
3: {
PREV_APPLICATION_YEAR: [
PREV_APPLICATION_AFTER_2014,
PREV_APPLICATION_AFTER_2011,
PREV_APPLICATION_AFTER_2017,
],
},
},
},
FAILURE_TO_EXHAUST: {
FORK: {
0: {
DISCHARGE_YEAR: [...validYearsForNonOldDischarge],
COURT_MARTIAL: [COURT_MARTIAL_NO, NOT_SURE],
INTENTION: [INTENTION_NO],
PREV_APPLICATION_TYPE: [PREV_APPLICATION_BCMR, PREV_APPLICATION_BCNR],
},
1: {
DISCHARGE_YEAR: [year15Yearsago],
DISCHARGE_MONTH: [...determineMonths],
COURT_MARTIAL: [COURT_MARTIAL_NO, NOT_SURE],
INTENTION: [INTENTION_NO],
PREV_APPLICATION_TYPE: [PREV_APPLICATION_BCMR, PREV_APPLICATION_BCNR],
},
},
},
PRIOR_SERVICE: {
FORK: {
0: {
SERVICE_BRANCH: [ARMY, NAVY, AIR_FORCE, COAST_GUARD, MARINE_CORPS],
DISCHARGE_YEAR: yearResponses,
DISCHARGE_MONTH: [],
REASON: [REASON_SEXUAL_ORIENTATION],
DISCHARGE_TYPE: [DISCHARGE_DISHONORABLE],
PREV_APPLICATION: [NO],
},
1: {
SERVICE_BRANCH: [ARMY, NAVY, AIR_FORCE, COAST_GUARD, MARINE_CORPS],
DISCHARGE_YEAR: yearResponses,
DISCHARGE_MONTH: [],
REASON: [
REASON_PTSD,
REASON_TBI,
REASON_SEXUAL_ASSAULT,
REASON_ERROR,
REASON_UNJUST,
REASON_DD215_UPDATE_TO_DD214,
],
PREV_APPLICATION: [NO],
},
2: {
SERVICE_BRANCH: [ARMY, NAVY, AIR_FORCE, COAST_GUARD, MARINE_CORPS],
DISCHARGE_YEAR: yearResponses,
DISCHARGE_MONTH: [],
REASON: [REASON_SEXUAL_ORIENTATION],
DISCHARGE_TYPE: [DISCHARGE_DISHONORABLE],
PREV_APPLICATION: [YES],
PREV_APPLICATION_YEAR: [
PREV_APPLICATION_BEFORE_2014,
PREV_APPLICATION_BEFORE_2011,
PREV_APPLICATION_BEFORE_2017,
],
},
3: {
SERVICE_BRANCH: [ARMY, NAVY, AIR_FORCE, COAST_GUARD, MARINE_CORPS],
DISCHARGE_YEAR: yearResponses,
DISCHARGE_MONTH: [],
REASON: [
REASON_PTSD,
REASON_TBI,
REASON_SEXUAL_ASSAULT,
REASON_ERROR,
REASON_UNJUST,
REASON_DD215_UPDATE_TO_DD214,
],
PREV_APPLICATION: [YES],
PREV_APPLICATION_YEAR: [
PREV_APPLICATION_BEFORE_2014,
PREV_APPLICATION_BEFORE_2011,
PREV_APPLICATION_BEFORE_2017,
],
},
4: {
SERVICE_BRANCH: [ARMY, NAVY, AIR_FORCE, COAST_GUARD, MARINE_CORPS],
DISCHARGE_YEAR: yearResponses,
DISCHARGE_MONTH: [],
REASON: [
REASON_PTSD,
REASON_TBI,
REASON_SEXUAL_ASSAULT,
REASON_ERROR,
REASON_UNJUST,
],
PREV_APPLICATION: [YES],
PREV_APPLICATION_YEAR: [
PREV_APPLICATION_BEFORE_2014,
PREV_APPLICATION_BEFORE_2011,
PREV_APPLICATION_BEFORE_2017,
],
PREV_APPLICATION_TYPE: [
PREV_APPLICATION_DRB_DOCUMENTARY,
PREV_APPLICATION_DRB_PERSONAL,
NOT_SURE,
],
},
5: {
SERVICE_BRANCH: [ARMY, NAVY, AIR_FORCE, COAST_GUARD, MARINE_CORPS],
DISCHARGE_YEAR: yearResponses,
DISCHARGE_MONTH: [],
REASON: [REASON_SEXUAL_ORIENTATION],
DISCHARGE_TYPE: [DISCHARGE_DISHONORABLE],
PREV_APPLICATION: [YES],
PREV_APPLICATION_YEAR: [
PREV_APPLICATION_BEFORE_2014,
PREV_APPLICATION_BEFORE_2011,
PREV_APPLICATION_BEFORE_2017,
],
PREV_APPLICATION_TYPE: [
PREV_APPLICATION_DRB_DOCUMENTARY,
PREV_APPLICATION_DRB_PERSONAL,
NOT_SURE,
],
},
6: {
SERVICE_BRANCH: [ARMY, NAVY, AIR_FORCE, COAST_GUARD, MARINE_CORPS],
DISCHARGE_YEAR: yearResponses,
DISCHARGE_MONTH: [],
REASON: [REASON_SEXUAL_ORIENTATION],
DISCHARGE_TYPE: [DISCHARGE_DISHONORABLE],
INTENTION: [INTENTION_NO],
COURT_MARTIAL: [COURT_MARTIAL_NO, NOT_SURE],
PREV_APPLICATION: [YES],
PREV_APPLICATION_YEAR: [
PREV_APPLICATION_AFTER_2014,
PREV_APPLICATION_AFTER_2011,
PREV_APPLICATION_AFTER_2017,
],
PREV_APPLICATION_TYPE: [PREV_APPLICATION_BCMR, PREV_APPLICATION_BCNR],
},
7: {
SERVICE_BRANCH: [ARMY, NAVY, AIR_FORCE, COAST_GUARD, MARINE_CORPS],
DISCHARGE_YEAR: yearResponses,
DISCHARGE_MONTH: [],
REASON: [REASON_SEXUAL_ORIENTATION],
DISCHARGE_TYPE: [DISCHARGE_DISHONORABLE],
INTENTION: [INTENTION_NO],
COURT_MARTIAL: [COURT_MARTIAL_NO, NOT_SURE],
PREV_APPLICATION: [YES],
PREV_APPLICATION_YEAR: [
PREV_APPLICATION_AFTER_2014,
PREV_APPLICATION_AFTER_2011,
PREV_APPLICATION_AFTER_2017,
],
PREV_APPLICATION_TYPE: [PREV_APPLICATION_BCMR, PREV_APPLICATION_BCNR],
FAILURE_TO_EXHAUST: [
FAILURE_TO_EXHAUST_BCMR_YES,
FAILURE_TO_EXHAUST_BCMR_NO,
FAILURE_TO_EXHAUST_BCNR_YES,
FAILURE_TO_EXHAUST_BCNR_NO,
],
},
8: {
SERVICE_BRANCH: [ARMY, NAVY, AIR_FORCE, COAST_GUARD, MARINE_CORPS],
DISCHARGE_YEAR: yearResponses,
DISCHARGE_MONTH: [],
REASON: [
REASON_PTSD,
REASON_TBI,
REASON_SEXUAL_ORIENTATION,
REASON_SEXUAL_ASSAULT,
REASON_ERROR,
REASON_UNJUST,
],
PREV_APPLICATION: [YES],
PREV_APPLICATION_YEAR: [
PREV_APPLICATION_AFTER_2014,
PREV_APPLICATION_AFTER_2011,
PREV_APPLICATION_AFTER_2017,
],
PREV_APPLICATION_TYPE: [PREV_APPLICATION_BCMR, PREV_APPLICATION_BCNR],
FAILURE_TO_EXHAUST: [
FAILURE_TO_EXHAUST_BCMR_YES,
FAILURE_TO_EXHAUST_BCMR_NO,
FAILURE_TO_EXHAUST_BCNR_YES,
FAILURE_TO_EXHAUST_BCNR_NO,
],
},
9: {
SERVICE_BRANCH: [ARMY, NAVY, AIR_FORCE, COAST_GUARD, MARINE_CORPS],
DISCHARGE_YEAR: yearResponses,
DISCHARGE_MONTH: [],
REASON: [
REASON_PTSD,
REASON_TBI,
REASON_SEXUAL_ORIENTATION,
REASON_SEXUAL_ASSAULT,
REASON_UNJUST,
REASON_ERROR,
],
COURT_MARTIAL: [COURT_MARTIAL_NO, NOT_SURE],
PREV_APPLICATION: [YES],
PREV_APPLICATION_YEAR: [
PREV_APPLICATION_AFTER_2014,
PREV_APPLICATION_AFTER_2011,
PREV_APPLICATION_AFTER_2017,
],
PREV_APPLICATION_TYPE: [
PREV_APPLICATION_DRB_DOCUMENTARY,
PREV_APPLICATION_DRB_PERSONAL,
],
},
10: {
SERVICE_BRANCH: [ARMY, NAVY, AIR_FORCE, COAST_GUARD, MARINE_CORPS],
DISCHARGE_YEAR: yearResponses,
DISCHARGE_MONTH: [],
REASON: [
REASON_PTSD,
REASON_TBI,
REASON_SEXUAL_ORIENTATION,
REASON_SEXUAL_ASSAULT,
REASON_ERROR,
REASON_UNJUST,
],
PREV_APPLICATION: [YES],
PREV_APPLICATION_TYPE: [
PREV_APPLICATION_DRB_DOCUMENTARY,
PREV_APPLICATION_DRB_PERSONAL,
PREV_APPLICATION_BCMR,
PREV_APPLICATION_BCNR,
NOT_SURE,
],
},
},
},
REVIEW: {
DISCHARGE_YEAR: yearResponses,
SERVICE_BRANCH: [ARMY, NAVY, AIR_FORCE, COAST_GUARD, MARINE_CORPS],
REASON: [
REASON_PTSD,
REASON_TBI,
REASON_SEXUAL_ORIENTATION,
REASON_SEXUAL_ASSAULT,
REASON_TRANSGENDER,
REASON_ERROR,
REASON_UNJUST,
REASON_DD215_UPDATE_TO_DD214,
],
},
});