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

This commit is contained in:
James Agnew 2018-08-13 11:54:36 -04:00
commit bc1ee1f9dc
51 changed files with 1870 additions and 1068 deletions

View File

@ -4,8 +4,8 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>2.3-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
<version>2.5-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>hapi-fhir-jaxrs-sse</artifactId>
<build>

View File

@ -9,9 +9,9 @@ package ca.uhn.fhir.model.view;
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -20,31 +20,21 @@ package ca.uhn.fhir.model.view;
* #L%
*/
import ca.uhn.fhir.context.*;
import org.hl7.fhir.instance.model.api.*;
import java.util.List;
import org.hl7.fhir.instance.model.api.IBase;
import org.hl7.fhir.instance.model.api.IBaseExtension;
import ca.uhn.fhir.context.BaseRuntimeChildDefinition;
import ca.uhn.fhir.context.BaseRuntimeElementCompositeDefinition;
import ca.uhn.fhir.context.ConfigurationException;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.RuntimeChildDeclaredExtensionDefinition;
import ca.uhn.fhir.context.RuntimeResourceDefinition;
import ca.uhn.fhir.model.api.BaseElement;
import ca.uhn.fhir.model.api.ExtensionDt;
import ca.uhn.fhir.model.api.IResource;
public class ViewGenerator {
private FhirContext myCtx;
public ViewGenerator(FhirContext theFhirContext) {
myCtx=theFhirContext;
myCtx = theFhirContext;
}
public <T extends IResource> T newView(IResource theResource, Class<T> theTargetType) {
Class<? extends IResource> sourceType = theResource.getClass();
public <T extends IBaseResource> T newView(IBaseResource theResource, Class<T> theTargetType) {
Class<? extends IBaseResource> sourceType = theResource.getClass();
RuntimeResourceDefinition sourceDef = myCtx.getResourceDefinition(theResource);
RuntimeResourceDefinition targetDef = myCtx.getResourceDefinition(theTargetType);
@ -57,18 +47,16 @@ public class ViewGenerator {
T retVal;
try {
retVal = theTargetType.newInstance();
} catch (InstantiationException e) {
throw new ConfigurationException("Failed to instantiate " + theTargetType, e);
} catch (IllegalAccessException e) {
} catch (Exception e) {
throw new ConfigurationException("Failed to instantiate " + theTargetType, e);
}
copyChildren(sourceDef, (BaseElement) theResource, targetDef, (BaseElement) retVal);
copyChildren(sourceDef, (IBase) theResource, targetDef, (IBase) retVal);
return retVal;
}
private void copyChildren(BaseRuntimeElementCompositeDefinition<?> theSourceDef, BaseElement theSource, BaseRuntimeElementCompositeDefinition<?> theTargetDef, BaseElement theTarget) {
private void copyChildren(BaseRuntimeElementCompositeDefinition<?> theSourceDef, IBase theSource, BaseRuntimeElementCompositeDefinition<?> theTargetDef, IBase theTarget) {
if (!theSource.isEmpty()) {
List<BaseRuntimeChildDefinition> targetChildren = theTargetDef.getChildren();
List<RuntimeChildDeclaredExtensionDefinition> targetExts = theTargetDef.getExtensions();
@ -79,7 +67,7 @@ public class ViewGenerator {
if (nextChild.getValidChildNames().size() > 1) {
elementName = nextChild.getValidChildNames().iterator().next();
}
BaseRuntimeChildDefinition sourceChildEquivalent = theSourceDef.getChildByNameOrThrowDataFormatException(elementName);
if (sourceChildEquivalent == null) {
continue;
@ -89,7 +77,7 @@ public class ViewGenerator {
for (IBase nextElement : sourceValues) {
boolean handled = false;
if (nextElement instanceof IBaseExtension) {
String url = ((IBaseExtension<?,?>) nextElement).getUrl();
String url = ((IBaseExtension<?, ?>) nextElement).getUrl();
for (RuntimeChildDeclaredExtensionDefinition nextExt : targetExts) {
String nextTargetUrl = nextExt.getExtensionUrl();
if (!nextTargetUrl.equals(url)) {
@ -97,40 +85,49 @@ public class ViewGenerator {
}
addExtension(theSourceDef, theSource, theTarget, nextExt, url);
handled = true;
}
}
}
}
if (!handled) {
nextChild.getMutator().addValue(theTarget, nextElement);
}
}
}
for (RuntimeChildDeclaredExtensionDefinition nextExt : targetExts) {
String url = nextExt.getExtensionUrl();
addExtension(theSourceDef, theSource, theTarget, nextExt, url);
}
}
}
private void addExtension(BaseRuntimeElementCompositeDefinition<?> theSourceDef, BaseElement theSource, BaseElement theTarget, RuntimeChildDeclaredExtensionDefinition nextExt, String url) {
private void addExtension(BaseRuntimeElementCompositeDefinition<?> theSourceDef, IBase theSource, IBase theTarget, RuntimeChildDeclaredExtensionDefinition nextExt, String url) {
RuntimeChildDeclaredExtensionDefinition sourceDeclaredExt = theSourceDef.getDeclaredExtension(url, "");
if (sourceDeclaredExt == null) {
for (ExtensionDt next : theSource.getAllUndeclaredExtensions()) {
if (next.getUrlAsString().equals(url)) {
nextExt.getMutator().addValue(theTarget, next.getValue());
if (theSource instanceof IBaseHasExtensions) {
for (IBaseExtension<?, ?> next : ((IBaseHasExtensions) theSource).getExtension()) {
if (next.getUrl().equals(url)) {
nextExt.getMutator().addValue(theTarget, next.getValue());
}
}
}
if (theSource instanceof IBaseHasModifierExtensions) {
for (IBaseExtension<?, ?> next : ((IBaseHasModifierExtensions) theSource).getModifierExtension()) {
if (next.getUrl().equals(url)) {
nextExt.getMutator().addValue(theTarget, next.getValue());
}
}
}
} else {
List<? extends IBase> values = sourceDeclaredExt.getAccessor().getValues(theSource);
for (IBase nextElement : values) {
nextExt.getMutator().addValue(theTarget, nextElement);
}
}
}
}

View File

@ -9,9 +9,9 @@ package ca.uhn.fhir.util;
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -32,6 +32,7 @@ import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.Locale;
import java.util.TimeZone;
import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicInteger;
import static org.apache.commons.lang3.StringUtils.defaultString;
@ -144,6 +145,24 @@ public class TestUtil {
}
}
/**
* <b>THIS IS FOR UNIT TESTS ONLY - DO NOT CALL THIS METHOD FROM USER CODE</b>
* <p>
* Wait for an atomicinteger to hit a given site and fail if it never does
*/
public static void waitForSize(int theTarget, Callable<Integer> theSource) throws Exception {
long start = System.currentTimeMillis();
while (theSource.call() != theTarget && (System.currentTimeMillis() - start) <= 15000) {
try {
Thread.sleep(50);
} catch (InterruptedException theE) {
throw new Error(theE);
}
}
if ((System.currentTimeMillis() - start) >= 15000) {
throw new IllegalStateException("Size " + theSource.call() + " is != target " + theTarget);
}
}
/**
* <b>THIS IS FOR UNIT TESTS ONLY - DO NOT CALL THIS METHOD FROM USER CODE</b>

View File

@ -0,0 +1,41 @@
package ca.uhn.fhir.jpa.dao;
/*
* #%L
* HAPI FHIR JPA Server
* %%
* Copyright (C) 2014 - 2018 University Health Network
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import ca.uhn.fhir.model.dstu2.resource.Composition;
import ca.uhn.fhir.rest.api.SortSpec;
import ca.uhn.fhir.rest.api.server.IBundleProvider;
import ca.uhn.fhir.rest.api.server.RequestDetails;
import ca.uhn.fhir.rest.param.DateRangeParam;
import ca.uhn.fhir.rest.server.exceptions.NotImplementedOperationException;
import org.hl7.fhir.instance.model.api.IIdType;
import org.hl7.fhir.instance.model.api.IPrimitiveType;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest;
public class FhirResourceDaoCompositionDstu2 extends FhirResourceDaoDstu2<Composition>implements IFhirResourceDaoComposition<Composition> {
@Override
public IBundleProvider getDocumentForComposition(HttpServletRequest theServletRequest, IIdType theId, IPrimitiveType<Integer> theCount, DateRangeParam theLastUpdate, SortSpec theSort, RequestDetails theRequestDetails) {
throw new NotImplementedOperationException("$document not implemented in DSTU2");
}
}

View File

@ -0,0 +1,37 @@
package ca.uhn.fhir.jpa.dao;
import ca.uhn.fhir.rest.api.SortSpec;
import ca.uhn.fhir.rest.api.server.IBundleProvider;
import ca.uhn.fhir.rest.api.server.RequestDetails;
import ca.uhn.fhir.rest.param.DateRangeParam;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IIdType;
import org.hl7.fhir.instance.model.api.IPrimitiveType;
import javax.servlet.http.HttpServletRequest;
/*
* #%L
* HAPI FHIR JPA Server
* %%
* Copyright (C) 2014 - 2018 University Health Network
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
public interface IFhirResourceDaoComposition<T extends IBaseResource> extends IFhirResourceDao<T> {
IBundleProvider getDocumentForComposition(HttpServletRequest theServletRequest, IIdType theId, IPrimitiveType<Integer> theCount, DateRangeParam theLastUpdate, SortSpec theSort, RequestDetails theRequestDetails);
}

View File

@ -0,0 +1,58 @@
package ca.uhn.fhir.jpa.dao.dstu3;
/*
* #%L
* HAPI FHIR JPA Server
* %%
* Copyright (C) 2014 - 2018 University Health Network
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import ca.uhn.fhir.jpa.dao.IFhirResourceDaoComposition;
import ca.uhn.fhir.jpa.dao.ISearchParamRegistry;
import ca.uhn.fhir.jpa.dao.SearchParameterMap;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.rest.api.SortSpec;
import ca.uhn.fhir.rest.api.server.IBundleProvider;
import ca.uhn.fhir.rest.api.server.RequestDetails;
import ca.uhn.fhir.rest.param.DateRangeParam;
import ca.uhn.fhir.rest.param.StringParam;
import org.hl7.fhir.dstu3.model.Composition;
import org.hl7.fhir.instance.model.api.IIdType;
import org.hl7.fhir.instance.model.api.IPrimitiveType;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest;
import java.util.Collections;
public class FhirResourceDaoCompositionDstu3 extends FhirResourceDaoDstu3<Composition> implements IFhirResourceDaoComposition<Composition> {
@Override
public IBundleProvider getDocumentForComposition(HttpServletRequest theServletRequest, IIdType theId, IPrimitiveType<Integer> theCount, DateRangeParam theLastUpdate, SortSpec theSort, RequestDetails theRequestDetails) {
SearchParameterMap paramMap = new SearchParameterMap();
if (theCount != null) {
paramMap.setCount(theCount.getValue());
}
paramMap.setIncludes(Collections.singleton(IResource.INCLUDE_ALL.asRecursive()));
paramMap.setSort(theSort);
paramMap.setLastUpdated(theLastUpdate);
if (theId != null) {
paramMap.add("_id", new StringParam(theId.getIdPart()));
}
IBundleProvider bundleProvider = search(paramMap);
return bundleProvider;
}
}

View File

@ -41,9 +41,6 @@ import ca.uhn.fhir.rest.param.*;
public class FhirResourceDaoPatientDstu3 extends FhirResourceDaoDstu3<Patient>implements IFhirResourceDaoPatient<Patient> {
@Autowired
private ISearchParamRegistry mySerarchParamRegistry;
private IBundleProvider doEverythingOperation(IIdType theId, IPrimitiveType<Integer> theCount, DateRangeParam theLastUpdated, SortSpec theSort, StringAndListParam theContent, StringAndListParam theNarrative, RequestDetails theRequestDetails) {
SearchParameterMap paramMap = new SearchParameterMap();
if (theCount != null) {

View File

@ -0,0 +1,58 @@
package ca.uhn.fhir.jpa.dao.r4;
/*
* #%L
* HAPI FHIR JPA Server
* %%
* Copyright (C) 2014 - 2018 University Health Network
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import ca.uhn.fhir.jpa.dao.IFhirResourceDaoComposition;
import ca.uhn.fhir.jpa.dao.ISearchParamRegistry;
import ca.uhn.fhir.jpa.dao.SearchParameterMap;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.rest.api.SortSpec;
import ca.uhn.fhir.rest.api.server.IBundleProvider;
import ca.uhn.fhir.rest.api.server.RequestDetails;
import ca.uhn.fhir.rest.param.DateRangeParam;
import ca.uhn.fhir.rest.param.StringParam;
import org.hl7.fhir.instance.model.api.IIdType;
import org.hl7.fhir.instance.model.api.IPrimitiveType;
import org.hl7.fhir.r4.model.Composition;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest;
import java.util.Collections;
public class FhirResourceDaoCompositionR4 extends FhirResourceDaoR4<Composition>implements IFhirResourceDaoComposition<Composition> {
@Override
public IBundleProvider getDocumentForComposition(HttpServletRequest theServletRequest, IIdType theId, IPrimitiveType<Integer> theCount, DateRangeParam theLastUpdate, SortSpec theSort, RequestDetails theRequestDetails) {
SearchParameterMap paramMap = new SearchParameterMap();
if (theCount != null) {
paramMap.setCount(theCount.getValue());
}
paramMap.setIncludes(Collections.singleton(IResource.INCLUDE_ALL.asRecursive()));
paramMap.setSort(theSort);
paramMap.setLastUpdated(theLastUpdate);
if (theId != null) {
paramMap.add("_id", new StringParam(theId.getIdPart()));
}
IBundleProvider bundleProvider = search(paramMap);
return bundleProvider;
}
}

View File

@ -41,9 +41,6 @@ import ca.uhn.fhir.rest.param.*;
public class FhirResourceDaoPatientR4 extends FhirResourceDaoR4<Patient>implements IFhirResourceDaoPatient<Patient> {
@Autowired
private ISearchParamRegistry mySerarchParamRegistry;
private IBundleProvider doEverythingOperation(IIdType theId, IPrimitiveType<Integer> theCount, DateRangeParam theLastUpdated, SortSpec theSort, StringAndListParam theContent, StringAndListParam theNarrative, RequestDetails theRequestDetails) {
SearchParameterMap paramMap = new SearchParameterMap();
if (theCount != null) {

View File

@ -0,0 +1,63 @@
package ca.uhn.fhir.jpa.provider;
import ca.uhn.fhir.jpa.dao.IFhirResourceDaoComposition;
import ca.uhn.fhir.jpa.util.JpaConstants;
import ca.uhn.fhir.model.api.annotation.Description;
import ca.uhn.fhir.model.dstu2.resource.Bundle;
import ca.uhn.fhir.model.dstu2.resource.Composition;
import ca.uhn.fhir.model.valueset.BundleTypeEnum;
import ca.uhn.fhir.rest.annotation.IdParam;
import ca.uhn.fhir.rest.annotation.Operation;
import ca.uhn.fhir.rest.annotation.OperationParam;
import ca.uhn.fhir.rest.annotation.Sort;
import ca.uhn.fhir.rest.api.Constants;
import ca.uhn.fhir.rest.api.SortSpec;
import ca.uhn.fhir.rest.api.server.IBundleProvider;
import ca.uhn.fhir.rest.api.server.RequestDetails;
import ca.uhn.fhir.rest.param.DateRangeParam;
import org.hl7.fhir.instance.model.api.IBaseBundle;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
/*
* #%L
* HAPI FHIR JPA Server
* %%
* Copyright (C) 2014 - 2018 University Health Network
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
public class BaseJpaResourceProviderCompositionDstu2 extends JpaResourceProviderDstu2<Composition> {
/**
* Composition/123/$document
*/
//@formatter:off
@Operation(name = JpaConstants.OPERATION_DOCUMENT, idempotent = true, bundleType=BundleTypeEnum.SEARCHSET)
public IBaseBundle getDocumentForComposition(
javax.servlet.http.HttpServletRequest theServletRequest) {
//@formatter:on
startRequest(theServletRequest);
try {
((IFhirResourceDaoComposition<Composition>)getDao()).getDocumentForComposition(theServletRequest, null, null, null, null, null);
return null;
} finally {
endRequest(theServletRequest);
}
}
}

View File

@ -0,0 +1,91 @@
package ca.uhn.fhir.jpa.provider.dstu3;
import ca.uhn.fhir.jpa.dao.IFhirResourceDaoComposition;
import ca.uhn.fhir.jpa.util.JpaConstants;
import ca.uhn.fhir.model.api.annotation.Description;
import ca.uhn.fhir.model.valueset.BundleTypeEnum;
import ca.uhn.fhir.rest.annotation.IdParam;
import ca.uhn.fhir.rest.annotation.Operation;
import ca.uhn.fhir.rest.annotation.OperationParam;
import ca.uhn.fhir.rest.annotation.Sort;
import ca.uhn.fhir.rest.api.Constants;
import ca.uhn.fhir.rest.api.SortSpec;
import ca.uhn.fhir.rest.api.server.IBundleProvider;
import ca.uhn.fhir.rest.api.server.RequestDetails;
import ca.uhn.fhir.rest.param.DateRangeParam;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import org.hl7.fhir.dstu3.model.*;
import org.hl7.fhir.instance.model.api.IBaseBundle;
import org.hl7.fhir.instance.model.api.IBaseResource;
import javax.print.attribute.standard.Severity;
import java.util.ArrayList;
import java.util.List;
/*
* #%L
* HAPI FHIR JPA Server
* %%
* Copyright (C) 2014 - 2018 University Health Network
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
public class BaseJpaResourceProviderCompositionDstu3 extends JpaResourceProviderDstu3<Composition> {
/**
* Composition/123/$document
*
* @param theRequestDetails
*/
//@formatter:off
@Operation(name = JpaConstants.OPERATION_DOCUMENT, idempotent = true, bundleType=BundleTypeEnum.DOCUMENT)
public IBaseBundle getDocumentForComposition(
javax.servlet.http.HttpServletRequest theServletRequest,
@IdParam
IdType theId,
@Description(formalDefinition="Results from this method are returned across multiple pages. This parameter controls the size of those pages.")
@OperationParam(name = Constants.PARAM_COUNT)
UnsignedIntType theCount,
@Description(shortDefinition="Only return resources which were last updated as specified by the given range")
@OperationParam(name = Constants.PARAM_LASTUPDATED, min=0, max=1)
DateRangeParam theLastUpdated,
@Sort
SortSpec theSortSpec,
RequestDetails theRequestDetails
) {
//@formatter:on
startRequest(theServletRequest);
try {
IBundleProvider bundleProvider = ((IFhirResourceDaoComposition<Composition>) getDao()).getDocumentForComposition(theServletRequest, theId, theCount, theLastUpdated, theSortSpec, theRequestDetails);
List<IBaseResource> resourceList = bundleProvider.getResources(0, bundleProvider.size());
boolean foundCompositionResource = false;
Bundle bundle = new Bundle().setType(Bundle.BundleType.DOCUMENT);
for (IBaseResource resource : resourceList) {
bundle.addEntry(new Bundle.BundleEntryComponent().setResource((Resource) resource));
}
return bundle;
} finally {
endRequest(theServletRequest);
}
}
}

View File

@ -0,0 +1,89 @@
package ca.uhn.fhir.jpa.provider.r4;
import ca.uhn.fhir.jpa.dao.IFhirResourceDaoComposition;
import ca.uhn.fhir.jpa.util.JpaConstants;
import ca.uhn.fhir.model.api.annotation.Description;
import ca.uhn.fhir.model.valueset.BundleTypeEnum;
import ca.uhn.fhir.rest.annotation.IdParam;
import ca.uhn.fhir.rest.annotation.Operation;
import ca.uhn.fhir.rest.annotation.OperationParam;
import ca.uhn.fhir.rest.annotation.Sort;
import ca.uhn.fhir.rest.api.Constants;
import ca.uhn.fhir.rest.api.SortSpec;
import ca.uhn.fhir.rest.api.server.IBundleProvider;
import ca.uhn.fhir.rest.api.server.RequestDetails;
import ca.uhn.fhir.rest.param.DateRangeParam;
import org.hl7.fhir.instance.model.api.IBaseBundle;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.r4.model.*;
import java.util.List;
/*
* #%L
* HAPI FHIR JPA Server
* %%
* Copyright (C) 2014 - 2018 University Health Network
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
public class BaseJpaResourceProviderCompositionR4 extends JpaResourceProviderR4<Composition> {
/**
* Composition/123/$document
*
* @param theRequestDetails
*/
//@formatter:off
@Operation(name = JpaConstants.OPERATION_DOCUMENT, idempotent = true, bundleType=BundleTypeEnum.DOCUMENT)
public IBaseBundle getDocumentForComposition(
javax.servlet.http.HttpServletRequest theServletRequest,
@IdParam
IdType theId,
@Description(formalDefinition="Results from this method are returned across multiple pages. This parameter controls the size of those pages.")
@OperationParam(name = Constants.PARAM_COUNT)
UnsignedIntType theCount,
@Description(shortDefinition="Only return resources which were last updated as specified by the given range")
@OperationParam(name = Constants.PARAM_LASTUPDATED, min=0, max=1)
DateRangeParam theLastUpdated,
@Sort
SortSpec theSortSpec,
RequestDetails theRequestDetails
) {
//@formatter:on
startRequest(theServletRequest);
try {
IBundleProvider bundleProvider = ((IFhirResourceDaoComposition<Composition>) getDao()).getDocumentForComposition(theServletRequest, theId, theCount, theLastUpdated, theSortSpec, theRequestDetails);
List<IBaseResource> resourceList = bundleProvider.getResources(0, bundleProvider.size());
boolean foundCompositionResource = false;
Bundle bundle = new Bundle().setType(Bundle.BundleType.DOCUMENT);
for (IBaseResource resource : resourceList) {
bundle.addEntry(new Bundle.BundleEntryComponent().setResource((Resource) resource));
}
return bundle;
} finally {
endRequest(theServletRequest);
}
}
}

View File

@ -169,4 +169,9 @@ public class JpaConstants {
* Operation name for the $translate operation
*/
public static final String OPERATION_TRANSLATE = "$translate";
/**
* Operation name for the $document operation
*/
public static final String OPERATION_DOCUMENT = "$document";
}

View File

@ -168,6 +168,9 @@ public abstract class BaseJpaDstu3Test extends BaseJpaTest {
@Qualifier("myPatientDaoDstu3")
protected IFhirResourceDaoPatient<Patient> myPatientDao;
@Autowired
@Qualifier("myCompositionDaoDstu3")
protected IFhirResourceDao<Composition> myCompositionDao;
@Autowired
@Qualifier("myCommunicationDaoDstu3")
protected IFhirResourceDao<Communication> myCommunicationDao;
@Autowired

View File

@ -26,6 +26,4 @@ public class FhirResourceDaoDocumentDstu3Test extends BaseJpaDstu3Test {
Bundle inputBundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, input);
DaoMethodOutcome responseBundle = myBundleDao.create(inputBundle, mySrd);
}
}

View File

@ -1315,7 +1315,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
ourLog.info(output);
List<IdDt> ids = toIdListUnqualifiedVersionless(myFhirCtx.newXmlParser().parseResource(Bundle.class, output));
ourLog.info(ids.toString());
assertThat(ids, containsInAnyOrder(pId, cId));
assertThat(ids, containsInAnyOrder(pId, cId, oId));
} finally {
response.close();
}
@ -1330,7 +1330,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
ourLog.info(output);
List<IdDt> ids = toIdListUnqualifiedVersionless(myFhirCtx.newXmlParser().parseResource(Bundle.class, output));
ourLog.info(ids.toString());
assertThat(ids, containsInAnyOrder(pId, cId));
assertThat(ids, containsInAnyOrder(pId, cId, oId));
} finally {
response.close();
}

