FIx problem with non-code having token search params

This commit is contained in:
jamesagnew 2014-06-12 17:38:28 -04:00
parent ab3d656249
commit 1c6bcfee4c
3 changed files with 36 additions and 16 deletions

View File

@ -22,6 +22,7 @@ import javax.persistence.criteria.Expression;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.transaction.PlatformTransactionManager;
@ -412,11 +413,15 @@ public class FhirResourceDao<T extends IResource> extends BaseFhirDao implements
}
ArrayList<Predicate> singleCodePredicates = (new ArrayList<Predicate>());
if (system != null) {
if (StringUtils.isNotBlank(system)) {
singleCodePredicates.add(builder.equal(from.get("mySystem"), system));
} else {
singleCodePredicates.add(builder.isNull(from.get("mySystem")));
}
if (code != null) {
if (StringUtils.isNotBlank(code)) {
singleCodePredicates.add(builder.equal(from.get("myValue"), code));
}else {
singleCodePredicates.add(builder.isNull(from.get("myValue")));
}
Predicate singleCode = builder.and(singleCodePredicates.toArray(new Predicate[0]));
codePredicates.add(singleCode);

View File

@ -4,27 +4,20 @@ import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.apache.commons.lang3.StringUtils;
@Entity
@Table(name = "HFJ_SPIDX_TOKEN" /*, indexes = { @Index(name = "IDX_SP_TOKEN", columnList = "SP_SYSTEM,SP_VALUE") }*/)
@org.hibernate.annotations.Table(appliesTo="HFJ_SPIDX_TOKEN", indexes= {
@org.hibernate.annotations.Index(name="IDX_SP_TOKEN", columnNames= {"SP_SYSTEM","SP_VALUE"})})
@Table(name = "HFJ_SPIDX_TOKEN" /* , indexes = { @Index(name = "IDX_SP_TOKEN", columnList = "SP_SYSTEM,SP_VALUE") } */)
@org.hibernate.annotations.Table(appliesTo = "HFJ_SPIDX_TOKEN", indexes = { @org.hibernate.annotations.Index(name = "IDX_SP_TOKEN", columnNames = { "SP_SYSTEM", "SP_VALUE" }) })
public class ResourceIndexedSearchParamToken extends BaseResourceIndexedSearchParam {
private static final long serialVersionUID = 1L;
@Column(name = "SP_VALUE", nullable = true, length = 100)
public String myValue;
@Column(name = "SP_SYSTEM", nullable = true, length = 100)
public String mySystem;
public String getSystem() {
return mySystem;
}
public void setSystem(String theSystem) {
mySystem = theSystem;
}
@Column(name = "SP_VALUE", nullable = true, length = 100)
public String myValue;
public ResourceIndexedSearchParamToken() {
}
@ -35,12 +28,20 @@ public class ResourceIndexedSearchParamToken extends BaseResourceIndexedSearchPa
setValue(theValue);
}
public String getSystem() {
return mySystem;
}
public String getValue() {
return myValue;
}
public void setSystem(String theSystem) {
mySystem = StringUtils.defaultIfBlank(theSystem, null);
}
public void setValue(String theValue) {
myValue = theValue;
myValue = StringUtils.defaultIfBlank(theValue, null);
}
}

View File

@ -80,6 +80,20 @@ public class CompleteResourceProviderTest {
}
@Test
public void testSearchByIdentifierWithoutSystem() {
Patient p1 = new Patient();
p1.addIdentifier().setValue("testSearchByIdentifierWithoutSystem01");
IdDt p1Id = ourClient.create(p1).getId();
Bundle actual = ourClient.search().forResource(Patient.class).where(Patient.IDENTIFIER.exactly().systemAndCode(null, "testSearchByIdentifierWithoutSystem01")).encodedJson().prettyPrint().execute();
assertEquals(1, actual.size());
assertEquals(p1Id.getUnqualifiedId(), actual.getEntries().get(0).getId().getUnqualifiedId());
}
@Test
public void testSearchByResourceChain() {
Organization o1 = new Organization();