当前位置: 首页>>代码示例>>Java>>正文


Java FhirInstanceValidator类代码示例

本文整理汇总了Java中org.hl7.fhir.dstu3.hapi.validation.FhirInstanceValidator的典型用法代码示例。如果您正苦于以下问题:Java FhirInstanceValidator类的具体用法?Java FhirInstanceValidator怎么用?Java FhirInstanceValidator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FhirInstanceValidator类属于org.hl7.fhir.dstu3.hapi.validation包,在下文中一共展示了FhirInstanceValidator类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.hl7.fhir.dstu3.hapi.validation.FhirInstanceValidator; //导入依赖的package包/类
public static void main(String[] args) {
	// Create an incomplete encounter (status is required)
	Encounter enc = new Encounter();
	enc.addIdentifier().setSystem("http://acme.org/encNums").setValue("12345");
	
	// Create a new validator
	FhirValidator validator = FhirContext.forDstu3().newValidator();
	
	// Cache this object! Supplies structure definitions
	DefaultProfileValidationSupport support = new DefaultProfileValidationSupport();
	
	// Create the validator
	FhirInstanceValidator module = new FhirInstanceValidator(support);
	validator.registerValidatorModule(module);
	
	// Did we succeed?
	IParser parser = FhirContext.forDstu3().newXmlParser().setPrettyPrint(true);
	System.out.println(parser.encodeResourceToString(validator.validateWithResult(enc).toOperationOutcome()));
}
 
开发者ID:furore-fhir,项目名称:fhirstarters,代码行数:20,代码来源:Example22_ValidateResourceInstanceValidator.java

示例2: testSearchXmlInvalidInstanceValidator

