diff --git a/hapi-deployable-pom/pom.xml b/hapi-deployable-pom/pom.xml index e441d7d527b..d1d00a4500f 100644 --- a/hapi-deployable-pom/pom.xml +++ b/hapi-deployable-pom/pom.xml @@ -5,8 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-android/pom.xml b/hapi-fhir-android/pom.xml index a1c20ea9219..e06ff02f534 100644 --- a/hapi-fhir-android/pom.xml +++ b/hapi-fhir-android/pom.xml @@ -5,8 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-base/pom.xml b/hapi-fhir-base/pom.xml index 527d33045cd..761d70e5e55 100644 --- a/hapi-fhir-base/pom.xml +++ b/hapi-fhir-base/pom.xml @@ -5,8 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/MethodOutcome.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/MethodOutcome.java index bff7a15e112..5e50cee3d1c 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/MethodOutcome.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/MethodOutcome.java @@ -254,7 +254,7 @@ public class MethodOutcome { return myResource != null; } - public void setStatusCode(int theResponseStatusCode) { + public void setResponseStatusCode(int theResponseStatusCode) { myResponseStatusCode = theResponseStatusCode; } diff --git a/hapi-fhir-bom/pom.xml b/hapi-fhir-bom/pom.xml index c284916d5eb..2d8663a278e 100644 --- a/hapi-fhir-bom/pom.xml +++ b/hapi-fhir-bom/pom.xml @@ -4,16 +4,14 @@ 4.0.0 ca.uhn.hapi.fhir hapi-fhir-bom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT pom HAPI FHIR BOM ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-checkstyle/pom.xml b/hapi-fhir-checkstyle/pom.xml index 5dfd29dbf5b..8495ff5cda1 100644 --- a/hapi-fhir-checkstyle/pom.xml +++ b/hapi-fhir-checkstyle/pom.xml @@ -5,8 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/pom.xml b/hapi-fhir-cli/hapi-fhir-cli-api/pom.xml index 7d28ec0892e..19e6204f078 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/pom.xml +++ b/hapi-fhir-cli/hapi-fhir-cli-api/pom.xml @@ -4,8 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-cli/hapi-fhir-cli-app/pom.xml b/hapi-fhir-cli/hapi-fhir-cli-app/pom.xml index fdbd8852b6e..071914a1900 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-app/pom.xml +++ b/hapi-fhir-cli/hapi-fhir-cli-app/pom.xml @@ -6,8 +6,7 @@ ca.uhn.hapi.fhir hapi-fhir-cli - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/pom.xml b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/pom.xml index 7b91c6a1835..0e59c1de1f6 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/pom.xml +++ b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/pom.xml @@ -6,8 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../../hapi-deployable-pom diff --git a/hapi-fhir-cli/pom.xml b/hapi-fhir-cli/pom.xml index e575e9f19f1..f6fc6aa49d9 100644 --- a/hapi-fhir-cli/pom.xml +++ b/hapi-fhir-cli/pom.xml @@ -5,8 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-client-okhttp/pom.xml b/hapi-fhir-client-okhttp/pom.xml index 8cce88f6f38..937ace806e2 100644 --- a/hapi-fhir-client-okhttp/pom.xml +++ b/hapi-fhir-client-okhttp/pom.xml @@ -4,8 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-client/pom.xml b/hapi-fhir-client/pom.xml index 353b3e5f911..b2967811ce7 100644 --- a/hapi-fhir-client/pom.xml +++ b/hapi-fhir-client/pom.xml @@ -4,8 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/impl/GenericClient.java b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/impl/GenericClient.java index 0d57d24dcb2..afa9ed1e697 100644 --- a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/impl/GenericClient.java +++ b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/impl/GenericClient.java @@ -28,7 +28,6 @@ import ca.uhn.fhir.context.IRuntimeDatatypeDefinition; import ca.uhn.fhir.context.RuntimeResourceDefinition; import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.model.api.IQueryParameterType; -import ca.uhn.fhir.model.api.IResource; import ca.uhn.fhir.model.api.Include; import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum; import ca.uhn.fhir.model.base.resource.BaseOperationOutcome; @@ -135,7 +134,6 @@ import com.google.common.base.Charsets; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.Validate; -import org.hl7.fhir.instance.model.api.IAnyResource; import org.hl7.fhir.instance.model.api.IBase; import org.hl7.fhir.instance.model.api.IBaseBundle; import org.hl7.fhir.instance.model.api.IBaseConformance; @@ -1511,9 +1509,13 @@ public class GenericClient extends BaseClient implements IGenericClient { IBaseResource response = myWrap.invokeClient(theResponseMimeType, theResponseInputStream, theResponseStatusCode, theHeaders); MethodOutcome retVal = new MethodOutcome(); - retVal.setResource(response); + if (response instanceof IBaseOperationOutcome) { + retVal.setOperationOutcome((IBaseOperationOutcome) response); + } else { + retVal.setResource(response); + } retVal.setCreatedUsingStatusCode(theResponseStatusCode); - retVal.setStatusCode(theResponseStatusCode); + retVal.setResponseStatusCode(theResponseStatusCode); retVal.setResponseHeaders(theHeaders); return retVal; } @@ -2349,10 +2351,8 @@ public class GenericClient extends BaseClient implements IGenericClient { public MethodOutcome execute() { BaseHttpClientInvocation invocation = ValidateMethodBindingDstu2Plus.createValidateInvocation(myContext, myResource); ResourceResponseHandler handler = new ResourceResponseHandler<>(null, null); - IBaseOperationOutcome outcome = invoke(null, handler, invocation); - MethodOutcome retVal = new MethodOutcome(); - retVal.setOperationOutcome(outcome); - return retVal; + MethodOutcomeResponseHandler methodHandler = new MethodOutcomeResponseHandler(handler); + return invoke(null, methodHandler, invocation); } @Override diff --git a/hapi-fhir-converter/pom.xml b/hapi-fhir-converter/pom.xml index d104e6e1d83..773473901e6 100644 --- a/hapi-fhir-converter/pom.xml +++ b/hapi-fhir-converter/pom.xml @@ -5,8 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-dist/pom.xml b/hapi-fhir-dist/pom.xml index f5bff28ee82..1cbf54aaa90 100644 --- a/hapi-fhir-dist/pom.xml +++ b/hapi-fhir-dist/pom.xml @@ -5,8 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-docs/pom.xml b/hapi-fhir-docs/pom.xml index 0f9fb71b21f..0400d094840 100644 --- a/hapi-fhir-docs/pom.xml +++ b/hapi-fhir-docs/pom.xml @@ -5,8 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_6_0/4662-fhirclient-validate.yaml b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_6_0/4662-fhirclient-validate.yaml new file mode 100644 index 00000000000..7501a9f4481 --- /dev/null +++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_6_0/4662-fhirclient-validate.yaml @@ -0,0 +1,6 @@ +--- +type: change +issue: 4662 +title: "The Resource $validate operation no longer returns Precondition Failed 412 when a resource fails validation. +It now returns 200 irrespective of the validation outcome as required by the + [FHIR Spec for the Resource $validate operation](https://www.hl7.org/fhir/R4/resource-operation-validate.html)." diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_6_0/upgrade.md b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_6_0/upgrade.md index 7bb5a0704cb..f503c3be2c7 100644 --- a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_6_0/upgrade.md +++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_6_0/upgrade.md @@ -1,7 +1,8 @@ -This release changes database indexing for string and uri SearchParameters. -The database migration may take several minutes. -These changes will be applied automatically on first startup. -To avoid this delay on first startup, run the migration manually. + +This release has breaking changes. +* The Resource $validate operation no longer returns Precondition Failed 412 when a resource fails validation. It now returns 200 irrespective of the validation outcome as required by the [FHIR Specification for the Resource $validate operation](https://www.hl7.org/fhir/R4/resource-operation-validate.html). + +* This release changes database indexing for string and uri SearchParameters. The database migration may take several minutes. These changes will be applied automatically on first startup. To avoid this delay on first startup, run the migration manually. Bulk export behaviour is changing in this release such that Binary resources created as part of the response will now be created in the partition that the bulk export was requested rather than in the DEFAULT partition as was being done previously. diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/docs/server_plain/rest_operations.md b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/docs/server_plain/rest_operations.md index f8708013cec..072b2d2ffab 100644 --- a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/docs/server_plain/rest_operations.md +++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/docs/server_plain/rest_operations.md @@ -285,7 +285,7 @@ Validate methods must be annotated with the [@Validate](/hapi-fhir/apidocs/hapi- Validate methods may optionally also have a parameter of type IdType annotated with the [@IdParam](/hapi-fhir/apidocs/hapi-fhir-base/ca/uhn/fhir/rest/annotation/IdParam.html) annotation. This parameter contains the resource ID (see the [FHIR specification](http://hl7.org/implement/standards/fhir/http.html#validation) for details on how this is used). -Validate methods must return normally if the resource validates successfully, or throw an [UnprocessableEntityException](/hapi-fhir/apidocs/hapi-fhir-base/ca/uhn/fhir/rest/server/exceptions/UnprocessableEntityException.html) or [InvalidRequestException](/hapi-fhir/apidocs/hapi-fhir-base/ca/uhn/fhir/rest/server/exceptions/InvalidRequestException.html) if the validation fails. +Validate methods must return normally independent of the validation outcome. The ResponseStatusCode of the MethodOutcome returned should be 200 irrespective of the validation outcome as required by the [FHIR Specification for the Resource $validate operation](https://www.hl7.org/fhir/R4/resource-operation-validate.html). Validate methods must return either: diff --git a/hapi-fhir-jacoco/pom.xml b/hapi-fhir-jacoco/pom.xml index 817e3ba5360..d096e22d4ae 100644 --- a/hapi-fhir-jacoco/pom.xml +++ b/hapi-fhir-jacoco/pom.xml @@ -11,8 +11,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jaxrsserver-base/pom.xml b/hapi-fhir-jaxrsserver-base/pom.xml index 33a2db27f7d..101eb749be4 100644 --- a/hapi-fhir-jaxrsserver-base/pom.xml +++ b/hapi-fhir-jaxrsserver-base/pom.xml @@ -4,8 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpa/pom.xml b/hapi-fhir-jpa/pom.xml index cca0c44b1ce..e63d5004337 100644 --- a/hapi-fhir-jpa/pom.xml +++ b/hapi-fhir-jpa/pom.xml @@ -5,8 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml 4.0.0 diff --git a/hapi-fhir-jpaserver-base/pom.xml b/hapi-fhir-jpaserver-base/pom.xml index 919495a0656..6b41787078e 100644 --- a/hapi-fhir-jpaserver-base/pom.xml +++ b/hapi-fhir-jpaserver-base/pom.xml @@ -5,8 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/bulk/export/svc/JpaBulkExportProcessor.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/bulk/export/svc/JpaBulkExportProcessor.java index 21f457fe3af..05831a14a9a 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/bulk/export/svc/JpaBulkExportProcessor.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/bulk/export/svc/JpaBulkExportProcessor.java @@ -38,7 +38,6 @@ import ca.uhn.fhir.jpa.dao.SearchBuilderFactory; import ca.uhn.fhir.jpa.dao.mdm.MdmExpansionCacheSvc; import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.model.search.SearchRuntimeDetails; -import ca.uhn.fhir.rest.api.server.SystemRequestDetails; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.jpa.util.QueryChunker; import ca.uhn.fhir.mdm.api.MdmMatchResultEnum; @@ -46,6 +45,7 @@ import ca.uhn.fhir.mdm.dao.IMdmLinkDao; import ca.uhn.fhir.mdm.model.MdmPidTuple; import ca.uhn.fhir.model.api.Include; import ca.uhn.fhir.model.primitive.IdDt; +import ca.uhn.fhir.rest.api.server.SystemRequestDetails; import ca.uhn.fhir.rest.api.server.bulk.BulkDataExportOptions; import ca.uhn.fhir.rest.param.HasOrListParam; import ca.uhn.fhir.rest.param.HasParam; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/HibernatePropertiesProvider.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/HibernatePropertiesProvider.java index 1ca901a5752..6fb23eb4a37 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/HibernatePropertiesProvider.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/HibernatePropertiesProvider.java @@ -20,7 +20,6 @@ package ca.uhn.fhir.jpa.config; import ca.uhn.fhir.jpa.api.config.JpaStorageSettings; -import ca.uhn.fhir.rest.api.Constants; import ca.uhn.fhir.util.ReflectionUtil; import com.google.common.annotations.VisibleForTesting; import org.apache.commons.lang3.StringUtils; @@ -31,7 +30,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; import javax.sql.DataSource; -import java.util.Map; public class HibernatePropertiesProvider { diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java index b81328ae895..d6ec8442e99 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java @@ -1899,14 +1899,11 @@ public abstract class BaseHapiFhirResourceDao extends B result = validator.validateWithResult(theResource, options); } - if (result.isSuccessful()) { - MethodOutcome retVal = new MethodOutcome(); - retVal.setOperationOutcome(result.toOperationOutcome()); - return retVal; - } else { - throw new PreconditionFailedException(Msg.code(993) + "Validation failed", result.toOperationOutcome()); - } - + MethodOutcome retVal = new MethodOutcome(); + retVal.setOperationOutcome(result.toOperationOutcome()); + // Note an earlier version of this code returned PreconditionFailedException when the validation + // failed, but we since realized the spec requires we return 200 regardless of the validation result. + return retVal; } /** diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/TransactionProcessor.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/TransactionProcessor.java index ec5d1bf76e8..f31627c4d61 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/TransactionProcessor.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/TransactionProcessor.java @@ -22,7 +22,6 @@ package ca.uhn.fhir.jpa.dao; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.RuntimeResourceDefinition; import ca.uhn.fhir.interceptor.model.RequestPartitionId; -import ca.uhn.fhir.jpa.api.IDaoRegistry; import ca.uhn.fhir.jpa.api.config.JpaStorageSettings; import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao; import ca.uhn.fhir.jpa.api.model.DaoMethodOutcome; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/IResourceIndexedSearchParamUriDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/IResourceIndexedSearchParamUriDao.java index 419a4618744..ba2e0b7cc09 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/IResourceIndexedSearchParamUriDao.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/IResourceIndexedSearchParamUriDao.java @@ -19,14 +19,13 @@ */ package ca.uhn.fhir.jpa.dao.data; -import java.util.Collection; - +import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamUri; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamUri; +import java.util.Collection; public interface IResourceIndexedSearchParamUriDao extends JpaRepository, IHapiFhirJpaRepository { diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/packages/PackageInstallerSvcImpl.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/packages/PackageInstallerSvcImpl.java index 3b61808ff90..5d30c22a073 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/packages/PackageInstallerSvcImpl.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/packages/PackageInstallerSvcImpl.java @@ -34,16 +34,15 @@ import ca.uhn.fhir.jpa.api.model.DaoMethodOutcome; import ca.uhn.fhir.jpa.dao.data.INpmPackageVersionDao; import ca.uhn.fhir.jpa.model.config.PartitionSettings; import ca.uhn.fhir.jpa.model.entity.NpmPackageVersionEntity; -import ca.uhn.fhir.rest.api.server.SystemRequestDetails; import ca.uhn.fhir.jpa.packages.loader.PackageResourceParsingSvc; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.jpa.searchparam.registry.ISearchParamRegistryController; import ca.uhn.fhir.jpa.searchparam.util.SearchParameterHelper; import ca.uhn.fhir.rest.api.server.IBundleProvider; +import ca.uhn.fhir.rest.api.server.SystemRequestDetails; import ca.uhn.fhir.rest.param.StringParam; import ca.uhn.fhir.rest.param.TokenParam; import ca.uhn.fhir.rest.param.UriParam; -import ca.uhn.fhir.rest.server.util.ISearchParamRegistry; import ca.uhn.fhir.util.FhirTerser; import ca.uhn.fhir.util.SearchParameterUtil; import com.google.common.annotations.VisibleForTesting; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/predicate/UriPredicateBuilder.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/predicate/UriPredicateBuilder.java index 8bb64563835..6610234b503 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/predicate/UriPredicateBuilder.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/predicate/UriPredicateBuilder.java @@ -28,14 +28,14 @@ import ca.uhn.fhir.jpa.dao.predicate.SearchFilterParser; import ca.uhn.fhir.jpa.model.entity.BaseResourceIndexedSearchParam; import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamUri; import ca.uhn.fhir.jpa.model.search.StorageProcessingMessage; -import ca.uhn.fhir.jpa.util.QueryParameterUtils; import ca.uhn.fhir.jpa.search.builder.sql.SearchQueryBuilder; -import ca.uhn.fhir.rest.server.util.CompositeInterceptorBroadcaster; +import ca.uhn.fhir.jpa.util.QueryParameterUtils; import ca.uhn.fhir.model.api.IQueryParameterType; import ca.uhn.fhir.rest.api.server.RequestDetails; import ca.uhn.fhir.rest.param.UriParam; import ca.uhn.fhir.rest.param.UriParamQualifierEnum; import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; +import ca.uhn.fhir.rest.server.util.CompositeInterceptorBroadcaster; import com.healthmarketscience.sqlbuilder.BinaryCondition; import com.healthmarketscience.sqlbuilder.ComboCondition; import com.healthmarketscience.sqlbuilder.Condition; @@ -48,7 +48,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -import static ca.uhn.fhir.jpa.util.QueryParameterUtils.toEqualToOrInPredicate; import static ca.uhn.fhir.jpa.search.builder.predicate.StringPredicateBuilder.createLeftAndRightMatchLikeExpression; import static ca.uhn.fhir.jpa.search.builder.predicate.StringPredicateBuilder.createLeftMatchLikeExpression; import static ca.uhn.fhir.jpa.search.builder.predicate.StringPredicateBuilder.createRightMatchLikeExpression; diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/bulk/export/svc/JpaBulkExportProcessorTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/bulk/export/svc/JpaBulkExportProcessorTest.java index 7569fd8a5f6..99d8fba6036 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/bulk/export/svc/JpaBulkExportProcessorTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/bulk/export/svc/JpaBulkExportProcessorTest.java @@ -15,12 +15,12 @@ import ca.uhn.fhir.jpa.dao.SearchBuilderFactory; import ca.uhn.fhir.jpa.dao.mdm.MdmExpansionCacheSvc; import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.model.search.SearchRuntimeDetails; -import ca.uhn.fhir.rest.api.server.SystemRequestDetails; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.mdm.api.MdmMatchResultEnum; import ca.uhn.fhir.mdm.dao.IMdmLinkDao; import ca.uhn.fhir.mdm.model.MdmPidTuple; import ca.uhn.fhir.model.primitive.IdDt; +import ca.uhn.fhir.rest.api.server.SystemRequestDetails; import ca.uhn.fhir.rest.api.server.bulk.BulkDataExportOptions; import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.r4.model.Group; diff --git a/hapi-fhir-jpaserver-elastic-test-utilities/pom.xml b/hapi-fhir-jpaserver-elastic-test-utilities/pom.xml index 9366244137b..a1c1c437e1f 100644 --- a/hapi-fhir-jpaserver-elastic-test-utilities/pom.xml +++ b/hapi-fhir-jpaserver-elastic-test-utilities/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-ips/pom.xml b/hapi-fhir-jpaserver-ips/pom.xml index d2b73607d76..9c48b491964 100644 --- a/hapi-fhir-jpaserver-ips/pom.xml +++ b/hapi-fhir-jpaserver-ips/pom.xml @@ -3,8 +3,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-mdm/pom.xml b/hapi-fhir-jpaserver-mdm/pom.xml index e8ea1cf50bf..c2a6689b63e 100644 --- a/hapi-fhir-jpaserver-mdm/pom.xml +++ b/hapi-fhir-jpaserver-mdm/pom.xml @@ -6,8 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/dao/MdmLinkDaoSvcTest.java b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/dao/MdmLinkDaoSvcTest.java index 27c9e8835c6..6f0bb32afa3 100644 --- a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/dao/MdmLinkDaoSvcTest.java +++ b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/dao/MdmLinkDaoSvcTest.java @@ -4,8 +4,8 @@ import ca.uhn.fhir.interceptor.model.RequestPartitionId; import ca.uhn.fhir.jpa.entity.MdmLink; import ca.uhn.fhir.jpa.mdm.BaseMdmR4Test; import ca.uhn.fhir.jpa.model.dao.JpaPid; -import ca.uhn.fhir.jpa.util.TestUtil; import ca.uhn.fhir.jpa.model.entity.EnversRevision; +import ca.uhn.fhir.jpa.util.TestUtil; import ca.uhn.fhir.mdm.api.IMdmLink; import ca.uhn.fhir.mdm.api.MdmHistorySearchParameters; import ca.uhn.fhir.mdm.api.MdmLinkSourceEnum; diff --git a/hapi-fhir-jpaserver-model/pom.xml b/hapi-fhir-jpaserver-model/pom.xml index 5f4d44eb132..750fee29f61 100644 --- a/hapi-fhir-jpaserver-model/pom.xml +++ b/hapi-fhir-jpaserver-model/pom.xml @@ -5,8 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ResourceTable.java b/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ResourceTable.java index cc7a33b61f9..7cfbdf6604a 100644 --- a/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ResourceTable.java +++ b/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ResourceTable.java @@ -21,20 +21,18 @@ package ca.uhn.fhir.jpa.model.entity; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.jpa.model.cross.IBasePersistedResource; -import ca.uhn.fhir.jpa.model.cross.IResourceLookup; import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.model.search.ExtendedHSearchIndexData; import ca.uhn.fhir.jpa.model.search.ResourceTableRoutingBinder; import ca.uhn.fhir.jpa.model.search.SearchParamTextPropertyBinder; import ca.uhn.fhir.model.primitive.IdDt; import ca.uhn.fhir.rest.api.Constants; -import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; -import org.hibernate.annotations.GenericGenerator; import org.hibernate.Session; import org.hibernate.annotations.GenerationTime; import org.hibernate.annotations.GeneratorType; +import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.OptimisticLock; import org.hibernate.search.engine.backend.types.Projectable; import org.hibernate.search.engine.backend.types.Searchable; @@ -63,7 +61,6 @@ import javax.persistence.OneToMany; import javax.persistence.OneToOne; import javax.persistence.PrePersist; import javax.persistence.PreUpdate; -import org.hibernate.annotations.GenericGenerator; import javax.persistence.Table; import javax.persistence.Transient; import javax.persistence.Version; diff --git a/hapi-fhir-jpaserver-searchparam/pom.xml b/hapi-fhir-jpaserver-searchparam/pom.xml index c4a9573c00b..8e946c05556 100755 --- a/hapi-fhir-jpaserver-searchparam/pom.xml +++ b/hapi-fhir-jpaserver-searchparam/pom.xml @@ -5,8 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-subscription/pom.xml b/hapi-fhir-jpaserver-subscription/pom.xml index 44f9f99114e..498dca07b61 100644 --- a/hapi-fhir-jpaserver-subscription/pom.xml +++ b/hapi-fhir-jpaserver-subscription/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-test-dstu2/pom.xml b/hapi-fhir-jpaserver-test-dstu2/pom.xml index a17747196fb..1c75570d80e 100644 --- a/hapi-fhir-jpaserver-test-dstu2/pom.xml +++ b/hapi-fhir-jpaserver-test-dstu2/pom.xml @@ -6,8 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/BaseJpaDstu2Test.java b/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/BaseJpaDstu2Test.java index 02ea5e33380..15aa0f38c91 100644 --- a/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/BaseJpaDstu2Test.java +++ b/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/BaseJpaDstu2Test.java @@ -43,6 +43,7 @@ import ca.uhn.fhir.model.dstu2.resource.Medication; import ca.uhn.fhir.model.dstu2.resource.MedicationAdministration; import ca.uhn.fhir.model.dstu2.resource.MedicationOrder; import ca.uhn.fhir.model.dstu2.resource.Observation; +import ca.uhn.fhir.model.dstu2.resource.OperationOutcome; import ca.uhn.fhir.model.dstu2.resource.Organization; import ca.uhn.fhir.model.dstu2.resource.Patient; import ca.uhn.fhir.model.dstu2.resource.Practitioner; @@ -75,6 +76,9 @@ import javax.persistence.EntityManager; import java.util.ArrayList; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + @ExtendWith(SpringExtension.class) @ContextConfiguration(classes = {TestDstu2Config.class}) public abstract class BaseJpaDstu2Test extends BaseJpaTest { @@ -265,4 +269,16 @@ public abstract class BaseJpaDstu2Test extends BaseJpaTest { } return retVal; } + + public void assertHasErrors(OperationOutcome theOperationOutcome) { + assertTrue(hasValidationErrors(theOperationOutcome), "Expected validation errors, found none"); + } + + public void assertHasNoErrors(OperationOutcome theOperationOutcome) { + assertFalse(hasValidationErrors(theOperationOutcome), "Expected no validation errors, found some"); + } + + private static boolean hasValidationErrors(OperationOutcome theOperationOutcome) { + return theOperationOutcome.getIssue().stream().anyMatch(t -> "error".equals(t.getSeverity())); + } } diff --git a/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2Test.java b/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2Test.java index 1493e170075..3ba85f3b44a 100644 --- a/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2Test.java +++ b/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2Test.java @@ -32,6 +32,7 @@ import ca.uhn.fhir.model.dstu2.resource.Device; import ca.uhn.fhir.model.dstu2.resource.DiagnosticReport; import ca.uhn.fhir.model.dstu2.resource.Encounter; import ca.uhn.fhir.model.dstu2.resource.Observation; +import ca.uhn.fhir.model.dstu2.resource.OperationOutcome; import ca.uhn.fhir.model.dstu2.resource.Organization; import ca.uhn.fhir.model.dstu2.resource.Patient; import ca.uhn.fhir.model.dstu2.resource.Questionnaire; @@ -67,7 +68,6 @@ import ca.uhn.fhir.rest.param.StringParam; import ca.uhn.fhir.rest.param.TokenOrListParam; import ca.uhn.fhir.rest.param.TokenParam; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; -import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException; import ca.uhn.fhir.rest.server.exceptions.ResourceGoneException; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import ca.uhn.fhir.rest.server.exceptions.ResourceVersionConflictException; @@ -2837,12 +2837,10 @@ public class FhirResourceDaoDstu2Test extends BaseJpaDstu2Test { String rawResource = loadResource("/binu_testpatient_resource.json"); IBaseResource parsedResource = myFhirContext.newJsonParser().parseResource(rawResource); - try { - myPatientDao.validate((Patient) parsedResource, null, rawResource, EncodingEnum.JSON, ValidationModeEnum.UPDATE, null, mySrd); - fail(); - } catch (PreconditionFailedException e) { - ourLog.debug(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); - } + MethodOutcome result = myPatientDao.validate((Patient) parsedResource, null, rawResource, EncodingEnum.JSON, ValidationModeEnum.UPDATE, null, mySrd); + OperationOutcome oo = (OperationOutcome) result.getOperationOutcome(); + assertHasErrors(oo); + ourLog.debug(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(oo)); } } diff --git a/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2ValidateTest.java b/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2ValidateTest.java index 305b3a8af9d..755b492e898 100644 --- a/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2ValidateTest.java +++ b/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2ValidateTest.java @@ -14,6 +14,7 @@ import ca.uhn.fhir.model.dstu2.resource.ValueSet; import ca.uhn.fhir.model.dstu2.valueset.ObservationStatusEnum; import ca.uhn.fhir.model.primitive.IdDt; import ca.uhn.fhir.rest.api.EncodingEnum; +import ca.uhn.fhir.rest.api.MethodOutcome; import ca.uhn.fhir.rest.api.ValidationModeEnum; import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException; import ca.uhn.fhir.rest.server.exceptions.ResourceVersionConflictException; @@ -98,25 +99,19 @@ public class FhirResourceDaoDstu2ValidateTest extends BaseJpaDstu2Test { String encoded; ValidationModeEnum mode = ValidationModeEnum.CREATE; switch (enc) { - case JSON: - encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(input); - ourLog.info(encoded); - try { - myObservationDao.validate(input, null, encoded, EncodingEnum.JSON, mode, null, mySrd); - fail(); - } catch (PreconditionFailedException e) { - return (OperationOutcome) e.getOperationOutcome(); - } - break; - case XML: - encoded = myFhirContext.newXmlParser().encodeResourceToString(input); - try { - myObservationDao.validate(input, null, encoded, EncodingEnum.XML, mode, null, mySrd); - fail(); - } catch (PreconditionFailedException e) { - return (OperationOutcome) e.getOperationOutcome(); - } - break; + case JSON: + encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(input); + ourLog.info(encoded); + MethodOutcome result = myObservationDao.validate(input, null, encoded, EncodingEnum.JSON, mode, null, mySrd); + OperationOutcome oo = (OperationOutcome) result.getOperationOutcome(); + assertHasErrors(oo); + return oo; + case XML: + encoded = myFhirContext.newXmlParser().encodeResourceToString(input); + result = myObservationDao.validate(input, null, encoded, EncodingEnum.XML, mode, null, mySrd); + oo = (OperationOutcome) result.getOperationOutcome(); + assertHasErrors(oo); + return oo; } throw new IllegalStateException(); // shouldn't get here @@ -138,15 +133,12 @@ public class FhirResourceDaoDstu2ValidateTest extends BaseJpaDstu2Test { ValidationModeEnum mode = ValidationModeEnum.CREATE; String encoded = myFhirContext.newJsonParser().encodeResourceToString(input); ourLog.info(encoded); - try { - myObservationDao.validate(input, null, encoded, EncodingEnum.JSON, mode, null, mySrd); - fail(); - } catch (PreconditionFailedException e) { - String ooString = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome()); - ourLog.info(ooString); - assertThat(ooString, containsString("Profile reference 'http://example.com/StructureDefinition/testValidateResourceContainingProfileDeclarationInvalid' has not been checked because it is unknown")); - } - + MethodOutcome result = myObservationDao.validate(input, null, encoded, EncodingEnum.JSON, mode, null, mySrd); + OperationOutcome oo = (OperationOutcome) result.getOperationOutcome(); + assertHasErrors(oo); + String ooString = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo); + ourLog.info(ooString); + assertThat(ooString, containsString("Profile reference 'http://example.com/StructureDefinition/testValidateResourceContainingProfileDeclarationInvalid' has not been checked because it is unknown")); } @Test diff --git a/hapi-fhir-jpaserver-test-dstu3/pom.xml b/hapi-fhir-jpaserver-test-dstu3/pom.xml index 3736e0c4db6..6a819d4a95b 100644 --- a/hapi-fhir-jpaserver-test-dstu3/pom.xml +++ b/hapi-fhir-jpaserver-test-dstu3/pom.xml @@ -6,8 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchNoFtTest.java b/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchNoFtTest.java index 48e3d1403bc..7c2d95ac116 100644 --- a/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchNoFtTest.java +++ b/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchNoFtTest.java @@ -115,7 +115,7 @@ import java.util.List; import java.util.Set; import java.util.TreeSet; -import static ca.uhn.fhir.test.utilities.CustomMatchersUtil.*; +import static ca.uhn.fhir.test.utilities.CustomMatchersUtil.assertDoesNotContainAnyOf; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.containsInAnyOrder; diff --git a/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3ValidateTest.java b/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3ValidateTest.java index f93c00f6640..5b65f42d148 100644 --- a/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3ValidateTest.java +++ b/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3ValidateTest.java @@ -103,14 +103,11 @@ public class FhirResourceDaoDstu3ValidateTest extends BaseJpaDstu3Test { myFhirInstanceValidator.invalidateCaches(); ProxyUtil.getSingletonTarget(myPersistedResourceValidationSupport, JpaPersistedResourceValidationSupport.class).clearCaches(); - try { - myQuestionnaireResponseDao.validate(qr, null, null, null, null, null, null); - fail(); - } catch (PreconditionFailedException e) { - ourLog.debug(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); - // good - } - + MethodOutcome result = myQuestionnaireResponseDao.validate(qr, null, null, null, null, null, null); + OperationOutcome oo = (OperationOutcome) result.getOperationOutcome(); + assertHasErrors(oo); + ourLog.debug(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); + // good } @@ -125,7 +122,7 @@ public class FhirResourceDaoDstu3ValidateTest extends BaseJpaDstu3Test { ValueSet expansion = myValueSetDao.expandByIdentifier("http://ccim.on.ca/fhir/iar/ValueSet/iar-citizenship-status", null); ourLog.debug(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(expansion)); - assertThat(expansion.getExpansion().getContains().stream().map(t->t.getCode()).collect(Collectors.toList()), containsInAnyOrder( + assertThat(expansion.getExpansion().getContains().stream().map(t -> t.getCode()).collect(Collectors.toList()), containsInAnyOrder( "CDN", "PR", "TR", "REF", "UNK", "ASKU" )); } @@ -173,32 +170,21 @@ public class FhirResourceDaoDstu3ValidateTest extends BaseJpaDstu3Test { .setValue(new Coding().setSystem("http://hl7.org/fhir/administrative-gender").setCode("aaa").setDisplay("AAAA")); // Validate as resource - try { - MethodOutcome outcome = myQuestionnaireResponseDao.validate(qr, null, null, null, ValidationModeEnum.CREATE, null, mySrd); - OperationOutcome oo = (OperationOutcome) outcome.getOperationOutcome(); - ourLog.debug(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); - fail(); - } catch (PreconditionFailedException e) { - OperationOutcome oo = (OperationOutcome) e.getOperationOutcome(); - String encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo); - ourLog.info(encoded); - assertThat(encoded, containsString("is not in the options value set")); - } + MethodOutcome outcome = myQuestionnaireResponseDao.validate(qr, null, null, null, ValidationModeEnum.CREATE, null, mySrd); + OperationOutcome oo = (OperationOutcome) outcome.getOperationOutcome(); + assertHasErrors(oo); + String encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo); + ourLog.info(encoded); + assertThat(encoded, containsString("is not in the options value set")); // Validate as string - try { - String raw = myFhirContext.newJsonParser().encodeResourceToString(qr); - MethodOutcome outcome = myQuestionnaireResponseDao.validate(qr, null, raw, EncodingEnum.JSON, ValidationModeEnum.CREATE, null, mySrd); - OperationOutcome oo = (OperationOutcome) outcome.getOperationOutcome(); - ourLog.debug(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); - fail(); - } catch (PreconditionFailedException e) { - OperationOutcome oo = (OperationOutcome) e.getOperationOutcome(); - String encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo); - ourLog.info(encoded); - assertThat(encoded, containsString("is not in the options value set")); - } - + String raw = myFhirContext.newJsonParser().encodeResourceToString(qr); + outcome = myQuestionnaireResponseDao.validate(qr, null, raw, EncodingEnum.JSON, ValidationModeEnum.CREATE, null, mySrd); + oo = (OperationOutcome) outcome.getOperationOutcome(); + assertHasErrors(oo); + encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo); + ourLog.info(encoded); + assertThat(encoded, containsString("is not in the options value set")); } @@ -337,17 +323,13 @@ public class FhirResourceDaoDstu3ValidateTest extends BaseJpaDstu3Test { ValidationModeEnum mode = ValidationModeEnum.CREATE; String encoded = myFhirContext.newJsonParser().encodeResourceToString(input); - try { - // Expected to throw exception - MethodOutcome output = myObservationDao.validate(input, null, encoded, EncodingEnum.JSON, mode, null, mySrd); - ourLog.debug(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(output.getOperationOutcome())); - fail(); - } catch (PreconditionFailedException e) { - OperationOutcome oo = (OperationOutcome) e.getOperationOutcome(); - String outputString = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo); - ourLog.info(outputString); - assertThat(outputString, containsString("Profile reference 'http://example.com/StructureDefinition/testValidateResourceContainingProfileDeclarationInvalid' has not been checked because it is unknown")); - } + // Expected to throw exception + MethodOutcome result = myObservationDao.validate(input, null, encoded, EncodingEnum.JSON, mode, null, mySrd); + OperationOutcome oo = (OperationOutcome) result.getOperationOutcome(); + assertHasErrors(oo); + String outputString = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo); + ourLog.info(outputString); + assertThat(outputString, containsString("Profile reference 'http://example.com/StructureDefinition/testValidateResourceContainingProfileDeclarationInvalid' has not been checked because it is unknown")); } @Test diff --git a/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/packages/NpmDstu3Test.java b/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/packages/NpmDstu3Test.java index 0725017e5ea..bee28e90161 100644 --- a/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/packages/NpmDstu3Test.java +++ b/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/packages/NpmDstu3Test.java @@ -2,8 +2,8 @@ package ca.uhn.fhir.jpa.packages; import ca.uhn.fhir.jpa.test.BaseJpaDstu3Test; import ca.uhn.fhir.rest.api.Constants; +import ca.uhn.fhir.rest.api.MethodOutcome; import ca.uhn.fhir.rest.api.ValidationModeEnum; -import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException; import ca.uhn.fhir.test.utilities.JettyUtil; import ca.uhn.fhir.test.utilities.ProxyUtil; import ca.uhn.fhir.util.ClasspathUtil; @@ -33,7 +33,6 @@ import java.util.Map; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.fail; public class NpmDstu3Test extends BaseJpaDstu3Test { @@ -91,22 +90,18 @@ public class NpmDstu3Test extends BaseJpaDstu3Test { CodeSystem cs = (CodeSystem) myNpmJpaValidationSupport.fetchCodeSystem("http://fhir.de/CodeSystem/deuev/anlage-8-laenderkennzeichen"); assertEquals("http://fhir.de/CodeSystem/deuev/anlage-8-laenderkennzeichen", cs.getUrl()); - + // Try and validate using a profile from the IG Condition condition = new Condition(); condition.setClinicalStatus(Condition.ConditionClinicalStatus.RESOLVED); condition.getMeta().addProfile("http://fhir.de/StructureDefinition/condition-de-basis/0.2"); - try { - myConditionDao.validate(condition, null, null, null, ValidationModeEnum.CREATE, null, mySrd); - fail(); - } catch (PreconditionFailedException e) { - ourLog.debug("Fail Outcome: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); + MethodOutcome result = myConditionDao.validate(condition, null, null, null, ValidationModeEnum.CREATE, null, mySrd); + OperationOutcome oo = (OperationOutcome) result.getOperationOutcome(); + assertHasErrors(oo); + ourLog.debug("Fail Outcome: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); - OperationOutcome oo = (OperationOutcome) e.getOperationOutcome(); - assertThat(oo.getIssueFirstRep().getDiagnostics(), - containsString("Condition.subject: minimum required = 1, but only found 0 (from http://fhir.de/StructureDefinition/condition-de-basis/0.2")); - } - + assertThat(oo.getIssueFirstRep().getDiagnostics(), + containsString("Condition.subject: minimum required = 1, but only found 0 (from http://fhir.de/StructureDefinition/condition-de-basis/0.2")); } diff --git a/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3Test.java b/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3Test.java index 09e81fa0351..2c0a4c56378 100644 --- a/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3Test.java +++ b/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3Test.java @@ -4693,7 +4693,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test { try (CloseableHttpResponse response = ourHttpClient.execute(get)) { String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); ourLog.info(resp); - assertEquals(412, response.getStatusLine().getStatusCode()); + assertEquals(200, response.getStatusLine().getStatusCode()); assertThat(resp, containsString("SHALL at least contain a contact's details or a reference to an organization")); } } diff --git a/hapi-fhir-jpaserver-test-r4/pom.xml b/hapi-fhir-jpaserver-test-r4/pom.xml index fd9b3ed19a4..596d7dbb6f2 100644 --- a/hapi-fhir-jpaserver-test-r4/pom.xml +++ b/hapi-fhir-jpaserver-test-r4/pom.xml @@ -6,8 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/TransactionProcessorTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/TransactionProcessorTest.java index aa0be6962d4..6bc21dff961 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/TransactionProcessorTest.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/TransactionProcessorTest.java @@ -3,7 +3,6 @@ package ca.uhn.fhir.jpa.dao; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.interceptor.executor.InterceptorService; -import ca.uhn.fhir.jpa.api.IDaoRegistry; import ca.uhn.fhir.jpa.api.config.JpaStorageSettings; import ca.uhn.fhir.jpa.api.config.ThreadPoolFactoryConfig; import ca.uhn.fhir.jpa.api.dao.DaoRegistry; @@ -27,10 +26,7 @@ import org.hl7.fhir.r4.model.Meta; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.CsvSource; import org.mockito.Answers; -import org.mockito.Spy; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -41,18 +37,13 @@ import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.transaction.TransactionStatus; -import org.springframework.transaction.support.TransactionCallback; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.fail; -import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @ExtendWith(SpringExtension.class) diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/BasePartitioningR4Test.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/BasePartitioningR4Test.java index 0f2e87c1b18..266c77b4d97 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/BasePartitioningR4Test.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/BasePartitioningR4Test.java @@ -14,7 +14,6 @@ import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; import ca.uhn.fhir.util.HapiExtensions; import com.helger.commons.lang.StackTraceHelper; -import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.Validate; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.r4.model.BooleanType; diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ConcurrentWriteTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ConcurrentWriteTest.java index 7f0603d11d8..254fe4a6c0a 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ConcurrentWriteTest.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ConcurrentWriteTest.java @@ -3,11 +3,11 @@ package ca.uhn.fhir.jpa.dao.r4; import ca.uhn.fhir.interceptor.executor.InterceptorService; import ca.uhn.fhir.jpa.interceptor.TransactionConcurrencySemaphoreInterceptor; import ca.uhn.fhir.jpa.interceptor.UserRequestRetryVersionConflictsInterceptor; -import ca.uhn.fhir.rest.api.server.SystemRequestDetails; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.jpa.test.BaseJpaR4Test; import ca.uhn.fhir.rest.api.PatchTypeEnum; import ca.uhn.fhir.rest.api.server.IBundleProvider; +import ca.uhn.fhir.rest.api.server.SystemRequestDetails; import ca.uhn.fhir.rest.param.TokenParam; import ca.uhn.fhir.rest.server.RestfulServer; import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException; diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4QueryCountTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4QueryCountTest.java index 49827496b80..2f88b3db09e 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4QueryCountTest.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4QueryCountTest.java @@ -3,7 +3,6 @@ package ca.uhn.fhir.jpa.dao.r4; import ca.uhn.fhir.context.support.ValidationSupportContext; import ca.uhn.fhir.context.support.ValueSetExpansionOptions; import ca.uhn.fhir.jpa.api.config.JpaStorageSettings; -import ca.uhn.fhir.jpa.api.model.DaoMethodOutcome; import ca.uhn.fhir.jpa.api.model.HistoryCountModeEnum; import ca.uhn.fhir.jpa.entity.TermValueSet; import ca.uhn.fhir.jpa.entity.TermValueSetPreExpansionStatusEnum; @@ -26,7 +25,6 @@ import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException; import ca.uhn.fhir.rest.server.interceptor.auth.AuthorizationInterceptor; import ca.uhn.fhir.rest.server.interceptor.auth.PolicyEnum; import ca.uhn.fhir.util.BundleBuilder; -import org.apache.commons.lang3.StringUtils; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.r4.model.Bundle; diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchOptimizedTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchOptimizedTest.java index 4a0f7ede0bc..67fb685cfcd 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchOptimizedTest.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchOptimizedTest.java @@ -7,7 +7,6 @@ import ca.uhn.fhir.jpa.dao.data.ISearchResultDao; import ca.uhn.fhir.jpa.entity.Search; import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.jpa.model.search.SearchStatusEnum; -import ca.uhn.fhir.rest.api.server.SystemRequestDetails; import ca.uhn.fhir.jpa.search.PersistedJpaBundleProvider; import ca.uhn.fhir.jpa.search.SearchCoordinatorSvcImpl; import ca.uhn.fhir.jpa.searchparam.MatchUrlService; @@ -18,6 +17,7 @@ import ca.uhn.fhir.rest.api.SearchTotalModeEnum; import ca.uhn.fhir.rest.api.SortSpec; import ca.uhn.fhir.rest.api.SummaryEnum; import ca.uhn.fhir.rest.api.server.IBundleProvider; +import ca.uhn.fhir.rest.api.server.SystemRequestDetails; import ca.uhn.fhir.rest.param.DateRangeParam; import ca.uhn.fhir.rest.param.ReferenceOrListParam; import ca.uhn.fhir.rest.param.ReferenceParam; diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4StandardQueriesNoFTTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4StandardQueriesNoFTTest.java index dbfb204bbf3..0819c4f1318 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4StandardQueriesNoFTTest.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4StandardQueriesNoFTTest.java @@ -38,7 +38,6 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasItem; import static org.hamcrest.Matchers.hasItems; import static org.hamcrest.Matchers.not; -import static org.junit.jupiter.api.Assertions.fail; @ExtendWith(SpringExtension.class) @ContextConfiguration(classes = { diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ValidateTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ValidateTest.java index 6b10d43f2a1..e8c230c358d 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ValidateTest.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ValidateTest.java @@ -523,18 +523,12 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { } // Use a code that's not in the ValueSet - try { - outcome = (OperationOutcome) myObservationDao.validate(loadResourceFromClasspath(Observation.class, "/r4/bl/bb-obs-code-not-in-valueset.json"), null, null, null, null, null, mySrd).getOperationOutcome(); - String outcomeStr = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); - ourLog.info("Validation outcome: {}", outcomeStr); - fail(); - } catch (PreconditionFailedException e) { - outcome = (OperationOutcome) e.getOperationOutcome(); - String outcomeStr = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); - ourLog.info("Validation outcome: {}", outcomeStr); - assertThat(outcomeStr, - containsString("The code provided (http://unitsofmeasure.org#cm) is not in the value set")); - } + outcome = (OperationOutcome) myObservationDao.validate(loadResourceFromClasspath(Observation.class, "/r4/bl/bb-obs-code-not-in-valueset.json"), null, null, null, null, null, mySrd).getOperationOutcome(); + assertHasErrors(outcome); + String outcomeStr = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); + ourLog.info("Validation outcome: {}", outcomeStr); + assertThat(outcomeStr, + containsString("The code provided (http://unitsofmeasure.org#cm) is not in the value set")); // Before, the VS wasn't pre-expanded. Try again with it pre-expanded runInTransaction(() -> { @@ -552,24 +546,18 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { // Use a code that's in the ValueSet { outcome = (OperationOutcome) myObservationDao.validate(loadResourceFromClasspath(Observation.class, "/r4/bl/bb-obs-code-in-valueset.json"), null, null, null, null, null, mySrd).getOperationOutcome(); - String outcomeStr = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); + outcomeStr = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); ourLog.info("Validation outcome: {}", outcomeStr); assertThat(outcomeStr, not(containsString("\"error\""))); } // Use a code that's not in the ValueSet - try { - outcome = (OperationOutcome) myObservationDao.validate(loadResourceFromClasspath(Observation.class, "/r4/bl/bb-obs-code-not-in-valueset.json"), null, null, null, null, null, mySrd).getOperationOutcome(); - String outcomeStr = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); - ourLog.info("Validation outcome: {}", outcomeStr); - fail(); - } catch (PreconditionFailedException e) { - outcome = (OperationOutcome) e.getOperationOutcome(); - String outcomeStr = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); - ourLog.info("Validation outcome: {}", outcomeStr); - assertThat(outcomeStr, - containsString("The code provided (http://unitsofmeasure.org#cm) is not in the value set")); - } + outcome = (OperationOutcome) myObservationDao.validate(loadResourceFromClasspath(Observation.class, "/r4/bl/bb-obs-code-not-in-valueset.json"), null, null, null, null, null, mySrd).getOperationOutcome(); + assertHasErrors(outcome); + outcomeStr = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); + ourLog.info("Validation outcome: {}", outcomeStr); + assertThat(outcomeStr, + containsString("The code provided (http://unitsofmeasure.org#cm) is not in the value set")); } @@ -587,34 +575,22 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { OperationOutcome outcome; // Use the wrong datatype - try { - myFhirContext.setParserErrorHandler(new LenientErrorHandler()); - Observation resource = loadResourceFromClasspath(Observation.class, "/r4/bl/bb-obs-value-is-not-quantity2.json"); - outcome = (OperationOutcome) myObservationDao.validate(resource, null, null, null, null, null, mySrd).getOperationOutcome(); - String outcomeStr = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); - ourLog.info("Validation outcome: {}", outcomeStr); - fail(); - } catch (PreconditionFailedException e) { - outcome = (OperationOutcome) e.getOperationOutcome(); - String outcomeStr = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); - ourLog.info("Validation outcome: {}", outcomeStr); - assertThat(outcomeStr, containsString("\"error\"")); - } + myFhirContext.setParserErrorHandler(new LenientErrorHandler()); + Observation resource = loadResourceFromClasspath(Observation.class, "/r4/bl/bb-obs-value-is-not-quantity2.json"); + outcome = (OperationOutcome) myObservationDao.validate(resource, null, null, null, null, null, mySrd).getOperationOutcome(); + assertHasErrors(outcome); + String outcomeStr = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); + ourLog.info("Validation outcome: {}", outcomeStr); + assertThat(outcomeStr, containsString("\"error\"")); // Use the wrong datatype - try { - myFhirContext.setParserErrorHandler(new LenientErrorHandler()); - Observation resource = loadResourceFromClasspath(Observation.class, "/r4/bl/bb-obs-value-is-not-quantity.json"); - outcome = (OperationOutcome) myObservationDao.validate(resource, null, null, null, null, null, mySrd).getOperationOutcome(); - String outcomeStr = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); - ourLog.info("Validation outcome: {}", outcomeStr); - fail(); - } catch (PreconditionFailedException e) { - outcome = (OperationOutcome) e.getOperationOutcome(); - String outcomeStr = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); - ourLog.info("Validation outcome: {}", outcomeStr); - assertThat(outcomeStr, containsString("The Profile 'https://bb/StructureDefinition/BBDemographicAge' definition allows for the type Quantity but found type string")); - } + myFhirContext.setParserErrorHandler(new LenientErrorHandler()); + resource = loadResourceFromClasspath(Observation.class, "/r4/bl/bb-obs-value-is-not-quantity.json"); + outcome = (OperationOutcome) myObservationDao.validate(resource, null, null, null, null, null, mySrd).getOperationOutcome(); + assertHasErrors(outcome); + outcomeStr = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); + ourLog.info("Validation outcome: {}", outcomeStr); + assertThat(outcomeStr, containsString("The Profile 'https://bb/StructureDefinition/BBDemographicAge' definition allows for the type Quantity but found type string")); } /** @@ -1048,19 +1024,12 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { obs.getCode().getCodingFirstRep().setSystem("http://example.com/foo-foo"); obs.getCode().getCodingFirstRep().setCode("some-code"); obs.getCode().getCodingFirstRep().setDisplay("Some Code"); - try { - outcome = (OperationOutcome) myObservationDao.validate(obs, null, null, null, ValidationModeEnum.CREATE, "http://example.com/structuredefinition", mySrd).getOperationOutcome(); - ourLog.debug("Outcome: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); - assertEquals("", outcome.getIssueFirstRep().getDiagnostics()); - assertEquals(OperationOutcome.IssueSeverity.INFORMATION, outcome.getIssueFirstRep().getSeverity()); - fail(); - } catch (PreconditionFailedException e) { - outcome = (OperationOutcome) e.getOperationOutcome(); - ourLog.debug("Outcome: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); - assertThat(outcome.getIssueFirstRep().getDiagnostics(), - containsString("None of the codings provided are in the value set 'MessageCategory'")); - assertEquals(OperationOutcome.IssueSeverity.ERROR, outcome.getIssueFirstRep().getSeverity()); - } + outcome = (OperationOutcome) myObservationDao.validate(obs, null, null, null, ValidationModeEnum.CREATE, "http://example.com/structuredefinition", mySrd).getOperationOutcome(); + assertHasErrors(outcome); + ourLog.debug("Outcome: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); + assertThat(outcome.getIssueFirstRep().getDiagnostics(), + containsString("None of the codings provided are in the value set 'MessageCategory'")); + assertEquals(OperationOutcome.IssueSeverity.ERROR, outcome.getIssueFirstRep().getSeverity()); } @Test @@ -1303,14 +1272,14 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { private OperationOutcome validateAndReturnOutcome(T theObs, Boolean theWantError) { IFhirResourceDao dao = (IFhirResourceDao) myDaoRegistry.getResourceDao(theObs.getClass()); - try { - MethodOutcome outcome = dao.validate(theObs, null, null, null, ValidationModeEnum.CREATE, null, mySrd); - assertTrue(theWantError == null || !theWantError, "Wanted an error response but got a non-error"); - return (OperationOutcome) outcome.getOperationOutcome(); - } catch (PreconditionFailedException e) { - assertTrue(theWantError == null || theWantError, "Wanted a non-error response but got an error"); - return (OperationOutcome) e.getOperationOutcome(); + MethodOutcome outcome = dao.validate(theObs, null, null, null, ValidationModeEnum.CREATE, null, mySrd); + OperationOutcome oo = (OperationOutcome) outcome.getOperationOutcome(); + if (theWantError) { + assertHasErrors(oo); + } else { + assertHasNoErrors(oo); } + return oo; } @Test @@ -1343,18 +1312,12 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { String input = IOUtils.toString(getClass().getResourceAsStream("/r4/document-bundle.json"), StandardCharsets.UTF_8); Bundle document = myFhirContext.newJsonParser().parseResource(Bundle.class, input); - ourLog.info("Starting validation"); - try { - MethodOutcome outcome = myBundleDao.validate(document, null, null, null, ValidationModeEnum.CREATE, null, mySrd); - String encodedResponse = myFhirContext.newJsonParser().encodeResourceToString(outcome.getOperationOutcome()); - ourLog.info("Validation result: {}", encodedResponse); - fail(); - } catch (PreconditionFailedException e) { - ourLog.debug(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); - } - ourLog.info("Done validation"); - + MethodOutcome outcome = myBundleDao.validate(document, null, null, null, ValidationModeEnum.CREATE, null, mySrd); + OperationOutcome oo = (OperationOutcome) outcome.getOperationOutcome(); + assertHasErrors(oo); + String encodedResponse = myFhirContext.newJsonParser().encodeResourceToString(oo); + ourLog.info("Validation result: {}", encodedResponse); } @Test @@ -1486,15 +1449,12 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { ValidationModeEnum mode = ValidationModeEnum.CREATE; String encoded = myFhirContext.newJsonParser().encodeResourceToString(input); - try { - myObservationDao.validate(input, null, encoded, EncodingEnum.JSON, mode, null, mySrd); - fail(); - } catch (PreconditionFailedException e) { - org.hl7.fhir.r4.model.OperationOutcome oo = (org.hl7.fhir.r4.model.OperationOutcome) e.getOperationOutcome(); - String outputString = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo); - ourLog.info(outputString); - assertThat(outputString, containsString("Profile reference 'http://example.com/StructureDefinition/testValidateResourceContainingProfileDeclarationInvalid' has not been checked because it is unknown")); - } + MethodOutcome result = myObservationDao.validate(input, null, encoded, EncodingEnum.JSON, mode, null, mySrd); + OperationOutcome oo = (OperationOutcome) result.getOperationOutcome(); + assertHasErrors(oo); + String outputString = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo); + ourLog.info(outputString); + assertThat(outputString, containsString("Profile reference 'http://example.com/StructureDefinition/testValidateResourceContainingProfileDeclarationInvalid' has not been checked because it is unknown")); } @Test @@ -1522,15 +1482,12 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { String encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(input); ourLog.info(encoded); - try { - myBundleDao.validate(input, null, encoded, EncodingEnum.JSON, mode, null, mySrd); - fail(); - } catch (PreconditionFailedException e) { - org.hl7.fhir.r4.model.OperationOutcome oo = (org.hl7.fhir.r4.model.OperationOutcome) e.getOperationOutcome(); - String outputString = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo); - ourLog.info(outputString); - assertThat(outputString, containsString("Profile reference 'http://example.com/StructureDefinition/testValidateResourceContainingProfileDeclarationInvalid' has not been checked because it is unknown")); - } + MethodOutcome methodOutcome = myBundleDao.validate(input, null, encoded, EncodingEnum.JSON, mode, null, mySrd); + org.hl7.fhir.r4.model.OperationOutcome oo = (org.hl7.fhir.r4.model.OperationOutcome) methodOutcome.getOperationOutcome(); + assertHasErrors(oo); + String outputString = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo); + ourLog.info(outputString); + assertThat(outputString, containsString("Profile reference 'http://example.com/StructureDefinition/testValidateResourceContainingProfileDeclarationInvalid' has not been checked because it is unknown")); } @Test @@ -1565,17 +1522,12 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { .setLinkId("LINKID") .addAnswer() .setValue(new Coding().setSystem("http://hl7.org/fhir/administrative-gender").setCode("aaa")); - try { - MethodOutcome outcome = myQuestionnaireResponseDao.validate(qr, null, null, null, ValidationModeEnum.CREATE, null, mySrd); - OperationOutcome oo = (OperationOutcome) outcome.getOperationOutcome(); - ourLog.debug(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); - fail(); - } catch (PreconditionFailedException e) { - OperationOutcome oo = (OperationOutcome) e.getOperationOutcome(); - String encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo); - ourLog.info(encoded); - assertThat(encoded, containsString("is not in the options value set")); - } + MethodOutcome outcome = myQuestionnaireResponseDao.validate(qr, null, null, null, ValidationModeEnum.CREATE, null, mySrd); + OperationOutcome oo = (OperationOutcome) outcome.getOperationOutcome(); + assertHasErrors(oo); + String encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo); + ourLog.info(encoded); + assertThat(encoded, containsString("is not in the options value set")); } @Test @@ -1598,17 +1550,12 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { patient.setType("Patient"); patient.addSearchParam().setName("foo").setType(Enumerations.SearchParamType.DATE).setDefinition("http://example.com/name"); - - try { - myCapabilityStatementDao.validate(cs, null, null, null, ValidationModeEnum.CREATE, null, mySrd); - fail(); - } catch (PreconditionFailedException e) { - String oo = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome()); - ourLog.info(oo); - assertThat(oo, oo, containsString("Type mismatch - SearchParameter 'http://example.com/name' type is string, but type here is date")); - } - - + MethodOutcome result = myCapabilityStatementDao.validate(cs, null, null, null, ValidationModeEnum.CREATE, null, mySrd); + OperationOutcome oo = (OperationOutcome) result.getOperationOutcome(); + assertHasErrors(oo); + String ooString = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo); + ourLog.info(ooString); + assertThat(ooString, ooString, containsString("Type mismatch - SearchParameter 'http://example.com/name' type is string, but type here is date")); } @@ -1802,34 +1749,29 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { { String resource = loadResource("/r4/uscore/patient-resource-badcode.json"); IBaseResource parsedResource = myFhirContext.newJsonParser().parseResource(resource); - try { - myPatientDao.validate((Patient) parsedResource, null, resource, null, null, null, mySrd); - fail(); - } catch (PreconditionFailedException e) { - OperationOutcome oo = (OperationOutcome) e.getOperationOutcome(); - String encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo); - ourLog.info("Outcome:\n{}", encoded); - assertThat(encoded, containsString("Unable to validate code urn:oid:2.16.840.1.113883.6.238#2106-3AAA")); - } + MethodOutcome result = myPatientDao.validate((Patient) parsedResource, null, resource, null, null, null, mySrd); + OperationOutcome oo = (OperationOutcome) result.getOperationOutcome(); + assertHasErrors(oo); + String encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo); + ourLog.info("Outcome:\n{}", encoded); + assertThat(encoded, containsString("Unable to validate code urn:oid:2.16.840.1.113883.6.238#2106-3AAA")); } { String resource = loadResource("/r4/uscore/patient-resource-good.json"); IBaseResource parsedResource = myFhirContext.newJsonParser().parseResource(resource); - try { - MethodOutcome outcome = myPatientDao.validate((Patient) parsedResource, null, resource, null, null, null, mySrd); - OperationOutcome oo = (OperationOutcome) outcome.getOperationOutcome(); - String encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo); - ourLog.info("Outcome:\n{}", encoded); - assertThat(encoded, containsString("No issues detected")); - } catch (PreconditionFailedException e) { - fail(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); - } + MethodOutcome outcome = myPatientDao.validate((Patient) parsedResource, null, resource, null, null, null, mySrd); + OperationOutcome oo = (OperationOutcome) outcome.getOperationOutcome(); + assertHasNoErrors(oo); + String encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo); + ourLog.info("Outcome:\n{}", encoded); + assertThat(encoded, containsString("No issues detected")); } { String resource = loadResource("/r4/uscore/observation-resource-good.json"); IBaseResource parsedResource = myFhirContext.newJsonParser().parseResource(resource); MethodOutcome outcome = myObservationDao.validate((Observation) parsedResource, null, resource, null, null, null, mySrd); OperationOutcome oo = (OperationOutcome) outcome.getOperationOutcome(); + assertHasNoErrors(oo); String encoded = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo); ourLog.info("Outcome:\n{}", encoded); assertThat(encoded, not(containsString("error"))); @@ -1852,17 +1794,12 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { qa.getQuestionnaireElement().setValue("http://foo/q"); qa.addItem().setLinkId("link1").addAnswer().setValue(new StringType("FOO")); - try { - MethodOutcome validationOutcome = myQuestionnaireResponseDao.validate(qa, null, null, null, null, null, null); - OperationOutcome oo = (OperationOutcome) validationOutcome.getOperationOutcome(); - String encode = encode(oo); - ourLog.info(encode); - fail("Didn't fail- response was " + encode); - } catch (PreconditionFailedException e) { - OperationOutcome oo = (OperationOutcome) e.getOperationOutcome(); - assertEquals("No response answer found for required item 'link0'", oo.getIssueFirstRep().getDiagnostics()); - } - + MethodOutcome validationOutcome = myQuestionnaireResponseDao.validate(qa, null, null, null, null, null, null); + OperationOutcome oo = (OperationOutcome) validationOutcome.getOperationOutcome(); + assertHasErrors(oo); + String encode = encode(oo); + ourLog.info(encode); + assertEquals("No response answer found for required item 'link0'", oo.getIssueFirstRep().getDiagnostics()); } @Test @@ -1881,17 +1818,12 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { qa.getQuestionnaireElement().setValue("http://foo/q"); qa.addItem().setLinkId("link1").addAnswer().setValue(new StringType("FOO")); - try { - MethodOutcome validationOutcome = myQuestionnaireResponseDao.validate(qa, null, null, null, null, null, null); - OperationOutcome oo = (OperationOutcome) validationOutcome.getOperationOutcome(); - String encode = encode(oo); - ourLog.info(encode); - fail("Didn't fail- response was " + encode); - } catch (PreconditionFailedException e) { - OperationOutcome oo = (OperationOutcome) e.getOperationOutcome(); - assertEquals("No response answer found for required item 'link0'", oo.getIssueFirstRep().getDiagnostics()); - } - + MethodOutcome validationOutcome = myQuestionnaireResponseDao.validate(qa, null, null, null, null, null, null); + OperationOutcome oo = (OperationOutcome) validationOutcome.getOperationOutcome(); + assertHasErrors(oo); + String encode = encode(oo); + ourLog.info(encode); + assertEquals("No response answer found for required item 'link0'", oo.getIssueFirstRep().getDiagnostics()); } @Test @@ -1924,18 +1856,14 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { public void testValidateCodeInUnknownCodeSystemWithRequiredBinding() throws IOException { Condition condition = loadResourceFromClasspath(Condition.class, "/r4/code-in-unknown-system-with-required-binding.xml"); - try { - myConditionDao.validate(condition, null, null, null, null, null, null); - fail(); - } catch (PreconditionFailedException e) { - OperationOutcome oo = (OperationOutcome) e.getOperationOutcome(); - ourLog.debug(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); - assertThat(oo.getIssueFirstRep().getDiagnostics(), - containsString("None of the codings provided are in the value set 'Condition Clinical Status Codes' (http://hl7.org/fhir/ValueSet/condition-clinical|4.0.1), and a coding from this value set is required) (codes = http://terminology.hl7.org/CodeSystem/condition-clinical/wrong-system#notrealcode)")); - } + MethodOutcome result = myConditionDao.validate(condition, null, null, null, null, null, null); + OperationOutcome oo = (OperationOutcome) result.getOperationOutcome(); + assertHasErrors(oo); + ourLog.debug(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo)); + assertThat(oo.getIssueFirstRep().getDiagnostics(), + containsString("None of the codings provided are in the value set 'Condition Clinical Status Codes' (http://hl7.org/fhir/ValueSet/condition-clinical|4.0.1), and a coding from this value set is required) (codes = http://terminology.hl7.org/CodeSystem/condition-clinical/wrong-system#notrealcode)")); } - private IBaseResource findResourceByIdInBundle(Bundle vss, String name) { IBaseResource retVal = null; for (BundleEntryComponent next : vss.getEntry()) { diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirSystemDaoR4Test.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirSystemDaoR4Test.java index 94a05457f8d..302845dc3ca 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirSystemDaoR4Test.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirSystemDaoR4Test.java @@ -39,9 +39,7 @@ import ca.uhn.fhir.util.BundleBuilder; import ca.uhn.fhir.util.ClasspathUtil; import org.apache.commons.io.IOUtils; import org.hamcrest.Matchers; -import org.hibernate.envers.query.AuditEntity; import org.hl7.fhir.instance.model.api.IAnyResource; -import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.r4.model.AllergyIntolerance; import org.hl7.fhir.r4.model.Appointment; @@ -74,7 +72,6 @@ import org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity; import org.hl7.fhir.r4.model.Organization; import org.hl7.fhir.r4.model.Patient; import org.hl7.fhir.r4.model.Practitioner; -import org.hl7.fhir.r4.model.Provenance; import org.hl7.fhir.r4.model.Quantity; import org.hl7.fhir.r4.model.Reference; import org.hl7.fhir.r4.model.Resource; diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/PartitioningSqlR4Test.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/PartitioningSqlR4Test.java index 456e71d91e3..e969bf122d5 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/PartitioningSqlR4Test.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/PartitioningSqlR4Test.java @@ -21,11 +21,11 @@ import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.jpa.model.entity.ResourceTag; import ca.uhn.fhir.jpa.model.entity.SearchParamPresentEntity; import ca.uhn.fhir.jpa.model.util.JpaConstants; -import ca.uhn.fhir.rest.api.server.SystemRequestDetails; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.jpa.util.SqlQuery; import ca.uhn.fhir.rest.api.Constants; import ca.uhn.fhir.rest.api.server.IBundleProvider; +import ca.uhn.fhir.rest.api.server.SystemRequestDetails; import ca.uhn.fhir.rest.param.DateAndListParam; import ca.uhn.fhir.rest.param.DateOrListParam; import ca.uhn.fhir.rest.param.DateParam; diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/SyntheaPerfTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/SyntheaPerfTest.java index 7f473cc6892..b5297fa0030 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/SyntheaPerfTest.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/SyntheaPerfTest.java @@ -4,11 +4,11 @@ import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.jpa.api.config.JpaStorageSettings; import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao; import ca.uhn.fhir.jpa.model.entity.ResourceEncodingEnum; -import ca.uhn.fhir.rest.api.server.SystemRequestDetails; import ca.uhn.fhir.jpa.search.reindex.BlockPolicy; import ca.uhn.fhir.jpa.test.BaseJpaTest; import ca.uhn.fhir.jpa.test.config.TestHSearchAddInConfig; import ca.uhn.fhir.jpa.test.config.TestR4Config; +import ca.uhn.fhir.rest.api.server.SystemRequestDetails; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import ca.uhn.fhir.system.HapiTestSystemProperties; import ca.uhn.fhir.util.StopWatch; @@ -68,7 +68,7 @@ public class SyntheaPerfTest extends BaseJpaTest { myFhirContext.getParserOptions().setAutoContainReferenceTargetsWithNoId(true); } - @Disabled + @Disabled("Stress test") @Test public void testLoadSynthea() throws Exception { assertEquals(100, TestR4Config.getMaxThreads()); diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/interceptor/validation/ValidationMessageSuppressingInterceptorTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/interceptor/validation/ValidationMessageSuppressingInterceptorTest.java index 9714cd15fe6..0dc8f8dff97 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/interceptor/validation/ValidationMessageSuppressingInterceptorTest.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/interceptor/validation/ValidationMessageSuppressingInterceptorTest.java @@ -54,12 +54,8 @@ public class ValidationMessageSuppressingInterceptorTest extends BaseResourcePro String input = loadResource("/r4/uscore/observation-pulseox.json"); Observation inputObs = loadResource(myFhirContext, Observation.class, "/r4/uscore/observation-pulseox.json"); - try { - myObservationDao.validate(inputObs, null, input, null, null, null, null); - fail(); - } catch (PreconditionFailedException e) { - // good - } + MethodOutcome result = myObservationDao.validate(inputObs, null, input, null, null, null, null); + ValidationMessageSuppressingInterceptor interceptor = new ValidationMessageSuppressingInterceptor(); interceptor.addMessageSuppressionPatterns("Unknown code 'http://loinc.org#59408-5'"); @@ -67,6 +63,7 @@ public class ValidationMessageSuppressingInterceptorTest extends BaseResourcePro MethodOutcome validationOutcome = myObservationDao.validate(inputObs, null, input, null, null, null, null); OperationOutcome oo = (OperationOutcome) validationOutcome.getOperationOutcome(); + assertHasWarnings(oo); String encode = encode(oo); ourLog.info(encode); assertThat(encode, containsString("All observations should have a performer")); diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/MultitenantServerR4Test.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/MultitenantServerR4Test.java index 533afe4a403..da988fee7cc 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/MultitenantServerR4Test.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/MultitenantServerR4Test.java @@ -15,9 +15,9 @@ import ca.uhn.fhir.jpa.model.config.PartitionSettings; import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.jpa.model.util.JpaConstants; import ca.uhn.fhir.jpa.partition.RequestPartitionHelperSvc; -import ca.uhn.fhir.rest.api.server.SystemRequestDetails; import ca.uhn.fhir.rest.api.Constants; import ca.uhn.fhir.rest.api.server.RequestDetails; +import ca.uhn.fhir.rest.api.server.SystemRequestDetails; import ca.uhn.fhir.rest.api.server.bulk.BulkDataExportOptions; import ca.uhn.fhir.rest.server.RestfulServer; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderHasParamR4Test.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderHasParamR4Test.java index 4dbbee087a6..2384494a5dc 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderHasParamR4Test.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderHasParamR4Test.java @@ -30,7 +30,6 @@ import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.contains; @@ -623,7 +622,7 @@ public class ResourceProviderHasParamR4Test extends BaseResourceProviderR4Test { assertNotEquals(0, notInListQueries.size()); } - private List searchAndReturnUnqualifiedVersionlessIdValues(String uri) throws IOException { + public List searchAndReturnUnqualifiedVersionlessIdValues(String uri) throws IOException { List ids; HttpGet get = new HttpGet(uri); diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4EverythingTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4EverythingTest.java new file mode 100644 index 00000000000..9eabf227dab --- /dev/null +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4EverythingTest.java @@ -0,0 +1,1267 @@ +package ca.uhn.fhir.jpa.provider.r4; + +import ca.uhn.fhir.jpa.provider.BaseResourceProviderR4Test; +import ca.uhn.fhir.jpa.search.SearchCoordinatorSvcImpl; +import ca.uhn.fhir.jpa.util.QueryParameterUtils; +import ca.uhn.fhir.model.api.Include; +import ca.uhn.fhir.parser.IParser; +import ca.uhn.fhir.rest.api.Constants; +import ca.uhn.fhir.rest.param.NumberParam; +import ca.uhn.fhir.rest.param.StringAndListParam; +import ca.uhn.fhir.rest.param.StringOrListParam; +import ca.uhn.fhir.rest.param.StringParam; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.hl7.fhir.instance.model.api.IIdType; +import org.hl7.fhir.r4.model.Bundle; +import org.hl7.fhir.r4.model.Composition; +import org.hl7.fhir.r4.model.Condition; +import org.hl7.fhir.r4.model.Device; +import org.hl7.fhir.r4.model.Encounter; +import org.hl7.fhir.r4.model.IdType; +import org.hl7.fhir.r4.model.InstantType; +import org.hl7.fhir.r4.model.IntegerType; +import org.hl7.fhir.r4.model.Location; +import org.hl7.fhir.r4.model.Medication; +import org.hl7.fhir.r4.model.MedicationRequest; +import org.hl7.fhir.r4.model.Observation; +import org.hl7.fhir.r4.model.Organization; +import org.hl7.fhir.r4.model.Parameters; +import org.hl7.fhir.r4.model.Patient; +import org.hl7.fhir.r4.model.Practitioner; +import org.hl7.fhir.r4.model.Provenance; +import org.hl7.fhir.r4.model.Reference; +import org.hl7.fhir.r4.model.StringType; +import org.hl7.fhir.r4.model.UnsignedIntType; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Date; +import java.util.List; +import java.util.Set; +import java.util.TreeSet; +import java.util.stream.Collectors; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.contains; +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.containsInRelativeOrder; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.emptyString; +import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.Matchers.hasItem; +import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.Matchers.lessThanOrEqualTo; +import static org.hamcrest.Matchers.not; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; + +public class ResourceProviderR4EverythingTest extends BaseResourceProviderR4Test { + + public static final int LARGE_NUMBER = 77; + private SearchCoordinatorSvcImpl mySearchCoordinatorSvcImpl; + + @BeforeEach + void beforeEach() { + mySearchCoordinatorSvcImpl = (SearchCoordinatorSvcImpl)mySearchCoordinatorSvc; + } + + @Override + @AfterEach + public void after() throws Exception { + super.after(); + mySearchCoordinatorSvcImpl.setSyncSizeForUnitTests(QueryParameterUtils.DEFAULT_SYNC_SIZE); + mySearchCoordinatorSvcImpl.setLoadingThrottleForUnitTests(null); + mySearchCoordinatorSvcImpl.setNeverUseLocalSearchForUnitTests(false); + } + + @Test + public void testEverythingEncounterInstance() { + String methodName = "testEverythingEncounterInstance"; + + Organization org1parent = new Organization(); + org1parent.setId("org1parent"); + org1parent.setName(methodName + "1parent"); + IIdType orgId1parent = myClient.update().resource(org1parent).execute().getId().toUnqualifiedVersionless(); + + Organization org1 = new Organization(); + org1.setName(methodName + "1"); + org1.getPartOf().setReferenceElement(orgId1parent); + IIdType orgId1 = myClient.create().resource(org1).execute().getId().toUnqualifiedVersionless(); + + Patient p = new Patient(); + p.addName().setFamily(methodName); + p.getManagingOrganization().setReferenceElement(orgId1); + IIdType patientId = myClient.create().resource(p).execute().getId().toUnqualifiedVersionless(); + + IIdType orgId2 = createOrganization(methodName, "1"); + + Device dev = new Device(); + dev.setManufacturer(methodName); + dev.getOwner().setReferenceElement(orgId2); + IIdType devId = myClient.create().resource(dev).execute().getId().toUnqualifiedVersionless(); + + Location locParent = new Location(); + locParent.setName(methodName + "Parent"); + IIdType locPId = myClient.create().resource(locParent).execute().getId().toUnqualifiedVersionless(); + + Location locChild = new Location(); + locChild.setName(methodName); + locChild.getPartOf().setReferenceElement(locPId); + IIdType locCId = myClient.create().resource(locChild).execute().getId().toUnqualifiedVersionless(); + + Encounter encU = new Encounter(); + encU.getSubject().setReferenceElement(patientId); + encU.addLocation().getLocation().setReferenceElement(locCId); + IIdType encUId = myClient.create().resource(encU).execute().getId().toUnqualifiedVersionless(); + + Encounter enc = new Encounter(); + enc.getSubject().setReferenceElement(patientId); + enc.addLocation().getLocation().setReferenceElement(locCId); + IIdType encId = myClient.create().resource(enc).execute().getId().toUnqualifiedVersionless(); + + Observation obs = new Observation(); + obs.getSubject().setReferenceElement(patientId); + obs.getDevice().setReferenceElement(devId); + obs.getEncounter().setReferenceElement(encId); + IIdType obsId = myClient.create().resource(obs).execute().getId().toUnqualifiedVersionless(); + + ourLog.info("IDs: EncU:" + encUId.getIdPart() + " Enc:" + encId.getIdPart() + " " + patientId.toUnqualifiedVersionless()); + + Parameters output = myClient.operation().onInstance(encId).named("everything").withNoParameters(Parameters.class).execute(); + Bundle b = (Bundle) output.getParameter().get(0).getResource(); + List ids = toUnqualifiedVersionlessIds(b); + assertThat(ids, containsInAnyOrder(patientId, encId, orgId1, orgId2, orgId1parent, locPId, locCId, obsId, devId)); + assertThat(ids, not(containsInRelativeOrder(encUId))); + + ourLog.info(ids.toString()); + } + + @Test + public void testEverythingEncounterType() { + String methodName = "testEverythingEncounterInstance"; + + Organization org1parent = new Organization(); + org1parent.setId("org1parent"); + org1parent.setName(methodName + "1parent"); + IIdType orgId1parent = myClient.update().resource(org1parent).execute().getId().toUnqualifiedVersionless(); + + Organization org1 = new Organization(); + org1.setName(methodName + "1"); + org1.getPartOf().setReferenceElement(orgId1parent); + IIdType orgId1 = myClient.create().resource(org1).execute().getId().toUnqualifiedVersionless(); + + Patient p = new Patient(); + p.addName().setFamily(methodName); + p.getManagingOrganization().setReferenceElement(orgId1); + IIdType patientId = myClient.create().resource(p).execute().getId().toUnqualifiedVersionless(); + + IIdType orgId2 = createOrganization(methodName, "1"); + + Device dev = new Device(); + dev.setManufacturer(methodName); + dev.getOwner().setReferenceElement(orgId2); + IIdType devId = myClient.create().resource(dev).execute().getId().toUnqualifiedVersionless(); + + Location locParent = new Location(); + locParent.setName(methodName + "Parent"); + IIdType locPId = myClient.create().resource(locParent).execute().getId().toUnqualifiedVersionless(); + + Location locChild = new Location(); + locChild.setName(methodName); + locChild.getPartOf().setReferenceElement(locPId); + IIdType locCId = myClient.create().resource(locChild).execute().getId().toUnqualifiedVersionless(); + + Encounter encU = new Encounter(); + encU.addIdentifier().setValue(methodName); + IIdType encUId = myClient.create().resource(encU).execute().getId().toUnqualifiedVersionless(); + + Encounter enc = new Encounter(); + enc.getSubject().setReferenceElement(patientId); + enc.addLocation().getLocation().setReferenceElement(locCId); + IIdType encId = myClient.create().resource(enc).execute().getId().toUnqualifiedVersionless(); + + Observation obs = new Observation(); + obs.getSubject().setReferenceElement(patientId); + obs.getDevice().setReferenceElement(devId); + obs.getEncounter().setReferenceElement(encId); + IIdType obsId = myClient.create().resource(obs).execute().getId().toUnqualifiedVersionless(); + + Parameters output = myClient.operation().onType(Encounter.class).named("everything").withNoParameters(Parameters.class).execute(); + Bundle b = (Bundle) output.getParameter().get(0).getResource(); + List ids = toUnqualifiedVersionlessIds(b); + assertThat(ids, containsInAnyOrder(patientId, encUId, encId, orgId1, orgId2, orgId1parent, locPId, locCId, obsId, devId)); + + ourLog.info(ids.toString()); + } + + @Test + public void testEverythingInstanceWithContentFilter() { + Patient pt1 = new Patient(); + pt1.addName().setFamily("Everything").addGiven("Arthur"); + IIdType ptId1 = myPatientDao.create(pt1, mySrd).getId().toUnqualifiedVersionless(); + + Patient pt2 = new Patient(); + pt2.addName().setFamily("Everything").addGiven("Arthur"); + IIdType ptId2 = myPatientDao.create(pt2, mySrd).getId().toUnqualifiedVersionless(); + + Device dev1 = new Device(); + dev1.setManufacturer("Some Manufacturer"); + IIdType devId1 = myDeviceDao.create(dev1, mySrd).getId().toUnqualifiedVersionless(); + + Device dev2 = new Device(); + dev2.setManufacturer("Some Manufacturer 2"); + myDeviceDao.create(dev2, mySrd).getId().toUnqualifiedVersionless(); + + Observation obs1 = new Observation(); + obs1.getText().setDivAsString("
OBSTEXT1
"); + obs1.getSubject().setReferenceElement(ptId1); + obs1.getCode().addCoding().setCode("CODE1"); + obs1.setValue(new StringType("obsvalue1")); + obs1.getDevice().setReferenceElement(devId1); + IIdType obsId1 = myObservationDao.create(obs1, mySrd).getId().toUnqualifiedVersionless(); + + Observation obs2 = new Observation(); + obs2.getSubject().setReferenceElement(ptId1); + obs2.getCode().addCoding().setCode("CODE2"); + obs2.setValue(new StringType("obsvalue2")); + IIdType obsId2 = myObservationDao.create(obs2, mySrd).getId().toUnqualifiedVersionless(); + + Observation obs3 = new Observation(); + obs3.getSubject().setReferenceElement(ptId2); + obs3.getCode().addCoding().setCode("CODE3"); + obs3.setValue(new StringType("obsvalue3")); + IIdType obsId3 = myObservationDao.create(obs3, mySrd).getId().toUnqualifiedVersionless(); + + List actual; + StringAndListParam param; + + ourLog.info("Pt1:{} Pt2:{} Obs1:{} Obs2:{} Obs3:{}", ptId1.getIdPart(), ptId2.getIdPart(), obsId1.getIdPart(), obsId2.getIdPart(), obsId3.getIdPart()); + + param = new StringAndListParam(); + param.addAnd(new StringOrListParam().addOr(new StringParam("obsvalue1"))); + + //@formatter:off + Parameters response = myClient + .operation() + .onInstance(ptId1) + .named("everything") + .withParameter(Parameters.class, Constants.PARAM_CONTENT, new StringType("obsvalue1")) + .execute(); + //@formatter:on + + actual = toUnqualifiedVersionlessIds((Bundle) response.getParameter().get(0).getResource()); + assertThat(actual, containsInAnyOrder(ptId1, obsId1, devId1)); + + } + + /** + * See #147 + */ + @Test + public void testEverythingPatientDoesntRepeatPatient() { + Bundle b; + IParser parser = myFhirContext.newJsonParser(); + b = parser.parseResource(Bundle.class, new InputStreamReader(ResourceProviderR4Test.class.getResourceAsStream("/r4/bug147-bundle.json"))); + + Bundle resp = myClient.transaction().withBundle(b).execute(); + List ids = new ArrayList<>(); + for (Bundle.BundleEntryComponent next : resp.getEntry()) { + IdType toAdd = new IdType(next.getResponse().getLocation()).toUnqualifiedVersionless(); + ids.add(toAdd); + } + ourLog.info("Created: " + ids.toString()); + + IdType patientId = new IdType(resp.getEntry().get(0).getResponse().getLocation()); + assertEquals("Patient", patientId.getResourceType()); + + { + Parameters output = myClient.operation().onInstance(patientId).named("everything").withNoParameters(Parameters.class).execute(); + b = (Bundle) output.getParameter().get(0).getResource(); + + ids = new ArrayList<>(); + boolean dupes = false; + for (Bundle.BundleEntryComponent next : b.getEntry()) { + IdType toAdd = next.getResource().getIdElement().toUnqualifiedVersionless(); + dupes = dupes | ids.contains(toAdd); + ids.add(toAdd); + } + ourLog.info("$everything: " + ids.toString()); + + assertFalse(dupes, ids.toString()); + } + + /* + * Now try with a size specified + */ + { + Parameters input = new Parameters(); + input.addParameter().setName(Constants.PARAM_COUNT).setValue(new UnsignedIntType(100)); + Parameters output = myClient.operation().onInstance(patientId).named("everything").withParameters(input).execute(); + b = (Bundle) output.getParameter().get(0).getResource(); + + ids = new ArrayList<>(); + boolean dupes = false; + for (Bundle.BundleEntryComponent next : b.getEntry()) { + IdType toAdd = next.getResource().getIdElement().toUnqualifiedVersionless(); + dupes = dupes | ids.contains(toAdd); + ids.add(toAdd); + } + ourLog.info("$everything: " + ids.toString()); + + assertFalse(dupes, ids.toString()); + assertThat(ids.toString(), containsString("Condition")); + assertThat(ids.size(), greaterThan(10)); + } + } + + /** + * Test for #226 + */ + @Test + public void testEverythingPatientIncludesBackReferences() { + String methodName = "testEverythingIncludesBackReferences"; + + Medication med = new Medication(); + med.getCode().setText(methodName); + IIdType medId = myMedicationDao.create(med, mySrd).getId().toUnqualifiedVersionless(); + + Patient pat = new Patient(); + pat.addAddress().addLine(methodName); + IIdType patId = myPatientDao.create(pat, mySrd).getId().toUnqualifiedVersionless(); + + MedicationRequest mo = new MedicationRequest(); + mo.getSubject().setReferenceElement(patId); + mo.setMedication(new Reference(medId)); + IIdType moId = myMedicationRequestDao.create(mo, mySrd).getId().toUnqualifiedVersionless(); + + Parameters output = myClient.operation().onInstance(patId).named("everything").withNoParameters(Parameters.class).execute(); + Bundle b = (Bundle) output.getParameter().get(0).getResource(); + List ids = toUnqualifiedVersionlessIds(b); + ourLog.info(ids.toString()); + assertThat(ids, containsInAnyOrder(patId, medId, moId)); + } + + /** + * See #148 + */ + @Test + public void testEverythingPatientIncludesCondition() { + Bundle b = new Bundle(); + Patient p = new Patient(); + p.setId("1"); + b.addEntry().setResource(p).getRequest().setMethod(Bundle.HTTPVerb.POST); + + Condition c = new Condition(); + c.getSubject().setReference("Patient/1"); + b.addEntry().setResource(c).getRequest().setMethod(Bundle.HTTPVerb.POST); + + Bundle resp = myClient.transaction().withBundle(b).execute(); + + ourLog.debug(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(resp)); + + IdType patientId = new IdType(resp.getEntry().get(0).getResponse().getLocation()); + assertEquals("Patient", patientId.getResourceType()); + + Parameters output = myClient.operation().onInstance(patientId).named("everything").withNoParameters(Parameters.class).execute(); + b = (Bundle) output.getParameter().get(0).getResource(); + + List ids = new ArrayList<>(); + for (Bundle.BundleEntryComponent next : b.getEntry()) { + IdType toAdd = next.getResource().getIdElement().toUnqualifiedVersionless(); + ids.add(toAdd); + } + + assertThat(ids.toString(), containsString("Patient/")); + assertThat(ids.toString(), containsString("Condition/")); + + } + + @Test + public void testEverythingPatientOperation() { + String methodName = "testEverythingOperation"; + + Organization org1parent = new Organization(); + org1parent.setId("org1parent"); + org1parent.setName(methodName + "1parent"); + IIdType orgId1parent = myClient.update().resource(org1parent).execute().getId().toUnqualifiedVersionless(); + + Organization org1 = new Organization(); + org1.setName(methodName + "1"); + org1.getPartOf().setReferenceElement(orgId1parent); + IIdType orgId1 = myClient.create().resource(org1).execute().getId().toUnqualifiedVersionless(); + + Patient p = new Patient(); + p.addName().setFamily(methodName); + p.getManagingOrganization().setReferenceElement(orgId1); + IIdType patientId = myClient.create().resource(p).execute().getId().toUnqualifiedVersionless(); + + IIdType orgId2 = createOrganization(methodName, "1"); + + Device dev = new Device(); + dev.setManufacturer(methodName); + dev.getOwner().setReferenceElement(orgId2); + IIdType devId = myClient.create().resource(dev).execute().getId().toUnqualifiedVersionless(); + + Observation obs = new Observation(); + obs.getSubject().setReferenceElement(patientId); + obs.getDevice().setReferenceElement(devId); + IIdType obsId = myClient.create().resource(obs).execute().getId().toUnqualifiedVersionless(); + + Encounter enc = new Encounter(); + enc.getSubject().setReferenceElement(patientId); + IIdType encId = myClient.create().resource(enc).execute().getId().toUnqualifiedVersionless(); + + Parameters output = myClient.operation().onInstance(patientId).named("everything").withNoParameters(Parameters.class).execute(); + Bundle b = (Bundle) output.getParameter().get(0).getResource(); + List ids = toUnqualifiedVersionlessIds(b); + assertThat(ids, containsInAnyOrder(patientId, devId, obsId, encId, orgId1, orgId2, orgId1parent)); + + ourLog.info(ids.toString()); + } + + @Test + public void testEverythingPatientType() { + String methodName = "testEverythingPatientType"; + + IIdType o1Id = createOrganization(methodName, "1"); + IIdType o2Id = createOrganization(methodName, "2"); + + IIdType p1Id = createPatientWithIndexAtOrganization(methodName, "1", o1Id); + IIdType c1Id = createConditionForPatient(methodName, "1", p1Id); + + IIdType p2Id = createPatientWithIndexAtOrganization(methodName, "2", o2Id); + IIdType c2Id = createConditionForPatient(methodName, "2", p2Id); + + IIdType c3Id = createConditionForPatient(methodName, "3", null); + + Parameters output = myClient.operation().onType(Patient.class).named("everything").withNoParameters(Parameters.class).execute(); + Bundle b = (Bundle) output.getParameter().get(0).getResource(); + + assertEquals(Bundle.BundleType.SEARCHSET, b.getType()); + List ids = toUnqualifiedVersionlessIds(b); + + assertThat(ids, containsInAnyOrder(o1Id, o2Id, p1Id, p2Id, c1Id, c2Id)); + assertThat(ids, not(containsInRelativeOrder(c3Id))); + } + + @Test + public void testEverythingPatientTypeWithIdParameter() { + String methodName = "testEverythingPatientTypeWithIdParameter"; + + //Patient 1 stuff. + IIdType o1Id = createOrganization(methodName, "1"); + IIdType p1Id = createPatientWithIndexAtOrganization(methodName, "1", o1Id); + IIdType c1Id = createConditionForPatient(methodName, "1", p1Id); + + //Patient 2 stuff. + IIdType o2Id = createOrganization(methodName, "2"); + IIdType p2Id = createPatientWithIndexAtOrganization(methodName, "2", o2Id); + IIdType c2Id = createConditionForPatient(methodName, "2", p2Id); + + //Patient 3 stuff. + IIdType o3Id = createOrganization(methodName, "3"); + IIdType p3Id = createPatientWithIndexAtOrganization(methodName, "3", o3Id); + IIdType c3Id = createConditionForPatient(methodName, "3", p3Id); + + //Patient 4 stuff. + IIdType o4Id = createOrganization(methodName, "4"); + IIdType p4Id = createPatientWithIndexAtOrganization(methodName, "4", o4Id); + IIdType c4Id = createConditionForPatient(methodName, "4", p4Id); + + //No Patient Stuff + IIdType c5Id = createConditionForPatient(methodName, "4", null); + + + { + //Test for only one patient + Parameters parameters = new Parameters(); + parameters.addParameter("_id", p1Id.getIdPart()); + + Parameters output = myClient.operation().onType(Patient.class).named("everything").withParameters(parameters).execute(); + Bundle b = (Bundle) output.getParameter().get(0).getResource(); + + assertEquals(Bundle.BundleType.SEARCHSET, b.getType()); + List ids = toUnqualifiedVersionlessIds(b); + + assertThat(ids, containsInAnyOrder(o1Id, p1Id, c1Id)); + assertThat(ids, not((o2Id))); + assertThat(ids, not(hasItem(c2Id))); + assertThat(ids, not(hasItem(p2Id))); + } + + { + // Test for Patient 1 and 2 + // e.g. _id=1&_id=2 + Parameters parameters = new Parameters(); + parameters.addParameter("_id", p1Id.getIdPart()); + parameters.addParameter("_id", p2Id.getIdPart()); + + Parameters output = myClient.operation().onType(Patient.class).named("everything").withParameters(parameters).execute(); + Bundle b = (Bundle) output.getParameter().get(0).getResource(); + + assertEquals(Bundle.BundleType.SEARCHSET, b.getType()); + List ids = toUnqualifiedVersionlessIds(b); + + assertThat(ids, containsInAnyOrder(o1Id, p1Id, c1Id, o2Id, c2Id, p2Id)); + } + + { + // Test for both patients using orList + // e.g. _id=1,2 + Parameters parameters = new Parameters(); + parameters.addParameter("_id", p1Id.getIdPart() + "," + p2Id.getIdPart()); + + Parameters output = myClient.operation().onType(Patient.class).named("everything").withParameters(parameters).execute(); + Bundle b = (Bundle) output.getParameter().get(0).getResource(); + + assertEquals(Bundle.BundleType.SEARCHSET, b.getType()); + List ids = toUnqualifiedVersionlessIds(b); + + assertThat(ids, containsInAnyOrder(o1Id, p1Id, c1Id, o2Id, c2Id, p2Id)); + assertThat(ids, not(hasItem(c5Id))); + } + + { + // Test combining 2 or-listed params + // e.g. _id=1,2&_id=3,4 + Parameters parameters = new Parameters(); + parameters.addParameter("_id", "Patient/" + p1Id.getIdPart() + "," + p2Id.getIdPart()); + parameters.addParameter("_id", p3Id.getIdPart() + "," + p4Id.getIdPart()); + parameters.addParameter(new Parameters.ParametersParameterComponent().setName("_count").setValue(new UnsignedIntType(20))); + + Parameters output = myClient.operation().onType(Patient.class).named("everything").withParameters(parameters).execute(); + Bundle b = (Bundle) output.getParameter().get(0).getResource(); + + assertEquals(Bundle.BundleType.SEARCHSET, b.getType()); + List ids = toUnqualifiedVersionlessIds(b); + + assertThat(ids, containsInAnyOrder(o1Id, p1Id, c1Id, o2Id, c2Id, p2Id, p3Id, o3Id, c3Id, p4Id, c4Id, o4Id)); + assertThat(ids, not(hasItem(c5Id))); + } + + { + // Test paging works. + // There are 12 results, lets make 2 pages of 6. + Parameters parameters = new Parameters(); + parameters.addParameter("_id", "Patient/" + p1Id.getIdPart() + "," + p2Id.getIdPart()); + parameters.addParameter("_id", p3Id.getIdPart() + "," + p4Id.getIdPart()); + parameters.addParameter(new Parameters.ParametersParameterComponent().setName("_count").setValue(new UnsignedIntType(6))); + + Parameters output = myClient.operation().onType(Patient.class).named("everything").withParameters(parameters).execute(); + Bundle bundle = (Bundle) output.getParameter().get(0).getResource(); + + String next = bundle.getLink("next").getUrl(); + Bundle nextBundle = myClient.loadPage().byUrl(next).andReturnBundle(Bundle.class).execute(); + assertEquals(Bundle.BundleType.SEARCHSET, bundle.getType()); + + assertThat(bundle.getEntry(), hasSize(6)); + assertThat(nextBundle.getEntry(), hasSize(6)); + + List firstBundle = toUnqualifiedVersionlessIds(bundle); + List secondBundle = toUnqualifiedVersionlessIds(nextBundle); + List allresults = new ArrayList<>(); + allresults.addAll(firstBundle); + allresults.addAll(secondBundle); + + assertThat(allresults, containsInAnyOrder(o1Id, p1Id, c1Id, o2Id, c2Id, p2Id, p3Id, o3Id, c3Id, p4Id, c4Id, o4Id)); + assertThat(allresults, not(hasItem(c5Id))); + } + } + + @Test + public void testEverythingPatientInstanceWithTypeParameter() { + String methodName = "testEverythingPatientInstanceWithTypeParameter"; + + //Patient 1 stuff. + IIdType o1Id = createOrganization(methodName, "1"); + IIdType p1Id = createPatientWithIndexAtOrganization(methodName, "1", o1Id); + IIdType c1Id = createConditionForPatient(methodName, "1", p1Id); + IIdType obs1Id = createObservationForPatient(p1Id, "1"); + IIdType m1Id = createMedicationRequestForPatient(p1Id, "1"); + + //Test for only one patient + Parameters parameters = new Parameters(); + parameters.addParameter("_type", "Condition, Observation"); + + myCaptureQueriesListener.clear(); + + Parameters output = myClient.operation().onInstance(p1Id).named("everything").withParameters(parameters).execute(); + ourLog.debug(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(output)); + Bundle b = (Bundle) output.getParameter().get(0).getResource(); + + myCaptureQueriesListener.logSelectQueries(); + + assertEquals(Bundle.BundleType.SEARCHSET, b.getType()); + List ids = toUnqualifiedVersionlessIds(b); + + assertThat(ids, containsInAnyOrder(p1Id, c1Id, obs1Id)); + assertThat(ids, not(hasItem(o1Id))); + assertThat(ids, not(hasItem(m1Id))); + } + + @Test + public void testEverythingPatientTypeWithTypeParameter() { + String methodName = "testEverythingPatientTypeWithTypeParameter"; + + //Patient 1 stuff. + IIdType o1Id = createOrganization(methodName, "1"); + IIdType p1Id = createPatientWithIndexAtOrganization(methodName, "1", o1Id); + IIdType c1Id = createConditionForPatient(methodName, "1", p1Id); + IIdType obs1Id = createObservationForPatient(p1Id, "1"); + IIdType m1Id = createMedicationRequestForPatient(p1Id, "1"); + + //Test for only one patient + Parameters parameters = new Parameters(); + parameters.addParameter("_type", "Condition, Observation"); + + myCaptureQueriesListener.clear(); + + Parameters output = myClient.operation().onType(Patient.class).named("everything").withParameters(parameters).execute(); + ourLog.debug(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(output)); + Bundle b = (Bundle) output.getParameter().get(0).getResource(); + + myCaptureQueriesListener.logSelectQueries(); + + assertEquals(Bundle.BundleType.SEARCHSET, b.getType()); + List ids = toUnqualifiedVersionlessIds(b); + + assertThat(ids, containsInAnyOrder(p1Id, c1Id, obs1Id)); + assertThat(ids, not(hasItem(o1Id))); + assertThat(ids, not(hasItem(m1Id))); + } + + @Test + public void testEverythingPatientTypeWithTypeAndIdParameter() { + String methodName = "testEverythingPatientTypeWithTypeAndIdParameter"; + + //Patient 1 stuff. + IIdType o1Id = createOrganization(methodName, "1"); + IIdType p1Id = createPatientWithIndexAtOrganization(methodName, "1", o1Id); + IIdType c1Id = createConditionForPatient(methodName, "1", p1Id); + IIdType obs1Id = createObservationForPatient(p1Id, "1"); + IIdType m1Id = createMedicationRequestForPatient(p1Id, "1"); + + //Patient 2 stuff. + IIdType o2Id = createOrganization(methodName, "2"); + IIdType p2Id = createPatientWithIndexAtOrganization(methodName, "2", o2Id); + IIdType c2Id = createConditionForPatient(methodName, "2", p2Id); + IIdType obs2Id = createObservationForPatient(p2Id, "2"); + IIdType m2Id = createMedicationRequestForPatient(p2Id, "2"); + + //Test for only patient 1 + Parameters parameters = new Parameters(); + parameters.addParameter("_type", "Condition, Observation"); + parameters.addParameter("_id", p1Id.getIdPart()); + + myCaptureQueriesListener.clear(); + + Parameters output = myClient.operation().onType(Patient.class).named("everything").withParameters(parameters).execute(); + ourLog.debug(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(output)); + Bundle b = (Bundle) output.getParameter().get(0).getResource(); + + myCaptureQueriesListener.logSelectQueries(); + + assertEquals(Bundle.BundleType.SEARCHSET, b.getType()); + List ids = toUnqualifiedVersionlessIds(b); + + assertThat(ids, containsInAnyOrder(p1Id, c1Id, obs1Id)); + assertThat(ids, not(hasItem(o1Id))); + assertThat(ids, not(hasItem(m1Id))); + assertThat(ids, not(hasItem(p2Id))); + assertThat(ids, not(hasItem(o2Id))); + } + + @Test + public void testEverythingPatientWorksWithForcedId() { + String methodName = "testEverythingPatientType"; + + //Given + IIdType o1Id = createOrganization(methodName, "1"); + //Patient ABC stuff. + Patient patientABC = new Patient(); + patientABC.setId("abc"); + patientABC.setManagingOrganization(new Reference(o1Id)); + IIdType pabcId = myPatientDao.update(patientABC).getId().toUnqualifiedVersionless(); + IIdType c1Id = createConditionForPatient(methodName, "1", pabcId); + + //Patient DEF stuff. + IIdType o2Id = createOrganization(methodName, "2"); + Patient patientDEF = new Patient(); + patientDEF.setId("def"); + patientDEF.setManagingOrganization(new Reference(o2Id)); + IIdType pdefId = myPatientDao.update(patientDEF).getId().toUnqualifiedVersionless(); + IIdType c2Id = createConditionForPatient(methodName, "2", pdefId); + + IIdType c3Id = createConditionForPatient(methodName, "2", null); + + { + Parameters parameters = new Parameters(); + parameters.addParameter("_id", "Patient/abc,Patient/def"); + + //When + Parameters output = myClient.operation().onType(Patient.class).named("everything").withParameters(parameters).execute(); + Bundle b = (Bundle) output.getParameter().get(0).getResource(); + + //Then + assertEquals(Bundle.BundleType.SEARCHSET, b.getType()); + List ids = toUnqualifiedVersionlessIds(b); + assertThat(ids, containsInAnyOrder(o1Id, pabcId, c1Id, pdefId, o2Id, c2Id)); + assertThat(ids, not(hasItem(c3Id))); + } + + + } + + + // retest + @Test + public void testEverythingPatientWithLastUpdatedAndSort() throws Exception { + String methodName = "testEverythingWithLastUpdatedAndSort"; + + Organization org = new Organization(); + org.setName(methodName); + IIdType oId = myClient.create().resource(org).execute().getId().toUnqualifiedVersionless(); + + long time1 = System.currentTimeMillis(); + Thread.sleep(10); + + Patient p = new Patient(); + p.addName().setFamily(methodName); + p.getManagingOrganization().setReferenceElement(oId); + IIdType pId = myClient.create().resource(p).execute().getId().toUnqualifiedVersionless(); + + long time2 = System.currentTimeMillis(); + Thread.sleep(10); + + Condition c = new Condition(); + c.getCode().setText(methodName); + c.getSubject().setReferenceElement(pId); + IIdType cId = myClient.create().resource(c).execute().getId().toUnqualifiedVersionless(); + + ourLog.info("Resource IDs:\n * {}\n * {}\n * {}", oId, pId, cId); + runInTransaction(() -> { + ourLog.info("Resource Links:\n * {}", myResourceLinkDao.findAll().stream().map(t -> t.toString()).collect(Collectors.joining("\n * "))); + ourLog.info("Resources:\n * {}", myResourceTableDao.findAll().stream().map(t -> t.toString()).collect(Collectors.joining("\n * "))); + }); + + Thread.sleep(10); + long time3 = System.currentTimeMillis(); + + // %3E=> %3C=< + + myCaptureQueriesListener.clear(); + HttpGet get = new HttpGet(myServerBase + "/Patient/" + pId.getIdPart() + "/$everything?_lastUpdated=%3E" + new InstantType(new Date(time1)).getValueAsString()); + CloseableHttpResponse response = ourHttpClient.execute(get); + myCaptureQueriesListener.logSelectQueries(); + try { + assertEquals(200, response.getStatusLine().getStatusCode()); + String output = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); + response.getEntity().getContent().close(); + ourLog.info(output); + List ids = toUnqualifiedVersionlessIds(myFhirContext.newXmlParser().parseResource(Bundle.class, output)); + ourLog.info(ids.toString()); + assertThat(ids, containsInAnyOrder(pId, cId, oId)); + } finally { + response.close(); + } + + get = new HttpGet(myServerBase + "/Patient/" + pId.getIdPart() + "/$everything?_lastUpdated=%3E" + new InstantType(new Date(time2)).getValueAsString() + "&_lastUpdated=%3C" + + new InstantType(new Date(time3)).getValueAsString()); + response = ourHttpClient.execute(get); + try { + assertEquals(200, response.getStatusLine().getStatusCode()); + String output = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); + response.getEntity().getContent().close(); + ourLog.info(output); + List ids = toUnqualifiedVersionlessIds(myFhirContext.newXmlParser().parseResource(Bundle.class, output)); + ourLog.info(ids.toString()); + assertThat(ids, containsInAnyOrder(pId, cId, oId)); + } finally { + response.close(); + } + + /* + * Sorting is not working since the performance enhancements in 2.4 but + * sorting for lastupdated is non-standard anyhow.. Hopefully at some point + * we can bring this back + */ + // get = new HttpGet(ourServerBase + "/Patient/" + pId.getIdPart() + "/$everything?_lastUpdated=%3E" + new InstantType(new Date(time1)).getValueAsString() + "&_sort=_lastUpdated"); + // response = ourHttpClient.execute(get); + // try { + // assertEquals(200, response.getStatusLine().getStatusCode()); + // String output = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); + // response.getEntity().getContent().close(); + // ourLog.info(output); + // List ids = toUnqualifiedVersionlessIds(myFhirCtx.newXmlParser().parseResource(Bundle.class, output)); + // ourLog.info(ids.toString()); + // assertThat(ids, contains(pId, cId)); + // } finally { + // response.close(); + // } + // + // get = new HttpGet(ourServerBase + "/Patient/" + pId.getIdPart() + "/$everything?_sort:desc=_lastUpdated"); + // response = ourHttpClient.execute(get); + // try { + // assertEquals(200, response.getStatusLine().getStatusCode()); + // String output = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); + // response.getEntity().getContent().close(); + // ourLog.info(output); + // List ids = toUnqualifiedVersionlessIds(myFhirCtx.newXmlParser().parseResource(Bundle.class, output)); + // ourLog.info(ids.toString()); + // assertThat(ids, contains(cId, pId, oId)); + // } finally { + // response.close(); + // } + + } + + /** + * Per message from David Hay on Skype + */ + @Test + @Disabled + public void testEverythingWithLargeSet() throws Exception { + + String inputString = IOUtils.toString(getClass().getResourceAsStream("/david_big_bundle.json"), StandardCharsets.UTF_8); + Bundle inputBundle = myFhirContext.newJsonParser().parseResource(Bundle.class, inputString); + inputBundle.setType(Bundle.BundleType.TRANSACTION); + + assertEquals(53, inputBundle.getEntry().size()); + + Set allIds = new TreeSet<>(); + for (Bundle.BundleEntryComponent nextEntry : inputBundle.getEntry()) { + nextEntry.getRequest().setMethod(Bundle.HTTPVerb.PUT); + nextEntry.getRequest().setUrl(nextEntry.getResource().getId()); + allIds.add(nextEntry.getResource().getIdElement().toUnqualifiedVersionless().getValue()); + } + + assertEquals(53, allIds.size()); + + mySystemDao.transaction(mySrd, inputBundle); + + Bundle responseBundle = myClient + .operation() + .onInstance(new IdType("Patient/A161443")) + .named("everything") + .withParameter(Parameters.class, "_count", new IntegerType(20)) + .useHttpGet() + .returnResourceType(Bundle.class) + .execute(); + + ourLog.debug(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(responseBundle)); + + List ids = new ArrayList<>(); + for (Bundle.BundleEntryComponent nextEntry : responseBundle.getEntry()) { + ids.add(nextEntry.getResource().getIdElement().toUnqualifiedVersionless().getValue()); + } + Collections.sort(ids); + ourLog.info("{} ids: {}", ids.size(), ids); + + assertThat(responseBundle.getEntry().size(), lessThanOrEqualTo(25)); + + TreeSet idsSet = new TreeSet<>(); + for (int i = 0; i < responseBundle.getEntry().size(); i++) { + for (Bundle.BundleEntryComponent nextEntry : responseBundle.getEntry()) { + idsSet.add(nextEntry.getResource().getIdElement().toUnqualifiedVersionless().getValue()); + } + } + + String nextUrl = responseBundle.getLink("next").getUrl(); + responseBundle = myClient.fetchResourceFromUrl(Bundle.class, nextUrl); + for (int i = 0; i < responseBundle.getEntry().size(); i++) { + for (Bundle.BundleEntryComponent nextEntry : responseBundle.getEntry()) { + idsSet.add(nextEntry.getResource().getIdElement().toUnqualifiedVersionless().getValue()); + } + } + + nextUrl = responseBundle.getLink("next").getUrl(); + responseBundle = myClient.fetchResourceFromUrl(Bundle.class, nextUrl); + for (int i = 0; i < responseBundle.getEntry().size(); i++) { + for (Bundle.BundleEntryComponent nextEntry : responseBundle.getEntry()) { + idsSet.add(nextEntry.getResource().getIdElement().toUnqualifiedVersionless().getValue()); + } + } + + assertEquals(null, responseBundle.getLink("next")); + + assertThat(idsSet, hasItem("List/A161444")); + assertThat(idsSet, hasItem("List/A161468")); + assertThat(idsSet, hasItem("List/A161500")); + + ourLog.info("Expected {} - {}", allIds.size(), allIds); + ourLog.info("Actual {} - {}", idsSet.size(), idsSet); + assertEquals(allIds, idsSet); + + } + + /** + * Per message from David Hay on Skype + */ + @Test + public void testEverythingWithLargeSet2() { + myStorageSettings.setSearchPreFetchThresholds(Arrays.asList(15, 30, -1)); + myPagingProvider.setDefaultPageSize(500); + myPagingProvider.setMaximumPageSize(1000); + + Patient p = new Patient(); + p.setActive(true); + IIdType id = myClient.create().resource(p).execute().getId().toUnqualifiedVersionless(); + + for (int i = 1; i < LARGE_NUMBER; i++) { + Observation obs = new Observation(); + obs.setId("A" + StringUtils.leftPad(Integer.toString(i), 2, '0')); + obs.setSubject(new Reference(id)); + myClient.update().resource(obs).execute(); + } + + Bundle responseBundle = myClient + .operation() + .onInstance(id) + .named("everything") + .withParameter(Parameters.class, "_count", new IntegerType(50)) + .useHttpGet() + .returnResourceType(Bundle.class) + .execute(); + + ArrayList ids = new ArrayList<>(); + for (int i = 0; i < responseBundle.getEntry().size(); i++) { + Bundle.BundleEntryComponent nextEntry = responseBundle.getEntry().get(i); + ids.add(nextEntry.getResource().getIdElement().getIdPart()); + } + + Bundle.BundleLinkComponent nextLink = responseBundle.getLink("next"); + ourLog.info("Have {} IDs with next link[{}] : {}", ids.size(), nextLink.getUrl(), ids); + + while (nextLink != null) { + String nextUrl = nextLink.getUrl(); + responseBundle = myClient.fetchResourceFromUrl(Bundle.class, nextUrl); + for (int i = 0; i < responseBundle.getEntry().size(); i++) { + Bundle.BundleEntryComponent nextEntry = responseBundle.getEntry().get(i); + ids.add(nextEntry.getResource().getIdElement().getIdPart()); + } + + nextLink = responseBundle.getLink("next"); + if (nextLink == null) { + ourLog.info("Have {} IDs with no next link : {}", ids.size(), ids); + } else { + ourLog.info("Have {} IDs with next link[{}] : {}", ids.size(), nextLink.getUrl(), ids); + } + } + + assertThat(ids, hasItem(id.getIdPart())); + + // TODO KHS this fails intermittently with 53 instead of 77. + // This can happen if a previous test set mySearchCoordinatorSvcImpl.setSyncSizeForUnitTests to a lower value + assertEquals(LARGE_NUMBER, ids.size()); + for (int i = 1; i < LARGE_NUMBER; i++) { + assertThat(ids.size() + " ids: " + ids, ids, hasItem("A" + StringUtils.leftPad(Integer.toString(i), 2, '0'))); + } + } + + @Test + public void testEverythingWithOnlyPatient() { + Patient p = new Patient(); + p.setActive(true); + IIdType id = myClient.create().resource(p).execute().getId().toUnqualifiedVersionless(); + + myFhirContext.getRestfulClientFactory().setSocketTimeout(300 * 1000); + + Bundle response = myClient + .operation() + .onInstance(id) + .named("everything") + .withNoParameters(Parameters.class) + .returnResourceType(Bundle.class) + .execute(); + + assertEquals(1, response.getEntry().size()); + } + + @Test + public void testFulltextEverythingWithIdAndContent() throws IOException { + Patient p = new Patient(); + p.setId("FOO"); + p.addName().setFamily("FAMILY"); + myClient.update().resource(p).execute(); + + p = new Patient(); + p.setId("BAR"); + p.addName().setFamily("HELLO"); + myClient.update().resource(p).execute(); + + Observation o = new Observation(); + o.setId("BAZ"); + o.getSubject().setReference("Patient/FOO"); + o.getCode().setText("GOODBYE"); + myClient.update().resource(o).execute(); + + List ids = searchAndReturnUnqualifiedVersionlessIdValues(myServerBase + "/Patient/FOO/$everything?_content=White"); + assertThat(ids, contains("Patient/FOO")); + + ids = searchAndReturnUnqualifiedVersionlessIdValues(myServerBase + "/Patient/FOO/$everything?_content=HELLO"); + assertThat(ids, contains("Patient/FOO")); + + ids = searchAndReturnUnqualifiedVersionlessIdValues(myServerBase + "/Patient/FOO/$everything?_content=GOODBYE"); + assertThat(ids, containsInAnyOrder("Patient/FOO", "Observation/BAZ")); + } + + + @Test + public void testPagingOverEverythingSet() throws InterruptedException { + Patient p = new Patient(); + p.setActive(true); + String pid = myPatientDao.create(p).getId().toUnqualifiedVersionless().getValue(); + + for (int i = 0; i < 20; i++) { + Observation o = new Observation(); + o.getSubject().setReference(pid); + o.addIdentifier().setSystem("foo").setValue(Integer.toString(i)); + myObservationDao.create(o); + } + + mySearchCoordinatorSvcImpl.setLoadingThrottleForUnitTests(50); + mySearchCoordinatorSvcImpl.setSyncSizeForUnitTests(10); + mySearchCoordinatorSvcImpl.setNeverUseLocalSearchForUnitTests(true); + + Bundle response = myClient + .operation() + .onInstance(new IdType(pid)) + .named("everything") + .withSearchParameter(Parameters.class, "_count", new NumberParam(10)) + .returnResourceType(Bundle.class) + .useHttpGet() + .execute(); + + assertEquals(10, response.getEntry().size()); + if (response.getTotalElement().getValueAsString() != null) { + assertEquals("21", response.getTotalElement().getValueAsString()); + } + assertThat(response.getLink("next").getUrl(), not(emptyString())); + + // Load page 2 + + String nextUrl = response.getLink("next").getUrl(); + response = myClient.fetchResourceFromUrl(Bundle.class, nextUrl); + + assertEquals(10, response.getEntry().size()); + if (response.getTotalElement().getValueAsString() != null) { + assertEquals("21", response.getTotalElement().getValueAsString()); + } + assertThat(response.getLink("next").getUrl(), not(emptyString())); + + // Load page 3 + Thread.sleep(2000); + + nextUrl = response.getLink("next").getUrl(); + response = myClient.fetchResourceFromUrl(Bundle.class, nextUrl); + + assertEquals(1, response.getEntry().size()); + assertEquals("21", response.getTotalElement().getValueAsString()); + assertEquals(null, response.getLink("next")); + + } + + @Disabled + @Test + public void testEverythingWithNoPagingProvider() { + myServer.getRestfulServer().setPagingProvider(null); + + Patient p = new Patient(); + p.setActive(true); + String pid = myPatientDao.create(p).getId().toUnqualifiedVersionless().getValue(); + + for (int i = 0; i < 20; i++) { + Observation o = new Observation(); + o.getSubject().setReference(pid); + o.addIdentifier().setSystem("foo").setValue(Integer.toString(i)); + myObservationDao.create(o); + } + + mySearchCoordinatorSvcImpl.setLoadingThrottleForUnitTests(50); + mySearchCoordinatorSvcImpl.setSyncSizeForUnitTests(10); + mySearchCoordinatorSvcImpl.setNeverUseLocalSearchForUnitTests(true); + + Bundle response = myClient + .operation() + .onInstance(new IdType(pid)) + .named("everything") + .withSearchParameter(Parameters.class, "_count", new NumberParam(10)) + .returnResourceType(Bundle.class) + .useHttpGet() + .execute(); + + assertEquals(10, response.getEntry().size()); + assertEquals(null, response.getTotalElement().getValue()); + assertEquals(null, response.getLink("next")); + } + + @Test + public void testEverythingDoesNotEnterSecondPatient() { + Patient goodPatient = new Patient(); + goodPatient.setActive(true); + String goodPid = myPatientDao.create(goodPatient, mySrd).getId().toUnqualifiedVersionless().getValue(); + + Patient badPatient = new Patient(); + badPatient.setActive(true); + String badPid = myPatientDao.create(badPatient, mySrd).getId().toUnqualifiedVersionless().getValue(); + + Observation o = new Observation(); + o.getSubject().setReference(goodPid); + o.addIdentifier().setSystem("foo").setValue("1"); + String oid = myObservationDao.create(o, mySrd).getId().toUnqualifiedVersionless().getValue(); + + Provenance prov = new Provenance(); + prov.addTarget().setReference(goodPid); + prov.addTarget().setReference(badPid); + String provid = myProvenanceDao.create(prov, mySrd).getId().toUnqualifiedVersionless().getValue(); + + Bundle response = myClient + .operation() + .onInstance(new IdType(goodPid)) + .named("everything") + .withNoParameters(Parameters.class) + .returnResourceType(Bundle.class) + .execute(); + + List ids = toUnqualifiedVersionlessIdValues(response); + // We should not pick up other resources via the provenance + assertThat(ids, containsInAnyOrder(goodPid, oid, provid)); + } + + @Test + public void testIncludeRecurseFromProvenanceDoesTraverse() { + Patient goodPatient = new Patient(); + goodPatient.setActive(true); + String goodPid = myPatientDao.create(goodPatient, mySrd).getId().toUnqualifiedVersionless().getValue(); + + Practitioner prac = new Practitioner(); + prac.addName().setFamily("FAM"); + String pracid = myPractitionerDao.create(prac, mySrd).getId().toUnqualifiedVersionless().getValue(); + + Patient otherPatient = new Patient(); + otherPatient.setActive(true); + otherPatient.addGeneralPractitioner().setReference(pracid); + String otherPid = myPatientDao.create(otherPatient, mySrd).getId().toUnqualifiedVersionless().getValue(); + + Provenance prov = new Provenance(); + prov.addTarget().setReference(goodPid); + prov.addTarget().setReference(otherPid); + String provid = myProvenanceDao.create(prov, mySrd).getId().toUnqualifiedVersionless().getValue(); + + Bundle response = myClient + .search() + .forResource("Provenance") + .where(Provenance.TARGET.hasId(goodPid)) + .include(new Include("*", true)) + .returnBundle(Bundle.class) + .execute(); + + List ids = toUnqualifiedVersionlessIdValues(response); + // We should not pick up other resources via the provenance + assertThat(ids, containsInAnyOrder(goodPid, otherPid, pracid, provid)); + } + + @Test + public void testEverythingDoesNotEnterSecondPatientLinkedByProvenanceAndComposition() { + final Patient desiredPatient = new Patient(); + desiredPatient.setActive(true); + final String desiredPid = myPatientDao.create(desiredPatient, mySrd).getId().toUnqualifiedVersionless().getValue(); + + final Patient notDesiredPatient = new Patient(); + desiredPatient.setActive(true); + final String notDesiredPid = myPatientDao.create(notDesiredPatient, mySrd).getId().toUnqualifiedVersionless().getValue(); + + final Observation desiredObservation = new Observation(); + desiredObservation.getSubject().setReference(desiredPid); + desiredObservation.addIdentifier().setSystem("foo").setValue("1"); + final String desiredObservationId = myObservationDao.create(desiredObservation, mySrd).getId().toUnqualifiedVersionless().getValue(); + + final Observation notDesiredObservation = new Observation(); + notDesiredObservation.getSubject().setReference(notDesiredPid); + notDesiredObservation.addIdentifier().setSystem("foo").setValue("1"); + final String notDesiredObservationId = myObservationDao.create(notDesiredObservation, mySrd).getId().toUnqualifiedVersionless().getValue(); + + final Composition composition = new Composition(); + final Reference referenceToNotDesiredPatient = new Reference(); + referenceToNotDesiredPatient.setReference(notDesiredPid); + composition.setSubject(referenceToNotDesiredPatient); + final String compositionId = myCompositionDao.create(composition, mySrd).getId().toUnqualifiedVersionless().getValue(); + + final Provenance desiredProvenance = new Provenance(); + desiredProvenance.addTarget().setReference(desiredPid); + desiredProvenance.addTarget().setReference(compositionId); + final String desiredProvenanceId = myProvenanceDao.create(desiredProvenance, mySrd).getId().toUnqualifiedVersionless().getValue(); + + final Provenance notDesiredProvenance = new Provenance(); + notDesiredProvenance.addTarget().setReference(notDesiredPid); + notDesiredProvenance.addTarget().setReference(compositionId); + final String notDesiredProvenanceId = myProvenanceDao.create(notDesiredProvenance, mySrd).getId().toUnqualifiedVersionless().getValue(); + + final Bundle response = myClient + .operation() + .onInstance(new IdType(desiredPid)) + .named("everything") + .withNoParameters(Parameters.class) + .returnResourceType(Bundle.class) + .execute(); + + final List actualResourceIds = toUnqualifiedVersionlessIdValues(response); + // We should not pick up other resources via the notDesiredProvenance + assertThat(actualResourceIds, containsInAnyOrder(desiredPid, desiredObservationId, desiredProvenanceId)); + } + + private IIdType createOrganization(String methodName, String s) { + Organization o1 = new Organization(); + o1.setName(methodName + s); + return myClient.create().resource(o1).execute().getId().toUnqualifiedVersionless(); + } + + public IIdType createPatientWithIndexAtOrganization(String theMethodName, String theIndex, IIdType theOrganizationId) { + Patient p1 = new Patient(); + p1.addName().setFamily(theMethodName + theIndex); + p1.getManagingOrganization().setReferenceElement(theOrganizationId); + IIdType p1Id = myClient.create().resource(p1).execute().getId().toUnqualifiedVersionless(); + return p1Id; + } + + public IIdType createConditionForPatient(String theMethodName, String theIndex, IIdType thePatientId) { + Condition c = new Condition(); + c.addIdentifier().setValue(theMethodName + theIndex); + if (thePatientId != null) { + c.getSubject().setReferenceElement(thePatientId); + } + IIdType cId = myClient.create().resource(c).execute().getId().toUnqualifiedVersionless(); + return cId; + } + + private IIdType createMedicationRequestForPatient(IIdType thePatientId, String theIndex) { + MedicationRequest m = new MedicationRequest(); + m.addIdentifier().setValue(theIndex); + if (thePatientId != null) { + m.getSubject().setReferenceElement(thePatientId); + } + IIdType mId = myClient.create().resource(m).execute().getId().toUnqualifiedVersionless(); + return mId; + } + + private IIdType createObservationForPatient(IIdType thePatientId, String theIndex) { + Observation o = new Observation(); + o.addIdentifier().setValue(theIndex); + if (thePatientId != null) { + o.getSubject().setReferenceElement(thePatientId); + } + IIdType oId = myClient.create().resource(o).execute().getId().toUnqualifiedVersionless(); + return oId; + } +} diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4SearchContainedTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4SearchContainedTest.java index 362fd24b7d7..be955c3c401 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4SearchContainedTest.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4SearchContainedTest.java @@ -988,7 +988,7 @@ public class ResourceProviderR4SearchContainedTest extends BaseResourceProviderR } - private List searchAndReturnUnqualifiedVersionlessIdValues(String uri) throws IOException { + public List searchAndReturnUnqualifiedVersionlessIdValues(String uri) throws IOException { List ids; HttpGet get = new HttpGet(uri); diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4Test.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4Test.java index 4e62135724c..07c877c54aa 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4Test.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4Test.java @@ -3,7 +3,6 @@ package ca.uhn.fhir.jpa.provider.r4; import ca.uhn.fhir.i18n.HapiLocalizer; import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.jpa.api.config.JpaStorageSettings; -import ca.uhn.fhir.jpa.api.model.DaoMethodOutcome; import ca.uhn.fhir.jpa.dao.data.ISearchDao; import ca.uhn.fhir.jpa.entity.Search; import ca.uhn.fhir.jpa.model.entity.NormalizedQuantitySearchLevel; @@ -16,7 +15,6 @@ import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.jpa.term.ZipCollectionBuilder; import ca.uhn.fhir.jpa.test.config.TestR4Config; import ca.uhn.fhir.jpa.util.QueryParameterUtils; -import ca.uhn.fhir.model.api.Include; import ca.uhn.fhir.model.api.StorageResponseCodeEnum; import ca.uhn.fhir.model.api.TemporalPrecisionEnum; import ca.uhn.fhir.model.primitive.IdDt; @@ -29,7 +27,6 @@ import ca.uhn.fhir.rest.api.MethodOutcome; import ca.uhn.fhir.rest.api.PreferReturnEnum; import ca.uhn.fhir.rest.api.SearchTotalModeEnum; import ca.uhn.fhir.rest.api.SummaryEnum; -import ca.uhn.fhir.rest.api.server.SystemRequestDetails; import ca.uhn.fhir.rest.client.apache.ResourceEntity; import ca.uhn.fhir.rest.client.api.IClientInterceptor; import ca.uhn.fhir.rest.client.api.IGenericClient; @@ -40,11 +37,7 @@ import ca.uhn.fhir.rest.gclient.ICriterion; import ca.uhn.fhir.rest.gclient.NumberClientParam; import ca.uhn.fhir.rest.gclient.StringClientParam; import ca.uhn.fhir.rest.param.DateRangeParam; -import ca.uhn.fhir.rest.param.NumberParam; import ca.uhn.fhir.rest.param.ParamPrefixEnum; -import ca.uhn.fhir.rest.param.StringAndListParam; -import ca.uhn.fhir.rest.param.StringOrListParam; -import ca.uhn.fhir.rest.param.StringParam; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException; @@ -90,7 +83,6 @@ import org.hl7.fhir.r4.model.Binary; import org.hl7.fhir.r4.model.BooleanType; import org.hl7.fhir.r4.model.Bundle; import org.hl7.fhir.r4.model.Bundle.BundleEntryComponent; -import org.hl7.fhir.r4.model.Bundle.BundleLinkComponent; import org.hl7.fhir.r4.model.Bundle.BundleType; import org.hl7.fhir.r4.model.Bundle.HTTPVerb; import org.hl7.fhir.r4.model.Bundle.SearchEntryMode; @@ -99,9 +91,7 @@ import org.hl7.fhir.r4.model.CodeSystem; import org.hl7.fhir.r4.model.CodeType; import org.hl7.fhir.r4.model.CodeableConcept; import org.hl7.fhir.r4.model.Coding; -import org.hl7.fhir.r4.model.Composition; import org.hl7.fhir.r4.model.ConceptMap; -import org.hl7.fhir.r4.model.Condition; import org.hl7.fhir.r4.model.Coverage; import org.hl7.fhir.r4.model.DateTimeType; import org.hl7.fhir.r4.model.DateType; @@ -120,7 +110,6 @@ import org.hl7.fhir.r4.model.Group; import org.hl7.fhir.r4.model.IdType; import org.hl7.fhir.r4.model.ImagingStudy; import org.hl7.fhir.r4.model.InstantType; -import org.hl7.fhir.r4.model.IntegerType; import org.hl7.fhir.r4.model.Location; import org.hl7.fhir.r4.model.Media; import org.hl7.fhir.r4.model.Medication; @@ -140,7 +129,6 @@ import org.hl7.fhir.r4.model.Patient; import org.hl7.fhir.r4.model.Period; import org.hl7.fhir.r4.model.Practitioner; import org.hl7.fhir.r4.model.Procedure; -import org.hl7.fhir.r4.model.Provenance; import org.hl7.fhir.r4.model.Quantity; import org.hl7.fhir.r4.model.Questionnaire; import org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType; @@ -154,9 +142,9 @@ import org.hl7.fhir.r4.model.StructureDefinition; import org.hl7.fhir.r4.model.Subscription; import org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType; import org.hl7.fhir.r4.model.Subscription.SubscriptionStatus; -import org.hl7.fhir.r4.model.UnsignedIntType; import org.hl7.fhir.r4.model.UriType; import org.hl7.fhir.r4.model.ValueSet; +import org.hl7.fhir.utilities.xhtml.NodeType; import org.hl7.fhir.utilities.xhtml.XhtmlNode; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; @@ -191,7 +179,6 @@ import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Set; -import java.util.TreeSet; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -207,7 +194,6 @@ import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.containsInRelativeOrder; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.empty; -import static org.hamcrest.Matchers.emptyString; import static org.hamcrest.Matchers.endsWith; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.greaterThan; @@ -216,7 +202,6 @@ import static org.hamcrest.Matchers.hasItems; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.lessThan; -import static org.hamcrest.Matchers.lessThanOrEqualTo; import static org.hamcrest.Matchers.matchesPattern; import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.startsWith; @@ -231,8 +216,6 @@ import static org.junit.jupiter.api.Assertions.fail; @SuppressWarnings("Duplicates") public class ResourceProviderR4Test extends BaseResourceProviderR4Test { - - public static final int LARGE_NUMBER = 77; private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResourceProviderR4Test.class); private SearchCoordinatorSvcImpl mySearchCoordinatorSvcRaw; private CapturingInterceptor myCapturingInterceptor = new CapturingInterceptor(); @@ -764,7 +747,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { } @Test - public void testUpdateResourceAfterReadOperationAndNoChangesShouldNotChangeVersion(){ + public void testUpdateResourceAfterReadOperationAndNoChangesShouldNotChangeVersion() { // Create Patient Patient patient = new Patient(); patient.getText().setDivAsString("
hello
"); @@ -899,21 +882,6 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { return ids; } - private List searchAndReturnUnqualifiedVersionlessIdValues(String uri) throws IOException { - List ids; - HttpGet get = new HttpGet(uri); - - try (CloseableHttpResponse response = ourHttpClient.execute(get)) { - String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); - ourLog.info(resp); - Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, resp); - ids = toUnqualifiedVersionlessIdValues(bundle); - ourLog.debug("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); - } - - return ids; - } - @Test @Disabled public void testMakingQuery() throws IOException { @@ -1254,18 +1222,22 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { } @Test - @Disabled - public void testCreateQuestionnaireResponseWithValidation() { + public void testCreateQuestionnaireResponseWithValidation() throws IOException { CodeSystem cs = new CodeSystem(); - cs.setUrl("http://urn/system"); + cs.setUrl("http://cs"); + cs.setStatus(Enumerations.PublicationStatus.ACTIVE); + cs.setContent(CodeSystem.CodeSystemContentMode.COMPLETE); cs.addConcept().setCode("code0"); myClient.create().resource(cs).execute(); ValueSet options = new ValueSet(); - options.getCompose().addInclude().setSystem("http://urn/system"); - IIdType optId = myClient.create().resource(options).execute().getId(); + options.setStatus(Enumerations.PublicationStatus.ACTIVE); + options.setUrl("http://vs"); + options.getCompose().addInclude().setSystem("http://cs"); + IIdType optId = myClient.create().resource(options).execute().getId().toUnqualifiedVersionless(); Questionnaire q = new Questionnaire(); + q.setUrl("http://urn/questionnaire"); q.addItem().setLinkId("link0").setRequired(false).setType(QuestionnaireItemType.CHOICE).setAnswerValueSet((optId.getValue())); IIdType qId = myClient.create().resource(q).execute().getId(); @@ -1274,20 +1246,40 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { // Good code qa = new QuestionnaireResponse(); - qa.setQuestionnaire(qId.toUnqualifiedVersionless().getValue()); - qa.addItem().setLinkId("link0").addAnswer().setValue(new Coding().setSystem("urn:system").setCode("code0")); - myClient.create().resource(qa).execute(); + qa.setStatus(QuestionnaireResponse.QuestionnaireResponseStatus.COMPLETED); + qa.setText(new Narrative().setStatus(NarrativeStatus.ADDITIONAL).setDiv(new XhtmlNode(NodeType.Element).addText("foo"))); + qa.setQuestionnaire(q.getUrl()); + qa.addItem().setLinkId("link0").addAnswer().setValue(new Coding().setSystem("http://cs").setCode("code0")); + + MethodOutcome result = myClient.validate().resource(qa).execute(); + + OperationOutcome oo = (OperationOutcome) result.getOperationOutcome(); + + assertThat(oo.getIssue(), hasSize(1)); + OperationOutcome.OperationOutcomeIssueComponent firstIssue = oo.getIssue().get(0); + assertEquals(OperationOutcome.IssueSeverity.INFORMATION, firstIssue.getSeverity()); + assertEquals("No issues detected during validation", firstIssue.getDiagnostics()); + + assertEquals(200, result.getResponseStatusCode()); // Bad code qa = new QuestionnaireResponse(); - qa.setQuestionnaire(qId.toUnqualifiedVersionless().getValue()); - qa.addItem().setLinkId("link0").addAnswer().setValue(new Coding().setSystem("urn:system").setCode("code1")); + qa.setStatus(QuestionnaireResponse.QuestionnaireResponseStatus.COMPLETED); + qa.setText(new Narrative().setStatus(NarrativeStatus.ADDITIONAL).setDiv(new XhtmlNode(NodeType.Element).addText("foo"))); + qa.setQuestionnaire(q.getUrl()); + qa.addItem().setLinkId("link0").addAnswer().setValue(new Coding().setSystem("http://cs").setCode("code1")); + try { - myClient.create().resource(qa).execute(); - fail(); - } catch (UnprocessableEntityException e) { - assertThat(e.getMessage(), containsString("Question with linkId[link0]")); + myClient.validate().resource(qa).execute(); + } catch (PreconditionFailedException e) { + oo = (OperationOutcome) e.getOperationOutcome(); + assertThat(oo.getIssue(), hasSize(2)); + + for (OperationOutcome.OperationOutcomeIssueComponent next : oo.getIssue()) { + assertEquals(OperationOutcome.IssueSeverity.ERROR, next.getSeverity()); + assertThat(next.getDiagnostics(), containsString("code1")); + } } } @@ -1733,7 +1725,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { } @Test - @Disabled + @Disabled("Scratchpad for ad-hoc testing") public void testQuery() throws IOException { ourLog.info("** Performing Search"); HttpGet read = new HttpGet(myServerBase + "/MedicationRequest?category=community&identifier=urn:oid:2.16.840.1.113883.3.7418.12.3%7C&intent=order&medication.code:text=calcitriol,hectorol,Zemplar,rocaltrol,vectical,vitamin%20D,doxercalciferol,paricalcitol&status=active,completed"); @@ -1989,500 +1981,6 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { } - @Test - public void testEverythingEncounterInstance() { - String methodName = "testEverythingEncounterInstance"; - - Organization org1parent = new Organization(); - org1parent.setId("org1parent"); - org1parent.setName(methodName + "1parent"); - IIdType orgId1parent = myClient.update().resource(org1parent).execute().getId().toUnqualifiedVersionless(); - - Organization org1 = new Organization(); - org1.setName(methodName + "1"); - org1.getPartOf().setReferenceElement(orgId1parent); - IIdType orgId1 = myClient.create().resource(org1).execute().getId().toUnqualifiedVersionless(); - - Patient p = new Patient(); - p.addName().setFamily(methodName); - p.getManagingOrganization().setReferenceElement(orgId1); - IIdType patientId = myClient.create().resource(p).execute().getId().toUnqualifiedVersionless(); - - IIdType orgId2 = createOrganization(methodName, "1"); - - Device dev = new Device(); - dev.setManufacturer(methodName); - dev.getOwner().setReferenceElement(orgId2); - IIdType devId = myClient.create().resource(dev).execute().getId().toUnqualifiedVersionless(); - - Location locParent = new Location(); - locParent.setName(methodName + "Parent"); - IIdType locPId = myClient.create().resource(locParent).execute().getId().toUnqualifiedVersionless(); - - Location locChild = new Location(); - locChild.setName(methodName); - locChild.getPartOf().setReferenceElement(locPId); - IIdType locCId = myClient.create().resource(locChild).execute().getId().toUnqualifiedVersionless(); - - Encounter encU = new Encounter(); - encU.getSubject().setReferenceElement(patientId); - encU.addLocation().getLocation().setReferenceElement(locCId); - IIdType encUId = myClient.create().resource(encU).execute().getId().toUnqualifiedVersionless(); - - Encounter enc = new Encounter(); - enc.getSubject().setReferenceElement(patientId); - enc.addLocation().getLocation().setReferenceElement(locCId); - IIdType encId = myClient.create().resource(enc).execute().getId().toUnqualifiedVersionless(); - - Observation obs = new Observation(); - obs.getSubject().setReferenceElement(patientId); - obs.getDevice().setReferenceElement(devId); - obs.getEncounter().setReferenceElement(encId); - IIdType obsId = myClient.create().resource(obs).execute().getId().toUnqualifiedVersionless(); - - ourLog.info("IDs: EncU:" + encUId.getIdPart() + " Enc:" + encId.getIdPart() + " " + patientId.toUnqualifiedVersionless()); - - Parameters output = myClient.operation().onInstance(encId).named("everything").withNoParameters(Parameters.class).execute(); - Bundle b = (Bundle) output.getParameter().get(0).getResource(); - List ids = toUnqualifiedVersionlessIds(b); - assertThat(ids, containsInAnyOrder(patientId, encId, orgId1, orgId2, orgId1parent, locPId, locCId, obsId, devId)); - assertThat(ids, not(containsInRelativeOrder(encUId))); - - ourLog.info(ids.toString()); - } - - @Test - public void testEverythingEncounterType() { - String methodName = "testEverythingEncounterInstance"; - - Organization org1parent = new Organization(); - org1parent.setId("org1parent"); - org1parent.setName(methodName + "1parent"); - IIdType orgId1parent = myClient.update().resource(org1parent).execute().getId().toUnqualifiedVersionless(); - - Organization org1 = new Organization(); - org1.setName(methodName + "1"); - org1.getPartOf().setReferenceElement(orgId1parent); - IIdType orgId1 = myClient.create().resource(org1).execute().getId().toUnqualifiedVersionless(); - - Patient p = new Patient(); - p.addName().setFamily(methodName); - p.getManagingOrganization().setReferenceElement(orgId1); - IIdType patientId = myClient.create().resource(p).execute().getId().toUnqualifiedVersionless(); - - IIdType orgId2 = createOrganization(methodName, "1"); - - Device dev = new Device(); - dev.setManufacturer(methodName); - dev.getOwner().setReferenceElement(orgId2); - IIdType devId = myClient.create().resource(dev).execute().getId().toUnqualifiedVersionless(); - - Location locParent = new Location(); - locParent.setName(methodName + "Parent"); - IIdType locPId = myClient.create().resource(locParent).execute().getId().toUnqualifiedVersionless(); - - Location locChild = new Location(); - locChild.setName(methodName); - locChild.getPartOf().setReferenceElement(locPId); - IIdType locCId = myClient.create().resource(locChild).execute().getId().toUnqualifiedVersionless(); - - Encounter encU = new Encounter(); - encU.addIdentifier().setValue(methodName); - IIdType encUId = myClient.create().resource(encU).execute().getId().toUnqualifiedVersionless(); - - Encounter enc = new Encounter(); - enc.getSubject().setReferenceElement(patientId); - enc.addLocation().getLocation().setReferenceElement(locCId); - IIdType encId = myClient.create().resource(enc).execute().getId().toUnqualifiedVersionless(); - - Observation obs = new Observation(); - obs.getSubject().setReferenceElement(patientId); - obs.getDevice().setReferenceElement(devId); - obs.getEncounter().setReferenceElement(encId); - IIdType obsId = myClient.create().resource(obs).execute().getId().toUnqualifiedVersionless(); - - Parameters output = myClient.operation().onType(Encounter.class).named("everything").withNoParameters(Parameters.class).execute(); - Bundle b = (Bundle) output.getParameter().get(0).getResource(); - List ids = toUnqualifiedVersionlessIds(b); - assertThat(ids, containsInAnyOrder(patientId, encUId, encId, orgId1, orgId2, orgId1parent, locPId, locCId, obsId, devId)); - - ourLog.info(ids.toString()); - } - - @Test - public void testEverythingInstanceWithContentFilter() { - Patient pt1 = new Patient(); - pt1.addName().setFamily("Everything").addGiven("Arthur"); - IIdType ptId1 = myPatientDao.create(pt1, mySrd).getId().toUnqualifiedVersionless(); - - Patient pt2 = new Patient(); - pt2.addName().setFamily("Everything").addGiven("Arthur"); - IIdType ptId2 = myPatientDao.create(pt2, mySrd).getId().toUnqualifiedVersionless(); - - Device dev1 = new Device(); - dev1.setManufacturer("Some Manufacturer"); - IIdType devId1 = myDeviceDao.create(dev1, mySrd).getId().toUnqualifiedVersionless(); - - Device dev2 = new Device(); - dev2.setManufacturer("Some Manufacturer 2"); - myDeviceDao.create(dev2, mySrd).getId().toUnqualifiedVersionless(); - - Observation obs1 = new Observation(); - obs1.getText().setDivAsString("
OBSTEXT1
"); - obs1.getSubject().setReferenceElement(ptId1); - obs1.getCode().addCoding().setCode("CODE1"); - obs1.setValue(new StringType("obsvalue1")); - obs1.getDevice().setReferenceElement(devId1); - IIdType obsId1 = myObservationDao.create(obs1, mySrd).getId().toUnqualifiedVersionless(); - - Observation obs2 = new Observation(); - obs2.getSubject().setReferenceElement(ptId1); - obs2.getCode().addCoding().setCode("CODE2"); - obs2.setValue(new StringType("obsvalue2")); - IIdType obsId2 = myObservationDao.create(obs2, mySrd).getId().toUnqualifiedVersionless(); - - Observation obs3 = new Observation(); - obs3.getSubject().setReferenceElement(ptId2); - obs3.getCode().addCoding().setCode("CODE3"); - obs3.setValue(new StringType("obsvalue3")); - IIdType obsId3 = myObservationDao.create(obs3, mySrd).getId().toUnqualifiedVersionless(); - - List actual; - StringAndListParam param; - - ourLog.info("Pt1:{} Pt2:{} Obs1:{} Obs2:{} Obs3:{}", ptId1.getIdPart(), ptId2.getIdPart(), obsId1.getIdPart(), obsId2.getIdPart(), obsId3.getIdPart()); - - param = new StringAndListParam(); - param.addAnd(new StringOrListParam().addOr(new StringParam("obsvalue1"))); - - //@formatter:off - Parameters response = myClient - .operation() - .onInstance(ptId1) - .named("everything") - .withParameter(Parameters.class, Constants.PARAM_CONTENT, new StringType("obsvalue1")) - .execute(); - //@formatter:on - - actual = toUnqualifiedVersionlessIds((Bundle) response.getParameter().get(0).getResource()); - assertThat(actual, containsInAnyOrder(ptId1, obsId1, devId1)); - - } - - /** - * See #147 - */ - @Test - public void testEverythingPatientDoesntRepeatPatient() { - Bundle b; - IParser parser = myFhirContext.newJsonParser(); - b = parser.parseResource(Bundle.class, new InputStreamReader(ResourceProviderR4Test.class.getResourceAsStream("/r4/bug147-bundle.json"))); - - Bundle resp = myClient.transaction().withBundle(b).execute(); - List ids = new ArrayList<>(); - for (BundleEntryComponent next : resp.getEntry()) { - IdType toAdd = new IdType(next.getResponse().getLocation()).toUnqualifiedVersionless(); - ids.add(toAdd); - } - ourLog.info("Created: " + ids.toString()); - - IdType patientId = new IdType(resp.getEntry().get(0).getResponse().getLocation()); - assertEquals("Patient", patientId.getResourceType()); - - { - Parameters output = myClient.operation().onInstance(patientId).named("everything").withNoParameters(Parameters.class).execute(); - b = (Bundle) output.getParameter().get(0).getResource(); - - ids = new ArrayList<>(); - boolean dupes = false; - for (BundleEntryComponent next : b.getEntry()) { - IdType toAdd = next.getResource().getIdElement().toUnqualifiedVersionless(); - dupes = dupes | ids.contains(toAdd); - ids.add(toAdd); - } - ourLog.info("$everything: " + ids.toString()); - - assertFalse(dupes, ids.toString()); - } - - /* - * Now try with a size specified - */ - { - Parameters input = new Parameters(); - input.addParameter().setName(Constants.PARAM_COUNT).setValue(new UnsignedIntType(100)); - Parameters output = myClient.operation().onInstance(patientId).named("everything").withParameters(input).execute(); - b = (Bundle) output.getParameter().get(0).getResource(); - - ids = new ArrayList<>(); - boolean dupes = false; - for (BundleEntryComponent next : b.getEntry()) { - IdType toAdd = next.getResource().getIdElement().toUnqualifiedVersionless(); - dupes = dupes | ids.contains(toAdd); - ids.add(toAdd); - } - ourLog.info("$everything: " + ids.toString()); - - assertFalse(dupes, ids.toString()); - assertThat(ids.toString(), containsString("Condition")); - assertThat(ids.size(), greaterThan(10)); - } - } - - /** - * Test for #226 - */ - @Test - public void testEverythingPatientIncludesBackReferences() { - String methodName = "testEverythingIncludesBackReferences"; - - Medication med = new Medication(); - med.getCode().setText(methodName); - IIdType medId = myMedicationDao.create(med, mySrd).getId().toUnqualifiedVersionless(); - - Patient pat = new Patient(); - pat.addAddress().addLine(methodName); - IIdType patId = myPatientDao.create(pat, mySrd).getId().toUnqualifiedVersionless(); - - MedicationRequest mo = new MedicationRequest(); - mo.getSubject().setReferenceElement(patId); - mo.setMedication(new Reference(medId)); - IIdType moId = myMedicationRequestDao.create(mo, mySrd).getId().toUnqualifiedVersionless(); - - Parameters output = myClient.operation().onInstance(patId).named("everything").withNoParameters(Parameters.class).execute(); - Bundle b = (Bundle) output.getParameter().get(0).getResource(); - List ids = toUnqualifiedVersionlessIds(b); - ourLog.info(ids.toString()); - assertThat(ids, containsInAnyOrder(patId, medId, moId)); - } - - /** - * See #148 - */ - @Test - public void testEverythingPatientIncludesCondition() { - Bundle b = new Bundle(); - Patient p = new Patient(); - p.setId("1"); - b.addEntry().setResource(p).getRequest().setMethod(HTTPVerb.POST); - - Condition c = new Condition(); - c.getSubject().setReference("Patient/1"); - b.addEntry().setResource(c).getRequest().setMethod(HTTPVerb.POST); - - Bundle resp = myClient.transaction().withBundle(b).execute(); - - ourLog.debug(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(resp)); - - IdType patientId = new IdType(resp.getEntry().get(0).getResponse().getLocation()); - assertEquals("Patient", patientId.getResourceType()); - - Parameters output = myClient.operation().onInstance(patientId).named("everything").withNoParameters(Parameters.class).execute(); - b = (Bundle) output.getParameter().get(0).getResource(); - - List ids = new ArrayList<>(); - for (BundleEntryComponent next : b.getEntry()) { - IdType toAdd = next.getResource().getIdElement().toUnqualifiedVersionless(); - ids.add(toAdd); - } - - assertThat(ids.toString(), containsString("Patient/")); - assertThat(ids.toString(), containsString("Condition/")); - - } - - @Test - public void testEverythingPatientOperation() { - String methodName = "testEverythingOperation"; - - Organization org1parent = new Organization(); - org1parent.setId("org1parent"); - org1parent.setName(methodName + "1parent"); - IIdType orgId1parent = myClient.update().resource(org1parent).execute().getId().toUnqualifiedVersionless(); - - Organization org1 = new Organization(); - org1.setName(methodName + "1"); - org1.getPartOf().setReferenceElement(orgId1parent); - IIdType orgId1 = myClient.create().resource(org1).execute().getId().toUnqualifiedVersionless(); - - Patient p = new Patient(); - p.addName().setFamily(methodName); - p.getManagingOrganization().setReferenceElement(orgId1); - IIdType patientId = myClient.create().resource(p).execute().getId().toUnqualifiedVersionless(); - - IIdType orgId2 = createOrganization(methodName, "1"); - - Device dev = new Device(); - dev.setManufacturer(methodName); - dev.getOwner().setReferenceElement(orgId2); - IIdType devId = myClient.create().resource(dev).execute().getId().toUnqualifiedVersionless(); - - Observation obs = new Observation(); - obs.getSubject().setReferenceElement(patientId); - obs.getDevice().setReferenceElement(devId); - IIdType obsId = myClient.create().resource(obs).execute().getId().toUnqualifiedVersionless(); - - Encounter enc = new Encounter(); - enc.getSubject().setReferenceElement(patientId); - IIdType encId = myClient.create().resource(enc).execute().getId().toUnqualifiedVersionless(); - - Parameters output = myClient.operation().onInstance(patientId).named("everything").withNoParameters(Parameters.class).execute(); - Bundle b = (Bundle) output.getParameter().get(0).getResource(); - List ids = toUnqualifiedVersionlessIds(b); - assertThat(ids, containsInAnyOrder(patientId, devId, obsId, encId, orgId1, orgId2, orgId1parent)); - - ourLog.info(ids.toString()); - } - - @Test - public void testEverythingPatientType() { - String methodName = "testEverythingPatientType"; - - IIdType o1Id = createOrganization(methodName, "1"); - IIdType o2Id = createOrganization(methodName, "2"); - - IIdType p1Id = createPatientWithIndexAtOrganization(methodName, "1", o1Id); - IIdType c1Id = createConditionForPatient(methodName, "1", p1Id); - - IIdType p2Id = createPatientWithIndexAtOrganization(methodName, "2", o2Id); - IIdType c2Id = createConditionForPatient(methodName, "2", p2Id); - - IIdType c3Id = createConditionForPatient(methodName, "3", null); - - Parameters output = myClient.operation().onType(Patient.class).named("everything").withNoParameters(Parameters.class).execute(); - Bundle b = (Bundle) output.getParameter().get(0).getResource(); - - assertEquals(BundleType.SEARCHSET, b.getType()); - List ids = toUnqualifiedVersionlessIds(b); - - assertThat(ids, containsInAnyOrder(o1Id, o2Id, p1Id, p2Id, c1Id, c2Id)); - assertThat(ids, not(containsInRelativeOrder(c3Id))); - } - - @Test - public void testEverythingPatientTypeWithIdParameter() { - String methodName = "testEverythingPatientTypeWithIdParameter"; - - //Patient 1 stuff. - IIdType o1Id = createOrganization(methodName, "1"); - IIdType p1Id = createPatientWithIndexAtOrganization(methodName, "1", o1Id); - IIdType c1Id = createConditionForPatient(methodName, "1", p1Id); - - //Patient 2 stuff. - IIdType o2Id = createOrganization(methodName, "2"); - IIdType p2Id = createPatientWithIndexAtOrganization(methodName, "2", o2Id); - IIdType c2Id = createConditionForPatient(methodName, "2", p2Id); - - //Patient 3 stuff. - IIdType o3Id = createOrganization(methodName, "3"); - IIdType p3Id = createPatientWithIndexAtOrganization(methodName, "3", o3Id); - IIdType c3Id = createConditionForPatient(methodName, "3", p3Id); - - //Patient 4 stuff. - IIdType o4Id = createOrganization(methodName, "4"); - IIdType p4Id = createPatientWithIndexAtOrganization(methodName, "4", o4Id); - IIdType c4Id = createConditionForPatient(methodName, "4", p4Id); - - //No Patient Stuff - IIdType c5Id = createConditionForPatient(methodName, "4", null); - - - { - //Test for only one patient - Parameters parameters = new Parameters(); - parameters.addParameter("_id", p1Id.getIdPart()); - - Parameters output = myClient.operation().onType(Patient.class).named("everything").withParameters(parameters).execute(); - Bundle b = (Bundle) output.getParameter().get(0).getResource(); - - assertEquals(BundleType.SEARCHSET, b.getType()); - List ids = toUnqualifiedVersionlessIds(b); - - assertThat(ids, containsInAnyOrder(o1Id, p1Id, c1Id)); - assertThat(ids, not((o2Id))); - assertThat(ids, not(hasItem(c2Id))); - assertThat(ids, not(hasItem(p2Id))); - } - - { - // Test for Patient 1 and 2 - // e.g. _id=1&_id=2 - Parameters parameters = new Parameters(); - parameters.addParameter("_id", p1Id.getIdPart()); - parameters.addParameter("_id", p2Id.getIdPart()); - - Parameters output = myClient.operation().onType(Patient.class).named("everything").withParameters(parameters).execute(); - Bundle b = (Bundle) output.getParameter().get(0).getResource(); - - assertEquals(BundleType.SEARCHSET, b.getType()); - List ids = toUnqualifiedVersionlessIds(b); - - assertThat(ids, containsInAnyOrder(o1Id, p1Id, c1Id, o2Id, c2Id, p2Id)); - } - - { - // Test for both patients using orList - // e.g. _id=1,2 - Parameters parameters = new Parameters(); - parameters.addParameter("_id", p1Id.getIdPart() + "," + p2Id.getIdPart()); - - Parameters output = myClient.operation().onType(Patient.class).named("everything").withParameters(parameters).execute(); - Bundle b = (Bundle) output.getParameter().get(0).getResource(); - - assertEquals(BundleType.SEARCHSET, b.getType()); - List ids = toUnqualifiedVersionlessIds(b); - - assertThat(ids, containsInAnyOrder(o1Id, p1Id, c1Id, o2Id, c2Id, p2Id)); - assertThat(ids, not(hasItem(c5Id))); - } - - { - // Test combining 2 or-listed params - // e.g. _id=1,2&_id=3,4 - Parameters parameters = new Parameters(); - parameters.addParameter("_id", "Patient/" + p1Id.getIdPart() + "," + p2Id.getIdPart()); - parameters.addParameter("_id", p3Id.getIdPart() + "," + p4Id.getIdPart()); - parameters.addParameter(new Parameters.ParametersParameterComponent().setName("_count").setValue(new UnsignedIntType(20))); - - Parameters output = myClient.operation().onType(Patient.class).named("everything").withParameters(parameters).execute(); - Bundle b = (Bundle) output.getParameter().get(0).getResource(); - - assertEquals(BundleType.SEARCHSET, b.getType()); - List ids = toUnqualifiedVersionlessIds(b); - - assertThat(ids, containsInAnyOrder(o1Id, p1Id, c1Id, o2Id, c2Id, p2Id, p3Id, o3Id, c3Id, p4Id, c4Id, o4Id)); - assertThat(ids, not(hasItem(c5Id))); - } - - { - // Test paging works. - // There are 12 results, lets make 2 pages of 6. - Parameters parameters = new Parameters(); - parameters.addParameter("_id", "Patient/" + p1Id.getIdPart() + "," + p2Id.getIdPart()); - parameters.addParameter("_id", p3Id.getIdPart() + "," + p4Id.getIdPart()); - parameters.addParameter(new Parameters.ParametersParameterComponent().setName("_count").setValue(new UnsignedIntType(6))); - - Parameters output = myClient.operation().onType(Patient.class).named("everything").withParameters(parameters).execute(); - Bundle bundle = (Bundle) output.getParameter().get(0).getResource(); - - String next = bundle.getLink("next").getUrl(); - Bundle nextBundle = myClient.loadPage().byUrl(next).andReturnBundle(Bundle.class).execute(); - assertEquals(BundleType.SEARCHSET, bundle.getType()); - - assertThat(bundle.getEntry(), hasSize(6)); - assertThat(nextBundle.getEntry(), hasSize(6)); - - List firstBundle = toUnqualifiedVersionlessIds(bundle); - List secondBundle = toUnqualifiedVersionlessIds(nextBundle); - List allresults = new ArrayList<>(); - allresults.addAll(firstBundle); - allresults.addAll(secondBundle); - - assertThat(allresults, containsInAnyOrder(o1Id, p1Id, c1Id, o2Id, c2Id, p2Id, p3Id, o3Id, c3Id, p4Id, c4Id, o4Id)); - assertThat(allresults, not(hasItem(c5Id))); - } - } - @Test public void testContains() { List test = List.of("a", "b", "c"); @@ -2501,414 +1999,6 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { assertThat(test, not(containsInAnyOrder("a", "b"))); //replace with indiv calls to not(hasItem()) } - @Test - public void testEverythingPatientInstanceWithTypeParameter() { - String methodName = "testEverythingPatientInstanceWithTypeParameter"; - - //Patient 1 stuff. - IIdType o1Id = createOrganization(methodName, "1"); - IIdType p1Id = createPatientWithIndexAtOrganization(methodName, "1", o1Id); - IIdType c1Id = createConditionForPatient(methodName, "1", p1Id); - IIdType obs1Id = createObservationForPatient(p1Id, "1"); - IIdType m1Id = createMedicationRequestForPatient(p1Id, "1"); - - //Test for only one patient - Parameters parameters = new Parameters(); - parameters.addParameter("_type", "Condition, Observation"); - - myCaptureQueriesListener.clear(); - - Parameters output = myClient.operation().onInstance(p1Id).named("everything").withParameters(parameters).execute(); - ourLog.debug(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(output)); - Bundle b = (Bundle) output.getParameter().get(0).getResource(); - - myCaptureQueriesListener.logSelectQueries(); - - assertEquals(BundleType.SEARCHSET, b.getType()); - List ids = toUnqualifiedVersionlessIds(b); - - assertThat(ids, containsInAnyOrder(p1Id, c1Id, obs1Id)); - assertThat(ids, not(hasItem(o1Id))); - assertThat(ids, not(hasItem(m1Id))); - } - - @Test - public void testEverythingPatientTypeWithTypeParameter() { - String methodName = "testEverythingPatientTypeWithTypeParameter"; - - //Patient 1 stuff. - IIdType o1Id = createOrganization(methodName, "1"); - IIdType p1Id = createPatientWithIndexAtOrganization(methodName, "1", o1Id); - IIdType c1Id = createConditionForPatient(methodName, "1", p1Id); - IIdType obs1Id = createObservationForPatient(p1Id, "1"); - IIdType m1Id = createMedicationRequestForPatient(p1Id, "1"); - - //Test for only one patient - Parameters parameters = new Parameters(); - parameters.addParameter("_type", "Condition, Observation"); - - myCaptureQueriesListener.clear(); - - Parameters output = myClient.operation().onType(Patient.class).named("everything").withParameters(parameters).execute(); - ourLog.debug(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(output)); - Bundle b = (Bundle) output.getParameter().get(0).getResource(); - - myCaptureQueriesListener.logSelectQueries(); - - assertEquals(BundleType.SEARCHSET, b.getType()); - List ids = toUnqualifiedVersionlessIds(b); - - assertThat(ids, containsInAnyOrder(p1Id, c1Id, obs1Id)); - assertThat(ids, not(hasItem(o1Id))); - assertThat(ids, not(hasItem(m1Id))); - } - - @Test - public void testEverythingPatientTypeWithTypeAndIdParameter() { - String methodName = "testEverythingPatientTypeWithTypeAndIdParameter"; - - //Patient 1 stuff. - IIdType o1Id = createOrganization(methodName, "1"); - IIdType p1Id = createPatientWithIndexAtOrganization(methodName, "1", o1Id); - IIdType c1Id = createConditionForPatient(methodName, "1", p1Id); - IIdType obs1Id = createObservationForPatient(p1Id, "1"); - IIdType m1Id = createMedicationRequestForPatient(p1Id, "1"); - - //Patient 2 stuff. - IIdType o2Id = createOrganization(methodName, "2"); - IIdType p2Id = createPatientWithIndexAtOrganization(methodName, "2", o2Id); - IIdType c2Id = createConditionForPatient(methodName, "2", p2Id); - IIdType obs2Id = createObservationForPatient(p2Id, "2"); - IIdType m2Id = createMedicationRequestForPatient(p2Id, "2"); - - //Test for only patient 1 - Parameters parameters = new Parameters(); - parameters.addParameter("_type", "Condition, Observation"); - parameters.addParameter("_id", p1Id.getIdPart()); - - myCaptureQueriesListener.clear(); - - Parameters output = myClient.operation().onType(Patient.class).named("everything").withParameters(parameters).execute(); - ourLog.debug(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(output)); - Bundle b = (Bundle) output.getParameter().get(0).getResource(); - - myCaptureQueriesListener.logSelectQueries(); - - assertEquals(BundleType.SEARCHSET, b.getType()); - List ids = toUnqualifiedVersionlessIds(b); - - assertThat(ids, containsInAnyOrder(p1Id, c1Id, obs1Id)); - assertThat(ids, not(hasItem(o1Id))); - assertThat(ids, not(hasItem(m1Id))); - assertThat(ids, not(hasItem(p2Id))); - assertThat(ids, not(hasItem(o2Id))); - } - - @Test - public void testEverythingPatientWorksWithForcedId() { - String methodName = "testEverythingPatientType"; - - //Given - IIdType o1Id = createOrganization(methodName, "1"); - //Patient ABC stuff. - Patient patientABC = new Patient(); - patientABC.setId("abc"); - patientABC.setManagingOrganization(new Reference(o1Id)); - IIdType pabcId = myPatientDao.update(patientABC).getId().toUnqualifiedVersionless(); - IIdType c1Id = createConditionForPatient(methodName, "1", pabcId); - - //Patient DEF stuff. - IIdType o2Id = createOrganization(methodName, "2"); - Patient patientDEF = new Patient(); - patientDEF.setId("def"); - patientDEF.setManagingOrganization(new Reference(o2Id)); - IIdType pdefId = myPatientDao.update(patientDEF).getId().toUnqualifiedVersionless(); - IIdType c2Id = createConditionForPatient(methodName, "2", pdefId); - - IIdType c3Id = createConditionForPatient(methodName, "2", null); - - { - Parameters parameters = new Parameters(); - parameters.addParameter("_id", "Patient/abc,Patient/def"); - - //When - Parameters output = myClient.operation().onType(Patient.class).named("everything").withParameters(parameters).execute(); - Bundle b = (Bundle) output.getParameter().get(0).getResource(); - - //Then - assertEquals(BundleType.SEARCHSET, b.getType()); - List ids = toUnqualifiedVersionlessIds(b); - assertThat(ids, containsInAnyOrder(o1Id, pabcId, c1Id, pdefId, o2Id, c2Id)); - assertThat(ids, not(hasItem(c3Id))); - } - - - } - - private IIdType createOrganization(String methodName, String s) { - Organization o1 = new Organization(); - o1.setName(methodName + s); - return myClient.create().resource(o1).execute().getId().toUnqualifiedVersionless(); - } - - // retest - @Test - public void testEverythingPatientWithLastUpdatedAndSort() throws Exception { - String methodName = "testEverythingWithLastUpdatedAndSort"; - - Organization org = new Organization(); - org.setName(methodName); - IIdType oId = myClient.create().resource(org).execute().getId().toUnqualifiedVersionless(); - - long time1 = System.currentTimeMillis(); - Thread.sleep(10); - - Patient p = new Patient(); - p.addName().setFamily(methodName); - p.getManagingOrganization().setReferenceElement(oId); - IIdType pId = myClient.create().resource(p).execute().getId().toUnqualifiedVersionless(); - - long time2 = System.currentTimeMillis(); - Thread.sleep(10); - - Condition c = new Condition(); - c.getCode().setText(methodName); - c.getSubject().setReferenceElement(pId); - IIdType cId = myClient.create().resource(c).execute().getId().toUnqualifiedVersionless(); - - ourLog.info("Resource IDs:\n * {}\n * {}\n * {}", oId, pId, cId); - runInTransaction(() -> { - ourLog.info("Resource Links:\n * {}", myResourceLinkDao.findAll().stream().map(t -> t.toString()).collect(Collectors.joining("\n * "))); - ourLog.info("Resources:\n * {}", myResourceTableDao.findAll().stream().map(t -> t.toString()).collect(Collectors.joining("\n * "))); - }); - - Thread.sleep(10); - long time3 = System.currentTimeMillis(); - - // %3E=> %3C=< - - myCaptureQueriesListener.clear(); - HttpGet get = new HttpGet(myServerBase + "/Patient/" + pId.getIdPart() + "/$everything?_lastUpdated=%3E" + new InstantType(new Date(time1)).getValueAsString()); - CloseableHttpResponse response = ourHttpClient.execute(get); - myCaptureQueriesListener.logSelectQueries(); - try { - assertEquals(200, response.getStatusLine().getStatusCode()); - String output = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); - response.getEntity().getContent().close(); - ourLog.info(output); - List ids = toUnqualifiedVersionlessIds(myFhirContext.newXmlParser().parseResource(Bundle.class, output)); - ourLog.info(ids.toString()); - assertThat(ids, containsInAnyOrder(pId, cId, oId)); - } finally { - response.close(); - } - - get = new HttpGet(myServerBase + "/Patient/" + pId.getIdPart() + "/$everything?_lastUpdated=%3E" + new InstantType(new Date(time2)).getValueAsString() + "&_lastUpdated=%3C" - + new InstantType(new Date(time3)).getValueAsString()); - response = ourHttpClient.execute(get); - try { - assertEquals(200, response.getStatusLine().getStatusCode()); - String output = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); - response.getEntity().getContent().close(); - ourLog.info(output); - List ids = toUnqualifiedVersionlessIds(myFhirContext.newXmlParser().parseResource(Bundle.class, output)); - ourLog.info(ids.toString()); - assertThat(ids, containsInAnyOrder(pId, cId, oId)); - } finally { - response.close(); - } - - /* - * Sorting is not working since the performance enhancements in 2.4 but - * sorting for lastupdated is non-standard anyhow.. Hopefully at some point - * we can bring this back - */ - // get = new HttpGet(ourServerBase + "/Patient/" + pId.getIdPart() + "/$everything?_lastUpdated=%3E" + new InstantType(new Date(time1)).getValueAsString() + "&_sort=_lastUpdated"); - // response = ourHttpClient.execute(get); - // try { - // assertEquals(200, response.getStatusLine().getStatusCode()); - // String output = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); - // response.getEntity().getContent().close(); - // ourLog.info(output); - // List ids = toUnqualifiedVersionlessIds(myFhirCtx.newXmlParser().parseResource(Bundle.class, output)); - // ourLog.info(ids.toString()); - // assertThat(ids, contains(pId, cId)); - // } finally { - // response.close(); - // } - // - // get = new HttpGet(ourServerBase + "/Patient/" + pId.getIdPart() + "/$everything?_sort:desc=_lastUpdated"); - // response = ourHttpClient.execute(get); - // try { - // assertEquals(200, response.getStatusLine().getStatusCode()); - // String output = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); - // response.getEntity().getContent().close(); - // ourLog.info(output); - // List ids = toUnqualifiedVersionlessIds(myFhirCtx.newXmlParser().parseResource(Bundle.class, output)); - // ourLog.info(ids.toString()); - // assertThat(ids, contains(cId, pId, oId)); - // } finally { - // response.close(); - // } - - } - - /** - * Per message from David Hay on Skype - */ - @Test - @Disabled - public void testEverythingWithLargeSet() throws Exception { - - String inputString = IOUtils.toString(getClass().getResourceAsStream("/david_big_bundle.json"), StandardCharsets.UTF_8); - Bundle inputBundle = myFhirContext.newJsonParser().parseResource(Bundle.class, inputString); - inputBundle.setType(BundleType.TRANSACTION); - - assertEquals(53, inputBundle.getEntry().size()); - - Set allIds = new TreeSet<>(); - for (BundleEntryComponent nextEntry : inputBundle.getEntry()) { - nextEntry.getRequest().setMethod(HTTPVerb.PUT); - nextEntry.getRequest().setUrl(nextEntry.getResource().getId()); - allIds.add(nextEntry.getResource().getIdElement().toUnqualifiedVersionless().getValue()); - } - - assertEquals(53, allIds.size()); - - mySystemDao.transaction(mySrd, inputBundle); - - Bundle responseBundle = myClient - .operation() - .onInstance(new IdType("Patient/A161443")) - .named("everything") - .withParameter(Parameters.class, "_count", new IntegerType(20)) - .useHttpGet() - .returnResourceType(Bundle.class) - .execute(); - - ourLog.debug(myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(responseBundle)); - - List ids = new ArrayList<>(); - for (BundleEntryComponent nextEntry : responseBundle.getEntry()) { - ids.add(nextEntry.getResource().getIdElement().toUnqualifiedVersionless().getValue()); - } - Collections.sort(ids); - ourLog.info("{} ids: {}", ids.size(), ids); - - assertThat(responseBundle.getEntry().size(), lessThanOrEqualTo(25)); - - TreeSet idsSet = new TreeSet<>(); - for (int i = 0; i < responseBundle.getEntry().size(); i++) { - for (BundleEntryComponent nextEntry : responseBundle.getEntry()) { - idsSet.add(nextEntry.getResource().getIdElement().toUnqualifiedVersionless().getValue()); - } - } - - String nextUrl = responseBundle.getLink("next").getUrl(); - responseBundle = myClient.fetchResourceFromUrl(Bundle.class, nextUrl); - for (int i = 0; i < responseBundle.getEntry().size(); i++) { - for (BundleEntryComponent nextEntry : responseBundle.getEntry()) { - idsSet.add(nextEntry.getResource().getIdElement().toUnqualifiedVersionless().getValue()); - } - } - - nextUrl = responseBundle.getLink("next").getUrl(); - responseBundle = myClient.fetchResourceFromUrl(Bundle.class, nextUrl); - for (int i = 0; i < responseBundle.getEntry().size(); i++) { - for (BundleEntryComponent nextEntry : responseBundle.getEntry()) { - idsSet.add(nextEntry.getResource().getIdElement().toUnqualifiedVersionless().getValue()); - } - } - - assertEquals(null, responseBundle.getLink("next")); - - assertThat(idsSet, hasItem("List/A161444")); - assertThat(idsSet, hasItem("List/A161468")); - assertThat(idsSet, hasItem("List/A161500")); - - ourLog.info("Expected {} - {}", allIds.size(), allIds); - ourLog.info("Actual {} - {}", idsSet.size(), idsSet); - assertEquals(allIds, idsSet); - - } - - /** - * Per message from David Hay on Skype - */ - @Test - public void testEverythingWithLargeSet2() { - myStorageSettings.setSearchPreFetchThresholds(Arrays.asList(15, 30, -1)); - myPagingProvider.setDefaultPageSize(500); - myPagingProvider.setMaximumPageSize(1000); - - Patient p = new Patient(); - p.setActive(true); - IIdType id = myClient.create().resource(p).execute().getId().toUnqualifiedVersionless(); - - for (int i = 1; i < LARGE_NUMBER; i++) { - Observation obs = new Observation(); - obs.setId("A" + StringUtils.leftPad(Integer.toString(i), 2, '0')); - obs.setSubject(new Reference(id)); - myClient.update().resource(obs).execute(); - } - - Bundle responseBundle = myClient - .operation() - .onInstance(id) - .named("everything") - .withParameter(Parameters.class, "_count", new IntegerType(50)) - .useHttpGet() - .returnResourceType(Bundle.class) - .execute(); - - ArrayList ids = new ArrayList<>(); - for (int i = 0; i < responseBundle.getEntry().size(); i++) { - BundleEntryComponent nextEntry = responseBundle.getEntry().get(i); - ids.add(nextEntry.getResource().getIdElement().getIdPart()); - } - - BundleLinkComponent nextLink = responseBundle.getLink("next"); - ourLog.info("Have {} IDs with next link[{}] : {}", ids.size(), nextLink, ids); - - while (nextLink != null) { - String nextUrl = nextLink.getUrl(); - responseBundle = myClient.fetchResourceFromUrl(Bundle.class, nextUrl); - for (int i = 0; i < responseBundle.getEntry().size(); i++) { - BundleEntryComponent nextEntry = responseBundle.getEntry().get(i); - ids.add(nextEntry.getResource().getIdElement().getIdPart()); - } - - nextLink = responseBundle.getLink("next"); - ourLog.info("Have {} IDs with next link[{}] : {}", ids.size(), nextLink, ids); - } - - assertThat(ids, hasItem(id.getIdPart())); - - // TODO KHS this fails intermittently with 53 instead of 77 - assertEquals(LARGE_NUMBER, ids.size()); - for (int i = 1; i < LARGE_NUMBER; i++) { - assertThat(ids.size() + " ids: " + ids, ids, hasItem("A" + StringUtils.leftPad(Integer.toString(i), 2, '0'))); - } - } - - @Test - public void testEverythingWithOnlyPatient() { - Patient p = new Patient(); - p.setActive(true); - IIdType id = myClient.create().resource(p).execute().getId().toUnqualifiedVersionless(); - - myFhirContext.getRestfulClientFactory().setSocketTimeout(300 * 1000); - - Bundle response = myClient - .operation() - .onInstance(id) - .named("everything") - .withNoParameters(Parameters.class) - .returnResourceType(Bundle.class) - .execute(); - - assertEquals(1, response.getEntry().size()); - } /** * See #872 @@ -2991,7 +2081,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { try (CloseableHttpResponse resp = ourHttpClient.execute(post)) { String respString = IOUtils.toString(resp.getEntity().getContent(), Charsets.UTF_8); ourLog.debug(respString); - assertEquals(412, resp.getStatusLine().getStatusCode()); + assertEquals(200, resp.getStatusLine().getStatusCode()); assertThat(respString, containsString("Profile reference 'http://foo/structuredefinition/myprofile' has not been checked because it is unknown")); } } @@ -3020,34 +2110,6 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { } } - @Test - public void testFulltextEverythingWithIdAndContent() throws IOException { - Patient p = new Patient(); - p.setId("FOO"); - p.addName().setFamily("FAMILY"); - myClient.update().resource(p).execute(); - - p = new Patient(); - p.setId("BAR"); - p.addName().setFamily("HELLO"); - myClient.update().resource(p).execute(); - - Observation o = new Observation(); - o.setId("BAZ"); - o.getSubject().setReference("Patient/FOO"); - o.getCode().setText("GOODBYE"); - myClient.update().resource(o).execute(); - - List ids = searchAndReturnUnqualifiedVersionlessIdValues(myServerBase + "/Patient/FOO/$everything?_content=White"); - assertThat(ids, contains("Patient/FOO")); - - ids = searchAndReturnUnqualifiedVersionlessIdValues(myServerBase + "/Patient/FOO/$everything?_content=HELLO"); - assertThat(ids, contains("Patient/FOO")); - - ids = searchAndReturnUnqualifiedVersionlessIdValues(myServerBase + "/Patient/FOO/$everything?_content=GOODBYE"); - assertThat(ids, containsInAnyOrder("Patient/FOO", "Observation/BAZ")); - } - @Test public void testFulltextSearchWithIdAndContent() throws IOException { Patient p = new Patient(); @@ -3677,211 +2739,6 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { assertEquals(1, resp.getTotal()); } - @Test - public void testPagingOverEverythingSet() throws InterruptedException { - Patient p = new Patient(); - p.setActive(true); - String pid = myPatientDao.create(p).getId().toUnqualifiedVersionless().getValue(); - - for (int i = 0; i < 20; i++) { - Observation o = new Observation(); - o.getSubject().setReference(pid); - o.addIdentifier().setSystem("foo").setValue(Integer.toString(i)); - myObservationDao.create(o); - } - - mySearchCoordinatorSvcRaw.setLoadingThrottleForUnitTests(50); - mySearchCoordinatorSvcRaw.setSyncSizeForUnitTests(10); - mySearchCoordinatorSvcRaw.setNeverUseLocalSearchForUnitTests(true); - - Bundle response = myClient - .operation() - .onInstance(new IdType(pid)) - .named("everything") - .withSearchParameter(Parameters.class, "_count", new NumberParam(10)) - .returnResourceType(Bundle.class) - .useHttpGet() - .execute(); - - assertEquals(10, response.getEntry().size()); - if (response.getTotalElement().getValueAsString() != null) { - assertEquals("21", response.getTotalElement().getValueAsString()); - } - assertThat(response.getLink("next").getUrl(), not(emptyString())); - - // Load page 2 - - String nextUrl = response.getLink("next").getUrl(); - response = myClient.fetchResourceFromUrl(Bundle.class, nextUrl); - - assertEquals(10, response.getEntry().size()); - if (response.getTotalElement().getValueAsString() != null) { - assertEquals("21", response.getTotalElement().getValueAsString()); - } - assertThat(response.getLink("next").getUrl(), not(emptyString())); - - // Load page 3 - Thread.sleep(2000); - - nextUrl = response.getLink("next").getUrl(); - response = myClient.fetchResourceFromUrl(Bundle.class, nextUrl); - - assertEquals(1, response.getEntry().size()); - assertEquals("21", response.getTotalElement().getValueAsString()); - assertEquals(null, response.getLink("next")); - - } - - @Disabled - @Test - public void testEverythingWithNoPagingProvider() { - myServer.getRestfulServer().setPagingProvider(null); - - Patient p = new Patient(); - p.setActive(true); - String pid = myPatientDao.create(p).getId().toUnqualifiedVersionless().getValue(); - - for (int i = 0; i < 20; i++) { - Observation o = new Observation(); - o.getSubject().setReference(pid); - o.addIdentifier().setSystem("foo").setValue(Integer.toString(i)); - myObservationDao.create(o); - } - - mySearchCoordinatorSvcRaw.setLoadingThrottleForUnitTests(50); - mySearchCoordinatorSvcRaw.setSyncSizeForUnitTests(10); - mySearchCoordinatorSvcRaw.setNeverUseLocalSearchForUnitTests(true); - - Bundle response = myClient - .operation() - .onInstance(new IdType(pid)) - .named("everything") - .withSearchParameter(Parameters.class, "_count", new NumberParam(10)) - .returnResourceType(Bundle.class) - .useHttpGet() - .execute(); - - assertEquals(10, response.getEntry().size()); - assertEquals(null, response.getTotalElement().getValue()); - assertEquals(null, response.getLink("next")); - } - - - @Test - public void testEverythingDoesNotEnterSecondPatient() { - Patient goodPatient = new Patient(); - goodPatient.setActive(true); - String goodPid = myPatientDao.create(goodPatient, mySrd).getId().toUnqualifiedVersionless().getValue(); - - Patient badPatient = new Patient(); - badPatient.setActive(true); - String badPid = myPatientDao.create(badPatient, mySrd).getId().toUnqualifiedVersionless().getValue(); - - Observation o = new Observation(); - o.getSubject().setReference(goodPid); - o.addIdentifier().setSystem("foo").setValue("1"); - String oid = myObservationDao.create(o, mySrd).getId().toUnqualifiedVersionless().getValue(); - - Provenance prov = new Provenance(); - prov.addTarget().setReference(goodPid); - prov.addTarget().setReference(badPid); - String provid = myProvenanceDao.create(prov, mySrd).getId().toUnqualifiedVersionless().getValue(); - - Bundle response = myClient - .operation() - .onInstance(new IdType(goodPid)) - .named("everything") - .withNoParameters(Parameters.class) - .returnResourceType(Bundle.class) - .execute(); - - List ids = toUnqualifiedVersionlessIdValues(response); - // We should not pick up other resources via the provenance - assertThat(ids, containsInAnyOrder(goodPid, oid, provid)); - } - - @Test - public void testEverythingDoesNotEnterSecondPatientLinkedByProvenanceAndComposition() { - final Patient desiredPatient = new Patient(); - desiredPatient.setActive(true); - final String desiredPid = myPatientDao.create(desiredPatient, mySrd).getId().toUnqualifiedVersionless().getValue(); - - final Patient notDesiredPatient = new Patient(); - desiredPatient.setActive(true); - final String notDesiredPid = myPatientDao.create(notDesiredPatient, mySrd).getId().toUnqualifiedVersionless().getValue(); - - final Observation desiredObservation = new Observation(); - desiredObservation.getSubject().setReference(desiredPid); - desiredObservation.addIdentifier().setSystem("foo").setValue("1"); - final String desiredObservationId = myObservationDao.create(desiredObservation, mySrd).getId().toUnqualifiedVersionless().getValue(); - - final Observation notDesiredObservation = new Observation(); - notDesiredObservation.getSubject().setReference(notDesiredPid); - notDesiredObservation.addIdentifier().setSystem("foo").setValue("1"); - final String notDesiredObservationId = myObservationDao.create(notDesiredObservation, mySrd).getId().toUnqualifiedVersionless().getValue(); - - final Composition composition = new Composition(); - final Reference referenceToNotDesiredPatient = new Reference(); - referenceToNotDesiredPatient.setReference(notDesiredPid); - composition.setSubject(referenceToNotDesiredPatient); - final String compositionId = myCompositionDao.create(composition, mySrd).getId().toUnqualifiedVersionless().getValue(); - - final Provenance desiredProvenance = new Provenance(); - desiredProvenance.addTarget().setReference(desiredPid); - desiredProvenance.addTarget().setReference(compositionId); - final String desiredProvenanceId = myProvenanceDao.create(desiredProvenance, mySrd).getId().toUnqualifiedVersionless().getValue(); - - final Provenance notDesiredProvenance = new Provenance(); - notDesiredProvenance.addTarget().setReference(notDesiredPid); - notDesiredProvenance.addTarget().setReference(compositionId); - final String notDesiredProvenanceId = myProvenanceDao.create(notDesiredProvenance, mySrd).getId().toUnqualifiedVersionless().getValue(); - - final Bundle response = myClient - .operation() - .onInstance(new IdType(desiredPid)) - .named("everything") - .withNoParameters(Parameters.class) - .returnResourceType(Bundle.class) - .execute(); - - final List actualResourceIds = toUnqualifiedVersionlessIdValues(response); - // We should not pick up other resources via the notDesiredProvenance - assertThat(actualResourceIds, containsInAnyOrder(desiredPid, desiredObservationId, desiredProvenanceId)); - } - - @Test - public void testIncludeRecurseFromProvenanceDoesTraverse() { - Patient goodPatient = new Patient(); - goodPatient.setActive(true); - String goodPid = myPatientDao.create(goodPatient, mySrd).getId().toUnqualifiedVersionless().getValue(); - - Practitioner prac = new Practitioner(); - prac.addName().setFamily("FAM"); - String pracid = myPractitionerDao.create(prac, mySrd).getId().toUnqualifiedVersionless().getValue(); - - Patient otherPatient = new Patient(); - otherPatient.setActive(true); - otherPatient.addGeneralPractitioner().setReference(pracid); - String otherPid = myPatientDao.create(otherPatient, mySrd).getId().toUnqualifiedVersionless().getValue(); - - Provenance prov = new Provenance(); - prov.addTarget().setReference(goodPid); - prov.addTarget().setReference(otherPid); - String provid = myProvenanceDao.create(prov, mySrd).getId().toUnqualifiedVersionless().getValue(); - - Bundle response = myClient - .search() - .forResource("Provenance") - .where(Provenance.TARGET.hasId(goodPid)) - .include(new Include("*", true)) - .returnBundle(Bundle.class) - .execute(); - - List ids = toUnqualifiedVersionlessIdValues(response); - // We should not pick up other resources via the provenance - assertThat(ids, containsInAnyOrder(goodPid, otherPid, pracid, provid)); - } - @Test public void testParseAndEncodeExtensionWithValueWithExtension() throws IOException { String input = "\n" + @@ -4530,7 +3387,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { } @Test - public void testSearchByIdForDeletedResourceWithClientAssignedId() throws IOException { + public void testSearchByIdForDeletedResourceWithClientAssignedId() { // Create with client assigned ID Patient p = new Patient(); String patientId = "AAA"; @@ -4565,7 +3422,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { } @Test - public void testSearchByIdForDeletedResourceWithServerAssignedId() throws IOException { + public void testSearchByIdForDeletedResourceWithServerAssignedId() { // Create with server assigned ID Patient p = new Patient(); MethodOutcome outcome = myClient.create().resource(p).execute(); @@ -4949,11 +3806,11 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { public void testSearchMedicationChain() throws Exception { Medication medication = new Medication(); medication.getCode().addCoding().setSystem("SYSTEM").setCode("04823543"); - IIdType medId = myMedicationDao.create(medication).getId().toUnqualifiedVersionless(); + IIdType medId = myMedicationDao.create(medication, mySrd).getId().toUnqualifiedVersionless(); MedicationAdministration ma = new MedicationAdministration(); ma.setMedication(new Reference(medId)); - IIdType moId = myMedicationAdministrationDao.create(ma).getId().toUnqualifiedVersionless(); + IIdType moId = myMedicationAdministrationDao.create(ma, mySrd).getId().toUnqualifiedVersionless(); HttpGet get = new HttpGet(myServerBase + "/MedicationAdministration?medication.code=04823543"); try (CloseableHttpResponse response = ourHttpClient.execute(get)) { @@ -5193,7 +4050,6 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { Observation obs = new Observation(); obs.addIdentifier().setSystem("urn:system").setValue("FOO"); obs.getSubject().setReferenceElement(pid0); - CodeableConcept cc = obs.getCode(); obs.setValue(new Quantity().setValueElement(new DecimalType(100)).setUnit("CM").setSystem("http://foo").setCode("cm")); myObservationDao.create(obs, mySrd); @@ -5216,7 +4072,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { } @Test - public void testSearchWithNormalizedQuantitySearchSupported_DegreeFahrenheit() throws Exception { + public void testSearchWithNormalizedQuantitySearchSupported_DegreeFahrenheit() { myStorageSettings.setNormalizedQuantitySearchLevel(NormalizedQuantitySearchLevel.NORMALIZED_QUANTITY_SEARCH_SUPPORTED); IIdType pid0; @@ -5254,7 +4110,6 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { Observation obs = new Observation(); obs.addIdentifier().setSystem("urn:system").setValue("FOO"); obs.getSubject().setReferenceElement(pid0); - CodeableConcept cc = obs.getCode(); obs.setValue(new Quantity().setUnit("CM").setSystem("http://foo").setCode("cm")); myObservationDao.create(obs, mySrd); @@ -5348,7 +4203,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { .execute(); final String uuid1 = toSearchUuidFromLinkNext(result1); runInTransaction(() -> { - Search search = mySearchEntityDao.findByUuidAndFetchIncludes(uuid1).orElseThrow(() -> new IllegalStateException()); + Search search = mySearchEntityDao.findByUuidAndFetchIncludes(uuid1).orElseThrow(IllegalStateException::new); search.setExpiryOrNull(DateUtils.addSeconds(new Date(), -2)); mySearchEntityDao.save(search); }); @@ -5600,7 +4455,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { // When we've only got one DB connection available, we are forced to wait for the // search to finish before returning if (TestR4Config.getMaxThreads() > 1) { - assertEquals(null, found.getTotalElement().getValue()); + assertNull(found.getTotalElement().getValue()); assertEquals(1, found.getEntry().size()); assertThat(sw.getMillis(), lessThan(1000L)); } else { @@ -5665,7 +4520,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { // WHen we've only got one DB connection available, we are forced to wait for the // search to finish before returning if (TestR4Config.getMaxThreads() > 1) { - assertEquals(null, found.getTotalElement().getValue()); + assertNull(found.getTotalElement().getValue()); assertEquals(1, found.getEntry().size()); assertThat(sw.getMillis(), lessThan(1500L)); } else { @@ -6071,11 +4926,11 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { MedicationRequest mr1 = new MedicationRequest(); mr1.addCategory().addCoding().setSystem("urn:medicationroute").setCode("oral"); mr1.addDosageInstruction().getTiming().addEventElement().setValueAsString("2017-01-01"); - IIdType id1 = myMedicationRequestDao.create(mr1).getId().toUnqualifiedVersionless(); + IIdType id1 = myMedicationRequestDao.create(mr1, mySrd).getId().toUnqualifiedVersionless(); MedicationRequest mr2 = new MedicationRequest(); mr2.addCategory().addCoding().setSystem("urn:medicationroute").setCode("oral"); - IIdType id2 = myMedicationRequestDao.create(mr2).getId().toUnqualifiedVersionless(); + IIdType id2 = myMedicationRequestDao.create(mr2, mySrd).getId().toUnqualifiedVersionless(); HttpGet get = new HttpGet(myServerBase + "/MedicationRequest?date:missing=false"); try (CloseableHttpResponse resp = ourHttpClient.execute(get)) { @@ -6386,7 +5241,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { } // Read back through the HTTP API { - Organization returned = myClient.read(Organization.class, orgId.getIdPart()); + Organization returned = myClient.read().resource(Organization.class).withId(orgId.getIdPart()).execute(); String val = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(returned); ourLog.info(val); assertThat(val, containsString("")); @@ -6406,7 +5261,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { } @Test - public void testCreateResourcesWithAdvancedHSearchIndexingAndIndexMissingFieldsEnableSucceeds() throws Exception { + public void testCreateResourcesWithAdvancedHSearchIndexingAndIndexMissingFieldsEnableSucceeds() { myStorageSettings.setIndexMissingFields(JpaStorageSettings.IndexEnabledEnum.ENABLED); myStorageSettings.setAdvancedHSearchIndexing(true); String identifierValue = "someValue"; @@ -6489,11 +5344,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { } } - /** - * This does not currently cause an error, so this test is disabled - */ @Test - @Disabled public void testUpdateNoIdInBody() throws Exception { String methodName = "testUpdateNoIdInBody"; @@ -6506,7 +5357,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { try (CloseableHttpResponse response = ourHttpClient.execute(post)) { String responseString = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); ourLog.info(responseString); - assertThat(responseString, containsString("Can not update resource, request URL must contain an ID element for update (PUT) operation (it must be of the form [base]/[resource type]/[id])")); + assertThat(responseString, containsString("Can not update resource, resource body must contain an ID element for update (PUT) operation")); assertThat(responseString, containsString(" ids; HttpGet get = new HttpGet(uri); try (CloseableHttpResponse response = ourHttpClient.execute(get)) { String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); ourLog.info(resp); Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, resp); - ids = toUnqualifiedVersionlessIdValues(bundle); ourLog.debug("Patient: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); } @@ -7340,7 +6189,6 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); ourLog.info(resp); Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, resp); - ids = toUnqualifiedVersionlessIdValues(bundle); ourLog.debug("Patient: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); } @@ -7705,7 +6553,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { } private static List createResourceParameters() { - boolean[] bools = new boolean[] { true, false }; + boolean[] bools = new boolean[]{true, false}; List input = new ArrayList<>(); for (boolean bool : bools) { for (boolean bool2 : bools) { @@ -7737,10 +6585,10 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { { List orgs = myOrganizationDao - .search(new SearchParameterMap(), new SystemRequestDetails()) + .search(new SearchParameterMap(), mySrd) .getAllResources(); - assertTrue(orgs == null || orgs.isEmpty()); + assertTrue(orgs.isEmpty()); } boolean isEnforceRefOnWrite = myStorageSettings.isEnforceReferentialIntegrityOnWrite(); @@ -7756,22 +6604,22 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { myStorageSettings.setAutoCreatePlaceholderReferenceTargets(theInput.IsAutoCreatePlaceholderReferences); // should fail - DaoMethodOutcome result = myPatientDao.create(patient, new SystemRequestDetails()); + myPatientDao.create(patient, mySrd); // a bad reference can never create a new resource { List orgs = myOrganizationDao - .search(new SearchParameterMap(), new SystemRequestDetails()) + .search(new SearchParameterMap(), mySrd) .getAllResources(); - assertTrue(orgs == null || orgs.isEmpty()); + assertTrue(orgs.isEmpty()); } // only if all 3 are true do we expect this to fail assertFalse( theInput.IsAutoCreatePlaceholderReferences - && theInput.IsEnforceRefOnType - && theInput.IsEnforceRefOnWrite + && theInput.IsEnforceRefOnType + && theInput.IsEnforceRefOnWrite ); } catch (InvalidRequestException ex) { assertTrue(ex.getMessage().contains( @@ -7894,7 +6742,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { conceptMap.setUrl("http://www.acme.org"); conceptMap.setStatus(Enumerations.PublicationStatus.ACTIVE); - ConceptMap.ConceptMapGroupComponent group = conceptMap.addGroup(); + ConceptMap.ConceptMapGroupComponent group = conceptMap.addGroup(); group.setSource("http://www.some-source.ca/codeSystem/CS"); group.setTarget("http://www.some-target.ca/codeSystem/CS"); @@ -7963,44 +6811,6 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { return new InstantDt(theDate).getValueAsString(); } - public IIdType createPatientWithIndexAtOrganization(String theMethodName, String theIndex, IIdType theOrganizationId) { - Patient p1 = new Patient(); - p1.addName().setFamily(theMethodName + theIndex); - p1.getManagingOrganization().setReferenceElement(theOrganizationId); - IIdType p1Id = myClient.create().resource(p1).execute().getId().toUnqualifiedVersionless(); - return p1Id; - } - - public IIdType createConditionForPatient(String theMethodName, String theIndex, IIdType thePatientId) { - Condition c = new Condition(); - c.addIdentifier().setValue(theMethodName + theIndex); - if (thePatientId != null) { - c.getSubject().setReferenceElement(thePatientId); - } - IIdType cId = myClient.create().resource(c).execute().getId().toUnqualifiedVersionless(); - return cId; - } - - private IIdType createMedicationRequestForPatient(IIdType thePatientId, String theIndex) { - MedicationRequest m = new MedicationRequest(); - m.addIdentifier().setValue(theIndex); - if (thePatientId != null) { - m.getSubject().setReferenceElement(thePatientId); - } - IIdType mId = myClient.create().resource(m).execute().getId().toUnqualifiedVersionless(); - return mId; - } - - private IIdType createObservationForPatient(IIdType thePatientId, String theIndex) { - Observation o = new Observation(); - o.addIdentifier().setValue(theIndex); - if (thePatientId != null) { - o.getSubject().setReferenceElement(thePatientId); - } - IIdType oId = myClient.create().resource(o).execute().getId().toUnqualifiedVersionless(); - return oId; - } - @Nested public class MissingSearchParameterTests { @@ -8118,9 +6928,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { org.setName("anything"); } return org; - }, (isMissing) -> { - return doSearch(Organization.class, Organization.NAME.isMissing(isMissing)); - } + }, (isMissing) -> doSearch(Organization.class, Organization.NAME.isMissing(isMissing)) ); } @@ -8131,7 +6939,9 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { (hasField) -> { Patient patient = new Patient(); if (hasField) { - patient.setBirthDate(new Date(2000, Calendar.DECEMBER, 25)); + Calendar cal = Calendar.getInstance(); + cal.set(2000, Calendar.DECEMBER, 25); + patient.setBirthDate(cal.getTime()); } return patient; }, (isMissing) -> { diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderSearchModifierR4Test.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderSearchModifierR4Test.java index e008acdfd61..2df91aa713a 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderSearchModifierR4Test.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderSearchModifierR4Test.java @@ -288,7 +288,7 @@ public class ResourceProviderSearchModifierR4Test extends BaseResourceProviderR4 } - private List searchAndReturnUnqualifiedVersionlessIdValues(String uri) throws IOException { + public List searchAndReturnUnqualifiedVersionlessIdValues(String uri) throws IOException { List ids; HttpGet get = new HttpGet(uri); diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/SystemProviderR4Test.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/SystemProviderR4Test.java index 249b90d6ae7..e6aba09b642 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/SystemProviderR4Test.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/SystemProviderR4Test.java @@ -666,19 +666,6 @@ public class SystemProviderR4Test extends BaseJpaR4Test { assertEquals(id1_4.toVersionless(), id2_4.toVersionless()); } - /** - * This is Gramahe's test transaction - it requires some set up in order to work - */ - @Test - @Disabled - public void testTransactionFromBundle3() throws Exception { - - InputStream bundleRes = SystemProviderR4Test.class.getResourceAsStream("/grahame-transaction.xml"); - String bundle = IOUtils.toString(bundleRes, StandardCharsets.UTF_8); - String response = myClient.transaction().withBundle(bundle).prettyPrint().execute(); - ourLog.info(response); - } - @Test public void testTransactionFromBundle4() throws Exception { InputStream bundleRes = SystemProviderR4Test.class.getResourceAsStream("/simone_bundle.xml"); @@ -850,7 +837,7 @@ public class SystemProviderR4Test extends BaseJpaR4Test { * FOrmat has changed, source is no longer valid */ @Test - @Disabled + @Disabled("input file needs to be upgraded to R4 format") public void testValidateUsingIncomingResources() throws Exception { FhirInstanceValidator val = new FhirInstanceValidator(myValidationSupport); RequestValidatingInterceptor interceptor = new RequestValidatingInterceptor(); diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/stresstest/StressTestParserTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/stresstest/StressTestParserTest.java index f0f5d41113c..3ed84e86520 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/stresstest/StressTestParserTest.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/stresstest/StressTestParserTest.java @@ -11,6 +11,7 @@ import org.slf4j.LoggerFactory; import java.io.IOException; +@Disabled("Stress Test") public class StressTestParserTest extends BaseTest { private static final Logger ourLog = LoggerFactory.getLogger(StressTestParserTest.class); @@ -20,7 +21,6 @@ public class StressTestParserTest extends BaseTest { * @throws IOException */ @Test - @Disabled public void test() throws IOException { FhirContext ctx = FhirContext.forR4Cached(); String input = loadResource("/org/hl7/fhir/r4/model/valueset/valuesets.xml"); diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/stresstest/StressTestR4Test.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/stresstest/StressTestR4Test.java index cc6b2c38010..546f102a6ae 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/stresstest/StressTestR4Test.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/stresstest/StressTestR4Test.java @@ -121,7 +121,7 @@ public class StressTestR4Test extends BaseResourceProviderR4Test { myPagingProvider.setMaximumPageSize(300); } - @Disabled + @Disabled("Stress test") @Test public void testNoDuplicatesInSearchResults() throws Exception { int resourceCount = 1000; @@ -198,7 +198,7 @@ public class StressTestR4Test extends BaseResourceProviderR4Test { assertEquals(resourceCount, ids.size()); } - @Disabled + @Disabled("Stress test") @Test public void testPageThroughLotsOfPages() { myStorageSettings.setIndexMissingFields(JpaStorageSettings.IndexEnabledEnum.DISABLED); @@ -270,7 +270,7 @@ public class StressTestR4Test extends BaseResourceProviderR4Test { assertEquals(count - 1000, Sets.newHashSet(ids).size()); } - @Disabled + @Disabled("Stress test") @Test public void testPageThroughLotsOfPages2() { myStorageSettings.setIndexMissingFields(JpaStorageSettings.IndexEnabledEnum.DISABLED); @@ -306,7 +306,7 @@ public class StressTestR4Test extends BaseResourceProviderR4Test { } - @Disabled + @Disabled("Stress test") @Test public void testSearchWithLargeNumberOfIncludes() { @@ -355,7 +355,7 @@ public class StressTestR4Test extends BaseResourceProviderR4Test { assertEquals(1001, resultsAndIncludes.size()); } - @Disabled + @Disabled("Stress test") @Test public void testUpdateListWithLargeNumberOfEntries() { int numPatients = 3000; @@ -395,7 +395,7 @@ public class StressTestR4Test extends BaseResourceProviderR4Test { } } - @Disabled + @Disabled("Stress test") @Test public void testMultithreadedSearch() throws Exception { Bundle input = new Bundle(); @@ -532,7 +532,7 @@ public class StressTestR4Test extends BaseResourceProviderR4Test { * JpaValidationSupportDstuXX be transactional, which it should have been * anyhow. */ - @Disabled + @Disabled("Stress test") @Test public void testMultithreadedSearchWithValidation() throws Exception { myServer.registerInterceptor(myRequestValidatingInterceptor); @@ -571,7 +571,7 @@ public class StressTestR4Test extends BaseResourceProviderR4Test { validateNoErrors(tasks); } - @Disabled + @Disabled("Stress test") @Test public void test_DeleteExpunge_withLargeBatchSizeManyResources() { // setup @@ -613,7 +613,7 @@ public class StressTestR4Test extends BaseResourceProviderR4Test { assertThat(deleteCount, is(equalTo(59))); } - @Disabled + @Disabled("Stress test") @Test public void testDeleteExpungeOperationOverLargeDataset() { myStorageSettings.setAllowMultipleDelete(true); diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookWithEventDefinitionR4Test.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookWithEventDefinitionR4Test.java index 08c5ed0c58f..59bc8a77ee7 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookWithEventDefinitionR4Test.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/subscription/resthook/RestHookWithEventDefinitionR4Test.java @@ -45,7 +45,7 @@ import java.util.List; /** * Ignored because this feature isn't implemented yet */ -@Disabled +@Disabled("Not implemented yet") public class RestHookWithEventDefinitionR4Test extends BaseResourceProviderR4Test { private static final Logger ourLog = org.slf4j.LoggerFactory.getLogger(RestHookWithEventDefinitionR4Test.class); diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/term/TerminologyLoaderSvcImgthlaTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/term/TerminologyLoaderSvcImgthlaTest.java index e636686ddc3..790120ac7bc 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/term/TerminologyLoaderSvcImgthlaTest.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/term/TerminologyLoaderSvcImgthlaTest.java @@ -47,7 +47,7 @@ public class TerminologyLoaderSvcImgthlaTest extends BaseLoaderTest { } @Test - @Disabled + @Disabled("Throws exception: HLA nomenclature terminology upload not yet fully implemented.") public void testLoadImgthlaMandatoryFilesOnly() throws IOException { addImgthlaMandatoryFilesToZip(myFiles); diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/term/TerminologyLoaderSvcSnomedCtTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/term/TerminologyLoaderSvcSnomedCtTest.java index 5b6abc742c5..7706f4244eb 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/term/TerminologyLoaderSvcSnomedCtTest.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/term/TerminologyLoaderSvcSnomedCtTest.java @@ -123,7 +123,7 @@ public class TerminologyLoaderSvcSnomedCtTest extends BaseLoaderTest { * This is just for trying stuff, it won't run without * local files external to the git repo */ - @Disabled + @Disabled("for manual testing") @Test public void testLoadSnomedCtAgainstRealFile() throws Exception { byte[] bytes = IOUtils.toByteArray(new FileInputStream("/Users/james/Downloads/SnomedCT_Release_INT_20160131_Full.zip")); diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcDeltaR4Test.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcDeltaR4Test.java index e331f30585a..dd0fe20bf61 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcDeltaR4Test.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcDeltaR4Test.java @@ -20,7 +20,6 @@ import org.hl7.fhir.r4.model.Parameters; import org.hl7.fhir.r4.model.StringType; import org.hl7.fhir.r4.model.ValueSet; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -451,7 +450,6 @@ public class TerminologySvcDeltaR4Test extends BaseJpaR4Test { } @Test - @Disabled public void testAddWithPropertiesAndDesignations() { // Create not-present @@ -460,10 +458,8 @@ public class TerminologySvcDeltaR4Test extends BaseJpaR4Test { cs.setUrl("http://foo/cs"); cs.setContent(CodeSystem.CodeSystemContentMode.NOTPRESENT); cs.setVersion("1.2.3"); - myCodeSystemDao.create(cs); - CodeSystem delta = new CodeSystem(); - CodeSystem.ConceptDefinitionComponent concept = delta + CodeSystem.ConceptDefinitionComponent concept = cs .addConcept() .setCode("lunch") .setDisplay("I'm having dog food"); @@ -483,6 +479,7 @@ public class TerminologySvcDeltaR4Test extends BaseJpaR4Test { concept.addProperty() .setCode("useless_sct_code") .setValue(new Coding("http://snomed.info", "1234567", "Choked on large meal (finding)")); + myCodeSystemDao.create(cs, mySrd); IValidationSupport.LookupCodeResult result = myTermSvc.lookupCode(new ValidationSupportContext(myValidationSupport), "http://foo/cs", "lunch", null); assertEquals(true, result.isFound()); diff --git a/hapi-fhir-jpaserver-test-utilities/src/test/resources/questionnaire-sdc-profile-example-ussg-fht.xml b/hapi-fhir-jpaserver-test-r4/src/test/resources/questionnaire-sdc-profile-example-ussg-fht.xml similarity index 100% rename from hapi-fhir-jpaserver-test-utilities/src/test/resources/questionnaire-sdc-profile-example-ussg-fht.xml rename to hapi-fhir-jpaserver-test-r4/src/test/resources/questionnaire-sdc-profile-example-ussg-fht.xml diff --git a/hapi-fhir-jpaserver-test-r4b/pom.xml b/hapi-fhir-jpaserver-test-r4b/pom.xml index 9c3a6a89453..e44617ae0d6 100644 --- a/hapi-fhir-jpaserver-test-r4b/pom.xml +++ b/hapi-fhir-jpaserver-test-r4b/pom.xml @@ -6,8 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-test-r5/pom.xml b/hapi-fhir-jpaserver-test-r5/pom.xml index 1c89efe3595..782c760a67f 100644 --- a/hapi-fhir-jpaserver-test-r5/pom.xml +++ b/hapi-fhir-jpaserver-test-r5/pom.xml @@ -6,8 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-test-r5/src/test/java/ca/uhn/fhir/jpa/subscription/BaseSubscriptionsR5Test.java b/hapi-fhir-jpaserver-test-r5/src/test/java/ca/uhn/fhir/jpa/subscription/BaseSubscriptionsR5Test.java index a618bc5385d..9a76358810b 100644 --- a/hapi-fhir-jpaserver-test-r5/src/test/java/ca/uhn/fhir/jpa/subscription/BaseSubscriptionsR5Test.java +++ b/hapi-fhir-jpaserver-test-r5/src/test/java/ca/uhn/fhir/jpa/subscription/BaseSubscriptionsR5Test.java @@ -46,7 +46,7 @@ import java.util.Collections; import java.util.Enumeration; import java.util.List; -@Disabled +@Disabled("abstract") public abstract class BaseSubscriptionsR5Test extends BaseResourceProviderR5Test { private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseSubscriptionsR5Test.class); protected static int ourListenerPort; diff --git a/hapi-fhir-jpaserver-test-utilities/pom.xml b/hapi-fhir-jpaserver-test-utilities/pom.xml index 7ad67eb5a2a..9b787c8772b 100644 --- a/hapi-fhir-jpaserver-test-utilities/pom.xml +++ b/hapi-fhir-jpaserver-test-utilities/pom.xml @@ -6,8 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/provider/BaseResourceProviderR4Test.java b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/provider/BaseResourceProviderR4Test.java index 039c11635eb..923b7e6b238 100644 --- a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/provider/BaseResourceProviderR4Test.java +++ b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/provider/BaseResourceProviderR4Test.java @@ -38,6 +38,9 @@ import ca.uhn.fhir.rest.server.interceptor.CorsInterceptor; import ca.uhn.fhir.test.utilities.HttpClientExtension; import ca.uhn.fhir.test.utilities.server.RestfulServerConfigurerExtension; import ca.uhn.fhir.test.utilities.server.RestfulServerExtension; +import org.apache.commons.io.IOUtils; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; import org.hl7.fhir.r4.model.Bundle; import org.hl7.fhir.r4.model.Bundle.BundleEntryComponent; import org.hl7.fhir.r4.model.Parameters; @@ -49,6 +52,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.web.cors.CorsConfiguration; +import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -210,4 +215,19 @@ public abstract class BaseResourceProviderR4Test extends BaseJpaR4Test { return false; } + protected List searchAndReturnUnqualifiedVersionlessIdValues(String uri) throws IOException { + List ids; + HttpGet get = new HttpGet(uri); + + try (CloseableHttpResponse response = ourHttpClient.execute(get)) { + String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); + ourLog.info(resp); + Bundle bundle = myFhirContext.newXmlParser().parseResource(Bundle.class, resp); + ids = toUnqualifiedVersionlessIdValues(bundle); + ourLog.debug("Observation: \n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle)); + } + + return ids; + } + } diff --git a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/BaseJpaDstu3Test.java b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/BaseJpaDstu3Test.java index 7f8bbfa6ca5..a699670da89 100644 --- a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/BaseJpaDstu3Test.java +++ b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/BaseJpaDstu3Test.java @@ -98,6 +98,7 @@ import org.hl7.fhir.dstu3.model.Meta; import org.hl7.fhir.dstu3.model.NamingSystem; import org.hl7.fhir.dstu3.model.Observation; import org.hl7.fhir.dstu3.model.OperationDefinition; +import org.hl7.fhir.dstu3.model.OperationOutcome; import org.hl7.fhir.dstu3.model.Organization; import org.hl7.fhir.dstu3.model.Patient; import org.hl7.fhir.dstu3.model.Practitioner; @@ -414,6 +415,10 @@ public abstract class BaseJpaDstu3Test extends BaseJpaTest { myJpaValidationSupportChainDstu3.invalidateCaches(); } + public void assertHasErrors(OperationOutcome theOperationOutcome) { + Dstu3ValidationTestUtil.assertHasErrors(theOperationOutcome); + } + /** * Creates a single {@link ConceptMap} entity that includes: *
diff --git a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/BaseJpaR4Test.java b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/BaseJpaR4Test.java index 0a32d6177a0..1a067904d84 100644 --- a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/BaseJpaR4Test.java +++ b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/BaseJpaR4Test.java @@ -153,6 +153,7 @@ import org.hl7.fhir.r4.model.MolecularSequence; import org.hl7.fhir.r4.model.NamingSystem; import org.hl7.fhir.r4.model.Observation; import org.hl7.fhir.r4.model.OperationDefinition; +import org.hl7.fhir.r4.model.OperationOutcome; import org.hl7.fhir.r4.model.Organization; import org.hl7.fhir.r4.model.OrganizationAffiliation; import org.hl7.fhir.r4.model.Patient; @@ -883,6 +884,18 @@ public abstract class BaseJpaR4Test extends BaseJpaTest implements ITestDataBuil return uuid; } + public void assertHasErrors(OperationOutcome theOperationOutcome) { + R4ValidationTestUtil.assertHasErrors(theOperationOutcome); + } + + public void assertHasWarnings(OperationOutcome theOperationOutcome) { + R4ValidationTestUtil.assertHasWarnings(theOperationOutcome); + } + + public void assertHasNoErrors(OperationOutcome theOperationOutcome) { + R4ValidationTestUtil.assertHasNoErrors(theOperationOutcome); + } + public class ValidationPolicyAdvisor implements IValidationPolicyAdvisor { @Override public ReferenceValidationPolicy policyForReference(IResourceValidator validator, Object appContext, String path, String url) { diff --git a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/Dstu3ValidationTestUtil.java b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/Dstu3ValidationTestUtil.java new file mode 100644 index 00000000000..a369f94b1f8 --- /dev/null +++ b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/Dstu3ValidationTestUtil.java @@ -0,0 +1,40 @@ +package ca.uhn.fhir.jpa.test; + +import ca.uhn.fhir.context.FhirContext; +import org.hl7.fhir.dstu3.model.OperationOutcome; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public final class Dstu3ValidationTestUtil { + private static final FhirContext ourFhirContext = FhirContext.forR4Cached(); + + private Dstu3ValidationTestUtil() { + } + + public static void assertHasErrors(OperationOutcome theOperationOutcome) { + assertTrue(hasValidationIssuesWithSeverity(theOperationOutcome, OperationOutcome.IssueSeverity.ERROR), "Expected validation errors, found none"); + } + + public static void assertHasWarnings(OperationOutcome theOperationOutcome) { + assertTrue(hasValidationIssuesWithSeverity(theOperationOutcome, OperationOutcome.IssueSeverity.WARNING), "Expected validation warnings, found none"); + } + + public static void assertHasNoErrors(OperationOutcome theOperationOutcome) { + assertFalse(hasValidationIssuesWithSeverity(theOperationOutcome, OperationOutcome.IssueSeverity.ERROR), "Expected no validation errors, found some"); + } + + // TODO KHS use this in places that call assertHasErrors to strengthen the assert (today many of those tests just assert a string is somewhere in the OperationOutcome, + // when it would be stronger to assert the string is in the diagnostics of an error) + private static boolean hasValidationIssuesWithSeverity(OperationOutcome theOperationOutcome, OperationOutcome.IssueSeverity theSeverity) { + return theOperationOutcome.getIssue().stream().anyMatch(t -> t.getSeverity() == theSeverity); + } + + public static String toString(OperationOutcome theOperationOutcome) { + return ourFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(theOperationOutcome); + } + + public static void assertErrorDiagnosticContainsString(OperationOutcome theOo, String theExpectedDiagnosticSubstring) { + assertTrue(theOo.getIssue().stream().anyMatch(t -> t.getSeverity() == OperationOutcome.IssueSeverity.ERROR && t.getDiagnostics().contains(theExpectedDiagnosticSubstring)), "Expected a validation error with diagnostic containing '" + theExpectedDiagnosticSubstring+ "', found none"); + } +} diff --git a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/R4ValidationTestUtil.java b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/R4ValidationTestUtil.java new file mode 100644 index 00000000000..340dc2352ed --- /dev/null +++ b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/R4ValidationTestUtil.java @@ -0,0 +1,40 @@ +package ca.uhn.fhir.jpa.test; + +import ca.uhn.fhir.context.FhirContext; +import org.hl7.fhir.r4.model.OperationOutcome; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public final class R4ValidationTestUtil { + private static final FhirContext ourFhirContext = FhirContext.forR4Cached(); + + private R4ValidationTestUtil() { + } + + public static void assertHasErrors(OperationOutcome theOperationOutcome) { + assertTrue(hasValidationIssuesWithSeverity(theOperationOutcome, OperationOutcome.IssueSeverity.ERROR), "Expected validation errors, found none"); + } + + public static void assertHasWarnings(OperationOutcome theOperationOutcome) { + assertTrue(hasValidationIssuesWithSeverity(theOperationOutcome, OperationOutcome.IssueSeverity.WARNING), "Expected validation warnings, found none"); + } + + public static void assertHasNoErrors(OperationOutcome theOperationOutcome) { + assertFalse(hasValidationIssuesWithSeverity(theOperationOutcome, OperationOutcome.IssueSeverity.ERROR), "Expected no validation errors, found some"); + } + + // TODO KHS use this in places that call assertHasErrors to strengthen the assert (today many of those tests just assert a string is somewhere in the OperationOutcome, + // when it would be stronger to assert the string is in the diagnostics of an error) + private static boolean hasValidationIssuesWithSeverity(OperationOutcome theOperationOutcome, OperationOutcome.IssueSeverity theSeverity) { + return theOperationOutcome.getIssue().stream().anyMatch(t -> t.getSeverity() == theSeverity); + } + + public static String toString(OperationOutcome theOperationOutcome) { + return ourFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(theOperationOutcome); + } + + public static void assertErrorDiagnosticContainsString(OperationOutcome theOo, String theExpectedDiagnosticSubstring) { + assertTrue(theOo.getIssue().stream().anyMatch(t -> t.getSeverity() == OperationOutcome.IssueSeverity.ERROR && t.getDiagnostics().contains(theExpectedDiagnosticSubstring)), "Expected a validation error with diagnostic containing '" + theExpectedDiagnosticSubstring+ "', found none"); + } +} diff --git a/hapi-fhir-jpaserver-test-utilities/src/test/resources/grahame-transaction.xml b/hapi-fhir-jpaserver-test-utilities/src/test/resources/grahame-transaction.xml deleted file mode 100644 index d3baf5b5aa8..00000000000 --- a/hapi-fhir-jpaserver-test-utilities/src/test/resources/grahame-transaction.xml +++ /dev/null @@ -1,285 +0,0 @@ - - - - - - - - - - - - -
Make sure links are updated: Patient -
-
- - - - - - - -
-
- - - - -
- - - - - - - -
Snipped for brevity
-
- - - - - - - - - - -
-
- - - - - -
- - - - - - -
Snipped for brevity
-
- - - - - - - - - - -
-
- - - - - -
- - - - - - - -
Snipped
-
- - - - -
-
- - - - -
- - - - - - - -
Snipped
-
- - - - -
-
- - - - -
- - - - - - - -
Snipped
-
- - - - -
-
- - - - - -
- - - - - - -
Snipped
-
- - - - - - - - - -
-
- - - - -
- - - - - - - -
Snipped
-
- - - - - - - - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
\ No newline at end of file diff --git a/hapi-fhir-jpaserver-uhnfhirtest/pom.xml b/hapi-fhir-jpaserver-uhnfhirtest/pom.xml index 2a0c24e8643..23a6fa4d01e 100644 --- a/hapi-fhir-jpaserver-uhnfhirtest/pom.xml +++ b/hapi-fhir-jpaserver-uhnfhirtest/pom.xml @@ -5,8 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-server-mdm/pom.xml b/hapi-fhir-server-mdm/pom.xml index bf5f2f7e63a..1edb123e287 100644 --- a/hapi-fhir-server-mdm/pom.xml +++ b/hapi-fhir-server-mdm/pom.xml @@ -7,8 +7,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-server-openapi/pom.xml b/hapi-fhir-server-openapi/pom.xml index 1aa1f3964e3..e2bc1485350 100644 --- a/hapi-fhir-server-openapi/pom.xml +++ b/hapi-fhir-server-openapi/pom.xml @@ -5,8 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-server/pom.xml b/hapi-fhir-server/pom.xml index 9ac559847fa..a657043e0e1 100644 --- a/hapi-fhir-server/pom.xml +++ b/hapi-fhir-server/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-serviceloaders/hapi-fhir-caching-api/pom.xml b/hapi-fhir-serviceloaders/hapi-fhir-caching-api/pom.xml index 1ee90c11193..86282704747 100644 --- a/hapi-fhir-serviceloaders/hapi-fhir-caching-api/pom.xml +++ b/hapi-fhir-serviceloaders/hapi-fhir-caching-api/pom.xml @@ -7,8 +7,7 @@ hapi-fhir-serviceloaders ca.uhn.hapi.fhir - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-serviceloaders/hapi-fhir-caching-caffeine/pom.xml b/hapi-fhir-serviceloaders/hapi-fhir-caching-caffeine/pom.xml index 7f0b4cb5393..7f37b40374f 100644 --- a/hapi-fhir-serviceloaders/hapi-fhir-caching-caffeine/pom.xml +++ b/hapi-fhir-serviceloaders/hapi-fhir-caching-caffeine/pom.xml @@ -7,8 +7,7 @@ hapi-fhir-serviceloaders ca.uhn.hapi.fhir - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../pom.xml @@ -21,8 +20,7 @@ ca.uhn.hapi.fhir hapi-fhir-caching-api - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT com.github.ben-manes.caffeine diff --git a/hapi-fhir-serviceloaders/hapi-fhir-caching-guava/pom.xml b/hapi-fhir-serviceloaders/hapi-fhir-caching-guava/pom.xml index daf46316b28..d81e54dd700 100644 --- a/hapi-fhir-serviceloaders/hapi-fhir-caching-guava/pom.xml +++ b/hapi-fhir-serviceloaders/hapi-fhir-caching-guava/pom.xml @@ -7,8 +7,7 @@ hapi-fhir-serviceloaders ca.uhn.hapi.fhir - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-serviceloaders/hapi-fhir-caching-testing/pom.xml b/hapi-fhir-serviceloaders/hapi-fhir-caching-testing/pom.xml index c31afccb6c6..977633cac5d 100644 --- a/hapi-fhir-serviceloaders/hapi-fhir-caching-testing/pom.xml +++ b/hapi-fhir-serviceloaders/hapi-fhir-caching-testing/pom.xml @@ -7,8 +7,7 @@ hapi-fhir ca.uhn.hapi.fhir - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../../pom.xml diff --git a/hapi-fhir-serviceloaders/pom.xml b/hapi-fhir-serviceloaders/pom.xml index 9ad1901fcb1..3ccec9137f6 100644 --- a/hapi-fhir-serviceloaders/pom.xml +++ b/hapi-fhir-serviceloaders/pom.xml @@ -5,7 +5,7 @@ hapi-deployable-pom ca.uhn.hapi.fhir - 6.5.9-SNAPSHOT + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/pom.xml index e252a859ba6..59c641dcd0d 100644 --- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/pom.xml +++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/pom.xml @@ -5,8 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-apache/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-apache/pom.xml index 654e5b26f4c..e96dd9eea5f 100644 --- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-apache/pom.xml +++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-apache/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir-spring-boot-samples - 6.5.9-SNAPSHOT + 6.5.10-SNAPSHOT hapi-fhir-spring-boot-sample-client-apache diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-okhttp/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-okhttp/pom.xml index fc133911fe5..194413c005a 100644 --- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-okhttp/pom.xml +++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-okhttp/pom.xml @@ -5,8 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir-spring-boot-samples - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT hapi-fhir-spring-boot-sample-client-okhttp diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-server-jersey/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-server-jersey/pom.xml index 921216e8166..92891b6bf2a 100644 --- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-server-jersey/pom.xml +++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-server-jersey/pom.xml @@ -5,8 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir-spring-boot-samples - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT hapi-fhir-spring-boot-sample-server-jersey diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/pom.xml index 8c8264d5925..239481af218 100644 --- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/pom.xml +++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/pom.xml @@ -5,8 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir-spring-boot - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT hapi-fhir-spring-boot-samples diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-starter/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-starter/pom.xml index 40503f51578..7d02ad696cf 100644 --- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-starter/pom.xml +++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-starter/pom.xml @@ -5,8 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-spring-boot/pom.xml b/hapi-fhir-spring-boot/pom.xml index 07414ae1840..38481791d21 100644 --- a/hapi-fhir-spring-boot/pom.xml +++ b/hapi-fhir-spring-boot/pom.xml @@ -5,8 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-sql-migrate/pom.xml b/hapi-fhir-sql-migrate/pom.xml index f60f09c4c5e..60b320dab9a 100644 --- a/hapi-fhir-sql-migrate/pom.xml +++ b/hapi-fhir-sql-migrate/pom.xml @@ -5,8 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-storage-batch2-jobs/pom.xml b/hapi-fhir-storage-batch2-jobs/pom.xml index 228e8647f17..5e8d42cb624 100644 --- a/hapi-fhir-storage-batch2-jobs/pom.xml +++ b/hapi-fhir-storage-batch2-jobs/pom.xml @@ -5,8 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml 4.0.0 diff --git a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/export/WriteBinaryStep.java b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/export/WriteBinaryStep.java index 9b3d4d0d8b3..02deacb436c 100644 --- a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/export/WriteBinaryStep.java +++ b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/export/WriteBinaryStep.java @@ -25,16 +25,16 @@ import ca.uhn.fhir.batch2.api.JobExecutionFailedException; import ca.uhn.fhir.batch2.api.RunOutcome; import ca.uhn.fhir.batch2.api.StepExecutionDetails; import ca.uhn.fhir.batch2.jobs.export.models.BulkExportBinaryFileId; -import ca.uhn.fhir.batch2.jobs.export.models.ExpandedResourcesList; import ca.uhn.fhir.batch2.jobs.export.models.BulkExportJobParameters; +import ca.uhn.fhir.batch2.jobs.export.models.ExpandedResourcesList; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.interceptor.model.RequestPartitionId; import ca.uhn.fhir.jpa.api.dao.DaoRegistry; import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao; import ca.uhn.fhir.jpa.api.model.DaoMethodOutcome; -import ca.uhn.fhir.rest.api.server.SystemRequestDetails; import ca.uhn.fhir.rest.api.Constants; +import ca.uhn.fhir.rest.api.server.SystemRequestDetails; import ca.uhn.fhir.util.BinaryUtil; import org.hl7.fhir.instance.model.api.IBaseBinary; import org.hl7.fhir.instance.model.api.IIdType; diff --git a/hapi-fhir-storage-batch2-jobs/src/test/java/ca/uhn/fhir/batch2/jobs/export/WriteBinaryStepTest.java b/hapi-fhir-storage-batch2-jobs/src/test/java/ca/uhn/fhir/batch2/jobs/export/WriteBinaryStepTest.java index 22f2218c5cb..c14d8e25519 100644 --- a/hapi-fhir-storage-batch2-jobs/src/test/java/ca/uhn/fhir/batch2/jobs/export/WriteBinaryStepTest.java +++ b/hapi-fhir-storage-batch2-jobs/src/test/java/ca/uhn/fhir/batch2/jobs/export/WriteBinaryStepTest.java @@ -6,8 +6,8 @@ import ca.uhn.fhir.batch2.api.JobExecutionFailedException; import ca.uhn.fhir.batch2.api.RunOutcome; import ca.uhn.fhir.batch2.api.StepExecutionDetails; import ca.uhn.fhir.batch2.jobs.export.models.BulkExportBinaryFileId; -import ca.uhn.fhir.batch2.jobs.export.models.ExpandedResourcesList; import ca.uhn.fhir.batch2.jobs.export.models.BulkExportJobParameters; +import ca.uhn.fhir.batch2.jobs.export.models.ExpandedResourcesList; import ca.uhn.fhir.batch2.model.JobInstance; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.interceptor.model.RequestPartitionId; diff --git a/hapi-fhir-storage-batch2-jobs/src/test/java/ca/uhn/fhir/batch2/jobs/services/Batch2JobRunnerImplTest.java b/hapi-fhir-storage-batch2-jobs/src/test/java/ca/uhn/fhir/batch2/jobs/services/Batch2JobRunnerImplTest.java index 50cc31d89ab..2e75bd1f49f 100644 --- a/hapi-fhir-storage-batch2-jobs/src/test/java/ca/uhn/fhir/batch2/jobs/services/Batch2JobRunnerImplTest.java +++ b/hapi-fhir-storage-batch2-jobs/src/test/java/ca/uhn/fhir/batch2/jobs/services/Batch2JobRunnerImplTest.java @@ -8,8 +8,8 @@ import ca.uhn.fhir.batch2.model.StatusEnum; import ca.uhn.fhir.interceptor.model.RequestPartitionId; import ca.uhn.fhir.jpa.api.model.Batch2JobInfo; import ca.uhn.fhir.jpa.api.model.BulkExportParameters; -import ca.uhn.fhir.jpa.batch.models.Batch2BaseJobParameters; import ca.uhn.fhir.jpa.api.svc.IBatch2JobRunner; +import ca.uhn.fhir.jpa.batch.models.Batch2BaseJobParameters; import ca.uhn.fhir.jpa.bulk.export.model.BulkExportJobStatusEnum; import ca.uhn.fhir.util.Batch2JobDefinitionConstants; import ch.qos.logback.classic.Level; @@ -31,8 +31,8 @@ import java.util.Date; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.never; diff --git a/hapi-fhir-storage-batch2-test-utilities/pom.xml b/hapi-fhir-storage-batch2-test-utilities/pom.xml index 0975820d7e7..4087c44f638 100644 --- a/hapi-fhir-storage-batch2-test-utilities/pom.xml +++ b/hapi-fhir-storage-batch2-test-utilities/pom.xml @@ -7,8 +7,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-storage-batch2/pom.xml b/hapi-fhir-storage-batch2/pom.xml index ed8bec9ece7..9c4b201e853 100644 --- a/hapi-fhir-storage-batch2/pom.xml +++ b/hapi-fhir-storage-batch2/pom.xml @@ -7,8 +7,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-storage-cr/pom.xml b/hapi-fhir-storage-cr/pom.xml index 9deef4b95a6..ba8cbbd0738 100644 --- a/hapi-fhir-storage-cr/pom.xml +++ b/hapi-fhir-storage-cr/pom.xml @@ -7,8 +7,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/common/Searches.java b/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/common/Searches.java index eb3ffb09f17..0091129cc1e 100644 --- a/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/common/Searches.java +++ b/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/common/Searches.java @@ -28,7 +28,6 @@ import ca.uhn.fhir.rest.param.UriOrListParam; import ca.uhn.fhir.rest.param.UriParam; import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.instance.model.api.IPrimitiveType; - import org.opencds.cqf.cql.evaluator.fhir.util.Canonicals; import java.util.ArrayList; diff --git a/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/r4/ISupplementalDataSearchParamUser.java b/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/r4/ISupplementalDataSearchParamUser.java index 41cadef6396..8dab94933f4 100644 --- a/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/r4/ISupplementalDataSearchParamUser.java +++ b/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/r4/ISupplementalDataSearchParamUser.java @@ -22,16 +22,22 @@ package ca.uhn.fhir.cr.r4; import ca.uhn.fhir.cr.common.IDaoRegistryUser; import ca.uhn.fhir.cr.common.Searches; import ca.uhn.fhir.rest.api.server.RequestDetails; -import org.hl7.fhir.r4.model.*; +import org.hl7.fhir.r4.model.CodeableConcept; +import org.hl7.fhir.r4.model.Coding; +import org.hl7.fhir.r4.model.ContactDetail; +import org.hl7.fhir.r4.model.ContactPoint; import org.hl7.fhir.r4.model.Enumerations.PublicationStatus; import org.hl7.fhir.r4.model.Enumerations.SearchParamType; +import org.hl7.fhir.r4.model.SearchParameter; import org.hl7.fhir.r4.model.SearchParameter.XPathUsageType; import java.util.Calendar; import java.util.Collections; import java.util.List; -import static ca.uhn.fhir.cr.common.SupplementalDataConstants.*; +import static ca.uhn.fhir.cr.common.SupplementalDataConstants.MEASUREREPORT_MEASURE_SUPPLEMENTALDATA_EXTENSION; +import static ca.uhn.fhir.cr.common.SupplementalDataConstants.MEASUREREPORT_SUPPLEMENTALDATA_SEARCHPARAMETER_URL; +import static ca.uhn.fhir.cr.common.SupplementalDataConstants.MEASUREREPORT_SUPPLEMENTALDATA_SEARCHPARAMETER_VERSION; public interface ISupplementalDataSearchParamUser extends IDaoRegistryUser { diff --git a/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/r4/measure/MeasureService.java b/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/r4/measure/MeasureService.java index 94ddbb68b99..3ebce00a666 100644 --- a/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/r4/measure/MeasureService.java +++ b/hapi-fhir-storage-cr/src/main/java/ca/uhn/fhir/cr/r4/measure/MeasureService.java @@ -31,7 +31,6 @@ import ca.uhn.fhir.rest.api.server.IBundleProvider; import ca.uhn.fhir.rest.api.server.RequestDetails; import ca.uhn.fhir.rest.client.api.IGenericClient; import ca.uhn.fhir.rest.param.ReferenceParam; -import ca.uhn.fhir.rest.server.IPagingProvider; import org.apache.commons.lang3.StringUtils; import org.cqframework.cql.cql2elm.LibrarySourceProvider; import org.hl7.fhir.instance.model.api.IBaseResource; diff --git a/hapi-fhir-storage-cr/src/test/java/ca/uhn/fhir/cr/r4/HapiFhirDalR4Test.java b/hapi-fhir-storage-cr/src/test/java/ca/uhn/fhir/cr/r4/HapiFhirDalR4Test.java index 02847718c8f..6647b80c15b 100644 --- a/hapi-fhir-storage-cr/src/test/java/ca/uhn/fhir/cr/r4/HapiFhirDalR4Test.java +++ b/hapi-fhir-storage-cr/src/test/java/ca/uhn/fhir/cr/r4/HapiFhirDalR4Test.java @@ -2,12 +2,11 @@ package ca.uhn.fhir.cr.r4; import ca.uhn.fhir.cr.BaseCrR4Test; import ca.uhn.fhir.cr.common.HapiFhirDal; -import ca.uhn.fhir.rest.server.IPagingProvider; +import ca.uhn.fhir.jpa.api.config.JpaStorageSettings; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.junit.jupiter.SpringExtension; -import ca.uhn.fhir.jpa.api.config.JpaStorageSettings; import static org.junit.jupiter.api.Assertions.assertEquals; /** diff --git a/hapi-fhir-storage-mdm/pom.xml b/hapi-fhir-storage-mdm/pom.xml index 60066a5ff50..8a176956a38 100644 --- a/hapi-fhir-storage-mdm/pom.xml +++ b/hapi-fhir-storage-mdm/pom.xml @@ -5,8 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml 4.0.0 diff --git a/hapi-fhir-storage-test-utilities/pom.xml b/hapi-fhir-storage-test-utilities/pom.xml index 9999fe09f01..c7f665dcdf4 100644 --- a/hapi-fhir-storage-test-utilities/pom.xml +++ b/hapi-fhir-storage-test-utilities/pom.xml @@ -5,8 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml 4.0.0 diff --git a/hapi-fhir-storage/pom.xml b/hapi-fhir-storage/pom.xml index 6f11ff060bc..0e88047590c 100644 --- a/hapi-fhir-storage/pom.xml +++ b/hapi-fhir-storage/pom.xml @@ -5,8 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/dao/IFhirResourceDao.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/dao/IFhirResourceDao.java index f2f08bc7534..7dc9b110279 100644 --- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/dao/IFhirResourceDao.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/dao/IFhirResourceDao.java @@ -314,7 +314,9 @@ public interface IFhirResourceDao extends IDao { * Not supported in DSTU1! * * @param theRequestDetails The request details including permissions and partitioning information + * @return MethodOutcome even if the resource fails validation it should still successfully return with a response status of 200 */ + MethodOutcome validate(T theResource, IIdType theId, String theRawResource, EncodingEnum theEncoding, ValidationModeEnum theMode, String theProfile, RequestDetails theRequestDetails); RuntimeResourceDefinition validateCriteriaAndReturnResourceDefinition(String criteria); diff --git a/hapi-fhir-structures-dstu2.1/pom.xml b/hapi-fhir-structures-dstu2.1/pom.xml index d0084401731..5c468272150 100644 --- a/hapi-fhir-structures-dstu2.1/pom.xml +++ b/hapi-fhir-structures-dstu2.1/pom.xml @@ -5,8 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-structures-dstu2/pom.xml b/hapi-fhir-structures-dstu2/pom.xml index ef71b937d84..5b982200c88 100644 --- a/hapi-fhir-structures-dstu2/pom.xml +++ b/hapi-fhir-structures-dstu2/pom.xml @@ -4,8 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-structures-dstu3/pom.xml b/hapi-fhir-structures-dstu3/pom.xml index c8fa2d3c449..70ba35217c3 100644 --- a/hapi-fhir-structures-dstu3/pom.xml +++ b/hapi-fhir-structures-dstu3/pom.xml @@ -5,8 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-structures-hl7org-dstu2/pom.xml b/hapi-fhir-structures-hl7org-dstu2/pom.xml index ccd93f02687..7641ad7f6b4 100644 --- a/hapi-fhir-structures-hl7org-dstu2/pom.xml +++ b/hapi-fhir-structures-hl7org-dstu2/pom.xml @@ -5,8 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-structures-r4/pom.xml b/hapi-fhir-structures-r4/pom.xml index 1e52e3f4500..6e84709ca48 100644 --- a/hapi-fhir-structures-r4/pom.xml +++ b/hapi-fhir-structures-r4/pom.xml @@ -5,8 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/util/UrlUtilTest.java b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/util/UrlUtilTest.java index d8894a0e088..7da512e59d1 100644 --- a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/util/UrlUtilTest.java +++ b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/util/UrlUtilTest.java @@ -14,8 +14,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; public class UrlUtilTest { diff --git a/hapi-fhir-structures-r4b/pom.xml b/hapi-fhir-structures-r4b/pom.xml index bd7ade816dd..8418c15dfaa 100644 --- a/hapi-fhir-structures-r4b/pom.xml +++ b/hapi-fhir-structures-r4b/pom.xml @@ -5,8 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-structures-r5/pom.xml b/hapi-fhir-structures-r5/pom.xml index 37ba353db07..86a356a6a24 100644 --- a/hapi-fhir-structures-r5/pom.xml +++ b/hapi-fhir-structures-r5/pom.xml @@ -5,8 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-test-utilities/pom.xml b/hapi-fhir-test-utilities/pom.xml index 22b247f556e..3823d54bfbd 100644 --- a/hapi-fhir-test-utilities/pom.xml +++ b/hapi-fhir-test-utilities/pom.xml @@ -5,8 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-testpage-overlay/pom.xml b/hapi-fhir-testpage-overlay/pom.xml index 4c7c761c97c..ba83c4cd634 100644 --- a/hapi-fhir-testpage-overlay/pom.xml +++ b/hapi-fhir-testpage-overlay/pom.xml @@ -5,8 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-validation-resources-dstu2.1/pom.xml b/hapi-fhir-validation-resources-dstu2.1/pom.xml index ad099aa8be8..26249495510 100644 --- a/hapi-fhir-validation-resources-dstu2.1/pom.xml +++ b/hapi-fhir-validation-resources-dstu2.1/pom.xml @@ -4,8 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-validation-resources-dstu2/pom.xml b/hapi-fhir-validation-resources-dstu2/pom.xml index 73c4ab82734..383a0932aec 100644 --- a/hapi-fhir-validation-resources-dstu2/pom.xml +++ b/hapi-fhir-validation-resources-dstu2/pom.xml @@ -4,8 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-validation-resources-dstu3/pom.xml b/hapi-fhir-validation-resources-dstu3/pom.xml index 0d67e9ae1b4..e17252ca3ac 100644 --- a/hapi-fhir-validation-resources-dstu3/pom.xml +++ b/hapi-fhir-validation-resources-dstu3/pom.xml @@ -4,8 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-validation-resources-r4/pom.xml b/hapi-fhir-validation-resources-r4/pom.xml index b44d9106712..a66b9709399 100644 --- a/hapi-fhir-validation-resources-r4/pom.xml +++ b/hapi-fhir-validation-resources-r4/pom.xml @@ -4,8 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-validation-resources-r4b/pom.xml b/hapi-fhir-validation-resources-r4b/pom.xml index 98057f92ee1..1357ca45d0b 100644 --- a/hapi-fhir-validation-resources-r4b/pom.xml +++ b/hapi-fhir-validation-resources-r4b/pom.xml @@ -4,8 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-validation-resources-r5/pom.xml b/hapi-fhir-validation-resources-r5/pom.xml index f273aa5ef7f..2167548f9e2 100644 --- a/hapi-fhir-validation-resources-r5/pom.xml +++ b/hapi-fhir-validation-resources-r5/pom.xml @@ -4,8 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-validation/pom.xml b/hapi-fhir-validation/pom.xml index 674c34520bc..bf5b7b2bbb0 100644 --- a/hapi-fhir-validation/pom.xml +++ b/hapi-fhir-validation/pom.xml @@ -5,8 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-tinder-plugin/pom.xml b/hapi-tinder-plugin/pom.xml index f03efe1b164..c448f68c6c8 100644 --- a/hapi-tinder-plugin/pom.xml +++ b/hapi-tinder-plugin/pom.xml @@ -5,8 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../pom.xml diff --git a/hapi-tinder-test/pom.xml b/hapi-tinder-test/pom.xml index 779ec51e9a8..28d0bb02bb8 100644 --- a/hapi-tinder-test/pom.xml +++ b/hapi-tinder-test/pom.xml @@ -4,8 +4,7 @@ ca.uhn.hapi.fhir hapi-fhir - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../pom.xml diff --git a/pom.xml b/pom.xml index 4892f6d53ad..b4835b215cd 100644 --- a/pom.xml +++ b/pom.xml @@ -7,8 +7,7 @@ ca.uhn.hapi.fhir hapi-fhir pom - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT HAPI-FHIR An open-source implementation of the FHIR specification in Java. https://hapifhir.io diff --git a/tests/hapi-fhir-base-test-jaxrsserver-kotlin/pom.xml b/tests/hapi-fhir-base-test-jaxrsserver-kotlin/pom.xml index e7f649a56b3..e04d0cb69c7 100644 --- a/tests/hapi-fhir-base-test-jaxrsserver-kotlin/pom.xml +++ b/tests/hapi-fhir-base-test-jaxrsserver-kotlin/pom.xml @@ -6,8 +6,7 @@ ca.uhn.hapi.fhir hapi-fhir - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../../pom.xml diff --git a/tests/hapi-fhir-base-test-mindeps-client/pom.xml b/tests/hapi-fhir-base-test-mindeps-client/pom.xml index 438ff1b8697..7181fe66a4c 100644 --- a/tests/hapi-fhir-base-test-mindeps-client/pom.xml +++ b/tests/hapi-fhir-base-test-mindeps-client/pom.xml @@ -4,8 +4,7 @@ ca.uhn.hapi.fhir hapi-fhir - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../../pom.xml diff --git a/tests/hapi-fhir-base-test-mindeps-server/pom.xml b/tests/hapi-fhir-base-test-mindeps-server/pom.xml index d0e2511c615..47bb6eea482 100644 --- a/tests/hapi-fhir-base-test-mindeps-server/pom.xml +++ b/tests/hapi-fhir-base-test-mindeps-server/pom.xml @@ -5,8 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 6.5.9-SNAPSHOT - + 6.5.10-SNAPSHOT ../../pom.xml