-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
449 additions
and
630 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
62 changes: 62 additions & 0 deletions
62
...e/src/main/java/gov/healthit/chpl/upload/listing/validation/reviewer/SvapIcsReviewer.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,62 @@ | ||
package gov.healthit.chpl.upload.listing.validation.reviewer; | ||
|
||
import org.apache.commons.collections.CollectionUtils; | ||
import org.apache.commons.lang3.BooleanUtils; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
import gov.healthit.chpl.domain.CertificationResult; | ||
import gov.healthit.chpl.domain.CertifiedProductSearchDetails; | ||
import gov.healthit.chpl.svap.domain.CertificationResultSvap; | ||
import gov.healthit.chpl.util.CertificationResultRules; | ||
import gov.healthit.chpl.util.ErrorMessageUtil; | ||
import gov.healthit.chpl.util.ValidationUtils; | ||
import lombok.extern.log4j.Log4j2; | ||
|
||
//This reviewer is only relevant to new listings - there is a validation rule | ||
//that newly created listings must have ICS if they are using any replaced SVAPs. | ||
//The rules are different when editing a listing. | ||
@Component("listingUploadSvapIcsReviewer") | ||
@Log4j2 | ||
public class SvapIcsReviewer { | ||
private CertificationResultRules certResultRules; | ||
private ValidationUtils validationUtils; | ||
private ErrorMessageUtil msgUtil; | ||
|
||
@Autowired | ||
public SvapIcsReviewer(CertificationResultRules certResultRules, | ||
ValidationUtils validationUtils, | ||
ErrorMessageUtil msgUtil) { | ||
this.certResultRules = certResultRules; | ||
this.validationUtils = validationUtils; | ||
this.msgUtil = msgUtil; | ||
} | ||
|
||
public void review(CertifiedProductSearchDetails listing) { | ||
listing.getCertificationResults().stream() | ||
.filter(certResult -> validationUtils.isEligibleForErrors(certResult)) | ||
.filter(certResult -> certResultRules.hasCertOption(certResult.getCriterion().getId(), CertificationResultRules.SVAP)) | ||
.forEach(certResult -> reviewCertificationResult(listing, certResult)); | ||
} | ||
|
||
private void reviewCertificationResult(CertifiedProductSearchDetails listing, CertificationResult certResult) { | ||
if (!CollectionUtils.isEmpty(certResult.getSvaps())) { | ||
certResult.getSvaps().stream() | ||
.forEach(svap -> reviewSvapMarkedAsReplaced(listing, certResult, svap)); | ||
} | ||
} | ||
|
||
private void reviewSvapMarkedAsReplaced(CertifiedProductSearchDetails listing, | ||
CertificationResult certResult, CertificationResultSvap svap) { | ||
if (svap.getSvapId() != null | ||
&& BooleanUtils.isTrue(svap.isReplaced()) | ||
&& !doesListingHaveIcs(listing)) { | ||
listing.addDataErrorMessage(msgUtil.getMessage("listing.criteria.svap.replacedWithIcs", | ||
svap.getRegulatoryTextCitation(), certResult.getCriterion().getNumber())); | ||
} | ||
} | ||
|
||
private boolean doesListingHaveIcs(CertifiedProductSearchDetails listing) { | ||
return listing.getIcs().getInherits(); | ||
} | ||
} |
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
152 changes: 0 additions & 152 deletions
152
...hpl-service/src/main/java/gov/healthit/chpl/validation/listing/reviewer/SvapReviewer.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.