From 06ea9a145345ff874ee6b5ff537d6206bad62625 Mon Sep 17 00:00:00 2001 From: jamesagnew Date: Fri, 6 Mar 2015 17:55:35 -0500 Subject: [PATCH] More work on operation support for DSTU2 --- .../ca/uhn/fhir/rest/gclient/IBaseOn.java | 20 +++ .../ca/uhn/fhir/rest/gclient/IHistory.java | 20 +++ .../uhn/fhir/rest/gclient/IHistoryTyped.java | 20 +++ .../fhir/rest/gclient/IHistoryUntyped.java | 20 +++ .../ca/uhn/fhir/rest/gclient/IOperation.java | 20 +++ .../uhn/fhir/rest/gclient/IOperationOn.java | 20 +++ .../fhir/rest/gclient/IOperationTyped.java | 20 +++ .../fhir/rest/gclient/IOperationUnnamed.java | 20 +++ .../fhir/rest/gclient/IOperationUntyped.java | 20 +++ .../gclient/IOperationUntypedWithInput.java | 20 +++ .../rest/method/OperationMethodBinding.java | 20 +++ .../fhir/rest/server/Dstu1BundleFactory.java | 20 +++ .../server/IVersionSpecificBundleFactory.java | 20 +++ .../fhir/rest/server/RestfulServerUtils.java | 20 +++ .../instance/model/api/IBaseParameters.java | 20 +++ hapi-fhir-jpaserver-base/pom.xml | 7 - .../ca/uhn/fhir/jpa/dao/FhirResourceDao.java | 137 +++++++++--------- .../jpa/dao/SearchParamExtractorDstu2.java | 2 +- .../uhn/fhir/jpa/dao/FhirResourceDaoTest.java | 41 +++++- .../provider/dstu2/Dstu2BundleFactory.java | 20 +++ .../webapp/WEB-INF/templates/resource.html | 2 +- 21 files changed, 431 insertions(+), 78 deletions(-) diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IBaseOn.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IBaseOn.java index e69b2e02116..098ca4ccf30 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IBaseOn.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IBaseOn.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.rest.gclient; +/* + * #%L + * HAPI FHIR - Core Library + * %% + * Copyright (C) 2014 - 2015 University Health Network + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import org.hl7.fhir.instance.model.IBaseResource; import ca.uhn.fhir.model.primitive.IdDt; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IHistory.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IHistory.java index 3a3dde7e140..5bc5d0aac96 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IHistory.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IHistory.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.rest.gclient; +/* + * #%L + * HAPI FHIR - Core Library + * %% + * Copyright (C) 2014 - 2015 University Health Network + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + public interface IHistory extends IBaseOn { } diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IHistoryTyped.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IHistoryTyped.java index e2c790bb87d..accebcc256d 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IHistoryTyped.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IHistoryTyped.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.rest.gclient; +/* + * #%L + * HAPI FHIR - Core Library + * %% + * Copyright (C) 2014 - 2015 University Health Network + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import java.util.Date; import ca.uhn.fhir.model.primitive.InstantDt; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IHistoryUntyped.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IHistoryUntyped.java index 53b3b5dbdb9..b021e201846 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IHistoryUntyped.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IHistoryUntyped.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.rest.gclient; +/* + * #%L + * HAPI FHIR - Core Library + * %% + * Copyright (C) 2014 - 2015 University Health Network + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import org.hl7.fhir.instance.model.api.IBaseBundle; import ca.uhn.fhir.model.api.Bundle; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IOperation.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IOperation.java index 26f11238383..ee44fea35d1 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IOperation.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IOperation.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.rest.gclient; +/* + * #%L + * HAPI FHIR - Core Library + * %% + * Copyright (C) 2014 - 2015 University Health Network + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + public interface IOperation extends IBaseOn { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IOperationOn.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IOperationOn.java index 8be7145a07d..56afa33337f 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IOperationOn.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IOperationOn.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.rest.gclient; +/* + * #%L + * HAPI FHIR - Core Library + * %% + * Copyright (C) 2014 - 2015 University Health Network + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + public interface IOperationOn extends IBaseOn { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IOperationTyped.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IOperationTyped.java index cdfb83bac89..25f393fee16 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IOperationTyped.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IOperationTyped.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.rest.gclient; +/* + * #%L + * HAPI FHIR - Core Library + * %% + * Copyright (C) 2014 - 2015 University Health Network + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + public interface IOperationTyped { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IOperationUnnamed.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IOperationUnnamed.java index 189c8f6b45f..01b45a51d6a 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IOperationUnnamed.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IOperationUnnamed.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.rest.gclient; +/* + * #%L + * HAPI FHIR - Core Library + * %% + * Copyright (C) 2014 - 2015 University Health Network + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + public interface IOperationUnnamed { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IOperationUntyped.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IOperationUntyped.java index 858bbfafcc6..4d2ed9b596b 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IOperationUntyped.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IOperationUntyped.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.rest.gclient; +/* + * #%L + * HAPI FHIR - Core Library + * %% + * Copyright (C) 2014 - 2015 University Health Network + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import org.hl7.fhir.instance.model.api.IBaseParameters; public interface IOperationUntyped { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IOperationUntypedWithInput.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IOperationUntypedWithInput.java index 35601867b8d..1e326e4a392 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IOperationUntypedWithInput.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IOperationUntypedWithInput.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.rest.gclient; +/* + * #%L + * HAPI FHIR - Core Library + * %% + * Copyright (C) 2014 - 2015 University Health Network + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import org.hl7.fhir.instance.model.api.IBaseParameters; public interface IOperationUntypedWithInput extends IClientExecutable, T> { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/OperationMethodBinding.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/OperationMethodBinding.java index 9a36fd91b30..0896be60e8c 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/OperationMethodBinding.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/OperationMethodBinding.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.rest.method; +/* + * #%L + * HAPI FHIR - Core Library + * %% + * Copyright (C) 2014 - 2015 University Health Network + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import static org.apache.commons.lang3.StringUtils.*; import org.hl7.fhir.instance.model.api.IBaseParameters; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/Dstu1BundleFactory.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/Dstu1BundleFactory.java index ec5c1071f66..63223fd3d4e 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/Dstu1BundleFactory.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/Dstu1BundleFactory.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.rest.server; +/* + * #%L + * HAPI FHIR - Core Library + * %% + * Copyright (C) 2014 - 2015 University Health Network + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import java.util.ArrayList; import java.util.HashSet; import java.util.List; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/IVersionSpecificBundleFactory.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/IVersionSpecificBundleFactory.java index 8e95c371c54..2758b2d986c 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/IVersionSpecificBundleFactory.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/IVersionSpecificBundleFactory.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.rest.server; +/* + * #%L + * HAPI FHIR - Core Library + * %% + * Copyright (C) 2014 - 2015 University Health Network + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import java.util.List; import org.hl7.fhir.instance.model.IBaseResource; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/RestfulServerUtils.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/RestfulServerUtils.java index a43fad59d38..fc335abacbd 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/RestfulServerUtils.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/RestfulServerUtils.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.rest.server; +/* + * #%L + * HAPI FHIR - Core Library + * %% + * Copyright (C) 2014 - 2015 University Health Network + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import static org.apache.commons.lang3.StringUtils.isNotBlank; import java.io.IOException; diff --git a/hapi-fhir-base/src/main/java/org/hl7/fhir/instance/model/api/IBaseParameters.java b/hapi-fhir-base/src/main/java/org/hl7/fhir/instance/model/api/IBaseParameters.java index 4a004f556c8..171d871ee00 100644 --- a/hapi-fhir-base/src/main/java/org/hl7/fhir/instance/model/api/IBaseParameters.java +++ b/hapi-fhir-base/src/main/java/org/hl7/fhir/instance/model/api/IBaseParameters.java @@ -1,5 +1,25 @@ package org.hl7.fhir.instance.model.api; +/* + * #%L + * HAPI FHIR - Core Library + * %% + * Copyright (C) 2014 - 2015 University Health Network + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import org.hl7.fhir.instance.model.IBaseResource; public interface IBaseParameters extends IBaseResource { diff --git a/hapi-fhir-jpaserver-base/pom.xml b/hapi-fhir-jpaserver-base/pom.xml index 17cf13c3e22..61214569e67 100644 --- a/hapi-fhir-jpaserver-base/pom.xml +++ b/hapi-fhir-jpaserver-base/pom.xml @@ -411,13 +411,6 @@ - - org.apache.maven.plugins - maven-deploy-plugin - - true - - diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirResourceDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirResourceDao.java index 98708c725e6..10a45c8f17f 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirResourceDao.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirResourceDao.java @@ -413,17 +413,13 @@ public class FhirResourceDao extends BaseFhirDao implements throw new IllegalArgumentException("Invalid quantity type: " + params.getClass()); } - Predicate system; - if (isBlank(systemValue)) { - system = builder.isNull(from.get("mySystem")); - } else { + Predicate system = null; + if (!isBlank(systemValue)) { system = builder.equal(from.get("mySystem"), systemValue); } - Predicate code; - if (isBlank(unitsValue)) { - code = builder.isNull(from.get("myUnits")); - } else { + Predicate code = null; + if (!isBlank(unitsValue)) { code = builder.equal(from.get("myUnits"), unitsValue); } @@ -458,9 +454,18 @@ public class FhirResourceDao extends BaseFhirDao implements } } - Predicate singleCode = builder.and(system, code, num); - codePredicates.add(singleCode); - + if (system == null && code == null) { + codePredicates.add(num); + } else if (system == null) { + Predicate singleCode = builder.and(code, num); + codePredicates.add(singleCode); + } else if (code == null) { + Predicate singleCode = builder.and(system, num); + codePredicates.add(singleCode); + } else { + Predicate singleCode = builder.and(system, code, num); + codePredicates.add(singleCode); + } } Predicate masterCodePredicate = builder.or(codePredicates.toArray(new Predicate[0])); @@ -668,7 +673,7 @@ public class FhirResourceDao extends BaseFhirDao implements myEntityManager.persist(newEntity); myEntityManager.merge(entity); notifyWriteCompleted(); - ourLog.info("Processed addTag {}/{} on {} in {}ms", new Object[]{theScheme, theTerm, theId, w.getMillisAndRestart()}); + ourLog.info("Processed addTag {}/{} on {} in {}ms", new Object[] { theScheme, theTerm, theId, w.getMillisAndRestart() }); } @Override @@ -1190,7 +1195,7 @@ public class FhirResourceDao extends BaseFhirDao implements myEntityManager.merge(entity); - ourLog.info("Processed remove tag {}/{} on {} in {}ms", new Object[]{theScheme, theTerm, theId.getValue(), w.getMillisAndRestart()}); + ourLog.info("Processed remove tag {}/{} on {} in {}ms", new Object[] { theScheme, theTerm, theId.getValue(), w.getMillisAndRestart() }); } @Override @@ -1331,8 +1336,7 @@ public class FhirResourceDao extends BaseFhirDao implements } retVal.addAll(resources); } - } - while (includePids.size() > 0 && previouslyLoadedPids.size() < getConfig().getIncludeLimit()); + } while (includePids.size() > 0 && previouslyLoadedPids.size() < getConfig().getIncludeLimit()); if (previouslyLoadedPids.size() >= getConfig().getIncludeLimit()) { OperationOutcome oo = new OperationOutcome(); @@ -1352,7 +1356,7 @@ public class FhirResourceDao extends BaseFhirDao implements } }; - ourLog.info("Processed search for {} on {} in {}ms", new Object[]{myResourceName, theParams, w.getMillisAndRestart()}); + ourLog.info("Processed search for {} on {} in {}ms", new Object[] { myResourceName, theParams, w.getMillisAndRestart() }); return retVal; } @@ -1437,62 +1441,62 @@ public class FhirResourceDao extends BaseFhirDao implements RuntimeSearchParam nextParamDef = resourceDef.getSearchParam(nextParamName); if (nextParamDef != null) { switch (nextParamDef.getParamType()) { - case DATE: - for (List nextAnd : nextParamEntry.getValue()) { - pids = addPredicateDate(nextParamName, pids, nextAnd); - if (pids.isEmpty()) { - return new HashSet(); - } + case DATE: + for (List nextAnd : nextParamEntry.getValue()) { + pids = addPredicateDate(nextParamName, pids, nextAnd); + if (pids.isEmpty()) { + return new HashSet(); } - break; - case QUANTITY: - for (List nextAnd : nextParamEntry.getValue()) { - pids = addPredicateQuantity(nextParamName, pids, nextAnd); - if (pids.isEmpty()) { - return new HashSet(); - } + } + break; + case QUANTITY: + for (List nextAnd : nextParamEntry.getValue()) { + pids = addPredicateQuantity(nextParamName, pids, nextAnd); + if (pids.isEmpty()) { + return new HashSet(); } - break; - case REFERENCE: - for (List nextAnd : nextParamEntry.getValue()) { - pids = addPredicateReference(nextParamName, pids, nextAnd); - if (pids.isEmpty()) { - return new HashSet(); - } + } + break; + case REFERENCE: + for (List nextAnd : nextParamEntry.getValue()) { + pids = addPredicateReference(nextParamName, pids, nextAnd); + if (pids.isEmpty()) { + return new HashSet(); } - break; - case STRING: - for (List nextAnd : nextParamEntry.getValue()) { - pids = addPredicateString(nextParamName, pids, nextAnd); - if (pids.isEmpty()) { - return new HashSet(); - } + } + break; + case STRING: + for (List nextAnd : nextParamEntry.getValue()) { + pids = addPredicateString(nextParamName, pids, nextAnd); + if (pids.isEmpty()) { + return new HashSet(); } - break; - case TOKEN: - for (List nextAnd : nextParamEntry.getValue()) { - pids = addPredicateToken(nextParamName, pids, nextAnd); - if (pids.isEmpty()) { - return new HashSet(); - } + } + break; + case TOKEN: + for (List nextAnd : nextParamEntry.getValue()) { + pids = addPredicateToken(nextParamName, pids, nextAnd); + if (pids.isEmpty()) { + return new HashSet(); } - break; - case NUMBER: - for (List nextAnd : nextParamEntry.getValue()) { - pids = addPredicateNumber(nextParamName, pids, nextAnd); - if (pids.isEmpty()) { - return new HashSet(); - } + } + break; + case NUMBER: + for (List nextAnd : nextParamEntry.getValue()) { + pids = addPredicateNumber(nextParamName, pids, nextAnd); + if (pids.isEmpty()) { + return new HashSet(); } - break; - case COMPOSITE: - for (List nextAnd : nextParamEntry.getValue()) { - pids = addPredicateComposite(nextParamDef, pids, nextAnd); - if (pids.isEmpty()) { - return new HashSet(); - } + } + break; + case COMPOSITE: + for (List nextAnd : nextParamEntry.getValue()) { + pids = addPredicateComposite(nextParamDef, pids, nextAnd); + if (pids.isEmpty()) { + return new HashSet(); } - break; + } + break; } } } @@ -1598,6 +1602,9 @@ public class FhirResourceDao extends BaseFhirDao implements } } else { resourceId = theResource.getId(); + if (resourceId == null || isBlank(resourceId.getIdPart())) { + throw new InvalidRequestException("Can not update a resource with no ID"); + } entity = readEntityLatestVersion(resourceId); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchParamExtractorDstu2.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchParamExtractorDstu2.java index cea7c4a2531..bbb488d5d90 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchParamExtractorDstu2.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchParamExtractorDstu2.java @@ -278,7 +278,7 @@ class SearchParamExtractorDstu2 implements ISearchParamExtractor { continue; } - ResourceIndexedSearchParamQuantity nextEntity = new ResourceIndexedSearchParamQuantity(resourceName, nextValue.getValueElement().getValue(), nextValue.getSystemElement().getValueAsString(), nextValue.getUnits()); + ResourceIndexedSearchParamQuantity nextEntity = new ResourceIndexedSearchParamQuantity(resourceName, nextValue.getValueElement().getValue(), nextValue.getSystemElement().getValueAsString(), nextValue.getCode()); nextEntity.setResource(theEntity); retVal.add(nextEntity); } else { diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoTest.java index cb3803cfb77..601cc060ba7 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoTest.java @@ -15,6 +15,7 @@ import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; @@ -89,6 +90,41 @@ public class FhirResourceDaoTest { private static IFhirResourceDao ourOrganizationDao; private static IFhirResourceDao ourPatientDao; + @Test + public void testSearchValueQuantity() { + String methodName = "testSearchValueQuantity"; + + QuantityParam param; + Set found; + param = new QuantityParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, new BigDecimal("10"), null, null); + found = ourObservationDao.searchForIds("value-quantity", param); + int initialSize = found.size(); + + Observation o = new Observation(); + o.getCode().addCoding().setSystem("urn:foo").setCode(methodName + "code"); + QuantityDt q = new QuantityDt().setSystem("urn:bar:" + methodName).setCode(methodName + "units").setValue(100); + o.setValue(q); + + ourObservationDao.create(o); + + param = new QuantityParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, new BigDecimal("10"), null, null); + found = ourObservationDao.searchForIds("value-quantity", param); + assertEquals(1 + initialSize, found.size()); + + param = new QuantityParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, new BigDecimal("10"), null, methodName + "units"); + found = ourObservationDao.searchForIds("value-quantity", param); + assertEquals(1, found.size()); + + param = new QuantityParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, new BigDecimal("10"), "urn:bar:" + methodName, null); + found = ourObservationDao.searchForIds("value-quantity", param); + assertEquals(1, found.size()); + + param = new QuantityParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, new BigDecimal("10"), "urn:bar:" + methodName, methodName + "units"); + found = ourObservationDao.searchForIds("value-quantity", param); + assertEquals(1, found.size()); + + } + @Test public void testCreateDuplicateIdFails() { String methodName = "testCreateDuplocateIdFailsText"; @@ -135,7 +171,6 @@ public class FhirResourceDaoTest { } - @Test public void testCreateNumericIdFails() { Patient p = new Patient(); @@ -150,7 +185,6 @@ public class FhirResourceDaoTest { } } - @Test public void testDeleteWithMatchUrl() { String methodName = "testDeleteWithMatchUrl"; @@ -188,7 +222,6 @@ public class FhirResourceDaoTest { } - @Test public void testCreateWithIfNoneExist() { String methodName = "testCreateWithIfNoneExist"; @@ -265,7 +298,7 @@ public class FhirResourceDaoTest { public void testChoiceParamQuantity() { Observation o3 = new Observation(); o3.getCode().addCoding().setSystem("foo").setCode("testChoiceParam03"); - o3.setValue(new QuantityDt(QuantityComparatorEnum.GREATERTHAN, 123.0, "foo", "bar")); + o3.setValue(new QuantityDt(QuantityComparatorEnum.GREATERTHAN, 123.0, "foo", "bar").setCode("bar")); IdDt id3 = ourObservationDao.create(o3).getId(); { diff --git a/hapi-fhir-structures-dstu2/src/main/java/ca/uhn/fhir/rest/server/provider/dstu2/Dstu2BundleFactory.java b/hapi-fhir-structures-dstu2/src/main/java/ca/uhn/fhir/rest/server/provider/dstu2/Dstu2BundleFactory.java index 78d3394401e..b15b6e5c5f2 100644 --- a/hapi-fhir-structures-dstu2/src/main/java/ca/uhn/fhir/rest/server/provider/dstu2/Dstu2BundleFactory.java +++ b/hapi-fhir-structures-dstu2/src/main/java/ca/uhn/fhir/rest/server/provider/dstu2/Dstu2BundleFactory.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.rest.server.provider.dstu2; +/* + * #%L + * HAPI FHIR Structures - DSTU2 (FHIR v0.4.0) + * %% + * Copyright (C) 2014 - 2015 University Health Network + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import static org.apache.commons.lang3.StringUtils.*; import java.util.ArrayList; diff --git a/hapi-fhir-testpage-overlay/src/main/webapp/WEB-INF/templates/resource.html b/hapi-fhir-testpage-overlay/src/main/webapp/WEB-INF/templates/resource.html index fe677e6e7b4..d358cc84ea7 100644 --- a/hapi-fhir-testpage-overlay/src/main/webapp/WEB-INF/templates/resource.html +++ b/hapi-fhir-testpage-overlay/src/main/webapp/WEB-INF/templates/resource.html @@ -113,7 +113,7 @@ }); $("#outerForm").attr("action", "search").submit(); }); - $('#search-btn').button('reset'); + $('#search-btn').prop('disabled', false);