Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CCAP-453][CCAP-439][CCAP-537] Update content on providerresponse/provider-number screen, update provider id validation logic, remove broken link #869

Merged
merged 10 commits into from
Dec 4, 2024
9 changes: 9 additions & 0 deletions src/main/java/org/ilgcc/app/data/ProviderRepository.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
package org.ilgcc.app.data;

import java.math.BigInteger;
import java.time.LocalDate;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

@Repository
public interface ProviderRepository extends JpaRepository<Provider, BigInteger> {

@Query(value = "SELECT CASE WHEN COUNT(*) > 0 THEN TRUE ELSE FALSE END FROM providers "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tunneled into staging and tested this query using psql. the test worked :)

+ "WHERE status IN :statuses AND provider_id = :providerId "
+ "AND date_of_last_approval >= :threeYearsAgo", nativeQuery = true)
boolean existsByStatusInAndProviderIdAndDateOfLastApprovalAfter(@Param("statuses") List<String> statuses,
@Param("providerId") BigInteger providerId, @Param("threeYearsAgo") LocalDate threeYearsAgo);
}
14 changes: 8 additions & 6 deletions src/main/java/org/ilgcc/app/data/ProviderRepositoryService.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.ilgcc.app.data;

import java.math.BigInteger;
import java.time.LocalDate;
import java.util.List;
import java.util.Objects;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
Expand All @@ -11,22 +13,22 @@ public class ProviderRepositoryService {

ProviderRepository providerRepository;

private static final String STATUS_ACTIVE = "A";
private static final String STATUS_PENDING = "P";
private static final List<String> VALID_STATUSES = List.of(STATUS_ACTIVE, STATUS_PENDING);

public ProviderRepositoryService(ProviderRepository providerRepository) {
this.providerRepository = providerRepository;
}

public boolean isProviderIdValid(String providerId) {

if (!Objects.isNull(providerId) && !providerId.isEmpty()) {
try {
BigInteger providerIdNumber = new BigInteger(providerId);
if (!providerRepository.existsById(providerIdNumber)) {
return false;
}
return providerRepository.existsByStatusInAndProviderIdAndDateOfLastApprovalAfter(VALID_STATUSES,
new BigInteger(providerId), LocalDate.now().minusYears(3));
} catch (NumberFormatException e) {
return false;
}
return true;
} else {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,20 @@ public Map<String, List<String>> runValidation(FormSubmission formSubmission, Su
Map<String, List<String>> errorMessages = new HashMap<>();
String inputValue = (String) formSubmission.getFormData().get(PROVIDER_NUMBER);

if (validateProviderId && !providerRepositoryService.isProviderIdValid(inputValue)) {
if (validateProviderId) {
Locale locale = LocaleContextHolder.getLocale();
errorMessages.put(PROVIDER_NUMBER,
List.of(messageSource.getMessage("provider-response-ccap-registration.error.invalid-number", null, locale)));

if (inputValue == null || inputValue.isBlank()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love the most specific error messages here. I think it makes it much clearer what the actual issue is.

errorMessages.put(PROVIDER_NUMBER,
List.of(messageSource.getMessage("errors.provide-provider-number", null, locale)));
} else if (inputValue.length() < 8 || inputValue.length() > 15) {
errorMessages.put(PROVIDER_NUMBER,
List.of(messageSource.getMessage("errors.provide-provider-number-length", null, locale)));
} else if (!providerRepositoryService.isProviderIdValid(inputValue)) {
errorMessages.put(PROVIDER_NUMBER,
List.of(messageSource.getMessage("provider-response-provider-number.error.invalid-number", null,
locale)));
}
}

return errorMessages;
Expand Down
8 changes: 2 additions & 6 deletions src/main/resources/flows-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -522,22 +522,18 @@ flow:
nextScreens:
- name: paid-by-ccap
condition: EnableProviderRegistration
- name: ccap-registration
- name: provider-number
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@spokenbird - heads up that this PR is actually renaming the ccap-registration screen to provider-number so it will actually always appear at the beginning of the flow. This means that you probably no longer need to add the GenerateDummyClientSubmissionForDev to the paid by CCAP screen

paid-by-ccap:
condition: EnableProviderRegistration
nextScreens:
- name: provider-number
condition: IsPaidByCCAP
- name: registration-start
provider-number:
condition: EnableProviderRegistration
nextScreens:
- name: confirmation-code
registration-start:
condition: EnableProviderRegistration
nextScreens:
- name: registration-getting-started
ccap-registration:
provider-number:
crossFieldValidationAction: ValidateProviderNumber
beforeSaveAction: SaveApplicationId
onPostAction: GenerateDummyClientSubmissionForDev
Expand Down
26 changes: 18 additions & 8 deletions src/main/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ errors.provide-state=Please choose the state.
errors.provide-zip=Please enter a zip code with 5 digits.
errors.provide-county=Select a county
errors.provide-program-name=Please provide a program name.
errors.provide-provider-number=Enter your provider number.
errors.provide-provider-number=Enter your provider ID number.
errors.provide-provider-number-length=Enter an 8-15 digit number.
errors.provide-applicant-number=Enter a valid code with 6 numbers and letters
errors.select-one-option=Please select one option
errors.select-at-least-one-day=Please select at least one day
Expand Down Expand Up @@ -237,7 +238,7 @@ onboarding-provider-info-review.link=Edit their info
#onboarding-provider-info-confirm
onboarding-provider-info-confirm.title=Confirm provider info
onboarding-provider-info-confirm.header=Thanks! Now we can help you contact {0} when you''re done.
onboarding-provider-info-confirm.notice=<div class='notice--success spacing-below-60'><p>At the end of this application, you'll have the option to <strong>text or email a secure link</strong> to '{0}'.</p><p>Using the link, your provider can quickly complete their part of the application.</p></div>
onboarding-provider-info-confirm.notice=<div class='notice--success spacing-below-60'><p>At the end of this application, you''ll have the option to <strong>text or email a secure link</strong> to '{0}'.</p><p>Using the link, your provider can quickly complete their part of the application.</p></div>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed this typo, missing the double apostrophe, when clicking through the app and fixed it here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for fixing this.


#
onboarding-confirm-provider.title=Confirm provider
Expand Down Expand Up @@ -1165,12 +1166,21 @@ provider-response-submit-start.responded.button=Return to home

provider-response-submit-start.provider-placeholder=child care provider

#ccap-registration
provider-response-ccap-registration.title=Provider number
provider-response-ccap-registration.header=What is your provider number?
provider-response-ccap-registration.subtext=This is a 8-15 digit number issued by the Department of Human Services.
provider-response-ccap-registration.no-provider-number=I don't have a provider number.
provider-response-ccap-registration.error.invalid-number=Make sure the provider number is valid
#provider-number
provider-response-provider-number.title=Provider ID number
provider-response-provider-number.header=What is your provider ID number?
provider-response-provider-number.subtext=This is an 8-15 digit number issued by the Department of Human Services.
provider-response-provider-number.no-provider-number=I don't have a provider number.
provider-response-provider-number.error.invalid-number=Make sure the provider ID number is valid.

provider-response-provider-number.accordion.title=Where can I find this number?
provider-response-provider-number.accordion.intro=Your provider ID number can be found on the following forms:
provider-response-provider-number.accordion.document1=CCAP Approval Notice (Form IL444-3455A)
provider-response-provider-number.accordion.document2=Child Care Certificate/Certificate Report (Form IL444-3492)
provider-response-provider-number.accordion.document3=Child Care Certificate Report for centers (Form IL444-3492A)
provider-response-provider-number.accordion.document4=Monthly Enrollment Report for Site Administered Providers



#confirmation-code
provider-response-confirmation-code.title=Confirmation code
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/static/assets/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,10 @@ ul.list--bulleted ul.list--bulleted.list--sublist li {
color: #5F5854;
}

div.move-40-up {
margin-top: -4.0rem;
}

/* THIS NEEDS TO BE HERE, IF IT'S REMOVED IT WILL BREAK JAVASCRIPT FOR SAME AS HOME ADDRESS FUNCTIONALITY */
.hidden {
display: none !important;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<th:block
th:replace="~{fragments/inputs/submitButton :: submitButton(text=${buttonLabel != null ? buttonLabel : 'Submit'})}"/>
<div>
<a th:if="hasSkipLocation"
<a th:if="${hasSkipLocation}"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was apparently always broken, fwiw.

th:id="${'skip-to-'+skipLocation}"
th:text="${hasSkipTextValue ? skipText : 'Skip'}"
th:href="|/flow/${flow}/${skipLocation}|"></a>
Expand Down

This file was deleted.

63 changes: 36 additions & 27 deletions src/main/resources/templates/providerresponse/provider-number.html
Original file line number Diff line number Diff line change
@@ -1,28 +1,37 @@
<!DOCTYPE html>
<html th:lang="${#locale.language}" xmlns:th="http://www.thymeleaf.org">
<head th:replace="~{fragments/head :: head(title='TEMPLATE')}"></head>
<body>
<div class="page-wrapper">
<div th:replace="~{fragments/toolbar :: toolbar}"></div>
<section class="slab">
<div class="grid">
<div th:replace="~{fragments/goBack :: goBackLink}"></div>
<main id="content" role="main" class="form-card spacing-above-35">
<th:block th:replace="~{fragments/cardHeader :: cardHeader(header=#{placeholder}, subtext=#{placeholder})}"/>
<th:block th:replace="~{fragments/form :: form(action=${formAction}, content=~{::formContent})}">
<th:block th:ref="formContent">
<div class="form-card__content">
<!-- Put inputs here -->
</div>
<div class="form-card__footer">
<th:block th:replace="~{fragments/inputs/submitButton :: submitButton(text=#{general.inputs.continue})}"/>
</div>
<th:block
th:replace="~{fragments/inputs/screenWithOneInputAndSkip ::
screenWithOneInputAndSkip(
title=#{'provider-response-provider-number.title'},
iconFragment=~{fragments/gcc-icons :: registeredProvider},
header=#{provider-response-provider-number.header},
required='true',
subtext=#{provider-response-provider-number.subtext},
buttonLabel=#{general.button.continue},
formAction=${formAction},
inputContent=~{::inputContent})}">

<th:block th:ref="inputContent">
<div class="spacing-below-60 move-40-up">
<th:block th:replace="~{'fragments/honeycrisp/reveal' :: reveal(
controlId='r1',
linkLabel=~{::revealLabel1},
content=~{::revealContent1},
forceShowContent='true')}">
<th:block th:ref="revealLabel1">
<th:span th:text="#{provider-response-provider-number.accordion.title}"></th:span>
</th:block>
<th:block th:ref="revealContent1">
<p th:text="#{provider-response-provider-number.accordion.intro}"></p>
<ul class="list--bulleted">
<li th:utext="#{provider-response-provider-number.accordion.document1}"></li>
<li th:utext="#{provider-response-provider-number.accordion.document2}"></li>
<li th:utext="#{provider-response-provider-number.accordion.document3}"></li>
<li th:utext="#{provider-response-provider-number.accordion.document4}"></li>
</ul>
</th:block>
</th:block>
</th:block>
</main>
</div>
</section>
</div>
<th:block th:replace="~{fragments/footer :: footer}"/>
</body>
</html>
</div>
<th:block
th:replace="~{fragments/inputs/overrides/number :: number(inputName='providerResponseProviderNumber', ariaLabel='header', required='true')}"/>
</th:block>
</th:block>
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ void ProviderresponseJourneyTest_validLink_No_Agreement_To_Care(){
assertThat(testPage.getTitle()).isEqualTo(getEnMessage("provider-response-submit-start.title"));
testPage.clickButton(getEnMessage("provider-response-submit-start.active.button"));

// ccap-registration
assertThat(testPage.getTitle()).isEqualTo(getEnMessage("provider-response-ccap-registration.title"));
// provider-number
assertThat(testPage.getTitle()).isEqualTo(getEnMessage("provider-response-provider-number.title"));
testPage.enter("providerResponseProviderNumber", "123456789012345");
testPage.clickContinue();

Expand Down Expand Up @@ -90,8 +90,8 @@ void ProviderresponseJourneyTest_validLink() {
assertThat(testPage.getTitle()).isEqualTo(getEnMessage("provider-response-submit-start.title"));
testPage.clickButton(getEnMessage("provider-response-submit-start.active.button"));

// ccap-registration
assertThat(testPage.getTitle()).isEqualTo(getEnMessage("provider-response-ccap-registration.title"));
// provider-number
assertThat(testPage.getTitle()).isEqualTo(getEnMessage("provider-response-provider-number.title"));
testPage.enter("providerResponseProviderNumber", "123456789012345");
testPage.clickContinue();

Expand Down Expand Up @@ -178,8 +178,8 @@ void ProviderresponseJourneyTest_noLink() {
assertThat(testPage.getTitle()).isEqualTo(getEnMessage("provider-response-submit-start.title"));
testPage.clickButton(getEnMessage("provider-response-submit-start.active.button"));

// ccap-registration
assertThat(testPage.getTitle()).isEqualTo(getEnMessage("provider-response-ccap-registration.title"));
// provider-number
assertThat(testPage.getTitle()).isEqualTo(getEnMessage("provider-response-provider-number.title"));
testPage.enter("providerResponseProviderNumber", "123456789012345");
testPage.clickContinue();

Expand Down Expand Up @@ -265,8 +265,8 @@ void ProviderresponseJourneyTest_noLink_invalidConfirmationCode() {
assertThat(testPage.getTitle()).isEqualTo(getEnMessage("provider-response-submit-start.title"));
testPage.clickButton(getEnMessage("provider-response-submit-start.active.button"));

// ccap-registration
assertThat(testPage.getTitle()).isEqualTo(getEnMessage("provider-response-ccap-registration.title"));
// provider-number
assertThat(testPage.getTitle()).isEqualTo(getEnMessage("provider-response-provider-number.title"));
testPage.enter("providerResponseProviderNumber", "123456789012345");
testPage.clickContinue();

Expand Down Expand Up @@ -311,8 +311,8 @@ void ProviderresponseJourneyTest_noLink_expiredConfirmationCode() {
assertThat(testPage.getTitle()).isEqualTo(getEnMessage("provider-response-submit-start.title"));
testPage.clickButton(getEnMessage("provider-response-submit-start.active.button"));

// ccap-registration
assertThat(testPage.getTitle()).isEqualTo(getEnMessage("provider-response-ccap-registration.title"));
// provider-number
assertThat(testPage.getTitle()).isEqualTo(getEnMessage("provider-response-provider-number.title"));
testPage.enter("providerResponseProviderNumber", "123456789012345");
testPage.clickContinue();

Expand Down Expand Up @@ -356,8 +356,8 @@ void ProviderresponseJourneyTest_noLink_alreadyResponded() {
assertThat(testPage.getTitle()).isEqualTo(getEnMessage("provider-response-submit-start.title"));
testPage.clickButton(getEnMessage("provider-response-submit-start.active.button"));

// ccap-registration
assertThat(testPage.getTitle()).isEqualTo(getEnMessage("provider-response-ccap-registration.title"));
// provider-number
assertThat(testPage.getTitle()).isEqualTo(getEnMessage("provider-response-provider-number.title"));
testPage.enter("providerResponseProviderNumber", "123456789012345");
testPage.clickContinue();

Expand Down
Loading