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

MAT-7038: Modify cs retrieve to return displayValues for vsac version #77

Merged
merged 5 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class CodeSystem {
private String title;
private String name;
private String version;
private String displayVersion; // match version HL7V3.0_2019-12 against fhir
private String versionId;
private String oid; // identifier[0].value oid of identifier List
private Instant lastUpdated; // when queried
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@

import java.time.Instant;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicBoolean;

@Service
@Slf4j
Expand Down Expand Up @@ -122,7 +124,49 @@ private List<QdmValueSet.Concept> getValueSetConcepts(
}

public List<CodeSystem> getAllCodeSystems() {
return codeSystemRepository.findAll();
// remove items that are marked as not present in vsac to cut expense
List<CodeSystemEntry> codeSystemEntries = mappingService.getCodeSystemEntries().stream().filter(codeSystemEntry -> !codeSystemEntry.getOid().contains("NOT.IN.VSAC")).toList();
List<CodeSystem> codeSystems = codeSystemRepository.findAll();
List<CodeSystem> transformedResults = new ArrayList<>(Collections.emptyList());
jkotanchik-SB marked this conversation as resolved.
Show resolved Hide resolved
codeSystems.forEach(codeSystem -> {
// if the oid shows up at all
int index = -1;
for (int i = 0; i < codeSystems.size(); i++) {
if (codeSystems.get(i).getOid().equals(codeSystem.getOid())) {
index = i;
break;
}
}
if(index != -1) {
CodeSystemEntry matchingEntry = null;
for (CodeSystemEntry entry : codeSystemEntries) {
if (entry.getOid().equals(codeSystem.getOid())) {
matchingEntry = entry;
break;
}
}
if (matchingEntry != null) {
AtomicBoolean usableVersionFound = new AtomicBoolean(false);
matchingEntry.getVersions().forEach(version -> {
// we use fhir csv to interact with api. goal here is to look for fhir version, then give users a display version
// that looks like vsac because that's what they understand.
if (version.getFhir().equals(codeSystem.getVersion()) && version.getVsac() != null) {
codeSystem.setDisplayVersion(version.getVsac());
transformedResults.add(codeSystem);
usableVersionFound.set(true);
}
});
if (usableVersionFound.get()){
log.info("CodeSystem title {} , version: {} was not found in mapping document", codeSystem.getTitle(), codeSystem.getVersion());
}
}
}
else {
// it was not found, we log that it's not located within vsac.
log.info("CodeSystem title {} , version: {} was not found in mapping document", codeSystem.getTitle(), codeSystem.getName());
}
});
return transformedResults;
}

public List<CodeSystem> retrieveAllCodeSystems(UmlsUser umlsUser) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

import java.io.File;
import java.io.IOException;
import java.lang.reflect.Array;
import java.nio.charset.Charset;
import java.time.Instant;
import java.util.*;
Expand Down Expand Up @@ -334,9 +335,20 @@ void testRetrieveAllCodeSystemsWithInsert() {
void testGetAllCodeSystems() {
var c1 = new gov.cms.madie.terminology.models.CodeSystem();
c1.setTitle("t1");
c1.setOid("fakeoid1");
c1.setVersion("1.0");
var c2 = new gov.cms.madie.terminology.models.CodeSystem();
c2.setTitle("t2");
c2.setOid("fakeoid2");
c2.setVersion("2.0");
CodeSystemEntry.Version cv1 = new CodeSystemEntry.Version().toBuilder().fhir("1.0").vsac("exists").build();
CodeSystemEntry.Version cv2 = new CodeSystemEntry.Version().toBuilder().fhir("2.0").vsac("exists").build();
var ce1 = new CodeSystemEntry().toBuilder().versions(java.util.Collections.singletonList(cv1)).oid("fakeoid1").build();
var ce2 = new CodeSystemEntry().toBuilder().versions(java.util.Collections.singletonList(cv2)).oid("fakeoid2").build();

List<CodeSystemEntry> codeSystemEntries = Arrays.asList(ce1, ce2);
List<gov.cms.madie.terminology.models.CodeSystem> codeSystems = Arrays.asList(c1, c2);
when(mappingService.getCodeSystemEntries()).thenAnswer(invocation -> codeSystemEntries);
when(codeSystemRepository.findAll()).thenAnswer(invocation -> codeSystems);
List<gov.cms.madie.terminology.models.CodeSystem> result =
fhirTerminologyService.getAllCodeSystems();
Expand Down
Loading