From 56a2dffc7965d0af9ee6561968cf5dd595b3c5a5 Mon Sep 17 00:00:00 2001 From: chibuisienyia Date: Wed, 8 Jan 2025 12:02:06 -0600 Subject: [PATCH] Adds ProviderSSNPreparer and test. --- .../ilgcc/app/pdf/ProviderSSNPreparer.java | 46 +++++++++++++ src/main/resources/pdf-map.yaml | 1 + .../app/pdf/ProviderSSNPreparerTest.java | 67 +++++++++++++++++++ 3 files changed, 114 insertions(+) create mode 100644 src/main/java/org/ilgcc/app/pdf/ProviderSSNPreparer.java create mode 100644 src/test/java/org/ilgcc/app/pdf/ProviderSSNPreparerTest.java diff --git a/src/main/java/org/ilgcc/app/pdf/ProviderSSNPreparer.java b/src/main/java/org/ilgcc/app/pdf/ProviderSSNPreparer.java new file mode 100644 index 000000000..6608dbd37 --- /dev/null +++ b/src/main/java/org/ilgcc/app/pdf/ProviderSSNPreparer.java @@ -0,0 +1,46 @@ +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 ProviderSSNPreparer implements SubmissionFieldPreparer { + + @Autowired + SubmissionRepositoryService submissionRepositoryService; + @Autowired + private ProviderSubmissionUtilities providerSubmissionUtilities; + + @Override + public Map prepareSubmissionFields(Submission familySubmission, PdfMap pdfMap) { + var results = new HashMap(); + Optional providerSubmission = providerSubmissionUtilities.getProviderSubmissionFromId( + submissionRepositoryService, familySubmission); + if (providerSubmission.isEmpty()) { + return results; + } + var providerInputData = providerSubmission.get().getInputData(); + if (providerInputData.containsKey("providerIdentityCheckSSN")) { + results.put("providerSSN", + new SingleField("providerSSN", (String) providerInputData.getOrDefault("providerIdentityCheckSSN", ""), + null)); + }else if(providerInputData.containsKey("providerTaxIdSSN")){ + results.put("providerSSN", + new SingleField("providerSSN", (String) providerInputData.getOrDefault("providerTaxIdSSN", ""), + null)); + }else{ + return results; + } + return results; + } +} diff --git a/src/main/resources/pdf-map.yaml b/src/main/resources/pdf-map.yaml index f62a76317..6e6c8e63a 100644 --- a/src/main/resources/pdf-map.yaml +++ b/src/main/resources/pdf-map.yaml @@ -168,6 +168,7 @@ inputFields: providerConviction: PROVIDER_CONVICTION providerConvictionExplanation: PROVIDER_CONVICTION_EXPLANATION providerIdentityCheckDateOfBirthDate: PROVIDER_DOB + providerSSN: PROVIDER_SSN providerSignature: PROVIDER_SIGNATURE providerSignatureDate: PROVIDER_SIGNATURE_DATE clientResponseConfirmationCode: APPLICATION_CONFIRMATION_CODE diff --git a/src/test/java/org/ilgcc/app/pdf/ProviderSSNPreparerTest.java b/src/test/java/org/ilgcc/app/pdf/ProviderSSNPreparerTest.java new file mode 100644 index 000000000..76ff7df20 --- /dev/null +++ b/src/test/java/org/ilgcc/app/pdf/ProviderSSNPreparerTest.java @@ -0,0 +1,67 @@ +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 ProviderSSNPreparerTest { + + + @Autowired + private ProviderSSNPreparer preparer; + + @Autowired + private SubmissionRepositoryService submissionRepositoryService; + + private Submission familySubmission; + private Submission providerSubmission; + + @Test + public void shouldPrintProviderIdentityCheckSSNToPDFIfPresent() { + providerSubmission = new SubmissionTestBuilder() + .withFlow("providerresponse") + .withProviderSubmissionData() + .with("providerIdentityCheckSSN", "445-32-6666") + .with("providerTaxIdSSN", "555-55-5555") + .build(); + submissionRepositoryService.save(providerSubmission); + + familySubmission = new SubmissionTestBuilder() + .withFlow("gcc") + .with("providerResponseSubmissionId", providerSubmission.getId()) + .build(); + Map result = preparer.prepareSubmissionFields(familySubmission, null); + assertThat(result.get("providerSSN")).isEqualTo(new SingleField("providerSSN", "445-32-6666", null)); + } + @Test + public void shouldPrintProviderTaxIdSSNIfPresent() { + providerSubmission = new SubmissionTestBuilder() + .withFlow("providerresponse") + .withProviderSubmissionData() + .with("providerTaxIdSSN", "444-44-4444") + .build(); + submissionRepositoryService.save(providerSubmission); + + familySubmission = new SubmissionTestBuilder() + .withFlow("gcc") + .with("providerResponseSubmissionId", providerSubmission.getId()) + .build(); + Map result = preparer.prepareSubmissionFields(familySubmission, null); + assertThat(result.get("providerSSN")).isEqualTo(new SingleField("providerSSN", "444-44-4444", null)); + } +}