import org.hl7.fhir.dstu3.hapi.validation.FhirInstanceValidator; //导入依赖的package包/类
@Test
public void testSearchXmlInvalidInstanceValidator() throws Exception {
	IValidatorModule module = new FhirInstanceValidator();
	myInterceptor.addValidatorModule(module);
	myInterceptor.setAddResponseHeaderOnSeverity(ResultSeverityEnum.INFORMATION);

	Patient patient = new Patient();
	patient.addIdentifier().setValue("002");
	patient.setGender(AdministrativeGender.MALE);
	patient.addContact().addRelationship().setText("FOO");
	myReturnResource = patient;

	HttpGet httpPost = new HttpGet("http://localhost:" + ourPort + "/Patient?foo=bar");

	HttpResponse status = ourClient.execute(httpPost);

	String responseContent = IOUtils.toString(status.getEntity().getContent());
	IOUtils.closeQuietly(status.getEntity().getContent());

	ourLog.info("Response was:\n{}", status);
	ourLog.info("Response was:\n{}", responseContent);

	Assert.assertEquals(422, status.getStatusLine().getStatusCode());
	Assert.assertThat(status.toString(), Matchers.containsString("X-FHIR-Response-Validation"));
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:26,代码来源:ResponseValidatingInterceptorDstu3Test.java

示例3: testSkipEnabled

import org.hl7.fhir.dstu3.hapi.validation.FhirInstanceValidator; //导入依赖的package包/类
@Test
public void testSkipEnabled() throws Exception {
	IValidatorModule module = new FhirInstanceValidator();
	myInterceptor.addValidatorModule(module);
	myInterceptor.addExcludeOperationType(RestOperationTypeEnum.METADATA);
	myInterceptor.setResponseHeaderValueNoIssues("No issues");

	HttpGet httpPost = new HttpGet("http://localhost:" + ourPort + "/metadata");
	HttpResponse status = ourClient.execute(httpPost);

	String responseContent = IOUtils.toString(status.getEntity().getContent());
	IOUtils.closeQuietly(status.getEntity().getContent());

	ourLog.info("Response was:\n{}", status);
	ourLog.info("Response was:\n{}", responseContent);

	Assert.assertEquals(200, status.getStatusLine().getStatusCode());
	Assert.assertThat(status.toString(), Matchers.not(Matchers.containsString("X-FHIR-Response-Validation")));
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:20,代码来源:ResponseValidatingInterceptorDstu3Test.java

示例4: testSkipNotEnabled

import org.hl7.fhir.dstu3.hapi.validation.FhirInstanceValidator; //导入依赖的package包/类
@Test
public void testSkipNotEnabled() throws Exception {
	IValidatorModule module = new FhirInstanceValidator();
	myInterceptor.addValidatorModule(module);
	myInterceptor.setResponseHeaderValueNoIssues("No issues");
	myInterceptor.setAddResponseHeaderOnSeverity(ResultSeverityEnum.INFORMATION);

	HttpGet httpPost = new HttpGet("http://localhost:" + ourPort + "/metadata?_pretty=true");
	HttpResponse status = ourClient.execute(httpPost);

	String responseContent = IOUtils.toString(status.getEntity().getContent());
	ourLog.info(responseContent);
	IOUtils.closeQuietly(status.getEntity().getContent());

	ourLog.info("Response was:\n{}", status);
	ourLog.info("Response was:\n{}", responseContent);

	Assert.assertEquals(200, status.getStatusLine().getStatusCode());
	Assert.assertThat(status.toString(), (Matchers.containsString("X-FHIR-Response-Validation")));
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:21,代码来源:ResponseValidatingInterceptorDstu3Test.java

示例5: validateProfileDstu3

import org.hl7.fhir.dstu3.hapi.validation.FhirInstanceValidator; //导入依赖的package包/类
public void validateProfileDstu3() {
   // START SNIPPET: validateFiles
   
   FhirContext ctx = FhirContext.forDstu3();
   FhirValidator validator = ctx.newValidator();
   
   // Typically if you are doing profile validation, you want to disable
   // the schema/schematron validation since the profile will specify
   // all the same rules (and more)
   validator.setValidateAgainstStandardSchema(false);
   validator.setValidateAgainstStandardSchematron(false);
   
   // FhirInstanceValidator is the validation module that handles 
   // profile validation. So, create an InstanceValidator module 
   // and register it to the validator.
   FhirInstanceValidator instanceVal = new FhirInstanceValidator();
   validator.registerValidatorModule(instanceVal);

   // FhirInstanceValidator requires an instance of "IValidationSupport" in
   // order to function. This module is used by the validator to actually obtain
   // all of the resources it needs in order to perform validation. Specifically,
   // the validator uses it to fetch StructureDefinitions, ValueSets, CodeSystems,
   // etc, as well as to perform terminology validation.
   //
   // The implementation used here (ValidationSupportChain) is allows for
   // multiple implementations to be used in a chain, where if a specific resource
   // is needed the whole chain is tried and the first module which is actually
   // able to answer is used. The first entry in the chain that we register is
   // the DefaultProfileValidationSupport, which supplies the "built-in" FHIR
   // StructureDefinitions and ValueSets
   ValidationSupportChain validationSupportChain = new ValidationSupportChain();
   validationSupportChain.addValidationSupport(new DefaultProfileValidationSupport());
   instanceVal.setValidationSupport(validationSupportChain);
   
   // END SNIPPET: validateFiles
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:37,代码来源:ValidatorExamplesDstu3.java

示例6: testCreateXmlInvalidInstanceValidator

import org.hl7.fhir.dstu3.hapi.validation.FhirInstanceValidator; //导入依赖的package包/类
@Test
public void testCreateXmlInvalidInstanceValidator() throws Exception {
	IValidatorModule module = new FhirInstanceValidator();
	myInterceptor.addValidatorModule(module);
	myInterceptor.setAddResponseHeaderOnSeverity(ResultSeverityEnum.INFORMATION);
	myInterceptor.setAddResponseHeaderOnSeverity(ResultSeverityEnum.INFORMATION);

	Patient patient = new Patient();
	patient.addIdentifier().setValue("002");
	patient.setGender(AdministrativeGender.MALE);
	patient.addContact().addRelationship().setText("FOO");
	String encoded = ourCtx.newXmlParser().encodeResourceToString(patient);

	HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient");
	httpPost.setEntity(new StringEntity(encoded, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));

	HttpResponse status = ourClient.execute(httpPost);

	String responseContent = IOUtils.toString(status.getEntity().getContent());
	IOUtils.closeQuietly(status.getEntity().getContent());

	ourLog.info("Response was:\n{}", status);
	ourLog.info("Response was:\n{}", responseContent);

	assertEquals(422, status.getStatusLine().getStatusCode());
	assertThat(status.toString(), Matchers.containsString("X-FHIR-Request-Validation"));
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:28,代码来源:RequestValidatingInterceptorDstu3Test.java

示例7: instanceValidatorDstu3

import org.hl7.fhir.dstu3.hapi.validation.FhirInstanceValidator; //导入依赖的package包/类
@Bean(name = "myInstanceValidatorDstu3")
@Lazy
public IValidatorModule instanceValidatorDstu3() {
	FhirInstanceValidator val = new FhirInstanceValidator();
	val.setBestPracticeWarningLevel(IResourceValidator.BestPracticeWarningLevel.Warning);
	val.setValidationSupport(validationSupportChainDstu3());
	return val;
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:9,代码来源:BaseDstu3Config.java

示例8: before

import org.hl7.fhir.dstu3.hapi.validation.FhirInstanceValidator; //导入依赖的package包/类
@Before
public void before() throws Exception {
	super.before();

	myRequestValidatingInterceptor = new RequestValidatingInterceptor();
	FhirInstanceValidator module = new FhirInstanceValidator();
	module.setValidationSupport(myValidationSupport);
	myRequestValidatingInterceptor.addValidatorModule(module);
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:10,代码来源:StressTestDstu3Test.java

示例9: testValidateUsingIncomingResources

import org.hl7.fhir.dstu3.hapi.validation.FhirInstanceValidator; //导入依赖的package包/类
/**
 * FOrmat has changed, source is no longer valid
 */
@Test
@Ignore
public void testValidateUsingIncomingResources() throws Exception {
	FhirInstanceValidator val = new FhirInstanceValidator(myValidationSupport);
	RequestValidatingInterceptor interceptor = new RequestValidatingInterceptor();
	interceptor.addValidatorModule(val);
	interceptor.setFailOnSeverity(ResultSeverityEnum.ERROR);
	interceptor.setAddResponseHeaderOnSeverity(ResultSeverityEnum.INFORMATION);
	myRestServer.registerInterceptor(interceptor);
	try {

		InputStream bundleRes = SystemProviderDstu2Test.class.getResourceAsStream("/questionnaire-sdc-profile-example-ussg-fht.xml");
		String bundleStr = IOUtils.toString(bundleRes, StandardCharsets.UTF_8);

		HttpPost req = new HttpPost(ourServerBase);
		req.setEntity(new StringEntity(bundleStr, ContentType.parse(Constants.CT_FHIR_XML + "; charset=utf-8")));
		
		CloseableHttpResponse resp = ourHttpClient.execute(req);
		try {
			String encoded = IOUtils.toString(resp.getEntity().getContent(), StandardCharsets.UTF_8);
			ourLog.info(encoded);

			//@formatter:off
			assertThat(encoded, containsString("Questionnaire/54127-6/_history/")); 
			//@formatter:on

			for (Header next : resp.getHeaders(RequestValidatingInterceptor.DEFAULT_RESPONSE_HEADER_NAME)) {
				ourLog.info(next.toString());
			}
		} finally {
			IOUtils.closeQuietly(resp.getEntity().getContent());
		}
	} finally {
		myRestServer.unregisterInterceptor(interceptor);
	}
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:40,代码来源:SystemProviderDstu3Test.java


注:本文中的org.hl7.fhir.dstu3.hapi.validation.FhirInstanceValidator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。