Add a test for custom params
This commit is contained in:
parent
b2996d3550
commit
5ac91bfb94
|
@ -35,9 +35,10 @@ public abstract class BaseResourceIndexedSearchParam implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
// TODO: make this nullable=false and a primitive (written may 2017)
|
||||||
@Field()
|
@Field()
|
||||||
@Column(name = "SP_MISSING", nullable = true)
|
@Column(name = "SP_MISSING", nullable = true)
|
||||||
private boolean myMissing;
|
private Boolean myMissing;
|
||||||
|
|
||||||
@Field
|
@Field
|
||||||
@Column(name = "SP_NAME", length = MAX_SP_NAME, nullable = false)
|
@Column(name = "SP_NAME", length = MAX_SP_NAME, nullable = false)
|
||||||
|
@ -83,7 +84,7 @@ public abstract class BaseResourceIndexedSearchParam implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isMissing() {
|
public boolean isMissing() {
|
||||||
return myMissing;
|
return Boolean.TRUE.equals(myMissing);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMissing(boolean theMissing) {
|
public void setMissing(boolean theMissing) {
|
||||||
|
|
|
@ -12,6 +12,7 @@ import java.util.List;
|
||||||
import org.hl7.fhir.dstu3.model.CodeType;
|
import org.hl7.fhir.dstu3.model.CodeType;
|
||||||
import org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender;
|
import org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender;
|
||||||
import org.hl7.fhir.dstu3.model.Patient;
|
import org.hl7.fhir.dstu3.model.Patient;
|
||||||
|
import org.hl7.fhir.dstu3.model.Reference;
|
||||||
import org.hl7.fhir.dstu3.model.SearchParameter;
|
import org.hl7.fhir.dstu3.model.SearchParameter;
|
||||||
import org.hl7.fhir.dstu3.model.StringType;
|
import org.hl7.fhir.dstu3.model.StringType;
|
||||||
import org.hl7.fhir.instance.model.api.IIdType;
|
import org.hl7.fhir.instance.model.api.IIdType;
|
||||||
|
@ -167,7 +168,7 @@ public class FhirResourceDaoDstu3SearchCustomSearchParamTest extends BaseJpaDstu
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSearchForExtension() {
|
public void testSearchForExtensionToken() {
|
||||||
SearchParameter eyeColourSp = new SearchParameter();
|
SearchParameter eyeColourSp = new SearchParameter();
|
||||||
eyeColourSp.addBase("Patient");
|
eyeColourSp.addBase("Patient");
|
||||||
eyeColourSp.setCode("eyecolour");
|
eyeColourSp.setCode("eyecolour");
|
||||||
|
@ -199,6 +200,40 @@ public class FhirResourceDaoDstu3SearchCustomSearchParamTest extends BaseJpaDstu
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSearchForExtensionReference() {
|
||||||
|
|
||||||
|
|
||||||
|
SearchParameter eyeColourSp = new SearchParameter();
|
||||||
|
eyeColourSp.addBase("Patient");
|
||||||
|
eyeColourSp.setCode("sibling");
|
||||||
|
eyeColourSp.setType(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.REFERENCE);
|
||||||
|
eyeColourSp.setTitle("Sibling");
|
||||||
|
eyeColourSp.setExpression("Patient.extension('http://acme.org/sibling')");
|
||||||
|
eyeColourSp.setXpathUsage(org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType.NORMAL);
|
||||||
|
eyeColourSp.setStatus(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.ACTIVE);
|
||||||
|
mySearchParameterDao.create(eyeColourSp, mySrd);
|
||||||
|
|
||||||
|
mySearchParamRegsitry.forceRefresh();
|
||||||
|
|
||||||
|
Patient p1 = new Patient();
|
||||||
|
p1.setActive(true);
|
||||||
|
IIdType p1id = myPatientDao.create(p1).getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
|
Patient p2 = new Patient();
|
||||||
|
p2.setActive(true);
|
||||||
|
p2.addExtension().setUrl("http://acme.org/sibling").setValue(new Reference(p1id));
|
||||||
|
IIdType p2id = myPatientDao.create(p2).getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
|
// Try with custom gender SP
|
||||||
|
SearchParameterMap map = new SearchParameterMap();
|
||||||
|
map.add("sibling", new ReferenceParam(p1id.getValue()));
|
||||||
|
IBundleProvider results = myPatientDao.search(map);
|
||||||
|
List<String> foundResources = toUnqualifiedVersionlessIdValues(results);
|
||||||
|
assertThat(foundResources, contains(p2id.getValue()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSearchWithCustomParam() {
|
public void testSearchWithCustomParam() {
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@
|
||||||
<ul class="nav nav-sidebar" th:unless="${conf.rest.empty}">
|
<ul class="nav nav-sidebar" th:unless="${conf.rest.empty}">
|
||||||
<th:block th:each="resource, resIterStat : ${conf.rest[0].resource}">
|
<th:block th:each="resource, resIterStat : ${conf.rest[0].resource}">
|
||||||
<li th:class="${resourceName} == ${resource.typeElement.valueAsString} ? 'active' : ''">
|
<li th:class="${resourceName} == ${resource.typeElement.valueAsString} ? 'active' : ''">
|
||||||
<a href="#" th:onclick="'doAction(this, \'resource\', \'' + ${resource.typeElement.valueAsString} + '\');'">
|
<a th:id="'leftResource' + ${resource.typeElement.valueAsString}" href="#" th:onclick="'doAction(this, \'resource\', \'' + ${resource.typeElement.valueAsString} + '\');'">
|
||||||
<th:block th:text="${resource.typeElement.valueAsString}" >Patient</th:block>
|
<th:block th:text="${resource.typeElement.valueAsString}" >Patient</th:block>
|
||||||
<span class="badge" th:if="${resourceCounts[resource.typeElement.valueAsString]} != null" th:text="${resourceCounts[resource.typeElement.valueAsString]}"/>
|
<span class="badge" th:if="${resourceCounts[resource.typeElement.valueAsString]} != null" th:text="${resourceCounts[resource.typeElement.valueAsString]}"/>
|
||||||
</a>
|
</a>
|
||||||
|
|
Loading…
Reference in New Issue