@Override public List<Bundle.BundleEntryComponent> getEntries(Bundle theRequest) { return theRequest.getEntry(); }
private List<Base> getEdges() { List<Base> list = new ArrayList<>(); for (BundleEntryComponent be : bnd.getEntry()) list.add(new SearchEdge(type.substring(0, type.length()-10)+"Edge", be)); return list; }
private List<Resource> filterResources(Argument fhirpath, Bundle bnd) throws EGraphQLException, FHIRException { List<Resource> result = new ArrayList<Resource>(); if (bnd.getEntry().size() > 0) { if ((fhirpath == null)) for (BundleEntryComponent be : bnd.getEntry()) result.add(be.getResource()); else { FHIRPathEngine fpe = new FHIRPathEngine(context); ExpressionNode node = fpe.parse(getSingleValue(fhirpath)); for (BundleEntryComponent be : bnd.getEntry()) if (fpe.evaluateToBoolean(null, be.getResource(), be.getResource(), node)) result.add(be.getResource()); } } return result; }
private void loadStructureDefinitions(FhirContext theContext, Map<String, StructureDefinition> theCodeSystems, String theClasspath) { ourLog.info("Loading structure definitions from classpath: {}", theClasspath); InputStream valuesetText = DefaultProfileValidationSupport.class.getResourceAsStream(theClasspath); if (valuesetText != null) { InputStreamReader reader = new InputStreamReader(valuesetText, Constants.CHARSET_UTF8); Bundle bundle = theContext.newXmlParser().parseResource(Bundle.class, reader); for (BundleEntryComponent next : bundle.getEntry()) { if (next.getResource() instanceof StructureDefinition) { StructureDefinition nextSd = (StructureDefinition) next.getResource(); nextSd.getText().setDivAsString(""); String system = nextSd.getUrl(); if (isNotBlank(system)) { theCodeSystems.put(system, nextSd); } } } } else { ourLog.warn("Unable to load resource: {}", theClasspath); } }
public static BundleEntryComponent getEntryById(Bundle feed, ResourceType type, String reference) { for (BundleEntryComponent item : feed.getEntry()) { if (item.getResource().getId().equals(reference) && item.getResource().getResourceType() == type) return item; } return null; }
private static int loadBundle(String server, Bundle b, int size, int start, int end) throws URISyntaxException { System.out.println("Post to "+server+". size = "+Integer.toString(size)+", start = "+Integer.toString(start)+", total = "+Integer.toString(b.getEntry().size())); FHIRToolingClient client = new FHIRToolingClient(server); int c = start; if (end == -1) end = b.getEntry().size(); while (c < end) { Bundle bt = new Bundle(); bt.setType(BundleType.BATCH); bt.setId(UUID.randomUUID().toString().toLowerCase()); for (int i = c; i < Math.min(b.getEntry().size(), c+size); i++) { BundleEntryComponent be = bt.addEntry(); be.setResource(b.getEntry().get(i).getResource()); be.getRequest().setMethod(HTTPVerb.PUT); be.getRequest().setUrl(be.getResource().getResourceType().toString()+"/"+be.getResource().getId()); Bundle resp = client.transaction(bt); for (int i = 0; i < resp.getEntry().size(); i++) { BundleEntryComponent t = resp.getEntry().get(i); if (!t.getResponse().getStatus().startsWith("2")) { System.out.println("failed status at "+Integer.toString(i)+": "+t.getResponse().getStatus());
@Override public Base setProperty(String name, Base value) throws FHIRException { if (name.equals("identifier")) { this.identifier = castToIdentifier(value); // Identifier } else if (name.equals("type")) { value = new BundleTypeEnumFactory().fromType(castToCode(value)); this.type = (Enumeration) value; // Enumeration<BundleType> } else if (name.equals("timestamp")) { this.timestamp = castToInstant(value); // InstantType } else if (name.equals("total")) { this.total = castToUnsignedInt(value); // UnsignedIntType } else if (name.equals("link")) { this.getLink().add((BundleLinkComponent) value); } else if (name.equals("entry")) { this.getEntry().add((BundleEntryComponent) value); } else if (name.equals("signature")) { this.signature = castToSignature(value); // Signature } else return super.setProperty(name, value); return value; }
private void filterBundle(org.hl7.fhir.r4.model.Bundle theBundle) { for (Iterator<org.hl7.fhir.r4.model.Bundle.BundleEntryComponent> iter = theBundle.getEntry().iterator(); iter.hasNext(); ) { IBaseResource next = iter.next().getResource(); for (IIdType nextExclude : myExcludes) { if (nextExclude.hasResourceType() && nextExclude.toUnqualifiedVersionless().getValue().equals(next.getIdElement().toUnqualifiedVersionless().getValue())) { iter.remove(); continue; } else if (nextExclude.getIdPart().equals(next.getIdElement().getIdPart())) { iter.remove(); continue; } } } }
public static Resource getById(Bundle feed, ResourceType type, String reference) { for (BundleEntryComponent item : feed.getEntry()) { if (item.getResource().getId().equals(reference) && item.getResource().getResourceType() == type) return item.getResource(); } return null; }
total = bundle.getEntry().size(); count = 1; Collections.sort(bundle.getEntry(), new Comparator<org.hl7.fhir.r4.model.Bundle.BundleEntryComponent>() { @Override public int compare(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent theO1, org.hl7.fhir.r4.model.Bundle.BundleEntryComponent theO2) { for (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent i : bundle.getEntry()) { org.hl7.fhir.r4.model.Resource next = i.getResource(); next.setId(next.getIdElement().toUnqualifiedVersionless());
for (BundleEntryComponent next : bundle.getEntry()) { if (next.getResource() instanceof CodeSystem) { CodeSystem nextValueSet = (CodeSystem) next.getResource();
public <T extends Resource> T getCanonical(Class<T> resourceClass, String canonicalURL) { ResourceRequest<T> result = null; try { result = utils.issueGetResourceRequest(resourceAddress.resolveGetUriFromResourceClassAndCanonical(resourceClass, canonicalURL), getPreferredResourceFormat()); result.addErrorStatus(410);//gone result.addErrorStatus(404);//unknown result.addErrorStatus(405);//unknown result.addSuccessStatus(200);//Only one for now if(result.isUnsuccessfulRequest()) { throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome)result.getPayload()); } } catch (Exception e) { handleException("An error has occurred while trying to read this version of the resource", e); } Bundle bnd = (Bundle) result.getPayload(); if (bnd.getEntry().size() == 0) throw new EFhirClientException("No matching resource found for canonical URL '"+canonicalURL+"'"); if (bnd.getEntry().size() > 1) throw new EFhirClientException("Multiple matching resources found for canonical URL '"+canonicalURL+"'"); return (T) bnd.getEntry().get(0).getResource(); }
@Override public List<IBaseResource> toListOfResources() { ArrayList<IBaseResource> retVal = new ArrayList<IBaseResource>(); for (BundleEntryComponent next : myBundle.getEntry()) { if (next.getResource() != null) { retVal.add(next.getResource()); } else if (next.getResponse().getLocationElement().isEmpty() == false) { IdType id = new IdType(next.getResponse().getLocation()); String resourceType = id.getResourceType(); if (isNotBlank(resourceType)) { IAnyResource res = (IAnyResource) myContext.getResourceDefinition(resourceType).newInstance(); res.setId(id); retVal.add(res); } } } return retVal; }
Set<String> fullIds = new HashSet<String>(); for (Iterator<org.hl7.fhir.r4.model.Bundle.BundleEntryComponent> iterator = bundle.getEntry().iterator(); iterator.hasNext(); ) { org.hl7.fhir.r4.model.Bundle.BundleEntryComponent next = iterator.next(); for (Iterator<org.hl7.fhir.r4.model.Bundle.BundleEntryComponent> iterator = bundle.getEntry().iterator(); iterator.hasNext(); ) { org.hl7.fhir.r4.model.Bundle.BundleEntryComponent next = iterator.next(); if (next.getResource().getIdElement().getIdPart() != null) { for (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent next : bundle.getEntry()) { List<ResourceReferenceInfo> refs = ctx.newTerser().getAllResourceReferences(next.getResource()); for (ResourceReferenceInfo nextRef : refs) { System.gc(); ourLog.info("Final bundle: {} entries", bundle.getEntry().size());
@Override public Base setProperty(int hash, String name, Base value) throws FHIRException { switch (hash) { case -1618432855: // identifier this.identifier = castToIdentifier(value); // Identifier return value; case 3575610: // type value = new BundleTypeEnumFactory().fromType(castToCode(value)); this.type = (Enumeration) value; // Enumeration<BundleType> return value; case 55126294: // timestamp this.timestamp = castToInstant(value); // InstantType return value; case 110549828: // total this.total = castToUnsignedInt(value); // UnsignedIntType return value; case 3321850: // link this.getLink().add((BundleLinkComponent) value); // BundleLinkComponent return value; case 96667762: // entry this.getEntry().add((BundleEntryComponent) value); // BundleEntryComponent return value; case 1073584312: // signature this.signature = castToSignature(value); // Signature return value; default: return super.setProperty(hash, name, value); } }
filterBundle(bundle); total = bundle.getEntry().size(); count = 1; for (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent i : bundle.getEntry()) { org.hl7.fhir.r4.model.Resource next = i.getResource(); next.setId(next.getIdElement().toUnqualifiedVersionless()); total = bundle.getEntry().size(); count = 1; for (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent i : bundle.getEntry()) { org.hl7.fhir.r4.model.Resource next = i.getResource(); next.setId(next.getIdElement().toUnqualifiedVersionless()); total = bundle.getEntry().size(); count = 1; for (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent i : bundle.getEntry()) { org.hl7.fhir.r4.model.Resource next = i.getResource(); if (next.getIdElement().isIdPartValidLong()) {
public static org.hl7.fhir.dstu2016may.model.Bundle convertBundle(org.hl7.fhir.r4.model.Bundle src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2016may.model.Bundle tgt = new org.hl7.fhir.dstu2016may.model.Bundle(); copyResource(src, tgt); tgt.setType(convertBundleType(src.getType())); if (src.hasTotal()) tgt.setTotal(src.getTotal()); for (org.hl7.fhir.r4.model.Bundle.BundleLinkComponent t : src.getLink()) tgt.addLink(convertBundleLinkComponent(t)); for (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent t : src.getEntry()) tgt.addEntry(convertBundleEntryComponent(t)); tgt.setSignature(convertSignature(src.getSignature())); return tgt; }
private List<Base> getEdges() { List<Base> list = new ArrayList<>(); for (BundleEntryComponent be : bnd.getEntry()) list.add(new SearchEdge(type.substring(0, type.length()-10)+"Edge", be)); return list; }
public org.hl7.fhir.instance.model.Bundle convertBundle(org.hl7.fhir.r4.model.Bundle src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.instance.model.Bundle tgt = new org.hl7.fhir.instance.model.Bundle(); copyResource(src, tgt); tgt.setType(convertBundleType(src.getType())); if (src.hasTotal()) tgt.setTotal(src.getTotal()); for (org.hl7.fhir.r4.model.Bundle.BundleLinkComponent t : src.getLink()) tgt.addLink(convertBundleLinkComponent(t)); for (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent t : src.getEntry()) tgt.addEntry(convertBundleEntryComponent(t)); if (src.hasSignature()) tgt.setSignature(convertSignature(src.getSignature())); return tgt; }