Fixed ResourceTable lookups for pre-expansion and code validation.

This commit is contained in:
Diederik Muylwyk 2019-08-30 19:31:05 -04:00
parent 9f7cf3923b
commit f29abd7167
4 changed files with 16 additions and 10 deletions

View File

@ -149,7 +149,7 @@ public class DaoConfig {
/**
* EXPERIMENTAL - Do not use in production! Do not change default of {@code false}!
*/
private boolean myPreExpandValueSetsExperimental = false;
private boolean myPreExpandValueSetsExperimental = true;
private boolean myFilterParameterEnabled = false;
private StoreMetaSourceInformation myStoreMetaSourceInformation = StoreMetaSourceInformation.SOURCE_URI_AND_REQUEST_ID;
/**

View File

@ -487,7 +487,8 @@ public abstract class BaseHapiTerminologySvcImpl implements IHapiTerminologySvc,
Optional<TermValueSet> optionalTermValueSet;
if (theValueSetToExpand.hasId()) {
Long valueSetResourcePid = IDao.RESOURCE_PID.get(theValueSetToExpand);
ResourceTable resourceTable = (ResourceTable) myValueSetResourceDao.readEntity(theValueSetToExpand.getIdElement(), null);
Long valueSetResourcePid = resourceTable.getId();
optionalTermValueSet = myValueSetDao.findByResourcePid(valueSetResourcePid);
} else if (theValueSetToExpand.hasUrl()) {
optionalTermValueSet = myValueSetDao.findByUrl(theValueSetToExpand.getUrl());
@ -956,7 +957,8 @@ public abstract class BaseHapiTerminologySvcImpl implements IHapiTerminologySvc,
@Override
public boolean isValueSetPreExpandedForCodeValidation(ValueSet theValueSet) {
Long valueSetResourcePid = IDao.RESOURCE_PID.get(theValueSet);
ResourceTable resourceTable = (ResourceTable) myValueSetResourceDao.readEntity(theValueSet.getIdElement(), null);
Long valueSetResourcePid = resourceTable.getId();
Optional<TermValueSet> optionalTermValueSet = myValueSetDao.findByResourcePid(valueSetResourcePid);
if (!optionalTermValueSet.isPresent()) {
@ -980,7 +982,8 @@ public abstract class BaseHapiTerminologySvcImpl implements IHapiTerminologySvc,
ValueSet theValueSet, String theSystem, String theCode, String theDisplay, Coding theCoding, CodeableConcept theCodeableConcept) {
ValidateUtil.isNotNullOrThrowUnprocessableEntity(theValueSet.hasId(), "ValueSet.id is required");
Long valueSetResourcePid = IDao.RESOURCE_PID.get(theValueSet);
ResourceTable resourceTable = (ResourceTable) myValueSetResourceDao.readEntity(theValueSet.getIdElement(), null);
Long valueSetResourcePid = resourceTable.getId();
List<TermValueSetConcept> concepts = new ArrayList<>();
if (isNotBlank(theCode)) {
@ -1625,7 +1628,8 @@ public abstract class BaseHapiTerminologySvcImpl implements IHapiTerminologySvc,
if (theCodeSystem.getContent() == CodeSystem.CodeSystemContentMode.COMPLETE || theCodeSystem.getContent() == null || theCodeSystem.getContent() == CodeSystem.CodeSystemContentMode.NOTPRESENT) {
ourLog.info("CodeSystem {} has a status of {}, going to store concepts in terminology tables", theResourceEntity.getIdDt().getValue(), theCodeSystem.getContentElement().getValueAsString());
Long codeSystemResourcePid = IDao.RESOURCE_PID.get(theCodeSystem);
ResourceTable resourceTable = (ResourceTable) myCodeSystemResourceDao.readEntity(theCodeSystem.getIdElement(), null);
Long codeSystemResourcePid = resourceTable.getId();
TermCodeSystemVersion persCs = myCodeSystemVersionDao.findCurrentVersionForCodeSystemResourcePid(codeSystemResourcePid);
if (persCs != null) {
ourLog.info("Code system version already exists in database");
@ -1822,7 +1826,7 @@ public abstract class BaseHapiTerminologySvcImpl implements IHapiTerminologySvc,
ourLog.info("Done storing TermConceptMap.");
}
@Scheduled(fixedDelay = 600000) // 10 minutes.
@Scheduled(fixedDelay = 6000) // 10 minutes.
@Override
public synchronized void preExpandDeferredValueSetsToTerminologyTables() {
if (isNotSafeToPreExpandValueSets()) {

View File

@ -1,7 +1,6 @@
package ca.uhn.fhir.jpa.term;
import ca.uhn.fhir.jpa.dao.DaoConfig;
import ca.uhn.fhir.jpa.dao.IDao;
import ca.uhn.fhir.jpa.dao.dstu3.BaseJpaDstu3Test;
import ca.uhn.fhir.jpa.entity.TermCodeSystem;
import ca.uhn.fhir.jpa.entity.TermCodeSystemVersion;
@ -601,7 +600,9 @@ public class TerminologySvcImplDstu3Test extends BaseJpaDstu3Test {
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus theStatus) {
TermCodeSystem codeSystem = myTermCodeSystemDao.findByResourcePid(IDao.RESOURCE_PID.get(codeSystemResource));
ResourceTable resourceTable = (ResourceTable) myCodeSystemDao.readEntity(codeSystemResource.getIdElement(), null);
Long codeSystemResourcePid = resourceTable.getId();
TermCodeSystem codeSystem = myTermCodeSystemDao.findByResourcePid(codeSystemResourcePid);
assertEquals(CS_URL, codeSystem.getCodeSystemUri());
assertEquals("SYSTEM NAME", codeSystem.getName());

View File

@ -2,7 +2,6 @@ package ca.uhn.fhir.jpa.term;
import ca.uhn.fhir.context.support.IContextValidationSupport;
import ca.uhn.fhir.jpa.dao.DaoConfig;
import ca.uhn.fhir.jpa.dao.IDao;
import ca.uhn.fhir.jpa.dao.IFhirResourceDaoValueSet.ValidateCodeResult;
import ca.uhn.fhir.jpa.dao.r4.BaseJpaR4Test;
import ca.uhn.fhir.jpa.entity.*;
@ -1591,7 +1590,9 @@ public class TerminologySvcImplR4Test extends BaseJpaR4Test {
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus theStatus) {
TermCodeSystem codeSystem = myTermCodeSystemDao.findByResourcePid(IDao.RESOURCE_PID.get(codeSystemResource));
ResourceTable resourceTable = (ResourceTable) myCodeSystemDao.readEntity(codeSystemResource.getIdElement(), null);
Long codeSystemResourcePid = resourceTable.getId();
TermCodeSystem codeSystem = myTermCodeSystemDao.findByResourcePid(codeSystemResourcePid);
assertEquals(CS_URL, codeSystem.getCodeSystemUri());
assertEquals("SYSTEM NAME", codeSystem.getName());