• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ValidationResult类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: testUnexpectedAnswer

import ca.uhn.fhir.validation.ValidationResult; //导入依赖的package包/类
@Test
public void testUnexpectedAnswer() {
	Questionnaire q = new Questionnaire();
	q.addItem().setLinkId("link0").setRequired(false).setType(QuestionnaireItemType.BOOLEAN);

	QuestionnaireResponse qa = new QuestionnaireResponse();
	qa.setStatus(QuestionnaireResponseStatus.COMPLETED);
	qa.getQuestionnaire().setReference("http://example.com/Questionnaire/q1");
	qa.addItem().setLinkId("link1").addAnswer().setValue(new StringType("FOO"));

	when(myValSupport.fetchResource(any(FhirContext.class), eq(Questionnaire.class), eq(qa.getQuestionnaire().getReference()))).thenReturn(q);
	ValidationResult errors = myVal.validateWithResult(qa);

	ourLog.info(errors.toString());
	assertThat(errors.toString(), containsString(" - QuestionnaireResponse"));
	assertThat(errors.toString(), containsString("LinkId \"link1\" not found in questionnaire"));
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:18,代码来源:QuestionnaireResponseValidatorR4Test.java


示例17: testValidateRawXmlWithMissingRootNamespace

import ca.uhn.fhir.validation.ValidationResult; //导入依赖的package包/类
@Test
public void testValidateRawXmlWithMissingRootNamespace() {
	//@formatter:off
	String input = ""
		+ "<Patient>"
		+ "    <text>"
		+ "        <status value=\"generated\"/>"
		+ "        <div xmlns=\"http://www.w3.org/1999/xhtml\">Some narrative</div>"
		+ "    </text>"
		+ "    <name>"
		+ "        <use value=\"official\"/>"
		+ "        <family value=\"Doe\"/>"
		+ "        <given value=\"John\"/>"
		+ "    </name>"
		+ "    <gender value=\"male\"/>"
		+ "    <birthDate value=\"1974-12-25\"/>"
		+ "</Patient>";
	//@formatter:on

	ValidationResult output = myVal.validateWithResult(input);
	assertEquals(output.toString(), 1, output.getMessages().size());
	assertEquals("This cannot be parsed as a FHIR object (no namespace)", output.getMessages().get(0).getMessage());
	ourLog.info(output.getMessages().get(0).getLocationString());
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:25,代码来源:FhirInstanceValidatorDstu3Test.java


示例18: testValidateResourceContainingLoincCode

import ca.uhn.fhir.validation.ValidationResult; //导入依赖的package包/类
@Test
public void testValidateResourceContainingLoincCode() {
	addValidConcept("http://loinc.org", "1234567");

	Observation input = new Observation();
	// input.getMeta().addProfile("http://hl7.org/fhir/StructureDefinition/devicemetricobservation");

	input.addIdentifier().setSystem("http://acme").setValue("12345");
	input.getContext().setReference("http://foo.com/Encounter/9");
	input.setStatus(ObservationStatus.FINAL);
	input.getCode().addCoding().setSystem("http://loinc.org").setCode("12345");

	myInstanceVal.setValidationSupport(myMockSupport);
	ValidationResult output = myVal.validateWithResult(input);
	List<SingleValidationMessage> errors = logResultsAndReturnAll(output);

	assertThat(errors.toString(), containsString("warning"));
	assertThat(errors.toString(), containsString("Unknown code: http://loinc.org / 12345"));
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:20,代码来源:FhirInstanceValidatorDstu3Test.java


示例19: testValidateResourceContainingProfileDeclaration

import ca.uhn.fhir.validation.ValidationResult; //导入依赖的package包/类
@Test
public void testValidateResourceContainingProfileDeclaration() {
	addValidConcept("http://loinc.org", "12345");

	Observation input = new Observation();
	input.getMeta().addProfile("http://hl7.org/fhir/StructureDefinition/devicemetricobservation");

	input.addIdentifier().setSystem("http://acme").setValue("12345");
	input.getContext().setReference("http://foo.com/Encounter/9");
	input.setStatus(ObservationStatus.FINAL);
	input.getCode().addCoding().setSystem("http://loinc.org").setCode("12345");

	myInstanceVal.setValidationSupport(myMockSupport);
	ValidationResult output = myVal.validateWithResult(input);
	List<SingleValidationMessage> errors = logResultsAndReturnNonInformationalOnes(output);

	assertThat(errors.toString(), containsString("Element 'Observation.subject': minimum required = 1, but only found 0"));
	assertThat(errors.toString(), containsString("Element 'Observation.context': max allowed = 0, but found 1"));
	assertThat(errors.toString(), containsString("Element 'Observation.device': minimum required = 1, but only found 0"));
	assertThat(errors.toString(), containsString(""));
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:22,代码来源:FhirInstanceValidatorDstu3Test.java


示例20: testValidateResourceContainingProfileDeclarationDoesntResolve

import ca.uhn.fhir.validation.ValidationResult; //导入依赖的package包/类
@Test
public void testValidateResourceContainingProfileDeclarationDoesntResolve() {
	addValidConcept("http://loinc.org", "12345");

	Observation input = new Observation();
	input.getMeta().addProfile("http://foo/myprofile");

	input.getCode().addCoding().setSystem("http://loinc.org").setCode("12345");
	input.setStatus(ObservationStatus.FINAL);

	myInstanceVal.setValidationSupport(myMockSupport);
	ValidationResult output = myVal.validateWithResult(input);
	List<SingleValidationMessage> errors = logResultsAndReturnNonInformationalOnes(output);
	assertEquals(errors.toString(), 1, errors.size());
	assertEquals("StructureDefinition reference \"http://foo/myprofile\" could not be resolved", errors.get(0).getMessage());
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:17,代码来源:FhirInstanceValidatorDstu3Test.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GroupQueryImpl类代码示例发布时间:2022-05-22
下一篇:
Java JerseyWebTarget类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap