Merge remote-tracking branch 'remotes/origin/master' into expunge-resource-hook
This commit is contained in:
commit
37411a6ae2
|
@ -257,6 +257,29 @@ public class FhirResourceDaoR4CreateTest extends BaseJpaR4Test {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTagsInContainedResourcesPreserved() {
|
||||
Patient p = new Patient();
|
||||
p.setActive(true);
|
||||
|
||||
Organization o = new Organization();
|
||||
o.getMeta().addTag("http://foo", "bar", "FOOBAR");
|
||||
p.getManagingOrganization().setResource(o);
|
||||
|
||||
ourLog.info("Input: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
||||
|
||||
IIdType id = myPatientDao.create(p).getId().toUnqualifiedVersionless();
|
||||
|
||||
p = myPatientDao.read(id);
|
||||
|
||||
ourLog.info("Output: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
||||
|
||||
Organization org = (Organization) p.getManagingOrganization().getResource();
|
||||
assertEquals("#1", org.getId());
|
||||
assertEquals(1, org.getMeta().getTag().size());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
|
|
|
@ -161,7 +161,7 @@ public class FhirResourceDaoR4SearchCustomSearchParamTest extends BaseJpaR4Test
|
|||
sp.setCode("myDoctor");
|
||||
sp.setType(org.hl7.fhir.r4.model.Enumerations.SearchParamType.REFERENCE);
|
||||
sp.setTitle("My Doctor");
|
||||
sp.setExpression("Patient.extension('http://fmcna.com/myDoctor')");
|
||||
sp.setExpression("Patient.extension('http://fmcna.com/myDoctor').value.as(Reference)");
|
||||
sp.setXpathUsage(org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.NORMAL);
|
||||
sp.setStatus(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.ACTIVE);
|
||||
mySearchParameterDao.create(sp);
|
||||
|
@ -184,6 +184,41 @@ public class FhirResourceDaoR4SearchCustomSearchParamTest extends BaseJpaR4Test
|
|||
assertThat(ids, contains(pid.getValue()));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testIndexIntoBundle() {
|
||||
SearchParameter sp = new SearchParameter();
|
||||
sp.addBase("Bundle");
|
||||
sp.setCode("messageid");
|
||||
sp.setType(Enumerations.SearchParamType.TOKEN);
|
||||
sp.setTitle("Message ID");
|
||||
sp.setExpression("Bundle.entry.resource.as(MessageHeader).id");
|
||||
sp.setXpathUsage(org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.NORMAL);
|
||||
sp.setStatus(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.ACTIVE);
|
||||
ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(sp));
|
||||
mySearchParameterDao.create(sp);
|
||||
|
||||
mySearchParamRegistry.forceRefresh();
|
||||
|
||||
MessageHeader messageHeader = new MessageHeader();
|
||||
messageHeader.setId("123");
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.setType(Bundle.BundleType.MESSAGE);
|
||||
bundle.addEntry()
|
||||
.setResource(messageHeader);
|
||||
|
||||
ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle));
|
||||
myBundleDao.create(bundle);
|
||||
|
||||
SearchParameterMap params = new SearchParameterMap();
|
||||
params.add("messageid", new TokenParam("123"));
|
||||
IBundleProvider outcome = myBundleDao.search(params);
|
||||
List<String> ids = toUnqualifiedVersionlessIdValues(outcome);
|
||||
ourLog.info("IDS: " + ids);
|
||||
assertThat(ids, not(empty()));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testExtensionWithNoValueIndexesWithoutFailure() {
|
||||
SearchParameter eyeColourSp = new SearchParameter();
|
||||
|
@ -1075,6 +1110,7 @@ public class FhirResourceDaoR4SearchCustomSearchParamTest extends BaseJpaR4Test
|
|||
sp.setExpression("Observation.specimen.resolve().receivedTime");
|
||||
sp.setXpathUsage(org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.NORMAL);
|
||||
sp.setStatus(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.ACTIVE);
|
||||
ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(sp));
|
||||
mySearchParameterDao.create(sp);
|
||||
|
||||
mySearchParamRegistry.forceRefresh();
|
||||
|
@ -1087,6 +1123,7 @@ public class FhirResourceDaoR4SearchCustomSearchParamTest extends BaseJpaR4Test
|
|||
o.getContained().add(specimen);
|
||||
o.setStatus(Observation.ObservationStatus.FINAL);
|
||||
o.setSpecimen(new Reference("#FOO"));
|
||||
ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(o));
|
||||
myObservationDao.update(o);
|
||||
|
||||
specimen = new Specimen();
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package ca.uhn.fhir.jpa.dao.r4;
|
||||
|
||||
import ca.uhn.fhir.jpa.config.TestR4Config;
|
||||
import ca.uhn.fhir.jpa.dao.DaoConfig;
|
||||
import ca.uhn.fhir.jpa.entity.Search;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceTable;
|
||||
|
@ -36,6 +35,7 @@ import java.util.concurrent.Future;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.leftPad;
|
||||
import static org.awaitility.Awaitility.await;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
|
@ -194,13 +194,17 @@ public class FhirResourceDaoR4SearchOptimizedTest extends BaseJpaR4Test {
|
|||
params.setSearchTotalMode(SearchTotalModeEnum.ACCURATE);
|
||||
params.setSummaryMode(SummaryEnum.DATA);
|
||||
IBundleProvider results = myPatientDao.search(params);
|
||||
String uuid = results.getUuid();
|
||||
final String uuid = results.getUuid();
|
||||
ourLog.info("** Search returned UUID: {}", uuid);
|
||||
assertEquals(200, results.size().intValue());
|
||||
List<String> ids = toUnqualifiedVersionlessIdValues(results, 0, 10, true);
|
||||
assertEquals("Patient/PT00000", ids.get(0));
|
||||
assertEquals("Patient/PT00009", ids.get(9));
|
||||
assertEquals(200, myDatabaseBackedPagingProvider.retrieveResultList(null, uuid).size().intValue());
|
||||
|
||||
await().until(() -> myDatabaseBackedPagingProvider.retrieveResultList(null, uuid).size() != null);
|
||||
results = myDatabaseBackedPagingProvider.retrieveResultList(null, uuid);
|
||||
Integer resultsSize = results.size();
|
||||
assertEquals(200, resultsSize.intValue());
|
||||
|
||||
// Try the same query again. This time the same thing should come back, but
|
||||
// from the cache...
|
||||
|
@ -210,13 +214,14 @@ public class FhirResourceDaoR4SearchOptimizedTest extends BaseJpaR4Test {
|
|||
params.setSearchTotalMode(SearchTotalModeEnum.ACCURATE);
|
||||
params.setSummaryMode(SummaryEnum.DATA);
|
||||
results = myPatientDao.search(params);
|
||||
uuid = results.getUuid();
|
||||
ourLog.info("** Search returned UUID: {}", uuid);
|
||||
String uuid2 = results.getUuid();
|
||||
assertEquals(uuid, uuid2);
|
||||
ourLog.info("** Search returned UUID: {}", uuid2);
|
||||
assertEquals(200, results.size().intValue());
|
||||
ids = toUnqualifiedVersionlessIdValues(results, 0, 10, true);
|
||||
assertEquals("Patient/PT00000", ids.get(0));
|
||||
assertEquals("Patient/PT00009", ids.get(9));
|
||||
assertEquals(200, myDatabaseBackedPagingProvider.retrieveResultList(null, uuid).size().intValue());
|
||||
assertEquals(200, myDatabaseBackedPagingProvider.retrieveResultList(null, uuid2).size().intValue());
|
||||
|
||||
}
|
||||
|
||||
|
@ -250,6 +255,7 @@ public class FhirResourceDaoR4SearchOptimizedTest extends BaseJpaR4Test {
|
|||
ids = toUnqualifiedVersionlessIdValues(results, 0, 10, true);
|
||||
assertEquals("Patient/PT00000", ids.get(0));
|
||||
assertEquals("Patient/PT00009", ids.get(9));
|
||||
await().until(() -> myDatabaseBackedPagingProvider.retrieveResultList(null, uuid2).size() != null);
|
||||
IBundleProvider results2 = myDatabaseBackedPagingProvider.retrieveResultList(null, uuid2);
|
||||
Integer results2Size = results2.size();
|
||||
assertEquals(200, results2Size.intValue());
|
||||
|
|
Loading…
Reference in New Issue