Add a test

This commit is contained in:
James Agnew 2019-07-23 11:28:35 -04:00
parent b1e409519d
commit 9094323c43
1 changed files with 38 additions and 1 deletions

View File

@ -161,7 +161,7 @@ public class FhirResourceDaoR4SearchCustomSearchParamTest extends BaseJpaR4Test
sp.setCode("myDoctor"); sp.setCode("myDoctor");
sp.setType(org.hl7.fhir.r4.model.Enumerations.SearchParamType.REFERENCE); sp.setType(org.hl7.fhir.r4.model.Enumerations.SearchParamType.REFERENCE);
sp.setTitle("My Doctor"); 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.setXpathUsage(org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.NORMAL);
sp.setStatus(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.ACTIVE); sp.setStatus(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.ACTIVE);
mySearchParameterDao.create(sp); mySearchParameterDao.create(sp);
@ -184,6 +184,41 @@ public class FhirResourceDaoR4SearchCustomSearchParamTest extends BaseJpaR4Test
assertThat(ids, contains(pid.getValue())); 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 @Test
public void testExtensionWithNoValueIndexesWithoutFailure() { public void testExtensionWithNoValueIndexesWithoutFailure() {
SearchParameter eyeColourSp = new SearchParameter(); SearchParameter eyeColourSp = new SearchParameter();
@ -1075,6 +1110,7 @@ public class FhirResourceDaoR4SearchCustomSearchParamTest extends BaseJpaR4Test
sp.setExpression("Observation.specimen.resolve().receivedTime"); sp.setExpression("Observation.specimen.resolve().receivedTime");
sp.setXpathUsage(org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.NORMAL); sp.setXpathUsage(org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.NORMAL);
sp.setStatus(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.ACTIVE); sp.setStatus(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.ACTIVE);
ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(sp));
mySearchParameterDao.create(sp); mySearchParameterDao.create(sp);
mySearchParamRegistry.forceRefresh(); mySearchParamRegistry.forceRefresh();
@ -1087,6 +1123,7 @@ public class FhirResourceDaoR4SearchCustomSearchParamTest extends BaseJpaR4Test
o.getContained().add(specimen); o.getContained().add(specimen);
o.setStatus(Observation.ObservationStatus.FINAL); o.setStatus(Observation.ObservationStatus.FINAL);
o.setSpecimen(new Reference("#FOO")); o.setSpecimen(new Reference("#FOO"));
ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(o));
myObservationDao.update(o); myObservationDao.update(o);
specimen = new Specimen(); specimen = new Specimen();