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

OCD-4711 - Generate a list of certified products based on health IT standards #1790

Open
wants to merge 6 commits into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public ListingSearchResponse findListings(SearchRequest searchRequest) throws Va
.filter(listing -> matchesHasAnySvapFilter(listing, searchRequest.getHasAnySvap()))
.filter(listing -> matchesSvapNoticeUrlFilter(listing, searchRequest.getHasSvapNoticeUrl()))
.filter(listing -> matchesSvaps(listing, searchRequest.getSvapIds(), searchRequest.getSvapOperator()))
.filter(listing -> matchesStandards(listing, searchRequest.getStandardIds(), searchRequest.getStandardOperator()))
.filter(listing -> matchesRiskManagementSummaryInformationFilter(listing, searchRequest.getRiskManagementSummaryInformationOptions()))
.collect(Collectors.toList());
LOGGER.debug("Total matched listings: " + matchedListings.size());
Expand Down Expand Up @@ -552,6 +553,20 @@ private Set<Long> getSvapIds(Set<CertificationCriterionSearchResultWithLongField
.collect(Collectors.toSet());
}

private boolean matchesStandards(ListingSearchResult listing, Set<Long> standardIds, SearchSetOperator searchOperator) {
if (CollectionUtils.isEmpty(standardIds)) {
return true;
}
if (searchOperator.equals(SearchSetOperator.AND)) {
return standardIds.stream()
.allMatch(standardId -> listing.getStandardsMet().contains(standardId));
} else if (searchOperator.equals(SearchSetOperator.OR)) {
return standardIds.stream()
.anyMatch(standardId -> listing.getStandardsMet().contains(standardId));
}
return false;
}

private boolean applyOperation(SearchSetOperator operation, Boolean... filters) {
List<Boolean> nonNullFilters = Stream.of(filters)
.filter(booleanElement -> booleanElement != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public void normalize(SearchRequest request) {
normalizeRwtOptionsOperator(request);
normalizeSvapIds(request);
normalizeSvapOperator(request);
normalizeStanadrdIds(request);
normalizeStandardOperator(request);
normalizeRiskManagementSummaryInformationOptions(request);
normalizeOrderBy(request);
}
Expand Down Expand Up @@ -272,6 +274,30 @@ private void normalizeSvapOperator(SearchRequest request) {
}
}

private void normalizeStanadrdIds(SearchRequest request) {
if (request.getStandardIdStrings() != null && request.getStandardIdStrings().size() > 0
&& (request.getStandardIds() == null || request.getStandardIds().size() == 0)) {
request.setStandardIds(request.getStandardIdStrings().stream()
.filter(standardIdString -> !StringUtils.isBlank(standardIdString))
.map(standardIdString -> standardIdString.trim())
.filter(standardIdString -> isParseableLong(standardIdString))
.map(standardIdString -> Long.parseLong(standardIdString))
.collect(Collectors.toSet()));
}
}

private void normalizeStandardOperator(SearchRequest request) {
if (!StringUtils.isBlank(request.getStandardOperatorString())
&& request.getStandardOperator() == null) {
try {
request.setStandardOperator(
SearchSetOperator.valueOf(request.getStandardOperatorString().toUpperCase().trim()));
} catch (Exception ignore) {
LOGGER.error(ignore);
}
}
}

private void normalizeRiskManagementSummaryInformationOptions(SearchRequest request) {
if (!CollectionUtils.isEmpty(request.getRiskManagementSummaryInformationOptionsStrings())
&& CollectionUtils.isEmpty(request.getRiskManagementSummaryInformationOptions())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.springframework.stereotype.Repository;

import gov.healthit.chpl.dao.impl.BaseDAOImpl;
Expand Down Expand Up @@ -134,6 +135,7 @@ private ListingSearchResult buildListingSearchResult(ListingSearchEntity entity)
.previousDevelopers(convertToSetOfProductOwners(entity.getPreviousDevelopers(), ListingSearchEntity.SMILEY_SPLIT_CHAR))
.apiDocumentation(convertToSetOfCriteriaWithStringFields(entity.getCriteriaWithApiDocumentation(), ListingSearchEntity.SMILEY_SPLIT_CHAR))
.serviceBaseUrlList(convertToCriterionWithStringField(entity.getCriteriaWithServiceBaseUrlList()))
.standardsMet(convertToSetOfLongs(entity.getStandardsMet(), STANDARD_VALUE_SPLIT_CHAR))
.svaps(convertToSetOfCriteriaWithLongFields(entity.getCriteriaWithSvap(), ListingSearchEntity.SMILEY_SPLIT_CHAR))
.riskManagementSummaryInformation(convertToCriterionWithStringField(entity.getCriteriaWithRiskManagementSummaryInformation()))
.build();
Expand Down Expand Up @@ -172,6 +174,19 @@ private Set<String> convertToSetOfStrings(String delimitedString, String valueTo
.collect(Collectors.toSet());
}

private Set<Long> convertToSetOfLongs(String delimitedString, String delimeter)
throws EntityRetrievalException, NumberFormatException {
if (ObjectUtils.isEmpty(delimitedString)) {
return new LinkedHashSet<Long>();
}

String[] splitStrings = delimitedString.split(delimeter);
return Stream.of(splitStrings)
.filter(str -> NumberUtils.isParsable(str))
.map(str -> Long.valueOf(str))
.collect(Collectors.toSet());
}

private Set<DateRangeSearchResult> convertToSetOfDateRangesWithDelimiter(String delimitedDateRangeString, String delimeter)
throws EntityRetrievalException, DateTimeParseException, NumberFormatException {
if (ObjectUtils.isEmpty(delimitedDateRangeString)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public class ListingSearchResult implements Serializable {
private String rwtPlansUrl;
private String rwtResultsUrl;
private String svapNoticeUrl;
private Set<Long> standardsMet;

public ListingSearchResult() {
this.setDirectReviewCount(0);
Expand All @@ -102,6 +103,7 @@ public ListingSearchResult() {
statusEvents = new HashSet<StatusEventSearchResult>();
apiDocumentation = new HashSet<CertificationCriterionSearchResultWithStringField>();
svaps = new HashSet<CertificationCriterionSearchResultWithLongFields>();
standardsMet = new HashSet<Long>();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ public class SearchRequest implements Serializable {
private String svapOperatorString;
private SearchSetOperator svapOperator;

@Builder.Default
@JsonIgnore
private Set<String> standardIdStrings = new HashSet<String>();
@Builder.Default
private Set<Long> standardIds = new HashSet<Long>();
@JsonIgnore
private String standardOperatorString;
private SearchSetOperator standardOperator;

@JsonIgnore
@Builder.Default
private Set<String> riskManagementSummaryInformationOptionsStrings = new HashSet<String>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,7 @@ public class ListingSearchEntity {

@Column(name = "children")
private String children;

@Column(name = "standards_met")
private String standardsMet;
}
Loading