View File

@ -132,13 +132,15 @@ public abstract class BaseResourceProviderDstu3Test extends BaseJpaDstu3Test {
// Register a CORS filter
CorsConfiguration config = new CorsConfiguration();
CorsInterceptor corsInterceptor = new CorsInterceptor(config);
config.addAllowedHeader("x-fhir-starter");
config.addAllowedHeader("Origin");
config.addAllowedHeader("Accept");
config.addAllowedHeader("X-Requested-With");
config.addAllowedHeader("Content-Type");
config.addAllowedHeader("Access-Control-Request-Method");
config.addAllowedHeader("Access-Control-Request-Headers");
config.addAllowedHeader("Access-Control-Request-Method");
config.addAllowedHeader("Cache-Control");
config.addAllowedHeader("Content-Type");
config.addAllowedHeader("Origin");
config.addAllowedHeader("Prefer");
config.addAllowedHeader("x-fhir-starter");
config.addAllowedHeader("X-Requested-With");
config.addAllowedOrigin("*");
config.addExposedHeader("Location");
config.addExposedHeader("Content-Location");

View File

@ -0,0 +1,134 @@
package ca.uhn.fhir.jpa.provider.dstu3;
import ca.uhn.fhir.jpa.dao.DaoConfig;
import ca.uhn.fhir.parser.StrictErrorHandler;
import ca.uhn.fhir.rest.api.EncodingEnum;
import ca.uhn.fhir.util.TestUtil;
import com.google.common.base.Charsets;
import org.apache.commons.io.IOUtils;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.hl7.fhir.dstu3.model.*;
import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent;
import org.hl7.fhir.dstu3.model.Encounter.EncounterStatus;
import org.hl7.fhir.dstu3.model.Observation.ObservationStatus;
import org.junit.*;
import java.io.IOException;
import java.util.*;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
public class CompositionDocumentDstu3Test extends BaseResourceProviderDstu3Test {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(CompositionDocumentDstu3Test.class);
private String orgId;
private String patId;
private List<String> myObsIds;
private String encId;
private String listId;
private String compId;
@Before
public void beforeDisableResultReuse() {
myDaoConfig.setReuseCachedSearchResultsForMillis(null);
}
@Override
@After
public void after() throws Exception {
super.after();
myDaoConfig.setReuseCachedSearchResultsForMillis(new DaoConfig().getReuseCachedSearchResultsForMillis());
}
@Override
public void before() throws Exception {
super.before();
myFhirCtx.setParserErrorHandler(new StrictErrorHandler());
myDaoConfig.setAllowMultipleDelete(true);
Organization org = new Organization();
org.setName("an org");
orgId = ourClient.create().resource(org).execute().getId().toUnqualifiedVersionless().getValue();
ourLog.info("OrgId: {}", orgId);
Patient patient = new Patient();
patient.getManagingOrganization().setReference(orgId);
patId = ourClient.create().resource(patient).execute().getId().toUnqualifiedVersionless().getValue();
Encounter enc = new Encounter();
enc.setStatus(EncounterStatus.ARRIVED);
enc.getSubject().setReference(patId);
enc.getServiceProvider().setReference(orgId);
encId = ourClient.create().resource(enc).execute().getId().toUnqualifiedVersionless().getValue();
ListResource listResource = new ListResource();
ArrayList<Observation> myObs = new ArrayList<>();
myObsIds = new ArrayList<String>();
for (int i = 0; i < 5; i++) {
Observation obs = new Observation();
obs.getSubject().setReference(patId);
obs.setStatus(ObservationStatus.FINAL);
String obsId = ourClient.create().resource(obs).execute().getId().toUnqualifiedVersionless().getValue();
listResource.addEntry(new ListResource.ListEntryComponent().setItem(new Reference(obs)));
myObs.add(obs);
myObsIds.add(obsId);
}
listId = ourClient.create().resource(listResource).execute().getId().toUnqualifiedVersionless().getValue();
Composition composition = new Composition();
composition.setSubject(new Reference(patId));
composition.addSection().addEntry(new Reference(patId));
composition.addSection().addEntry(new Reference(orgId));
composition.addSection().addEntry(new Reference(encId));
composition.addSection().addEntry(new Reference(listId));
for (String obsId : myObsIds) {
composition.addSection().addEntry(new Reference(obsId));
}
compId = ourClient.create().resource(composition).execute().getId().toUnqualifiedVersionless().getValue();
}
@Test
public void testDocumentBundleReturnedCorrect() throws IOException {
String theUrl = ourServerBase + "/" + compId + "/$document?_format=json";
Bundle bundle = fetchBundle(theUrl, EncodingEnum.JSON);
assertNull(bundle.getLink("next"));
Set<String> actual = new HashSet<>();
for (BundleEntryComponent nextEntry : bundle.getEntry()) {
actual.add(nextEntry.getResource().getIdElement().toUnqualifiedVersionless().getValue());
}
ourLog.info("Found IDs: {}", actual);
assertThat(actual, hasItem(patId));
assertThat(actual, hasItem(orgId));
assertThat(actual, hasItem(encId));
assertThat(actual, hasItem(listId));
assertThat(actual, hasItems(myObsIds.toArray(new String[0])));
}
private Bundle fetchBundle(String theUrl, EncodingEnum theEncoding) throws IOException, ClientProtocolException {
Bundle bundle;
HttpGet get = new HttpGet(theUrl);
try (CloseableHttpResponse resp = ourHttpClient.execute(get)) {
String resourceString = IOUtils.toString(resp.getEntity().getContent(), Charsets.UTF_8);
bundle = theEncoding.newParser(myFhirCtx).parseResource(Bundle.class, resourceString);
}
return bundle;
}
@AfterClass
public static void afterClassClearContext() {
TestUtil.clearAllStaticFieldsForUnitTest();
}
}

View File

@ -47,11 +47,11 @@ public class AuthorizationInterceptorResourceProviderR4Test extends BaseResource
public void testBlockUpdatingPatientUserDoesnNotHaveAccessTo() {
Patient pt1 = new Patient();
pt1.setActive(true);
final IIdType pid1 = myClient.create().resource(pt1).execute().getId().toUnqualifiedVersionless();
final IIdType pid1 = ourClient.create().resource(pt1).execute().getId().toUnqualifiedVersionless();
Patient pt2 = new Patient();
pt2.setActive(false);
final IIdType pid2 = myClient.create().resource(pt2).execute().getId().toUnqualifiedVersionless();
final IIdType pid2 = ourClient.create().resource(pt2).execute().getId().toUnqualifiedVersionless();
ourRestServer.registerInterceptor(new AuthorizationInterceptor(PolicyEnum.DENY) {
@Override
@ -65,7 +65,7 @@ public class AuthorizationInterceptorResourceProviderR4Test extends BaseResource
Observation obs = new Observation();
obs.setStatus(ObservationStatus.FINAL);
obs.setSubject(new Reference(pid1));
IIdType oid = myClient.create().resource(obs).execute().getId().toUnqualified();
IIdType oid = ourClient.create().resource(obs).execute().getId().toUnqualified();
unregisterInterceptors();
@ -89,7 +89,7 @@ public class AuthorizationInterceptorResourceProviderR4Test extends BaseResource
obs.setSubject(new Reference(pid2));
try {
myClient.update().resource(obs).execute();
ourClient.update().resource(obs).execute();
fail();
} catch (ForbiddenOperationException e) {
// good
@ -103,7 +103,7 @@ public class AuthorizationInterceptorResourceProviderR4Test extends BaseResource
Patient patient = new Patient();
patient.addIdentifier().setSystem("http://uhn.ca/mrns").setValue("100");
patient.addName().setFamily("Tester").addGiven("Raghad");
final MethodOutcome output1 = myClient.update().resource(patient).conditionalByUrl("Patient?identifier=http://uhn.ca/mrns|100").execute();
final MethodOutcome output1 = ourClient.update().resource(patient).conditionalByUrl("Patient?identifier=http://uhn.ca/mrns|100").execute();
ourRestServer.registerInterceptor(new AuthorizationInterceptor(PolicyEnum.DENY) {
@Override
@ -121,7 +121,7 @@ public class AuthorizationInterceptorResourceProviderR4Test extends BaseResource
patient.setId(output1.getId().toUnqualifiedVersionless());
patient.addIdentifier().setSystem("http://uhn.ca/mrns").setValue("100");
patient.addName().setFamily("Tester").addGiven("Raghad");
MethodOutcome output2 = myClient.update().resource(patient).conditionalByUrl("Patient?identifier=http://uhn.ca/mrns|100").execute();
MethodOutcome output2 = ourClient.update().resource(patient).conditionalByUrl("Patient?identifier=http://uhn.ca/mrns|100").execute();
assertEquals(output1.getId().getIdPart(), output2.getId().getIdPart());
@ -129,7 +129,7 @@ public class AuthorizationInterceptorResourceProviderR4Test extends BaseResource
patient.addIdentifier().setSystem("http://uhn.ca/mrns").setValue("100");
patient.addName().setFamily("Tester").addGiven("Raghad");
try {
myClient.update().resource(patient).conditionalByUrl("Patient?identifier=http://uhn.ca/mrns|101").execute();
ourClient.update().resource(patient).conditionalByUrl("Patient?identifier=http://uhn.ca/mrns|101").execute();
fail();
} catch (ForbiddenOperationException e) {
assertEquals("HTTP 403 Forbidden: Access denied by default policy (no applicable rules)", e.getMessage());
@ -140,7 +140,7 @@ public class AuthorizationInterceptorResourceProviderR4Test extends BaseResource
patient.addIdentifier().setSystem("http://uhn.ca/mrns").setValue("100");
patient.addName().setFamily("Tester").addGiven("Raghad");
try {
myClient.update().resource(patient).execute();
ourClient.update().resource(patient).execute();
fail();
} catch (ForbiddenOperationException e) {
assertEquals("HTTP 403 Forbidden: Access denied by default policy (no applicable rules)", e.getMessage());
@ -158,17 +158,17 @@ public class AuthorizationInterceptorResourceProviderR4Test extends BaseResource
patient.setId("Patient/A");
patient.addIdentifier().setSystem("http://uhn.ca/mrns").setValue("100");
patient.addName().setFamily("Tester").addGiven("Raghad");
IIdType id = myClient.update().resource(patient).execute().getId();
IIdType id = ourClient.update().resource(patient).execute().getId();
Observation obs = new Observation();
obs.setId("Observation/B");
obs.getSubject().setReference("Patient/A");
myClient.update().resource(obs).execute();
ourClient.update().resource(obs).execute();
obs = new Observation();
obs.setId("Observation/C");
obs.setStatus(ObservationStatus.FINAL);
myClient.update().resource(obs).execute();
ourClient.update().resource(obs).execute();
ourRestServer.registerInterceptor(new AuthorizationInterceptor(PolicyEnum.DENY) {
@Override
@ -181,17 +181,17 @@ public class AuthorizationInterceptorResourceProviderR4Test extends BaseResource
}
});
myClient.delete().resourceById(new IdType("Observation/B")).execute();
ourClient.delete().resourceById(new IdType("Observation/B")).execute();
try {
myClient.read().resource(Observation.class).withId("Observation/B").execute();
ourClient.read().resource(Observation.class).withId("Observation/B").execute();
fail();
} catch (ResourceGoneException e) {
// good
}
try {
myClient.delete().resourceById(new IdType("Observation/C")).execute();
ourClient.delete().resourceById(new IdType("Observation/C")).execute();
fail();
} catch (ForbiddenOperationException e) {
// good
@ -207,16 +207,16 @@ public class AuthorizationInterceptorResourceProviderR4Test extends BaseResource
Patient patient = new Patient();
patient.addIdentifier().setSystem("http://uhn.ca/mrns").setValue("100");
patient.addName().setFamily("Tester").addGiven("Raghad");
final IIdType id = myClient.create().resource(patient).execute().getId();
final IIdType id = ourClient.create().resource(patient).execute().getId();
Observation obsInCompartment = new Observation();
obsInCompartment.setStatus(ObservationStatus.FINAL);
obsInCompartment.getSubject().setReferenceElement(id.toUnqualifiedVersionless());
IIdType obsInCompartmentId = myClient.create().resource(obsInCompartment).execute().getId().toUnqualifiedVersionless();
IIdType obsInCompartmentId = ourClient.create().resource(obsInCompartment).execute().getId().toUnqualifiedVersionless();
Observation obsNotInCompartment = new Observation();
obsNotInCompartment.setStatus(ObservationStatus.FINAL);
IIdType obsNotInCompartmentId = myClient.create().resource(obsNotInCompartment).execute().getId().toUnqualifiedVersionless();
IIdType obsNotInCompartmentId = ourClient.create().resource(obsNotInCompartment).execute().getId().toUnqualifiedVersionless();
ourRestServer.registerInterceptor(new AuthorizationInterceptor(PolicyEnum.DENY) {
@Override
@ -229,10 +229,10 @@ public class AuthorizationInterceptorResourceProviderR4Test extends BaseResource
}
});
myClient.delete().resourceById(obsInCompartmentId.toUnqualifiedVersionless()).execute();
ourClient.delete().resourceById(obsInCompartmentId.toUnqualifiedVersionless()).execute();
try {
myClient.delete().resourceById(obsNotInCompartmentId.toUnqualifiedVersionless()).execute();
ourClient.delete().resourceById(obsNotInCompartmentId.toUnqualifiedVersionless()).execute();
fail();
} catch (ForbiddenOperationException e) {
// good
@ -258,16 +258,16 @@ public class AuthorizationInterceptorResourceProviderR4Test extends BaseResource
Patient patient = new Patient();
patient.addIdentifier().setSystem("http://uhn.ca/mrns").setValue("100");
patient.addName().setFamily("Tester").addGiven("Raghad");
IIdType id = myClient.create().resource(patient).execute().getId();
IIdType id = ourClient.create().resource(patient).execute().getId();
try {
myClient.delete().resourceById(id.toUnqualifiedVersionless()).execute();
ourClient.delete().resourceById(id.toUnqualifiedVersionless()).execute();
fail();
} catch (ForbiddenOperationException e) {
// good
}
patient = myClient.read().resource(Patient.class).withId(id.toUnqualifiedVersionless()).execute();
patient = ourClient.read().resource(Patient.class).withId(id.toUnqualifiedVersionless()).execute();
assertEquals(id.getValue(), patient.getId());
}
@ -371,7 +371,7 @@ public class AuthorizationInterceptorResourceProviderR4Test extends BaseResource
o.getSubject().setResource(p);
request.addEntry().setResource(o).getRequest().setMethod(Bundle.HTTPVerb.POST);
Bundle resp = myClient.transaction().withBundle(request).execute();
Bundle resp = ourClient.transaction().withBundle(request).execute();
assertEquals(2, resp.getEntry().size());
@ -458,7 +458,7 @@ public class AuthorizationInterceptorResourceProviderR4Test extends BaseResource
.setMethod(Bundle.HTTPVerb.POST);
Bundle resp = myClient.transaction().withBundle(bundle).execute();
Bundle resp = ourClient.transaction().withBundle(bundle).execute();
assertEquals(3, resp.getEntry().size());
}
@ -467,21 +467,21 @@ public class AuthorizationInterceptorResourceProviderR4Test extends BaseResource
public void testPatchWithinCompartment() {
Patient pt1 = new Patient();
pt1.setActive(true);
final IIdType pid1 = myClient.create().resource(pt1).execute().getId().toUnqualifiedVersionless();
final IIdType pid1 = ourClient.create().resource(pt1).execute().getId().toUnqualifiedVersionless();
Observation obs1 = new Observation();
obs1.setStatus(ObservationStatus.FINAL);
obs1.setSubject(new Reference(pid1));
IIdType oid1 = myClient.create().resource(obs1).execute().getId().toUnqualified();
IIdType oid1 = ourClient.create().resource(obs1).execute().getId().toUnqualified();
Patient pt2 = new Patient();
pt2.setActive(false);
final IIdType pid2 = myClient.create().resource(pt2).execute().getId().toUnqualifiedVersionless();
final IIdType pid2 = ourClient.create().resource(pt2).execute().getId().toUnqualifiedVersionless();
Observation obs2 = new Observation();
obs2.setStatus(ObservationStatus.FINAL);
obs2.setSubject(new Reference(pid2));
IIdType oid2 = myClient.create().resource(obs2).execute().getId().toUnqualified();
IIdType oid2 = ourClient.create().resource(obs2).execute().getId().toUnqualified();
ourRestServer.registerInterceptor(new AuthorizationInterceptor(PolicyEnum.DENY) {
@Override
@ -499,18 +499,18 @@ public class AuthorizationInterceptorResourceProviderR4Test extends BaseResource
" ]";
// Allowed
myClient.patch().withBody(patchBody).withId(oid1).execute();
obs1 = myClient.read().resource(Observation.class).withId(oid1.toUnqualifiedVersionless()).execute();
ourClient.patch().withBody(patchBody).withId(oid1).execute();
obs1 = ourClient.read().resource(Observation.class).withId(oid1.toUnqualifiedVersionless()).execute();
assertEquals(ObservationStatus.AMENDED, obs1.getStatus());
// Denied
try {
myClient.patch().withBody(patchBody).withId(oid2).execute();
ourClient.patch().withBody(patchBody).withId(oid2).execute();
fail();
} catch (ForbiddenOperationException e) {
// good
}
obs2 = myClient.read().resource(Observation.class).withId(oid2.toUnqualifiedVersionless()).execute();
obs2 = ourClient.read().resource(Observation.class).withId(oid2.toUnqualifiedVersionless()).execute();
assertEquals(ObservationStatus.FINAL, obs2.getStatus());
}
@ -520,14 +520,14 @@ public class AuthorizationInterceptorResourceProviderR4Test extends BaseResource
@Test
public void testReadingObservationAccessRight() {
Practitioner practitioner1 = new Practitioner();
final IIdType practitionerId1 = myClient.create().resource(practitioner1).execute().getId().toUnqualifiedVersionless();
final IIdType practitionerId1 = ourClient.create().resource(practitioner1).execute().getId().toUnqualifiedVersionless();
Practitioner practitioner2 = new Practitioner();
final IIdType practitionerId2 = myClient.create().resource(practitioner2).execute().getId().toUnqualifiedVersionless();
final IIdType practitionerId2 = ourClient.create().resource(practitioner2).execute().getId().toUnqualifiedVersionless();
Patient patient = new Patient();
patient.setActive(true);
final IIdType patientId = myClient.create().resource(patient).execute().getId().toUnqualifiedVersionless();
final IIdType patientId = ourClient.create().resource(patient).execute().getId().toUnqualifiedVersionless();
ourRestServer.registerInterceptor(new AuthorizationInterceptor(PolicyEnum.DENY) {
@Override
@ -553,19 +553,19 @@ public class AuthorizationInterceptorResourceProviderR4Test extends BaseResource
obs1.setStatus(ObservationStatus.FINAL);
obs1.setPerformer(
Arrays.asList(new Reference(practitionerId1), new Reference(practitionerId2)));
IIdType oid1 = myClient.create().resource(obs1).execute().getId().toUnqualified();
IIdType oid1 = ourClient.create().resource(obs1).execute().getId().toUnqualified();
// Observation with practitioner1 and practitioner1 as the Performer -> should have the read access
myClient.read().resource(Observation.class).withId(oid1).execute();
ourClient.read().resource(Observation.class).withId(oid1).execute();
Observation obs2 = new Observation();
obs2.setStatus(ObservationStatus.FINAL);
obs2.setSubject(new Reference(patientId));
IIdType oid2 = myClient.create().resource(obs2).execute().getId().toUnqualified();
IIdType oid2 = ourClient.create().resource(obs2).execute().getId().toUnqualified();
// Observation with patient as the subject -> read access should be blocked
try {
myClient.read().resource(Observation.class).withId(oid2).execute();
ourClient.read().resource(Observation.class).withId(oid2).execute();
fail();
} catch (ForbiddenOperationException e) {
// good

View File

@ -60,7 +60,7 @@ public abstract class BaseResourceProviderR4Test extends BaseJpaR4Test {
protected static ISearchCoordinatorSvc mySearchCoordinatorSvc;
protected static GenericWebApplicationContext ourWebApplicationContext;
private static Server ourServer;
protected IGenericClient myClient;
protected IGenericClient ourClient;
protected ResourceCountCache ourResourceCountsCache;
private TerminologyUploaderProviderR4 myTerminologyUploaderProvider;
private Object ourGraphQLProvider;
@ -233,9 +233,9 @@ public abstract class BaseResourceProviderR4Test extends BaseJpaR4Test {
ourRestServer.setPagingProvider(ourPagingProvider);
myClient = myFhirCtx.newRestfulGenericClient(ourServerBase);
ourClient = myFhirCtx.newRestfulGenericClient(ourServerBase);
if (shouldLogClient()) {
myClient.registerInterceptor(new LoggingInterceptor());
ourClient.registerInterceptor(new LoggingInterceptor());
}
}
@ -257,7 +257,7 @@ public abstract class BaseResourceProviderR4Test extends BaseJpaR4Test {
}
protected List<String> toNameList(Bundle resp) {
List<String> names = new ArrayList<String>();
List<String> names = new ArrayList<>();
for (BundleEntryComponent next : resp.getEntry()) {
Patient nextPt = (Patient) next.getResource();
String nextStr = nextPt.getName().size() > 0 ? nextPt.getName().get(0).getGivenAsSingleString() + " " + nextPt.getName().get(0).getFamily() : "";

View File

@ -0,0 +1,143 @@
package ca.uhn.fhir.jpa.provider.r4;
import ca.uhn.fhir.jpa.dao.DaoConfig;
import ca.uhn.fhir.parser.StrictErrorHandler;
import ca.uhn.fhir.rest.api.EncodingEnum;
import ca.uhn.fhir.util.TestUtil;
import com.google.common.base.Charsets;
import org.apache.commons.io.IOUtils;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.hl7.fhir.r4.model.*;
import org.hl7.fhir.r4.model.codesystems.EncounterStatus;
import org.hl7.fhir.r4.model.codesystems.ObservationStatus;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.hasItems;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
public class CompositionDocumentR4Test extends BaseResourceProviderR4Test {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(CompositionDocumentR4Test.class);
private String orgId;
private String patId;
private List<String> myObsIds;
private String encId;
private String listId;
private String compId;
@Before
public void beforeDisableResultReuse() {
myDaoConfig.setReuseCachedSearchResultsForMillis(null);
}
@Override
@After
public void after() throws Exception {
super.after();
myDaoConfig.setReuseCachedSearchResultsForMillis(new DaoConfig().getReuseCachedSearchResultsForMillis());
}
@Override
public void before() throws Exception {
super.before();
myFhirCtx.setParserErrorHandler(new StrictErrorHandler());
myDaoConfig.setAllowMultipleDelete(true);
Organization org = new Organization();
org.setName("an org");
orgId = ourClient.create().resource(org).execute().getId().toUnqualifiedVersionless().getValue();
ourLog.info("OrgId: {}", orgId);
Patient patient = new Patient();
patient.getManagingOrganization().setReference(orgId);
patId = ourClient.create().resource(patient).execute().getId().toUnqualifiedVersionless().getValue();
Encounter enc = new Encounter();
enc.setStatus(Encounter.EncounterStatus.ARRIVED);
enc.getSubject().setReference(patId);
enc.getServiceProvider().setReference(orgId);
encId = ourClient.create().resource(enc).execute().getId().toUnqualifiedVersionless().getValue();
ListResource listResource = new ListResource();
ArrayList<Observation> myObs = new ArrayList<>();
myObsIds = new ArrayList<String>();
for (int i = 0; i < 5; i++) {
Observation obs = new Observation();
obs.getSubject().setReference(patId);
obs.setStatus(Observation.ObservationStatus.FINAL);
String obsId = ourClient.create().resource(obs).execute().getId().toUnqualifiedVersionless().getValue();
listResource.addEntry(new ListResource.ListEntryComponent().setItem(new Reference(obs)));
myObs.add(obs);
myObsIds.add(obsId);
}
listId = ourClient.create().resource(listResource).execute().getId().toUnqualifiedVersionless().getValue();
Composition composition = new Composition();
composition.setSubject(new Reference(patId));
composition.addSection().addEntry(new Reference(patId));
composition.addSection().addEntry(new Reference(orgId));
composition.addSection().addEntry(new Reference(encId));
composition.addSection().addEntry(new Reference(listId));
for (String obsId : myObsIds) {
composition.addSection().addEntry(new Reference(obsId));
}
compId = ourClient.create().resource(composition).execute().getId().toUnqualifiedVersionless().getValue();
}
@Test
public void testDocumentBundleReturnedCorrect() throws IOException {
String theUrl = ourServerBase + "/" + compId + "/$document?_format=json";
Bundle bundle = fetchBundle(theUrl, EncodingEnum.JSON);
assertNull(bundle.getLink("next"));
Set<String> actual = new HashSet<>();
for (Bundle.BundleEntryComponent nextEntry : bundle.getEntry()) {
actual.add(nextEntry.getResource().getIdElement().toUnqualifiedVersionless().getValue());
}
ourLog.info("Found IDs: {}", actual);
assertThat(actual, hasItem(compId));
assertThat(actual, hasItem(patId));
assertThat(actual, hasItem(orgId));
assertThat(actual, hasItem(encId));
assertThat(actual, hasItem(listId));
assertThat(actual, hasItems(myObsIds.toArray(new String[0])));
}
private Bundle fetchBundle(String theUrl, EncodingEnum theEncoding) throws IOException, ClientProtocolException {
Bundle bundle;
HttpGet get = new HttpGet(theUrl);
try (CloseableHttpResponse resp = ourHttpClient.execute(get)) {
String resourceString = IOUtils.toString(resp.getEntity().getContent(), Charsets.UTF_8);
bundle = theEncoding.newParser(myFhirCtx).parseResource(Bundle.class, resourceString);
}
return bundle;
}
@AfterClass
public static void afterClassClearContext() {
TestUtil.clearAllStaticFieldsForUnitTest();
}
}

View File

@ -85,13 +85,13 @@ public class GraphQLProviderR4Test extends BaseResourceProviderR4Test {
p.addName()
.addGiven("GivenOnly1")
.addGiven("GivenOnly2");
myPatientId0 = myClient.create().resource(p).execute().getId().toUnqualifiedVersionless();
myPatientId0 = ourClient.create().resource(p).execute().getId().toUnqualifiedVersionless();
p = new Patient();
p.addName()
.addGiven("GivenOnlyB1")
.addGiven("GivenOnlyB2");
myClient.create().resource(p).execute();
ourClient.create().resource(p).execute();
}

View File

@ -57,41 +57,41 @@ public class PatientEverythingR4Test extends BaseResourceProviderR4Test {
Organization org = new Organization();
org.setName("an org");
orgId = myClient.create().resource(org).execute().getId().toUnqualifiedVersionless().getValue();
orgId = ourClient.create().resource(org).execute().getId().toUnqualifiedVersionless().getValue();
ourLog.info("OrgId: {}", orgId);
Patient patient = new Patient();
patient.getManagingOrganization().setReference(orgId);
patId = myClient.create().resource(patient).execute().getId().toUnqualifiedVersionless().getValue();
patId = ourClient.create().resource(patient).execute().getId().toUnqualifiedVersionless().getValue();
Patient patient2 = new Patient();
patient2.getManagingOrganization().setReference(orgId);
myWrongPatId = myClient.create().resource(patient2).execute().getId().toUnqualifiedVersionless().getValue();
myWrongPatId = ourClient.create().resource(patient2).execute().getId().toUnqualifiedVersionless().getValue();
Encounter enc1 = new Encounter();
enc1.setStatus(EncounterStatus.CANCELLED);
enc1.getSubject().setReference(patId);
enc1.getServiceProvider().setReference(orgId);
encId1 = myClient.create().resource(enc1).execute().getId().toUnqualifiedVersionless().getValue();
encId1 = ourClient.create().resource(enc1).execute().getId().toUnqualifiedVersionless().getValue();
Encounter enc2 = new Encounter();
enc2.setStatus(EncounterStatus.ARRIVED);
enc2.getSubject().setReference(patId);
enc2.getServiceProvider().setReference(orgId);
encId2 = myClient.create().resource(enc2).execute().getId().toUnqualifiedVersionless().getValue();
encId2 = ourClient.create().resource(enc2).execute().getId().toUnqualifiedVersionless().getValue();
Encounter wrongEnc1 = new Encounter();
wrongEnc1.setStatus(EncounterStatus.ARRIVED);
wrongEnc1.getSubject().setReference(myWrongPatId);
wrongEnc1.getServiceProvider().setReference(orgId);
myWrongEnc1 = myClient.create().resource(wrongEnc1).execute().getId().toUnqualifiedVersionless().getValue();
myWrongEnc1 = ourClient.create().resource(wrongEnc1).execute().getId().toUnqualifiedVersionless().getValue();
myObsIds = new ArrayList<String>();
for (int i = 0; i < 20; i++) {
Observation obs = new Observation();
obs.getSubject().setReference(patId);
obs.setStatus(ObservationStatus.FINAL);
String obsId = myClient.create().resource(obs).execute().getId().toUnqualifiedVersionless().getValue();
String obsId = ourClient.create().resource(obs).execute().getId().toUnqualifiedVersionless().getValue();
myObsIds.add(obsId);
}

View File

@ -80,7 +80,7 @@ public class ResourceProviderCustomSearchParamR4Test extends BaseResourceProvide
sp.setTitle("Foo Param");
try {
myClient.create().resource(sp).execute();
ourClient.create().resource(sp).execute();
fail();
} catch (UnprocessableEntityException e) {
assertEquals("HTTP 422 Unprocessable Entity: SearchParameter.status is missing or invalid", e.getMessage());
@ -91,7 +91,7 @@ public class ResourceProviderCustomSearchParamR4Test extends BaseResourceProvide
public void testConformanceOverrideAllowed() {
myDaoConfig.setDefaultSearchParamsCanBeOverridden(true);
CapabilityStatement conformance = myClient
CapabilityStatement conformance = ourClient
.fetchConformance()
.ofType(CapabilityStatement.class)
.execute();
@ -143,7 +143,7 @@ public class ResourceProviderCustomSearchParamR4Test extends BaseResourceProvide
}
});
conformance = myClient
conformance = ourClient
.fetchConformance()
.ofType(CapabilityStatement.class)
.execute();
@ -161,7 +161,7 @@ public class ResourceProviderCustomSearchParamR4Test extends BaseResourceProvide
public void testConformanceOverrideNotAllowed() {
myDaoConfig.setDefaultSearchParamsCanBeOverridden(false);
CapabilityStatement conformance = myClient
CapabilityStatement conformance = ourClient
.fetchConformance()
.ofType(CapabilityStatement.class)
.execute();
@ -197,7 +197,7 @@ public class ResourceProviderCustomSearchParamR4Test extends BaseResourceProvide
mySearchParamRegsitry.forceRefresh();
conformance = myClient
conformance = ourClient
.fetchConformance()
.ofType(CapabilityStatement.class)
.execute();
@ -301,7 +301,7 @@ public class ResourceProviderCustomSearchParamR4Test extends BaseResourceProvide
ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(eyeColourSp));
myClient
ourClient
.create()
.resource(eyeColourSp)
.execute();
@ -320,7 +320,7 @@ public class ResourceProviderCustomSearchParamR4Test extends BaseResourceProvide
p2.addExtension().setUrl("http://acme.org/eyecolour").setValue(new CodeType("green"));
IIdType p2id = myPatientDao.create(p2).getId().toUnqualifiedVersionless();
Bundle bundle = myClient
Bundle bundle = ourClient
.search()
.forResource(Patient.class)
.where(new TokenClientParam("eyecolour").exactly().code("blue"))
@ -367,7 +367,7 @@ public class ResourceProviderCustomSearchParamR4Test extends BaseResourceProvide
List<String> foundResources;
Bundle result;
result = myClient
result = ourClient
.search()
.forResource(Observation.class)
.where(new ReferenceClientParam("foo").hasChainedProperty(Patient.GENDER.exactly().code("male")))
@ -407,7 +407,7 @@ public class ResourceProviderCustomSearchParamR4Test extends BaseResourceProvide
List<String> foundResources;
Bundle result;
result = myClient
result = ourClient
.search()
.forResource(Patient.class)
.where(new TokenClientParam("foo").exactly().code("male"))

View File

@ -139,7 +139,7 @@ public class ResourceProviderExpungeR4Test extends BaseResourceProviderR4Test {
ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(input));
Parameters output = myClient
Parameters output = ourClient
.operation()
.onInstance(myTwoVersionPatientId)
.named("expunge")
@ -179,7 +179,7 @@ public class ResourceProviderExpungeR4Test extends BaseResourceProviderR4Test {
.setValue(new BooleanType(true));
try {
myClient
ourClient
.operation()
.onInstance(myTwoVersionPatientId)
.named("expunge")
@ -212,7 +212,7 @@ public class ResourceProviderExpungeR4Test extends BaseResourceProviderR4Test {
ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(input));
Parameters output = myClient
Parameters output = ourClient
.operation()
.onServer()
.named("expunge")
@ -251,7 +251,7 @@ public class ResourceProviderExpungeR4Test extends BaseResourceProviderR4Test {
ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(input));
Parameters output = myClient
Parameters output = ourClient
.operation()
.onType(Patient.class)
.named("expunge")
@ -297,7 +297,7 @@ public class ResourceProviderExpungeR4Test extends BaseResourceProviderR4Test {
ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(input));
Parameters output = myClient
Parameters output = ourClient
.operation()
.onInstanceVersion(myTwoVersionPatientId.withVersion("1"))
.named("expunge")

View File

@ -241,7 +241,7 @@ public class ResourceProviderInterceptorR4Test extends BaseResourceProviderR4Tes
Organization org = new Organization();
org.setName("orgName");
IIdType orgId = myClient.create().resource(org).execute().getId().toUnqualified();
IIdType orgId = ourClient.create().resource(org).execute().getId().toUnqualified();
assertNotNull(orgId.getVersionIdPartAsLong());
resetServerInterceptor();

View File

@ -72,7 +72,7 @@ public class ResourceProviderQuestionnaireResponseR4Test extends BaseResourcePro
qr1.setStatus(QuestionnaireResponseStatus.COMPLETED);
qr1.addItem().setLinkId("link1").addAnswer().setValue(new DecimalType(123));
try {
myClient.create().resource(qr1).execute();
ourClient.create().resource(qr1).execute();
fail();
} catch (UnprocessableEntityException e) {
assertThat(e.toString(), containsString("Answer value must be of type string"));
@ -95,7 +95,7 @@ public class ResourceProviderQuestionnaireResponseR4Test extends BaseResourcePro
qr1.setStatus(QuestionnaireResponseStatus.COMPLETED);
qr1.addItem().setLinkId("link1").addAnswer().setValue(new DecimalType(123));
try {
myClient.create().resource(qr1).execute();
ourClient.create().resource(qr1).execute();
fail();
} catch (UnprocessableEntityException e) {
assertThat(e.toString(), containsString("Answer value must be of type string"));

View File

@ -32,10 +32,11 @@ public class ResourceProviderR4BundleTest extends BaseResourceProviderR4Test {
composition.setTitle("Visit Summary");
bundle.addEntry().setFullUrl("http://foo").setResource(composition);
IIdType id = myClient.create().resource(bundle).execute().getId();
IIdType id = ourClient.create().resource(bundle).execute().getId();
Bundle retBundle = myClient.read().resource(Bundle.class).withId(id).execute();
ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(retBundle));
Bundle retBundle = ourClient.read().resource(Bundle.class).withId(id).execute();
ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(retBundle));
assertEquals("http://foo", bundle.getEntry().get(0).getFullUrl());
}
@ -51,7 +52,7 @@ public class ResourceProviderR4BundleTest extends BaseResourceProviderR4Test {
.setName("content")
.setResource(bundle);
try {
myClient.operation().onType(MessageHeader.class).named(JpaConstants.OPERATION_PROCESS_MESSAGE).withParameters(parameters).execute();
ourClient.operation().onType(MessageHeader.class).named(JpaConstants.OPERATION_PROCESS_MESSAGE).withParameters(parameters).execute();
fail();
} catch (NotImplementedOperationException e) {
assertThat(e.getMessage(), containsString("This operation is not yet implemented on this server"));

View File

@ -35,7 +35,7 @@ public class ResourceProviderR4CacheTest extends BaseResourceProviderR4Test {
myDaoConfig.setReuseCachedSearchResultsForMillis(new DaoConfig().getReuseCachedSearchResultsForMillis());
myDaoConfig.setCacheControlNoStoreMaxResultsUpperLimit(new DaoConfig().getCacheControlNoStoreMaxResultsUpperLimit());
myClient.unregisterInterceptor(myCapturingInterceptor);
ourClient.unregisterInterceptor(myCapturingInterceptor);
}
@Override
@ -45,7 +45,7 @@ public class ResourceProviderR4CacheTest extends BaseResourceProviderR4Test {
mySearchCoordinatorSvcRaw = AopTestUtils.getTargetObject(mySearchCoordinatorSvc);
myCapturingInterceptor = new CapturingInterceptor();
myClient.registerInterceptor(myCapturingInterceptor);
ourClient.registerInterceptor(myCapturingInterceptor);
}
@Test
@ -53,9 +53,9 @@ public class ResourceProviderR4CacheTest extends BaseResourceProviderR4Test {
Patient pt1 = new Patient();
pt1.addName().setFamily("FAM");
myClient.create().resource(pt1).execute();
ourClient.create().resource(pt1).execute();
Bundle results = myClient
Bundle results = ourClient
.search()
.forResource("Patient")
.where(Patient.FAMILY.matches().value("FAM"))
@ -68,9 +68,9 @@ public class ResourceProviderR4CacheTest extends BaseResourceProviderR4Test {
Patient pt2 = new Patient();
pt2.addName().setFamily("FAM");
myClient.create().resource(pt2).execute();
ourClient.create().resource(pt2).execute();
results = myClient
results = ourClient
.search()
.forResource("Patient")
.where(Patient.FAMILY.matches().value("FAM"))
@ -89,10 +89,10 @@ public class ResourceProviderR4CacheTest extends BaseResourceProviderR4Test {
for (int i = 0; i < 10; i++) {
Patient pt1 = new Patient();
pt1.addName().setFamily("FAM" + i);
myClient.create().resource(pt1).execute();
ourClient.create().resource(pt1).execute();
}
Bundle results = myClient
Bundle results = ourClient
.search()
.forResource("Patient")
.where(Patient.FAMILY.matches().value("FAM"))
@ -109,7 +109,7 @@ public class ResourceProviderR4CacheTest extends BaseResourceProviderR4Test {
public void testCacheNoStoreMaxResultsWithIllegalValue() throws IOException {
myDaoConfig.setCacheControlNoStoreMaxResultsUpperLimit(123);
try {
myClient
ourClient
.search()
.forResource("Patient")
.where(Patient.FAMILY.matches().value("FAM"))
@ -127,18 +127,18 @@ public class ResourceProviderR4CacheTest extends BaseResourceProviderR4Test {
Patient pt1 = new Patient();
pt1.addName().setFamily("FAM");
myClient.create().resource(pt1).execute();
ourClient.create().resource(pt1).execute();
Bundle results = myClient.search().forResource("Patient").where(Patient.FAMILY.matches().value("FAM")).returnBundle(Bundle.class).execute();
Bundle results = ourClient.search().forResource("Patient").where(Patient.FAMILY.matches().value("FAM")).returnBundle(Bundle.class).execute();
assertEquals(1, results.getEntry().size());
assertEquals(1, mySearchEntityDao.count());
assertThat(myCapturingInterceptor.getLastResponse().getHeaders(Constants.HEADER_X_CACHE), empty());
Patient pt2 = new Patient();
pt2.addName().setFamily("FAM");
myClient.create().resource(pt2).execute();
ourClient.create().resource(pt2).execute();
results = myClient
results = ourClient
.search()
.forResource("Patient")
.where(Patient.FAMILY.matches().value("FAM"))
@ -156,11 +156,11 @@ public class ResourceProviderR4CacheTest extends BaseResourceProviderR4Test {
Patient pt1 = new Patient();
pt1.addName().setFamily("FAM");
myClient.create().resource(pt1).execute();
ourClient.create().resource(pt1).execute();
Date beforeFirst = new Date();
Bundle results1 = myClient.search().forResource("Patient").where(Patient.FAMILY.matches().value("FAM")).returnBundle(Bundle.class).execute();
Bundle results1 = ourClient.search().forResource("Patient").where(Patient.FAMILY.matches().value("FAM")).returnBundle(Bundle.class).execute();
assertEquals(1, results1.getEntry().size());
assertEquals(1, mySearchEntityDao.count());
assertThat(myCapturingInterceptor.getLastResponse().getHeaders(Constants.HEADER_X_CACHE), empty());
@ -170,9 +170,9 @@ public class ResourceProviderR4CacheTest extends BaseResourceProviderR4Test {
Patient pt2 = new Patient();
pt2.addName().setFamily("FAM");
myClient.create().resource(pt2).execute();
ourClient.create().resource(pt2).execute();
Bundle results2 = myClient.search().forResource("Patient").where(Patient.FAMILY.matches().value("FAM")).returnBundle(Bundle.class).execute();
Bundle results2 = ourClient.search().forResource("Patient").where(Patient.FAMILY.matches().value("FAM")).returnBundle(Bundle.class).execute();
assertEquals(1, results2.getEntry().size());
assertEquals(1, mySearchEntityDao.count());
assertEquals("HIT from " + ourServerBase, myCapturingInterceptor.getLastResponse().getHeaders(Constants.HEADER_X_CACHE).get(0));

View File

@ -40,7 +40,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test
public void testLookupOnExternalCode() {
ResourceProviderR4ValueSetTest.createExternalCs(myCodeSystemDao, myResourceTableDao, myTermSvc, mySrd);
Parameters respParam = myClient
Parameters respParam = ourClient
.operation()
.onType(CodeSystem.class)
.named("lookup")
@ -59,7 +59,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test
assertEquals(false, ((BooleanType)respParam.getParameter().get(2).getValue()).getValue().booleanValue());
// With HTTP GET
respParam = myClient
respParam = ourClient
.operation()
.onType(CodeSystem.class)
.named("lookup")
@ -82,7 +82,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test
@Test
public void testLookupOperationByCodeAndSystemBuiltInCode() {
Parameters respParam = myClient
Parameters respParam = ourClient
.operation()
.onType(CodeSystem.class)
.named("lookup")
@ -105,7 +105,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test
public void testLookupOperationByCodeAndSystemBuiltInNonexistantCode() {
//@formatter:off
try {
myClient
ourClient
.operation()
.onType(CodeSystem.class)
.named("lookup")
@ -122,7 +122,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test
@Test
public void testLookupOperationByCodeAndSystemUserDefinedCode() {
//@formatter:off
Parameters respParam = myClient
Parameters respParam = ourClient
.operation()
.onType(CodeSystem.class)
.named("lookup")
@ -146,7 +146,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test
public void testLookupOperationByCodeAndSystemUserDefinedNonExistantCode() {
//@formatter:off
try {
myClient
ourClient
.operation()
.onType(CodeSystem.class)
.named("lookup")
@ -163,7 +163,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test
@Test
public void testLookupOperationByCoding() {
//@formatter:off
Parameters respParam = myClient
Parameters respParam = ourClient
.operation()
.onType(CodeSystem.class)
.named("lookup")
@ -186,7 +186,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test
public void testLookupOperationByInvalidCombination() {
//@formatter:off
try {
myClient
ourClient
.operation()
.onType(CodeSystem.class)
.named("lookup")
@ -205,7 +205,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test
public void testLookupOperationByInvalidCombination2() {
//@formatter:off
try {
myClient
ourClient
.operation()
.onType(CodeSystem.class)
.named("lookup")
@ -223,7 +223,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test
public void testLookupOperationByInvalidCombination3() {
//@formatter:off
try {
myClient
ourClient
.operation()
.onType(CodeSystem.class)
.named("lookup")
@ -240,7 +240,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test
// @Ignore
public void testLookupOperationForBuiltInCode() {
//@formatter:off
Parameters respParam = myClient
Parameters respParam = ourClient
.operation()
.onType(CodeSystem.class)
.named("lookup")

View File

@ -34,7 +34,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
public void testStoreExistingTermConceptMapAndChildren() {
ConceptMap conceptMap = createConceptMap();
MethodOutcome methodOutcome = myClient
MethodOutcome methodOutcome = ourClient
.update()
.resource(conceptMap)
.conditional()
@ -50,7 +50,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
ConceptMap conceptMap = createConceptMap();
conceptMap.getGroupFirstRep().getElementFirstRep().setCode("UPDATED_CODE");
MethodOutcome methodOutcome = myClient
MethodOutcome methodOutcome = ourClient
.update()
.resource(conceptMap)
.conditional()
@ -74,7 +74,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams));
Parameters respParams = myClient
Parameters respParams = ourClient
.operation()
.onType(ConceptMap.class)
.named("translate")
@ -132,7 +132,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams));
Parameters respParams = myClient
Parameters respParams = ourClient
.operation()
.onType(ConceptMap.class)
.named("translate")
@ -177,7 +177,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams));
Parameters respParams = myClient
Parameters respParams = ourClient
.operation()
.onType(ConceptMap.class)
.named("translate")
@ -210,7 +210,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams));
Parameters respParams = myClient
Parameters respParams = ourClient
.operation()
.onType(ConceptMap.class)
.named("translate")
@ -288,7 +288,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams));
Parameters respParams = myClient
Parameters respParams = ourClient
.operation()
.onType(ConceptMap.class)
.named("translate")
@ -341,7 +341,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams));
Parameters respParams = myClient
Parameters respParams = ourClient
.operation()
.onType(ConceptMap.class)
.named("translate")
@ -432,7 +432,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams));
Parameters respParams = myClient
Parameters respParams = ourClient
.operation()
.onType(ConceptMap.class)
.named("translate")
@ -511,7 +511,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams));
Parameters respParams = myClient
Parameters respParams = ourClient
.operation()
.onType(ConceptMap.class)
.named("translate")
@ -562,7 +562,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams));
Parameters respParams = myClient
Parameters respParams = ourClient
.operation()
.onType(ConceptMap.class)
.named("translate")
@ -627,7 +627,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams));
Parameters respParams = myClient
Parameters respParams = ourClient
.operation()
.onType(ConceptMap.class)
.named("translate")
@ -678,7 +678,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams));
Parameters respParams = myClient
Parameters respParams = ourClient
.operation()
.onType(ConceptMap.class)
.named("translate")
@ -741,7 +741,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams));
Parameters respParams = myClient
Parameters respParams = ourClient
.operation()
.onType(ConceptMap.class)
.named("translate")
@ -818,7 +818,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams));
Parameters respParams = myClient
Parameters respParams = ourClient
.operation()
.onType(ConceptMap.class)
.named("translate")
@ -889,7 +889,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams));
Parameters respParams = myClient
Parameters respParams = ourClient
.operation()
.onInstance(myConceptMapId)
.named("translate")
@ -970,7 +970,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams));
Parameters respParams = myClient
Parameters respParams = ourClient
.operation()
.onType(ConceptMap.class)
.named("translate")
@ -1016,7 +1016,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams));
Parameters respParams = myClient
Parameters respParams = ourClient
.operation()
.onType(ConceptMap.class)
.named("translate")
@ -1051,7 +1051,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams));
Parameters respParams = myClient
Parameters respParams = ourClient
.operation()
.onType(ConceptMap.class)
.named("translate")
@ -1117,7 +1117,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams));
Parameters respParams = myClient
Parameters respParams = ourClient
.operation()
.onType(ConceptMap.class)
.named("translate")
@ -1187,7 +1187,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams));
Parameters respParams = myClient
Parameters respParams = ourClient
.operation()
.onType(ConceptMap.class)
.named("translate")
@ -1280,7 +1280,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams));
Parameters respParams = myClient
Parameters respParams = ourClient
.operation()
.onType(ConceptMap.class)
.named("translate")
@ -1347,7 +1347,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams));
Parameters respParams = myClient
Parameters respParams = ourClient
.operation()
.onType(ConceptMap.class)
.named("translate")
@ -1414,7 +1414,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams));
Parameters respParams = myClient
Parameters respParams = ourClient
.operation()
.onType(ConceptMap.class)
.named("translate")
@ -1467,7 +1467,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams));
Parameters respParams = myClient
Parameters respParams = ourClient
.operation()
.onType(ConceptMap.class)
.named("translate")
@ -1518,7 +1518,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams));
Parameters respParams = myClient
Parameters respParams = ourClient
.operation()
.onType(ConceptMap.class)
.named("translate")
@ -1583,7 +1583,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams));
Parameters respParams = myClient
Parameters respParams = ourClient
.operation()
.onType(ConceptMap.class)
.named("translate")
@ -1641,7 +1641,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams));
Parameters respParams = myClient
Parameters respParams = ourClient
.operation()
.onInstance(myConceptMapId)
.named("translate")

