Adjust concept and designation totals as we process.

This commit is contained in:
Diederik Muylwyk 2019-09-03 16:23:20 -04:00
parent b42b598d01
commit 6ebc9572ac
2 changed files with 9 additions and 4 deletions

View File

@ -1862,7 +1862,7 @@ public abstract class BaseHapiTerminologySvcImpl implements IHapiTerminologySvc,
TermValueSet refreshedValueSetToExpand = myValueSetDao.findById(valueSetToExpand.getId()).get();
return getValueSetFromResourceTable(refreshedValueSetToExpand.getResource());
});
expandValueSet(valueSet, new ValueSetConceptAccumulator(valueSetToExpand, myValueSetConceptDao, myValueSetConceptDesignationDao));
expandValueSet(valueSet, new ValueSetConceptAccumulator(valueSetToExpand, myValueSetDao, myValueSetConceptDao, myValueSetConceptDesignationDao));
// We are done with this ValueSet.
txTemplate.execute(t -> {

View File

@ -22,6 +22,7 @@ package ca.uhn.fhir.jpa.term;
import ca.uhn.fhir.jpa.dao.data.ITermValueSetConceptDao;
import ca.uhn.fhir.jpa.dao.data.ITermValueSetConceptDesignationDao;
import ca.uhn.fhir.jpa.dao.data.ITermValueSetDao;
import ca.uhn.fhir.jpa.entity.TermConceptDesignation;
import ca.uhn.fhir.jpa.entity.TermValueSet;
import ca.uhn.fhir.jpa.entity.TermValueSetConcept;
@ -38,13 +39,15 @@ public class ValueSetConceptAccumulator implements IValueSetConceptAccumulator {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ValueSetConceptAccumulator.class);
private TermValueSet myTermValueSet;
private ITermValueSetDao myValueSetDao;
private ITermValueSetConceptDao myValueSetConceptDao;
private ITermValueSetConceptDesignationDao myValueSetConceptDesignationDao;
private int myConceptsSaved;
private int myDesignationsSaved;
public ValueSetConceptAccumulator(@Nonnull TermValueSet theTermValueSet, @Nonnull ITermValueSetConceptDao theValueSetConceptDao, @Nonnull ITermValueSetConceptDesignationDao theValueSetConceptDesignationDao) {
public ValueSetConceptAccumulator(@Nonnull TermValueSet theTermValueSet, @Nonnull ITermValueSetDao theValueSetDao, @Nonnull ITermValueSetConceptDao theValueSetConceptDao, @Nonnull ITermValueSetConceptDesignationDao theValueSetConceptDesignationDao) {
myTermValueSet = theTermValueSet;
myValueSetDao = theValueSetDao;
myValueSetConceptDao = theValueSetConceptDao;
myValueSetConceptDesignationDao = theValueSetConceptDesignationDao;
myConceptsSaved = 0;
@ -83,11 +86,13 @@ public class ValueSetConceptAccumulator implements IValueSetConceptAccumulator {
}
myValueSetConceptDao.deleteById(concept.getId());
myTermValueSet.decrementTotalConcepts();
myValueSetDao.save(myTermValueSet);
ourLog.info("Done excluding [{}|{}] from ValueSet[{}]", concept.getSystem(), concept.getCode(), myTermValueSet.getUrl());
ourLog.info("Flushing...");
myValueSetConceptDesignationDao.flush();
myValueSetConceptDao.flush();
myValueSetDao.flush();
ourLog.info("Done flushing.");
}
}
@ -104,7 +109,7 @@ public class ValueSetConceptAccumulator implements IValueSetConceptAccumulator {
concept.setDisplay(theDisplay);
}
myValueSetConceptDao.save(concept);
myTermValueSet.incrementTotalConcepts();
myValueSetDao.save(myTermValueSet.incrementTotalConcepts());
if (myConceptsSaved++ % 250 == 0) { // TODO: DM 2019-08-23 - This message never appears in the log. Fix it!
ourLog.info("Have pre-expanded {} concepts in ValueSet[{}]", myConceptsSaved, myTermValueSet.getUrl());
@ -129,7 +134,7 @@ public class ValueSetConceptAccumulator implements IValueSetConceptAccumulator {
}
designation.setValue(theDesignation.getValue());
myValueSetConceptDesignationDao.save(designation);
myTermValueSet.incrementTotalConceptDesignations();
myValueSetDao.save(myTermValueSet.incrementTotalConceptDesignations());
if (myDesignationsSaved++ % 250 == 0) { // TODO: DM 2019-08-23 - This message never appears in the log. Fix it!
ourLog.info("Have pre-expanded {} designations for Concept[{}|{}] in ValueSet[{}]", myDesignationsSaved, theConcept.getSystem(), theConcept.getCode(), myTermValueSet.getUrl());