Skip to content

Commit

Permalink
MAT-7362: Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmcphillips committed Jul 29, 2024
1 parent 125b80b commit 9fca552
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,34 +71,40 @@ public List<QdmValueSet> recursivelyRequestAllValueSetsExpansionsForQDM(

List<QdmValueSet.Concept> concepts =
getValueSetConcepts(valueSetResource, codeSystemEntries, "QDM");
log.info("vs total [{}] count: [{}] offset: [{}], oid: [{}]", total, vsParam.getCount(), vsParam.getOffset(), vsParam.getOid());
log.info(
"vs total [{}] count: [{}] offset: [{}], oid: [{}]",
total,
vsParam.getCount(),
vsParam.getOffset(),
vsParam.getOid());

// Check if the ValueSet with the same oid already exists in allValueSets
QdmValueSet existingValueSet = allValueSets.stream()
QdmValueSet existingValueSet =
allValueSets.stream()
.filter(vs -> vs.getOid().equals(vsParam.getOid()))
.findFirst()
.orElse(null);
if (existingValueSet != null) {
List<QdmValueSet.Concept> updatedConcepts = new ArrayList<>(existingValueSet.getConcepts());
updatedConcepts.addAll(concepts);
// Create a new QdmValueSet with the updated concepts
QdmValueSet updatedValueSet = QdmValueSet.builder()
.oid(existingValueSet.getOid())
.displayName(existingValueSet.getDisplayName())
.version(existingValueSet.getVersion())
.concepts(updatedConcepts)
.build();
// Replace the existing QdmValueSet in the list
allValueSets.set(allValueSets.indexOf(existingValueSet), updatedValueSet);
} else {
allValueSets.add(
QdmValueSet.builder()
.oid(valueSetResource.getIdPart())
.displayName(valueSetResource.getName())
.version(valueSetResource.getVersion())
.concepts(concepts)
.build());

if (existingValueSet != null) {
List<QdmValueSet.Concept> updatedConcepts = new ArrayList<>(existingValueSet.getConcepts());
updatedConcepts.addAll(concepts);
// Create a new QdmValueSet with the updated concepts
QdmValueSet updatedValueSet =
QdmValueSet.builder()
.oid(existingValueSet.getOid())
.displayName(existingValueSet.getDisplayName())
.version(existingValueSet.getVersion())
.concepts(updatedConcepts)
.build();
// Replace the existing QdmValueSet in the list
allValueSets.set(allValueSets.indexOf(existingValueSet), updatedValueSet);
} else {
allValueSets.add(
QdmValueSet.builder()
.oid(valueSetResource.getIdPart())
.displayName(valueSetResource.getName())
.version(valueSetResource.getVersion())
.concepts(concepts)
.build());
}
// if the total results in the searchSet are still greater than our current offset + the count
// of our last request, then we request again
Expand All @@ -123,7 +129,7 @@ public List<QdmValueSet> getValueSetsExpansionsForQdm(
.flatMap(
vsParam ->
recursivelyRequestAllValueSetsExpansionsForQDM(
new ArrayList<>(),
new ArrayList<>(),
umlsUser.getApiKey(),
vsParam,
valueSetsSearchCriteria,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,15 @@ public static URI buildValueSetResourceUri(
ManifestExpansion manifestExpansion) {
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
String expandValueSetUri = "/ValueSet/" + valueSetParams.getOid() + "/$expand";
if (valueSetParams.getOffset() >= 0) {
params.put("offset", List.of(String.valueOf(valueSetParams.getOffset())));
}
if (valueSetParams.getCount() >= 0) {
params.put("count", List.of(String.valueOf(valueSetParams.getCount())));
if (valueSetParams != null) {
Integer offset = valueSetParams.getOffset();
Integer count = valueSetParams.getCount();
if (offset != null && offset >= 0) {
params.put("offset", List.of(String.valueOf(offset)));
}
if (count != null && count >= 0) {
params.put("count", List.of(String.valueOf(count)));
}
}
if (StringUtils.isNotBlank(valueSetParams.getVersion())) {
params.put("valueSetVersion", List.of(valueSetParams.getVersion()));
Expand Down

0 comments on commit 9fca552

Please sign in to comment.