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 b0d5d90f782..561905b4a87 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 @@ -133,6 +133,9 @@ import ca.uhn.fhir.util.ObjectUtil; @Transactional(propagation = Propagation.REQUIRED) public abstract class BaseHapiFhirResourceDao extends BaseHapiFhirDao implements IFhirResourceDao { + static final String OO_SEVERITY_INFO = "information"; + static final String OO_SEVERITY_ERROR = "error"; + private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseHapiFhirResourceDao.class); @PersistenceContext(type = PersistenceContextType.TRANSACTION) @@ -962,11 +965,11 @@ public abstract class BaseHapiFhirResourceDao extends BaseH } protected IBaseOperationOutcome createErrorOperationOutcome(String theMessage) { - return createOperationOutcome(IssueSeverityEnum.ERROR.getCode(), theMessage); + return createOperationOutcome(OO_SEVERITY_ERROR, theMessage); } protected IBaseOperationOutcome createInfoOperationOutcome(String theMessage) { - return createOperationOutcome(IssueSeverityEnum.INFORMATION.getCode(), theMessage); + return createOperationOutcome(OO_SEVERITY_INFO, theMessage); } protected abstract IBaseOperationOutcome createOperationOutcome(String theSeverity, String theMessage); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoDstu2Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoDstu2Test.java index 4878991db17..41818b001ff 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoDstu2Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoDstu2Test.java @@ -36,9 +36,6 @@ import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.jmx.access.InvalidInvocationException; - -import com.ctc.wstx.util.StringUtil; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamString; @@ -115,6 +112,21 @@ public class FhirResourceDaoDstu2Test extends BaseJpaTest { private static IFhirResourceDao ourQuestionnaireDao; private static IFhirSystemDao ourSystemDao; + @Test + public void testCreateOperationOutcome() { + /* + * If any of this ever fails, it means that one of the OperationOutcome + * issue severity codes has changed code value across versions. We store + * the string as a constant, so something will need to be fixed. + */ + assertEquals(org.hl7.fhir.instance.model.OperationOutcome.IssueSeverity.ERROR.toCode(), BaseHapiFhirResourceDao.OO_SEVERITY_ERROR); + assertEquals(ca.uhn.fhir.model.dstu.valueset.IssueSeverityEnum.ERROR.getCode(), BaseHapiFhirResourceDao.OO_SEVERITY_ERROR); + assertEquals(ca.uhn.fhir.model.dstu2.valueset.IssueSeverityEnum.ERROR.getCode(), BaseHapiFhirResourceDao.OO_SEVERITY_ERROR); + assertEquals(org.hl7.fhir.instance.model.OperationOutcome.IssueSeverity.INFORMATION.toCode(), BaseHapiFhirResourceDao.OO_SEVERITY_INFO); + assertEquals(ca.uhn.fhir.model.dstu.valueset.IssueSeverityEnum.INFORMATION.getCode(), BaseHapiFhirResourceDao.OO_SEVERITY_INFO); + assertEquals(ca.uhn.fhir.model.dstu2.valueset.IssueSeverityEnum.INFORMATION.getCode(), BaseHapiFhirResourceDao.OO_SEVERITY_INFO); +} + @Test public void testChoiceParamConcept() { Observation o1 = new Observation();