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


Java ValidationResult类代码示例

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


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

示例1: validateResource

import ca.uhn.fhir.validation.ValidationResult; //导入依赖的package包/类
private void validateResource(Resource resource) {
    ValidationResult result = validator.validateWithResult(resource);

    // Show the issues
    // Colour values https://github.com/yonchu/shell-color-pallet/blob/master/color16
    for (SingleValidationMessage next : result.getMessages()) {
        switch (next.getSeverity())
        {
            case ERROR:
                fail("FHIR Validation ERROR - "+ next.getMessage());
                break;
            case WARNING:
                //fail("FHIR Validation WARNING - "+ next.getMessage());
                System.out.println(  (char)27 + "[34mWARNING" + (char)27 + "[0m" + " - " +  next.getLocationString() + " - " + next.getMessage());
                break;
            case INFORMATION:
                System.out.println( (char)27 + "[34mINFORMATION" + (char)27 + "[0m" + " - " +  next.getLocationString() + " - " + next.getMessage());
                break;
            default:
                System.out.println(" Next issue " + next.getSeverity() + " - " + next.getLocationString() + " - " + next.getMessage());
        }
    }
}
 
开发者ID:nhsconnect,项目名称:careconnect-reference-implementation,代码行数:24,代码来源:JPAStepsDef.java

示例2: publishFhirConsentToHie

import ca.uhn.fhir.validation.ValidationResult; //导入依赖的package包/类
@Override
public void publishFhirConsentToHie(Consent fhirConsent) {
    //validate the resource
    ValidationResult validationResult =  fhirValidator.validateWithResult(fhirConsent);

    logger.debug("validationResult.isSuccessful(): " + validationResult.isSuccessful());
    //throw format error if the validation is not successful
    if (!validationResult.isSuccessful()) {
        throw new FHIRFormatErrorException("Consent Validation is not successful" + validationResult.getMessages());
    }

    /*
    Use the client to store a new consent resource instance
    Invoke the server create method (and send pretty-printed JSON
    encoding to the server
    instead of the default which is non-pretty printed XML)
    invoke Consent service
    */
   fhirClient.create().resource(fhirConsent).execute();

}
 
开发者ID:bhits,项目名称:pcm-api,代码行数:22,代码来源:FhirConsentServiceImpl.java

示例3: validateFhirRequest

import ca.uhn.fhir.validation.ValidationResult; //导入依赖的package包/类
private FhirValidationResult validateFhirRequest(Contents contents) {
    FhirValidationResult result = new FhirValidationResult();
    FhirValidator validator = fhirContext.newValidator();

    IParser parser = newParser(contents.contentType);
    IBaseResource resource = parser.parseResource(contents.content);
    ValidationResult vr = validator.validateWithResult(resource);

    if (vr.isSuccessful()) {
        result.passed = true;
    } else {
        result.passed = false;
        result.operationOutcome = vr.toOperationOutcome();
    }

    return result;
}
 
开发者ID:jembi,项目名称:openhim-mediator-fhir-proxy,代码行数:18,代码来源:FhirProxyHandler.java

示例4: main

import ca.uhn.fhir.validation.ValidationResult; //导入依赖的package包/类
public static void main(String[] args) {

      String input = "<Encounter xmlns=\"http://hl7.org/fhir\"></Encounter>";

      // Create a new validator
      FhirContext ctx = FhirContext.forDstu3();
      FhirValidator validator = ctx.newValidator();

      // Did we succeed?
      ValidationResult result = validator.validateWithResult(input);
      System.out.println("Success: " + result.isSuccessful());

      // What was the result
      OperationOutcome outcome = (OperationOutcome) result.toOperationOutcome();
      IParser parser = ctx.newXmlParser().setPrettyPrint(true);
      System.out.println(parser.encodeResourceToString(outcome));
   }
 
开发者ID:furore-fhir,项目名称:fhirstarters,代码行数:18,代码来源:Example21_ValidateResourceString.java

示例5: main

import ca.uhn.fhir.validation.ValidationResult; //导入依赖的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
	FhirContext ctx = FhirContext.forDstu3();
	FhirValidator validator = ctx.newValidator();
	
	// Did we succeed?
	ValidationResult result = validator.validateWithResult(enc);
	System.out.println("Success: " + result.isSuccessful());
	
	// What was the result
	OperationOutcome outcome = (OperationOutcome) result.toOperationOutcome();
	IParser parser = ctx.newXmlParser().setPrettyPrint(true);
	System.out.println(parser.encodeResourceToString(outcome));
}
 
开发者ID:furore-fhir,项目名称:fhirstarters,代码行数:20,代码来源:Example20_ValidateResource.java

示例6: testDateParsesWithInvalidPrecision

import ca.uhn.fhir.validation.ValidationResult; //导入依赖的package包/类
/**
 * Test for #57
 */
