Skip to content

Commit

Permalink
[CCAP-385] - map additional inputs (#770)
Browse files Browse the repository at this point in the history
  • Loading branch information
analoo authored Nov 6, 2024
1 parent 05802e1 commit af4f558
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 9 deletions.
30 changes: 23 additions & 7 deletions src/main/java/org/ilgcc/app/pdf/ProviderApplicationPreparer.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,13 @@ public Map<String, SubmissionField> prepareSubmissionFields(Submission submissio

private Map<String, SubmissionField> prepareSubmittedDayCareData(Submission submission) {
var results = new HashMap<String, SubmissionField>();
var inputData = submission.getInputData();
Map<String, Object> inputData = submission.getInputData();
boolean hasProviderResponse = inputData.containsKey("providerResponseSubmissionId");
List<String> providerFields = List.of(
"providerResponseProviderNumber",
"providerResponseFirstName",
"providerResponseLastName",
"providerResponseBusinessName",
"providerResponseServiceStreetAddress1",
"providerResponseServiceStreetAddress2",
"providerResponseServiceCity",
"providerResponseServiceState",
"providerResponseServiceZipCode",
"providerResponseContactPhoneNumber",
"providerResponseContactEmail"
);
Expand All @@ -74,6 +70,8 @@ private Map<String, SubmissionField> prepareSubmittedDayCareData(Submission subm
new SingleField(fieldName, providerInputData.getOrDefault(fieldName, "").toString(), null));
}

results.putAll(prepareProviderAddressData(providerInputData));

results.put("providerSignature",
new SingleField("providerSignature", providerSignature(providerInputData), null));
try {
Expand Down Expand Up @@ -112,7 +110,6 @@ private Map<String, SubmissionField> prepareSubmittedDayCareData(Submission subm
new SingleField("providerResponse", "No response from provider", null));
}


return results;
}

Expand All @@ -132,6 +129,25 @@ private Map<String, SubmissionField> prepareSelectedDayCareData(Submission submi
return results;
}

private Map<String, SubmissionField> prepareProviderAddressData(Map<String, Object> inputData) {
var results = new HashMap<String, SubmissionField>();
var useSuggestedParentAddress = inputData.getOrDefault("useSuggestedProviderAddress", "false").equals("true");

String mailingAddressStreet1 = useSuggestedParentAddress ? "providerResponseServiceStreetAddress1_validated" : "providerResponseServiceStreetAddress1";
String mailingAddressStreet2 = useSuggestedParentAddress ? "" : "providerResponseServiceStreetAddress2";
String mailingCity = useSuggestedParentAddress ? "providerResponseServiceCity_validated" : "providerResponseServiceCity";
String mailingState = useSuggestedParentAddress ? "providerResponseServiceState_validated" : "providerResponseServiceState";
String mailingZipCode = useSuggestedParentAddress ? "providerResponseServiceZipCode_validated" : "providerResponseServiceZipCode";

results.put("providerResponseServiceStreetAddress1", new SingleField("providerResponseServiceStreetAddress1", inputData.getOrDefault(mailingAddressStreet1, "").toString(), null));
results.put("providerResponseServiceStreetAddress2", new SingleField("providerResponseServiceStreetAddress2", inputData.getOrDefault(mailingAddressStreet2, "").toString(), null));
results.put("providerResponseServiceCity", new SingleField("providerResponseServiceCity", inputData.getOrDefault(mailingCity, "").toString(), null));
results.put("providerResponseServiceState", new SingleField("providerResponseServiceState", inputData.getOrDefault(mailingState, "").toString(), null));
results.put("providerResponseServiceZipCode", new SingleField("providerResponseServiceZipCode", inputData.getOrDefault(mailingZipCode, "").toString(), null));

return results;
}

private String providerSignature(Map<String, Object> providerInputData) {
String firstname = (String) providerInputData.getOrDefault("providerResponseFirstName", "");
String lastName = (String) providerInputData.getOrDefault("providerResponseLastName", "");
Expand Down
3 changes: 1 addition & 2 deletions src/main/resources/pdf-map.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ inputFields:
partnerSignedAt: PARTNER_SIGNATURE_DATE
receivedTimestamp: RECEIVED_TIMESTAMP



providerResponseProviderNumber: PROVIDER_ID_NUMBER
providerNameCorporate: PROVIDER_NAME_CORPORATE
providerPhoneNumber: PROVIDER_PHONE_NUMBER
providerEmail: PROVIDER_EMAIL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,65 @@ public void setsProviderInputtedDataWhenProviderResponds() {
assertThat(result.get("dayCareAddressZip")).isEqualTo(null);
}

@Test
public void setsValidatedAddressWhenSelected() {
providerSubmission = new SubmissionTestBuilder()
.withFlow("providerresponse")
.withProviderSubmissionData()
.with("providerResponseAgreeToCare", "true")
.with("useSuggestedProviderAddress", "true")
.with("providerResponseServiceStreetAddress1_validated", "123 Main Street")
.with("providerResponseServiceCity_validated", "De Kalb")
.with("providerResponseServiceState_validated", "IL")
.with("providerResponseServiceZipCode_validated", "60112-1234")
.build();

submissionRepositoryService.save(providerSubmission);

familySubmission = new SubmissionTestBuilder()
.withFlow("gcc")
.withDayCareProvider()
.withSubmittedAtDate(OffsetDateTime.now())
.with("familyIntendedProviderName", "ProviderName")
.with("familyIntendedProviderPhoneNumber", "(125) 785-67896")
.with("familyIntendedProviderEmail", "[email protected]")
.with("providerResponseSubmissionId", providerSubmission.getId())

.build();

Map<String, SubmissionField> result = preparer.prepareSubmissionFields(familySubmission, null);
assertThat(result.get("providerNameCorporate")).isNull();

assertThat(result.get("providerResponseFirstName")).isEqualTo(
new SingleField("providerResponseFirstName", "Provider", null));
assertThat(result.get("providerResponseLastName")).isEqualTo(
new SingleField("providerResponseLastName", "LastName", null));
assertThat(result.get("providerResponseBusinessName")).isEqualTo(
new SingleField("providerResponseBusinessName", "DayCare Place", null));
assertThat(result.get("providerResponseServiceStreetAddress1")).isEqualTo(
new SingleField("providerResponseServiceStreetAddress1", "123 Main Street", null));
assertThat(result.get("providerResponseServiceStreetAddress2")).isEqualTo(
new SingleField("providerResponseServiceStreetAddress2", "", null));
assertThat(result.get("providerResponseServiceCity")).isEqualTo(
new SingleField("providerResponseServiceCity", "De Kalb", null));
assertThat(result.get("providerResponseServiceState")).isEqualTo(
new SingleField("providerResponseServiceState", "IL", null));
assertThat(result.get("providerResponseServiceZipCode")).isEqualTo(
new SingleField("providerResponseServiceZipCode", "60112-1234", null));
assertThat(result.get("providerResponseContactPhoneNumber")).isEqualTo(
new SingleField("providerResponseContactPhoneNumber", "(111) 222-3333", null));
assertThat(result.get("providerResponseContactEmail")).isEqualTo(
new SingleField("providerResponseContactEmail", "[email protected]", null));

assertThat(result.get("dayCareName")).isEqualTo(null);
assertThat(result.get("dayCareIdNumber")).isEqualTo(null);
assertThat(result.get("dayCareAddressStreet")).isEqualTo(null);
assertThat(result.get("dayCareAddressApt")).isEqualTo(null);
assertThat(result.get("dayCareAddressCity")).isEqualTo(null);
assertThat(result.get("dayCareAddressState")).isEqualTo(null);
assertThat(result.get("dayCareAddressZip")).isEqualTo(null);
}

@Test
public void setsNoProviderInputtedDataWhenProviderResponseCannotBeFound() {
providerSubmission = new SubmissionTestBuilder()
Expand Down

0 comments on commit af4f558

Please sign in to comment.