Closed Dr-Pongo closed 1 year ago
Dan Path Minimal Submission Object
{
"personalIdentification": {
"ssn": "4437",
"fileNumber": "4437",
"fsrReason": ""
},
"personalData": {
"veteranFullName": {
"first": "Dan",
"middle": "",
"last": "Path"
},
"address": {
"addresslineOne": "1200 Park Ave",
"addresslineTwo": "c/o Pixar",
"addresslineThree": "",
"city": "Emeryville",
"stateOrProvince": "CA",
"zipOrPostalCode": "94608",
"countryName": "US"
},
"telephoneNumber": "(510) 922-4444",
"dateOfBirth": "10/04/1950",
"married": false,
"spouseFullName": {
"first": "",
"middle": "",
"last": ""
},
"agesOfOtherDependents": [
"12"
],
"employmentHistory": [
{
"veteranOrSpouse": "VETERAN",
"occupationName": "Full time",
"from": "03/2020",
"to": "",
"present": true,
"employerName": "Dan's Wizard Hole",
"employerAddress": {
"addresslineOne": "",
"addresslineTwo": "",
"addresslineThree": "",
"city": "",
"stateOrProvince": "",
"zipOrPostalCode": "",
"countryName": ""
}
}
]
},
"income": [
{
"veteranOrSpouse": "VETERAN",
"monthlyGrossSalary": "3313.00",
"deductions": {
"taxes": "853.50",
"retirement": "0.00",
"socialSecurity": "0.00",
"otherDeductions": {
"name": "",
"amount": "0.00"
}
},
"totalDeductions": "853.50",
"netTakeHomePay": "2459.50",
"otherIncome": {
"name": "",
"amount": "0.00"
},
"totalMonthlyNetIncome": "2459.50"
},
{
"veteranOrSpouse": "SPOUSE",
"monthlyGrossSalary": "0.00",
"deductions": {
"taxes": "0.00",
"retirement": "0.00",
"socialSecurity": "0.00",
"otherDeductions": {
"name": "",
"amount": "0.00"
}
},
"totalDeductions": "0.00",
"netTakeHomePay": "0.00",
"otherIncome": {
"name": "",
"amount": "0.00"
},
"totalMonthlyNetIncome": "0.00"
}
],
"expenses": {
"rentOrMortgage": "0.00",
"food": "0.00",
"utilities": "0.00",
"otherLivingExpenses": {
"name": "",
"amount": "0.00"
},
"expensesInstallmentContractsAndOtherDebts": "0.00",
"totalMonthlyExpenses": "0.00"
},
"discretionaryIncome": {
"netMonthlyIncomeLessExpenses": "2459.50",
"amountCanBePaidTowardDebt": "0.00"
},
"assets": {
"cashInBank": "500.00",
"cashOnHand": "0.00",
"usSavingsBonds": "0.00",
"stocksAndOtherBonds": "0.00",
"realEstateOwned": "0.00",
"totalAssets": "500.00"
},
"installmentContractsAndOtherDebts": [],
"totalOfInstallmentContractsAndOtherDebts": {
"originalAmount": "0.00",
"unpaidBalance": "0.00",
"amountDueMonthly": "0.00",
"amountPastDue": "0.00"
},
"additionalData": {
"bankruptcy": {}
},
"applicantCertifications": {
"veteranSignature": "Mark Webb",
"veteranDateSigned": "07/25/2023"
},
"selectedDebtsAndCopays": [
{
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"pSSeqNum": "1.00",
"pSTotSeqNum": "1.00",
"pSFacilityNum": "757",
"pSFacPhoneNum": null,
"pSTotStatement": "3.00",
"pSStatementVal": "0000037953E",
"pSStatementDate": "05242023",
"pSStatementDateOutput": "05/24/2023",
"pSProcessDate": "12102020",
"pSProcessDateOutput": "12/10/2020",
"pHPatientLstNme": "HHUFHYULSEHU",
"pHPatientFstNme": "CDAA",
"pHPatientMidNme": "A",
"pHAddress1": "7780 RED MAPLE CT",
"pHAddress2": null,
"pHAddress3": null,
"pHCity": "HUBER HEIGHTS",
"pHState": "OH",
"pHZipCde": "45424",
"pHZipCdeOutput": "45424",
"pHCtryNme": null,
"pHAmtDue": "105.24",
"pHAmtDueOutput": "105.24 ",
"pHPrevBal": "103.21",
"pHPrevBalOutput": "103.21 ",
"pHTotCharges": "2.03",
"pHTotChargesOutput": "2.03 ",
"pHTotCredits": "0.00",
"pHTotCreditsOutput": ".00 ",
"pHNewBalance": "105.24",
"pHNewBalanceOutput": "105.24 ",
"pHSpecialNotes": null,
"pHroParaCdes": "0125304050556065708085",
"pHNumOfLines": "2.00",
"pHDfnNumber": "197750.00",
"pHCernerStatementNumber": "0.00",
"pHCernerPatientId": " ",
"pHCernerAccountNumber": " ",
"pHIcnNumber": " ",
"pHAccountNumber": "7570000000197750.00",
"pHLargeFontIndcator": "0.00",
"details": [
{
"pDDatePosted": null,
"pDDatePostedOutput": "",
"pDTransDesc": "INTEREST/ADM. CHARGE (Int:0.10 Adm:1.93 Other:0.00",
"pDTransDescOutput": "INTEREST/ADM. CHARGE (Int:0.10 Adm:1.93 Other:0.00",
"pDTransAmt": "2.03",
"pDTransAmtOutput": "2.03 ",
"pDRefNo": null
},
{
"pDDatePosted": null,
"pDDatePostedOutput": "",
"pDTransDesc": "Please refer to previous statement of rights.",
"pDTransDescOutput": " Please refer to previous statement of rights.",
"pDTransAmt": "0.00",
"pDTransAmtOutput": ".00 ",
"pDRefNo": null
}
],
"station": {
"facilitYNum": "757",
"visNNum": "10",
"facilitYDesc": "CHALMERS P WYLIE VA ACC (757)",
"cyclENum": "004",
"remiTToFlag": "L",
"maiLInsertFlag": "0",
"staTAddress1": "420 N JAMES RD",
"staTAddress2": null,
"staTAddress3": null,
"city": "Columbus",
"state": "OH",
"ziPCde": "432191834",
"ziPCdeOutput": "43219-1834",
"baRCde": "*432191834203*",
"teLNumFlag": "S",
"teLNum": "1-866-812-0318",
"teLNum2": null,
"contacTInfo": null,
"dM2TelNum": null,
"contacTInfo2": null,
"toPTelNum": null,
"lbXFedexAddress1": null,
"lbXFedexAddress2": null,
"lbXFedexAddress3": null,
"lbXFedexCity": null,
"lbXFedexState": null,
"lbXFedexZipCde": null,
"lbXFedexBarCde": null,
"lbXFedexContact": null,
"lbXFedexContactTelNum": null,
"facilityName": "Chalmers P. Wylie Veterans Outpatient Clinic"
},
"debtType": "COPAY"
}
],
"streamlined": {
"value": true,
"type": "short"
}
}
Link to draft PR with saved objects:
https://github.com/department-of-veterans-affairs/vets-website/pull/24979/files
We landed on the convention: long and short for the naming convention
{
"streamlined": {
"value": true,
"type": "short"
},
"streamlined": {
"value": false,
"type": "long"
}
}
We need to make a few adjustments to allow the short forms to make it through our data transform.
Large function: The transform function is quite large and does a lot of things. It would be more maintainable to break it down into smaller, more focused functions. Each function should do one thing and do it well.
Destructuring and default values: The code is destructuring form data and providing default values at the same time. While this is not necessarily a bad practice, it can lead to confusion when the structure of the form data is complex.
Maybe it might be clearer to separate these two operations?
Error handling: It appears that there are instances where the code is trying to read properties of undefined, which I resolved in the PR but this likely means that the data structure is not always consistent. To improve this, you can add null checks or use optional chaining (e.g., someObj?.someProp
) to prevent runtime errors.
Repeated patterns: There are repeated patterns in the code, like filtering and summing values. These could be extracted into separate helper functions to reduce duplication.
One possible way to improve the readability of the transform could be through reusable modules and separation of concerns. However, when I attempted this, I ultimately reverted back to the current method, as it seemed less readable in my opinion.
here's en example I was exploring:
function calculateGrossSalary(isEnhancedFSRActive, employmentRecords, grossSalaryField) {
return isEnhancedFSRActive
? sumValues(employmentRecords, 'grossMonthlyIncome')
: sumValues(grossSalaryField, 'grossSalary');
}
function calculateAdditionalIncome(addlIncRecords) {
return sumValues(addlIncRecords, 'amount');
}
function calculateSocialSecAmt(isEnhancedFSRActive, socialSecurity) {
return !isEnhancedFSRActive
? Number(socialSecurity.socialSecAmt?.replaceAll(/[^0-9.-]/g, '') ?? 0)
: 0;
}
function calculateBenefits(income) {
const comp = sumValues(income, 'compensationAndPension');
const edu = sumValues(income, 'education');
return comp + edu;
}
function calculateDeductions(isEnhancedFSRActive, employmentRecords, currEmployment) {
return isEnhancedFSRActive
? employmentRecords
?.filter(emp => emp.isCurrent)
.map(emp => emp.deductions)
.flat() ?? 0
: currEmployment?.map(emp => emp.deductions).flat() ?? 0;
}
// veteran
const vetGrossSalary = calculateGrossSalary(enhancedFSRActive, employmentRecords, currEmployment);
const vetAddlInc = calculateAdditionalIncome(addlIncRecords);
const vetSocSecAmt = calculateSocialSecAmt(enhancedFSRActive, socialSecurity);
const vetBenefits = calculateBenefits(income);
const vetDeductions = calculateDeductions(enhancedFSRActive, employmentRecords, currEmployment);
// spouse
const spGrossSalary = calculateGrossSalary(enhancedFSRActive, spEmploymentRecords, spCurrEmployment);
const spAddlInc = calculateAdditionalIncome(spAddlIncome);
const spSocialSecAmt = calculateSocialSecAmt(enhancedFSRActive, socialSecurity.spouse);
const spBenefits = calculateBenefits(benefits.spouseBenefits);
const spDeductions = calculateDeductions(enhancedFSRActive, spEmploymentRecords, spCurrEmployment);
Issue Description
Since streamlined is cutting off some of the form, we need to create examples of submission objects for the different routes so BE can adjust the required fields. Let's see if we can work out specific flags for each path? that way we have established expectations for each and it will hopefully make troubleshooting any problems easier.
Tasks
Acceptance Criteria
[x] BE has submission examples for new SW flow.
How to configure this issue
product support
,analytics-insights
,operations
,service-design
,Console-Services
,tools-fe
)backend
,frontend
,devops
,design
,research
,product
,ia
,qa
,analytics
,contact center
,research
,accessibility
,content
)bug
,request
,discovery
,documentation
, etc.)