Fix compile issues from merge

This commit is contained in:
jamesagnew 2016-02-27 09:42:15 -05:00
parent 7fdbee6f21
commit 3f363eff9f
7 changed files with 80 additions and 64 deletions

View File

@ -796,6 +796,7 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
} }
@SuppressWarnings("unchecked")
private <R extends IBaseResource> R populateResourceMetadataHapi(Class<R> theResourceType, BaseHasResource theEntity, boolean theForHistoryOperation, IResource res) { private <R extends IBaseResource> R populateResourceMetadataHapi(Class<R> theResourceType, BaseHasResource theEntity, boolean theForHistoryOperation, IResource res) {
R retVal = (R) res; R retVal = (R) res;
if (theEntity.getDeleted() != null) { if (theEntity.getDeleted() != null) {
@ -866,6 +867,7 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
return retVal; return retVal;
} }
@SuppressWarnings("unchecked")
private <R extends IBaseResource> R populateResourceMetadataRi(Class<R> theResourceType, BaseHasResource theEntity, boolean theForHistoryOperation, IAnyResource res) { private <R extends IBaseResource> R populateResourceMetadataRi(Class<R> theResourceType, BaseHasResource theEntity, boolean theForHistoryOperation, IAnyResource res) {
R retVal = (R) res; R retVal = (R) res;
if (theEntity.getDeleted() != null) { if (theEntity.getDeleted() != null) {
@ -936,6 +938,7 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
* @return Returns <code>true</code> if the tag should be removed * @return Returns <code>true</code> if the tag should be removed
* @see <a href="http://hl7.org/fhir/2015Sep/resource.html#1.11.3.7">Updates to Tags, Profiles, and Security Labels</a> for a description of the logic that the default behaviour folows. * @see <a href="http://hl7.org/fhir/2015Sep/resource.html#1.11.3.7">Updates to Tags, Profiles, and Security Labels</a> for a description of the logic that the default behaviour folows.
*/ */
@SuppressWarnings("unused")
protected void postPersist(ResourceTable theEntity, T theResource) { protected void postPersist(ResourceTable theEntity, T theResource) {
// nothing // nothing
} }
@ -968,6 +971,8 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
return ids; return ids;
} }
@SuppressWarnings("unused")
@CoverageIgnore
public BaseHasResource readEntity(IIdType theValueId) { public BaseHasResource readEntity(IIdType theValueId) {
throw new NotImplementedException(""); throw new NotImplementedException("");
} }
@ -1194,7 +1199,6 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
} }
@Override @Override
@SuppressWarnings("unchecked")
public <R extends IBaseResource> R toResource(Class<R> theResourceType, BaseHasResource theEntity, boolean theForHistoryOperation) { public <R extends IBaseResource> R toResource(Class<R> theResourceType, BaseHasResource theEntity, boolean theForHistoryOperation) {
String resourceText = null; String resourceText = null;
switch (theEntity.getEncoding()) { switch (theEntity.getEncoding()) {
@ -1563,10 +1567,6 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
return theEntity; return theEntity;
} }
protected ResourceTable updateEntity(final IResource theResource, ResourceTable entity, boolean theUpdateHistory, Date theDeletedTimestampOrNull, Date theUpdateTime) {
return updateEntity(theResource, entity, theUpdateHistory, theDeletedTimestampOrNull, true, true, theUpdateTime);
}
protected void validateDeleteConflictsEmptyOrThrowException(List<DeleteConflict> theDeleteConflicts) { protected void validateDeleteConflictsEmptyOrThrowException(List<DeleteConflict> theDeleteConflicts) {
if (theDeleteConflicts.isEmpty()) { if (theDeleteConflicts.isEmpty()) {
return; return;

View File

@ -1,8 +1,9 @@
package ca.uhn.fhir.jpa.dao; package ca.uhn.fhir.jpa.dao;
import static org.mockito.Mockito.mock;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.sql.DriverManager;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -12,21 +13,29 @@ import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent;
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.instance.model.api.IIdType;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.Before;
import ca.uhn.fhir.jpa.provider.SystemProviderDstu2Test; import ca.uhn.fhir.jpa.provider.SystemProviderDstu2Test;
import ca.uhn.fhir.model.dstu2.resource.Bundle; import ca.uhn.fhir.model.dstu2.resource.Bundle;
import ca.uhn.fhir.model.dstu2.resource.Bundle.Entry; import ca.uhn.fhir.model.dstu2.resource.Bundle.Entry;
import ca.uhn.fhir.rest.server.IBundleProvider; import ca.uhn.fhir.rest.server.IBundleProvider;
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
public class BaseJpaTest { public class BaseJpaTest {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseJpaTest.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseJpaTest.class);
protected ServletRequestDetails mySrd;
@SuppressWarnings({ "rawtypes" }) @SuppressWarnings({ "rawtypes" })
protected List toList(IBundleProvider theSearch) { protected List toList(IBundleProvider theSearch) {
return theSearch.getResources(0, theSearch.size()); return theSearch.getResources(0, theSearch.size());
} }
@Before
public void beforeCreateSrd() {
mySrd = mock(ServletRequestDetails.class);
}
protected List<IIdType> toUnqualifiedVersionlessIds(Bundle theFound) { protected List<IIdType> toUnqualifiedVersionlessIds(Bundle theFound) {
List<IIdType> retVal = new ArrayList<IIdType>(); List<IIdType> retVal = new ArrayList<IIdType>();
for (Entry next : theFound.getEntry()) { for (Entry next : theFound.getEntry()) {

View File

@ -12,6 +12,7 @@ import org.junit.Test;
import ca.uhn.fhir.jpa.dao.SearchParameterMap; import ca.uhn.fhir.jpa.dao.SearchParameterMap;
import ca.uhn.fhir.rest.param.TokenParam; import ca.uhn.fhir.rest.param.TokenParam;
import ca.uhn.fhir.rest.param.TokenParamModifier; import ca.uhn.fhir.rest.param.TokenParamModifier;
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
public class FhirResourceDaoDstu3ContainedTest extends BaseJpaDstu3Test { public class FhirResourceDaoDstu3ContainedTest extends BaseJpaDstu3Test {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDaoDstu3ContainedTest.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDaoDstu3ContainedTest.class);
@ -30,16 +31,16 @@ public class FhirResourceDaoDstu3ContainedTest extends BaseJpaDstu3Test {
Observation o1 = new Observation(); Observation o1 = new Observation();
o1.getCode().setText("Some Observation"); o1.getCode().setText("Some Observation");
o1.setSubject(new Reference(p)); o1.setSubject(new Reference(p));
IIdType oid1 = myObservationDao.create(o1).getId().toUnqualifiedVersionless(); IIdType oid1 = myObservationDao.create(o1, new ServletRequestDetails()).getId().toUnqualifiedVersionless();
Observation o2 = new Observation(); Observation o2 = new Observation();
o2.getCode().setText("Some Observation"); o2.getCode().setText("Some Observation");
o2.setSubject(new Reference(p)); o2.setSubject(new Reference(p));
IIdType oid2 = myObservationDao.create(o2).getId().toUnqualifiedVersionless(); IIdType oid2 = myObservationDao.create(o2, new ServletRequestDetails()).getId().toUnqualifiedVersionless();
Patient p2 = new Patient(); Patient p2 = new Patient();
p2.addName().addFamily("MYFAMILY").addGiven("MYGIVEN"); p2.addName().addFamily("MYFAMILY").addGiven("MYGIVEN");
IIdType pid2 = myPatientDao.create(p2).getId().toUnqualifiedVersionless(); IIdType pid2 = myPatientDao.create(p2, new ServletRequestDetails()).getId().toUnqualifiedVersionless();
ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(o2)); ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(o2));

View File

@ -47,13 +47,13 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
obs1.setStatus(ObservationStatus.FINAL); obs1.setStatus(ObservationStatus.FINAL);
obs1.setValue(new Quantity(123)); obs1.setValue(new Quantity(123));
obs1.setComments("obs1"); obs1.setComments("obs1");
IIdType id1 = myObservationDao.create(obs1, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); IIdType id1 = myObservationDao.create(obs1, mySrd).getId().toUnqualifiedVersionless();
Observation obs2 = new Observation(); Observation obs2 = new Observation();
obs2.getCode().setText("Diastolic Blood Pressure"); obs2.getCode().setText("Diastolic Blood Pressure");
obs2.setStatus(ObservationStatus.FINAL); obs2.setStatus(ObservationStatus.FINAL);
obs2.setValue(new Quantity(81)); obs2.setValue(new Quantity(81));
IIdType id2 = myObservationDao.create(obs2, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); IIdType id2 = myObservationDao.create(obs2, mySrd).getId().toUnqualifiedVersionless();
SearchParameterMap map; SearchParameterMap map;
@ -72,6 +72,10 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
} }
private ServletRequestDetails mockSrd() {
return new ServletRequestDetails();
}
@Test @Test
@Ignore @Ignore
public void testStringTextSearch() { public void testStringTextSearch() {
@ -79,13 +83,13 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
obs1.getCode().setText("AAAAA"); obs1.getCode().setText("AAAAA");
obs1.setValue(new StringType("Systolic Blood Pressure")); obs1.setValue(new StringType("Systolic Blood Pressure"));
obs1.setStatus(ObservationStatus.FINAL); obs1.setStatus(ObservationStatus.FINAL);
IIdType id1 = myObservationDao.create(obs1, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); IIdType id1 = myObservationDao.create(obs1, mockSrd()).getId().toUnqualifiedVersionless();
Observation obs2 = new Observation(); Observation obs2 = new Observation();
obs1.getCode().setText("AAAAA"); obs1.getCode().setText("AAAAA");
obs1.setValue(new StringType("Diastolic Blood Pressure")); obs1.setValue(new StringType("Diastolic Blood Pressure"));
obs2.setStatus(ObservationStatus.FINAL); obs2.setStatus(ObservationStatus.FINAL);
IIdType id2 = myObservationDao.create(obs2, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); IIdType id2 = myObservationDao.create(obs2, mockSrd()).getId().toUnqualifiedVersionless();
SearchParameterMap map; SearchParameterMap map;
@ -100,7 +104,7 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
public void testSuggestIgnoresBase64Content() { public void testSuggestIgnoresBase64Content() {
Patient patient = new Patient(); Patient patient = new Patient();
patient.addName().addFamily("testSuggest"); patient.addName().addFamily("testSuggest");
IIdType ptId = myPatientDao.create(patient, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); IIdType ptId = myPatientDao.create(patient, mockSrd()).getId().toUnqualifiedVersionless();
Media med = new Media(); Media med = new Media();
med.getSubject().setReferenceElement(ptId); med.getSubject().setReferenceElement(ptId);
@ -108,7 +112,7 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
med.getContent().setContentType("LCws"); med.getContent().setContentType("LCws");
med.getContent().setDataElement(new Base64BinaryType(new byte[] {44,44,44,44,44,44,44,44})); med.getContent().setDataElement(new Base64BinaryType(new byte[] {44,44,44,44,44,44,44,44}));
med.getContent().setTitle("bbbb syst"); med.getContent().setTitle("bbbb syst");
myMediaDao.create(med, new ServletRequestDetails()); myMediaDao.create(med, mockSrd());
ourLog.info(myFhirCtx.newJsonParser().encodeResourceToString(med)); ourLog.info(myFhirCtx.newJsonParser().encodeResourceToString(med));
List<Suggestion> output = mySearchDao.suggestKeywords("Patient/" + ptId.getIdPart() + "/$everything", "_content", "press"); List<Suggestion> output = mySearchDao.suggestKeywords("Patient/" + ptId.getIdPart() + "/$everything", "_content", "press");
@ -140,35 +144,35 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
public void testSuggest() { public void testSuggest() {
Patient patient = new Patient(); Patient patient = new Patient();
patient.addName().addFamily("testSuggest"); patient.addName().addFamily("testSuggest");
IIdType ptId = myPatientDao.create(patient, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); IIdType ptId = myPatientDao.create(patient, mockSrd()).getId().toUnqualifiedVersionless();
Observation obs = new Observation(); Observation obs = new Observation();
obs.getSubject().setReferenceElement(ptId); obs.getSubject().setReferenceElement(ptId);
obs.getCode().setText("ZXCVBNM ASDFGHJKL QWERTYUIOPASDFGHJKL"); obs.getCode().setText("ZXCVBNM ASDFGHJKL QWERTYUIOPASDFGHJKL");
myObservationDao.create(obs, new ServletRequestDetails()); myObservationDao.create(obs, mockSrd());
obs = new Observation(); obs = new Observation();
obs.getSubject().setReferenceElement(ptId); obs.getSubject().setReferenceElement(ptId);
obs.getCode().setText("MNBVCXZ"); obs.getCode().setText("MNBVCXZ");
myObservationDao.create(obs, new ServletRequestDetails()); myObservationDao.create(obs, mockSrd());
obs = new Observation(); obs = new Observation();
obs.getSubject().setReferenceElement(ptId); obs.getSubject().setReferenceElement(ptId);
obs.getCode().setText("ZXC HELLO"); obs.getCode().setText("ZXC HELLO");
obs.addComponent().getCode().setText("HHHHHHHHHH"); obs.addComponent().getCode().setText("HHHHHHHHHH");
myObservationDao.create(obs, new ServletRequestDetails()); myObservationDao.create(obs, mockSrd());
/* /*
* These shouldn't match since they're for another patient * These shouldn't match since they're for another patient
*/ */
patient = new Patient(); patient = new Patient();
patient.addName().addFamily("testSuggest2"); patient.addName().addFamily("testSuggest2");
IIdType ptId2 = myPatientDao.create(patient, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); IIdType ptId2 = myPatientDao.create(patient, mockSrd()).getId().toUnqualifiedVersionless();
Observation obs2 = new Observation(); Observation obs2 = new Observation();
obs2.getSubject().setReferenceElement(ptId2); obs2.getSubject().setReferenceElement(ptId2);
obs2.getCode().setText("ZXCVBNMZZ"); obs2.getCode().setText("ZXCVBNMZZ");
myObservationDao.create(obs2, new ServletRequestDetails()); myObservationDao.create(obs2, mockSrd());
List<Suggestion> output = mySearchDao.suggestKeywords("Patient/" + ptId.getIdPart() + "/$everything", "_content", "ZXCVBNM"); List<Suggestion> output = mySearchDao.suggestKeywords("Patient/" + ptId.getIdPart() + "/$everything", "_content", "ZXCVBNM");
ourLog.info("Found: " + output); ourLog.info("Found: " + output);
@ -213,7 +217,7 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
patient = new Patient(); patient = new Patient();
patient.getText().setDivAsString("<div>DIVAAA</div>"); patient.getText().setDivAsString("<div>DIVAAA</div>");
patient.addName().addGiven("NAMEAAA"); patient.addName().addGiven("NAMEAAA");
IIdType pId1 = myPatientDao.create(patient, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); IIdType pId1 = myPatientDao.create(patient, mockSrd()).getId().toUnqualifiedVersionless();
map = new SearchParameterMap(); map = new SearchParameterMap();
map.add(Constants.PARAM_CONTENT, new StringParam("NAMEAAA")); map.add(Constants.PARAM_CONTENT, new StringParam("NAMEAAA"));
@ -231,7 +235,7 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
patient.setId(pId1); patient.setId(pId1);
patient.getText().setDivAsString("<div>DIVBBB</div>"); patient.getText().setDivAsString("<div>DIVBBB</div>");
patient.addName().addGiven("NAMEBBB"); patient.addName().addGiven("NAMEBBB");
myPatientDao.update(patient, new ServletRequestDetails()); myPatientDao.update(patient, mockSrd());
map = new SearchParameterMap(); map = new SearchParameterMap();
map.add(Constants.PARAM_CONTENT, new StringParam("NAMEAAA")); map.add(Constants.PARAM_CONTENT, new StringParam("NAMEAAA"));
@ -255,19 +259,19 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
public void testEverythingInstanceWithContentFilter() { public void testEverythingInstanceWithContentFilter() {
Patient pt1 = new Patient(); Patient pt1 = new Patient();
pt1.addName().addFamily("Everything").addGiven("Arthur"); pt1.addName().addFamily("Everything").addGiven("Arthur");
IIdType ptId1 = myPatientDao.create(pt1, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); IIdType ptId1 = myPatientDao.create(pt1, mockSrd()).getId().toUnqualifiedVersionless();
Patient pt2 = new Patient(); Patient pt2 = new Patient();
pt2.addName().addFamily("Everything").addGiven("Arthur"); pt2.addName().addFamily("Everything").addGiven("Arthur");
IIdType ptId2 = myPatientDao.create(pt2, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); IIdType ptId2 = myPatientDao.create(pt2, mockSrd()).getId().toUnqualifiedVersionless();
Device dev1 = new Device(); Device dev1 = new Device();
dev1.setManufacturer("Some Manufacturer"); dev1.setManufacturer("Some Manufacturer");
IIdType devId1 = myDeviceDao.create(dev1, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); IIdType devId1 = myDeviceDao.create(dev1, mockSrd()).getId().toUnqualifiedVersionless();
Device dev2 = new Device(); Device dev2 = new Device();
dev2.setManufacturer("Some Manufacturer 2"); dev2.setManufacturer("Some Manufacturer 2");
myDeviceDao.create(dev2, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); myDeviceDao.create(dev2, mockSrd()).getId().toUnqualifiedVersionless();
Observation obs1 = new Observation(); Observation obs1 = new Observation();
obs1.getText().setDivAsString("<div>OBSTEXT1</div>"); obs1.getText().setDivAsString("<div>OBSTEXT1</div>");
@ -275,19 +279,19 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
obs1.getCode().addCoding().setCode("CODE1"); obs1.getCode().addCoding().setCode("CODE1");
obs1.setValue(new StringType("obsvalue1")); obs1.setValue(new StringType("obsvalue1"));
obs1.getDevice().setReferenceElement(devId1); obs1.getDevice().setReferenceElement(devId1);
IIdType obsId1 = myObservationDao.create(obs1, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); IIdType obsId1 = myObservationDao.create(obs1, mockSrd()).getId().toUnqualifiedVersionless();
Observation obs2 = new Observation(); Observation obs2 = new Observation();
obs2.getSubject().setReferenceElement(ptId1); obs2.getSubject().setReferenceElement(ptId1);
obs2.getCode().addCoding().setCode("CODE2"); obs2.getCode().addCoding().setCode("CODE2");
obs2.setValue(new StringType("obsvalue2")); obs2.setValue(new StringType("obsvalue2"));
IIdType obsId2 = myObservationDao.create(obs2, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); IIdType obsId2 = myObservationDao.create(obs2, mockSrd()).getId().toUnqualifiedVersionless();
Observation obs3 = new Observation(); Observation obs3 = new Observation();
obs3.getSubject().setReferenceElement(ptId2); obs3.getSubject().setReferenceElement(ptId2);
obs3.getCode().addCoding().setCode("CODE3"); obs3.getCode().addCoding().setCode("CODE3");
obs3.setValue(new StringType("obsvalue3")); obs3.setValue(new StringType("obsvalue3"));
IIdType obsId3 = myObservationDao.create(obs3, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); IIdType obsId3 = myObservationDao.create(obs3, mockSrd()).getId().toUnqualifiedVersionless();
HttpServletRequest request; HttpServletRequest request;
List<String> actual; List<String> actual;
@ -298,16 +302,16 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
param = new StringAndListParam(); param = new StringAndListParam();
param.addAnd(new StringOrListParam().addOr(new StringParam("obsvalue1"))); param.addAnd(new StringOrListParam().addOr(new StringParam("obsvalue1")));
actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientInstanceEverything(request, ptId1, null, null, null, param, null, new ServletRequestDetails())); actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientInstanceEverything(request, ptId1, null, null, null, param, null, mockSrd()));
assertThat(actual, containsInAnyOrder(toValues(ptId1, obsId1, devId1))); assertThat(actual, containsInAnyOrder(toValues(ptId1, obsId1, devId1)));
param = new StringAndListParam(); param = new StringAndListParam();
param.addAnd(new StringOrListParam().addOr(new StringParam("obstext1"))); param.addAnd(new StringOrListParam().addOr(new StringParam("obstext1")));
actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientInstanceEverything(request, ptId1, null, null, null, null, param, new ServletRequestDetails())); actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientInstanceEverything(request, ptId1, null, null, null, null, param, mockSrd()));
assertThat(actual, containsInAnyOrder(toValues(ptId1, obsId1, devId1))); assertThat(actual, containsInAnyOrder(toValues(ptId1, obsId1, devId1)));
request = mock(HttpServletRequest.class); request = mock(HttpServletRequest.class);
actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientInstanceEverything(request, ptId1, null, null, null, null, null, new ServletRequestDetails())); actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientInstanceEverything(request, ptId1, null, null, null, null, null, mockSrd()));
assertThat(actual, containsInAnyOrder(toValues(ptId1, obsId1, obsId2, devId1))); assertThat(actual, containsInAnyOrder(toValues(ptId1, obsId1, obsId2, devId1)));
/* /*
@ -318,12 +322,12 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
obs4.getSubject().setReferenceElement(ptId1); obs4.getSubject().setReferenceElement(ptId1);
obs4.getCode().addCoding().setCode("CODE1"); obs4.getCode().addCoding().setCode("CODE1");
obs4.setValue(new StringType("obsvalue1")); obs4.setValue(new StringType("obsvalue1"));
IIdType obsId4 = myObservationDao.create(obs4, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); IIdType obsId4 = myObservationDao.create(obs4, mockSrd()).getId().toUnqualifiedVersionless();
assertNotEquals(obsId1.getIdPart(), obsId4.getIdPart(), devId1); assertNotEquals(obsId1.getIdPart(), obsId4.getIdPart(), devId1);
param = new StringAndListParam(); param = new StringAndListParam();
param.addAnd(new StringOrListParam().addOr(new StringParam("obsvalue1"))); param.addAnd(new StringOrListParam().addOr(new StringParam("obsvalue1")));
actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientInstanceEverything(request, ptId1, null, null, null, param, null, new ServletRequestDetails())); actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientInstanceEverything(request, ptId1, null, null, null, param, null, mockSrd()));
assertThat(actual, containsInAnyOrder(toValues(ptId1, obsId1, obsId4, devId1))); assertThat(actual, containsInAnyOrder(toValues(ptId1, obsId1, obsId4, devId1)));
/* /*
@ -335,11 +339,11 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
obs1.getSubject().setReferenceElement(ptId1); obs1.getSubject().setReferenceElement(ptId1);
obs1.getCode().addCoding().setCode("CODE2"); obs1.getCode().addCoding().setCode("CODE2");
obs1.setValue(new StringType("obsvalue2")); obs1.setValue(new StringType("obsvalue2"));
myObservationDao.update(obs1, new ServletRequestDetails()); myObservationDao.update(obs1, mockSrd());
param = new StringAndListParam(); param = new StringAndListParam();
param.addAnd(new StringOrListParam().addOr(new StringParam("obsvalue1"))); param.addAnd(new StringOrListParam().addOr(new StringParam("obsvalue1")));
actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientInstanceEverything(request, ptId1, null, null, null, param, null, new ServletRequestDetails())); actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientInstanceEverything(request, ptId1, null, null, null, param, null, mockSrd()));
assertThat(actual, containsInAnyOrder(toValues(ptId1, obsId4))); assertThat(actual, containsInAnyOrder(toValues(ptId1, obsId4)));
} }
@ -348,38 +352,38 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
public void testEverythingTypeWithContentFilter() { public void testEverythingTypeWithContentFilter() {
Patient pt1 = new Patient(); Patient pt1 = new Patient();
pt1.addName().addFamily("Everything").addGiven("Arthur"); pt1.addName().addFamily("Everything").addGiven("Arthur");
IIdType ptId1 = myPatientDao.create(pt1, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); IIdType ptId1 = myPatientDao.create(pt1, mockSrd()).getId().toUnqualifiedVersionless();
Patient pt2 = new Patient(); Patient pt2 = new Patient();
pt2.addName().addFamily("Everything").addGiven("Arthur"); pt2.addName().addFamily("Everything").addGiven("Arthur");
IIdType ptId2 = myPatientDao.create(pt2, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); IIdType ptId2 = myPatientDao.create(pt2, mockSrd()).getId().toUnqualifiedVersionless();
Device dev1 = new Device(); Device dev1 = new Device();
dev1.setManufacturer("Some Manufacturer"); dev1.setManufacturer("Some Manufacturer");
IIdType devId1 = myDeviceDao.create(dev1, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); IIdType devId1 = myDeviceDao.create(dev1, mockSrd()).getId().toUnqualifiedVersionless();
Device dev2 = new Device(); Device dev2 = new Device();
dev2.setManufacturer("Some Manufacturer 2"); dev2.setManufacturer("Some Manufacturer 2");
IIdType devId2 = myDeviceDao.create(dev2, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); myDeviceDao.create(dev2, mockSrd()).getId().toUnqualifiedVersionless();
Observation obs1 = new Observation(); Observation obs1 = new Observation();
obs1.getSubject().setReferenceElement(ptId1); obs1.getSubject().setReferenceElement(ptId1);
obs1.getCode().addCoding().setCode("CODE1"); obs1.getCode().addCoding().setCode("CODE1");
obs1.setValue(new StringType("obsvalue1")); obs1.setValue(new StringType("obsvalue1"));
obs1.getDevice().setReferenceElement(devId1); obs1.getDevice().setReferenceElement(devId1);
IIdType obsId1 = myObservationDao.create(obs1, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); IIdType obsId1 = myObservationDao.create(obs1, mockSrd()).getId().toUnqualifiedVersionless();
Observation obs2 = new Observation(); Observation obs2 = new Observation();
obs2.getSubject().setReferenceElement(ptId1); obs2.getSubject().setReferenceElement(ptId1);
obs2.getCode().addCoding().setCode("CODE2"); obs2.getCode().addCoding().setCode("CODE2");
obs2.setValue(new StringType("obsvalue2")); obs2.setValue(new StringType("obsvalue2"));
IIdType obsId2 = myObservationDao.create(obs2, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); IIdType obsId2 = myObservationDao.create(obs2, mockSrd()).getId().toUnqualifiedVersionless();
Observation obs3 = new Observation(); Observation obs3 = new Observation();
obs3.getSubject().setReferenceElement(ptId2); obs3.getSubject().setReferenceElement(ptId2);
obs3.getCode().addCoding().setCode("CODE3"); obs3.getCode().addCoding().setCode("CODE3");
obs3.setValue(new StringType("obsvalue3")); obs3.setValue(new StringType("obsvalue3"));
IIdType obsId3 = myObservationDao.create(obs3, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); IIdType obsId3 = myObservationDao.create(obs3, mockSrd()).getId().toUnqualifiedVersionless();
HttpServletRequest request; HttpServletRequest request;
List<String> actual; List<String> actual;
@ -390,11 +394,11 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
param = new StringAndListParam(); param = new StringAndListParam();
param.addAnd(new StringOrListParam().addOr(new StringParam("obsvalue1"))); param.addAnd(new StringOrListParam().addOr(new StringParam("obsvalue1")));
actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientTypeEverything(request, null, null, null, param, null, new ServletRequestDetails())); actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientTypeEverything(request, null, null, null, param, null, mockSrd()));
assertThat(actual, containsInAnyOrder(toValues(ptId1, obsId1, devId1))); assertThat(actual, containsInAnyOrder(toValues(ptId1, obsId1, devId1)));
request = mock(HttpServletRequest.class); request = mock(HttpServletRequest.class);
actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientTypeEverything(request, null, null, null, null, null, new ServletRequestDetails())); actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientTypeEverything(request, null, null, null, null, null, mockSrd()));
assertThat(actual, containsInAnyOrder(toValues(ptId1, obsId1, obsId2, devId1, ptId2, obsId3))); assertThat(actual, containsInAnyOrder(toValues(ptId1, obsId1, obsId2, devId1, ptId2, obsId3)));
/* /*
@ -405,12 +409,12 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
obs4.getSubject().setReferenceElement(ptId1); obs4.getSubject().setReferenceElement(ptId1);
obs4.getCode().addCoding().setCode("CODE1"); obs4.getCode().addCoding().setCode("CODE1");
obs4.setValue(new StringType("obsvalue1")); obs4.setValue(new StringType("obsvalue1"));
IIdType obsId4 = myObservationDao.create(obs4, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); IIdType obsId4 = myObservationDao.create(obs4, mockSrd()).getId().toUnqualifiedVersionless();
assertNotEquals(obsId1.getIdPart(), obsId4.getIdPart(), devId1); assertNotEquals(obsId1.getIdPart(), obsId4.getIdPart(), devId1);
param = new StringAndListParam(); param = new StringAndListParam();
param.addAnd(new StringOrListParam().addOr(new StringParam("obsvalue1"))); param.addAnd(new StringOrListParam().addOr(new StringParam("obsvalue1")));
actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientTypeEverything(request, null, null, null, param, null, new ServletRequestDetails())); actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientTypeEverything(request, null, null, null, param, null, mockSrd()));
assertThat(actual, containsInAnyOrder(toValues(ptId1, obsId1, obsId4, devId1))); assertThat(actual, containsInAnyOrder(toValues(ptId1, obsId1, obsId4, devId1)));
/* /*
@ -422,11 +426,11 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
obs1.getSubject().setReferenceElement(ptId1); obs1.getSubject().setReferenceElement(ptId1);
obs1.getCode().addCoding().setCode("CODE2"); obs1.getCode().addCoding().setCode("CODE2");
obs1.setValue(new StringType("obsvalue2")); obs1.setValue(new StringType("obsvalue2"));
myObservationDao.update(obs1, new ServletRequestDetails()); myObservationDao.update(obs1, mockSrd());
param = new StringAndListParam(); param = new StringAndListParam();
param.addAnd(new StringOrListParam().addOr(new StringParam("obsvalue1"))); param.addAnd(new StringOrListParam().addOr(new StringParam("obsvalue1")));
actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientTypeEverything(request, null, null, null, param, null, new ServletRequestDetails())); actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientTypeEverything(request, null, null, null, param, null, mockSrd()));
assertThat(actual, containsInAnyOrder(toValues(ptId1, obsId4))); assertThat(actual, containsInAnyOrder(toValues(ptId1, obsId4)));
} }
@ -444,7 +448,7 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
patient = new Patient(); patient = new Patient();
patient.getText().setDivAsString("<div>DIVAAA</div>"); patient.getText().setDivAsString("<div>DIVAAA</div>");
patient.addName().addGiven("NAMEAAA"); patient.addName().addGiven("NAMEAAA");
IIdType pId1 = myPatientDao.create(patient, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); IIdType pId1 = myPatientDao.create(patient, mockSrd()).getId().toUnqualifiedVersionless();
map = new SearchParameterMap(); map = new SearchParameterMap();
map.add(Constants.PARAM_CONTENT, new StringParam("NAMEAAA")); map.add(Constants.PARAM_CONTENT, new StringParam("NAMEAAA"));
@ -462,7 +466,7 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
patient.setId(pId1); patient.setId(pId1);
patient.getText().setDivAsString("<div>DIVBBB</div>"); patient.getText().setDivAsString("<div>DIVBBB</div>");
patient.addName().addGiven("NAMEBBB"); patient.addName().addGiven("NAMEBBB");
myPatientDao.update(patient, null, false, new ServletRequestDetails()); myPatientDao.update(patient, null, false, mockSrd());
map = new SearchParameterMap(); map = new SearchParameterMap();
map.add(Constants.PARAM_CONTENT, new StringParam("NAMEAAA")); map.add(Constants.PARAM_CONTENT, new StringParam("NAMEAAA"));
@ -471,7 +475,7 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
map.add(Constants.PARAM_CONTENT, new StringParam("NAMEBBB")); map.add(Constants.PARAM_CONTENT, new StringParam("NAMEBBB"));
assertThat(toUnqualifiedVersionlessIdValues(myPatientDao.search(map)), not(contains(toValues(pId1)))); assertThat(toUnqualifiedVersionlessIdValues(myPatientDao.search(map)), not(contains(toValues(pId1))));
myPatientDao.update(patient, null, true, new ServletRequestDetails()); myPatientDao.update(patient, null, true, mockSrd());
map = new SearchParameterMap(); map = new SearchParameterMap();
map.add(Constants.PARAM_CONTENT, new StringParam("NAMEAAA")); map.add(Constants.PARAM_CONTENT, new StringParam("NAMEAAA"));
@ -499,18 +503,18 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
Patient patient = new Patient(); Patient patient = new Patient();
patient.addName().addGiven(methodName); patient.addName().addGiven(methodName);
patient.addAddress().addLine("My fulltext address"); patient.addAddress().addLine("My fulltext address");
pId1 = myPatientDao.create(patient, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); pId1 = myPatientDao.create(patient, mockSrd()).getId().toUnqualifiedVersionless();
} }
Observation obs = new Observation(); Observation obs = new Observation();
obs.getSubject().setReferenceElement(pId1); obs.getSubject().setReferenceElement(pId1);
obs.setValue(new StringType("This is the FULLtext of the observation")); obs.setValue(new StringType("This is the FULLtext of the observation"));
IIdType oId1 = myObservationDao.create(obs, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); IIdType oId1 = myObservationDao.create(obs, mockSrd()).getId().toUnqualifiedVersionless();
obs = new Observation(); obs = new Observation();
obs.getSubject().setReferenceElement(pId1); obs.getSubject().setReferenceElement(pId1);
obs.setValue(new StringType("Another fullText")); obs.setValue(new StringType("Another fullText"));
IIdType oId2 = myObservationDao.create(obs, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); IIdType oId2 = myObservationDao.create(obs, mockSrd()).getId().toUnqualifiedVersionless();
List<String> patients; List<String> patients;
SearchParameterMap params; SearchParameterMap params;

View File

@ -51,6 +51,7 @@ import org.hl7.fhir.dstu3.model.Subscription.SubscriptionStatus;
import org.hl7.fhir.dstu3.model.Substance; import org.hl7.fhir.dstu3.model.Substance;
import org.hl7.fhir.dstu3.model.TemporalPrecisionEnum; import org.hl7.fhir.dstu3.model.TemporalPrecisionEnum;
import org.hl7.fhir.dstu3.model.ValueSet; import org.hl7.fhir.dstu3.model.ValueSet;
import org.hl7.fhir.instance.model.api.IAnyResource;
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.instance.model.api.IIdType;
import org.junit.Ignore; import org.junit.Ignore;
@ -67,6 +68,7 @@ import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamUri;
import ca.uhn.fhir.jpa.entity.ResourceLink; import ca.uhn.fhir.jpa.entity.ResourceLink;
import ca.uhn.fhir.model.api.IQueryParameterType; import ca.uhn.fhir.model.api.IQueryParameterType;
import ca.uhn.fhir.model.api.Include; import ca.uhn.fhir.model.api.Include;
import ca.uhn.fhir.model.dstu.valueset.QuantityCompararatorEnum;
import ca.uhn.fhir.rest.api.SortOrderEnum; import ca.uhn.fhir.rest.api.SortOrderEnum;
import ca.uhn.fhir.rest.api.SortSpec; import ca.uhn.fhir.rest.api.SortSpec;
import ca.uhn.fhir.rest.param.CompositeParam; import ca.uhn.fhir.rest.param.CompositeParam;

View File

@ -322,7 +322,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
Patient p = new Patient(); Patient p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName); p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.setId("Patient/" + methodName); p.setId("Patient/" + methodName);
IIdType id = myPatientDao.update(p).getId(); IIdType id = myPatientDao.update(p, mySrd).getId();
ourLog.info("Created patient, got it: {}", id); ourLog.info("Created patient, got it: {}", id);
Observation o = new Observation(); Observation o = new Observation();
@ -339,7 +339,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
assertThat(respEntry.getResponse().getLocation(), endsWith("/_history/1")); assertThat(respEntry.getResponse().getLocation(), endsWith("/_history/1"));
assertEquals("1", respEntry.getResponse().getEtag()); assertEquals("1", respEntry.getResponse().getEtag());
o = myObservationDao.read(new IdType(respEntry.getResponse().getLocationElement())); o = myObservationDao.read(new IdType(respEntry.getResponse().getLocationElement()), mySrd);
assertEquals(id.toVersionless().getValue(), o.getSubject().getReference()); assertEquals(id.toVersionless().getValue(), o.getSubject().getReference());
assertEquals("1", o.getIdElement().getVersionIdPart()); assertEquals("1", o.getIdElement().getVersionIdPart());
@ -354,11 +354,11 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
Patient p = new Patient(); Patient p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName); p.addIdentifier().setSystem("urn:system").setValue(methodName);
myPatientDao.create(p).getId(); myPatientDao.create(p, mySrd).getId();
p = new Patient(); p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName); p.addIdentifier().setSystem("urn:system").setValue(methodName);
myPatientDao.create(p).getId(); myPatientDao.create(p, mySrd).getId();
Observation o = new Observation(); Observation o = new Observation();
o.getCode().setText("Some Observation"); o.getCode().setText("Some Observation");
@ -382,11 +382,11 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
Patient p = new Patient(); Patient p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName); p.addIdentifier().setSystem("urn:system").setValue(methodName);
myPatientDao.create(p).getId(); myPatientDao.create(p, mySrd).getId();
p = new Patient(); p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName); p.addIdentifier().setSystem("urn:system").setValue(methodName);
myPatientDao.create(p).getId(); myPatientDao.create(p, mySrd).getId();
Observation o = new Observation(); Observation o = new Observation();
o.getCode().setText("Some Observation"); o.getCode().setText("Some Observation");

View File

@ -173,8 +173,8 @@ public class DynamicSearchTest {
@Override @Override
public List<RuntimeSearchParam> getSearchParameters() { public List<RuntimeSearchParam> getSearchParameters() {
ArrayList<RuntimeSearchParam> retVal = new ArrayList<RuntimeSearchParam>(); ArrayList<RuntimeSearchParam> retVal = new ArrayList<RuntimeSearchParam>();
retVal.add(new RuntimeSearchParam("param1", "This is the first parameter", "Patient.param1", RestSearchParameterTypeEnum.STRING)); retVal.add(new RuntimeSearchParam("param1", "This is the first parameter", "Patient.param1", RestSearchParameterTypeEnum.STRING, null));
retVal.add(new RuntimeSearchParam("param2", "This is the second parameter", "Patient.param2", RestSearchParameterTypeEnum.DATE)); retVal.add(new RuntimeSearchParam("param2", "This is the second parameter", "Patient.param2", RestSearchParameterTypeEnum.DATE, null));
return retVal; return retVal;
} }