Attempt to correct build issues
This commit is contained in:
parent
3922ff026e
commit
c8173810f4
|
@ -64,14 +64,6 @@ public class BaseDstu3Config extends BaseConfig {
|
||||||
ca.uhn.fhir.jpa.dao.dstu3.JpaValidationSupportDstu3 retVal = new ca.uhn.fhir.jpa.dao.dstu3.JpaValidationSupportDstu3();
|
ca.uhn.fhir.jpa.dao.dstu3.JpaValidationSupportDstu3 retVal = new ca.uhn.fhir.jpa.dao.dstu3.JpaValidationSupportDstu3();
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean(name="myQuestionnaireResponseValidatorDstu3")
|
|
||||||
@Lazy
|
|
||||||
public IValidatorModule questionnaireResponseValidatorDstu3() {
|
|
||||||
FhirQuestionnaireResponseValidator module = new FhirQuestionnaireResponseValidator();
|
|
||||||
module.setValidationSupport(validationSupportChainDstu3());
|
|
||||||
return module;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean(autowire = Autowire.BY_TYPE)
|
@Bean(autowire = Autowire.BY_TYPE)
|
||||||
public IFulltextSearchSvc searchDaoDstu3() {
|
public IFulltextSearchSvc searchDaoDstu3() {
|
||||||
|
|
|
@ -1,124 +1,65 @@
|
||||||
package ca.uhn.fhir.jpa.dao.dstu3;
|
package ca.uhn.fhir.jpa.dao.dstu3;
|
||||||
|
|
||||||
/*
|
|
||||||
* #%L
|
|
||||||
* HAPI FHIR JPA Server
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2014 - 2016 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 javax.annotation.PostConstruct;
|
|
||||||
|
|
||||||
import org.hl7.fhir.dstu3.model.OperationOutcome;
|
|
||||||
import org.hl7.fhir.dstu3.model.Questionnaire;
|
|
||||||
import org.hl7.fhir.dstu3.model.QuestionnaireResponse;
|
import org.hl7.fhir.dstu3.model.QuestionnaireResponse;
|
||||||
import org.hl7.fhir.dstu3.model.ValueSet;
|
|
||||||
import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
|
|
||||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
|
||||||
import org.hl7.fhir.instance.model.api.IIdType;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.jpa.dao.IFhirResourceDao;
|
|
||||||
import ca.uhn.fhir.jpa.entity.ResourceTable;
|
|
||||||
import ca.uhn.fhir.rest.method.RequestDetails;
|
|
||||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
|
||||||
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
|
||||||
import ca.uhn.fhir.validation.FhirValidator;
|
|
||||||
import ca.uhn.fhir.validation.IResourceLoader;
|
|
||||||
import ca.uhn.fhir.validation.IValidatorModule;
|
|
||||||
import ca.uhn.fhir.validation.ValidationResult;
|
|
||||||
|
|
||||||
public class FhirResourceDaoQuestionnaireResponseDstu3 extends FhirResourceDaoDstu3<QuestionnaireResponse> {
|
public class FhirResourceDaoQuestionnaireResponseDstu3 extends FhirResourceDaoDstu3<QuestionnaireResponse> {
|
||||||
|
|
||||||
private Boolean myValidateResponses;
|
|
||||||
|
|
||||||
@Autowired
|
// @Override
|
||||||
@Qualifier("myQuestionnaireResponseValidatorDstu3")
|
// protected void validateResourceForStorage(QuestionnaireResponse theResource, ResourceTable theEntityToSave, RequestDetails theRequestDetails) {
|
||||||
private IValidatorModule myQuestionnaireResponseValidatorDstu3;
|
// super.validateResourceForStorage(theResource, theEntityToSave, theRequestDetails);
|
||||||
|
// if (!myValidateResponses) {
|
||||||
|
// return;
|
||||||
/**
|
// }
|
||||||
* Initialize the bean
|
//
|
||||||
*/
|
// if (theResource == null || theResource.getQuestionnaire() == null || theResource.getQuestionnaire().getReference() == null || theResource.getQuestionnaire().getReference().isEmpty()) {
|
||||||
@PostConstruct
|
// return;
|
||||||
public void initialize() {
|
// }
|
||||||
try {
|
//
|
||||||
Class.forName("org.hl7.fhir.instance.model.QuestionnaireResponse");
|
// FhirValidator val = getContext().newValidator();
|
||||||
myValidateResponses = true;
|
// val.setValidateAgainstStandardSchema(false);
|
||||||
} catch (ClassNotFoundException e) {
|
// val.setValidateAgainstStandardSchematron(false);
|
||||||
myValidateResponses = Boolean.FALSE;
|
//
|
||||||
}
|
// val.registerValidatorModule(myQuestionnaireResponseValidatorDstu3);
|
||||||
}
|
//
|
||||||
|
// ValidationResult result = val.validateWithResult(getContext().newJsonParser().parseResource(getContext().newJsonParser().encodeResourceToString(theResource)));
|
||||||
@Override
|
// if (!result.isSuccessful()) {
|
||||||
protected void validateResourceForStorage(QuestionnaireResponse theResource, ResourceTable theEntityToSave, RequestDetails theRequestDetails) {
|
// IBaseOperationOutcome oo = getContext().newJsonParser().parseResource(OperationOutcome.class, getContext().newJsonParser().encodeResourceToString(result.toOperationOutcome()));
|
||||||
super.validateResourceForStorage(theResource, theEntityToSave, theRequestDetails);
|
// throw new UnprocessableEntityException(getContext(), oo);
|
||||||
if (!myValidateResponses) {
|
// }
|
||||||
return;
|
// }
|
||||||
}
|
//
|
||||||
|
// public class JpaResourceLoader implements IResourceLoader {
|
||||||
if (theResource == null || theResource.getQuestionnaire() == null || theResource.getQuestionnaire().getReference() == null || theResource.getQuestionnaire().getReference().isEmpty()) {
|
//
|
||||||
return;
|
// private RequestDetails myRequestDetails;
|
||||||
}
|
//
|
||||||
|
// public JpaResourceLoader(RequestDetails theRequestDetails) {
|
||||||
FhirValidator val = getContext().newValidator();
|
// super();
|
||||||
val.setValidateAgainstStandardSchema(false);
|
// myRequestDetails = theRequestDetails;
|
||||||
val.setValidateAgainstStandardSchematron(false);
|
// }
|
||||||
|
//
|
||||||
val.registerValidatorModule(myQuestionnaireResponseValidatorDstu3);
|
// @Override
|
||||||
|
// public <T extends IBaseResource> T load(Class<T> theType, IIdType theId) throws ResourceNotFoundException {
|
||||||
ValidationResult result = val.validateWithResult(getContext().newJsonParser().parseResource(getContext().newJsonParser().encodeResourceToString(theResource)));
|
//
|
||||||
if (!result.isSuccessful()) {
|
// /*
|
||||||
IBaseOperationOutcome oo = getContext().newJsonParser().parseResource(OperationOutcome.class, getContext().newJsonParser().encodeResourceToString(result.toOperationOutcome()));
|
// * The QuestionnaireResponse validator uses RI structures, so for now we need to convert between that and HAPI
|
||||||
throw new UnprocessableEntityException(getContext(), oo);
|
// * structures. This is a bit hackish, but hopefully it will go away at some point.
|
||||||
}
|
// */
|
||||||
}
|
// if ("ValueSet".equals(theType.getSimpleName())) {
|
||||||
|
// IFhirResourceDao<ValueSet> dao = getDao(ValueSet.class);
|
||||||
public class JpaResourceLoader implements IResourceLoader {
|
// ValueSet in = dao.read(theId, myRequestDetails);
|
||||||
|
// return (T) in;
|
||||||
private RequestDetails myRequestDetails;
|
// } else if ("Questionnaire".equals(theType.getSimpleName())) {
|
||||||
|
// IFhirResourceDao<Questionnaire> dao = getDao(Questionnaire.class);
|
||||||
public JpaResourceLoader(RequestDetails theRequestDetails) {
|
// Questionnaire vs = dao.read(theId, myRequestDetails);
|
||||||
super();
|
// return (T) vs;
|
||||||
myRequestDetails = theRequestDetails;
|
// } else {
|
||||||
}
|
// // Should not happen, validator will only ask for these two
|
||||||
|
// throw new IllegalStateException("Unexpected request to load resource of type " + theType);
|
||||||
@Override
|
// }
|
||||||
public <T extends IBaseResource> T load(Class<T> theType, IIdType theId) throws ResourceNotFoundException {
|
//
|
||||||
|
// }
|
||||||
/*
|
//
|
||||||
* The QuestionnaireResponse validator uses RI structures, so for now we need to convert between that and HAPI
|
// }
|
||||||
* structures. This is a bit hackish, but hopefully it will go away at some point.
|
|
||||||
*/
|
|
||||||
if ("ValueSet".equals(theType.getSimpleName())) {
|
|
||||||
IFhirResourceDao<ValueSet> dao = getDao(ValueSet.class);
|
|
||||||
ValueSet in = dao.read(theId, myRequestDetails);
|
|
||||||
return (T) in;
|
|
||||||
} else if ("Questionnaire".equals(theType.getSimpleName())) {
|
|
||||||
IFhirResourceDao<Questionnaire> dao = getDao(Questionnaire.class);
|
|
||||||
Questionnaire vs = dao.read(theId, myRequestDetails);
|
|
||||||
return (T) vs;
|
|
||||||
} else {
|
|
||||||
// Should not happen, validator will only ask for these two
|
|
||||||
throw new IllegalStateException("Unexpected request to load resource of type " + theType);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package ca.uhn.fhir.jpa.term;
|
package ca.uhn.fhir.jpa.term;
|
||||||
|
|
||||||
|
import static java.util.stream.Collectors.collectingAndThen;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.IdentityHashMap;
|
import java.util.IdentityHashMap;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -71,15 +74,18 @@ public class TerminologySvcImpl implements ITerminologySvc {
|
||||||
@Override
|
@Override
|
||||||
public Set<TermConcept> findCodesAbove(Long theCodeSystemResourcePid, Long theCodeSystemVersionPid, String theCode) {
|
public Set<TermConcept> findCodesAbove(Long theCodeSystemResourcePid, Long theCodeSystemVersionPid, String theCode) {
|
||||||
Stopwatch stopwatch = Stopwatch.createStarted();
|
Stopwatch stopwatch = Stopwatch.createStarted();
|
||||||
|
|
||||||
TermConcept concept = fetchLoadedCode(theCodeSystemResourcePid, theCodeSystemVersionPid, theCode);
|
TermConcept concept = fetchLoadedCode(theCodeSystemResourcePid, theCodeSystemVersionPid, theCode);
|
||||||
|
if (concept == null) {
|
||||||
|
return Collections.emptySet();
|
||||||
|
}
|
||||||
|
|
||||||
Set<TermConcept> retVal = new HashSet<TermConcept>();
|
Set<TermConcept> retVal = new HashSet<TermConcept>();
|
||||||
retVal.add(concept);
|
retVal.add(concept);
|
||||||
|
|
||||||
fetchParents(concept, retVal);
|
fetchParents(concept, retVal);
|
||||||
|
|
||||||
ourLog.info("Fetched {} codes above code {} in {}ms", retVal.size(), theCode, stopwatch.elapsed(TimeUnit.MILLISECONDS));
|
ourLog.info("Fetched {} codes above code {} in {}ms", new Object[] { retVal.size(), theCode, stopwatch.elapsed(TimeUnit.MILLISECONDS) });
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,15 +93,18 @@ public class TerminologySvcImpl implements ITerminologySvc {
|
||||||
@Override
|
@Override
|
||||||
public Set<TermConcept> findCodesBelow(Long theCodeSystemResourcePid, Long theCodeSystemVersionPid, String theCode) {
|
public Set<TermConcept> findCodesBelow(Long theCodeSystemResourcePid, Long theCodeSystemVersionPid, String theCode) {
|
||||||
Stopwatch stopwatch = Stopwatch.createStarted();
|
Stopwatch stopwatch = Stopwatch.createStarted();
|
||||||
|
|
||||||
TermConcept concept = fetchLoadedCode(theCodeSystemResourcePid, theCodeSystemVersionPid, theCode);
|
TermConcept concept = fetchLoadedCode(theCodeSystemResourcePid, theCodeSystemVersionPid, theCode);
|
||||||
|
if (concept == null) {
|
||||||
|
return Collections.emptySet();
|
||||||
|
}
|
||||||
|
|
||||||
Set<TermConcept> retVal = new HashSet<TermConcept>();
|
Set<TermConcept> retVal = new HashSet<TermConcept>();
|
||||||
retVal.add(concept);
|
retVal.add(concept);
|
||||||
|
|
||||||
fetchChildren(concept, retVal);
|
fetchChildren(concept, retVal);
|
||||||
|
|
||||||
ourLog.info("Fetched {} codes below code {} in {}ms", retVal.size(), theCode, stopwatch.elapsed(TimeUnit.MILLISECONDS));
|
ourLog.info("Fetched {} codes below code {} in {}ms", new Object[] { retVal.size(), theCode, stopwatch.elapsed(TimeUnit.MILLISECONDS) });
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +140,8 @@ public class TerminologySvcImpl implements ITerminologySvc {
|
||||||
myCodeSystemDao.save(newCodeSystem);
|
myCodeSystemDao.save(newCodeSystem);
|
||||||
} else {
|
} else {
|
||||||
if (!ObjectUtil.equals(codeSystem.getResource().getId(), theCodeSystem.getResource().getId())) {
|
if (!ObjectUtil.equals(codeSystem.getResource().getId(), theCodeSystem.getResource().getId())) {
|
||||||
throw new InvalidRequestException(myContext.getLocalizer().getMessage(TerminologySvcImpl.class, "cannotCreateDuplicateCodeSystemUri", theSystemUri, codeSystem.getResource().getIdDt().getValue()));
|
throw new InvalidRequestException(
|
||||||
|
myContext.getLocalizer().getMessage(TerminologySvcImpl.class, "cannotCreateDuplicateCodeSystemUri", theSystemUri, codeSystem.getResource().getIdDt().getValue()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,11 +9,14 @@ import org.apache.commons.dbcp2.BasicDataSource;
|
||||||
import org.hibernate.jpa.HibernatePersistenceProvider;
|
import org.hibernate.jpa.HibernatePersistenceProvider;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.orm.jpa.JpaTransactionManager;
|
import org.springframework.orm.jpa.JpaTransactionManager;
|
||||||
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
||||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
|
|
||||||
import ca.uhn.fhir.jpa.dao.DaoConfig;
|
import ca.uhn.fhir.jpa.dao.DaoConfig;
|
||||||
|
import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor;
|
||||||
|
import ca.uhn.fhir.validation.ResultSeverityEnum;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableTransactionManagement()
|
@EnableTransactionManagement()
|
||||||
|
@ -65,4 +68,19 @@ public class TestDstu3Config extends BaseJavaConfigDstu3 {
|
||||||
return extraProperties;
|
return extraProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bean which validates incoming requests
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
@Lazy
|
||||||
|
public RequestValidatingInterceptor requestValidatingInterceptor() {
|
||||||
|
RequestValidatingInterceptor requestValidator = new RequestValidatingInterceptor();
|
||||||
|
requestValidator.setFailOnSeverity(ResultSeverityEnum.ERROR);
|
||||||
|
requestValidator.setAddResponseHeaderOnSeverity(null);
|
||||||
|
requestValidator.setAddResponseOutcomeHeaderOnSeverity(ResultSeverityEnum.INFORMATION);
|
||||||
|
requestValidator.addValidatorModule(instanceValidatorDstu3());
|
||||||
|
|
||||||
|
return requestValidator;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package ca.uhn.fhir.jpa.term;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||||
import static org.hamcrest.Matchers.containsString;
|
import static org.hamcrest.Matchers.containsString;
|
||||||
|
import static org.hamcrest.Matchers.empty;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
@ -100,9 +101,15 @@ public class TerminologySvcImplTest extends BaseJpaDstu3Test {
|
||||||
concepts = myTermSvc.findCodesBelow(id.getIdPartAsLong(), id.getVersionIdPartAsLong(), "childAA");
|
concepts = myTermSvc.findCodesBelow(id.getIdPartAsLong(), id.getVersionIdPartAsLong(), "childAA");
|
||||||
codes = toCodes(concepts);
|
codes = toCodes(concepts);
|
||||||
assertThat(codes, containsInAnyOrder("childAA", "childAAA", "childAAB"));
|
assertThat(codes, containsInAnyOrder("childAA", "childAAA", "childAAB"));
|
||||||
}
|
|
||||||
|
// Try an unknown code
|
||||||
|
concepts = myTermSvc.findCodesBelow(id.getIdPartAsLong(), id.getVersionIdPartAsLong(), "FOO_BAD_CODE");
|
||||||
|
codes = toCodes(concepts);
|
||||||
|
assertThat(codes, empty());
|
||||||
|
|
||||||
@Test@Ignore
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testFindCodesAbove() {
|
public void testFindCodesAbove() {
|
||||||
CodeSystem codeSystem = new CodeSystem();
|
CodeSystem codeSystem = new CodeSystem();
|
||||||
codeSystem.setUrl("http://example.com/my_code_system");
|
codeSystem.setUrl("http://example.com/my_code_system");
|
||||||
|
@ -145,6 +152,11 @@ public class TerminologySvcImplTest extends BaseJpaDstu3Test {
|
||||||
concepts = myTermSvc.findCodesAbove(id.getIdPartAsLong(), id.getVersionIdPartAsLong(), "childAAB");
|
concepts = myTermSvc.findCodesAbove(id.getIdPartAsLong(), id.getVersionIdPartAsLong(), "childAAB");
|
||||||
codes = toCodes(concepts);
|
codes = toCodes(concepts);
|
||||||
assertThat(codes, containsInAnyOrder("ParentA", "childAA", "childAAB"));
|
assertThat(codes, containsInAnyOrder("ParentA", "childAA", "childAAB"));
|
||||||
|
|
||||||
|
// Try an unknown code
|
||||||
|
concepts = myTermSvc.findCodesAbove(id.getIdPartAsLong(), id.getVersionIdPartAsLong(), "FOO_BAD_CODE");
|
||||||
|
codes = toCodes(concepts);
|
||||||
|
assertThat(codes, empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -157,14 +157,12 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-dbcp2</artifactId>
|
<artifactId>commons-dbcp2</artifactId>
|
||||||
<version>2.0.1</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Only required for CORS support -->
|
<!-- Only required for CORS support -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.ebaysf.web</groupId>
|
<groupId>org.ebaysf.web</groupId>
|
||||||
<artifactId>cors-filter</artifactId>
|
<artifactId>cors-filter</artifactId>
|
||||||
<version>${ebay_cors_filter_version}</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
@ -14,6 +14,7 @@ import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.DependsOn;
|
import org.springframework.context.annotation.DependsOn;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
||||||
import org.springframework.orm.jpa.JpaTransactionManager;
|
import org.springframework.orm.jpa.JpaTransactionManager;
|
||||||
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
||||||
|
@ -93,12 +94,12 @@ public class TestDstu3Config extends BaseJavaConfigDstu3 {
|
||||||
* Bean which validates incoming requests
|
* Bean which validates incoming requests
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
|
@Lazy
|
||||||
public RequestValidatingInterceptor requestValidatingInterceptor() {
|
public RequestValidatingInterceptor requestValidatingInterceptor() {
|
||||||
RequestValidatingInterceptor requestValidator = new RequestValidatingInterceptor();
|
RequestValidatingInterceptor requestValidator = new RequestValidatingInterceptor();
|
||||||
requestValidator.setFailOnSeverity(ResultSeverityEnum.ERROR);
|
requestValidator.setFailOnSeverity(ResultSeverityEnum.ERROR);
|
||||||
requestValidator.setAddResponseHeaderOnSeverity(null);
|
requestValidator.setAddResponseHeaderOnSeverity(null);
|
||||||
requestValidator.setAddResponseOutcomeHeaderOnSeverity(ResultSeverityEnum.INFORMATION);
|
requestValidator.setAddResponseOutcomeHeaderOnSeverity(ResultSeverityEnum.INFORMATION);
|
||||||
requestValidator.addValidatorModule(questionnaireResponseValidatorDstu3());
|
|
||||||
requestValidator.addValidatorModule(instanceValidatorDstu3());
|
requestValidator.addValidatorModule(instanceValidatorDstu3());
|
||||||
|
|
||||||
return requestValidator;
|
return requestValidator;
|
||||||
|
@ -108,6 +109,7 @@ public class TestDstu3Config extends BaseJavaConfigDstu3 {
|
||||||
* Bean which validates outgoing responses
|
* Bean which validates outgoing responses
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
|
@Lazy
|
||||||
public ResponseValidatingInterceptor responseValidatingInterceptor() {
|
public ResponseValidatingInterceptor responseValidatingInterceptor() {
|
||||||
ResponseValidatingInterceptor responseValidator = new ResponseValidatingInterceptor();
|
ResponseValidatingInterceptor responseValidator = new ResponseValidatingInterceptor();
|
||||||
responseValidator.setResponseHeaderValueNoIssues("Validation did not detect any issues");
|
responseValidator.setResponseHeaderValueNoIssues("Validation did not detect any issues");
|
||||||
|
@ -124,7 +126,6 @@ public class TestDstu3Config extends BaseJavaConfigDstu3 {
|
||||||
responseValidator.addExcludeOperationType(RestOperationTypeEnum.HISTORY_TYPE);
|
responseValidator.addExcludeOperationType(RestOperationTypeEnum.HISTORY_TYPE);
|
||||||
responseValidator.addExcludeOperationType(RestOperationTypeEnum.SEARCH_SYSTEM);
|
responseValidator.addExcludeOperationType(RestOperationTypeEnum.SEARCH_SYSTEM);
|
||||||
responseValidator.addExcludeOperationType(RestOperationTypeEnum.SEARCH_TYPE);
|
responseValidator.addExcludeOperationType(RestOperationTypeEnum.SEARCH_TYPE);
|
||||||
responseValidator.addValidatorModule(questionnaireResponseValidatorDstu3());
|
|
||||||
responseValidator.addValidatorModule(instanceValidatorDstu3());
|
responseValidator.addValidatorModule(instanceValidatorDstu3());
|
||||||
return responseValidator;
|
return responseValidator;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,16 +2,14 @@ package ca.uhn.fhirtest;
|
||||||
|
|
||||||
import org.eclipse.jetty.server.Server;
|
import org.eclipse.jetty.server.Server;
|
||||||
import org.eclipse.jetty.webapp.WebAppContext;
|
import org.eclipse.jetty.webapp.WebAppContext;
|
||||||
|
import org.hl7.fhir.dstu3.model.Organization;
|
||||||
|
import org.hl7.fhir.dstu3.model.Patient;
|
||||||
|
import org.hl7.fhir.dstu3.model.Subscription;
|
||||||
|
import org.hl7.fhir.dstu3.model.Subscription.SubscriptionChannelType;
|
||||||
|
import org.hl7.fhir.dstu3.model.Subscription.SubscriptionStatus;
|
||||||
|
import org.hl7.fhir.instance.model.api.IIdType;
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
|
|
||||||
import ca.uhn.fhir.model.api.TagList;
|
|
||||||
import ca.uhn.fhir.model.dstu.resource.Organization;
|
|
||||||
import ca.uhn.fhir.model.dstu.resource.Patient;
|
|
||||||
import ca.uhn.fhir.model.dstu2.resource.Subscription;
|
|
||||||
import ca.uhn.fhir.model.dstu2.valueset.SubscriptionChannelTypeEnum;
|
|
||||||
import ca.uhn.fhir.model.dstu2.valueset.SubscriptionStatusEnum;
|
|
||||||
import ca.uhn.fhir.model.primitive.IdDt;
|
|
||||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||||
import ca.uhn.fhir.rest.client.IGenericClient;
|
import ca.uhn.fhir.rest.client.IGenericClient;
|
||||||
|
|
||||||
|
@ -20,7 +18,7 @@ public class UhnFhirTestApp {
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
|
||||||
int myPort = 8888;
|
int myPort = 8888;
|
||||||
String base = "http://localhost:" + myPort + "/baseDstu2";
|
String base = "http://localhost:" + myPort + "/baseDstu3";
|
||||||
|
|
||||||
// new File("target/testdb").mkdirs();
|
// new File("target/testdb").mkdirs();
|
||||||
System.setProperty("fhir.db.location", "./target/testdb");
|
System.setProperty("fhir.db.location", "./target/testdb");
|
||||||
|
@ -50,28 +48,24 @@ public class UhnFhirTestApp {
|
||||||
// base = "http://spark.furore.com/fhir";
|
// base = "http://spark.furore.com/fhir";
|
||||||
|
|
||||||
if (true) {
|
if (true) {
|
||||||
FhirContext ctx = FhirContext.forDstu2();
|
FhirContext ctx = FhirContext.forDstu3();
|
||||||
IGenericClient client = ctx.newRestfulGenericClient(base);
|
IGenericClient client = ctx.newRestfulGenericClient(base);
|
||||||
// client.setLogRequestAndResponse(true);
|
// client.setLogRequestAndResponse(true);
|
||||||
|
|
||||||
Organization o1 = new Organization();
|
Organization o1 = new Organization();
|
||||||
o1.getName().setValue("Some Org");
|
o1.getNameElement().setValue("Some Org");
|
||||||
MethodOutcome create = client.create().resource(o1).execute();
|
MethodOutcome create = client.create().resource(o1).execute();
|
||||||
IdDt orgId = (IdDt) create.getId();
|
IIdType orgId = (IIdType) create.getId();
|
||||||
|
|
||||||
Patient p1 = new Patient();
|
Patient p1 = new Patient();
|
||||||
p1.addIdentifier("foo:bar", "12345");
|
p1.getMeta().addTag("http://hl7.org/fhir/tag", "urn:happytag", "This is a happy resource");
|
||||||
|
p1.addIdentifier().setSystem("foo:bar").setValue("12345");
|
||||||
p1.addName().addFamily("Smith").addGiven("John");
|
p1.addName().addFamily("Smith").addGiven("John");
|
||||||
p1.getManagingOrganization().setReference(orgId);
|
p1.getManagingOrganization().setReferenceElement(orgId);
|
||||||
|
|
||||||
TagList list = new TagList();
|
|
||||||
list.addTag("http://hl7.org/fhir/tag", "urn:happytag", "This is a happy resource");
|
|
||||||
ResourceMetadataKeyEnum.TAG_LIST.put(p1, list);
|
|
||||||
client.create().resource(p1).execute();
|
|
||||||
|
|
||||||
Subscription subs = new Subscription();
|
Subscription subs = new Subscription();
|
||||||
subs.setStatus(SubscriptionStatusEnum.ACTIVE);
|
subs.setStatus(SubscriptionStatus.ACTIVE);
|
||||||
subs.getChannel().setType(SubscriptionChannelTypeEnum.WEBSOCKET);
|
subs.getChannel().setType(SubscriptionChannelType.WEBSOCKET);
|
||||||
subs.setCriteria("Observation?");
|
subs.setCriteria("Observation?");
|
||||||
client.create().resource(subs).execute();
|
client.create().resource(subs).execute();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue