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


Java OperationOutcome类代码示例

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


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

示例1: buildOperationOutcomeException

import org.hl7.fhir.dstu3.model.OperationOutcome; //导入依赖的package包/类
public static BaseServerResponseException buildOperationOutcomeException(BaseServerResponseException exception, OperationOutcome.IssueSeverity code, OperationOutcome.IssueType issueType) {
    CodeableConcept codeableConcept = new CodeableConcept()
            .setText(exception.getMessage());


    OperationOutcome operationOutcome = new OperationOutcome();

    operationOutcome.addIssue()
            .setSeverity(OperationOutcome.IssueSeverity.ERROR)
            .setCode(issueType)
            .setDetails(codeableConcept);

   // operationOutcome.getMeta()
   //         .addProfile(SystemURL.SD_GPC_OPERATIONOUTCOME);

    exception.setOperationOutcome(operationOutcome);
    return exception;
}
 
开发者ID:nhsconnect,项目名称:careconnect-reference-implementation,代码行数:19,代码来源:OperationOutcomeFactory.java

示例2: main

import org.hl7.fhir.dstu3.model.OperationOutcome; //导入依赖的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

示例3: main

import org.hl7.fhir.dstu3.model.OperationOutcome; //导入依赖的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

示例4: loadCache

import org.hl7.fhir.dstu3.model.OperationOutcome; //导入依赖的package包/类
private void loadCache() throws FHIRFormatError, IOException {
 File[] files = new File(cacheFolder).listFiles();
  for (File f : files) {
    if (f.getName().endsWith(".xml")) {
      final FileInputStream is = new FileInputStream(f);
      try {	   
      Resource r = context.newXmlParser().setOutputStyle(OutputStyle.PRETTY).parse(is);
      if (r instanceof OperationOutcome) {
        OperationOutcome oo = (OperationOutcome) r;
        expansions.put(ToolingExtensions.getExtension(oo,VS_ID_EXT).getValue().toString(),
          new ValueSetExpansionOutcome(new XhtmlComposer(XhtmlComposer.XML).composePlainText(oo.getText().getDiv()), TerminologyServiceErrorClass.UNKNOWN));
      } else {
        ValueSet vs = (ValueSet) r; 
        expansions.put(vs.getUrl(), new ValueSetExpansionOutcome(vs));
      }
      } finally {
        IOUtils.closeQuietly(is);
      }
    }
  }
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:22,代码来源:ValueSetExpansionCache.java

示例5: testAddHeadersNotFound

import org.hl7.fhir.dstu3.model.OperationOutcome; //导入依赖的package包/类
@Test
public void testAddHeadersNotFound() throws Exception {
	
	OperationOutcome operationOutcome = new OperationOutcome();
	operationOutcome.addIssue().setCode(IssueType.BUSINESSRULE);
	
	ourException = new ResourceNotFoundException("SOME MESSAGE");
	ourException.addResponseHeader("X-Foo", "BAR BAR");
	

	HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient");
	CloseableHttpResponse status = ourClient.execute(httpGet);
	try {
		String responseContent = IOUtils.toString(status.getEntity().getContent(), StandardCharsets.UTF_8);
		ourLog.info(status.getStatusLine().toString());
		ourLog.info(responseContent);
		
		assertEquals(404, status.getStatusLine().getStatusCode());
		assertEquals("BAR BAR", status.getFirstHeader("X-Foo").getValue());
		assertThat(status.getFirstHeader("X-Powered-By").getValue(), containsString("HAPI FHIR"));
	} finally {
		IOUtils.closeQuietly(status.getEntity().getContent());
	}

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

示例6: testAuthorize

import org.hl7.fhir.dstu3.model.OperationOutcome; //导入依赖的package包/类
@Test
public void testAuthorize() throws Exception {
	
	OperationOutcome operationOutcome = new OperationOutcome();
	operationOutcome.addIssue().setCode(IssueType.BUSINESSRULE);
	
	ourException = new AuthenticationException().addAuthenticateHeaderForRealm("REALM");
	
	HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient");
	CloseableHttpResponse status = ourClient.execute(httpGet);
	try {
		String responseContent = IOUtils.toString(status.getEntity().getContent(), StandardCharsets.UTF_8);
		ourLog.info(status.getStatusLine().toString());
		ourLog.info(responseContent);
		
		assertEquals(401, status.getStatusLine().getStatusCode());
		assertEquals("Basic realm=\"REALM\"", status.getFirstHeader("WWW-Authenticate").getValue());
	} finally {
		IOUtils.closeQuietly(status.getEntity().getContent());
	}

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

示例7: testCreateReturnsOperationOutcome

import org.hl7.fhir.dstu3.model.OperationOutcome; //导入依赖的package包/类
@Test
public void testCreateReturnsOperationOutcome() throws Exception {
	ourReturnOo = new OperationOutcome().addIssue(new OperationOutcomeIssueComponent().setDiagnostics("DIAG"));
	
	HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient");
	httpPost.setEntity(new StringEntity("{\"resourceType\":\"Patient\", \"status\":\"active\"}", ContentType.parse("application/fhir+json; charset=utf-8")));
	HttpResponse status = ourClient.execute(httpPost);

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

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

	assertEquals(201, status.getStatusLine().getStatusCode());

	assertThat(responseContent, containsString("DIAG"));
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:18,代码来源:CreateDstu3Test.java

示例8: testSearch

import org.hl7.fhir.dstu3.model.OperationOutcome; //导入依赖的package包/类
@Test
public void testSearch() throws Exception {
	
	OperationOutcome operationOutcome = new OperationOutcome();
	operationOutcome.addIssue().setCode(IssueType.BUSINESSRULE);
	ourException = new UnclassifiedServerFailureException(477, "SOME MESSAGE", operationOutcome);

	HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient");
	CloseableHttpResponse status = ourClient.execute(httpGet);
	try {
		String responseContent = IOUtils.toString(status.getEntity().getContent(), StandardCharsets.UTF_8);
		ourLog.info(status.getStatusLine().toString());
		ourLog.info(responseContent);
		assertEquals(477, status.getStatusLine().getStatusCode());
		//assertEquals("SOME MESSAGE", status.getStatusLine().getReasonPhrase());
		assertThat(responseContent, stringContainsInOrder("business-rule"));
	} finally {
		IOUtils.closeQuietly(status.getEntity().getContent());
	}

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

示例9: update

import org.hl7.fhir.dstu3.model.OperationOutcome; //导入依赖的package包/类
@Update
public MethodOutcome update(HttpServletRequest theRequest, @ResourceParam DocumentReference documentReference, @IdParam IdType theId, @ConditionalUrlParam String theConditional, RequestDetails theRequestDetails) {

    MethodOutcome method = new MethodOutcome();
    method.setCreated(true);
    OperationOutcome opOutcome = new OperationOutcome();
    method.setOperationOutcome(opOutcome);

    DocumentReference newDocumentReference = documentReferenceDao.create(ctx,documentReference, theId, theConditional);
    method.setId(newDocumentReference.getIdElement());
    method.setResource(newDocumentReference);

    return method;
}
 
开发者ID:nhsconnect,项目名称:careconnect-reference-implementation,代码行数:15,代码来源:DocumentReferenceProvider.java

示例10: create

import org.hl7.fhir.dstu3.model.OperationOutcome; //导入依赖的package包/类
@Create
public MethodOutcome create(HttpServletRequest theRequest, @ResourceParam DocumentReference documentReference) {

    MethodOutcome method = new MethodOutcome();
    method.setCreated(true);
    OperationOutcome opOutcome = new OperationOutcome();
    method.setOperationOutcome(opOutcome);

    DocumentReference newDocumentReference = documentReferenceDao.create(ctx,documentReference, null,null);
    method.setId(newDocumentReference.getIdElement());
    method.setResource(newDocumentReference);

    return method;
}
 
开发者ID:nhsconnect,项目名称:careconnect-reference-implementation,代码行数:15,代码来源:DocumentReferenceProvider.java

示例11: get

import org.hl7.fhir.dstu3.model.OperationOutcome; //导入依赖的package包/类
@Read()
public DocumentReference get(@IdParam IdType documentReferenceId) {

    DocumentReference documentReference = documentReferenceDao.read(ctx,documentReferenceId);

    if ( documentReference == null) {
        throw OperationOutcomeFactory.buildOperationOutcomeException(
                new ResourceNotFoundException("No DocumentReference/ " + documentReferenceId.getIdPart()),
                OperationOutcome.IssueSeverity.ERROR, OperationOutcome.IssueType.NOTFOUND);
    }

    return documentReference;
}
 
开发者ID:nhsconnect,项目名称:careconnect-reference-implementation,代码行数:14,代码来源:DocumentReferenceProvider.java

示例12: if

import org.hl7.fhir.dstu3.model.OperationOutcome; //导入依赖的package包/类
@Read
public PractitionerRole getPractitionerRole
        (@IdParam IdType internalId) {
    PractitionerRole practitionerRole = practitionerRoleDao.read(ctx, internalId);

    if ( practitionerRole == null) {
        throw OperationOutcomeFactory.buildOperationOutcomeException(
                new ResourceNotFoundException("No PractitionerRole/" + internalId.getIdPart()),
                OperationOutcome.IssueSeverity.ERROR, OperationOutcome.IssueType.NOTFOUND);
    }

    return practitionerRole;
}
 
开发者ID:nhsconnect,项目名称:careconnect-reference-implementation,代码行数:14,代码来源:PractitionerRoleProvider.java

示例13: update

import org.hl7.fhir.dstu3.model.OperationOutcome; //导入依赖的package包/类
@Update
public MethodOutcome update(HttpServletRequest theRequest, @ResourceParam Composition composition, @IdParam IdType theId, @ConditionalUrlParam String theConditional, RequestDetails theRequestDetails) {

    MethodOutcome method = new MethodOutcome();
    method.setCreated(true);
    OperationOutcome opOutcome = new OperationOutcome();
    method.setOperationOutcome(opOutcome);

    Composition newComposition = compositionDao.create(ctx,composition, theId, theConditional);
    method.setId(newComposition.getIdElement());
    method.setResource(newComposition);

    return method;
}
 
开发者ID:nhsconnect,项目名称:careconnect-reference-implementation,代码行数:15,代码来源:CompositionProvider.java

示例14: create

import org.hl7.fhir.dstu3.model.OperationOutcome; //导入依赖的package包/类
@Create
public MethodOutcome create(HttpServletRequest theRequest, @ResourceParam Composition composition) {

    MethodOutcome method = new MethodOutcome();
    method.setCreated(true);
    OperationOutcome opOutcome = new OperationOutcome();
    method.setOperationOutcome(opOutcome);

    Composition newComposition = compositionDao.create(ctx,composition, null,null);
    method.setId(newComposition.getIdElement());
    method.setResource(newComposition);

    return method;
}
 
开发者ID:nhsconnect,项目名称:careconnect-reference-implementation,代码行数:15,代码来源:CompositionProvider.java

示例15: get

import org.hl7.fhir.dstu3.model.OperationOutcome; //导入依赖的package包/类
@Read()
public Composition get(@IdParam IdType compositionId) {

    Composition composition = compositionDao.read(ctx,compositionId);

    if ( composition == null) {
        throw OperationOutcomeFactory.buildOperationOutcomeException(
                new ResourceNotFoundException("No Composition/ " + compositionId.getIdPart()),
                OperationOutcome.IssueSeverity.ERROR, OperationOutcome.IssueType.NOTFOUND);
    }

    return composition;
}
 
开发者ID:nhsconnect,项目名称:careconnect-reference-implementation,代码行数:14,代码来源:CompositionProvider.java


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