diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/TermValueSetConceptView.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/TermValueSetConceptView.java index df7fe29f2e8..de921c27f49 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/TermValueSetConceptView.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/TermValueSetConceptView.java @@ -48,11 +48,12 @@ import java.io.Serializable; " LEFT OUTER JOIN TRM_VALUESET_C_DESIGNATION vscd ON vsc.PID = vscd.VALUESET_CONCEPT_PID" ) public class TermValueSetConceptView implements Serializable { - private static final long serialVersionUID = 1L; + private static final int MAX_LENGTH = 500; + @Id - @Column(name="PID") + @Column(name="PID", length = MAX_LENGTH) private String myPid; @Column(name = "CONCEPT_PID") @@ -64,31 +65,31 @@ public class TermValueSetConceptView implements Serializable { @Column(name = "CONCEPT_VALUESET_ORDER") private int myConceptOrder; - @Column(name = "CONCEPT_SYSTEM_URL") + @Column(name = "CONCEPT_SYSTEM_URL", length = TermCodeSystem.MAX_URL_LENGTH) private String myConceptSystemUrl; - @Column(name = "CONCEPT_CODEVAL") + @Column(name = "CONCEPT_CODEVAL", length = TermConcept.MAX_CODE_LENGTH) private String myConceptCode; - @Column(name = "CONCEPT_DISPLAY") + @Column(name = "CONCEPT_DISPLAY", length = TermConcept.MAX_DESC_LENGTH) private String myConceptDisplay; @Column(name = "DESIGNATION_PID") private Long myDesignationPid; - @Column(name = "DESIGNATION_LANG") + @Column(name = "DESIGNATION_LANG", length = TermValueSetConceptDesignation.MAX_LENGTH) private String myDesignationLang; - @Column(name = "DESIGNATION_USE_SYSTEM") + @Column(name = "DESIGNATION_USE_SYSTEM", length = TermValueSetConceptDesignation.MAX_LENGTH) private String myDesignationUseSystem; - @Column(name = "DESIGNATION_USE_CODE") + @Column(name = "DESIGNATION_USE_CODE", length = TermValueSetConceptDesignation.MAX_LENGTH) private String myDesignationUseCode; - @Column(name = "DESIGNATION_USE_DISPLAY") + @Column(name = "DESIGNATION_USE_DISPLAY", length = TermValueSetConceptDesignation.MAX_LENGTH) private String myDesignationUseDisplay; - @Column(name = "DESIGNATION_VAL") + @Column(name = "DESIGNATION_VAL", length = TermValueSetConceptDesignation.MAX_LENGTH) private String myDesignationVal; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/BaseHapiTerminologySvcImpl.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/BaseHapiTerminologySvcImpl.java index 341b977e812..8ea73872735 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/BaseHapiTerminologySvcImpl.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/BaseHapiTerminologySvcImpl.java @@ -578,15 +578,15 @@ public abstract class BaseHapiTerminologySvcImpl implements IHapiTerminologySvc, logConceptsExpanded("Finished expanding concepts. ", theTermValueSet, conceptsExpanded); } - private void logConceptsExpanded(String thePrefix, TermValueSet theTermValueSet, int theConceptsExpanded) { + private void logConceptsExpanded(String theLogDescriptionPrefix, TermValueSet theTermValueSet, int theConceptsExpanded) { if (theConceptsExpanded > 0) { - ourLog.info("{}Have expanded {} concepts in ValueSet[{}]", thePrefix, theConceptsExpanded, theTermValueSet.getUrl()); + ourLog.info("{}Have expanded {} concepts in ValueSet[{}]", theLogDescriptionPrefix, theConceptsExpanded, theTermValueSet.getUrl()); } } - private void logDesignationsExpanded(String thePrefix, TermValueSet theTermValueSet, int theDesignationsExpanded) { + private void logDesignationsExpanded(String theLogDescriptionPrefix, TermValueSet theTermValueSet, int theDesignationsExpanded) { if (theDesignationsExpanded > 0) { - ourLog.info("{}Have expanded {} designations in ValueSet[{}]", thePrefix, theDesignationsExpanded, theTermValueSet.getUrl()); + ourLog.info("{}Have expanded {} designations in ValueSet[{}]", theLogDescriptionPrefix, theDesignationsExpanded, theTermValueSet.getUrl()); } } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3TerminologyTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3TerminologyTest.java index de223cbb46c..74e611b3df1 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3TerminologyTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3TerminologyTest.java @@ -13,6 +13,7 @@ import ca.uhn.fhir.parser.IParser; import ca.uhn.fhir.rest.param.TokenParam; import ca.uhn.fhir.rest.param.TokenParamModifier; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; +import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException; import ca.uhn.fhir.util.TestUtil; import ca.uhn.fhir.validation.FhirValidator; @@ -801,8 +802,8 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { try { params.add(Observation.SP_CODE, new TokenParam(null, URL_MY_VALUE_SET).setModifier(TokenParamModifier.IN)); assertThat(toUnqualifiedVersionlessIdValues(myObservationDao.search(params)), empty()); - } catch (InvalidRequestException e) { - assertEquals("Unable to find imported value set http://example.com/my_value_set", e.getMessage()); + } catch (ResourceNotFoundException e) { + assertEquals("Unknown ValueSet: http%3A%2F%2Fexample.com%2Fmy_value_set", e.getMessage()); } } @@ -1117,10 +1118,13 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { valueSet.setUrl(URL_MY_VALUE_SET); myValueSetDao.update(valueSet, mySrd).getId().toUnqualifiedVersionless(); - params = new SearchParameterMap(); - params.add(Observation.SP_CODE, new TokenParam(null, URL_MY_VALUE_SET).setModifier(TokenParamModifier.IN)); - params.add(Observation.SP_STATUS, new TokenParam(null, "final")); - assertThat(toUnqualifiedVersionlessIdValues(myObservationDao.search(params)), empty()); + try { + params = new SearchParameterMap(); + params.add(Observation.SP_CODE, new TokenParam(null, URL_MY_VALUE_SET).setModifier(TokenParamModifier.IN)); + params.add(Observation.SP_STATUS, new TokenParam(null, "final")); + } catch (ResourceNotFoundException e) { + assertEquals("Unknown ValueSet: http%3A%2F%2Fexample.com%2Fmy_value_set", e.getMessage()); + } } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4TerminologyTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4TerminologyTest.java index fe666c008a4..d4d327347c7 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4TerminologyTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4TerminologyTest.java @@ -13,6 +13,7 @@ import ca.uhn.fhir.parser.IParser; import ca.uhn.fhir.rest.param.TokenParam; import ca.uhn.fhir.rest.param.TokenParamModifier; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; +import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException; import ca.uhn.fhir.util.TestUtil; import ca.uhn.fhir.validation.FhirValidator; @@ -1168,9 +1169,12 @@ public class FhirResourceDaoR4TerminologyTest extends BaseJpaR4Test { params.add(AuditEvent.SP_TYPE, new TokenParam(null, "http://hl7.org/fhir/ValueSet/audit-event-type").setModifier(TokenParamModifier.IN)); assertThat(toUnqualifiedVersionlessIdValues(myAuditEventDao.search(params)), containsInAnyOrder(idIn1.getValue(), idIn2.getValue())); - params = new SearchParameterMap(); - params.add(AuditEvent.SP_TYPE, new TokenParam(null, "http://hl7.org/fhir/ValueSet/v3-PurposeOfUse").setModifier(TokenParamModifier.IN)); - assertThat(toUnqualifiedVersionlessIdValues(myAuditEventDao.search(params)), empty()); + try { + params = new SearchParameterMap(); + params.add(AuditEvent.SP_TYPE, new TokenParam(null, "http://hl7.org/fhir/ValueSet/v3-PurposeOfUse").setModifier(TokenParamModifier.IN)); + } catch (ResourceNotFoundException e) { + assertEquals("Unknown ValueSet: http%3A%2F%2Fhl7.org%2Ffhir%2FValueSet%2Fv3-PurposeOfUse", e.getMessage()); + } } @Test @@ -1203,8 +1207,8 @@ public class FhirResourceDaoR4TerminologyTest extends BaseJpaR4Test { try { params.add(Observation.SP_CODE, new TokenParam(null, URL_MY_VALUE_SET).setModifier(TokenParamModifier.IN)); assertThat(toUnqualifiedVersionlessIdValues(myObservationDao.search(params)), empty()); - } catch (InvalidRequestException e) { - assertEquals("Unable to find imported value set http://example.com/my_value_set", e.getMessage()); + } catch (ResourceNotFoundException e) { + assertEquals("Unknown ValueSet: http%3A%2F%2Fexample.com%2Fmy_value_set", e.getMessage()); } } @@ -1234,10 +1238,13 @@ public class FhirResourceDaoR4TerminologyTest extends BaseJpaR4Test { valueSet.setUrl(URL_MY_VALUE_SET); myValueSetDao.update(valueSet, mySrd).getId().toUnqualifiedVersionless(); - params = new SearchParameterMap(); - params.add(Observation.SP_CODE, new TokenParam(null, URL_MY_VALUE_SET).setModifier(TokenParamModifier.IN)); - params.add(Observation.SP_STATUS, new TokenParam(null, "final")); - assertThat(toUnqualifiedVersionlessIdValues(myObservationDao.search(params)), empty()); + try { + params = new SearchParameterMap(); + params.add(Observation.SP_CODE, new TokenParam(null, URL_MY_VALUE_SET).setModifier(TokenParamModifier.IN)); + params.add(Observation.SP_STATUS, new TokenParam(null, "final")); + } catch (ResourceNotFoundException e) { + assertEquals("Unknown ValueSet: http%3A%2F%2Fnon_existant_VS", e.getMessage()); + } } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ExpungeR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ExpungeR4Test.java index 182b39366d5..66ad4b49b82 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ExpungeR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ExpungeR4Test.java @@ -347,22 +347,16 @@ public class ExpungeR4Test extends BaseResourceProviderR4Test { public void testExpungeEverythingWhereResourceInSearchResults() { createStandardPatients(); - runInTransaction(() -> { - await().until(()->mySearchEntityDao.count() == 0); - await().until(()->mySearchResultDao.count() == 0); - }); + await().until(()-> runInTransaction(() -> mySearchEntityDao.count() == 0)); + await().until(()-> runInTransaction(() -> mySearchResultDao.count() == 0)); PersistedJpaSearchFirstPageBundleProvider search = (PersistedJpaSearchFirstPageBundleProvider) myPatientDao.search(new SearchParameterMap()); assertEquals(PersistedJpaSearchFirstPageBundleProvider.class, search.getClass()); assertEquals(2, search.size().intValue()); assertEquals(2, search.getResources(0, 2).size()); - runInTransaction(() -> { - await().until(()->mySearchEntityDao.count() == 1); - await().until(()->mySearchResultDao.count() == 2); - ourLog.info("Search results: {}", mySearchResultDao.findAll().toString()); - assertEquals(mySearchResultDao.findAll().toString(), 2, mySearchResultDao.count()); - }); + await().until(()-> runInTransaction(() -> mySearchEntityDao.count() == 1)); + await().until(()-> runInTransaction(() -> mySearchResultDao.count() == 2)); mySystemDao.expunge(new ExpungeOptions() .setExpungeEverything(true), null);