Merge remote-tracking branch 'origin/ld-20240906-i-repository-factory-return-repository' into ld-20240913-initial-work-evaluate-measure-timezone

This commit is contained in:
Luke deGruchy 2024-09-17 15:33:28 -04:00
commit d3ae5beb4e
6 changed files with 80 additions and 123 deletions

View File

@ -0,0 +1,10 @@
---
type: remove
issue: 6283
title: "Hibernate Search Fulltext fields which were unused
have been removed from indexing.
This will reduce storage usage in Lucene and Elasticsearch.
The fields that were removed are: `myNarrativeTextEdgeNGram`,
`myNarrativeTextNGram`, `myNarrativeTextPhonetic`, `myContentTextEdgeNGram`,
`myContentTextNGram`, `myContentTextPhonetic`.
"

View File

@ -119,21 +119,6 @@ public class ResourceTable extends BaseHasResource implements Serializable, IBas
searchable = Searchable.YES, searchable = Searchable.YES,
projectable = Projectable.YES, projectable = Projectable.YES,
analyzer = "standardAnalyzer") analyzer = "standardAnalyzer")
@FullTextField(
name = "myContentTextEdgeNGram",
searchable = Searchable.YES,
projectable = Projectable.NO,
analyzer = "autocompleteEdgeAnalyzer")
@FullTextField(
name = "myContentTextNGram",
searchable = Searchable.YES,
projectable = Projectable.NO,
analyzer = "autocompleteNGramAnalyzer")
@FullTextField(
name = "myContentTextPhonetic",
searchable = Searchable.YES,
projectable = Projectable.NO,
analyzer = "autocompletePhoneticAnalyzer")
@OptimisticLock(excluded = true) @OptimisticLock(excluded = true)
@IndexingDependency(derivedFrom = @ObjectPath(@PropertyValue(propertyName = "myVersion"))) @IndexingDependency(derivedFrom = @ObjectPath(@PropertyValue(propertyName = "myVersion")))
private String myContentText; private String myContentText;
@ -171,21 +156,6 @@ public class ResourceTable extends BaseHasResource implements Serializable, IBas
searchable = Searchable.YES, searchable = Searchable.YES,
projectable = Projectable.YES, projectable = Projectable.YES,
analyzer = "standardAnalyzer") analyzer = "standardAnalyzer")
@FullTextField(
name = "myNarrativeTextEdgeNGram",
searchable = Searchable.YES,
projectable = Projectable.NO,
analyzer = "autocompleteEdgeAnalyzer")
@FullTextField(
name = "myNarrativeTextNGram",
searchable = Searchable.YES,
projectable = Projectable.NO,
analyzer = "autocompleteNGramAnalyzer")
@FullTextField(
name = "myNarrativeTextPhonetic",
searchable = Searchable.YES,
projectable = Projectable.NO,
analyzer = "autocompletePhoneticAnalyzer")
@OptimisticLock(excluded = true) @OptimisticLock(excluded = true)
@IndexingDependency(derivedFrom = @ObjectPath(@PropertyValue(propertyName = "myVersion"))) @IndexingDependency(derivedFrom = @ObjectPath(@PropertyValue(propertyName = "myVersion")))
private String myNarrativeText; private String myNarrativeText;

View File

