Skip to content

Commit

Permalink
Merge pull request #77 from MeasureAuthoringTool/MAT-7038
Browse files Browse the repository at this point in the history
MAT-7038: Modify cs retrieve to return displayValues for vsac version
  • Loading branch information
mcmcphillips authored May 10, 2024
2 parents c281b34 + 9b3b205 commit 8a83bc3
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 6 deletions.
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 qdmDisplayVersion; // 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 @@ -122,7 +122,46 @@ 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> codeSystemMappingEntries =
mappingService.getCodeSystemEntries().stream()
.filter(codeSystemEntry -> !codeSystemEntry.getOid().contains("NOT.IN.VSAC"))
.toList();
List<CodeSystem> codeSystems = codeSystemRepository.findAll();
codeSystems.forEach(
codeSystem -> {
Optional<CodeSystemEntry> matchingEntry =
codeSystemMappingEntries.stream()
.filter(entry -> entry.getOid().equals(codeSystem.getOid()))
.findFirst();
if (matchingEntry.isPresent()) {
matchingEntry
.get()
.getVersions()
.forEach(
version -> {
// We use fhir url to interact with VSAC FHIR Term Service.
// Goal here is to look for fhir version, then give users
// viewing QDM measures a display version that looks like
// svs vsac because that's what they expect.
if (version.getFhir().equals(codeSystem.getVersion())
&& version.getVsac() != null) {
codeSystem.setQdmDisplayVersion(version.getVsac());
log.debug(
"CodeSystem title {} , version: {} was found in mapping document",
codeSystem.getTitle(),
codeSystem.getVersion());
}
});
} else {
// it was not found, we log that it's not located within vsac.
log.debug(
"CodeSystem title {} , version: {} was NOT found in mapping document",
codeSystem.getTitle(),
codeSystem.getName());
}
});
return codeSystems;
}

public List<CodeSystem> retrieveAllCodeSystems(UmlsUser umlsUser) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package gov.cms.madie.terminology.service;

import ca.uhn.fhir.context.FhirContext;
import com.okta.commons.lang.Collections;
import gov.cms.madie.models.mapping.CodeSystemEntry;
import gov.cms.madie.models.measure.ManifestExpansion;
import gov.cms.madie.terminology.dto.Code;
Expand All @@ -27,6 +26,7 @@
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.times;
Expand All @@ -39,7 +39,6 @@
import java.time.Instant;
import java.util.*;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.when;

Expand Down Expand Up @@ -143,7 +142,7 @@ public void setUp() throws IOException {
.name("Icd10CM")
.oid("urn:oid:2.16.840.1.113883.6.90")
.url("http://hl7.org/fhir/sid/icd-10-cm")
.versions(Collections.toList(version))
.versions(List.of(version))
.build();
codeSystemEntries.add(codeSystemEntry);
}
Expand Down Expand Up @@ -334,17 +333,45 @@ 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");
List<gov.cms.madie.terminology.models.CodeSystem> codeSystems = Arrays.asList(c1, c2);
c2.setOid("fakeoid2");
c2.setVersion("2.0");
var c3 = new gov.cms.madie.terminology.models.CodeSystem();
c3.setTitle("t3");
c3.setOid("fakeoid3");
c3.setVersion("2024");

CodeSystemEntry.Version cv1 =
new CodeSystemEntry.Version().toBuilder().fhir("1.0").vsac("1").build();
CodeSystemEntry.Version cv2 =
new CodeSystemEntry.Version().toBuilder().fhir("2.0").vsac("2").build();
CodeSystemEntry.Version cv3 = new CodeSystemEntry.Version().toBuilder().fhir("latest").build();
var ce1 = new CodeSystemEntry().toBuilder().versions(List.of(cv1)).oid("fakeoid1").build();
var ce2 = new CodeSystemEntry().toBuilder().versions(List.of(cv2)).oid("fakeoid2").build();
var ce3 = new CodeSystemEntry().toBuilder().versions(List.of(cv3)).oid("NOT.IN.VSAC").build();

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

verify(codeSystemRepository).findAll();
assertEquals(2, result.size());
assertEquals(3, result.size());
assertEquals("t1", result.get(0).getTitle());
assertEquals("1", result.get(0).getQdmDisplayVersion());

assertEquals("t2", result.get(1).getTitle());
assertEquals("2", result.get(1).getQdmDisplayVersion());

// Verify FHIR only Code Systems appear in the result set
assertEquals("t3", result.get(2).getTitle());
assertEquals("2024", result.get(2).getVersion());
assertNull(result.get(2).getQdmDisplayVersion());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
public class UpdateCodeSystemTaskTest {
@Mock private FhirTerminologyService fhirTerminologyService;
@InjectMocks UpdateCodeSystemTask updateCodeSystemTask;

@Test
void updateCodeSystemTaskTest() {
UmlsUser umlsUser = new UmlsUser();
Expand Down

0 comments on commit 8a83bc3

Please sign in to comment.