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


Java Bundle类代码示例

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


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

示例1: main

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

import org.hl7.fhir.dstu3.model.Bundle; //导入依赖的package包/类
/**
 * Extracts the given resource type from the RDD of bundles and returns
 * it as a Dataset of that type.
 *
 * @param spark the spark session
 * @param bundles an RDD of FHIR Bundles
 * @param resourceName the FHIR name of the resource type to extract
 *     (e.g., condition, patient. etc).
 * @param encoders the Encoders instance defining how the resources are encoded.
 * @param <T> the type of the resource being extracted from the bundles.
 * @return a dataset of the given resource
 */
public static <T extends IBaseResource> Dataset<T> extractEntry(SparkSession spark,
    JavaRDD<Bundle> bundles,
    String resourceName,
    FhirEncoders encoders) {

  RuntimeResourceDefinition def = context.getResourceDefinition(resourceName);

  JavaRDD<T> resourceRdd = bundles.flatMap(new ToResource<T>(def.getName()));

  Encoder<T> encoder = encoders.of((Class<T>) def.getImplementingClass());

  return spark.createDataset(resourceRdd.rdd(), encoder);
}
 
开发者ID:cerner,项目名称:bunsen,代码行数:26,代码来源:Bundles.java

示例3: testGetAllPopulatedChildElementsOfTypeDoesntDescendIntoEmbedded

