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

Java IGenericClient类代码示例

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

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



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

示例1: main

import ca.uhn.fhir.rest.client.api.IGenericClient; //导入依赖的package包/类
public static void main(String[] theArgs) {
   FhirContext ctx = FhirContext.forDstu3();
   IGenericClient client = ctx.newRestfulGenericClient("http://fhirtest.uhn.ca/baseDstu3");

   // Build a search and execute it
   Bundle response = client.search()
      .forResource(Patient.class)
      .where(Patient.NAME.matches().value("Test"))
      .and(Patient.BIRTHDATE.before().day("2014-01-01"))
      .count(100)
      .returnBundle(Bundle.class)
      .execute();

   // How many resources did we find?
   System.out.println("Responses: " + response.getTotal());

   // Print the ID of the first one
   System.out.println("First response ID: " + response.getEntry().get(0).getResource().getId());
}
 
开发者ID:furore-fhir,项目名称:fhirstarters,代码行数:20,代码来源:Example08_ClientSearch.java


示例2: fetchResource

import ca.uhn.fhir.rest.client.api.IGenericClient; //导入依赖的package包/类
@Override
public <T extends IBaseResource> T fetchResource(FhirContext theContext, Class<T> theClass, String theUri) {
	String resName = myCtx.getResourceDefinition(theClass).getName();
	ourLog.info("Attempting to fetch {} at URL: {}", resName, theUri);
	
	myCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER);
	IGenericClient client = myCtx.newRestfulGenericClient("http://example.com");
	
	T result;
	try {
		result = client.read(theClass, theUri);
	} catch (BaseServerResponseException e) {
		throw new CommandFailureException("FAILURE: "+theUri+" Received HTTP " + e.getStatusCode() + ": " + e.getMessage());
	}
	ourLog.info("Successfully loaded resource");
	return result;
}
 
开发者ID:nhsconnect,项目名称:careconnect-reference-implementation,代码行数:18,代码来源:LoadingValidationSupportDstu3.java


示例3: step1_read_a_resource

import ca.uhn.fhir.rest.client.api.IGenericClient; //导入依赖的package包/类
public static void step1_read_a_resource() {

		FhirContext ctx = FhirContext.forDstu3();
		IGenericClient client = ctx.newRestfulGenericClient("http://fhirtest.uhn.ca/baseDstu3");

		Patient patient;
		try {
			// Try changing the ID from 952975 to 999999999999
			patient = client.read().resource(Patient.class).withId("952975").execute();
		} catch (ResourceNotFoundException e) {
			System.out.println("Resource not found!");
			return;
		}

		String string = ctx.newXmlParser().setPrettyPrint(true).encodeResourceToString(patient);
		System.out.println(string);

	}
 
开发者ID:furore-fhir,项目名称:fhirstarters,代码行数:19,代码来源:TestApplicationHints.java


示例4: step2_search_for_patients_named_test

import ca.uhn.fhir.rest.client.api.IGenericClient; //导入依赖的package包/类
public static void step2_search_for_patients_named_test() {
	FhirContext ctx = FhirContext.forDstu3();
	IGenericClient client = ctx.newRestfulGenericClient("http://fhirtest.uhn.ca/baseDstu3");

	org.hl7.fhir.dstu3.model.Bundle results = client
		.search()
		.forResource(Patient.class)
		.where(Patient.NAME.matches().value("test"))
		.returnBundle(org.hl7.fhir.dstu3.model.Bundle.class)
		.execute();

	System.out.println("First page: ");
	System.out.println(ctx.newXmlParser().encodeResourceToString(results));

	// Load the next page
	org.hl7.fhir.dstu3.model.Bundle nextPage = client
		.loadPage()
		.next(results)
		.execute();

	System.out.println("Next page: ");
	System.out.println(ctx.newXmlParser().encodeResourceToString(nextPage));

}
 
开发者ID:furore-fhir,项目名称:fhirstarters,代码行数:25,代码来源:TestApplicationHints.java


示例5: main

import ca.uhn.fhir.rest.client.api.IGenericClient; //导入依赖的package包/类
public static void main(String[] theArgs) {

      Patient pat = new Patient();
      pat.addName().setFamily("Simpson").addGiven("Homer").addGiven("J");
      pat.addIdentifier().setSystem("http://acme.org/MRNs").setValue("7000135");
      pat.setGender(AdministrativeGender.MALE);

      // Create a context
      FhirContext ctx = FhirContext.forDstu3();

      // Create a client
      String serverBaseUrl = "http://fhirtest.uhn.ca/baseDstu3";
      IGenericClient client = ctx.newRestfulGenericClient(serverBaseUrl);

      // Use the client to store a new resource instance
      MethodOutcome outcome = client
         .create()
         .resource(pat)
         .execute();

      // Print the ID of the newly created resource
      System.out.println(outcome.getId());
   }
 
