FIx problem with non-code having token search params
This commit is contained in:
parent
ab3d656249
commit
1c6bcfee4c
|
@ -22,6 +22,7 @@ import javax.persistence.criteria.Expression;
|
||||||
import javax.persistence.criteria.Predicate;
|
import javax.persistence.criteria.Predicate;
|
||||||
import javax.persistence.criteria.Root;
|
import javax.persistence.criteria.Root;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Required;
|
import org.springframework.beans.factory.annotation.Required;
|
||||||
import org.springframework.transaction.PlatformTransactionManager;
|
import org.springframework.transaction.PlatformTransactionManager;
|
||||||
|
@ -412,11 +413,15 @@ public class FhirResourceDao<T extends IResource> extends BaseFhirDao implements
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<Predicate> singleCodePredicates = (new ArrayList<Predicate>());
|
ArrayList<Predicate> singleCodePredicates = (new ArrayList<Predicate>());
|
||||||
if (system != null) {
|
if (StringUtils.isNotBlank(system)) {
|
||||||
singleCodePredicates.add(builder.equal(from.get("mySystem"), 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));
|
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]));
|
Predicate singleCode = builder.and(singleCodePredicates.toArray(new Predicate[0]));
|
||||||
codePredicates.add(singleCode);
|
codePredicates.add(singleCode);
|
||||||
|
|
|
@ -4,27 +4,20 @@ import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "HFJ_SPIDX_TOKEN" /*, indexes = { @Index(name = "IDX_SP_TOKEN", columnList = "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.Table(appliesTo = "HFJ_SPIDX_TOKEN", indexes = { @org.hibernate.annotations.Index(name = "IDX_SP_TOKEN", columnNames = { "SP_SYSTEM", "SP_VALUE" }) })
|
||||||
@org.hibernate.annotations.Index(name="IDX_SP_TOKEN", columnNames= {"SP_SYSTEM","SP_VALUE"})})
|
|
||||||
public class ResourceIndexedSearchParamToken extends BaseResourceIndexedSearchParam {
|
public class ResourceIndexedSearchParamToken extends BaseResourceIndexedSearchParam {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
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)
|
@Column(name = "SP_SYSTEM", nullable = true, length = 100)
|
||||||
public String mySystem;
|
public String mySystem;
|
||||||
|
|
||||||
public String getSystem() {
|
@Column(name = "SP_VALUE", nullable = true, length = 100)
|
||||||
return mySystem;
|
public String myValue;
|
||||||
}
|
|
||||||
|
|
||||||
public void setSystem(String theSystem) {
|
|
||||||
mySystem = theSystem;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ResourceIndexedSearchParamToken() {
|
public ResourceIndexedSearchParamToken() {
|
||||||
}
|
}
|
||||||
|
@ -35,12 +28,20 @@ public class ResourceIndexedSearchParamToken extends BaseResourceIndexedSearchPa
|
||||||
setValue(theValue);
|
setValue(theValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getSystem() {
|
||||||
|
return mySystem;
|
||||||
|
}
|
||||||
|
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
return myValue;
|
return myValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSystem(String theSystem) {
|
||||||
|
mySystem = StringUtils.defaultIfBlank(theSystem, null);
|
||||||
|
}
|
||||||
|
|
||||||
public void setValue(String theValue) {
|
public void setValue(String theValue) {
|
||||||
myValue = theValue;
|
myValue = StringUtils.defaultIfBlank(theValue, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
@Test
|
||||||
public void testSearchByResourceChain() {
|
public void testSearchByResourceChain() {
|
||||||
Organization o1 = new Organization();
|
Organization o1 = new Organization();
|
||||||
|
|
Loading…
Reference in New Issue