private static void copyResource(org.hl7.fhir.dstu3.model.Resource src, org.hl7.fhir.dstu2016may.model.Resource tgt) throws FHIRException { if (src.hasId()) tgt.setId(src.getId()); if (src.hasMeta()) tgt.setMeta(convertMeta(src.getMeta())); if (src.hasImplicitRules()) tgt.setImplicitRules(src.getImplicitRules()); if (src.hasLanguage()) tgt.setLanguage(src.getLanguage()); }
private static void copy(FhirContext theCtx, IGenericClient theTarget, String theResType, List<IBaseResource> theQueued, Set<String> theSent, Bundle theReceived) { for (Bundle.BundleEntryComponent nextEntry : theReceived.getEntry()) { Resource nextResource = nextEntry.getResource(); nextResource.setId(theResType + "/" + "CR-" + nextResource.getIdElement().getIdPart()); boolean haveUnsentReference = false; for (ResourceReferenceInfo nextRefInfo : theCtx.newTerser().getAllResourceReferences(nextResource)) { IIdType nextRef = nextRefInfo.getResourceReference().getReferenceElement(); if (nextRef.hasIdPart()) { String newRef = nextRef.getResourceType() + "/" + "CR-" + nextRef.getIdPart(); ourLog.info("Changing reference {} to {}", nextRef.getValue(), newRef); nextRefInfo.getResourceReference().setReference(newRef); if (!theSent.contains(newRef)) { haveUnsentReference = true; } } } if (haveUnsentReference) { ourLog.info("Queueing {} for delivery after", nextResource.getId()); theQueued.add(nextResource); continue; } IIdType newId = theTarget .update() .resource(nextResource) .execute() .getId(); ourLog.info("Copied resource {} and got ID {}", nextResource.getId(), newId); theSent.add(nextResource.getIdElement().toUnqualifiedVersionless().getValue()); } }
if ("Subscription".equals(next.getResource().getResourceType()) || "DataElement".equals(next.getResource().getResourceType()) || "OperationOutcome".equals(next.getResource().getResourceType()) || "OperationDefinition".equals(next.getResource().getResourceType())) { ourLog.info("Skipping " + next.getResource().getResourceType() + " example"); iterator.remove(); } else { IdDt resourceId = new IdDt(next.getResource().getResourceType() + "/EX" + next.getResource().getIdElement().getIdPart()); if (!fullIds.add(resourceId.toUnqualifiedVersionless().getValue())) { ourLog.info("Discarding duplicate resource: " + resourceId.getValue()); next.getResource().setId(resourceId); } else { ourLog.info("Discarding resource with not explicit ID"); for (Iterator<BundleEntryComponent> iterator = bundle.getEntry().iterator(); iterator.hasNext(); ) { BundleEntryComponent next = iterator.next(); if (next.getResource().getIdElement().getIdPart() != null) { String nextId = next.getResource().getIdElement().getValue(); next.getRequest().setMethod(HTTPVerb.PUT); next.getRequest().setUrl(nextId);
public void copyResource(org.hl7.fhir.instance.model.Resource src, org.hl7.fhir.dstu3.model.Resource tgt) throws FHIRException { tgt.setId(src.getId()); tgt.setMeta(convertMeta(src.getMeta())); tgt.setImplicitRules(src.getImplicitRules()); tgt.setLanguage(src.getLanguage()); } public void copyResource(org.hl7.fhir.dstu3.model.Resource src, org.hl7.fhir.instance.model.Resource tgt) throws FHIRException {
private StructureDefinition resolveProfile(StructureDefinition profile, String pr) { if (pr.startsWith("#")) { for (Resource r : profile.getContained()) { if (r.getId().equals(pr.substring(1)) && r instanceof StructureDefinition) return (StructureDefinition) r; } return null; } else { long t = System.nanoTime(); StructureDefinition fr = context.fetchResource(StructureDefinition.class, pr); sdTime = sdTime + (System.nanoTime() - t); return fr; } }
if (next instanceof DomainResource) { for (Resource nextContained : ((DomainResource) next).getContained()) { if (nextContained.getIdElement().isEmpty() == false) { containedIds.add(nextContained.getIdElement().getValue()); if (next.getIdElement().hasBaseUrl()) { entry.setFullUrl(next.getId()); if (httpVerb != null) { entry.getRequest().getMethodElement().setValueAsString(httpVerb); entry.getRequest().getUrlElement().setValue(next.getId());
for (BundleEntryComponent i : bundle.getEntry()) { org.hl7.fhir.dstu3.model.Resource next = i.getResource(); next.setId(next.getIdElement().toUnqualifiedVersionless()); ourLog.info("Uploading ValueSet {}/{} : {} ({} bytes}", new Object[] {count, total, next.getIdElement().getValue(), bytes}); try { IIdType id = client.update().resource(next).execute().getId(); for (BundleEntryComponent i : bundle.getEntry()) { org.hl7.fhir.dstu3.model.Resource next = i.getResource(); next.setId(next.getIdElement().toUnqualifiedVersionless()); ourLog.info("Uploading v3-codesystems ValueSet {}/{} : {}", new Object[] {count, total, next.getIdElement().getValue()}); try { client.update().resource(next).execute(); for (BundleEntryComponent i : bundle.getEntry()) { org.hl7.fhir.dstu3.model.Resource next = i.getResource(); if (next.getIdElement().isIdPartValidLong()) { next.setIdElement(new IdType("v2-" + next.getIdElement().getIdPart())); next.setId(next.getIdElement().toUnqualifiedVersionless()); ourLog.info("Uploading v2-tables ValueSet {}/{} : {}", new Object[] {count, total, next.getIdElement().getValue()}); client.update().resource(next).execute(); count++;
next.setId(next.getIdElement().toUnqualifiedVersionless()); if (next instanceof CapabilityStatement) { continue; ourLog.info("Uploading {} StructureDefinition {}/{} : {}", new Object[] {theName, count, total, next.getIdElement().getValue()}); client.update().resource(next).execute();
@Override public Base makeProperty(int hash, String name) throws FHIRException { switch (hash) { case 3355: return getIdElement(); case 3347973: return getMeta(); case -961826286: return getImplicitRulesElement(); case -1613589672: return getLanguageElement(); default: return super.makeProperty(hash, name); } }
public boolean hasContained() { if (this.contained == null) return false; for (Resource item : this.contained) if (!item.isEmpty()) return true; return false; }
@Override public void setIdBase(String value) { setId(value); } public abstract ResourceType getResourceType();
/** * Converts a {@link Bundle} into a map grouped by the entry resources types * * @param bundle Bundle * @return map of entries grouped by their resource type */ public static Map<ResourceType, List<Bundle.BundleEntryComponent>> getBundleEntries(Bundle bundle) { return bundle.getEntry().stream() .collect(Collectors.groupingBy(entry -> { Bundle.BundleEntryRequestComponent request = entry.getRequest(); if (request == null || request.getUrl() == null) { throw unprocessableEntity( OperationOutcome.IssueSeverity.ERROR, OperationOutcome.IssueType.INVALID, null, null, "Invalid bundle entry request element %s", entry); } return entry.getResource().getResourceType(); } , LinkedHashMap::new, Collectors.toList())); }
@Override public IPrimitiveType<Date> getLastUpdated(IBaseResource theResource) { return ((Resource) theResource).getMeta().getLastUpdatedElement(); }
if (entry.getResource().fhirType().equals("ExplanationOfBenefit")) { ValidationResult bbResult = validationResources.validate(entry.getResource());
private ValueSet resolveBindingReference(DomainResource ctxt, Type reference, String uri) { if (reference instanceof UriType) { long t = System.nanoTime(); ValueSet fr = context.fetchResource(ValueSet.class, ((UriType) reference).getValue().toString()); txTime = txTime + (System.nanoTime() - t); return fr; } else if (reference instanceof Reference) { String s = ((Reference) reference).getReference(); if (s.startsWith("#")) { for (Resource c : ctxt.getContained()) { if (c.getId().equals(s.substring(1)) && (c instanceof ValueSet)) return (ValueSet) c; } return null; } else { long t = System.nanoTime(); String ref = ((Reference) reference).getReference(); if (!Utilities.isAbsoluteUrl(ref)) ref = resolve(uri, ref); ValueSet fr = context.fetchResource(ValueSet.class, ref); txTime = txTime + (System.nanoTime() - t); return fr; } } else return null; }
private static void copyResource(org.hl7.fhir.dstu2016may.model.Resource src, org.hl7.fhir.dstu3.model.Resource tgt) throws FHIRException { if (src.hasId()) tgt.setId(src.getId()); tgt.setMeta(convertMeta(src.getMeta())); if (src.hasImplicitRules()) tgt.setImplicitRules(src.getImplicitRules()); if (src.hasLanguage()) tgt.setLanguage(src.getLanguage()); } private static void copyResource(org.hl7.fhir.dstu3.model.Resource src, org.hl7.fhir.dstu2016may.model.Resource tgt) throws FHIRException {
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());
public org.hl7.fhir.instance.model.Resource convertResource(org.hl7.fhir.dstu3.model.Resource src) throws FHIRException { if (src == null || src.isEmpty()) return null; if (src instanceof org.hl7.fhir.dstu3.model.Parameters) if (src instanceof org.hl7.fhir.dstu3.model.ValueSet) return convertValueSet((org.hl7.fhir.dstu3.model.ValueSet) src); throw new Error("Unknown resource "+src.fhirType());
public boolean hasResource() { return this.resource != null && !this.resource.isEmpty(); }