@ -44,13 +44,13 @@ public interface ISearchParamExtractor {
/** /**
* Constant for the {@literal theSearchParamFilter} parameters on this interface * Constant for the {@literal theSearchParamFilter} parameters on this interface
* indicating that all search parameters should be indexed. * indicating that all search parameters should be extracted.
*/ */
ISearchParamFilter ALL_PARAMS = t -> t; ISearchParamFilter ALL_PARAMS = t -> t;
/** /**
* Constant for the {@literal theSearchParamFilter} parameters on this interface * Constant for the {@literal theSearchParamFilter} parameters on this interface
* indicating that no search parameters should be indexed. * indicating that no search parameters should be extracted.
*/ */
ISearchParamFilter NO_PARAMS = t -> Collections.emptyList(); ISearchParamFilter NO_PARAMS = t -> Collections.emptyList();
@ -155,7 +155,7 @@ public interface ISearchParamExtractor {
interface ISearchParamFilter { interface ISearchParamFilter {
/** /**
* Given the list of search parameters for indexing, an implementation of this * Given the list of search parameters for extracting, an implementation of this
* interface may selectively remove any that it wants to remove (or can add if desired). * interface may selectively remove any that it wants to remove (or can add if desired).
* <p> * <p>
* Implementations must not modify the list that is passed in. If changes are * Implementations must not modify the list that is passed in. If changes are

View File

@ -1,9 +1,8 @@
package ca.uhn.fhir.jpa.term; package ca.uhn.fhir.jpa.term;
import static org.junit.jupiter.api.Assertions.assertNull;
import ca.uhn.fhir.context.support.IValidationSupport; import ca.uhn.fhir.context.support.IValidationSupport;
import ca.uhn.fhir.context.support.ValidationSupportContext;
import ca.uhn.fhir.context.support.LookupCodeRequest; import ca.uhn.fhir.context.support.LookupCodeRequest;
import ca.uhn.fhir.context.support.ValidationSupportContext;
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao; import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao;
import ca.uhn.fhir.jpa.config.JpaConfig; import ca.uhn.fhir.jpa.config.JpaConfig;
import ca.uhn.fhir.jpa.entity.TermCodeSystem; import ca.uhn.fhir.jpa.entity.TermCodeSystem;
@ -20,9 +19,10 @@ import ca.uhn.fhir.rest.param.UriParam;
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import jakarta.persistence.EntityManager;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IIdType;
import org.hl7.fhir.r4.model.CodeSystem; import org.hl7.fhir.r4.model.CodeSystem;
import org.hl7.fhir.r4.model.CodeType; import org.hl7.fhir.r4.model.CodeType;
import org.hl7.fhir.r4.model.IdType; import org.hl7.fhir.r4.model.IdType;
@ -40,8 +40,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import jakarta.persistence.EntityManager;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
@ -82,14 +80,12 @@ import static ca.uhn.fhir.jpa.term.loinc.LoincUploadPropertiesEnum.LOINC_UPLOAD_
import static ca.uhn.fhir.jpa.term.loinc.LoincUploadPropertiesEnum.LOINC_XML_FILE; import static ca.uhn.fhir.jpa.term.loinc.LoincUploadPropertiesEnum.LOINC_XML_FILE;
import static java.util.stream.Collectors.joining; import static java.util.stream.Collectors.joining;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.fail;
import static org.hl7.fhir.common.hapi.validation.support.ValidationConstants.LOINC_ALL_VALUESET_ID; import static org.hl7.fhir.common.hapi.validation.support.ValidationConstants.LOINC_ALL_VALUESET_ID;
import static org.hl7.fhir.common.hapi.validation.support.ValidationConstants.LOINC_LOW; import static org.hl7.fhir.common.hapi.validation.support.ValidationConstants.LOINC_LOW;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.fail; import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
/** /**
@ -141,9 +137,7 @@ public class TerminologySvcImplCurrentVersionR4Test extends BaseJpaR4Test {
@Autowired @Autowired
private Batch2JobHelper myBatchJobHelper; private Batch2JobHelper myBatchJobHelper;
private final ServletRequestDetails myRequestDetails = new ServletRequestDetails();
private ZipCollectionBuilder myFiles;
private ServletRequestDetails myRequestDetails = new ServletRequestDetails();
private Properties uploadProperties; private Properties uploadProperties;
private IFhirResourceDao<ValueSet> myValueSetIFhirResourceDao; private IFhirResourceDao<ValueSet> myValueSetIFhirResourceDao;
@ -182,17 +176,7 @@ public class TerminologySvcImplCurrentVersionR4Test extends BaseJpaR4Test {
private void validateValidateCode(String theCurrentVersion, Collection<String> allVersions) { private void validateValidateCode(String theCurrentVersion, Collection<String> allVersions) {
IValidationSupport.CodeValidationResult resultNoVersioned = myCodeSystemDao.validateCode(null, validateValidateCodeForVersion(theCurrentVersion);
new UriType(BASE_LOINC_URL), null, new CodeType(VS_NO_VERSIONED_ON_UPLOAD_FIRST_CODE),
null, null, null, null);
assertNotNull(resultNoVersioned);
assertEquals(prefixWithVersion(theCurrentVersion, VS_NO_VERSIONED_ON_UPLOAD_FIRST_DISPLAY), resultNoVersioned.getDisplay());
IValidationSupport.CodeValidationResult resultVersioned = myCodeSystemDao.validateCode(null,
new UriType(BASE_LOINC_URL), null, new CodeType(VS_VERSIONED_ON_UPLOAD_FIRST_CODE),
null, null, null, null);
assertNotNull(resultVersioned);
assertEquals(prefixWithVersion(theCurrentVersion, VS_VERSIONED_ON_UPLOAD_FIRST_DISPLAY), resultVersioned.getDisplay());
allVersions.forEach(this::validateValidateCodeForVersion); allVersions.forEach(this::validateValidateCodeForVersion);
} }
@ -215,13 +199,15 @@ public class TerminologySvcImplCurrentVersionR4Test extends BaseJpaR4Test {
private void validateValueLookup(String theCurrentVersion, Collection<String> allVersions) { private void validateValueLookup(String theCurrentVersion, Collection<String> allVersions) {
IValidationSupport.LookupCodeResult resultNoVer = myValidationSupport.lookupCode( IValidationSupport.LookupCodeResult resultNoVer = myValidationSupport.lookupCode(
new ValidationSupportContext(myValidationSupport), new LookupCodeRequest(BASE_LOINC_URL, VS_NO_VERSIONED_ON_UPLOAD_FIRST_CODE)); new ValidationSupportContext(myValidationSupport),
new LookupCodeRequest(BASE_LOINC_URL, VS_NO_VERSIONED_ON_UPLOAD_FIRST_CODE));
assertNotNull(resultNoVer); assertNotNull(resultNoVer);
String expectedNoVer = prefixWithVersion(theCurrentVersion, VS_NO_VERSIONED_ON_UPLOAD_FIRST_DISPLAY); String expectedNoVer = prefixWithVersion(theCurrentVersion, VS_NO_VERSIONED_ON_UPLOAD_FIRST_DISPLAY);
assertEquals(expectedNoVer, resultNoVer.getCodeDisplay()); assertEquals(expectedNoVer, resultNoVer.getCodeDisplay());
IValidationSupport.LookupCodeResult resultWithVer = myValidationSupport.lookupCode( IValidationSupport.LookupCodeResult resultWithVer = myValidationSupport.lookupCode(
new ValidationSupportContext(myValidationSupport), new LookupCodeRequest(BASE_LOINC_URL, VS_VERSIONED_ON_UPLOAD_FIRST_CODE)); new ValidationSupportContext(myValidationSupport),
new LookupCodeRequest(BASE_LOINC_URL, VS_VERSIONED_ON_UPLOAD_FIRST_CODE));
assertNotNull(resultWithVer); assertNotNull(resultWithVer);
String expectedWithVer = prefixWithVersion(theCurrentVersion, VS_VERSIONED_ON_UPLOAD_FIRST_DISPLAY); String expectedWithVer = prefixWithVersion(theCurrentVersion, VS_VERSIONED_ON_UPLOAD_FIRST_DISPLAY);
assertEquals(expectedWithVer, resultWithVer.getCodeDisplay()); assertEquals(expectedWithVer, resultWithVer.getCodeDisplay());
@ -293,27 +279,13 @@ public class TerminologySvcImplCurrentVersionR4Test extends BaseJpaR4Test {
assertEquals(prefixWithVersion(theCurrentVersion, VS_VERSIONED_ON_UPLOAD_FIRST_DISPLAY), termConceptVerCsvNoVer.getDisplay()); assertEquals(prefixWithVersion(theCurrentVersion, VS_VERSIONED_ON_UPLOAD_FIRST_DISPLAY), termConceptVerCsvNoVer.getDisplay());
if (theCurrentVersion != null) { if (theCurrentVersion != null) {
TermConcept termConceptNoVerCsvVer = (TermConcept) myEntityManager.createQuery( validateExpandedTermConceptsForVersion(theCurrentVersion);
"select tc from TermConcept tc join fetch tc.myCodeSystem tcsv where tc.myCode = '" +
VS_NO_VERSIONED_ON_UPLOAD_FIRST_CODE + "' and tcsv.myCodeSystemVersionId = '" + theCurrentVersion + "'").getSingleResult();
assertNotNull(termConceptNoVerCsvVer);
// data should have version because it was loaded with a version
assertEquals(prefixWithVersion(theCurrentVersion, VS_NO_VERSIONED_ON_UPLOAD_FIRST_DISPLAY), termConceptNoVerCsvVer.getDisplay());
TermConcept termConceptVerCsvVer = (TermConcept) myEntityManager.createQuery(
"select tc from TermConcept tc join fetch tc.myCodeSystem tcsv where tc.myCode = '" +
VS_VERSIONED_ON_UPLOAD_FIRST_CODE + "' and tcsv.myCodeSystemVersionId = '" + theCurrentVersion + "'").getSingleResult();
assertNotNull(termConceptVerCsvVer);
// data should have version because it was loaded with a version
assertEquals(prefixWithVersion(theCurrentVersion, VS_VERSIONED_ON_UPLOAD_FIRST_DISPLAY), termConceptVerCsvVer.getDisplay());
} }
theAllVersions.forEach(this::validateExpandedTermConceptsForVersion); theAllVersions.forEach(this::validateExpandedTermConceptsForVersion);
}); });
} }
private void validateExpandedTermConceptsForVersion(String theVersion) { private void validateExpandedTermConceptsForVersion(String theVersion) {
TermConcept termConceptNoVer = (TermConcept) myEntityManager.createQuery( TermConcept termConceptNoVer = (TermConcept) myEntityManager.createQuery(
"select tc from TermConcept tc join fetch tc.myCodeSystem tcsv where tc.myCode = '" + "select tc from TermConcept tc join fetch tc.myCodeSystem tcsv where tc.myCode = '" +
@ -384,7 +356,7 @@ public class TerminologySvcImplCurrentVersionR4Test extends BaseJpaR4Test {
* no the CodeSystem version. * no the CodeSystem version.
*/ */
private void validateValueSetSearchForVersion(String theVersion) { private void validateValueSetSearchForVersion(String theVersion) {
// for no versioned VS (VS version, different than CS version) // for no versioned VS (VS version, different from CS version)
SearchParameterMap paramsUploadNoVer = new SearchParameterMap("url", new UriParam(VS_NO_VERSIONED_ON_UPLOAD)); SearchParameterMap paramsUploadNoVer = new SearchParameterMap("url", new UriParam(VS_NO_VERSIONED_ON_UPLOAD));
paramsUploadNoVer.add("version", new TokenParam(theVersion)); paramsUploadNoVer.add("version", new TokenParam(theVersion));
@ -398,7 +370,7 @@ public class TerminologySvcImplCurrentVersionR4Test extends BaseJpaR4Test {
assertEquals(expectedLoadNoVersionUnqualifiedId, loadNoVersionValueSet.getIdElement().getIdPart()); assertEquals(expectedLoadNoVersionUnqualifiedId, loadNoVersionValueSet.getIdElement().getIdPart());
// versioned VS (VS version, different than CS version) // versioned VS (VS version, different from CS version)
SearchParameterMap paramsUploadVer = new SearchParameterMap("url", new UriParam(VS_VERSIONED_ON_UPLOAD)); SearchParameterMap paramsUploadVer = new SearchParameterMap("url", new UriParam(VS_VERSIONED_ON_UPLOAD));
paramsUploadVer.add("version", new TokenParam(VS_ANSWER_LIST_VERSION + "-" + theVersion)); paramsUploadVer.add("version", new TokenParam(VS_ANSWER_LIST_VERSION + "-" + theVersion));
@ -437,8 +409,8 @@ public class TerminologySvcImplCurrentVersionR4Test extends BaseJpaR4Test {
Set<String> theExpectedIdVersionsPlusNull = Sets.newHashSet(theExpectedIdVersions); Set<String> theExpectedIdVersionsPlusNull = Sets.newHashSet(theExpectedIdVersions);
theExpectedIdVersionsPlusNull.add(null); theExpectedIdVersionsPlusNull.add(null);
assertThat(theExpectedIdVersionsPlusNull).containsExactlyInAnyOrderElementsOf(theValueSets.stream().map(r -> ((ValueSet) r).getVersion()).toList()); List<String> valueSetVersions = theValueSets.stream().map(r -> ((ValueSet) r).getVersion()).toList();
assertThat(valueSetVersions).containsExactlyInAnyOrderElementsOf(theExpectedIdVersionsPlusNull);
} }
@ -455,14 +427,13 @@ public class TerminologySvcImplCurrentVersionR4Test extends BaseJpaR4Test {
// for CodeSystem: // for CodeSystem:
// _ current CS is present and has no version // _ current CS is present and has no version
CodeSystem codeSystem = myCodeSystemDao.read(new IdType(LOINC_LOW)); CodeSystem codeSystem = myCodeSystemDao.read(new IdType(LOINC_LOW), myRequestDetails);
String csString = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem); String csString = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(codeSystem);
ourLog.info("CodeSystem:\n" + csString); ourLog.info("CodeSystem:\n {}", csString);
HashSet<String> shouldNotBePresentVersions = new HashSet<>(possibleVersions); HashSet<String> shouldNotBePresentVersions = new HashSet<>(possibleVersions);
theAllVersions.forEach(shouldNotBePresentVersions::remove); theAllVersions.forEach(shouldNotBePresentVersions::remove);
shouldNotBePresentVersions.forEach(vv -> assertFalse(csString.contains(vv), assertThat(shouldNotBePresentVersions).noneSatisfy(vv -> assertThat(vv).isEqualTo(codeSystem.getVersion()));
"Found version string: '" + vv + "' in CodeSystem: " + csString));
// same reading it from term service // same reading it from term service
CodeSystem cs = myITermReadSvc.fetchCanonicalCodeSystemFromCompleteContext(BASE_LOINC_URL); CodeSystem cs = myITermReadSvc.fetchCanonicalCodeSystemFromCompleteContext(BASE_LOINC_URL);
@ -501,7 +472,7 @@ public class TerminologySvcImplCurrentVersionR4Test extends BaseJpaR4Test {
@Test() @Test()
public void uploadCurrentNoVersion() throws Exception { public void uploadCurrentNoVersion() throws Exception {
IIdType csId = uploadLoincCodeSystem(null, true); uploadLoincCodeSystem(null, true);
runCommonValidations(Collections.emptyList()); runCommonValidations(Collections.emptyList());
@ -516,7 +487,7 @@ public class TerminologySvcImplCurrentVersionR4Test extends BaseJpaR4Test {
@Test() @Test()
public void uploadWithVersion() throws Exception { public void uploadWithVersion() throws Exception {
String ver = "2.67"; String ver = "2.67";
IIdType csId = uploadLoincCodeSystem(ver, true); uploadLoincCodeSystem(ver, true);
runCommonValidations(Collections.singletonList(ver)); runCommonValidations(Collections.singletonList(ver));
@ -637,25 +608,6 @@ public class TerminologySvcImplCurrentVersionR4Test extends BaseJpaR4Test {
assertThat(vsContainsDisplay).contains(expectedDisplay); assertThat(vsContainsDisplay).contains(expectedDisplay);
} }
private void validateValidateCodeLoincAllVS(String theCurrentVersion, Collection<String> allVersions) {
IValidationSupport.CodeValidationResult resultNoVersioned = myCodeSystemDao.validateCode(null,
new UriType(BASE_LOINC_URL), null, new CodeType(VS_NO_VERSIONED_ON_UPLOAD_FIRST_CODE),
null, null, null, null);
assertNotNull(resultNoVersioned);
assertEquals(prefixWithVersion(theCurrentVersion, VS_NO_VERSIONED_ON_UPLOAD_FIRST_DISPLAY), resultNoVersioned.getDisplay());
IValidationSupport.CodeValidationResult resultVersioned = myCodeSystemDao.validateCode(null,
new UriType(BASE_LOINC_URL), null, new CodeType(VS_VERSIONED_ON_UPLOAD_FIRST_CODE),
null, null, null, null);
assertNotNull(resultVersioned);
assertEquals(prefixWithVersion(theCurrentVersion, VS_VERSIONED_ON_UPLOAD_FIRST_DISPLAY), resultVersioned.getDisplay());
allVersions.forEach(this::validateValidateCodeForVersion);
}
private void validateValueExpandLoincAllVsForVersion(String theVersion) { private void validateValueExpandLoincAllVsForVersion(String theVersion) {
ValueSet vs = myValueSetDao.expandByIdentifier(LOINC_ALL_VS_URL + "|" + theVersion, null); ValueSet vs = myValueSetDao.expandByIdentifier(LOINC_ALL_VS_URL + "|" + theVersion, null);
assertThat(vs.getExpansion().getContains()).hasSize(ALL_VS_QTY); assertThat(vs.getExpansion().getContains()).hasSize(ALL_VS_QTY);
@ -664,7 +616,6 @@ public class TerminologySvcImplCurrentVersionR4Test extends BaseJpaR4Test {
checkContainsElementVersion(vs, theVersion); checkContainsElementVersion(vs, theVersion);
} }
/** /**
* Validates TermConcepts were created in the sequence indicated by the parameters * Validates TermConcepts were created in the sequence indicated by the parameters
* and their displays match the expected versions * and their displays match the expected versions
@ -735,8 +686,8 @@ public class TerminologySvcImplCurrentVersionR4Test extends BaseJpaR4Test {
} }
private IIdType uploadLoincCodeSystem(String theVersion, boolean theMakeItCurrent) throws Exception { private void uploadLoincCodeSystem(String theVersion, boolean theMakeItCurrent) throws Exception {
myFiles = new ZipCollectionBuilder(); ZipCollectionBuilder files = new ZipCollectionBuilder();
myRequestDetails.getUserData().put(LOINC_CODESYSTEM_MAKE_CURRENT, theMakeItCurrent); myRequestDetails.getUserData().put(LOINC_CODESYSTEM_MAKE_CURRENT, theMakeItCurrent);
uploadProperties.put(LOINC_CODESYSTEM_MAKE_CURRENT.getCode(), Boolean.toString(theMakeItCurrent)); uploadProperties.put(LOINC_CODESYSTEM_MAKE_CURRENT.getCode(), Boolean.toString(theMakeItCurrent));
@ -749,12 +700,10 @@ public class TerminologySvcImplCurrentVersionR4Test extends BaseJpaR4Test {
uploadProperties.put(LOINC_CODESYSTEM_VERSION.getCode(), theVersion); uploadProperties.put(LOINC_CODESYSTEM_VERSION.getCode(), theVersion);
} }
addLoincMandatoryFilesToZip(myFiles, theVersion); addLoincMandatoryFilesToZip(files, theVersion);
UploadStatistics stats = myTermLoaderSvc.loadLoinc(myFiles.getFiles(), mySrd); myTermLoaderSvc.loadLoinc(files.getFiles(), mySrd);
myTerminologyDeferredStorageSvc.saveAllDeferred(); myTerminologyDeferredStorageSvc.saveAllDeferred();
return stats.getTarget();
} }
@ -787,10 +736,12 @@ public class TerminologySvcImplCurrentVersionR4Test extends BaseJpaR4Test {
private TermCodeSystemVersion fetchCurrentCodeSystemVersion() { private TermCodeSystemVersion fetchCurrentCodeSystemVersion() {
runInTransaction(() -> { runInTransaction(() -> {
@SuppressWarnings("unchecked")
List<TermCodeSystem> tcsList = myEntityManager.createQuery("from TermCodeSystem").getResultList(); List<TermCodeSystem> tcsList = myEntityManager.createQuery("from TermCodeSystem").getResultList();
@SuppressWarnings("unchecked")
List<TermCodeSystemVersion> tcsvList = myEntityManager.createQuery("from TermCodeSystemVersion").getResultList(); List<TermCodeSystemVersion> tcsvList = myEntityManager.createQuery("from TermCodeSystemVersion").getResultList();
ourLog.error("tcslist: {}", tcsList.stream().map(tcs -> tcs.toString()).collect(joining("\n", "\n", ""))); ourLog.error("tcslist: {}", tcsList.stream().map(TermCodeSystem::toString).collect(joining("\n", "\n", "")));
ourLog.error("tcsvlist: {}", tcsvList.stream().map(v -> v.toString()).collect(joining("\n", "\n", ""))); ourLog.error("tcsvlist: {}", tcsvList.stream().map(TermCodeSystemVersion::toString).collect(joining("\n", "\n", "")));
if (tcsList.size() != 1) { if (tcsList.size() != 1) {
throw new IllegalStateException("More than one TCS: " + throw new IllegalStateException("More than one TCS: " +
@ -807,8 +758,9 @@ public class TerminologySvcImplCurrentVersionR4Test extends BaseJpaR4Test {
} }
private static void addBaseLoincMandatoryFilesToZip( private static void addBaseLoincMandatoryFilesToZip(ZipCollectionBuilder theFiles,
ZipCollectionBuilder theFiles, Boolean theIncludeTop2000, String theClassPathPrefix) throws IOException { @SuppressWarnings("SameParameterValue") Boolean theIncludeTop2000,
String theClassPathPrefix) throws IOException {
theFiles.addFileZip(theClassPathPrefix, LOINC_XML_FILE.getCode()); theFiles.addFileZip(theClassPathPrefix, LOINC_XML_FILE.getCode());
theFiles.addFileZip(theClassPathPrefix, LOINC_GROUP_FILE_DEFAULT.getCode()); theFiles.addFileZip(theClassPathPrefix, LOINC_GROUP_FILE_DEFAULT.getCode());
theFiles.addFileZip(theClassPathPrefix, LOINC_GROUP_TERMS_FILE_DEFAULT.getCode()); theFiles.addFileZip(theClassPathPrefix, LOINC_GROUP_TERMS_FILE_DEFAULT.getCode());

View File

@ -25,6 +25,7 @@ import org.opencds.cqf.fhir.api.Repository;
/** /**
* Factory interface to return a {@link Repository} from a {@link RequestDetails} * Factory interface to return a {@link Repository} from a {@link RequestDetails}
*/ */
@FunctionalInterface
public interface RepositoryFactoryForRepositoryInterface { public interface RepositoryFactoryForRepositoryInterface {
Repository create(RequestDetails theRequestDetails); Repository create(RequestDetails theRequestDetails);
} }

View File

@ -221,6 +221,28 @@ public class RestServerR4Helper extends BaseRestServerHelper implements BeforeEa
myRestServer.setConceptMapResourceProvider(theResourceProvider); myRestServer.setConceptMapResourceProvider(theResourceProvider);
} }
public <T extends IBaseResource> HashMapResourceProvider<T> getResourceProvider(Class<T> theResourceType) {
@SuppressWarnings("unchecked")
HashMapResourceProvider<T> resourceProvider = (HashMapResourceProvider<T>) myRestServer.myResourceProvidersMap.get(theResourceType);
assert resourceProvider != null : "No resource provider defined for resource type: '" + theResourceType + "'" ;
return resourceProvider;
}
public <T extends IBaseResource> void setResourceProvider(HashMapResourceProvider<T> theResourceProvider) {
assert theResourceProvider.getResourceType() != null : "resourceProvider doesn't have a resourceType";
@SuppressWarnings("unchecked")
HashMapResourceProvider<T> resourceProvider = (HashMapResourceProvider<T>) myRestServer.myResourceProvidersMap.get(theResourceProvider.getResourceType());
if (resourceProvider != null) {
resourceProvider.getStoredResources().forEach(theResourceProvider::store);
myRestServer.unregisterProvider(resourceProvider);
}
registerProvider(theResourceProvider);
myRestServer.myResourceProvidersMap.put(theResourceProvider.getResourceType(), theResourceProvider);
}
public void setPagingProvider(IPagingProvider thePagingProvider) { public void setPagingProvider(IPagingProvider thePagingProvider) {
myPagingProvider = thePagingProvider; myPagingProvider = thePagingProvider;
} }
@ -295,6 +317,8 @@ public class RestServerR4Helper extends BaseRestServerHelper implements BeforeEa
private HashMapResourceProvider<ConceptMap> myConceptMapResourceProvider; private HashMapResourceProvider<ConceptMap> myConceptMapResourceProvider;
private RestServerDstu3Helper.MyPlainProvider myPlainProvider; private RestServerDstu3Helper.MyPlainProvider myPlainProvider;
private final Map<Class<?>, HashMapResourceProvider<?>> myResourceProvidersMap = new HashMap<>();
private final boolean myInitialTransactionLatchEnabled; private final boolean myInitialTransactionLatchEnabled;
private PagingHttpMethodEnum myPagingHttpMethod = PagingHttpMethodEnum.GET; private PagingHttpMethodEnum myPagingHttpMethod = PagingHttpMethodEnum.GET;