开发者ID:furore-fhir,项目名称:fhirstarters,代码行数:24,代码来源:Example06_ClientCreate.java


示例6: main

import ca.uhn.fhir.rest.client.api.IGenericClient; //导入依赖的package包/类
public static void main(String[] theArgs) {

		// Create a client
      IGenericClient client = FhirContext.forDstu3().newRestfulGenericClient("http://fhirtest.uhn.ca/baseDstu3");

      // Register some interceptors
      client.registerInterceptor(new CookieInterceptor("mycookie=Chips Ahoy"));
      client.registerInterceptor(new LoggingInterceptor());

      // Read a Patient
      Patient patient = client.read().resource(Patient.class).withId("example").execute();

		// Change the gender
		patient.setGender(patient.getGender() == AdministrativeGender.MALE ? AdministrativeGender.FEMALE : AdministrativeGender.MALE);

		// Update the patient
		MethodOutcome outcome = client.update().resource(patient).execute();
		
		System.out.println("Now have ID: " + outcome.getId());
	}
 
开发者ID:furore-fhir,项目名称:fhirstarters,代码行数:21,代码来源:Example09_Interceptors.java


示例7: testContextDoesntScanUnneccesaryTypes

import ca.uhn.fhir.rest.client.api.IGenericClient; //导入依赖的package包/类
@Test
public void testContextDoesntScanUnneccesaryTypes() {
	FhirContext ctx = FhirContext.forDstu3();
	
	TreeSet<String> resDefs = scannedResourceNames(ctx);
	TreeSet<String> elementDefs = scannedElementNames(ctx);
	ourLog.info("Have {} resource definitions: {}", ctx.getAllResourceDefinitions().size(), resDefs);
	ourLog.info("Have {} element definitions: {}", ctx.getElementDefinitions().size(), elementDefs);
	assertThat(resDefs, not(containsInRelativeOrder("Observation")));
	
	IGenericClient client = ctx.newRestfulGenericClient("http://localhost:" + ourPort);
	client.read().resource(Patient.class).withId("1").execute();
	
	resDefs = scannedResourceNames(ctx);
	elementDefs = scannedElementNames(ctx);
	ourLog.info("Have {} resource definitions: {}", ctx.getAllResourceDefinitions().size(), resDefs);
	ourLog.info("Have {} element definitions: {}", ctx.getElementDefinitions().size(), elementDefs);		
	assertThat(resDefs, not(containsInRelativeOrder("Observation")));

	client.read().resource(Observation.class).withId("1").execute();
	resDefs = scannedResourceNames(ctx);
	elementDefs = scannedElementNames(ctx);
	ourLog.info("Have {} resource definitions: {}", ctx.getAllResourceDefinitions().size(), resDefs);
	ourLog.info("Have {} element definitions: {}", ctx.getElementDefinitions().size(), elementDefs);		
	assertThat(resDefs, containsInRelativeOrder("Observation"));
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:27,代码来源:ContextScanningDstu3Test.java


示例8: testMimetypeJsonLegacy

import ca.uhn.fhir.rest.client.api.IGenericClient; //导入依赖的package包/类
@Test
public void testMimetypeJsonLegacy() throws Exception {
	String requestCt = Constants.CT_FHIR_JSON;

	ArgumentCaptor<HttpUriRequest> capt = prepareMimetypePostTest(requestCt, false);

	IGenericClient client = ourCtx.newRestfulGenericClient("http://example.com/fhir");

	Patient pt = new Patient();
	pt.getText().setDivAsString("A PATIENT");

	MethodOutcome outcome = client.create().resource(pt).encodedJson().execute();

	assertEquals("<div xmlns=\"http://www.w3.org/1999/xhtml\">FINAL VALUE</div>", ((Patient) outcome.getResource()).getText().getDivAsString());
	assertEquals("http://example.com/fhir/Patient", capt.getAllValues().get(0).getURI().toASCIIString());
	assertEquals(Constants.CT_FHIR_JSON_NEW, capt.getAllValues().get(0).getFirstHeader("content-type").getValue().replaceAll(";.*", ""));
	assertEquals(Constants.HEADER_ACCEPT_VALUE_JSON_NON_LEGACY, capt.getAllValues().get(0).getFirstHeader("accept").getValue());
	assertEquals("{\"resourceType\":\"Patient\",\"text\":{\"div\":\"<div xmlns=\\\"http://www.w3.org/1999/xhtml\\\">A PATIENT</div>\"}}", extractBodyAsString(capt));
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:20,代码来源:ClientMimetypeR4Test.java


示例9: createSubscription

import ca.uhn.fhir.rest.client.api.IGenericClient; //导入依赖的package包/类
public static Subscription createSubscription(String criteria, String payload, String endpoint, IGenericClient client) {
    Subscription subscription = new Subscription();
    subscription.setReason("Monitor new neonatal function (note, age will be determined by the monitor)");
    subscription.setStatus(Subscription.SubscriptionStatus.REQUESTED);
    subscription.setCriteria(criteria);

    Subscription.SubscriptionChannelComponent channel = new Subscription.SubscriptionChannelComponent();
    channel.setType(Subscription.SubscriptionChannelType.RESTHOOK);
    channel.setPayload(payload);
    channel.setEndpoint(endpoint);
    subscription.setChannel(channel);

    MethodOutcome methodOutcome = client.create().resource(subscription).execute();
    subscription.setId(methodOutcome.getId().getIdPart());

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


示例10: testSearchWithNonFhirResponse

import ca.uhn.fhir.rest.client.api.IGenericClient; //导入依赖的package包/类
@SuppressWarnings("unused")
@Test
public void testSearchWithNonFhirResponse() throws Exception {

  String msg = getPatientFeedWithOneResult();

  ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
  when(myHttpClient.execute(capt.capture())).thenReturn(myHttpResponse);
  when(myHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK"));
  when(myHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_TEXT + "; charset=UTF-8"));
  when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader("Server Issues!"), Charset.forName("UTF-8")));

  IGenericClient client = ourCtx.newRestfulGenericClient("http://example.com/fhir");

  try {
    client.search().forResource(Patient.class).returnBundle(Bundle.class).execute();
    fail();
  } catch (NonFhirResponseException e) {
    assertThat(e.getMessage(), StringContains.containsString("Server Issues!"));
  }

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


示例11: testSearchByReferenceProperty

import ca.uhn.fhir.rest.client.api.IGenericClient; //导入依赖的package包/类
@SuppressWarnings("unused")
@Test
public void testSearchByReferenceProperty() throws Exception {

  String msg = getPatientFeedWithOneResult();

  ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
  when(myHttpClient.execute(capt.capture())).thenReturn(myHttpResponse);
  when(myHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK"));
  when(myHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
  when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));

  IGenericClient client = ourCtx.newRestfulGenericClient("http://example.com/fhir");

  Bundle response = client.search()
      .forResource(Patient.class)
      .where(Patient.GENERAL_PRACTITIONER.hasChainedProperty(Organization.NAME.matches().value("ORG0")))
      .returnBundle(Bundle.class)
      .execute();

  assertEquals("http://example.com/fhir/Patient?general-practitioner.name=ORG0", capt.getValue().getURI().toString());

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


示例12: testExplicitCustomTypeSearch

import ca.uhn.fhir.rest.client.api.IGenericClient; //导入依赖的package包/类
@Test
public void testExplicitCustomTypeSearch() throws Exception {
  final String respString = CustomTypeR4Test.createBundle(CustomTypeR4Test.createResource(false));
  ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
  when(myHttpClient.execute(capt.capture())).thenReturn(myHttpResponse);
  when(myHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK"));
  when(myHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
  when(myHttpResponse.getEntity().getContent()).thenAnswer(new Answer<ReaderInputStream>() {
    @Override
    public ReaderInputStream answer(InvocationOnMock theInvocation) throws Throwable {
      return new ReaderInputStream(new StringReader(respString), Charset.forName("UTF-8"));
    }
  });

  IGenericClient client = ourCtx.newRestfulGenericClient("http://example.com/fhir");

  Bundle resp = client
      .search()
      .forResource(CustomTypeR4Test.MyCustomPatient.class)
      .returnBundle(Bundle.class)
      .execute();

  assertEquals(1, resp.getEntry().size());
  assertEquals(CustomTypeR4Test.MyCustomPatient.class, resp.getEntry().get(0).getResource().getClass());
  assertEquals("http://example.com/fhir/Patient", capt.getAllValues().get(0).getURI().toASCIIString());
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:27,代码来源:GenericClientR4Test.java


示例13: testExplicitCustomTypeHistoryType

import ca.uhn.fhir.rest.client.api.IGenericClient; //导入依赖的package包/类
@Test
public void testExplicitCustomTypeHistoryType() throws Exception {
	final String respString = CustomTypeDstu3Test.createBundle(CustomTypeDstu3Test.createResource(false));
	ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
	when(myHttpClient.execute(capt.capture())).thenReturn(myHttpResponse);
	when(myHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK"));
	when(myHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
	when(myHttpResponse.getEntity().getContent()).thenAnswer(new Answer<ReaderInputStream>() {
		@Override
		public ReaderInputStream answer(InvocationOnMock theInvocation) throws Throwable {
			return new ReaderInputStream(new StringReader(respString), Charset.forName("UTF-8"));
		}
	});

	IGenericClient client = ourCtx.newRestfulGenericClient("http://example.com/fhir");

	Bundle resp = client
			.history()
			.onType(CustomTypeDstu3Test.MyCustomPatient.class)
			.andReturnBundle(Bundle.class)
			.execute();

	assertEquals(1, resp.getEntry().size());
	assertEquals(CustomTypeDstu3Test.MyCustomPatient.class, resp.getEntry().get(0).getResource().getClass());
	assertEquals("http://example.com/fhir/Patient/_history", capt.getAllValues().get(0).getURI().toASCIIString());
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:27,代码来源:GenericClientDstu3Test.java


示例14: testSearchWithMultipleTokens

import ca.uhn.fhir.rest.client.api.IGenericClient; //导入依赖的package包/类
@Test
public void testSearchWithMultipleTokens() throws Exception {
	ArgumentCaptor<HttpUriRequest> capt = prepareClientForSearchResponse();

	IGenericClient client = ourCtx.newRestfulGenericClient("http://example.com/fhir");
	int idx = 0;

	Collection<String> values = Arrays.asList("VAL1", "VAL2", "VAL3A,B");

	client.search()
			.forResource("Patient")
			.where(Patient.IDENTIFIER.exactly().systemAndValues("SYS", values))
			.returnBundle(Bundle.class)
			.execute();

	assertEquals("http://example.com/fhir/Patient?identifier=SYS%7CVAL1%2CSYS%7CVAL2%2CSYS%7CVAL3A%5C%2CB", capt.getAllValues().get(idx).getURI().toString());
	assertEquals("http://example.com/fhir/Patient?identifier=SYS|VAL1,SYS|VAL2,SYS|VAL3A\\,B", UrlUtil.unescape(capt.getAllValues().get(idx).getURI().toString()));
	idx++;

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


示例15: testExplicitCustomTypeSearch

import ca.uhn.fhir.rest.client.api.IGenericClient; //导入依赖的package包/类
@Test
public void testExplicitCustomTypeSearch() throws Exception {
	final String respString = CustomTypeDstu3Test.createBundle(CustomTypeDstu3Test.createResource(false));
	ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
	when(myHttpClient.execute(capt.capture())).thenReturn(myHttpResponse);
	when(myHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK"));
	when(myHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
	when(myHttpResponse.getEntity().getContent()).thenAnswer(new Answer<ReaderInputStream>() {
		@Override
		public ReaderInputStream answer(InvocationOnMock theInvocation) throws Throwable {
			return new ReaderInputStream(new StringReader(respString), Charset.forName("UTF-8"));
		}
	});

	IGenericClient client = ourCtx.newRestfulGenericClient("http://example.com/fhir");

	Bundle resp = client
			.search()
			.forResource(CustomTypeDstu3Test.MyCustomPatient.class)
			.returnBundle(Bundle.class)
			.execute();

	assertEquals(1, resp.getEntry().size());
	assertEquals(CustomTypeDstu3Test.MyCustomPatient.class, resp.getEntry().get(0).getResource().getClass());
	assertEquals("http://example.com/fhir/Patient", capt.getAllValues().get(0).getURI().toASCIIString());
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:27,代码来源:GenericClientDstu3Test.java


示例16: testHttp501

import ca.uhn.fhir.rest.client.api.IGenericClient; //导入依赖的package包/类
@Test
public void testHttp501() throws Exception {
	ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
	when(myHttpClient.execute(capt.capture())).thenReturn(myHttpResponse);
	when(myHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 501, "Not Implemented"));
	when(myHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
	when(myHttpResponse.getEntity().getContent()).thenAnswer(new Answer<InputStream>() {
		@Override
		public StringInputStream answer(InvocationOnMock theInvocation) throws Throwable {
			return new StringInputStream("not implemented", Charsets.UTF_8);
		}
	});

	IGenericClient client = ourCtx.newRestfulGenericClient("http://example.com/fhir");

	try {
		client.read().resource(Patient.class).withId("1").execute();
		fail();
	} catch (NotImplementedOperationException e) {
		assertEquals("HTTP 501 Not Implemented", e.getMessage());
	}

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


示例17: testReadWithUnparseableResponse

import ca.uhn.fhir.rest.client.api.IGenericClient; //导入依赖的package包/类
@Test
public void testReadWithUnparseableResponse() throws Exception {
	String msg = "{\"resourceTypeeeee\":\"Patient\"}";

	ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
	when(myHttpClient.execute(capt.capture())).thenReturn(myHttpResponse);
	when(myHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK"));
	when(myHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_JSON + "; charset=UTF-8"));
	when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));

	IGenericClient client = ourCtx.newRestfulGenericClient("http://example.com/fhir");

	try {
		client.read().resource("Patient").withId("123").elementsSubset("name", "identifier").execute();
		fail();
	} catch (FhirClientConnectionException e) {
		assertEquals(
				"Failed to parse response from server when performing GET to URL http://example.com/fhir/Patient/123?_elements=identifier%2Cname - ca.uhn.fhir.parser.DataFormatException: Invalid JSON content detected, missing required element: 'resourceType'",
				e.getMessage());
	}
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:22,代码来源:GenericClientDstu3Test.java


示例18: testSearchByStringExact

import ca.uhn.fhir.rest.client.api.IGenericClient; //导入依赖的package包/类
@SuppressWarnings("unused")
@Test
public void testSearchByStringExact() throws Exception {

  String msg = getPatientFeedWithOneResult();

  ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
  when(myHttpClient.execute(capt.capture())).thenReturn(myHttpResponse);
  when(myHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK"));
  when(myHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
  when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));

  IGenericClient client = ourCtx.newRestfulGenericClient("http://example.com/fhir");

  Bundle response = client.search()
      .forResource("Patient")
      .where(Patient.NAME.matchesExactly().value("james"))
      .returnBundle(Bundle.class)
      .execute();

  assertEquals("http://example.com/fhir/Patient?name%3Aexact=james", capt.getValue().getURI().toString());

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


示例19: testLoadPageAndReturnDstu1Bundle

import ca.uhn.fhir.rest.client.api.IGenericClient; //导入依赖的package包/类
@Test
public void testLoadPageAndReturnDstu1Bundle() throws Exception {

  String msg = getPatientFeedWithOneResult();

  ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);

  when(myHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK"));
  when(myHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
  when(myHttpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));

  when(myHttpClient.execute(capt.capture())).thenReturn(myHttpResponse);

  IGenericClient client = ourCtx.newRestfulGenericClient("http://foo");
  client
      .loadPage()
      .byUrl("http://example.com/page1")
      .andReturnBundle(Bundle.class)
      .execute();

  assertEquals("http://example.com/page1", capt.getValue().getURI().toString());
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:23,代码来源:GenericClientTest.java


示例20: testSearchWithMultipleTokens

import ca.uhn.fhir.rest.client.api.IGenericClient; //导入依赖的package包/类
@Test
public void testSearchWithMultipleTokens() throws Exception {
  ArgumentCaptor<HttpUriRequest> capt = prepareClientForSearchResponse();

  IGenericClient client = ourCtx.newRestfulGenericClient("http://example.com/fhir");
  int idx = 0;

  Collection<String> values = Arrays.asList("VAL1", "VAL2", "VAL3A,B");

  client.search()
      .forResource("Patient")
      .where(Patient.IDENTIFIER.exactly().systemAndValues("SYS", values))
      .returnBundle(Bundle.class)
      .execute();

  assertEquals("http://example.com/fhir/Patient?identifier=SYS%7CVAL1%2CSYS%7CVAL2%2CSYS%7CVAL3A%5C%2CB", capt.getAllValues().get(idx).getURI().toString());
  assertEquals("http://example.com/fhir/Patient?identifier=SYS|VAL1,SYS|VAL2,SYS|VAL3A\\,B", UrlUtil.unescape(capt.getAllValues().get(idx).getURI().toString()));
  idx++;

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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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