use of org.hl7.fhir.r4.model.Enumerations.ResourceType in project hapi-fhir-jpaserver-starter by hapifhir.
the class ExampleServerR4IT method testBatchPutWithIdenticalTags.
@Test
public void testBatchPutWithIdenticalTags() {
String batchPuts = "{\n" + "\t\"resourceType\": \"Bundle\",\n" + "\t\"id\": \"patients\",\n" + "\t\"type\": \"batch\",\n" + "\t\"entry\": [\n" + "\t\t{\n" + "\t\t\t\"request\": {\n" + "\t\t\t\t\"method\": \"PUT\",\n" + "\t\t\t\t\"url\": \"Patient/pat-1\"\n" + "\t\t\t},\n" + "\t\t\t\"resource\": {\n" + "\t\t\t\t\"resourceType\": \"Patient\",\n" + "\t\t\t\t\"id\": \"pat-1\",\n" + "\t\t\t\t\"meta\": {\n" + "\t\t\t\t\t\"tag\": [\n" + "\t\t\t\t\t\t{\n" + "\t\t\t\t\t\t\t\"system\": \"http://mysystem.org\",\n" + "\t\t\t\t\t\t\t\"code\": \"value2\"\n" + "\t\t\t\t\t\t}\n" + "\t\t\t\t\t]\n" + "\t\t\t\t}\n" + "\t\t\t},\n" + "\t\t\t\"fullUrl\": \"/Patient/pat-1\"\n" + "\t\t},\n" + "\t\t{\n" + "\t\t\t\"request\": {\n" + "\t\t\t\t\"method\": \"PUT\",\n" + "\t\t\t\t\"url\": \"Patient/pat-2\"\n" + "\t\t\t},\n" + "\t\t\t\"resource\": {\n" + "\t\t\t\t\"resourceType\": \"Patient\",\n" + "\t\t\t\t\"id\": \"pat-2\",\n" + "\t\t\t\t\"meta\": {\n" + "\t\t\t\t\t\"tag\": [\n" + "\t\t\t\t\t\t{\n" + "\t\t\t\t\t\t\t\"system\": \"http://mysystem.org\",\n" + "\t\t\t\t\t\t\t\"code\": \"value2\"\n" + "\t\t\t\t\t\t}\n" + "\t\t\t\t\t]\n" + "\t\t\t\t}\n" + "\t\t\t},\n" + "\t\t\t\"fullUrl\": \"/Patient/pat-2\"\n" + "\t\t}\n" + "\t]\n" + "}";
Bundle bundle = FhirContext.forR4().newJsonParser().parseResource(Bundle.class, batchPuts);
ourClient.transaction().withBundle(bundle).execute();
}
use of org.hl7.fhir.r4.model.Enumerations.ResourceType in project synthea by synthetichealth.
the class FhirR4 method newEntry.
/**
* 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
* @param resourceID The Resource ID to assign
* @return the created Entry
*/
private static BundleEntryComponent newEntry(Bundle bundle, Resource resource, String resourceID) {
BundleEntryComponent entry = bundle.addEntry();
resource.setId(resourceID);
entry.setFullUrl(getUrlPrefix(resource.fhirType()) + resourceID);
entry.setResource(resource);
if (TRANSACTION_BUNDLE) {
BundleEntryRequestComponent request = entry.getRequest();
request.setMethod(HTTPVerb.POST);
String resourceType = resource.getResourceType().name();
request.setUrl(resourceType);
if (ExportHelper.UNDUPLICATED_FHIR_RESOURCES.contains(resourceType)) {
Property prop = entry.getResource().getNamedProperty("identifier");
if (prop != null && prop.getValues().size() > 0) {
Identifier identifier = (Identifier) prop.getValues().get(0);
request.setIfNoneExist("identifier=" + identifier.getSystem() + "|" + identifier.getValue());
}
}
entry.setRequest(request);
}
return entry;
}
use of org.hl7.fhir.r4.model.Enumerations.ResourceType in project synthea by synthetichealth.
the class FhirStu3 method newEntry.
/**
* Helper function to create an Entry for the given Resource within the given Bundle.
* Sets the entry's fullURL to 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
* @param resourceID The Resource ID to assign
* @return the created Entry
*/
private static BundleEntryComponent newEntry(Bundle bundle, Resource resource, String resourceID) {
BundleEntryComponent entry = bundle.addEntry();
resource.setId(resourceID);
if (Config.getAsBoolean("exporter.fhir.bulk_data")) {
entry.setFullUrl(resource.fhirType() + "/" + resourceID);
} else {
entry.setFullUrl("urn:uuid:" + resourceID);
}
entry.setResource(resource);
if (TRANSACTION_BUNDLE) {
BundleEntryRequestComponent request = entry.getRequest();
request.setMethod(HTTPVerb.POST);
String resourceType = resource.getResourceType().name();
request.setUrl(resourceType);
if (ExportHelper.UNDUPLICATED_FHIR_RESOURCES.contains(resourceType)) {
Property prop = entry.getResource().getNamedProperty("identifier");
if (prop != null && prop.getValues().size() > 0) {
Identifier identifier = (Identifier) prop.getValues().get(0);
request.setIfNoneExist("identifier=" + identifier.getSystem() + "|" + identifier.getValue());
}
}
entry.setRequest(request);
}
return entry;
}
use of org.hl7.fhir.r4.model.Enumerations.ResourceType in project cqf-ruler by DBCG.
the class FhirMeasureBundler method bundle.
// Adds the resources returned from the given expressions to a bundle
@SuppressWarnings("unchecked")
public Bundle bundle(Context context, String... expressionNames) {
Bundle bundle = new Bundle();
bundle.setType(Bundle.BundleType.COLLECTION);
for (String expressionName : expressionNames) {
Object result = context.resolveExpressionRef(expressionName).evaluate(context);
for (Object element : (Iterable<Object>) result) {
Bundle.BundleEntryComponent entry = new Bundle.BundleEntryComponent();
entry.setResource((Resource) element);
// The null check for resourceType handles Lists, which don't have a resource
// type.
entry.setFullUrl((((Resource) element).getIdElement().getResourceType() != null ? (((Resource) element).getIdElement().getResourceType() + "/") : "") + ((Resource) element).getIdElement().getIdPart());
bundle.getEntry().add(entry);
}
}
return bundle;
}
use of org.hl7.fhir.r4.model.Enumerations.ResourceType in project cqf-ruler by DBCG.
the class FhirMeasureBundler method bundle.
public Bundle bundle(Iterable<Resource> resources, String fhirServerBase) {
Bundle bundle = new Bundle();
bundle.setType(Bundle.BundleType.COLLECTION);
for (Resource resource : resources) {
Bundle.BundleEntryComponent entry = new Bundle.BundleEntryComponent();
entry.setResource(resource);
// The null check for resourceType handles Lists, which don't have a resource
// type.
entry.setFullUrl(fhirServerBase + (resource.getIdElement().getResourceType() != null ? (resource.getIdElement().getResourceType() + "/") : "") + resource.getIdElement().getIdPart());
bundle.getEntry().add(entry);
}
return bundle;
}
Aggregations