From 2bf63b1fd75ebea3c6d8c35e22b16991d6b889b9 Mon Sep 17 00:00:00 2001 From: jiaola Date: Fri, 11 Oct 2019 19:21:38 -0400 Subject: [PATCH] Enable R5 support in testpage-overlay --- .../main/java/ca/uhn/fhir/to/Controller.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/hapi-fhir-testpage-overlay/src/main/java/ca/uhn/fhir/to/Controller.java b/hapi-fhir-testpage-overlay/src/main/java/ca/uhn/fhir/to/Controller.java index 8e701917867..9ed40191388 100644 --- a/hapi-fhir-testpage-overlay/src/main/java/ca/uhn/fhir/to/Controller.java +++ b/hapi-fhir-testpage-overlay/src/main/java/ca/uhn/fhir/to/Controller.java @@ -294,6 +294,9 @@ public class Controller extends BaseController { case R4: haveSearchParams = extractSearchParamsR4CapabilityStatement(conformance, resourceName, includes, revIncludes, sortParams, haveSearchParams, queryIncludes); break; + case R5: + haveSearchParams = extractSearchParamsR5CapabilityStatement(conformance, resourceName, includes, revIncludes, sortParams, haveSearchParams, queryIncludes); + break; default: throw new IllegalStateException("Unknown FHIR version: " + theRequest.getFhirVersion(myConfig)); } @@ -758,6 +761,38 @@ public class Controller extends BaseController { return haveSearchParams; } + private boolean extractSearchParamsR5CapabilityStatement(IBaseResource theConformance, String resourceName, TreeSet includes, TreeSet theRevIncludes, TreeSet sortParams, + boolean haveSearchParams, List> queryIncludes) { + org.hl7.fhir.r5.model.CapabilityStatement conformance = (org.hl7.fhir.r5.model.CapabilityStatement) theConformance; + for (org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestComponent nextRest : conformance.getRest()) { + for (org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestResourceComponent nextRes : nextRest.getResource()) { + if (nextRes.getTypeElement().getValue().equals(resourceName)) { + for (org.hl7.fhir.r5.model.StringType next : nextRes.getSearchInclude()) { + if (next.isEmpty() == false) { + includes.add(next.getValue()); + } + } + for (org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent next : nextRes.getSearchParam()) { + if (next.getTypeElement().getValue() != org.hl7.fhir.r5.model.Enumerations.SearchParamType.COMPOSITE) { + sortParams.add(next.getNameElement().getValue()); + } + } + if (nextRes.getSearchParam().size() > 0) { + haveSearchParams = true; + } + } else { + // It's a different resource from the one we're searching, so + // scan for revinclude candidates + for (org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestResourceSearchParamComponent next : nextRes.getSearchParam()) { + if (next.getTypeElement().getValue() == org.hl7.fhir.r5.model.Enumerations.SearchParamType.REFERENCE) { + } + } + } + } + } + return haveSearchParams; + } + private boolean handleSearchParam(String paramIdxString, HttpServletRequest theReq, IQuery theQuery, JsonWriter theClientCodeJsonWriter) throws IOException { String nextName = theReq.getParameter("param." + paramIdxString + ".name"); if (isBlank(nextName)) {