Skip to content

Commit

Permalink
[CCAP-484] Print Provider Type to PDF (#902)
Browse files Browse the repository at this point in the history
  • Loading branch information
enyia21 authored Dec 16, 2024
1 parent dfec592 commit e562fd1
Show file tree
Hide file tree
Showing 5 changed files with 270 additions and 0 deletions.
80 changes: 80 additions & 0 deletions src/main/java/org/ilgcc/app/pdf/ProviderTypePreparer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package org.ilgcc.app.pdf;

import formflow.library.data.Submission;
import formflow.library.data.SubmissionRepositoryService;
import formflow.library.pdf.PdfMap;
import formflow.library.pdf.SingleField;
import formflow.library.pdf.SubmissionField;
import formflow.library.pdf.SubmissionFieldPreparer;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import org.ilgcc.app.utils.ProviderSubmissionUtilities;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


@Component
public class ProviderTypePreparer implements SubmissionFieldPreparer {
@Autowired
SubmissionRepositoryService submissionRepositoryService;
@Autowired
private ProviderSubmissionUtilities providerSubmissionUtilities;

@Override
public Map<String, SubmissionField> prepareSubmissionFields(Submission familySubmission, PdfMap pdfMap) {
var results = new HashMap<String, SubmissionField>();
Optional<Submission> providerSubmission = providerSubmissionUtilities.getProviderSubmissionFromId(submissionRepositoryService, familySubmission);
if (providerSubmission.isEmpty()) {
return results;
}

var providerInputData = providerSubmission.get().getInputData();

String providerCurrentlyLicensed = (String) providerInputData.getOrDefault("providerCurrentlyLicensed", "");
if(providerCurrentlyLicensed.equals("true")) {
String providerLicensedCareLocation = (String) providerInputData.getOrDefault("providerLicensedCareLocation", "");
switch (providerLicensedCareLocation) {
case "childCareCenter":
results.put("providerType", new SingleField("providerType", "LICENSED_DAY_CARE_CENTER_760", null));
break;
case "childCareHome":
results.put("providerType", new SingleField("providerType", "LICENSED_DAY_CARE_HOME_762", null));
break;
case "groupChildCareHome":
results.put("providerType", new SingleField("providerType", "LICENSED_GROUP_DAY_CARE_HOME_763", null));
break;
default:
break;
}
}

if(providerCurrentlyLicensed.equals("false")){
String providerLicenseExemptType = (String) providerInputData.getOrDefault("providerLicenseExemptType", "");
if (providerLicenseExemptType.equals("License-exempt")) {
results.put("providerType", new SingleField("providerType", "DAY_CARE_CENTER_EXEMPT_FROM_LICENSING_761", null));
}

if (providerLicenseExemptType.equals("Self")) {
String providerLicenseExemptCareLocation = (String) providerInputData.getOrDefault("providerLicenseExemptCareLocation", "");
String providerLicenseExemptRelationship = (String) providerInputData.getOrDefault("providerLicenseExemptRelationship", "");

if(providerLicenseExemptCareLocation.equals("Providers home")) {
if(providerLicenseExemptRelationship.equals("Relative")) {
results.put("providerType", new SingleField("providerType", "CARE_BY_RELATIVE_IN_CHILD_CARE_PROVIDERS_HOME_765", null));
}else{
results.put("providerType", new SingleField("providerType", "CARE_BY_NON_RELATIVE_IN_CHILD_CARE_PROVIDERS_HOME_764", null));
}
}
if(providerLicenseExemptCareLocation.equals("Childs home")){
if(providerLicenseExemptRelationship.equals("Relative")) {
results.put("providerType", new SingleField("providerType", "CARE_BY_RELATIVE_IN_CHILDS_HOME_767", null));
}else{
results.put("providerType", new SingleField("providerType", "CARE_BY_NON_RELATIVE_IN_CHILDS_HOME_766", null));
}
}
}
}
return results;
}
}
10 changes: 10 additions & 0 deletions src/main/java/org/ilgcc/app/utils/ProviderSubmissionUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static org.ilgcc.app.utils.SubmissionUtilities.MM_DD_YYYY;

import formflow.library.data.Submission;
import formflow.library.data.SubmissionRepositoryService;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.OffsetDateTime;
Expand Down Expand Up @@ -181,4 +182,13 @@ public static boolean providerApplicationHasExpired(Submission submission, Zoned
MINUTES.between(ProviderSubmissionUtilities.threeBusinessDaysFromSubmittedAtDate(submission.getSubmittedAt()),
todaysDate) > 0;
}
public Optional<Submission> getProviderSubmissionFromId(SubmissionRepositoryService submissionRepositoryService,
Submission submission) {
if (submission.getInputData().containsKey("providerResponseSubmissionId")) {
UUID providerId = UUID.fromString(submission.getInputData().get("providerResponseSubmissionId").toString());
return submissionRepositoryService.findById(providerId);
}

return Optional.empty();
}
}
1 change: 1 addition & 0 deletions src/main/resources/pdf-map.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ inputFields:
providerLicenseNumber: PROVIDER_LICENSE_NUMBER
providerSignature: PROVIDER_SIGNATURE
providerSignatureDate: PROVIDER_SIGNATURE_DATE
providerType: PROVIDER_TYPE
clientResponseConfirmationCode: APPLICATION_CONFIRMATION_CODE

