Customize concept display in value set expansion (#2282)

* fix issue #2280

* revert the indentation back.

* revert-back untouched changes.
This commit is contained in:
Hanan Awwad 2021-02-07 19:29:05 +02:00 committed by GitHub
parent c69d741b43
commit 6384067e50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 43 additions and 3 deletions

View File

@ -1019,6 +1019,12 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
for (TermConcept concept: termConcepts) {
count.incrementAndGet();
countForBatch.incrementAndGet();
if (theAdd && expansionStep != null) {
ValueSet.ConceptReferenceComponent theIncludeConcept = getMatchedConceptIncludedInValueSet(theIncludeOrExclude, concept);
if (theIncludeConcept != null && isNotBlank(theIncludeConcept.getDisplay())) {
concept.setDisplay(theIncludeConcept.getDisplay());
}
}
boolean added = addCodeIfNotAlreadyAdded(theValueSetCodeAccumulator, theAddedCodes, concept, theAdd, includeOrExcludeVersion);
if (added) {
delta++;
@ -1036,6 +1042,13 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
}
}
private ValueSet.ConceptReferenceComponent getMatchedConceptIncludedInValueSet(ValueSet.ConceptSetComponent theIncludeOrExclude, TermConcept concept) {
ValueSet.ConceptReferenceComponent theIncludeConcept = theIncludeOrExclude.getConcept().stream().filter(includedConcept ->
includedConcept.getCode().equalsIgnoreCase(concept.getCode())
).findFirst().orElse(null);
return theIncludeConcept;
}
/**
* Helper method which builds a predicate for the expansion
*/

View File

@ -330,6 +330,33 @@ public class FhirResourceDaoR4TerminologyTest extends BaseJpaR4Test {
assertEquals("Invalid filter, must have fields populated: property op value", e.getMessage());
}
}
@Test
public void testExpandWithIncludeConceptHaveCodeAndDisplay() {
CodeSystem codeSystem = createExternalCsDogs();
ValueSet valueSet = new ValueSet();
valueSet.setUrl(URL_MY_VALUE_SET);
valueSet.getCompose()
.addInclude()
.setSystem(codeSystem.getUrl())
.addConcept(new ConceptReferenceComponent().setCode("hello").setDisplay("Display-VS"))
.addConcept(new ConceptReferenceComponent().setCode("goodbye").setDisplay("Goodbye-VS"));
myValueSetDao.create(valueSet, mySrd);
ValueSet result = myValueSetDao.expand(valueSet, "");
logAndValidateValueSet(result);
assertEquals(2, result.getExpansion().getTotal());
ArrayList<String> codes = toCodesContains(result.getExpansion().getContains());
assertThat(codes, containsInAnyOrder("hello", "goodbye"));
for (ValueSetExpansionContainsComponent vsConcept : result.getExpansion().getContains()){
assertTrue(vsConcept.getDisplay().contains("VS"));
}
}
@Test
public void testExpandWithCodesAndDisplayFilterBlank() {