Merge branch 'master' of github.com:jamesagnew/hapi-fhir

This commit is contained in:
James Agnew 2016-07-13 09:22:19 -04:00
commit 0b69367b11
24 changed files with 760 additions and 665 deletions

View File

@ -26,6 +26,13 @@
<version>1.6.0</version> <version>1.6.0</version>
</dependency> </dependency>
<!-- Use an old version of Gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3.1</version>
</dependency>
<!-- <!--
Woodstox note: The hapi-fhir-base-testmindeps-client project includes no Woodstox at all, so that we use the Woodstox note: The hapi-fhir-base-testmindeps-client project includes no Woodstox at all, so that we use the
StAX version that's bundled with the JDK. The hapi-fhir-base-testmindeps-server StAX version that's bundled with the JDK. The hapi-fhir-base-testmindeps-server

View File

@ -38,6 +38,13 @@
<version>3.2</version><!--$NO-MVN-MAN-VER$--> <version>3.2</version><!--$NO-MVN-MAN-VER$-->
</dependency> </dependency>
<!-- Use an old version of Gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3.1</version>
</dependency>
<!-- <!--
Woodstox note: The hapi-fhir-base-testmindeps-client project includes no Woodstox at all, so that we use the Woodstox note: The hapi-fhir-base-testmindeps-client project includes no Woodstox at all, so that we use the
StAX version that's bundled with the JDK. The hapi-fhir-base-testmindeps-server StAX version that's bundled with the JDK. The hapi-fhir-base-testmindeps-server

View File

@ -20,12 +20,9 @@
<!-- JSON --> <!-- JSON -->
<dependency> <dependency>
<groupId>javax.json</groupId> <groupId>com.google.code.gson</groupId>
<artifactId>javax.json-api</artifactId> <artifactId>gson</artifactId>
</dependency> <version>2.7</version>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
</dependency> </dependency>
<!-- XML --> <!-- XML -->

View File

