Customize concept display in value set expansion (#2282)
* fix issue #2280 * revert the indentation back. * revert-back untouched changes.
This commit is contained in:
parent
c69d741b43
commit
6384067e50
|
@ -575,7 +575,7 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
|
|||
//-- this is quick solution, may need to revisit
|
||||
if (!applyFilter(display, filterDisplayValue))
|
||||
continue;
|
||||
|
||||
|
||||
Long conceptPid = conceptView.getConceptPid();
|
||||
if (!pidToConcept.containsKey(conceptPid)) {
|
||||
FhirVersionIndependentConcept concept = new FhirVersionIndependentConcept(system, code, display);
|
||||
|
@ -646,7 +646,7 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
|
|||
}
|
||||
|
||||
public boolean applyFilter(final String theDisplay, final String theFilterDisplay) {
|
||||
|
||||
|
||||
//-- safety check only, no need to apply filter
|
||||
if (theDisplay == null || theFilterDisplay == null)
|
||||
return true;
|
||||
|
@ -654,7 +654,7 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
|
|||
// -- sentence case
|
||||
if (startsWithIgnoreCase(theDisplay, theFilterDisplay))
|
||||
return true;
|
||||
|
||||
|
||||
//-- token case
|
||||
if (startsWithByWordBoundaries(theDisplay, theFilterDisplay)) return true;
|
||||
|
||||
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue