From 64e2e1dc49e5a8cccb0f44de574840a024de4411 Mon Sep 17 00:00:00 2001 From: Ana Medrano Fernandez Date: Fri, 5 Apr 2024 15:07:51 -0700 Subject: [PATCH 1/4] Write tca signature only if tca application --- .../app/preparers/ApplicantNeedsPreparer.java | 10 +- src/main/resources/pdf-map.yaml | 2 + src/main/resources/pdfs/9701.pdf | Bin 1503322 -> 1509777 bytes .../preparers/ApplicantNeedsPreparerTest.java | 94 ++++++++++++++++++ 4 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 src/test/java/org/mdbenefits/app/preparers/ApplicantNeedsPreparerTest.java diff --git a/src/main/java/org/mdbenefits/app/preparers/ApplicantNeedsPreparer.java b/src/main/java/org/mdbenefits/app/preparers/ApplicantNeedsPreparer.java index a35647c7..40c3b573 100644 --- a/src/main/java/org/mdbenefits/app/preparers/ApplicantNeedsPreparer.java +++ b/src/main/java/org/mdbenefits/app/preparers/ApplicantNeedsPreparer.java @@ -28,10 +28,16 @@ public Map prepareSubmissionFields(Submission submissio results.put("needsSNAP", new SingleField("needsSNAP", String.valueOf(programs.contains("SNAP")), null)); - boolean needsCash = programs.contains("TDAP") || programs.contains("TCA") || programs.contains("RCA"); + boolean needsCash = programs.contains("TDAP") || programs.contains("RCA"); + boolean needsTCA = programs.contains("TCA"); results.put("needsCashAssistance", - new SingleField("needsCashAssistance", String.valueOf(needsCash), null)); + new SingleField("needsCashAssistance", String.valueOf(needsCash || needsTCA), null)); + + if(needsTCA){ + results.put("tcaSignature", new SingleField("tcaSignature", inputData.getOrDefault("signature", "").toString(), null)); + results.put("tcaSubmissionData", new SingleField("tcaSubmissionData", inputData.getOrDefault("submittedAt", "").toString(), null)); + } return results; } diff --git a/src/main/resources/pdf-map.yaml b/src/main/resources/pdf-map.yaml index e860ff34..45de1881 100644 --- a/src/main/resources/pdf-map.yaml +++ b/src/main/resources/pdf-map.yaml @@ -43,6 +43,8 @@ inputFields: needsCashAssistance: applicant_needs_cash_assistance needsSNAP: applicant_needs_snap signature: applicant_signature + tcaSignature: tca_applicant_signature + tcaSubmissionData: tca_date_submitted householdHasDisability: household_disability_bool householdHasDisabilitySeeCover: hhmember_disability_see_cover householdHasPregnancy: household_pregnancy_bool diff --git a/src/main/resources/pdfs/9701.pdf b/src/main/resources/pdfs/9701.pdf index 67b7b5ebdb2b9e5828e20635c5de187a028c07ec..2b0ac9e87be486edf40c960c6e6ef08195be252c 100644 GIT binary patch delta 1047 zcmcchAbR5Dn1&X{7N!>F7M2#)7Pc1l7LFFq7OocV7M>Q~7QPn#7J(MQ7NHj57LgXw zEn-n0wsRMYPGk}=(KRp)F*LO@Ftjo?)-^DnzNS>PiWfz6dLa{=`}C?Z(S0h(DTzjw zhUP}P1}VvDx+aMxiMmOqhN-$nsfH#gmd1%DCPr!7W6DL@IH&&(;0>4_8pu1F$Hc(Y z(A2;XV*L3AQ6omf$&Aselh;q-VluIu?08akW8zL$dAsSi=PSVEmSnySAK zU*G-r=jVSW9)_KVGY(HKydcVGHhJSkU1mcggXxUPjI#Ax3`{}|0yb>CSYCML!gr6e zn#`Y^E{X7b(a}BAu%xlkvctqET*K@7m2&Qj{3|bfKj)*_XJ%qz%&5g1WME>>Vx08V z*+ht&tH@}w@Mo__-Nu(c3we8W2bq3#b~07^>)b5TWPA6ojI&d7jOp7q3_yoG@sNMX zo0^wWTvC*pm^-=p0{7$%nfi>DlNHa&)|>QPwbR^_%aa-G{%=E#~NzIHS;K=q($w>K|(g+oQC|*Gb3Lp4cig%Wu2cw8)9P zpZFUB+;S(XbBZ;aZTn!oKLW&!iew35Li{hex0QW->FLtSF&8`N0fu)I7|TsTb)w&2`8?fT2FM|E=on zmL-M)Os!EYf=k?NI;PkqX=aGt>H4?#quCiA@k!bz4n*m6vzR~p#x}2Uznl58h{hwQ z7XN>cm%X-l2m9jWRU7$i=PnKMd46DO;-P{7?SoS;9Pm9?q^w^NVfD+7dET-_o))`> z`*Pc+-FmjQs?ID%^WQZT%25-T}{kf4K1DA3{A}}4b4m}%uG$44ees}J@ZmhE20ezjEofw6%5TR zEJ2iop(&6uF)=p+QD(*lV9Fds85)^@B@Ims%?uPwK?bDd1JwW}4HSa(eNyw%OEMHp zE%XD5QtQhUfQj75+|WorC_ldhXrP%XSXFRlRjLBW1XKNx%7Rq=h@jLo{qSf*1!Dz+ zSUWpNO5)|pxR;b9@>}5Oksqi2vI{daAFk*482={1X2Q`MtW!2jVJhn1Ze(b%DY`i& qpMg`2b;6tQ1_ow^r|x`~kn}kHd6B3%uc?8hvAG$qs;aBM8!rGj28#s% delta 53 zcmV~$$q_^V006LA_kB|wit$JTMk}iEQi2jTIj{YBx5G~$6p1BLnOvb%sWn=i-e5GD H?`8e|`$iGv diff --git a/src/test/java/org/mdbenefits/app/preparers/ApplicantNeedsPreparerTest.java b/src/test/java/org/mdbenefits/app/preparers/ApplicantNeedsPreparerTest.java new file mode 100644 index 00000000..02433add --- /dev/null +++ b/src/test/java/org/mdbenefits/app/preparers/ApplicantNeedsPreparerTest.java @@ -0,0 +1,94 @@ +package org.mdbenefits.app.preparers; + +import static org.assertj.core.api.Assertions.assertThat; +import formflow.library.data.Submission; +import formflow.library.pdf.SingleField; +import formflow.library.pdf.SubmissionField; +import java.util.List; +import java.util.Map; +import org.junit.jupiter.api.Test; +import org.mdbenefits.app.data.SubmissionTestBuilder; + +class ApplicantNeedsPreparerTest { + private final ApplicantNeedsPreparer preparer = new ApplicantNeedsPreparer(); + + @Test + public void tdapProgramSelectionGeneratesNeedsCashAssistance() { + Submission submission = new SubmissionTestBuilder() + .withPersonalInfo("John", "Doe", "10", "12", "1999", + "", "", "", "", "") + .with("programs[]", List.of("TDAP")) + .with("signature", "My Signature") + .with("submittedAt", "11/12/2024") + .build(); + + Map result = preparer.prepareSubmissionFields(submission, null); + assertThat(result.get("needsSNAP")) + .isEqualTo(new SingleField("needsSNAP", "false", null)); + assertThat(result.get("needsCashAssistance")) + .isEqualTo(new SingleField("needsCashAssistance", "true", null)); + assertThat(result.get("tcaSignature")) + .isEqualTo(null); + assertThat(result.get("tcaSubmissionData")).isEqualTo(null); + } + + @Test + public void rcaProgramSelectionGeneratesNeedsCashAssistance() { + Submission submission = new SubmissionTestBuilder() + .withPersonalInfo("John", "Doe", "10", "12", "1999", + "", "", "", "", "") + .with("programs[]", List.of("RCA")) + .with("signature", "My Signature") + .with("submittedAt", "11/12/2024") + .build(); + + Map result = preparer.prepareSubmissionFields(submission, null); + assertThat(result.get("needsSNAP")) + .isEqualTo(new SingleField("needsSNAP", "false", null)); + assertThat(result.get("needsCashAssistance")) + .isEqualTo(new SingleField("needsCashAssistance", "true", null)); + assertThat(result.get("tcaSignature")) + .isEqualTo(null); + assertThat(result.get("tcaSubmissionData")).isEqualTo(null); + } + + @Test + public void snapProgramSelectionGeneratesNeedsCashAssistance() { + Submission submission = new SubmissionTestBuilder() + .withPersonalInfo("John", "Doe", "10", "12", "1999", + "", "", "", "", "") + .with("programs[]", List.of("SNAP")) + .with("signature", "My Signature") + .with("submittedAt", "11/12/2024") + .build(); + + Map result = preparer.prepareSubmissionFields(submission, null); + assertThat(result.get("needsSNAP")) + .isEqualTo(new SingleField("needsSNAP", "true", null)); + assertThat(result.get("needsCashAssistance")) + .isEqualTo(new SingleField("needsCashAssistance", "false", null)); + assertThat(result.get("tcaSignature")) + .isEqualTo(null); + assertThat(result.get("tcaSubmissionData")).isEqualTo(null); + } + + @Test + public void tcaProgramSelectionGeneratesNeedsCashAssistance() { + Submission submission = new SubmissionTestBuilder() + .withPersonalInfo("John", "Doe", "10", "12", "1999", + "", "", "", "", "") + .with("programs[]", List.of("TCA")) + .with("signature", "My Signature") + .with("submittedAt", "11/12/2024") + .build(); + + Map result = preparer.prepareSubmissionFields(submission, null); + assertThat(result.get("needsSNAP")) + .isEqualTo(new SingleField("needsSNAP", "false", null)); + assertThat(result.get("needsCashAssistance")) + .isEqualTo(new SingleField("needsCashAssistance", "true", null)); + assertThat(result.get("tcaSignature")) + .isEqualTo(new SingleField("tcaSignature", "My Signature", null)); + assertThat(result.get("tcaSubmissionData")).isEqualTo(new SingleField("tcaSubmissionData", "11/12/2024", null)); + } +} \ No newline at end of file From d9ebda0ce4c6be7f72afb708c1ec24a2bcd234a8 Mon Sep 17 00:00:00 2001 From: Ana Medrano Fernandez Date: Tue, 9 Apr 2024 10:56:00 -0700 Subject: [PATCH 2/4] Fix name for submitted at date --- .../app/preparers/ApplicantNeedsPreparer.java | 2 +- src/main/resources/pdf-map.yaml | 2 +- src/main/resources/pdfs/9701.pdf | Bin 1509777 -> 1515552 bytes .../preparers/ApplicantNeedsPreparerTest.java | 8 ++++---- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/mdbenefits/app/preparers/ApplicantNeedsPreparer.java b/src/main/java/org/mdbenefits/app/preparers/ApplicantNeedsPreparer.java index 40c3b573..358323b2 100644 --- a/src/main/java/org/mdbenefits/app/preparers/ApplicantNeedsPreparer.java +++ b/src/main/java/org/mdbenefits/app/preparers/ApplicantNeedsPreparer.java @@ -36,7 +36,7 @@ public Map prepareSubmissionFields(Submission submissio if(needsTCA){ results.put("tcaSignature", new SingleField("tcaSignature", inputData.getOrDefault("signature", "").toString(), null)); - results.put("tcaSubmissionData", new SingleField("tcaSubmissionData", inputData.getOrDefault("submittedAt", "").toString(), null)); + results.put("tcaSubmissionData", new SingleField("tcaSubmissionDate", inputData.getOrDefault("submittedAt", "").toString(), null)); } return results; diff --git a/src/main/resources/pdf-map.yaml b/src/main/resources/pdf-map.yaml index 45de1881..027103f6 100644 --- a/src/main/resources/pdf-map.yaml +++ b/src/main/resources/pdf-map.yaml @@ -44,7 +44,7 @@ inputFields: needsSNAP: applicant_needs_snap signature: applicant_signature tcaSignature: tca_applicant_signature - tcaSubmissionData: tca_date_submitted + tcaSubmissionDate: tca_date_submitted householdHasDisability: household_disability_bool householdHasDisabilitySeeCover: hhmember_disability_see_cover householdHasPregnancy: household_pregnancy_bool diff --git a/src/main/resources/pdfs/9701.pdf b/src/main/resources/pdfs/9701.pdf index 2b0ac9e87be486edf40c960c6e6ef08195be252c..e1b5f7b49269bfb093cffd83c191268e8903e791 100644 GIT binary patch delta 532 zcmbO@IcC9un1&X{7N!>F7M2#)7Pc1l7LFFq7OocV7M>Q~7QPn#7J(MQ7NHj57LgXw z7O^ej6FIkY7mH405-`yqg9pyyjuC9}KpCsdcmI{VTx9ym;Np-)%{MXWjnoA@ZB$@I=wd2>lQ7 zpEIi_aDKOEWMhbO()>7`kyTub(R_Mgq^QDlRSt14Uq?$z3rjasM?+I1a}x`5GfM*# zXCq@rHzRXX7jtt1C%agE&%Bh>ifBUvBVz?a1rwl$L6n)f0gy5@GBGp-(I$pwrV7T> zFLH>BYnT}72Nb22DHxg>SQ?v~=?CTKmjLwv6&NT4=?7<4rGnL4Oc&r3S5kRC=fsg8 zLGL*(*MI!2FfEC3!dHj+osErWr92GkSUC(Bb{TU1n*OjzRF>D&(A3bvl2=vL)!&U5 E0P0MxF8}}l delta 55 zcmV~$SrI@`006*od+u8~VSH=>qks?sh-UZsj_W>7kys*?$rVaLrPgS5dV|qqwpeZN GeuW Date: Tue, 9 Apr 2024 14:55:18 -0700 Subject: [PATCH 3/4] Expand tca definition to be all cash assistance --- .../mdbenefits/app/preparers/ApplicantNeedsPreparer.java | 9 ++++----- .../app/preparers/ApplicantNeedsPreparerTest.java | 8 ++++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/mdbenefits/app/preparers/ApplicantNeedsPreparer.java b/src/main/java/org/mdbenefits/app/preparers/ApplicantNeedsPreparer.java index 358323b2..73585ef5 100644 --- a/src/main/java/org/mdbenefits/app/preparers/ApplicantNeedsPreparer.java +++ b/src/main/java/org/mdbenefits/app/preparers/ApplicantNeedsPreparer.java @@ -28,15 +28,14 @@ public Map prepareSubmissionFields(Submission submissio results.put("needsSNAP", new SingleField("needsSNAP", String.valueOf(programs.contains("SNAP")), null)); - boolean needsCash = programs.contains("TDAP") || programs.contains("RCA"); - boolean needsTCA = programs.contains("TCA"); + boolean needsCash = programs.contains("TDAP") || programs.contains("RCA") || programs.contains("TCA"); results.put("needsCashAssistance", - new SingleField("needsCashAssistance", String.valueOf(needsCash || needsTCA), null)); + new SingleField("needsCashAssistance", String.valueOf(needsCash), null)); - if(needsTCA){ + if(needsCash){ results.put("tcaSignature", new SingleField("tcaSignature", inputData.getOrDefault("signature", "").toString(), null)); - results.put("tcaSubmissionData", new SingleField("tcaSubmissionDate", inputData.getOrDefault("submittedAt", "").toString(), null)); + results.put("tcaSubmissionDate", new SingleField("tcaSubmissionDate", inputData.getOrDefault("submittedAt", "").toString(), null)); } return results; diff --git a/src/test/java/org/mdbenefits/app/preparers/ApplicantNeedsPreparerTest.java b/src/test/java/org/mdbenefits/app/preparers/ApplicantNeedsPreparerTest.java index 4760ca44..7980a3be 100644 --- a/src/test/java/org/mdbenefits/app/preparers/ApplicantNeedsPreparerTest.java +++ b/src/test/java/org/mdbenefits/app/preparers/ApplicantNeedsPreparerTest.java @@ -28,8 +28,8 @@ public void tdapProgramSelectionGeneratesNeedsCashAssistance() { assertThat(result.get("needsCashAssistance")) .isEqualTo(new SingleField("needsCashAssistance", "true", null)); assertThat(result.get("tcaSignature")) - .isEqualTo(null); - assertThat(result.get("tcaSubmissionDate")).isEqualTo(null); + .isEqualTo(new SingleField("tcaSignature", "My Signature", null)); + assertThat(result.get("tcaSubmissionDate")).isEqualTo(new SingleField("tcaSubmissionDate", "11/12/2024", null)); } @Test @@ -48,8 +48,8 @@ public void rcaProgramSelectionGeneratesNeedsCashAssistance() { assertThat(result.get("needsCashAssistance")) .isEqualTo(new SingleField("needsCashAssistance", "true", null)); assertThat(result.get("tcaSignature")) - .isEqualTo(null); - assertThat(result.get("tcaSubmissionDate")).isEqualTo(null); + .isEqualTo(new SingleField("tcaSignature", "My Signature", null)); + assertThat(result.get("tcaSubmissionDate")).isEqualTo(new SingleField("tcaSubmissionDate", "11/12/2024", null)); } @Test From 8da320becc40b6a6b7964a49b99cdd8956beb69a Mon Sep 17 00:00:00 2001 From: Ana Medrano Fernandez Date: Tue, 9 Apr 2024 15:22:19 -0700 Subject: [PATCH 4/4] Submitted At date correctly appears on PDF --- .../app/preparers/ApplicantNeedsPreparer.java | 3 ++- .../preparers/ApplicantNeedsPreparerTest.java | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/mdbenefits/app/preparers/ApplicantNeedsPreparer.java b/src/main/java/org/mdbenefits/app/preparers/ApplicantNeedsPreparer.java index 73585ef5..bedbeb55 100644 --- a/src/main/java/org/mdbenefits/app/preparers/ApplicantNeedsPreparer.java +++ b/src/main/java/org/mdbenefits/app/preparers/ApplicantNeedsPreparer.java @@ -5,6 +5,7 @@ import formflow.library.pdf.SingleField; import formflow.library.pdf.SubmissionField; import formflow.library.pdf.SubmissionFieldPreparer; +import java.time.format.DateTimeFormatter; import java.util.List; import org.springframework.stereotype.Component; @@ -35,7 +36,7 @@ public Map prepareSubmissionFields(Submission submissio if(needsCash){ results.put("tcaSignature", new SingleField("tcaSignature", inputData.getOrDefault("signature", "").toString(), null)); - results.put("tcaSubmissionDate", new SingleField("tcaSubmissionDate", inputData.getOrDefault("submittedAt", "").toString(), null)); + results.put("tcaSubmissionDate", new SingleField("tcaSubmissionDate", submission.getSubmittedAt().format(DateTimeFormatter.ofPattern("MM/dd/yyyy")), null)); } return results; diff --git a/src/test/java/org/mdbenefits/app/preparers/ApplicantNeedsPreparerTest.java b/src/test/java/org/mdbenefits/app/preparers/ApplicantNeedsPreparerTest.java index 7980a3be..f6dfc3a4 100644 --- a/src/test/java/org/mdbenefits/app/preparers/ApplicantNeedsPreparerTest.java +++ b/src/test/java/org/mdbenefits/app/preparers/ApplicantNeedsPreparerTest.java @@ -4,14 +4,18 @@ import formflow.library.data.Submission; import formflow.library.pdf.SingleField; import formflow.library.pdf.SubmissionField; +import java.time.OffsetDateTime; import java.util.List; import java.util.Map; import org.junit.jupiter.api.Test; import org.mdbenefits.app.data.SubmissionTestBuilder; +import org.mdbenefits.app.testutils.TestUtils; class ApplicantNeedsPreparerTest { private final ApplicantNeedsPreparer preparer = new ApplicantNeedsPreparer(); + private final OffsetDateTime NovTwelve = TestUtils.makeOffsetDateTime("2024-11-12"); + @Test public void tdapProgramSelectionGeneratesNeedsCashAssistance() { Submission submission = new SubmissionTestBuilder() @@ -19,9 +23,10 @@ public void tdapProgramSelectionGeneratesNeedsCashAssistance() { "", "", "", "", "") .with("programs[]", List.of("TDAP")) .with("signature", "My Signature") - .with("submittedAt", "11/12/2024") .build(); + submission.setSubmittedAt(NovTwelve); + Map result = preparer.prepareSubmissionFields(submission, null); assertThat(result.get("needsSNAP")) .isEqualTo(new SingleField("needsSNAP", "false", null)); @@ -39,9 +44,10 @@ public void rcaProgramSelectionGeneratesNeedsCashAssistance() { "", "", "", "", "") .with("programs[]", List.of("RCA")) .with("signature", "My Signature") - .with("submittedAt", "11/12/2024") .build(); + submission.setSubmittedAt(NovTwelve); + Map result = preparer.prepareSubmissionFields(submission, null); assertThat(result.get("needsSNAP")) .isEqualTo(new SingleField("needsSNAP", "false", null)); @@ -59,9 +65,10 @@ public void snapProgramSelectionGeneratesNeedsCashAssistance() { "", "", "", "", "") .with("programs[]", List.of("SNAP")) .with("signature", "My Signature") - .with("submittedAt", "11/12/2024") .build(); + submission.setSubmittedAt(NovTwelve); + Map result = preparer.prepareSubmissionFields(submission, null); assertThat(result.get("needsSNAP")) .isEqualTo(new SingleField("needsSNAP", "true", null)); @@ -79,9 +86,10 @@ public void tcaProgramSelectionGeneratesNeedsCashAssistance() { "", "", "", "", "") .with("programs[]", List.of("TCA")) .with("signature", "My Signature") - .with("submittedAt", "11/12/2024") .build(); + submission.setSubmittedAt(NovTwelve); + Map result = preparer.prepareSubmissionFields(submission, null); assertThat(result.get("needsSNAP")) .isEqualTo(new SingleField("needsSNAP", "false", null));