@Test
public void testDateParsesWithInvalidPrecision() {
	Condition c = new Condition();
	c.setDateAsserted(new DateDt());
	c.getDateAsserted().setValueAsString("2001-01-02T11:13:33");
	assertEquals(TemporalPrecisionEnum.SECOND, c.getDateAsserted().getPrecision());

	String encoded = ourCtx.newXmlParser().encodeResourceToString(c);
	Assert.assertThat(encoded, Matchers.containsString("value=\"2001-01-02T11:13:33\""));

	c = ourCtx.newXmlParser().parseResource(Condition.class, encoded);

	assertEquals("2001-01-02T11:13:33", c.getDateAsserted().getValueAsString());
	assertEquals(TemporalPrecisionEnum.SECOND, c.getDateAsserted().getPrecision());

	ValidationResult outcome = ourCtx.newValidator().validateWithResult(c);
	String outcomeStr = ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome.getOperationOutcome());
	ourLog.info(outcomeStr);

	assertThat(outcomeStr, containsString("date-primitive"));
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:25,代码来源:BaseDateTimeDtTest.java

示例7: main

import ca.uhn.fhir.validation.ValidationResult; //导入依赖的package包/类
public static void main(String[] args) {
	
	// Create an encounter with an invalid status and no class
	Encounter enc = new Encounter();
	enc.getStatus().setValueAsString("invalid_status");
	
	// Create a new validator
	FhirContext ctx = new FhirContext();
	FhirValidator validator = ctx.newValidator();
	
	// Did we succeed?
	ValidationResult result = validator.validateWithResult(enc);
	System.out.println("Success: " + result.isSuccessful());
	
	// What was the result
	OperationOutcome outcome = result.getOperationOutcome();
	IParser parser = ctx.newXmlParser().setPrettyPrint(true);
	System.out.println(parser.encodeResourceToString(outcome));

	
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:22,代码来源:Example08_ValidateResource.java

示例8: testValidateGeneratedStatement

import ca.uhn.fhir.validation.ValidationResult; //导入依赖的package包/类
@Test
public void testValidateGeneratedStatement() throws Exception {

	RestfulServer rs = new RestfulServer(ourCtx);
	rs.setProviders(new MultiOptionalProvider());

	ServerCapabilityStatementProvider sc = new ServerCapabilityStatementProvider(rs);
	rs.setServerConformanceProvider(sc);

	rs.init(createServletConfig());

	CapabilityStatement conformance = sc.getServerConformance(createHttpServletRequest());
	ourLog.info(ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(conformance));

	ValidationResult result = ourCtx.newValidator().validateWithResult(conformance);
	assertTrue(result.getMessages().toString(), result.isSuccessful());
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:18,代码来源:ServerCapabilityStatementProviderDstu3Test.java

示例9: testDateParsesWithInvalidPrecision

import ca.uhn.fhir.validation.ValidationResult; //导入依赖的package包/类
/**
 * Test for #57
 */
@Test
public void testDateParsesWithInvalidPrecision() {
	Goal c = new Goal();
	c.setStatusDateElement(new DateType());
	c.getStatusDateElement().setValueAsString("2001-01-02T11:13:33");
	assertEquals(TemporalPrecisionEnum.SECOND, c.getStatusDateElement().getPrecision());

	String encoded = ourCtx.newXmlParser().encodeResourceToString(c);
	Assert.assertThat(encoded, Matchers.containsString("value=\"2001-01-02T11:13:33\""));

	c = ourCtx.newXmlParser().parseResource(Goal.class, encoded);

	assertEquals("2001-01-02T11:13:33", c.getStatusDateElement().getValueAsString());
	assertEquals(TemporalPrecisionEnum.SECOND, c.getStatusDateElement().getPrecision());

	ValidationResult outcome = ourCtx.newValidator().validateWithResult(c);
	String outcomeStr = ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome.toOperationOutcome());
	ourLog.info(outcomeStr);

	assertThat(outcomeStr, containsString("date-primitive"));
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:25,代码来源:BaseDateTimeTypeDstu3Test.java

示例10: testValidateCustomStructure

import ca.uhn.fhir.validation.ValidationResult; //导入依赖的package包/类
@Test
public void testValidateCustomStructure() throws Exception {

	FooMessageHeader.FooMessageSourceComponent source = new FooMessageHeader.FooMessageSourceComponent();
	source.getMessageHeaderApplicationId().setValue("APPID");
	source.setName("NAME");
	source.setEndpoint("http://foo");

	FooMessageHeader header = new FooMessageHeader();
	header.setTimestamp(new Date());
	header.getEvent().setSystem("http://system").setCode("value");
	header.setSource(source);

	FhirValidator val = ourCtx.newValidator();
	val.setValidateAgainstStandardSchema(true);
	val.setValidateAgainstStandardSchematron(true);

	ValidationResult result = val.validateWithResult(header);

	ourLog.info(ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(result.toOperationOutcome()));
	assertTrue(result.isSuccessful());
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:23,代码来源:JsonParserDstu3Test.java

示例11: testValidateResourceWithValuesetExpansionBad

import ca.uhn.fhir.validation.ValidationResult; //导入依赖的package包/类
@Test
public void testValidateResourceWithValuesetExpansionBad() {

	Patient patient = new Patient();
	patient.addIdentifier().setSystem("http://example.com/").setValue("12345").getType().addCoding().setSystem("http://example.com/foo/bar").setCode("bar");

	ValidationResult output = myVal.validateWithResult(patient);
	List<SingleValidationMessage> all = logResultsAndReturnAll(output);
	assertEquals(1, all.size());
	assertEquals("Patient.identifier.type", all.get(0).getLocationString());
	assertEquals(
			"None of the codes provided are in the value set http://hl7.org/fhir/ValueSet/identifier-type (http://hl7.org/fhir/ValueSet/identifier-type, and a code should come from this value set unless it has no suitable code) (codes = http://example.com/foo/bar#bar)",
			all.get(0).getMessage());
	assertEquals(ResultSeverityEnum.WARNING, all.get(0).getSeverity());

}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:17,代码来源:FhirInstanceValidatorR4Test.java

示例12: incomingRequestPostProcessed

import ca.uhn.fhir.validation.ValidationResult; //导入依赖的package包/类
@Override
public boolean incomingRequestPostProcessed(RequestDetails theRequestDetails, HttpServletRequest theRequest, HttpServletResponse theResponse) throws AuthenticationException {
	EncodingEnum encoding = RestfulServerUtils.determineRequestEncodingNoDefault(theRequestDetails);
	if (encoding == null) {
		ourLog.trace("Incoming request does not appear to be FHIR, not going to validate");
		return true;
	}

	Charset charset = ResourceParameter.determineRequestCharset(theRequestDetails);
	String requestText = new String(theRequestDetails.loadRequestContents(), charset);

	if (isBlank(requestText)) {
		ourLog.trace("Incoming request does not have a body");
		return true;
	}

	ValidationResult validationResult = validate(requestText, theRequestDetails);

	// The JPA server will use this
	theRequestDetails.getUserData().put(REQUEST_VALIDATION_RESULT, validationResult);

	return true;
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:24,代码来源:RequestValidatingInterceptor.java

示例13: outgoingResponse

import ca.uhn.fhir.validation.ValidationResult; //导入依赖的package包/类
@Override
public boolean outgoingResponse(RequestDetails theRequestDetails, IBaseResource theResponseObject) {
	if (myAddValidationResultsToResponseOperationOutcome) {
		if (theResponseObject instanceof IBaseOperationOutcome) {
			IBaseOperationOutcome oo = (IBaseOperationOutcome) theResponseObject;

			if (theRequestDetails != null) {
				ValidationResult validationResult = (ValidationResult) theRequestDetails.getUserData().get(RequestValidatingInterceptor.REQUEST_VALIDATION_RESULT);
				if (validationResult != null) {
					validationResult.populateOperationOutcome(oo);
				}
			}

		}
	}

	return true;
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:19,代码来源:RequestValidatingInterceptor.java

示例14: testValidateBigRawJsonResource

import ca.uhn.fhir.validation.ValidationResult; //导入依赖的package包/类
@Test
public void testValidateBigRawJsonResource() throws Exception {
	InputStream stream = FhirInstanceValidatorDstu3Test.class.getResourceAsStream("/conformance.json.gz");
	stream = new GZIPInputStream(stream);
	String input = IOUtils.toString(stream);

	long start = System.currentTimeMillis();
	ValidationResult output = null;
	int passes = 1;
	for (int i = 0; i < passes; i++) {
		ourLog.info("Pass {}", i + 1);
		output = myVal.validateWithResult(input);
	}

	long delay = System.currentTimeMillis() - start;
	long per = delay / passes;

	logResultsAndReturnAll(output);

	ourLog.info("Took {} ms -- {}ms / pass", delay, per);
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:22,代码来源:FhirInstanceValidatorDstu3Test.java

示例15: testValidateRawJsonResourceBadAttributes

import ca.uhn.fhir.validation.ValidationResult; //导入依赖的package包/类
@Test
public void testValidateRawJsonResourceBadAttributes() {
	//@formatter:off
	String input =
		"{" +
			"\"resourceType\":\"Patient\"," +
			"\"id\":\"123\"," +
			"\"foo\":\"123\"" +
			"}";
	//@formatter:on

	ValidationResult output = myVal.validateWithResult(input);
	assertEquals(output.toString(), 1, output.getMessages().size());
	ourLog.info(output.getMessages().get(0).getLocationString());
	ourLog.info(output.getMessages().get(0).getMessage());
	assertEquals("/Patient", output.getMessages().get(0).getLocationString());
	assertEquals("Unrecognised property '@foo'", output.getMessages().get(0).getMessage());
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:19,代码来源:FhirInstanceValidatorDstu3Test.java


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