import org.hl7.fhir.dstu3.model.Bundle; //导入依赖的package包/类
@Test
public void testGetAllPopulatedChildElementsOfTypeDoesntDescendIntoEmbedded() {
	Patient p = new Patient();
	p.addName().setFamily("PATIENT");

	Bundle b = new Bundle();
	b.addEntry().setResource(p);
	b.addLink().setRelation("BUNDLE");

	FhirTerser t = ourCtx.newTerser();
	List<StringType> strings = t.getAllPopulatedChildElementsOfType(b, StringType.class);

	assertEquals(1, strings.size());
	assertThat(toStrings(strings), containsInAnyOrder("BUNDLE"));

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

示例4: testTransaction

import org.hl7.fhir.dstu3.model.Bundle; //导入依赖的package包/类
@Test
public void testTransaction() {
	Bundle bundle = new Bundle();
	
	Patient patient = new Patient();
	patient.setId("Patient/unit_test_patient");
	patient.addName().setFamily("SMITH");
	
	bundle.addEntry().setResource(patient);
	
	IGenericClient client = ctx.newRestfulGenericClient("http://127.0.0.1:1/fhir"); // won't connect
	ITransactionTyped<Bundle> transaction = client.transaction().withBundle(bundle);
	try {
		Bundle result = transaction.encodedJson().execute();
		fail();
	} catch (FhirClientConnectionException e) {
		// good
	}
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:20,代码来源:ClientTest.java

示例5: processMessage

import org.hl7.fhir.dstu3.model.Bundle; //导入依赖的package包/类
@SuppressWarnings("unused")
public void processMessage() {
   // START SNIPPET: processMessage
   FhirContext ctx = FhirContext.forDstu3();

   // Create the client
   IGenericClient client = ctx.newRestfulGenericClient("http://localhost:9999/fhir");
   
   Bundle bundle = new Bundle();
   // ..populate the bundle..
   
   Bundle response = client
         .operation()
         .processMessage() // New operation for sending messages
         .setMessageBundle(bundle)
         .asynchronous(Bundle.class)
         .execute();
   // END SNIPPET: processMessage
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:20,代码来源:ClientExamples.java

示例6: cacheControl

import org.hl7.fhir.dstu3.model.Bundle; //导入依赖的package包/类
@SuppressWarnings("unused")
public void cacheControl() {
	FhirContext ctx = FhirContext.forDstu3();

	// Create the client
	IGenericClient client = ctx.newRestfulGenericClient("http://localhost:9999/fhir");

	Bundle bundle = new Bundle();
	// ..populate the bundle..

	// START SNIPPET: cacheControl
	Bundle response = client
		.search()
		.forResource(Patient.class)
		.returnBundle(Bundle.class)
		.cacheControl(new CacheControlDirective().setNoCache(true)) // <-- add a directive
		.execute();
	// END SNIPPET: cacheControl
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:20,代码来源:ClientExamples.java

示例7: testBundlePreservesFullUrl

import org.hl7.fhir.dstu3.model.Bundle; //导入依赖的package包/类
/**
 * See #401
 */
@Test
public void testBundlePreservesFullUrl() throws Exception {
	
	Bundle bundle = new Bundle();
	bundle.setType(BundleType.DOCUMENT);
	
	Composition composition = new Composition();
	composition.setTitle("Visit Summary");
	bundle.addEntry().setFullUrl("http://foo").setResource(composition);
	
	IIdType id = ourClient.create().resource(bundle).execute().getId();
	
	Bundle retBundle = ourClient.read().resource(Bundle.class).withId(id).execute();
	ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(retBundle));
	
	assertEquals("http://foo", bundle.getEntry().get(0).getFullUrl());
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:21,代码来源:ResourceProviderDstu3BundleTest.java

示例8: testBatchWithGetHardLimitLargeSynchronous

import org.hl7.fhir.dstu3.model.Bundle; //导入依赖的package包/类
@Test
public void testBatchWithGetHardLimitLargeSynchronous() {
	List<String> ids = create20Patients();
	
	Bundle input = new Bundle();
	input.setType(BundleType.BATCH);
	input
		.addEntry()
		.getRequest()
		.setMethod(HTTPVerb.GET)
		.setUrl("Patient?_count=5&_sort=_id");
	
	myDaoConfig.setMaximumSearchResultCountInTransaction(100);
	
	Bundle output = ourClient.transaction().withBundle(input).execute();
	ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(output));
	
	assertEquals(1, output.getEntry().size());
	Bundle respBundle = (Bundle) output.getEntry().get(0).getResource();
	assertEquals(5, respBundle.getEntry().size());
	assertEquals(null, respBundle.getLink("next"));
	List<String> actualIds = toIds(respBundle);
	assertThat(actualIds, contains(ids.subList(0, 5).toArray(new String[0])));
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:25,代码来源:SystemProviderTransactionSearchDstu3Test.java

示例9: testTransactionWithGetHardLimitLargeSynchronous

import org.hl7.fhir.dstu3.model.Bundle; //导入依赖的package包/类
@Test
public void testTransactionWithGetHardLimitLargeSynchronous() {
	List<String> ids = create20Patients();
	
	Bundle input = new Bundle();
	input.setType(BundleType.TRANSACTION);
	input
		.addEntry()
		.getRequest()
		.setMethod(HTTPVerb.GET)
		.setUrl("Patient?_count=5&_sort=_id");
	
	myDaoConfig.setMaximumSearchResultCountInTransaction(100);
	
	Bundle output = ourClient.transaction().withBundle(input).execute();
	ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(output));
	
	assertEquals(1, output.getEntry().size());
	Bundle respBundle = (Bundle) output.getEntry().get(0).getResource();
	assertEquals(5, respBundle.getEntry().size());
	assertEquals(null, respBundle.getLink("next"));
	List<String> actualIds = toIds(respBundle);
	assertThat(actualIds, contains(ids.subList(0, 5).toArray(new String[0])));
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:25,代码来源:SystemProviderTransactionSearchDstu3Test.java

示例10: medicationClaim

import org.hl7.fhir.dstu3.model.Bundle; //导入依赖的package包/类
/**
 * Create an entry for the given Claim, which references a Medication.
 * 
 * @param personEntry
 *          Entry for the person
 * @param bundle
 *          The Bundle to add to
 * @param encounterEntry
 *          The current Encounter
 * @param claim
 *          the Claim object
 * @param medicationEntry
 *          The Entry for the Medication object, previously created
 * @return the added Entry
 */
private static BundleEntryComponent medicationClaim(BundleEntryComponent personEntry,
    Bundle bundle, BundleEntryComponent encounterEntry, Claim claim,
    BundleEntryComponent medicationEntry) {
  org.hl7.fhir.dstu3.model.Claim claimResource = new org.hl7.fhir.dstu3.model.Claim();
  org.hl7.fhir.dstu3.model.Encounter encounterResource = 
      (org.hl7.fhir.dstu3.model.Encounter) encounterEntry.getResource();

  claimResource.setStatus(ClaimStatus.ACTIVE);
  claimResource.setUse(org.hl7.fhir.dstu3.model.Claim.Use.COMPLETE);

  // duration of encounter
  claimResource.setBillablePeriod(encounterResource.getPeriod());

  claimResource.setPatient(new Reference(personEntry.getFullUrl()));
  claimResource.setOrganization(encounterResource.getServiceProvider());

  // add item for encounter
  claimResource.addItem(new org.hl7.fhir.dstu3.model.Claim.ItemComponent(new PositiveIntType(1))
      .addEncounter(new Reference(encounterEntry.getFullUrl())));

  // add prescription.
  claimResource.setPrescription(new Reference(medicationEntry.getFullUrl()));

  Money moneyResource = new Money();
  moneyResource.setValue(claim.total());
  moneyResource.setCode("USD");
  moneyResource.setSystem("urn:iso:std:iso:4217");
  claimResource.setTotal(moneyResource);

  return newEntry(bundle, claimResource);
}
 
开发者ID:synthetichealth,项目名称:synthea_java,代码行数:47,代码来源:FhirStu3.java

示例11: newEntry

import org.hl7.fhir.dstu3.model.Bundle; //导入依赖的package包/类
/**
 * Helper function to create an Entry for the given Resource within the given Bundle. Sets the
 * resourceID to a random UUID, sets the entry's fullURL to that resourceID, and adds the entry to
 * the bundle.
 * 
 * @param bundle
 *          The Bundle to add the Entry to
 * @param resource
 *          Resource the new Entry should contain
 * @return the created Entry
 */
private static BundleEntryComponent newEntry(Bundle bundle, Resource resource) {
  BundleEntryComponent entry = bundle.addEntry();

  String resourceID = UUID.randomUUID().toString();
  resource.setId(resourceID);
  entry.setFullUrl("urn:uuid:" + resourceID);

  entry.setResource(resource);

  return entry;
}
 
开发者ID:synthetichealth,项目名称:synthea_java,代码行数:23,代码来源:FhirStu3.java

示例12: export

import org.hl7.fhir.dstu3.model.Bundle; //导入依赖的package包/类
public static void export(long stop) {
  if (Boolean.parseBoolean(Config.get("exporter.hospital.fhir.export"))) {

    Bundle bundle = new Bundle();
    bundle.setType(BundleType.COLLECTION);
    for (Hospital h : Hospital.getHospitalList()) {
      // filter - exports only those hospitals in use

      Table<Integer, String, AtomicInteger> utilization = h.getUtilization();
      int totalEncounters = utilization.column(Provider.ENCOUNTERS).values().stream()
          .mapToInt(ai -> ai.get()).sum();
      if (totalEncounters > 0) {
        addHospitalToBundle(h, bundle);
      }
    }

    String bundleJson = FHIR_CTX.newJsonParser().setPrettyPrint(true)
        .encodeResourceToString(bundle);

    // get output folder
    List<String> folders = new ArrayList<>();
    folders.add("fhir");
    String baseDirectory = Config.get("exporter.baseDirectory");
    File f = Paths.get(baseDirectory, folders.toArray(new String[0])).toFile();
    f.mkdirs();
    Path outFilePath = f.toPath().resolve("hospitalInformation" + stop + ".json");

    try {
      Files.write(outFilePath, Collections.singleton(bundleJson), StandardOpenOption.CREATE_NEW);
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
}
 
开发者ID:synthetichealth,项目名称:synthea_java,代码行数:35,代码来源:HospitalExporter.java

示例13: newEntry

import org.hl7.fhir.dstu3.model.Bundle; //导入依赖的package包/类
private static BundleEntryComponent newEntry(Bundle bundle, Resource resource,
    String resourceID) {
  BundleEntryComponent entry = bundle.addEntry();

  resource.setId(resourceID);
  entry.setFullUrl("urn:uuid:" + resourceID);

  entry.setResource(resource);
  return entry;
}
 
开发者ID:synthetichealth,项目名称:synthea_java,代码行数:11,代码来源:HospitalExporter.java

示例14: loadFromDirectory

import org.hl7.fhir.dstu3.model.Bundle; //导入依赖的package包/类
/**
 * Returns an RDD of bundles loaded from the given path.
 *
 * @param spark the spark session
 * @param path a path to a directory of FHIR Bundles
 * @param minPartitions a suggested value for the minimal number of partitions
 * @return an RDD of FHIR Bundles
 */
public static JavaRDD<Bundle> loadFromDirectory(SparkSession spark,
    String path,
    int minPartitions) {

  return spark.sparkContext()
      .wholeTextFiles(path, minPartitions)
      .toJavaRDD()
      .map(new ToBundle());
}
 
开发者ID:cerner,项目名称:bunsen,代码行数:18,代码来源:Bundles.java

示例15: testSearchConsent

import org.hl7.fhir.dstu3.model.Bundle; //导入依赖的package包/类
/**
 * Test method for
 * {@link org.iexhub.services.JaxRsConsentRestProvider#search\(@IdParam
 * final IdDt id)}.
 */
@Test
public void testSearchConsent() {

	try {
		Logger logger = LoggerFactory.getLogger(ConsentDstu3Test.class);
		LoggingInterceptor loggingInterceptor = new LoggingInterceptor();
		loggingInterceptor.setLogRequestSummary(true);
		loggingInterceptor.setLogRequestBody(true);
		loggingInterceptor.setLogger(logger);

		IGenericClient client = ctxt.newRestfulGenericClient(serverBaseUrl);
		client.registerInterceptor(loggingInterceptor);

		Identifier searchParam = new Identifier();
		searchParam.setSystem(iExHubDomainOid).setValue(defaultPatientId);
		Bundle response = client
				.search()
				.forResource(Consent.class)
				.where(Patient.IDENTIFIER.exactly().identifier(searchParam.getId()))
				.returnBundle(Bundle.class).execute();

		assertTrue("Error - unexpected return value for testSearchConsent", response != null);
	} catch (Exception e) {
		fail(e.getMessage());
	}
}
 
开发者ID:bhits,项目名称:iexhub,代码行数:32,代码来源:ConsentDstu3Test.java


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