Missing commits
This commit is contained in:
parent
019d08a064
commit
5b707f97a9
|
@ -25,13 +25,10 @@ import ca.uhn.fhir.util.ValidateUtil;
|
|||
import org.apache.commons.lang3.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import org.hibernate.annotations.ColumnDefault;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.left;
|
||||
import static org.apache.commons.lang3.StringUtils.length;
|
||||
|
@ -72,29 +69,11 @@ public class TermValueSet implements Serializable {
|
|||
@Column(name = "VSNAME", nullable = true, length = MAX_NAME_LENGTH)
|
||||
private String myName;
|
||||
|
||||
@OneToMany(mappedBy = "myValueSet", fetch = FetchType.LAZY)
|
||||
private List<TermValueSetConcept> myConcepts;
|
||||
|
||||
@Column(name = "TOTAL_CONCEPTS", nullable = false)
|
||||
@ColumnDefault("0")
|
||||
private Long myTotalConcepts;
|
||||
|
||||
@Column(name = "TOTAL_CONCEPT_DESIGNATIONS", nullable = false)
|
||||
@ColumnDefault("0")
|
||||
private Long myTotalConceptDesignations;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "EXPANSION_STATUS", nullable = false, length = MAX_EXPANSION_STATUS_LENGTH)
|
||||
private TermValueSetPreExpansionStatusEnum myExpansionStatus;
|
||||
|
||||
@Transient
|
||||
private transient Integer myHashCode;
|
||||
|
||||
public TermValueSet() {
|
||||
super();
|
||||
myExpansionStatus = TermValueSetPreExpansionStatusEnum.NOT_EXPANDED;
|
||||
myTotalConcepts = 0L;
|
||||
myTotalConceptDesignations = 0L;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
|
@ -140,64 +119,6 @@ public class TermValueSet implements Serializable {
|
|||
return this;
|
||||
}
|
||||
|
||||
public List<TermValueSetConcept> getConcepts() {
|
||||
if (myConcepts == null) {
|
||||
myConcepts = new ArrayList<>();
|
||||
}
|
||||
|
||||
return myConcepts;
|
||||
}
|
||||
|
||||
public Long getTotalConcepts() {
|
||||
return myTotalConcepts;
|
||||
}
|
||||
|
||||
public TermValueSet setTotalConcepts(Long theTotalConcepts) {
|
||||
myTotalConcepts = theTotalConcepts;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TermValueSet decrementTotalConcepts() {
|
||||
if (myTotalConcepts > 0) {
|
||||
myTotalConcepts--;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public TermValueSet incrementTotalConcepts() {
|
||||
myTotalConcepts++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Long getTotalConceptDesignations() {
|
||||
return myTotalConceptDesignations;
|
||||
}
|
||||
|
||||
public TermValueSet setTotalConceptDesignations(Long theTotalConceptDesignations) {
|
||||
myTotalConceptDesignations = theTotalConceptDesignations;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TermValueSet decrementTotalConceptDesignations() {
|
||||
if (myTotalConceptDesignations > 0) {
|
||||
myTotalConceptDesignations--;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public TermValueSet incrementTotalConceptDesignations() {
|
||||
myTotalConceptDesignations++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TermValueSetPreExpansionStatusEnum getExpansionStatus() {
|
||||
return myExpansionStatus;
|
||||
}
|
||||
|
||||
public void setExpansionStatus(TermValueSetPreExpansionStatusEnum theExpansionStatus) {
|
||||
myExpansionStatus = theExpansionStatus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object theO) {
|
||||
if (this == theO) return true;
|
||||
|
@ -227,10 +148,6 @@ public class TermValueSet implements Serializable {
|
|||
.append(myResource != null ? ("myResource=" + myResource.toString()) : ("myResource=(null)"))
|
||||
.append("myResourcePid", myResourcePid)
|
||||
.append("myName", myName)
|
||||
.append(myConcepts != null ? ("myConcepts - size=" + myConcepts.size()) : ("myConcepts=(null)"))
|
||||
.append("myTotalConcepts", myTotalConcepts)
|
||||
.append("myTotalConceptDesignations", myTotalConceptDesignations)
|
||||
.append("myExpansionStatus", myExpansionStatus)
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ import ca.uhn.fhir.jpa.dao.data.ITermValueSetConceptDao;
|
|||
import ca.uhn.fhir.jpa.dao.data.ITermValueSetConceptDesignationDao;
|
||||
import ca.uhn.fhir.jpa.dao.data.ITermValueSetConceptViewDao;
|
||||
import ca.uhn.fhir.jpa.dao.data.ITermValueSetDao;
|
||||
import ca.uhn.fhir.jpa.dao.data.ITermValueSetVersionDao;
|
||||
import ca.uhn.fhir.jpa.entity.TermCodeSystem;
|
||||
import ca.uhn.fhir.jpa.entity.TermCodeSystemVersion;
|
||||
import ca.uhn.fhir.jpa.entity.TermConcept;
|
||||
|
@ -62,6 +63,7 @@ import ca.uhn.fhir.jpa.entity.TermValueSet;
|
|||
import ca.uhn.fhir.jpa.entity.TermValueSetConcept;
|
||||
import ca.uhn.fhir.jpa.entity.TermValueSetConceptView;
|
||||
import ca.uhn.fhir.jpa.entity.TermValueSetPreExpansionStatusEnum;
|
||||
import ca.uhn.fhir.jpa.entity.TermValueSetVersion;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceTable;
|
||||
import ca.uhn.fhir.jpa.model.sched.HapiJob;
|
||||
import ca.uhn.fhir.jpa.model.sched.ISchedulerService;
|
||||
|
@ -205,6 +207,8 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
|
|||
@Autowired
|
||||
protected ITermValueSetDao myValueSetDao;
|
||||
@Autowired
|
||||
protected ITermValueSetVersionDao myValueSetVersionDao;
|
||||
@Autowired
|
||||
protected ITermValueSetConceptDao myValueSetConceptDao;
|
||||
@Autowired
|
||||
protected ITermValueSetConceptDesignationDao myValueSetConceptDesignationDao;
|
||||
|
@ -425,10 +429,17 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
|
|||
}
|
||||
|
||||
TermValueSet termValueSet = optionalTermValueSet.get();
|
||||
TermValueSetVersion termValueSetVersion;
|
||||
String valueSetVersion = theValueSetToExpand.getVersion();
|
||||
if (valueSetVersion != null) {
|
||||
termValueSetVersion = myValueSetVersionDao.findByValueSetPidAndVersion(termValueSet.getId(),theValueSetToExpand.getVersion());
|
||||
} else {
|
||||
termValueSetVersion = myValueSetVersionDao.findByValueSetPidAndNullVersion(termValueSet.getId());
|
||||
}
|
||||
|
||||
if (termValueSet.getExpansionStatus() != TermValueSetPreExpansionStatusEnum.EXPANDED) {
|
||||
if (termValueSetVersion.getExpansionStatus() != TermValueSetPreExpansionStatusEnum.EXPANDED) {
|
||||
ourLog.warn("{} is present in terminology tables but not ready for persistence-backed invocation of operation $expand. Will perform in-memory expansion without parameters. Current status: {} | {}",
|
||||
getValueSetInfo(theValueSetToExpand), termValueSet.getExpansionStatus().name(), termValueSet.getExpansionStatus().getDescription());
|
||||
getValueSetInfo(theValueSetToExpand), termValueSetVersion.getExpansionStatus().name(), termValueSetVersion.getExpansionStatus().getDescription());
|
||||
return expandValueSetInMemory(theExpansionOptions, theValueSetToExpand, null); // In-memory expansion.
|
||||
}
|
||||
|
||||
|
@ -439,7 +450,7 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
|
|||
ValueSetExpansionOptions expansionOptions = provideExpansionOptions(theExpansionOptions);
|
||||
int offset = expansionOptions.getOffset();
|
||||
int count = expansionOptions.getCount();
|
||||
populateExpansionComponent(expansionComponent, termValueSet, offset, count);
|
||||
populateExpansionComponent(expansionComponent, termValueSetVersion, offset, count, termValueSet.getUrl());
|
||||
|
||||
ValueSet valueSet = new ValueSet();
|
||||
valueSet.setStatus(Enumerations.PublicationStatus.ACTIVE);
|
||||
|
@ -448,8 +459,8 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
|
|||
return valueSet;
|
||||
}
|
||||
|
||||
private void populateExpansionComponent(ValueSet.ValueSetExpansionComponent theExpansionComponent, TermValueSet theTermValueSet, int theOffset, int theCount) {
|
||||
int total = theTermValueSet.getTotalConcepts().intValue();
|
||||
private void populateExpansionComponent(ValueSet.ValueSetExpansionComponent theExpansionComponent, TermValueSetVersion theTermValueSetVersion, int theOffset, int theCount, String theValueSetUrl) {
|
||||
int total = theTermValueSetVersion.getTotalConcepts().intValue();
|
||||
theExpansionComponent.setTotal(total);
|
||||
theExpansionComponent.setOffset(theOffset);
|
||||
theExpansionComponent.addParameter().setName("offset").setValue(new IntegerType(theOffset));
|
||||
|
@ -459,17 +470,17 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
|
|||
return;
|
||||
}
|
||||
|
||||
expandConcepts(theExpansionComponent, theTermValueSet, theOffset, theCount);
|
||||
expandConcepts(theExpansionComponent, theTermValueSetVersion, theOffset, theCount, theValueSetUrl);
|
||||
}
|
||||
|
||||
private void expandConcepts(ValueSet.ValueSetExpansionComponent theExpansionComponent, TermValueSet theTermValueSet, int theOffset, int theCount) {
|
||||
private void expandConcepts(ValueSet.ValueSetExpansionComponent theExpansionComponent, TermValueSetVersion theTermValueSetVersion, int theOffset, int theCount, String theValueSetUrl) {
|
||||
int conceptsExpanded = 0;
|
||||
int designationsExpanded = 0;
|
||||
int toIndex = theOffset + theCount;
|
||||
Collection<TermValueSetConceptView> conceptViews = myTermValueSetConceptViewDao.findByTermValueSetId(theOffset, toIndex, theTermValueSet.getId());
|
||||
Collection<TermValueSetConceptView> conceptViews = myTermValueSetConceptViewDao.findByTermValueSetId(theOffset, toIndex, theTermValueSetVersion.getId());
|
||||
|
||||
if (conceptViews.isEmpty()) {
|
||||
logConceptsExpanded("No concepts to expand. ", theTermValueSet, conceptsExpanded);
|
||||
logConceptsExpanded("No concepts to expand. ", theValueSetUrl, conceptsExpanded);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -500,28 +511,28 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
|
|||
designationComponent.setValue(conceptView.getDesignationVal());
|
||||
|
||||
if (++designationsExpanded % 250 == 0) {
|
||||
logDesignationsExpanded("Expansion of designations in progress. ", theTermValueSet, designationsExpanded);
|
||||
logDesignationsExpanded("Expansion of designations in progress. ", theValueSetUrl, designationsExpanded);
|
||||
}
|
||||
}
|
||||
|
||||
if (++conceptsExpanded % 250 == 0) {
|
||||
logConceptsExpanded("Expansion of concepts in progress. ", theTermValueSet, conceptsExpanded);
|
||||
logConceptsExpanded("Expansion of concepts in progress. ", theValueSetUrl, conceptsExpanded);
|
||||
}
|
||||
}
|
||||
|
||||
logDesignationsExpanded("Finished expanding designations. ", theTermValueSet, designationsExpanded);
|
||||
logConceptsExpanded("Finished expanding concepts. ", theTermValueSet, conceptsExpanded);
|
||||
logDesignationsExpanded("Finished expanding designations. ", theValueSetUrl, designationsExpanded);
|
||||
logConceptsExpanded("Finished expanding concepts. ", theValueSetUrl, conceptsExpanded);
|
||||
}
|
||||
|
||||
private void logConceptsExpanded(String theLogDescriptionPrefix, TermValueSet theTermValueSet, int theConceptsExpanded) {
|
||||
private void logConceptsExpanded(String theLogDescriptionPrefix, String theValueSetUrl, int theConceptsExpanded) {
|
||||
if (theConceptsExpanded > 0) {
|
||||
ourLog.debug("{}Have expanded {} concepts in ValueSet[{}]", theLogDescriptionPrefix, theConceptsExpanded, theTermValueSet.getUrl());
|
||||
ourLog.debug("{}Have expanded {} concepts in ValueSet[{}]", theLogDescriptionPrefix, theConceptsExpanded, theValueSetUrl);
|
||||
}
|
||||
}
|
||||
|
||||
private void logDesignationsExpanded(String theLogDescriptionPrefix, TermValueSet theTermValueSet, int theDesignationsExpanded) {
|
||||
private void logDesignationsExpanded(String theLogDescriptionPrefix, String theValueSetUrl, int theDesignationsExpanded) {
|
||||
if (theDesignationsExpanded > 0) {
|
||||
ourLog.debug("{}Have expanded {} designations in ValueSet[{}]", theLogDescriptionPrefix, theDesignationsExpanded, theTermValueSet.getUrl());
|
||||
ourLog.debug("{}Have expanded {} designations in ValueSet[{}]", theLogDescriptionPrefix, theDesignationsExpanded, theValueSetUrl);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1262,10 +1273,17 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
|
|||
}
|
||||
|
||||
TermValueSet termValueSet = optionalTermValueSet.get();
|
||||
TermValueSetVersion termValueSetVersion;
|
||||
String valueSetVersion = theValueSet.getVersion();
|
||||
if (valueSetVersion != null) {
|
||||
termValueSetVersion = myValueSetVersionDao.findByValueSetPidAndVersion(termValueSet.getId(), valueSetVersion);
|
||||
} else {
|
||||
termValueSetVersion = myValueSetVersionDao.findByValueSetPidAndNullVersion(termValueSet.getId());
|
||||
}
|
||||
|
||||
if (termValueSet.getExpansionStatus() != TermValueSetPreExpansionStatusEnum.EXPANDED) {
|
||||
if (termValueSetVersion.getExpansionStatus() != TermValueSetPreExpansionStatusEnum.EXPANDED) {
|
||||
ourLog.warn("{} is present in terminology tables but not ready for persistence-backed invocation of operation $validation-code. Will perform in-memory code validation. Current status: {} | {}",
|
||||
getValueSetInfo(theValueSet), termValueSet.getExpansionStatus().name(), termValueSet.getExpansionStatus().getDescription());
|
||||
getValueSetInfo(theValueSet), termValueSetVersion.getExpansionStatus().name(), termValueSetVersion.getExpansionStatus().getDescription());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1680,15 +1698,15 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
|
|||
|
||||
while (true) {
|
||||
StopWatch sw = new StopWatch();
|
||||
TermValueSet valueSetToExpand = txTemplate.execute(t -> {
|
||||
Optional<TermValueSet> optionalTermValueSet = getNextTermValueSetNotExpanded();
|
||||
if (!optionalTermValueSet.isPresent()) {
|
||||
TermValueSetVersion valueSetToExpand = txTemplate.execute(t -> {
|
||||
Optional<TermValueSetVersion> optionalTermValueSetVersion = getNextTermValueSetNotExpanded();
|
||||
if (!optionalTermValueSetVersion.isPresent()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
TermValueSet termValueSet = optionalTermValueSet.get();
|
||||
termValueSet.setExpansionStatus(TermValueSetPreExpansionStatusEnum.EXPANSION_IN_PROGRESS);
|
||||
return myValueSetDao.saveAndFlush(termValueSet);
|
||||
TermValueSetVersion termValueSetVersion = optionalTermValueSetVersion.get();
|
||||
termValueSetVersion.setExpansionStatus(TermValueSetPreExpansionStatusEnum.EXPANSION_IN_PROGRESS);
|
||||
return myValueSetVersionDao.saveAndFlush(termValueSetVersion);
|
||||
});
|
||||
if (valueSetToExpand == null) {
|
||||
return;
|
||||
|
@ -1718,7 +1736,7 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
|
|||
ourLog.error("Failed to pre-expand ValueSet: " + e.getMessage(), e);
|
||||
txTemplate.execute(t -> {
|
||||
valueSetToExpand.setExpansionStatus(TermValueSetPreExpansionStatusEnum.FAILED_TO_EXPAND);
|
||||
myValueSetDao.saveAndFlush(valueSetToExpand);
|
||||
myValueSetVersionDao.saveAndFlush(valueSetToExpand);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
@ -1783,9 +1801,9 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
|
|||
|
||||
protected abstract ValueSet getValueSetFromResourceTable(ResourceTable theResourceTable);
|
||||
|
||||
private Optional<TermValueSet> getNextTermValueSetNotExpanded() {
|
||||
Optional<TermValueSet> retVal = Optional.empty();
|
||||
Slice<TermValueSet> page = myValueSetDao.findByExpansionStatus(PageRequest.of(0, 1), TermValueSetPreExpansionStatusEnum.NOT_EXPANDED);
|
||||
private Optional<TermValueSetVersion> getNextTermValueSetNotExpanded() {
|
||||
Optional<TermValueSetVersion> retVal = Optional.empty();
|
||||
Slice<TermValueSetVersion> page = myValueSetVersionDao.findByExpansionStatus(PageRequest.of(0, 1), TermValueSetPreExpansionStatusEnum.NOT_EXPANDED);
|
||||
|
||||
if (!page.getContent().isEmpty()) {
|
||||
retVal = Optional.of(page.getContent().get(0));
|
||||
|
|
|
@ -23,10 +23,12 @@ 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.dao.data.ITermValueSetVersionDao;
|
||||
import ca.uhn.fhir.jpa.entity.TermConceptDesignation;
|
||||
import ca.uhn.fhir.jpa.entity.TermValueSet;
|
||||
import ca.uhn.fhir.jpa.entity.TermValueSetConcept;
|
||||
import ca.uhn.fhir.jpa.entity.TermValueSetConceptDesignation;
|
||||
import ca.uhn.fhir.jpa.entity.TermValueSetVersion;
|
||||
import ca.uhn.fhir.util.ValidateUtil;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
@ -41,17 +43,18 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
|||
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 TermValueSetVersion myTermValueSetVersion;
|
||||
final private ITermValueSetVersionDao myValueSetVersionDao;
|
||||
final private ITermValueSetDao myValueSetDao;
|
||||
final private ITermValueSetConceptDao myValueSetConceptDao;
|
||||
final private ITermValueSetConceptDesignationDao myValueSetConceptDesignationDao;
|
||||
private int myConceptsSaved;
|
||||
private int myDesignationsSaved;
|
||||
private int myConceptsExcluded;
|
||||
private int myCount;
|
||||
|
||||
public ValueSetConceptAccumulator(@Nonnull TermValueSet theTermValueSet, @Nonnull ITermValueSetDao theValueSetDao, @Nonnull ITermValueSetConceptDao theValueSetConceptDao, @Nonnull ITermValueSetConceptDesignationDao theValueSetConceptDesignationDao) {
|
||||
myTermValueSet = theTermValueSet;
|
||||
public ValueSetConceptAccumulator(@Nonnull TermValueSetVersion theTermValueSetVersion, @Nonnull ITermValueSetVersionDao theValueSetVersionDao, @Nonnull ITermValueSetDao theValueSetDao, @Nonnull ITermValueSetConceptDao theValueSetConceptDao, @Nonnull ITermValueSetConceptDesignationDao theValueSetConceptDesignationDao) {
|
||||
myTermValueSetVersion = theTermValueSetVersion;
|
||||
myValueSetVersionDao = theValueSetVersionDao;
|
||||
myValueSetDao = theValueSetDao;
|
||||
myValueSetConceptDao = theValueSetConceptDao;
|
||||
myValueSetConceptDesignationDao = theValueSetConceptDesignationDao;
|
||||
|
@ -88,23 +91,23 @@ public class ValueSetConceptAccumulator implements IValueSetConceptAccumulator {
|
|||
}
|
||||
|
||||
// Get existing entity so it can be deleted.
|
||||
Optional<TermValueSetConcept> optionalConcept = myValueSetConceptDao.findByTermValueSetIdSystemAndCode(myTermValueSet.getId(), theSystem, theCode);
|
||||
Optional<TermValueSetConcept> optionalConcept = myValueSetConceptDao.findByTermValueSetIdSystemAndCode(myTermValueSetVersion.getId(), theSystem, theCode);
|
||||
|
||||
if (optionalConcept.isPresent()) {
|
||||
TermValueSetConcept concept = optionalConcept.get();
|
||||
|
||||
ourLog.debug("Excluding [{}|{}] from ValueSet[{}]", concept.getSystem(), concept.getCode(), myTermValueSet.getUrl());
|
||||
ourLog.debug("Excluding [{}|{}] from ValueSet[{}]", concept.getSystem(), concept.getCode(), myTermValueSetVersion.getValueSet().getUrl());
|
||||
for (TermValueSetConceptDesignation designation : concept.getDesignations()) {
|
||||
myValueSetConceptDesignationDao.deleteById(designation.getId());
|
||||
myTermValueSet.decrementTotalConceptDesignations();
|
||||
myTermValueSetVersion.decrementTotalConceptDesignations();
|
||||
}
|
||||
myValueSetConceptDao.deleteById(concept.getId());
|
||||
myTermValueSet.decrementTotalConcepts();
|
||||
myValueSetDao.save(myTermValueSet);
|
||||
ourLog.debug("Done excluding [{}|{}] from ValueSet[{}]", concept.getSystem(), concept.getCode(), myTermValueSet.getUrl());
|
||||
myTermValueSetVersion.decrementTotalConcepts();
|
||||
myValueSetVersionDao.save(myTermValueSetVersion);
|
||||
ourLog.debug("Done excluding [{}|{}] from ValueSet[{}]", concept.getSystem(), concept.getCode(), myTermValueSetVersion.getValueSet().getUrl());
|
||||
|
||||
if (++myConceptsExcluded % 250 == 0) {
|
||||
ourLog.info("Have excluded {} concepts from ValueSet[{}]", myConceptsExcluded, myTermValueSet.getUrl());
|
||||
ourLog.info("Have excluded {} concepts from ValueSet[{}]", myConceptsExcluded, myTermValueSetVersion.getValueSet().getUrl());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -115,7 +118,7 @@ public class ValueSetConceptAccumulator implements IValueSetConceptAccumulator {
|
|||
|
||||
myTermValueSetVersion = myValueSetVersionDao.findById(myTermValueSetVersion.getId()).get();
|
||||
TermValueSetConcept concept = new TermValueSetConcept();
|
||||
concept.setValueSet(myTermValueSet);
|
||||
concept.setValueSet(myTermValueSetVersion.getValueSet());
|
||||
concept.setOrder(myConceptsSaved);
|
||||
concept.setSystem(theSystem);
|
||||
concept.setCode(theCode);
|
||||
|
@ -123,21 +126,23 @@ public class ValueSetConceptAccumulator implements IValueSetConceptAccumulator {
|
|||
concept.setDisplay(theDisplay);
|
||||
}
|
||||
myValueSetConceptDao.save(concept);
|
||||
myValueSetDao.save(myTermValueSet.incrementTotalConcepts());
|
||||
myTermValueSetVersion.incrementTotalConcepts();
|
||||
myValueSetVersionDao.save(myTermValueSetVersion);
|
||||
|
||||
if (++myConceptsSaved % 250 == 0) {
|
||||
ourLog.info("Have pre-expanded {} concepts in ValueSet[{}]", myConceptsSaved, myTermValueSet.getUrl());
|
||||
ourLog.info("Have pre-expanded {} concepts in ValueSet[{}]", myConceptsSaved, myTermValueSetVersion.getValueSet().getUrl());
|
||||
}
|
||||
|
||||
return concept;
|
||||
}
|
||||
|
||||
private TermValueSetConceptDesignation saveConceptDesignation(TermValueSetConcept theConcept, TermConceptDesignation theDesignation) {
|
||||
private void saveConceptDesignation(TermValueSetConcept theConcept, TermConceptDesignation theDesignation) {
|
||||
ValidateUtil.isNotBlankOrThrowInvalidRequest(theDesignation.getValue(), "ValueSet contains a concept designation with no value");
|
||||
|
||||
TermValueSetConceptDesignation designation = new TermValueSetConceptDesignation();
|
||||
designation.setConcept(theConcept);
|
||||
designation.setValueSet(myTermValueSet);
|
||||
myTermValueSetVersion = myValueSetVersionDao.findById(myTermValueSetVersion.getId()).get();
|
||||
designation.setValueSet(myTermValueSetVersion.getValueSet());
|
||||
designation.setLanguage(theDesignation.getLanguage());
|
||||
if (isNoneBlank(theDesignation.getUseSystem(), theDesignation.getUseCode())) {
|
||||
designation.setUseSystem(theDesignation.getUseSystem());
|
||||
|
@ -148,13 +153,12 @@ public class ValueSetConceptAccumulator implements IValueSetConceptAccumulator {
|
|||
}
|
||||
designation.setValue(theDesignation.getValue());
|
||||
myValueSetConceptDesignationDao.save(designation);
|
||||
myValueSetDao.save(myTermValueSet.incrementTotalConceptDesignations());
|
||||
myValueSetVersionDao.save(myTermValueSetVersion.incrementTotalConceptDesignations());
|
||||
|
||||
if (++myDesignationsSaved % 250 == 0) {
|
||||
ourLog.debug("Have pre-expanded {} designations for Concept[{}|{}] in ValueSet[{}]", myDesignationsSaved, theConcept.getSystem(), theConcept.getCode(), myTermValueSet.getUrl());
|
||||
ourLog.debug("Have pre-expanded {} designations for Concept[{}|{}] in ValueSet[{}]", myDesignationsSaved, theConcept.getSystem(), theConcept.getCode(), myTermValueSetVersion.getValueSet().getUrl());
|
||||
}
|
||||
|
||||
return designation;
|
||||
}
|
||||
|
||||
public Boolean removeGapsFromConceptOrder() {
|
||||
|
@ -162,13 +166,13 @@ public class ValueSetConceptAccumulator implements IValueSetConceptAccumulator {
|
|||
return false;
|
||||
}
|
||||
|
||||
ourLog.info("Removing gaps from concept order for ValueSet[{}]", myTermValueSet.getUrl());
|
||||
ourLog.info("Removing gaps from concept order for ValueSet[{}]", myTermValueSetVersion.getValueSet().getUrl());
|
||||
int order = 0;
|
||||
List<Long> conceptIds = myValueSetConceptDao.findIdsByTermValueSetId(myTermValueSet.getId());
|
||||
List<Long> conceptIds = myValueSetConceptDao.findIdsByTermValueSetId(myTermValueSetVersion.getId());
|
||||
for (Long conceptId : conceptIds) {
|
||||
myValueSetConceptDao.updateOrderById(conceptId, order++);
|
||||
}
|
||||
ourLog.info("Have removed gaps from concept order for {} concepts in ValueSet[{}]", conceptIds.size(), myTermValueSet.getUrl());
|
||||
ourLog.info("Have removed gaps from concept order for {} concepts in ValueSet[{}]", conceptIds.size(), myTermValueSetVersion.getValueSet().getUrl());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue