-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
5 changed files
with
270 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
179 changes: 179 additions & 0 deletions
179
src/test/java/org/ilgcc/app/pdf/ProviderTypePreparerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.