View File

@ -130,7 +130,7 @@ public class ResourceProviderR4ValueSetTest extends BaseResourceProviderR4Test {
@Test
public void testExpandById() {
//@formatter:off
Parameters respParam = myClient
Parameters respParam = ourClient
.operation()
.onInstance(myExtensionalVsId)
.named("expand")
@ -161,7 +161,7 @@ public class ResourceProviderR4ValueSetTest extends BaseResourceProviderR4Test {
public void testExpandByIdWithFilter() {
//@formatter:off
Parameters respParam = myClient
Parameters respParam = ourClient
.operation()
.onInstance(myExtensionalVsId)
.named("expand")
@ -179,7 +179,7 @@ public class ResourceProviderR4ValueSetTest extends BaseResourceProviderR4Test {
@Test
public void testExpandByUrl() {
Parameters respParam = myClient
Parameters respParam = ourClient
.operation()
.onType(ValueSet.class)
.named("expand")
@ -199,7 +199,7 @@ public class ResourceProviderR4ValueSetTest extends BaseResourceProviderR4Test {
public void testExpandByValueSet() throws IOException {
ValueSet toExpand = loadResourceFromClasspath(ValueSet.class, "/extensional-case-3-vs.xml");
Parameters respParam = myClient
Parameters respParam = ourClient
.operation()
.onType(ValueSet.class)
.named("expand")
@ -222,7 +222,7 @@ public class ResourceProviderR4ValueSetTest extends BaseResourceProviderR4Test {
assertNotNull(myLocalValueSetId);
//@formatter:off
Parameters respParam = myClient
Parameters respParam = ourClient
.operation()
.onType(ValueSet.class)
.named("expand")
@ -244,7 +244,7 @@ public class ResourceProviderR4ValueSetTest extends BaseResourceProviderR4Test {
myLocalVs.setId("");
//@formatter:off
Parameters respParam = myClient
Parameters respParam = ourClient
.operation()
.onType(ValueSet.class)
.named("expand")
@ -266,7 +266,7 @@ public class ResourceProviderR4ValueSetTest extends BaseResourceProviderR4Test {
public void testExpandInvalidParams() throws IOException {
//@formatter:off
try {
myClient
ourClient
.operation()
.onType(ValueSet.class)
.named("expand")
@ -281,7 +281,7 @@ public class ResourceProviderR4ValueSetTest extends BaseResourceProviderR4Test {
//@formatter:off
try {
ValueSet toExpand = loadResourceFromClasspath(ValueSet.class, "/r4/extensional-case-r4.xml");
myClient
ourClient
.operation()
.onType(ValueSet.class)
.named("expand")
@ -297,7 +297,7 @@ public class ResourceProviderR4ValueSetTest extends BaseResourceProviderR4Test {
//@formatter:off
try {
ValueSet toExpand = loadResourceFromClasspath(ValueSet.class, "/r4/extensional-case.xml");
myClient
ourClient
.operation()
.onInstance(myExtensionalVsId)
.named("expand")
@ -318,7 +318,7 @@ public class ResourceProviderR4ValueSetTest extends BaseResourceProviderR4Test {
assertNotNull(myLocalValueSetId);
//@formatter:off
Parameters respParam = myClient
Parameters respParam = ourClient
.operation()
.onInstance(myLocalValueSetId)
.named("expand")
@ -339,7 +339,7 @@ public class ResourceProviderR4ValueSetTest extends BaseResourceProviderR4Test {
assertNotNull(myLocalValueSetId);
//@formatter:off
Parameters respParam = myClient
Parameters respParam = ourClient
.operation()
.onInstance(myLocalValueSetId)
.named("expand")
@ -363,7 +363,7 @@ public class ResourceProviderR4ValueSetTest extends BaseResourceProviderR4Test {
assertNotNull(myLocalValueSetId);
//@formatter:off
Parameters respParam = myClient
Parameters respParam = ourClient
.operation()
.onType(ValueSet.class)
.named("expand")
@ -388,7 +388,7 @@ public class ResourceProviderR4ValueSetTest extends BaseResourceProviderR4Test {
//@formatter:off
try {
myClient
ourClient
.operation()
.onInstance(myLocalValueSetId)
.named("expand")
@ -424,7 +424,8 @@ public class ResourceProviderR4ValueSetTest extends BaseResourceProviderR4Test {
@Test
public void testValidateCodeOperationByCodeAndSystemInstance() {
Parameters respParam = myClient
//@formatter:off
Parameters respParam = ourClient
.operation()
.onInstance(myExtensionalVsId)
.named("validate-code")
@ -483,7 +484,8 @@ public class ResourceProviderR4ValueSetTest extends BaseResourceProviderR4Test {
@Test
public void testValidateCodeOperationByCodeAndSystemType() {
Parameters respParam = myClient
//@formatter:off
Parameters respParam = ourClient
.operation()
.onType(ValueSet.class)
.named("validate-code")
@ -499,7 +501,7 @@ public class ResourceProviderR4ValueSetTest extends BaseResourceProviderR4Test {
@Test
public void testValiedateCodeAgainstBuiltInSystem() {
Parameters respParam = myClient
Parameters respParam = ourClient
.operation()
.onType(ValueSet.class)
.named("validate-code")

View File

@ -65,7 +65,7 @@ public class ServerR4Test extends BaseResourceProviderR4Test {
public void testMetadataIncludesResourceCounts() {
Patient p = new Patient();
p.setActive(true);
myClient.create().resource(p).execute();
ourClient.create().resource(p).execute();
/*
* Initial fetch after a clear should return
@ -73,7 +73,7 @@ public class ServerR4Test extends BaseResourceProviderR4Test {
*/
ourResourceCountsCache.clear();
CapabilityStatement capabilityStatement = myClient
CapabilityStatement capabilityStatement = ourClient
.capabilities()
.ofType(CapabilityStatement.class)
.execute();
@ -95,7 +95,7 @@ public class ServerR4Test extends BaseResourceProviderR4Test {
*/
ourResourceCountsCache.update();
capabilityStatement = myClient
capabilityStatement = ourClient
.capabilities()
.ofType(CapabilityStatement.class)
.execute();

View File

@ -56,7 +56,7 @@ public class StaleSearchDeletingSvcR4Test extends BaseResourceProviderR4Test {
}
//@formatter:off
IClientExecutable<IQuery<Bundle>, Bundle> search = myClient
IClientExecutable<IQuery<Bundle>, Bundle> search = ourClient
.search()
.forResource(Patient.class)
.where(Patient.NAME.matches().value("Everything"))
@ -74,12 +74,12 @@ public class StaleSearchDeletingSvcR4Test extends BaseResourceProviderR4Test {
String nextLinkUrl = nextLink.getUrl();
assertThat(nextLinkUrl, not(blankOrNullString()));
Bundle resp2 = myClient.search().byUrl(nextLinkUrl).returnBundle(Bundle.class).execute();
Bundle resp2 = ourClient.search().byUrl(nextLinkUrl).returnBundle(Bundle.class).execute();
ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(resp2));
myStaleSearchDeletingSvc.pollForStaleSearchesAndDeleteThem();
myClient.search().byUrl(nextLinkUrl).returnBundle(Bundle.class).execute();
ourClient.search().byUrl(nextLinkUrl).returnBundle(Bundle.class).execute();
Thread.sleep(20);
myDaoConfig.setExpireSearchResultsAfterMillis(10);
@ -87,7 +87,7 @@ public class StaleSearchDeletingSvcR4Test extends BaseResourceProviderR4Test {
myStaleSearchDeletingSvc.pollForStaleSearchesAndDeleteThem();
try {
myClient.search().byUrl(nextLinkUrl).returnBundle(Bundle.class).execute();
ourClient.search().byUrl(nextLinkUrl).returnBundle(Bundle.class).execute();
fail();
} catch (ResourceGoneException e) {
assertThat(e.getMessage(), containsString("does not exist and may have expired"));

View File

@ -57,7 +57,7 @@ public class SubscriptionsR4Test extends BaseResourceProviderR4Test {
subs.getChannel().setEndpoint("http://localhost:8888");
subs.setCriteria("Observation?identifier=123");
try {
myClient.create().resource(subs).execute();
ourClient.create().resource(subs).execute();
fail();
} catch (UnprocessableEntityException e) {
assertThat(e.getMessage(), containsString("Subscription.status must be populated on this server"));
@ -65,14 +65,14 @@ public class SubscriptionsR4Test extends BaseResourceProviderR4Test {
subs.setId("ABC");
try {
myClient.update().resource(subs).execute();
ourClient.update().resource(subs).execute();
fail();
} catch (UnprocessableEntityException e) {
assertThat(e.getMessage(), containsString("Subscription.status must be populated on this server"));
}
subs.setStatus(SubscriptionStatus.REQUESTED);
myClient.update().resource(subs).execute();
ourClient.update().resource(subs).execute();
}
@Test
@ -84,7 +84,7 @@ public class SubscriptionsR4Test extends BaseResourceProviderR4Test {
subs.setStatus(SubscriptionStatus.ACTIVE);
subs.setCriteria("Observation?identifier=123");
try {
myClient.create().resource(subs).execute();
ourClient.create().resource(subs).execute();
fail();
} catch (UnprocessableEntityException e) {
assertEquals("HTTP 422 Unprocessable Entity: Subscription.status must be 'off' or 'requested' on a newly created subscription", e.getMessage());
@ -92,7 +92,7 @@ public class SubscriptionsR4Test extends BaseResourceProviderR4Test {
subs.setId("ABC");
try {
myClient.update().resource(subs).execute();
ourClient.update().resource(subs).execute();
fail();
} catch (UnprocessableEntityException e) {
assertEquals("HTTP 422 Unprocessable Entity: Subscription.status must be 'off' or 'requested' on a newly created subscription", e.getMessage());
@ -109,13 +109,13 @@ public class SubscriptionsR4Test extends BaseResourceProviderR4Test {
subs.getChannel().setEndpoint("http://localhost:8888");
subs.setStatus(SubscriptionStatus.REQUESTED);
subs.setCriteria("Observation?identifier=123");
IIdType id = myClient.create().resource(subs).execute().getId().toUnqualifiedVersionless();
IIdType id = ourClient.create().resource(subs).execute().getId().toUnqualifiedVersionless();
subs.setId(id);
try {
subs.setStatus(SubscriptionStatus.ACTIVE);
myClient.update().resource(subs).execute();
ourClient.update().resource(subs).execute();
fail();
} catch (UnprocessableEntityException e) {
assertEquals("HTTP 422 Unprocessable Entity: Subscription.status can not be changed from 'requested' to 'active'", e.getMessage());
@ -123,7 +123,7 @@ public class SubscriptionsR4Test extends BaseResourceProviderR4Test {
try {
subs.setStatus((SubscriptionStatus) null);
myClient.update().resource(subs).execute();
ourClient.update().resource(subs).execute();
fail();
} catch (UnprocessableEntityException e) {
assertThat(e.getMessage(), containsString("Subscription.status must be populated on this server"));
@ -141,12 +141,12 @@ public class SubscriptionsR4Test extends BaseResourceProviderR4Test {
subs.getChannel().setEndpoint("http://localhost:8888");
subs.setCriteria("Observation?identifier=123");
subs.setStatus(SubscriptionStatus.REQUESTED);
IIdType id = myClient.create().resource(subs).execute().getId();
IIdType id = ourClient.create().resource(subs).execute().getId();
subs.setId(id);
try {
subs.setStatus(SubscriptionStatus.ACTIVE);
myClient.update().resource(subs).execute();
ourClient.update().resource(subs).execute();
fail();
} catch (UnprocessableEntityException e) {
assertEquals("HTTP 422 Unprocessable Entity: Subscription.status can not be changed from 'requested' to 'active'", e.getMessage());
@ -154,14 +154,14 @@ public class SubscriptionsR4Test extends BaseResourceProviderR4Test {
try {
subs.setStatus((SubscriptionStatus) null);
myClient.update().resource(subs).execute();
ourClient.update().resource(subs).execute();
fail();
} catch (UnprocessableEntityException e) {
assertThat(e.getMessage(), containsString("Subscription.status must be populated on this server"));
}
subs.setStatus(SubscriptionStatus.OFF);
myClient.update().resource(subs).execute();
ourClient.update().resource(subs).execute();
}
@AfterClass

View File

@ -47,7 +47,7 @@ public class TerminologyUploaderProviderR4Test extends BaseResourceProviderR4Tes
//@formatter:off
try {
myClient
ourClient
.operation()
.onServer()
.named("upload-external-code-system")
@ -66,7 +66,7 @@ public class TerminologyUploaderProviderR4Test extends BaseResourceProviderR4Tes
byte[] packageBytes = TerminologyUploaderProviderDstu3Test.createLoincZip();
//@formatter:off
Parameters respParam = myClient
Parameters respParam = ourClient
.operation()
.onServer()
.named("upload-external-code-system")
@ -86,7 +86,7 @@ public class TerminologyUploaderProviderR4Test extends BaseResourceProviderR4Tes
*/
//@formatter:off
respParam = myClient
respParam = ourClient
.operation()
.onServer()
.named("upload-external-code-system")
@ -104,7 +104,7 @@ public class TerminologyUploaderProviderR4Test extends BaseResourceProviderR4Tes
public void testUploadMissingPackage() throws Exception {
//@formatter:off
try {
myClient
ourClient
.operation()
.onServer()
.named("upload-external-code-system")
@ -123,7 +123,7 @@ public class TerminologyUploaderProviderR4Test extends BaseResourceProviderR4Tes
//@formatter:off
try {
myClient
ourClient
.operation()
.onServer()
.named("upload-external-code-system")
@ -141,7 +141,7 @@ public class TerminologyUploaderProviderR4Test extends BaseResourceProviderR4Tes
byte[] packageBytes = createSctZip();
//@formatter:off
Parameters respParam = myClient
Parameters respParam = ourClient
.operation()
.onServer()
.named("upload-external-code-system")
@ -167,7 +167,7 @@ public class TerminologyUploaderProviderR4Test extends BaseResourceProviderR4Tes
fos.close();
//@formatter:off
Parameters respParam = myClient
Parameters respParam = ourClient
.operation()
.onServer()
.named("upload-external-code-system")

View File

@ -61,7 +61,7 @@ public class PagingMultinodeProviderR4Test extends BaseResourceProviderR4Test {
mySearchCoordinatorSvcRaw.setSyncSizeForUnitTests(10);
mySearchCoordinatorSvcRaw.setNeverUseLocalSearchForUnitTests(true);
found = myClient
found = ourClient
.search()
.forResource(Patient.class)
.sort().ascending(Patient.SP_FAMILY)
@ -70,19 +70,19 @@ public class PagingMultinodeProviderR4Test extends BaseResourceProviderR4Test {
.execute();
assertThat(toUnqualifiedVersionlessIdValues(found), contains("Patient/A000", "Patient/A001", "Patient/A002", "Patient/A003", "Patient/A004", "Patient/A005", "Patient/A006", "Patient/A007", "Patient/A008", "Patient/A009"));
found = myClient
found = ourClient
.loadPage()
.next(found)
.execute();
assertThat(toUnqualifiedVersionlessIdValues(found), contains("Patient/A010", "Patient/A011", "Patient/A012", "Patient/A013", "Patient/A014", "Patient/A015", "Patient/A016", "Patient/A017", "Patient/A018", "Patient/A019"));
found = myClient
found = ourClient
.loadPage()
.next(found)
.execute();
assertThat(toUnqualifiedVersionlessIdValues(found), contains("Patient/A020", "Patient/A021", "Patient/A022", "Patient/A023", "Patient/A024", "Patient/A025", "Patient/A026", "Patient/A027", "Patient/A028", "Patient/A029"));
found = myClient
found = ourClient
.loadPage()
.next(found)
.execute();

View File

@ -67,7 +67,7 @@ public class RestHookActivatesPreExistingSubscriptionsR4Test extends BaseResourc
channel.setPayload(thePayload);
channel.setEndpoint(theEndpoint);
MethodOutcome methodOutcome = myClient.create().resource(subscription).execute();
MethodOutcome methodOutcome = ourClient.create().resource(subscription).execute();
subscription.setId(methodOutcome.getId().getIdPart());
waitForQueueToDrain();
@ -84,7 +84,7 @@ public class RestHookActivatesPreExistingSubscriptionsR4Test extends BaseResourc
observation.setStatus(Observation.ObservationStatus.FINAL);
MethodOutcome methodOutcome = myClient.create().resource(observation).execute();
MethodOutcome methodOutcome = ourClient.create().resource(observation).execute();
String observationId = methodOutcome.getId().getIdPart();
observation.setId(observationId);

View File

@ -4,7 +4,6 @@ import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.jpa.dao.DaoConfig;
import ca.uhn.fhir.jpa.provider.r4.BaseResourceProviderR4Test;
import ca.uhn.fhir.jpa.subscription.RestHookTestDstu2Test;
import ca.uhn.fhir.jpa.subscription.resthook.SubscriptionRestHookInterceptor;
import ca.uhn.fhir.jpa.util.JpaConstants;
import ca.uhn.fhir.rest.annotation.Create;
import ca.uhn.fhir.rest.annotation.ResourceParam;
@ -16,7 +15,6 @@ import ca.uhn.fhir.rest.server.RestfulServer;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import ca.uhn.fhir.util.BundleUtil;
import ca.uhn.fhir.util.PortUtil;
import ca.uhn.fhir.util.TestUtil;
import com.google.common.collect.Lists;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
@ -86,14 +84,14 @@ public class RestHookTestR4Test extends BaseResourceProviderR4Test {
for (IIdType next : mySubscriptionIds) {
IIdType nextId = next.toUnqualifiedVersionless();
ourLog.info("Deleting: {}", nextId);
myClient.delete().resourceById(nextId).execute();
ourClient.delete().resourceById(nextId).execute();
}
mySubscriptionIds.clear();
myDaoConfig.setAllowMultipleDelete(true);
ourLog.info("Deleting all subscriptions");
myClient.delete().resourceConditionalByUrl("Subscription?status=active").execute();
myClient.delete().resourceConditionalByUrl("Observation?code:missing=false").execute();
ourClient.delete().resourceConditionalByUrl("Subscription?status=active").execute();
ourClient.delete().resourceConditionalByUrl("Observation?code:missing=false").execute();
ourLog.info("Done deleting all subscriptions");
myDaoConfig.setAllowMultipleDelete(new DaoConfig().isAllowMultipleDelete());
@ -113,9 +111,9 @@ public class RestHookTestR4Test extends BaseResourceProviderR4Test {
ourHeaders.clear();
// Delete all Subscriptions
Bundle allSubscriptions = myClient.search().forResource(Subscription.class).returnBundle(Bundle.class).execute();
Bundle allSubscriptions = ourClient.search().forResource(Subscription.class).returnBundle(Bundle.class).execute();
for (IBaseResource next : BundleUtil.toListOfResources(myFhirCtx, allSubscriptions)) {
myClient.delete().resource(next).execute();
ourClient.delete().resource(next).execute();
}
waitForRegisteredSubscriptionCount(0);
@ -136,7 +134,7 @@ public class RestHookTestR4Test extends BaseResourceProviderR4Test {
channel.setPayload(thePayload);
channel.setEndpoint(theEndpoint);
MethodOutcome methodOutcome = myClient.create().resource(subscription).execute();
MethodOutcome methodOutcome = ourClient.create().resource(subscription).execute();
subscription.setId(methodOutcome.getId().getIdPart());
mySubscriptionIds.add(methodOutcome.getId());
@ -153,7 +151,7 @@ public class RestHookTestR4Test extends BaseResourceProviderR4Test {
observation.setStatus(Observation.ObservationStatus.FINAL);
MethodOutcome methodOutcome = myClient.create().resource(observation).execute();
MethodOutcome methodOutcome = ourClient.create().resource(observation).execute();
String observationId = methodOutcome.getId().getIdPart();
observation.setId(observationId);
@ -204,7 +202,7 @@ public class RestHookTestR4Test extends BaseResourceProviderR4Test {
// Send an update with no changes
obs.setId(obs.getIdElement().toUnqualifiedVersionless());
myClient.update().resource(obs).execute();
ourClient.update().resource(obs).execute();
// Should be no further deliveries
Thread.sleep(1000);
@ -234,9 +232,8 @@ public class RestHookTestR4Test extends BaseResourceProviderR4Test {
.getChannel()
.addExtension(JpaConstants.EXT_SUBSCRIPTION_RESTHOOK_DELIVER_LATEST_VERSION, new BooleanType("true"));
ourLog.info("** About to update subscription");
myClient.update().resource(subscription1).execute();
ourClient.update().resource(subscription1).execute();
waitForSize(modCount + 1, ()->myCountingInterceptor.getSentCount());
Thread.sleep(4000);
ourLog.info("** About to send observation");
Observation observation1 = sendObservation(code, "SNOMED-CT");
@ -273,11 +270,11 @@ public class RestHookTestR4Test extends BaseResourceProviderR4Test {
assertEquals("1", ourUpdatedObservations.get(0).getIdElement().getVersionIdPart());
Subscription subscriptionTemp = myClient.read(Subscription.class, subscription2.getId());
Subscription subscriptionTemp = ourClient.read(Subscription.class, subscription2.getId());
Assert.assertNotNull(subscriptionTemp);
subscriptionTemp.setCriteria(criteria1);
myClient.update().resource(subscriptionTemp).withId(subscriptionTemp.getIdElement()).execute();
ourClient.update().resource(subscriptionTemp).withId(subscriptionTemp.getIdElement()).execute();
waitForQueueToDrain();
Observation observation2 = sendObservation(code, "SNOMED-CT");
@ -287,7 +284,7 @@ public class RestHookTestR4Test extends BaseResourceProviderR4Test {
waitForSize(0, ourCreatedObservations);
waitForSize(3, ourUpdatedObservations);
myClient.delete().resourceById(new IdType("Subscription/" + subscription2.getId())).execute();
ourClient.delete().resourceById(new IdType("Subscription/" + subscription2.getId())).execute();
waitForQueueToDrain();
Observation observationTemp3 = sendObservation(code, "SNOMED-CT");
@ -297,27 +294,27 @@ public class RestHookTestR4Test extends BaseResourceProviderR4Test {
waitForSize(0, ourCreatedObservations);
waitForSize(4, ourUpdatedObservations);
Observation observation3 = myClient.read(Observation.class, observationTemp3.getId());
Observation observation3 = ourClient.read(Observation.class, observationTemp3.getId());
CodeableConcept codeableConcept = new CodeableConcept();
observation3.setCode(codeableConcept);
Coding coding = codeableConcept.addCoding();
coding.setCode(code + "111");
coding.setSystem("SNOMED-CT");
myClient.update().resource(observation3).withId(observation3.getIdElement()).execute();
ourClient.update().resource(observation3).withId(observation3.getIdElement()).execute();
// Should see no subscription notification
waitForQueueToDrain();
waitForSize(0, ourCreatedObservations);
waitForSize(4, ourUpdatedObservations);
Observation observation3a = myClient.read(Observation.class, observationTemp3.getId());
Observation observation3a = ourClient.read(Observation.class, observationTemp3.getId());
CodeableConcept codeableConcept1 = new CodeableConcept();
observation3a.setCode(codeableConcept1);
Coding coding1 = codeableConcept1.addCoding();
coding1.setCode(code);
coding1.setSystem("SNOMED-CT");
myClient.update().resource(observation3a).withId(observation3a.getIdElement()).execute();
ourClient.update().resource(observation3a).withId(observation3a.getIdElement()).execute();
// Should see only one subscription notification
waitForQueueToDrain();
@ -349,10 +346,10 @@ public class RestHookTestR4Test extends BaseResourceProviderR4Test {
waitForSize(1, ourUpdatedObservations);
assertEquals(Constants.CT_FHIR_XML_NEW, ourContentTypes.get(0));
Subscription subscriptionTemp = myClient.read(Subscription.class, subscription2.getId());
Subscription subscriptionTemp = ourClient.read(Subscription.class, subscription2.getId());
Assert.assertNotNull(subscriptionTemp);
subscriptionTemp.setCriteria(criteria1);
myClient.update().resource(subscriptionTemp).withId(subscriptionTemp.getIdElement()).execute();
ourClient.update().resource(subscriptionTemp).withId(subscriptionTemp.getIdElement()).execute();
waitForQueueToDrain();
Observation observation2 = sendObservation(code, "SNOMED-CT");
@ -362,7 +359,7 @@ public class RestHookTestR4Test extends BaseResourceProviderR4Test {
waitForSize(0, ourCreatedObservations);
waitForSize(3, ourUpdatedObservations);
myClient.delete().resourceById(new IdType("Subscription/" + subscription2.getId())).execute();
ourClient.delete().resourceById(new IdType("Subscription/" + subscription2.getId())).execute();
Observation observationTemp3 = sendObservation(code, "SNOMED-CT");
@ -371,27 +368,27 @@ public class RestHookTestR4Test extends BaseResourceProviderR4Test {
waitForSize(0, ourCreatedObservations);
waitForSize(4, ourUpdatedObservations);
Observation observation3 = myClient.read(Observation.class, observationTemp3.getId());
Observation observation3 = ourClient.read(Observation.class, observationTemp3.getId());
CodeableConcept codeableConcept = new CodeableConcept();
observation3.setCode(codeableConcept);
Coding coding = codeableConcept.addCoding();
coding.setCode(code + "111");
coding.setSystem("SNOMED-CT");
myClient.update().resource(observation3).withId(observation3.getIdElement()).execute();
ourClient.update().resource(observation3).withId(observation3.getIdElement()).execute();
// Should see no subscription notification
waitForQueueToDrain();
waitForSize(0, ourCreatedObservations);
waitForSize(4, ourUpdatedObservations);
Observation observation3a = myClient.read(Observation.class, observationTemp3.getId());
Observation observation3a = ourClient.read(Observation.class, observationTemp3.getId());
CodeableConcept codeableConcept1 = new CodeableConcept();
observation3a.setCode(codeableConcept1);
Coding coding1 = codeableConcept1.addCoding();
coding1.setCode(code);
coding1.setSystem("SNOMED-CT");
myClient.update().resource(observation3a).withId(observation3a.getIdElement()).execute();
ourClient.update().resource(observation3a).withId(observation3a.getIdElement()).execute();
// Should see only one subscription notification
waitForQueueToDrain();
@ -424,12 +421,12 @@ public class RestHookTestR4Test extends BaseResourceProviderR4Test {
Thread.sleep(1000);
assertEquals(0, ourUpdatedObservations.size());
Subscription subscriptionTemp = myClient.read().resource(Subscription.class).withId(subscription2.getId()).execute();
Subscription subscriptionTemp = ourClient.read().resource(Subscription.class).withId(subscription2.getId()).execute();
Assert.assertNotNull(subscriptionTemp);
String criteriaGood = "Observation?code=SNOMED-CT|" + code + "&_format=xml";
subscriptionTemp.setCriteria(criteriaGood);
ourLog.info("** About to update subscription");
myClient.update().resource(subscriptionTemp).withId(subscriptionTemp.getIdElement()).execute();
ourClient.update().resource(subscriptionTemp).withId(subscriptionTemp.getIdElement()).execute();
waitForQueueToDrain();
ourLog.info("** About to send Observation 2");
@ -440,7 +437,7 @@ public class RestHookTestR4Test extends BaseResourceProviderR4Test {
waitForSize(0, ourCreatedObservations);
waitForSize(1, ourUpdatedObservations);
myClient.delete().resourceById(new IdType("Subscription/" + subscription2.getId())).execute();
ourClient.delete().resourceById(new IdType("Subscription/" + subscription2.getId())).execute();
Observation observationTemp3 = sendObservation(code, "SNOMED-CT");
@ -500,7 +497,7 @@ public class RestHookTestR4Test extends BaseResourceProviderR4Test {
subscription.getChannel().addHeader("X-Foo: FOO");
subscription.getChannel().addHeader("X-Bar: BAR");
subscription.setStatus(Subscription.SubscriptionStatus.REQUESTED);
myClient.update().resource(subscription).execute();
ourClient.update().resource(subscription).execute();
waitForQueueToDrain();
sendObservation(code, "SNOMED-CT");
@ -533,7 +530,7 @@ public class RestHookTestR4Test extends BaseResourceProviderR4Test {
// Disable
subscription.setStatus(Subscription.SubscriptionStatus.OFF);
myClient.update().resource(subscription).execute();
ourClient.update().resource(subscription).execute();
waitForQueueToDrain();
// Send another object

View File

@ -44,7 +44,7 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigR4Test extends Base
public void afterUnregisterRestHookListener() {
myDaoConfig.setAllowMultipleDelete(true);
ourLog.info("Deleting all subscriptions");
myClient.delete().resourceConditionalByUrl("Subscription?status=active").execute();
ourClient.delete().resourceConditionalByUrl("Subscription?status=active").execute();
ourLog.info("Done deleting all subscriptions");
myDaoConfig.setAllowMultipleDelete(new DaoConfig().isAllowMultipleDelete());
@ -74,7 +74,7 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigR4Test extends Base
channel.setEndpoint(endpoint);
subscription.setChannel(channel);
MethodOutcome methodOutcome = myClient.create().resource(subscription).execute();
MethodOutcome methodOutcome = ourClient.create().resource(subscription).execute();
subscription.setId(methodOutcome.getId().getIdPart());
waitForQueueToDrain();
@ -99,7 +99,7 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigR4Test extends Base
observation.setStatus(Observation.ObservationStatus.FINAL);
MethodOutcome methodOutcome = myClient.create().resource(observation).execute();
MethodOutcome methodOutcome = ourClient.create().resource(observation).execute();
String observationId = methodOutcome.getId().getIdPart();
observation.setId(observationId);
@ -127,11 +127,11 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigR4Test extends Base
waitForSize(0, ourCreatedObservations);
waitForSize(1, ourUpdatedObservations);
Subscription subscriptionTemp = myClient.read(Subscription.class, subscription2.getId());
Subscription subscriptionTemp = ourClient.read(Subscription.class, subscription2.getId());
Assert.assertNotNull(subscriptionTemp);
subscriptionTemp.setCriteria(criteria1);
myClient.update().resource(subscriptionTemp).withId(subscriptionTemp.getIdElement()).execute();
ourClient.update().resource(subscriptionTemp).withId(subscriptionTemp.getIdElement()).execute();
Observation observation2 = sendObservation(code, "SNOMED-CT");
@ -141,7 +141,7 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigR4Test extends Base
waitForSize(0, ourCreatedObservations);
waitForSize(3, ourUpdatedObservations);
myClient.delete().resourceById(new IdDt("Subscription", subscription2.getId())).execute();
ourClient.delete().resourceById(new IdDt("Subscription", subscription2.getId())).execute();
Observation observationTemp3 = sendObservation(code, "SNOMED-CT");
@ -150,27 +150,27 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigR4Test extends Base
waitForSize(0, ourCreatedObservations);
waitForSize(4, ourUpdatedObservations);
Observation observation3 = myClient.read().resource(Observation.class).withId(observationTemp3.getId()).execute();
Observation observation3 = ourClient.read(Observation.class, observationTemp3.getId());
CodeableConcept codeableConcept = new CodeableConcept();
observation3.setCode(codeableConcept);
Coding coding = codeableConcept.addCoding();
coding.setCode(code + "111");
coding.setSystem("SNOMED-CT");
myClient.update().resource(observation3).withId(observation3.getIdElement()).execute();
ourClient.update().resource(observation3).withId(observation3.getIdElement()).execute();
// Should see no subscription notification
Thread.sleep(500);
waitForSize(0, ourCreatedObservations);
waitForSize(4, ourUpdatedObservations);
Observation observation3a = myClient.read(Observation.class, observationTemp3.getId());
Observation observation3a = ourClient.read(Observation.class, observationTemp3.getId());
CodeableConcept codeableConcept1 = new CodeableConcept();
observation3a.setCode(codeableConcept1);
Coding coding1 = codeableConcept1.addCoding();
coding1.setCode(code);
coding1.setSystem("SNOMED-CT");
myClient.update().resource(observation3a).withId(observation3a.getIdElement()).execute();
ourClient.update().resource(observation3a).withId(observation3a.getIdElement()).execute();
// Should see only one subscription notification
Thread.sleep(500);
@ -200,11 +200,11 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigR4Test extends Base
waitForSize(0, ourCreatedObservations);
waitForSize(1, ourUpdatedObservations);
Subscription subscriptionTemp = myClient.read(Subscription.class, subscription2.getId());
Subscription subscriptionTemp = ourClient.read(Subscription.class, subscription2.getId());
Assert.assertNotNull(subscriptionTemp);
subscriptionTemp.setCriteria(criteria1);
myClient.update().resource(subscriptionTemp).withId(subscriptionTemp.getIdElement()).execute();
ourClient.update().resource(subscriptionTemp).withId(subscriptionTemp.getIdElement()).execute();
Observation observation2 = sendObservation(code, "SNOMED-CT");
@ -214,7 +214,7 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigR4Test extends Base
waitForSize(0, ourCreatedObservations);
waitForSize(3, ourUpdatedObservations);
myClient.delete().resourceById(new IdDt("Subscription", subscription2.getId())).execute();
ourClient.delete().resourceById(new IdDt("Subscription", subscription2.getId())).execute();
Observation observationTemp3 = sendObservation(code, "SNOMED-CT");
@ -223,27 +223,27 @@ public class RestHookTestWithInterceptorRegisteredToDaoConfigR4Test extends Base
waitForSize(0, ourCreatedObservations);
waitForSize(4, ourUpdatedObservations);
Observation observation3 = myClient.read().resource(Observation.class).withId(observationTemp3.getId()).execute();
Observation observation3 = ourClient.read(Observation.class, observationTemp3.getId());
CodeableConcept codeableConcept = new CodeableConcept();
observation3.setCode(codeableConcept);
Coding coding = codeableConcept.addCoding();
coding.setCode(code + "111");
coding.setSystem("SNOMED-CT");
myClient.update().resource(observation3).withId(observation3.getIdElement()).execute();
ourClient.update().resource(observation3).withId(observation3.getIdElement()).execute();
// Should see no subscription notification
waitForQueueToDrain();
waitForSize(0, ourCreatedObservations);
waitForSize(4, ourUpdatedObservations);
Observation observation3a = myClient.read().resource(Observation.class).withId(observationTemp3.getId()).execute();
Observation observation3a = ourClient.read(Observation.class, observationTemp3.getId());
CodeableConcept codeableConcept1 = new CodeableConcept();
observation3a.setCode(codeableConcept1);
Coding coding1 = codeableConcept1.addCoding();
coding1.setCode(code);
coding1.setSystem("SNOMED-CT");
myClient.update().resource(observation3a).withId(observation3a.getIdElement()).execute();
ourClient.update().resource(observation3a).withId(observation3a.getIdElement()).execute();
// Should see only one subscription notification
waitForQueueToDrain();

View File

@ -52,14 +52,14 @@ public class RestHookWithEventDefinitionR4Test extends BaseResourceProviderR4Tes
@After
public void afterUnregisterRestHookListener() {
for (IIdType next : mySubscriptionIds) {
myClient.delete().resourceById(next).execute();
ourClient.delete().resourceById(next).execute();
}
mySubscriptionIds.clear();
myDaoConfig.setAllowMultipleDelete(true);
ourLog.info("Deleting all subscriptions");
myClient.delete().resourceConditionalByUrl("Subscription?status=active").execute();
myClient.delete().resourceConditionalByUrl("Observation?code:missing=false").execute();
ourClient.delete().resourceConditionalByUrl("Subscription?status=active").execute();
ourClient.delete().resourceConditionalByUrl("Observation?code:missing=false").execute();
ourLog.info("Done deleting all subscriptions");
myDaoConfig.setAllowMultipleDelete(new DaoConfig().isAllowMultipleDelete());
@ -83,7 +83,7 @@ public class RestHookWithEventDefinitionR4Test extends BaseResourceProviderR4Tes
*/
Patient patient = FhirR4Util.getPatient();
MethodOutcome methodOutcome = myClient.create().resource(patient).execute();
MethodOutcome methodOutcome = ourClient.create().resource(patient).execute();
myPatientId = methodOutcome.getId().getIdPart();
/*
@ -114,7 +114,7 @@ public class RestHookWithEventDefinitionR4Test extends BaseResourceProviderR4Tes
channel.setPayload("application/json");
subscription.setChannel(channel);
methodOutcome = myClient.create().resource(subscription).execute();
methodOutcome = ourClient.create().resource(subscription).execute();
mySubscriptionId = methodOutcome.getId().getIdPart();
}

View File

@ -49,7 +49,7 @@ public class WebsocketWithCriteriaR4Test extends BaseResourceProviderR4Test {
*/
Patient patient = FhirR4Util.getPatient();
MethodOutcome methodOutcome = myClient.create().resource(patient).execute();
MethodOutcome methodOutcome = ourClient.create().resource(patient).execute();
myPatientId = methodOutcome.getId().getIdPart();
/*
@ -66,7 +66,7 @@ public class WebsocketWithCriteriaR4Test extends BaseResourceProviderR4Test {
channel.setPayload("application/json");
subscription.setChannel(channel);
methodOutcome = myClient.create().resource(subscription).execute();
methodOutcome = ourClient.create().resource(subscription).execute();
mySubscriptionId = methodOutcome.getId().getIdPart();
/*
@ -105,7 +105,7 @@ public class WebsocketWithCriteriaR4Test extends BaseResourceProviderR4Test {
observation.setSubject(reference);
observation.setStatus(Observation.ObservationStatus.FINAL);
MethodOutcome methodOutcome2 = myClient.create().resource(observation).execute();
MethodOutcome methodOutcome2 = ourClient.create().resource(observation).execute();
String observationId = methodOutcome2.getId().getIdPart();
observation.setId(observationId);
@ -129,7 +129,7 @@ public class WebsocketWithCriteriaR4Test extends BaseResourceProviderR4Test {
observation.setSubject(reference);
observation.setStatus(Observation.ObservationStatus.FINAL);
MethodOutcome methodOutcome2 = myClient.create().resource(observation).execute();
MethodOutcome methodOutcome2 = ourClient.create().resource(observation).execute();
String observationId = methodOutcome2.getId().getIdPart();
observation.setId(observationId);

View File

@ -74,7 +74,7 @@ public class WebsocketWithSubscriptionIdR4Test extends BaseResourceProviderR4Tes
*/
Patient patient = FhirR4Util.getPatient();
MethodOutcome methodOutcome = myClient.create().resource(patient).execute();
MethodOutcome methodOutcome = ourClient.create().resource(patient).execute();
myPatientId = methodOutcome.getId().getIdPart();
/*
@ -91,7 +91,7 @@ public class WebsocketWithSubscriptionIdR4Test extends BaseResourceProviderR4Tes
channel.setPayload("application/json");
subscription.setChannel(channel);
methodOutcome = myClient.create().resource(subscription).execute();
methodOutcome = ourClient.create().resource(subscription).execute();
mySubscriptionId = methodOutcome.getId().getIdPart();
/*
@ -124,7 +124,7 @@ public class WebsocketWithSubscriptionIdR4Test extends BaseResourceProviderR4Tes
observation.setSubject(reference);
observation.setStatus(Observation.ObservationStatus.FINAL);
MethodOutcome methodOutcome2 = myClient.create().resource(observation).execute();
MethodOutcome methodOutcome2 = ourClient.create().resource(observation).execute();
String observationId = methodOutcome2.getId().getIdPart();
observation.setId(observationId);
@ -148,7 +148,7 @@ public class WebsocketWithSubscriptionIdR4Test extends BaseResourceProviderR4Tes
observation.setSubject(reference);
observation.setStatus(Observation.ObservationStatus.FINAL);
MethodOutcome methodOutcome2 = myClient.create().resource(observation).execute();
MethodOutcome methodOutcome2 = ourClient.create().resource(observation).execute();
String observationId = methodOutcome2.getId().getIdPart();
observation.setId(observationId);

View File

@ -0,0 +1,42 @@
package ca.uhn.fhir.parser.view;
import ca.uhn.fhir.model.api.annotation.Child;
import ca.uhn.fhir.model.api.annotation.Extension;
import ca.uhn.fhir.model.api.annotation.ResourceDef;
import org.hl7.fhir.r4.model.IntegerType;
import org.hl7.fhir.r4.model.Patient;
@ResourceDef(name = "Patient")
public class ExtPatient extends Patient {
@Extension(url = "urn:ext", isModifier = false, definedLocally = false)
@Child(name = "ext")
private IntegerType myExt;
@Extension(url = "urn:modExt", isModifier = false, definedLocally = false)
@Child(name = "modExt")
private IntegerType myModExt;
public IntegerType getExt() {
if (myExt == null) {
myExt = new IntegerType();
}
return myExt;
}
public void setExt(IntegerType theExt) {
myExt = theExt;
}
public IntegerType getModExt() {
if (myModExt == null) {
myModExt = new IntegerType();
}
return myModExt;
}
public void setModExt(IntegerType theModExt) {
myModExt = theModExt;
}
}

View File

@ -0,0 +1,116 @@
package ca.uhn.fhir.parser.view;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.parser.IParser;
import ca.uhn.fhir.util.TestUtil;
import org.hl7.fhir.r4.model.Extension;
import org.hl7.fhir.r4.model.IntegerType;
import org.hl7.fhir.r4.model.Patient;
import org.junit.AfterClass;
import org.junit.Test;
import java.util.List;
import static org.junit.Assert.assertEquals;
public class ViewGeneratorTest {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ViewGeneratorTest.class);
private static FhirContext ourCtx = FhirContext.forR4();
@AfterClass
public static void afterClassClearContext() {
TestUtil.clearAllStaticFieldsForUnitTest();
}
@Test
public void testView() {
ExtPatient src = new ExtPatient();
src.addIdentifier().setSystem("urn:sys").setValue("id1");
src.addIdentifier().setSystem("urn:sys").setValue("id2");
src.getExt().setValue(100);
src.getModExt().setValue(200);
String enc = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(src);
ourLog.info(enc);
IParser parser = ourCtx.newXmlParser();
Patient nonExt = parser.parseResource(Patient.class, enc);
assertEquals(Patient.class, nonExt.getClass());
assertEquals("urn:sys", nonExt.getIdentifier().get(0).getSystem());
assertEquals("id1", nonExt.getIdentifier().get(0).getValue());
assertEquals("urn:sys", nonExt.getIdentifier().get(1).getSystem());
assertEquals("id2", nonExt.getIdentifier().get(1).getValue());
List<Extension> ext = nonExt.getExtensionsByUrl("urn:ext");
assertEquals(1, ext.size());
assertEquals("urn:ext", ext.get(0).getUrl());
assertEquals(IntegerType.class, ext.get(0).getValueAsPrimitive().getClass());
assertEquals("100", ext.get(0).getValueAsPrimitive().getValueAsString());
List<Extension> modExt = nonExt.getExtensionsByUrl("urn:modExt");
assertEquals(1, modExt.size());
assertEquals("urn:modExt", modExt.get(0).getUrl());
assertEquals(IntegerType.class, modExt.get(0).getValueAsPrimitive().getClass());
assertEquals("200", modExt.get(0).getValueAsPrimitive().getValueAsString());
ExtPatient va = ourCtx.newViewGenerator().newView(nonExt, ExtPatient.class);
assertEquals("urn:sys", va.getIdentifier().get(0).getSystem());
assertEquals("id1", va.getIdentifier().get(0).getValue());
assertEquals("urn:sys", va.getIdentifier().get(1).getSystem());
assertEquals("id2", va.getIdentifier().get(1).getValue());
assertEquals(100, va.getExt().getValue().intValue());
assertEquals(200, va.getModExt().getValue().intValue());
assertEquals(0, va.getExtension().size());
}
@Test
public void testViewJson() {
ExtPatient src = new ExtPatient();
src.addIdentifier().setSystem("urn:sys").setValue("id1");
src.addIdentifier().setSystem("urn:sys").setValue("id2");
src.getExt().setValue(100);
src.getModExt().setValue(200);
String enc = ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(src);
ourLog.info(enc);
IParser parser = ourCtx.newJsonParser();
Patient nonExt = parser.parseResource(Patient.class, enc);
assertEquals(Patient.class, nonExt.getClass());
assertEquals("urn:sys", nonExt.getIdentifier().get(0).getSystem());
assertEquals("id1", nonExt.getIdentifier().get(0).getValue());
assertEquals("urn:sys", nonExt.getIdentifier().get(1).getSystem());
assertEquals("id2", nonExt.getIdentifier().get(1).getValue());
List<Extension> ext = nonExt.getExtensionsByUrl("urn:ext");
assertEquals(1, ext.size());
assertEquals("urn:ext", ext.get(0).getUrl());
assertEquals(IntegerType.class, ext.get(0).getValueAsPrimitive().getClass());
assertEquals("100", ext.get(0).getValueAsPrimitive().getValueAsString());
List<Extension> modExt = nonExt.getExtensionsByUrl("urn:modExt");
assertEquals(1, modExt.size());
assertEquals("urn:modExt", modExt.get(0).getUrl());
assertEquals(IntegerType.class, modExt.get(0).getValueAsPrimitive().getClass());
assertEquals("200", modExt.get(0).getValueAsPrimitive().getValueAsString());
ExtPatient va = ourCtx.newViewGenerator().newView(nonExt, ExtPatient.class);
assertEquals("urn:sys", va.getIdentifier().get(0).getSystem());
assertEquals("id1", va.getIdentifier().get(0).getValue());
assertEquals("urn:sys", va.getIdentifier().get(1).getSystem());
assertEquals("id2", va.getIdentifier().get(1).getValue());
assertEquals(100, va.getExt().getValue().intValue());
assertEquals(200, va.getModExt().getValue().intValue());
assertEquals(0, va.getExtension().size());
}
}

View File

@ -22,7 +22,7 @@ import ca.uhn.fhir.rest.api.SortSpec;
public class ${className}ResourceProvider extends
## We have specialized base classes for RPs that handle certain resource types. These
## RPs implement type specific operations
#if ( $version != 'dstu' && (${className} == 'Encounter' || ${className} == 'Patient' || ${className} == 'ValueSet' || ${className} == 'QuestionnaireAnswers' || ${className} == 'CodeSystem' || ($version != 'dstu2' && ${className} == 'ConceptMap') || ${className} == 'MessageHeader'))
#if ( $version != 'dstu' && (${className} == 'Encounter' || ${className} == 'Patient' || ${className} == 'ValueSet' || ${className} == 'QuestionnaireAnswers' || ${className} == 'CodeSystem' || ($version != 'dstu2' && ${className} == 'ConceptMap') || ${className} == 'MessageHeader' || ${className} == 'Composition'))
BaseJpaResourceProvider${className}${versionCapitalized}
#else
JpaResourceProvider${versionCapitalized}<${className}>

View File

@ -48,7 +48,7 @@
class="ca.uhn.fhir.jpa.dao.FhirResourceDao${res.name}${versionCapitalized}">
#elseif ( ${versionCapitalized} == 'R4' && ${res.name} == 'ConceptMap')
class="ca.uhn.fhir.jpa.dao.FhirResourceDao${res.name}${versionCapitalized}">
#elseif ( ${versionCapitalized} != 'Dstu1' && ( ${res.name} == 'Bundle' || ${res.name} == 'Encounter' || ${res.name} == 'Everything' || ${res.name} == 'Patient' || ${res.name} == 'Subscription' || ${res.name} == 'ValueSet' || ${res.name} == 'QuestionnaireResponse' || ${res.name} == 'SearchParameter'))
#elseif ( ${versionCapitalized} != 'Dstu1' && ( ${res.name} == 'Bundle' || ${res.name} == 'Encounter' || ${res.name} == 'Composition' || ${res.name} == 'Everything' || ${res.name} == 'Patient' || ${res.name} == 'Subscription' || ${res.name} == 'ValueSet' || ${res.name} == 'QuestionnaireResponse' || ${res.name} == 'SearchParameter'))
class="ca.uhn.fhir.jpa.dao.FhirResourceDao${res.name}${versionCapitalized}">
#else
class="ca.uhn.fhir.jpa.dao.FhirResourceDao${versionCapitalized}">

View File

@ -73,7 +73,7 @@ public abstract class BaseJavaConfig${versionCapitalized} extends ca.uhn.fhir.jp
IFhirResourceDaoConceptMap<org.hl7.fhir.dstu3.model.ConceptMap>
#elseif ( ${versionCapitalized} == 'R4' && ${res.name} == 'ConceptMap' )
IFhirResourceDaoConceptMap<org.hl7.fhir.r4.model.ConceptMap>
#elseif ( ${versionCapitalized} != 'Dstu1' && ( ${res.name} == 'Encounter' || ${res.name} == 'Everything' || ${res.name} == 'Patient' || ${res.name} == 'Subscription' || ${res.name} == 'SearchParameter' || ${res.name} == 'MessageHeader'))
#elseif ( ${versionCapitalized} != 'Dstu1' && (${res.name} == 'Composition' || ${res.name} == 'Encounter' || ${res.name} == 'Everything' || ${res.name} == 'Patient' || ${res.name} == 'Subscription' || ${res.name} == 'SearchParameter' || ${res.name} == 'MessageHeader'))
IFhirResourceDao${res.name}<${resourcePackage}.${res.declaringClassNameComplete}>
#else
IFhirResourceDao<${resourcePackage}.${res.declaringClassNameComplete}>
@ -83,7 +83,7 @@ public abstract class BaseJavaConfig${versionCapitalized} extends ca.uhn.fhir.jp
ca.uhn.fhir.jpa.dao${package_suffix}.FhirResourceDao${res.name}${versionCapitalized} retVal = new ca.uhn.fhir.jpa.dao${package_suffix}.FhirResourceDao${res.name}${versionCapitalized}();
#elseif ( ${versionCapitalized} == 'R4' && ${res.name} == 'ConceptMap' )
ca.uhn.fhir.jpa.dao${package_suffix}.FhirResourceDao${res.name}${versionCapitalized} retVal = new ca.uhn.fhir.jpa.dao${package_suffix}.FhirResourceDao${res.name}${versionCapitalized}();
#elseif ( ${res.name} == 'Bundle' || ${res.name} == 'Encounter' || ${res.name} == 'Everything' || ${res.name} == 'Patient' || ${res.name} == 'Subscription' || ${res.name} == 'ValueSet' || ${res.name} == 'QuestionnaireResponse' || ${res.name} == 'SearchParameter' || ${res.name} == 'CodeSystem' || ${res.name} == 'MessageHeader')
#elseif ( ${res.name} == 'Bundle' || ${res.name} == 'Encounter' || ${res.name} == 'Everything' || ${res.name} == 'Patient' || ${res.name} == 'Subscription' || ${res.name} == 'ValueSet' || ${res.name} == 'QuestionnaireResponse' || ${res.name} == 'SearchParameter' || ${res.name} == 'CodeSystem' || ${res.name} == 'MessageHeader' || ${res.name} == 'Composition')
ca.uhn.fhir.jpa.dao${package_suffix}.FhirResourceDao${res.name}${versionCapitalized} retVal = new ca.uhn.fhir.jpa.dao${package_suffix}.FhirResourceDao${res.name}${versionCapitalized}();
#else
ca.uhn.fhir.jpa.dao${package_suffix}.FhirResourceDao${versionCapitalized}<${resourcePackage}.${res.declaringClassNameComplete}> retVal = new ca.uhn.fhir.jpa.dao${package_suffix}.FhirResourceDao${versionCapitalized}<${resourcePackage}.${res.declaringClassNameComplete}>();

View File

@ -274,6 +274,10 @@
The Prefer header is now honoured for HTTP PATCH requests. Thanks to
Alin Leonard for the Pull Request!
</action>
<action type="add">
The <![CDATA[<code>Composition</code>]]> operation <![CDATA[<code>$document</code>]]> has been
implemented. Thanks to Patrick Werner for the Pull Request!
</action>
</release>
<release version="3.4.0" date="2018-05-28">
<action type="add">