Skip to content

Commit

Permalink
MAT-7362a
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmcphillips committed Jul 26, 2024
1 parent 495ff76 commit d6ab8cf
Showing 1 changed file with 29 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,38 @@ 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());

// Check if the ValueSet with the same oid already exists in allValueSets
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());
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
if (vsParam.getOffset() + vsParam.getCount() < total) {
if (vsParam.getOffset() + vsParam.getCount() <= total) {
vsParam.setOffset(vsParam.getOffset() + 1000);
recursivelyRequestAllValueSetsExpansionsForQDM(
allValueSets, apiKey, vsParam, valueSetsSearchCriteria, codeSystemEntries);
Expand Down

0 comments on commit d6ab8cf

Please sign in to comment.