本文整理汇总了Java中org.hl7.fhir.dstu3.model.Bundle类的典型用法代码示例。如果您正苦于以下问题:Java Bundle类的具体用法?Java Bundle怎么用?Java Bundle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Bundle类属于org.hl7.fhir.dstu3.model包,在下文中一共展示了Bundle类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: testFhirClient
import org.hl7.fhir.dstu3.model.Bundle; //导入依赖的package包/类
@Test
public void testFhirClient() {
FhirContext fhirContext = FhirContext.forDstu3();
IGenericClient fhirClient = fhirContext.newRestfulGenericClient("http://measure.eval.kanvix.com/cqf-ruler/baseDstu3");
Bundle patients = fhirClient.search().forResource("Patient").returnBundle(Bundle.class).execute();
assertTrue(patients.getEntry().size() > 0);
}
开发者ID:DBCG,项目名称:cql_engine,代码行数:9,代码来源:TestFhirDataProviderDstu3.java
示例17: hasLink
import org.hl7.fhir.dstu3.model.Bundle; //导入依赖的package包/类
private boolean hasLink(String theLinkType, Bundle theBundle) {
for (BundleLinkComponent next : theBundle.getLink()) {
if (theLinkType.equals(next.getRelation())) {
return true;
}
}
return false;
}
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:9,代码来源:Dstu3BundleFactory.java
示例18: initializeBundleFromResourceList
import org.hl7.fhir.dstu3.model.Bundle; //导入依赖的package包/类
@Override
public void initializeBundleFromResourceList(String theAuthor, List<? extends IBaseResource> theResources, String theServerBase, String theCompleteUrl, int theTotalResults,
BundleTypeEnum theBundleType) {
myBundle = new Bundle();
myBundle.setId(UUID.randomUUID().toString());
myBundle.getMeta().setLastUpdated(new Date());
myBundle.addLink().setRelation(Constants.LINK_FHIR_BASE).setUrl(theServerBase);
myBundle.addLink().setRelation(Constants.LINK_SELF).setUrl(theCompleteUrl);
myBundle.getTypeElement().setValueAsString(theBundleType.getCode());
if (theBundleType.equals(BundleTypeEnum.TRANSACTION)) {
for (IBaseResource nextBaseRes : theResources) {
Resource next = (Resource) nextBaseRes;
BundleEntryComponent nextEntry = myBundle.addEntry();
nextEntry.setResource(next);
if (next.getIdElement().isEmpty()) {
nextEntry.getRequest().setMethod(HTTPVerb.POST);
} else {
nextEntry.getRequest().setMethod(HTTPVerb.PUT);
if (next.getIdElement().isAbsolute()) {
nextEntry.getRequest().setUrl(next.getId());
} else {
String resourceType = myContext.getResourceDefinition(next).getName();
nextEntry.getRequest().setUrl(new IdType(theServerBase, resourceType, next.getIdElement().getIdPart(), next.getIdElement().getVersionIdPart()).getValue());
}
}
}
} else {
addResourcesForSearch(theResources);
}
myBundle.getTotalElement().setValue(theTotalResults);
}
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:38,代码来源:Dstu3BundleFactory.java
示例19: testSearchWithGenericReturnType
import org.hl7.fhir.dstu3.model.Bundle; //导入依赖的package包/类
@Test
public void testSearchWithGenericReturnType() throws Exception {
final Bundle bundle = new Bundle();
final ExtendedPatient patient = new ExtendedPatient();
patient.addIdentifier().setValue("PRP1660");
bundle.addEntry().setResource(patient);
final Organization org = new Organization();
org.setName("FOO");
patient.getManagingOrganization().setResource(org);
final FhirContext ctx = FhirContext.forDstu3();
ctx.setDefaultTypeForProfile(ExtendedPatient.HTTP_FOO_PROFILES_PROFILE, ExtendedPatient.class);
ctx.getRestfulClientFactory().setHttpClient(myHttpClient);
ctx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER);
String msg = ctx.newXmlParser().setPrettyPrint(true).encodeResourceToString(bundle);
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")));
// httpResponse = new BasicHttpResponse(statusline, catalog, locale)
when(myHttpClient.execute(capt.capture())).thenReturn(myHttpResponse);
ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
List<IBaseResource> response = client.getPatientByDobWithGenericResourceReturnType(new DateParam(ParamPrefixEnum.GREATERTHAN_OR_EQUALS, "2011-01-02"));
assertEquals("http://foo/Patient?birthdate=ge2011-01-02", capt.getValue().getURI().toString());
ExtendedPatient patientResp = (ExtendedPatient) response.get(0);
assertEquals("PRP1660", patientResp.getIdentifier().get(0).getValue());
}
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:38,代码来源:ClientWithCustomTypeDstu3Test.java
示例20: testSearchWithGenericReturnType2
import org.hl7.fhir.dstu3.model.Bundle; //导入依赖的package包/类
@Test
public void testSearchWithGenericReturnType2() throws Exception {
final Bundle bundle = new Bundle();
final ExtendedPatient patient = new ExtendedPatient();
patient.addIdentifier().setValue("PRP1660");
bundle.addEntry().setResource(patient);
final Organization org = new Organization();
org.setName("FOO");
patient.getManagingOrganization().setResource(org);
final FhirContext ctx = FhirContext.forDstu3();
ctx.setDefaultTypeForProfile(ExtendedPatient.HTTP_FOO_PROFILES_PROFILE, ExtendedPatient.class);
ctx.getRestfulClientFactory().setHttpClient(myHttpClient);
ctx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER);
String msg = ctx.newXmlParser().setPrettyPrint(true).encodeResourceToString(bundle);
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")));
// httpResponse = new BasicHttpResponse(statusline, catalog, locale)
when(myHttpClient.execute(capt.capture())).thenReturn(myHttpResponse);
ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
List<IAnyResource> response = client.getPatientByDobWithGenericResourceReturnType2(new DateParam(ParamPrefixEnum.GREATERTHAN_OR_EQUALS, "2011-01-02"));
assertEquals("http://foo/Patient?birthdate=ge2011-01-02", capt.getValue().getURI().toString());
ExtendedPatient patientResp = (ExtendedPatient) response.get(0);
assertEquals("PRP1660", patientResp.getIdentifier().get(0).getValue());
}
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:38,代码来源:ClientWithCustomTypeDstu3Test.java
注:本文中的org.hl7.fhir.dstu3.model.Bundle类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论