@ -1333,7 +1333,7 @@ public class GenericJaxRsClientDstu2Test {
@Test @Test
public void testReadWithElementsParam() throws Exception { public void testReadWithElementsParam() throws Exception {
String msg = "{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}"; String msg = "{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}";

View File

@ -1335,7 +1335,7 @@ public class GenericJaxRsClientDstu3Test {
@Test @Test
public void testReadWithElementsParam() throws Exception { public void testReadWithElementsParam() throws Exception {
String msg = "{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}"; String msg = "{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}";

View File

@ -1635,7 +1635,9 @@ public class FhirResourceDaoDstu2Test extends BaseJpaDstu2Test {
public void testOrganizationName() { public void testOrganizationName() {
//@formatter:off //@formatter:off
String inputStr = "{\"resourceType\":\"Organization\",\n" + String inputStr =
"{" +
" \"resourceType\":\"Organization\",\n" +
" \"extension\":[\n" + " \"extension\":[\n" +
" {\n" + " {\n" +
" \"url\":\"http://fhir.connectinggta.ca/Profile/organization#providerIdPool\",\n" + " \"url\":\"http://fhir.connectinggta.ca/Profile/organization#providerIdPool\",\n" +
@ -1655,8 +1657,7 @@ public class FhirResourceDaoDstu2Test extends BaseJpaDstu2Test {
" }\n" + " }\n" +
" ],\n" + " ],\n" +
" \"name\":\"Peterborough Regional Health Centre\"\n" + " \"name\":\"Peterborough Regional Health Centre\"\n" +
" }\n" + "}\n";
" }";
//@formatter:on //@formatter:on
Set<Long> val = myOrganizationDao.searchForIds("name", new StringParam("P")); Set<Long> val = myOrganizationDao.searchForIds("name", new StringParam("P"));

View File

@ -2044,7 +2044,9 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
public void testOrganizationName() { public void testOrganizationName() {
//@formatter:off //@formatter:off
String inputStr = "{\"resourceType\":\"Organization\",\n" + String inputStr =
"{" +
" \"resourceType\":\"Organization\",\n" +
" \"extension\":[\n" + " \"extension\":[\n" +
" {\n" + " {\n" +
" \"url\":\"http://fhir.connectinggta.ca/Profile/organization#providerIdPool\",\n" + " \"url\":\"http://fhir.connectinggta.ca/Profile/organization#providerIdPool\",\n" +
@ -2064,8 +2066,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
" }\n" + " }\n" +
" ],\n" + " ],\n" +
" \"name\":\"Peterborough Regional Health Centre\"\n" + " \"name\":\"Peterborough Regional Health Centre\"\n" +
" }\n" + "}\n";
" }";
//@formatter:on //@formatter:on
Set<Long> val = myOrganizationDao.searchForIds("name", new StringParam("P")); Set<Long> val = myOrganizationDao.searchForIds("name", new StringParam("P"));

View File

@ -1232,13 +1232,7 @@ public class JsonParserTest {
@Test @Test
public void testParseSingleQuotes() { public void testParseSingleQuotes() {
try { assertEquals("1", ourCtx.newJsonParser().parseBundle("{ 'resourceType': 'Bundle', 'id':'1' }").getBundleId().getValue());
ourCtx.newJsonParser().parseBundle("{ 'resourceType': 'Bundle' }");
fail();
} catch (DataFormatException e) {
// Should be an error message about how single quotes aren't valid JSON
assertThat(e.getMessage(), containsString("double quote"));
}
} }
@Test @Test

View File

@ -222,7 +222,7 @@ public class CreateTest {
ourLog.info("Response was:\n{}", responseContent); ourLog.info("Response was:\n{}", responseContent);
assertEquals(400, status.getStatusLine().getStatusCode()); assertEquals(400, status.getStatusLine().getStatusCode());
assertThat(responseContent, containsString("Unexpected char")); assertThat(responseContent, containsString("Content does not appear to be FHIR JSON, first non-whitespace character was: '&lt;' (must be '{')"));
} }
@Test @Test

View File

@ -775,7 +775,4 @@
"title" : "HTML Report" "title" : "HTML Report"
} }
] ]
},
"summary" : "\r\n<div xmlns=\"http://www.w3.org/1999/xhtml\"> &#x0A; &#x0A; \r\n <h3>CBC Report for Wile. E. COYOTE (MRN: 23453) issued 3-Mar 2011 11:45</h3> &#x0A;&#x0A; \r\n <!-- you could use ab html table here, but laboratories are still \n using fixed text tables, and this will take decades to change... -->&#x0A; &#x0A; \r\n <pre>&#x0A;Test Units Value Reference Range&#x0A;Haemoglobin g/L 176 135 - 180&#x0A;Red Cell Count x10*12/L 5.9 4.2 - 6.0&#x0A;Haematocrit 0.55+ 0.38 - 0.52&#x0A;Mean Cell Volume fL 99+ 80 - 98&#x0A;Mean Cell Haemoglobin pg 36+ 27 - 35&#x0A;Platelet Count x10*9/L 444 150 - 450&#x0A;White Cell Count x10*9/L 4.6 4.0 - 11.0&#x0A;Neutrophils % 20 &#x0A;Neutrophils x10*9/L 0.9--- 2.0 - 7.5&#x0A;Lymphocytes % 20 &#x0A;Lymphocytes x10*9/L 0.9- 1.1 - 4.0&#x0A;Monocytes % 20 &#x0A;Monocytes x10*9/L 0.9 0.2 - 1.0&#x0A;Eosinophils % 20 &#x0A;Eosinophils x10*9/L 0.92++ 0.04 - 0.40&#x0A;Basophils % 20 &#x0A;Basophils x10*9/L 0.92+++ &lt;0.21&#x0A; </pre>&#x0A; &#x0A; \r\n <p>Acme Laboratory, Inc signed: Dr Pete Pathologist</p>&#x0A; </div>"
} }

View File

@ -377,6 +377,9 @@ public class JsonParserDstu2Test {
ourLog.info(enc); ourLog.info(enc);
//@formatter:off //@formatter:off
String actual = enc.trim();
ourLog.info("Actual:\n{}", actual);
assertEquals("{\n" + assertEquals("{\n" +
" \"resourceType\": \"Patient\",\n" + " \"resourceType\": \"Patient\",\n" +
" \"meta\": {\n" + " \"meta\": {\n" +
@ -402,7 +405,7 @@ public class JsonParserDstu2Test {
" ]\n" + " ]\n" +
" }\n" + " }\n" +
" ]\n" + " ]\n" +
"}", enc.trim()); "}", actual);
//@formatter:on //@formatter:on
Patient parsed = ourCtx.newJsonParser().parseResource(Patient.class, enc); Patient parsed = ourCtx.newJsonParser().parseResource(Patient.class, enc);
@ -1547,7 +1550,16 @@ public class JsonParserDstu2Test {
*/ */
@Test @Test
public void testParseResourceWithInvalidType() { public void testParseResourceWithInvalidType() {
String input = "{" + "\"resourceType\":\"Patient\"," + "\"contained\":[" + " {" + " \"rezType\":\"Organization\"" + " }" + " ]" + "}"; //@formatter:off
String input = "{" +
"\"resourceType\":\"Patient\"," +
"\"contained\":[" +
" {" +
" \"rezType\":\"Organization\"" +
" }" +
" ]" +
"}";
//@formatter:on
IParser jsonParser = ourCtx.newJsonParser().setPrettyPrint(true); IParser jsonParser = ourCtx.newJsonParser().setPrettyPrint(true);
try { try {
@ -1589,7 +1601,7 @@ public class JsonParserDstu2Test {
ourCtx.newJsonParser().parseResource(Conformance.class, input); ourCtx.newJsonParser().parseResource(Conformance.class, input);
fail(); fail();
} catch (DataFormatException e) { } catch (DataFormatException e) {
assertEquals("Syntax error parsing JSON FHIR structure: Expected ARRAY at element 'modifierExtension', found 'OBJECT'", e.getMessage()); assertEquals("Syntax error parsing JSON FHIR structure: Expected ARRAY at element 'modifierExtension', found 'JsonObject'", e.getMessage());
} }
} }

View File

@ -1724,7 +1724,7 @@ public class GenericClientDstu2Test {
@Test @Test
public void testReadWithElementsParam() throws Exception { public void testReadWithElementsParam() throws Exception {
String msg = "{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}"; String msg = "{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}";
ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class); ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
when(myHttpClient.execute(capt.capture())).thenReturn(myHttpResponse); when(myHttpClient.execute(capt.capture())).thenReturn(myHttpResponse);

View File

@ -53,12 +53,6 @@
<version>9.6.0-4</version> <version>9.6.0-4</version>
</dependency> </dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3.1</version>
</dependency>
<!-- Testing --> <!-- Testing -->
<dependency> <dependency>
<groupId>xmlunit</groupId> <groupId>xmlunit</groupId>

View File

@ -926,8 +926,21 @@ public class JsonParserDstu3Test {
*/ */
@Test @Test
public void testExplanationOfBenefit() { public void testExplanationOfBenefit() {
String input = "{" + " \"resourceType\":\"ExplanationOfBenefit\"," + " \"coverage\": {\n" + " \"coverageReference\": {\n" + " \"reference\": \"Coverage/123\"\n" + " }\n" + " },\n" //@formatter:off
+ " \"relationship\": {\n" + " \"system\": \"http://hl7.org/fhir/relationship\",\n" + " \"code\": \"1\",\n" + " \"display\": \"self\"\n" + " }\n" + "}"; String input = "{" +
" \"resourceType\": \"ExplanationOfBenefit\"," +
" \"coverage\": {\n" +
" \"coverageReference\": {\n" +
" \"reference\": \"Coverage/123\"\n" +
" }\n" +
" },\n" +
" \"relationship\": {\n" +
" \"system\": \"http://hl7.org/fhir/relationship\",\n" +
" \"code\": \"1\",\n" +
" \"display\": \"self\"\n" +
" }\n" +
"}";
//@formatter:on
ExplanationOfBenefit eob = ourCtx.newJsonParser().parseResource(ExplanationOfBenefit.class, input); ExplanationOfBenefit eob = ourCtx.newJsonParser().parseResource(ExplanationOfBenefit.class, input);
assertEquals(Reference.class, eob.getCoverage().getCoverage().getClass()); assertEquals(Reference.class, eob.getCoverage().getCoverage().getClass());
@ -1390,9 +1403,24 @@ public class JsonParserDstu3Test {
/** /**
* See #342 * See #342
*/ */
@Test(expected = DataFormatException.class) @Test()
public void testParseInvalid() { public void testParseInvalid() {
try {
ourCtx.newJsonParser().parseResource("FOO"); ourCtx.newJsonParser().parseResource("FOO");
fail();
} catch (DataFormatException e) {
assertEquals("Failed to parse JSON content, error was: Content does not appear to be FHIR JSON, first non-whitespace character was: 'F' (must be '{')", e.getMessage());
}
try {
ourCtx.newJsonParser().parseResource("[\"aaa\"]");
fail();
} catch (DataFormatException e) {
assertEquals("Failed to parse JSON content, error was: Content does not appear to be FHIR JSON, first non-whitespace character was: '[' (must be '{')", e.getMessage());
}
assertEquals(Bundle.class, ourCtx.newJsonParser().parseResource(" {\"resourceType\" : \"Bundle\"}").getClass());
} }
@Test @Test
@ -1458,6 +1486,18 @@ public class JsonParserDstu3Test {
} }
@Test(expected=DataFormatException.class)
public void testParseWithTrailingContent() throws Exception {
//@formatter:off
String bundle = "{\n" +
" \"resourceType\" : \"Bundle\",\n" +
" \"total\" : 1\n" +
"}}";
//@formatter:on
Bundle b = ourCtx.newJsonParser().parseResource(Bundle.class, bundle);
}
/** /**
* See #163 * See #163
*/ */

View File

@ -52,12 +52,6 @@
<version>9.6.0-4</version> <version>9.6.0-4</version>
</dependency> </dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3.1</version>
</dependency>
<!-- Testing --> <!-- Testing -->
<dependency> <dependency>
<groupId>xmlunit</groupId> <groupId>xmlunit</groupId>

View File

@ -1104,13 +1104,7 @@ public class JsonParserHl7OrgDstu2Test {
@Test @Test
public void testParseSingleQuotes() { public void testParseSingleQuotes() {
ourCtx.newJsonParser().parseResource(Bundle.class, "{ \"resourceType\": \"Bundle\" }"); ourCtx.newJsonParser().parseResource(Bundle.class, "{ \"resourceType\": \"Bundle\" }");
try {
ourCtx.newJsonParser().parseResource(Bundle.class, "{ 'resourceType': 'Bundle' }"); ourCtx.newJsonParser().parseResource(Bundle.class, "{ 'resourceType': 'Bundle' }");
fail();
} catch (DataFormatException e) {
// good
}
} }
/** /**

View File

@ -5,14 +5,13 @@ import static org.apache.commons.lang3.StringUtils.defaultString;
import static org.apache.commons.lang3.StringUtils.isBlank; import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.apache.commons.lang3.StringUtils.isNotBlank; import static org.apache.commons.lang3.StringUtils.isNotBlank;
import java.io.IOException;
import java.io.StringWriter; import java.io.StringWriter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.TreeSet; import java.util.TreeSet;
import javax.json.Json;
import javax.json.stream.JsonGenerator;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
@ -29,6 +28,8 @@ import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingResult; import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import com.google.gson.stream.JsonWriter;
import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.context.FhirVersionEnum;
import ca.uhn.fhir.context.RuntimeResourceDefinition; import ca.uhn.fhir.context.RuntimeResourceDefinition;
@ -375,14 +376,16 @@ public class Controller extends BaseController {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@RequestMapping(value = { "/search" }) @RequestMapping(value = { "/search" })
public String actionSearch(HttpServletRequest theReq, HomeRequest theRequest, BindingResult theBindingResult, ModelMap theModel) { public String actionSearch(HttpServletRequest theReq, HomeRequest theRequest, BindingResult theBindingResult, ModelMap theModel) throws IOException {
addCommonParams(theReq, theRequest, theModel); addCommonParams(theReq, theRequest, theModel);
StringWriter clientCodeJsonStringWriter = new StringWriter(); StringWriter clientCodeJsonStringWriter = new StringWriter();
JsonGenerator clientCodeJsonWriter = Json.createGenerator(clientCodeJsonStringWriter); JsonWriter clientCodeJsonWriter = new JsonWriter(clientCodeJsonStringWriter);
clientCodeJsonWriter.writeStartObject(); clientCodeJsonWriter.beginObject();
clientCodeJsonWriter.write("action", "search"); clientCodeJsonWriter.name("action");
clientCodeJsonWriter.write("base", (String) theModel.get("base")); clientCodeJsonWriter.value("search");
clientCodeJsonWriter.name("base");
clientCodeJsonWriter.value((String) theModel.get("base"));
CaptureInterceptor interceptor = new CaptureInterceptor(); CaptureInterceptor interceptor = new CaptureInterceptor();
GenericClient client = theRequest.newClient(theReq, getContext(theRequest), myConfig, interceptor); GenericClient client = theRequest.newClient(theReq, getContext(theRequest), myConfig, interceptor);
@ -396,27 +399,34 @@ public class Controller extends BaseController {
theModel.put("errorMsg", e.toString()); theModel.put("errorMsg", e.toString());
return "resource"; return "resource";
} }
clientCodeJsonWriter.write("resource", theReq.getParameter("resource")); clientCodeJsonWriter.name("resource");
clientCodeJsonWriter.value(theReq.getParameter("resource"));
} else { } else {
query = search.forAllResources(); query = search.forAllResources();
clientCodeJsonWriter.writeNull("resource"); clientCodeJsonWriter.name("resource");
clientCodeJsonWriter.nullValue();
} }
if (client.getPrettyPrint() != null) { if (client.getPrettyPrint() != null) {
clientCodeJsonWriter.write("pretty", client.getPrettyPrint().toString()); clientCodeJsonWriter.name("pretty");
clientCodeJsonWriter.value(client.getPrettyPrint().toString());
} else { } else {
clientCodeJsonWriter.writeNull("pretty"); clientCodeJsonWriter.name("pretty");
clientCodeJsonWriter.nullValue();
} }
if (client.getEncoding() != null) { if (client.getEncoding() != null) {
clientCodeJsonWriter.write("format", client.getEncoding().getRequestContentType()); clientCodeJsonWriter.name("format");
clientCodeJsonWriter.value(client.getEncoding().getRequestContentType());
} else { } else {
clientCodeJsonWriter.writeNull("format"); clientCodeJsonWriter.name("format");
clientCodeJsonWriter.nullValue();
} }
String outcomeDescription = "Search for Resources"; String outcomeDescription = "Search for Resources";
clientCodeJsonWriter.writeStartArray("params"); clientCodeJsonWriter.name("params");
clientCodeJsonWriter.beginArray();
int paramIdx = -1; int paramIdx = -1;
while (true) { while (true) {
paramIdx++; paramIdx++;
@ -427,31 +437,33 @@ public class Controller extends BaseController {
break; break;
} }
} }
clientCodeJsonWriter.writeEnd(); clientCodeJsonWriter.endArray();
clientCodeJsonWriter.writeStartArray("includes"); clientCodeJsonWriter.name("includes");
clientCodeJsonWriter.beginArray();
String[] incValues = theReq.getParameterValues(Constants.PARAM_INCLUDE); String[] incValues = theReq.getParameterValues(Constants.PARAM_INCLUDE);
if (incValues != null) { if (incValues != null) {
for (String next : incValues) { for (String next : incValues) {
if (isNotBlank(next)) { if (isNotBlank(next)) {
query.include(new Include(next)); query.include(new Include(next));
clientCodeJsonWriter.write(next); clientCodeJsonWriter.value(next);
} }
} }
} }
clientCodeJsonWriter.writeEnd(); clientCodeJsonWriter.endArray();
clientCodeJsonWriter.writeStartArray("revincludes"); clientCodeJsonWriter.name("revincludes");
clientCodeJsonWriter.beginArray();
String[] revIncValues = theReq.getParameterValues(Constants.PARAM_REVINCLUDE); String[] revIncValues = theReq.getParameterValues(Constants.PARAM_REVINCLUDE);
if (revIncValues != null) { if (revIncValues != null) {
for (String next : revIncValues) { for (String next : revIncValues) {
if (isNotBlank(next)) { if (isNotBlank(next)) {
query.revInclude(new Include(next)); query.revInclude(new Include(next));
clientCodeJsonWriter.write(next); clientCodeJsonWriter.value(next);
} }
} }
} }
clientCodeJsonWriter.writeEnd(); clientCodeJsonWriter.endArray();
String limit = theReq.getParameter("resource-search-limit"); String limit = theReq.getParameter("resource-search-limit");
if (isNotBlank(limit)) { if (isNotBlank(limit)) {
@ -461,9 +473,11 @@ public class Controller extends BaseController {
} }
int limitInt = Integer.parseInt(limit); int limitInt = Integer.parseInt(limit);
query.limitTo(limitInt); query.limitTo(limitInt);
clientCodeJsonWriter.write("limit", limit); clientCodeJsonWriter.name("limit");
clientCodeJsonWriter.value(limit);
} else { } else {
clientCodeJsonWriter.writeNull("limit"); clientCodeJsonWriter.name("limit");
clientCodeJsonWriter.nullValue();
} }
String[] sort = theReq.getParameterValues("sort_by"); String[] sort = theReq.getParameterValues("sort_by");
@ -501,7 +515,7 @@ public class Controller extends BaseController {
processAndAddLastClientInvocation(client, returnsResource, theModel, delay, outcomeDescription, interceptor, theRequest); processAndAddLastClientInvocation(client, returnsResource, theModel, delay, outcomeDescription, interceptor, theRequest);
clientCodeJsonWriter.writeEnd(); clientCodeJsonWriter.endObject();
clientCodeJsonWriter.close(); clientCodeJsonWriter.close();
String clientCodeJson = clientCodeJsonStringWriter.toString(); String clientCodeJson = clientCodeJsonStringWriter.toString();
theModel.put("clientCodeJson", clientCodeJson); theModel.put("clientCodeJson", clientCodeJson);
@ -714,8 +728,7 @@ public class Controller extends BaseController {
} }
private boolean extractSearchParamsDstu1(IBaseResource theConformance, String resourceName, TreeSet<String> includes, TreeSet<String> sortParams, List<RestQuery> queries, boolean haveSearchParams, private boolean extractSearchParamsDstu1(IBaseResource theConformance, String resourceName, TreeSet<String> includes, TreeSet<String> sortParams, List<RestQuery> queries, boolean haveSearchParams, List<List<String>> queryIncludes) {
List<List<String>> queryIncludes) {
Conformance conformance = (Conformance) theConformance; Conformance conformance = (Conformance) theConformance;
for (Rest nextRest : conformance.getRest()) { for (Rest nextRest : conformance.getRest()) {
for (RestResource nextRes : nextRest.getResource()) { for (RestResource nextRes : nextRest.getResource()) {
@ -763,8 +776,7 @@ public class Controller extends BaseController {
return haveSearchParams; return haveSearchParams;
} }
private boolean extractSearchParamsDstu2(IBaseResource theConformance, String resourceName, TreeSet<String> includes, TreeSet<String> theRevIncludes, TreeSet<String> sortParams, List<RestQuery> queries, boolean haveSearchParams, private boolean extractSearchParamsDstu2(IBaseResource theConformance, String resourceName, TreeSet<String> includes, TreeSet<String> theRevIncludes, TreeSet<String> sortParams, List<RestQuery> queries, boolean haveSearchParams, List<List<String>> queryIncludes) {
List<List<String>> queryIncludes) {
ca.uhn.fhir.model.dstu2.resource.Conformance conformance = (ca.uhn.fhir.model.dstu2.resource.Conformance) theConformance; ca.uhn.fhir.model.dstu2.resource.Conformance conformance = (ca.uhn.fhir.model.dstu2.resource.Conformance) theConformance;
for (ca.uhn.fhir.model.dstu2.resource.Conformance.Rest nextRest : conformance.getRest()) { for (ca.uhn.fhir.model.dstu2.resource.Conformance.Rest nextRest : conformance.getRest()) {
for (ca.uhn.fhir.model.dstu2.resource.Conformance.RestResource nextRes : nextRest.getResource()) { for (ca.uhn.fhir.model.dstu2.resource.Conformance.RestResource nextRes : nextRest.getResource()) {
@ -800,8 +812,7 @@ public class Controller extends BaseController {
return haveSearchParams; return haveSearchParams;
} }
private boolean extractSearchParamsDstu3(IBaseResource theConformance, String resourceName, TreeSet<String> includes, TreeSet<String> theRevIncludes, TreeSet<String> sortParams, List<RestQuery> queries, boolean haveSearchParams, private boolean extractSearchParamsDstu3(IBaseResource theConformance, String resourceName, TreeSet<String> includes, TreeSet<String> theRevIncludes, TreeSet<String> sortParams, List<RestQuery> queries, boolean haveSearchParams, List<List<String>> queryIncludes) {
List<List<String>> queryIncludes) {
org.hl7.fhir.dstu3.model.Conformance conformance = (org.hl7.fhir.dstu3.model.Conformance) theConformance; org.hl7.fhir.dstu3.model.Conformance conformance = (org.hl7.fhir.dstu3.model.Conformance) theConformance;
for (ConformanceRestComponent nextRest : conformance.getRest()) { for (ConformanceRestComponent nextRest : conformance.getRest()) {
for (ConformanceRestResourceComponent nextRes : nextRest.getResource()) { for (ConformanceRestResourceComponent nextRes : nextRest.getResource()) {
@ -837,7 +848,7 @@ public class Controller extends BaseController {
return haveSearchParams; return haveSearchParams;
} }
private boolean handleSearchParam(String paramIdxString, HttpServletRequest theReq, IQuery<?> theQuery, JsonGenerator theClientCodeJsonWriter) { private boolean handleSearchParam(String paramIdxString, HttpServletRequest theReq, IQuery<?> theQuery, JsonWriter theClientCodeJsonWriter) throws IOException {
String nextName = theReq.getParameter("param." + paramIdxString + ".name"); String nextName = theReq.getParameter("param." + paramIdxString + ".name");
if (isBlank(nextName)) { if (isBlank(nextName)) {
return false; return false;
@ -921,12 +932,16 @@ public class Controller extends BaseController {
for (String nextValue : values) { for (String nextValue : values) {
theClientCodeJsonWriter.writeStartObject(); theClientCodeJsonWriter.beginObject();
theClientCodeJsonWriter.write("type", nextType); theClientCodeJsonWriter.name("type");
theClientCodeJsonWriter.write("name", nextName); theClientCodeJsonWriter.value(nextType);
theClientCodeJsonWriter.write("qualifier", nextQualifier); theClientCodeJsonWriter.name("name");
theClientCodeJsonWriter.write("value", nextValue); theClientCodeJsonWriter.value(nextName);
theClientCodeJsonWriter.writeEnd(); theClientCodeJsonWriter.name("qualifier");
theClientCodeJsonWriter.value(nextQualifier);
theClientCodeJsonWriter.name("value");
theClientCodeJsonWriter.value(nextValue);
theClientCodeJsonWriter.endObject();
if (addToWhere) { if (addToWhere) {
theQuery.where(new StringClientParam(nextName + nextQualifier).matches().value(nextValue)); theQuery.where(new StringClientParam(nextName + nextQualifier).matches().value(nextValue));
} }