Skip to content

Commit

Permalink
Filling in more fields after clarifications
Browse files Browse the repository at this point in the history
  • Loading branch information
sree-cfa committed Dec 8, 2023
1 parent df866e0 commit 7fa6a7f
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 68 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package org.ladocuploader.app.preparers;

import formflow.library.data.Submission;
import formflow.library.pdf.PdfMap;
import formflow.library.pdf.SingleField;
import formflow.library.pdf.SubmissionField;
import formflow.library.pdf.SubmissionFieldPreparer;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;

import static org.ladocuploader.app.utils.SubmissionUtilities.EDUCATION_MAP;

@Component
public class ApplicantDetailsPreparer implements SubmissionFieldPreparer {

@Override
public Map<String, SubmissionField> prepareSubmissionFields(Submission submission, PdfMap pdfMap) {
Map<String, SubmissionField> results = new HashMap<>();

Map<String, Object> inputData = submission.getInputData();

// Convert "who does this apply to" responses to a boolean indicator
Map.of("students[]", "applicantStudentInd",
"nonCitizens[]", "applicantNonCitizenInd",
"homeless[]", "applicantHomelessInd")
.forEach((key, value) -> {
var inputs = (List<String>) inputData.getOrDefault(key, new ArrayList<>());
var ind = inputs != null && inputs.contains("you") ? "Yes" : "No";
results.put(value, new SingleField(value, ind, null));
});

// Format birthday
var birthday = Stream.of("birthMonth", "birthDay", "birthYear")
.map(inputData::get)
.reduce((e, c) -> e + "/" + c)
.get();
results.put("applicantBirthday", new SingleField("applicantBirthdayFormatted", (String) birthday, null));

var educationStatus = inputData.get("highestEducation");
results.put("highestEducation", new SingleField("highestEducationFormatted", EDUCATION_MAP.get(educationStatus), null));

return results;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,12 @@
import java.util.Map;
import java.util.stream.Stream;

import static org.ladocuploader.app.utils.SubmissionUtilities.EDUCATION_MAP;
import static org.ladocuploader.app.utils.SubmissionUtilities.MARITAL_STATUS_MAP;

@Component
public class HouseholdDetailsPreparer implements SubmissionFieldPreparer {

private static final Map<String, String> EDUCATION_MAP = new HashMap<>();
private static final Map<String, String> MARITAL_STATUS_MAP = new HashMap<>();

static {
EDUCATION_MAP.put("firstGrade", "1st grade");
EDUCATION_MAP.put("secondGrade", "2nd grade");
EDUCATION_MAP.put("thirdGrade", "3rd grade");
EDUCATION_MAP.put("fourthGrade", "4th grade");
EDUCATION_MAP.put("fifthGrade", "5th grade");
EDUCATION_MAP.put("sixthGrade", "6th grade");
EDUCATION_MAP.put("seventhGrade", "7th grade");
EDUCATION_MAP.put("eighthGrade", "8th grade");
EDUCATION_MAP.put("ninthGrade", "9th grade");
EDUCATION_MAP.put("tenthGrade", "10th grade");
EDUCATION_MAP.put("eleventhGrade", "11th grade");
EDUCATION_MAP.put("highSchoolOrEquivalent", "High school / GED");
EDUCATION_MAP.put("associatesDegree", "Associate's degree");
EDUCATION_MAP.put("bachelorsDegree", "Bachelor's degree");
EDUCATION_MAP.put("graduateDegree", "Graduate/Master's degree");
EDUCATION_MAP.put("certificateOrDiploma", "Other certificate or diploma");
EDUCATION_MAP.put("noFormalEducation", "None");
EDUCATION_MAP.put("notSure", "Not sure");

MARITAL_STATUS_MAP.put("NeverMarried", "Never Married");
MARITAL_STATUS_MAP.put("MarriedLivingWithSpouse", "Married");
MARITAL_STATUS_MAP.put("MarriedNotLivingWithSpouse", "Married");
MARITAL_STATUS_MAP.put("LegallySeparated", "Separated");
MARITAL_STATUS_MAP.put("Divorced", "Divorced");
MARITAL_STATUS_MAP.put("Widowed", "Widowed");
}

@Override
public Map<String, SubmissionField> prepareSubmissionFields(Submission submission, PdfMap pdfMap) {
Expand All @@ -70,7 +43,7 @@ public Map<String, SubmissionField> prepareSubmissionFields(Submission submissio
var maritalStatus = householdMember.get("householdMaritalStatus");
results.put("householdMaritalStatus" + i, new SingleField("householdMaritalStatusFormatted", MARITAL_STATUS_MAP.get(maritalStatus), i + 1));

var birthday = Stream.of("householdBirthDay", "householdBirthMonth", "householdBirthYear")
var birthday = Stream.of("householdBirthMonth", "householdBirthDay", "householdBirthYear")
.map(householdMember::get)
.reduce((e, c) -> e + "/" + c)
.get();
Expand Down
32 changes: 32 additions & 0 deletions src/main/java/org/ladocuploader/app/utils/SubmissionUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,36 @@

public class SubmissionUtilities {

public static final Map<String, String> EDUCATION_MAP = new HashMap<>();
public static final Map<String, String> MARITAL_STATUS_MAP = new HashMap<>();

static {
EDUCATION_MAP.put("firstGrade", "1st grade");
EDUCATION_MAP.put("secondGrade", "2nd grade");
EDUCATION_MAP.put("thirdGrade", "3rd grade");
EDUCATION_MAP.put("fourthGrade", "4th grade");
EDUCATION_MAP.put("fifthGrade", "5th grade");
EDUCATION_MAP.put("sixthGrade", "6th grade");
EDUCATION_MAP.put("seventhGrade", "7th grade");
EDUCATION_MAP.put("eighthGrade", "8th grade");
EDUCATION_MAP.put("ninthGrade", "9th grade");
EDUCATION_MAP.put("tenthGrade", "10th grade");
EDUCATION_MAP.put("eleventhGrade", "11th grade");
EDUCATION_MAP.put("highSchoolOrEquivalent", "High school / GED");
EDUCATION_MAP.put("associatesDegree", "Associate's degree");
EDUCATION_MAP.put("bachelorsDegree", "Bachelor's degree");
EDUCATION_MAP.put("graduateDegree", "Graduate/Master's degree");
EDUCATION_MAP.put("certificateOrDiploma", "Other certificate or diploma");
EDUCATION_MAP.put("noFormalEducation", "None");
EDUCATION_MAP.put("notSure", "Not sure");

MARITAL_STATUS_MAP.put("NeverMarried", "Never Married");
MARITAL_STATUS_MAP.put("MarriedLivingWithSpouse", "Married");
MARITAL_STATUS_MAP.put("MarriedNotLivingWithSpouse", "Married");
MARITAL_STATUS_MAP.put("LegallySeparated", "Separated");
MARITAL_STATUS_MAP.put("Divorced", "Divorced");
MARITAL_STATUS_MAP.put("Widowed", "Widowed");
}
public static String formatMoney(String value) {
if (value == null) {
return "";
Expand Down Expand Up @@ -105,4 +135,6 @@ public static ArrayList<HashMap<String, Object>> getHouseholdIncomeReviewItems(S

return items;
}


}
7 changes: 4 additions & 3 deletions src/main/resources/pdf-map.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ inputFields:
mailingAddressStreetAddress2: mailingAddressStreetAddress2
mailingAddressStreetAddress1: mailingAddressStreetAddress1
signature: signature

applicantBirthdayFormatted: applicantBirthday
emailAddress: emailAddress
sex: sex
highestEducationFormatted: highestEducation
ethnicitySelected: ethnicitySelected
raceSelected:
American Indian or Alaskan Native: RACE_American Indian or Alaskan Native
Expand All @@ -38,7 +39,7 @@ inputFields:
White: RACE_White
maritalStatus: maritalStatus
applicantStudentInd: applicantStudentInd
applicantCitizenInd: applicantCitizenInd
applicantNonCitizenInd: applicantNonCitizenInd
applicantHomelessInd: applicantHomelessInd

authorizedRepresentative: authorizedRepresentative
Expand All @@ -59,14 +60,14 @@ inputFields:
ssns_6: ssns_6
ssns_7: ssns_7

# TODO add these to PDF
hasDependentCareExpenses: hasDependentCareExpenses
personalSituationDisablityInd: disablityInd
pregnancyInd: pregnancyInd
schoolInd: schoolInd
buyPrepareMealsSeparateIndicator: buyPrepareMealsSeparateIndicator
outOfStateBenefitsInd: outOfStateBenefitsInd
veteranInd: veteranInd
fosterAgedOutInd: fosterAgedOutInd

jobSearch: jobSearch
migrantOrSeasonalFarmWorkerInd: migrantOrSeasonalFarmWorkerInd
Expand Down
Binary file modified src/main/resources/pdfs/la_application_for_assistance.pdf
Binary file not shown.

0 comments on commit 7fa6a7f

Please sign in to comment.