Add tests and get :below queries working for built-in code systems

This commit is contained in:
jamesagnew 2016-07-01 08:51:47 -04:00
parent 9b6f548970
commit b8f1f39ead
6 changed files with 50 additions and 14 deletions

View File

@ -44,7 +44,6 @@ import org.hl7.fhir.instance.model.api.IAnyResource;
import org.hl7.fhir.instance.model.api.IBase; import org.hl7.fhir.instance.model.api.IBase;
import org.hl7.fhir.instance.model.api.IBaseCoding; import org.hl7.fhir.instance.model.api.IBaseCoding;
import org.hl7.fhir.instance.model.api.IBaseElement; import org.hl7.fhir.instance.model.api.IBaseElement;
import org.hl7.fhir.instance.model.api.IBaseExtension;
import org.hl7.fhir.instance.model.api.IBaseHasExtensions; import org.hl7.fhir.instance.model.api.IBaseHasExtensions;
import org.hl7.fhir.instance.model.api.IBaseHasModifierExtensions; import org.hl7.fhir.instance.model.api.IBaseHasModifierExtensions;
import org.hl7.fhir.instance.model.api.IBaseMetaType; import org.hl7.fhir.instance.model.api.IBaseMetaType;
@ -402,9 +401,9 @@ public abstract class BaseParser implements IParser {
String childName = theChild.getChildNameByDatatype(type); String childName = theChild.getChildNameByDatatype(type);
BaseRuntimeElementDefinition<?> childDef = theChild.getChildElementDefinitionByDatatype(type); BaseRuntimeElementDefinition<?> childDef = theChild.getChildElementDefinitionByDatatype(type);
if (childDef == null) { if (childDef == null) {
if (theValue instanceof IBaseExtension) { // if (theValue instanceof IBaseExtension) {
return null; // return null;
} // }
/* /*
* For RI structures Enumeration class, this replaces the child def * For RI structures Enumeration class, this replaces the child def

View File

@ -144,13 +144,22 @@ public class TokenParam extends BaseParam implements IQueryParameterType {
/** /**
* Returns the system for this token. Note that if a {@link #getModifier()} is being used, the entire value of the * Returns the system for this token. Note that if a {@link #getModifier()} is being used, the entire value of the
* parameter will be placed in {@link #getValue() value} and this method will return <code>null</code>. * parameter will be placed in {@link #getValue() value} and this method will return <code>null</code>.
* <p
* Also note that this value may be <code>null</code> or <code>""</code> (empty string) and that
* each of these have a different meaning. When a token is passed on a URL and it has no
* vertical bar (often meaning "return values that match the given code in any codesystem")
* this method will return <code>null</code>. When a token is passed on a URL and it has
* a vetical bar but nothing before the bar (often meaning "return values that match the
* given code but that have no codesystem) this method will return <code>""</code>
* </p>
*/ */
public String getSystem() { public String getSystem() {
return mySystem; return mySystem;
} }
/** /**
* Returns the value for the token * Returns the value for the token (generally the value to the right of the
* vertical bar on the URL)
*/ */
public String getValue() { public String getValue() {
return myValue; return myValue;

View File

@ -331,7 +331,7 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test {
ValueSet vs = new ValueSet(); ValueSet vs = new ValueSet();
ConceptSetComponent include = vs.getCompose().addInclude(); ConceptSetComponent include = vs.getCompose().addInclude();
include.setSystem(URL_MY_CODE_SYSTEM); include.setSystem(URL_MY_CODE_SYSTEM);
// include.addConcept().setCode("A"); include.addConcept().setCode("A");
// include.addConcept().setCode("AA"); // include.addConcept().setCode("AA");
// include.addConcept().setCode("AAA"); // include.addConcept().setCode("AAA");
// include.addConcept().setCode("AB"); // include.addConcept().setCode("AB");
@ -344,11 +344,12 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test {
ourLog.info(encoded); ourLog.info(encoded);
ArrayList<String> codes = toCodesContains(result.getExpansion().getContains()); ArrayList<String> codes = toCodesContains(result.getExpansion().getContains());
assertThat(codes, containsInAnyOrder("AAA")); assertThat(codes, containsInAnyOrder("A", "AAA"));
assertEquals("AAA", result.getExpansion().getContains().get(0).getCode()); int idx = codes.indexOf("AAA");
assertEquals("Code AAA", result.getExpansion().getContains().get(0).getDisplay()); assertEquals("AAA", result.getExpansion().getContains().get(idx).getCode());
assertEquals(URL_MY_CODE_SYSTEM, result.getExpansion().getContains().get(0).getSystem()); assertEquals("Code AAA", result.getExpansion().getContains().get(idx).getDisplay());
assertEquals(URL_MY_CODE_SYSTEM, result.getExpansion().getContains().get(idx).getSystem());
// //
} }
@ -612,7 +613,6 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test {
@Test @Test
@Ignore
public void testSearchCodeInEmptyValueSet() { public void testSearchCodeInEmptyValueSet() {
ValueSet valueSet = new ValueSet(); ValueSet valueSet = new ValueSet();
valueSet.setUrl(URL_MY_VALUE_SET); valueSet.setUrl(URL_MY_VALUE_SET);

View File

@ -24,7 +24,6 @@ import ca.uhn.fhir.jpa.entity.TermConcept;
import ca.uhn.fhir.jpa.entity.TermConceptParentChildLink.RelationshipTypeEnum; import ca.uhn.fhir.jpa.entity.TermConceptParentChildLink.RelationshipTypeEnum;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException; import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
import ca.uhn.fhir.util.TestUtil; import ca.uhn.fhir.util.TestUtil;
public class TerminologySvcImplTest extends BaseJpaDstu3Test { public class TerminologySvcImplTest extends BaseJpaDstu3Test {

View File

@ -0,0 +1,3 @@
call SYSCS_UTIL.SYSCS_COMPRESS_TABLE('SA', 'HFJ_SEARCH_RESULT', 1);
CALL SYSCS_UTIL.SYSCS_INPLACE_COMPRESS_TABLE( 'SA', 'HFJ_SEARCH_RESULT', 0, 0, 1 );

View File

@ -33,7 +33,7 @@ import ca.uhn.fhir.util.PortUtil;
import ca.uhn.fhir.util.TestUtil; import ca.uhn.fhir.util.TestUtil;
import ca.uhn.fhir.util.UrlUtil; import ca.uhn.fhir.util.UrlUtil;
public class TokenParameterTest { public class TokenParamTest {
private static CloseableHttpClient ourClient; private static CloseableHttpClient ourClient;
private static FhirContext ourCtx = FhirContext.forDstu1(); private static FhirContext ourCtx = FhirContext.forDstu1();
@ -63,6 +63,32 @@ public class TokenParameterTest {
assertEquals("b", ourLastOrList.getValuesAsQueryTokens().get(0).getValue()); assertEquals("b", ourLastOrList.getValuesAsQueryTokens().get(0).getValue());
} }
@Test
public void testNoSystem() throws Exception {
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?identifier=b");
HttpResponse status = ourClient.execute(httpGet);
IOUtils.closeQuietly(status.getEntity().getContent());
assertEquals(200, status.getStatusLine().getStatusCode());
assertEquals(1, ourLastOrList.getListAsCodings().size());
assertEquals(null, ourLastOrList.getValuesAsQueryTokens().get(0).getSystem());
assertEquals("b", ourLastOrList.getValuesAsQueryTokens().get(0).getValue());
}
@Test
public void testEmptySystem() throws Exception {
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?identifier=%7Cb");
HttpResponse status = ourClient.execute(httpGet);
IOUtils.closeQuietly(status.getEntity().getContent());
assertEquals(200, status.getStatusLine().getStatusCode());
assertEquals(1, ourLastOrList.getListAsCodings().size());
assertEquals("", ourLastOrList.getValuesAsQueryTokens().get(0).getSystem());
assertEquals("b", ourLastOrList.getValuesAsQueryTokens().get(0).getValue());
}
@Test @Test
public void testGetModifiersText() throws Exception { public void testGetModifiersText() throws Exception {
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?identifier:text=a%7Cb"); HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?identifier:text=a%7Cb");