dayCareName: PROVIDER_NAME_CORPORATE
Expand Down
179 changes: 179 additions & 0 deletions src/test/java/org/ilgcc/app/pdf/ProviderTypePreparerTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
package org.ilgcc.app.pdf;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;

import formflow.library.data.Submission;
import formflow.library.data.SubmissionRepositoryService;
import formflow.library.pdf.SingleField;
import formflow.library.pdf.SubmissionField;
import java.util.Map;
import org.ilgcc.app.IlGCCApplication;
import org.ilgcc.app.utils.SubmissionTestBuilder;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;

@SpringBootTest(
classes = IlGCCApplication.class,
properties = "il-gcc.dts.expand-existing-provider-flow=true"
)
@ActiveProfiles("test")
public class ProviderTypePreparerTest {


@Autowired
private ProviderTypePreparer preparer;

@Autowired
private SubmissionRepositoryService submissionRepositoryService;

private Submission familySubmission;
private Submission providerSubmission;

@Test
public void shouldSelectLicensedDayCareCenter(){
providerSubmission = new SubmissionTestBuilder()
.withFlow("providerresponse")
.withProviderSubmissionData()
.with("providerCurrentlyLicensed","true")
.with("providerLicensedCareLocation", "childCareCenter")
.build();
submissionRepositoryService.save(providerSubmission);

familySubmission = new SubmissionTestBuilder()
.withFlow("gcc")
.with("providerResponseSubmissionId", providerSubmission.getId())
.build();
Map<String, SubmissionField> result = preparer.prepareSubmissionFields(familySubmission, null);
assertThat(result.get("providerType")).isEqualTo(new SingleField("providerType", "LICENSED_DAY_CARE_CENTER_760", null));
}
@Test
public void shouldSelectLicensedDayCareHome(){
providerSubmission = new SubmissionTestBuilder()
.withFlow("providerresponse")
.withProviderSubmissionData()
.with("providerCurrentlyLicensed","true")
.with("providerLicensedCareLocation", "childCareHome")
.build();
submissionRepositoryService.save(providerSubmission);

familySubmission = new SubmissionTestBuilder()
.withFlow("gcc")
.with("providerResponseSubmissionId", providerSubmission.getId())
.build();
Map<String, SubmissionField> result = preparer.prepareSubmissionFields(familySubmission, null);
assertThat(result.get("providerType")).isEqualTo(new SingleField("providerType", "LICENSED_DAY_CARE_HOME_762", null));
}
@Test
public void shouldSelectLicensedGroupDayCare(){
providerSubmission = new SubmissionTestBuilder()
.withFlow("providerresponse")
.withProviderSubmissionData()
.with("providerCurrentlyLicensed","true")
.with("providerLicensedCareLocation", "groupChildCareHome")
.build();
submissionRepositoryService.save(providerSubmission);

familySubmission = new SubmissionTestBuilder()
.withFlow("gcc")
.with("providerResponseSubmissionId", providerSubmission.getId())
.build();
Map<String, SubmissionField> result = preparer.prepareSubmissionFields(familySubmission, null);
assertThat(result.get("providerType")).isEqualTo(new SingleField("providerType", "LICENSED_GROUP_DAY_CARE_HOME_763", null));
}
@Test
public void shouldSelectDayCareCenterExemptFromLicensing(){
providerSubmission = new SubmissionTestBuilder()
.withFlow("providerresponse")
.withProviderSubmissionData()
.with("providerCurrentlyLicensed","false")
.with("providerLicenseExemptType", "License-exempt")
.build();
submissionRepositoryService.save(providerSubmission);

familySubmission = new SubmissionTestBuilder()
.withFlow("gcc")
.with("providerResponseSubmissionId", providerSubmission.getId())
.build();
Map<String, SubmissionField> result = preparer.prepareSubmissionFields(familySubmission, null);
assertThat(result.get("providerType")).isEqualTo(new SingleField("providerType", "DAY_CARE_CENTER_EXEMPT_FROM_LICENSING_761", null));
}

@Test
public void shouldSelectCareByRelativeInChildCareProvidersHome(){
providerSubmission = new SubmissionTestBuilder()
.withFlow("providerresponse")
.withProviderSubmissionData()
.with("providerCurrentlyLicensed","false")
.with("providerLicenseExemptType", "Self")
.with("providerLicenseExemptCareLocation", "Providers home")
.with("providerLicenseExemptRelationship", "Relative")
.build();
submissionRepositoryService.save(providerSubmission);

familySubmission = new SubmissionTestBuilder()
.withFlow("gcc")
.with("providerResponseSubmissionId", providerSubmission.getId())
.build();
Map<String, SubmissionField> result = preparer.prepareSubmissionFields(familySubmission, null);
assertThat(result.get("providerType")).isEqualTo(new SingleField("providerType", "CARE_BY_RELATIVE_IN_CHILD_CARE_PROVIDERS_HOME_765", null));
}
@Test
public void shouldSelectCareByNonRelativeInChildCareProvidersHome(){
providerSubmission = new SubmissionTestBuilder()
.withFlow("providerresponse")
.withProviderSubmissionData()
.with("providerCurrentlyLicensed","false")
.with("providerLicenseExemptType", "Self")
.with("providerLicenseExemptCareLocation", "Providers home")
.with("providerLicenseExemptRelationship", "Not related")
.build();
submissionRepositoryService.save(providerSubmission);

familySubmission = new SubmissionTestBuilder()
.withFlow("gcc")
.with("providerResponseSubmissionId", providerSubmission.getId())
.build();
Map<String, SubmissionField> result = preparer.prepareSubmissionFields(familySubmission, null);
assertThat(result.get("providerType")).isEqualTo(new SingleField("providerType", "CARE_BY_NON_RELATIVE_IN_CHILD_CARE_PROVIDERS_HOME_764", null));
}
@Test
public void shouldSelectCareByRelativeInChildsHome(){
providerSubmission = new SubmissionTestBuilder()
.withFlow("providerresponse")
.withProviderSubmissionData()
.with("providerCurrentlyLicensed","false")
.with("providerLicenseExemptType", "Self")
.with("providerLicenseExemptCareLocation", "Childs home")
.with("providerLicenseExemptRelationship", "Relative")
.build();
submissionRepositoryService.save(providerSubmission);

familySubmission = new SubmissionTestBuilder()
.withFlow("gcc")
.with("providerResponseSubmissionId", providerSubmission.getId())
.build();
Map<String, SubmissionField> result = preparer.prepareSubmissionFields(familySubmission, null);
assertThat(result.get("providerType")).isEqualTo(new SingleField("providerType", "CARE_BY_RELATIVE_IN_CHILDS_HOME_767", null));
}
@Test
public void shouldSelectCareByNonRelativeInChildsHome(){
providerSubmission = new SubmissionTestBuilder()
.withFlow("providerresponse")
.withProviderSubmissionData()
.with("providerCurrentlyLicensed","false")
.with("providerLicenseExemptType", "Self")
.with("providerLicenseExemptCareLocation", "Childs home")
.with("providerLicenseExemptRelationship", "Not related")
.build();
submissionRepositoryService.save(providerSubmission);

familySubmission = new SubmissionTestBuilder()
.withFlow("gcc")
.with("providerResponseSubmissionId", providerSubmission.getId())
.build();
Map<String, SubmissionField> result = preparer.prepareSubmissionFields(familySubmission, null);
assertThat(result.get("providerType")).isEqualTo(new SingleField("providerType", "CARE_BY_NON_RELATIVE_IN_CHILDS_HOME_766", null));
}
}
Binary file modified src/test/resources/output/test_filled_ccap.pdf
Binary file not shown.

0 comments on commit e562fd1

Please sign in to comment.