private static IdType createId(final Long id, final Long theVersionId) { return new IdType("Patient", "" + id, "" + theVersionId); }
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++;
public static org.hl7.fhir.dstu3.model.IdType convertId(org.hl7.fhir.dstu2016may.model.IdType src) throws FHIRException { org.hl7.fhir.dstu3.model.IdType tgt = new org.hl7.fhir.dstu3.model.IdType(); if (src.hasValue()) tgt.setValue(src.getValue()); copyElement(src, tgt); return tgt; }
@Update public MethodOutcome update(@IdParam IdType theId, @ResourceParam Patient thePatient) { String resourceId = theId.getIdPart(); String versionId = theId.getVersionIdPart(); // this will contain the ETag String currentVersion = "1"; // populate this with the current version if (!versionId.equals(currentVersion)) { throw new ResourceVersionConflictException("Expected version " + currentVersion); } // ... perform the update ... return new MethodOutcome(); } //END SNIPPET: updateEtag
@Override public IdType withResourceType(String theResourceName) { if (isLocal() || isUrn()) { return new IdType(getValueAsString()); } return new IdType(theResourceName, getIdPart(), getVersionIdPart()); }
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());
@SuppressWarnings("unchecked") @Override public <T extends IBaseResource> T fetchResource(FhirContext theContext, Class<T> theClass, String theUri) { IdType id = new IdType(theUri); boolean localReference = false; if (id.hasBaseUrl() == false && id.hasIdPart() == true) { localReference = true; SearchParameterMap params = new SearchParameterMap(); params.setLoadSynchronousUpTo(1); params.add(IAnyResource.SP_RES_ID, new StringParam(id.getIdPart())); search = myQuestionnaireDao.search(params); } else if ("CodeSystem".equals(resourceName)) {
public org.hl7.fhir.instance.model.IdType convertId(org.hl7.fhir.dstu3.model.IdType src) throws FHIRException { org.hl7.fhir.instance.model.IdType tgt = new org.hl7.fhir.instance.model.IdType(src.getValue()); copyElement(src, tgt); return tgt; }
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()); } }
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()); 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);
/** * Returns true if this IdType matches the given IdType in terms of resource * type and ID, but ignores the URL base */ @SuppressWarnings("deprecation") public boolean equalsIgnoreBase(IdType theId) { if (theId == null) { return false; } if (theId.isEmpty()) { return isEmpty(); } return ObjectUtils.equals(getResourceType(), theId.getResourceType()) && ObjectUtils.equals(getIdPart(), theId.getIdPart()) && ObjectUtils.equals(getVersionIdPart(), theId.getVersionIdPart()); }
IdType id = new IdType(nextResource.getSourceReference().getReference()); if (isNotBlank(id.getResourceType())) { switch (id.getResourceType()) { case "CodeSystem": case "ConceptMap": case "ValueSet": IBaseResource resource = findResource(candidateResources, id); igResources.put(id.toUnqualifiedVersionless(), resource); break;
@Read(type = OperationDefinition.class) public OperationDefinition readOperationDefinition(@IdParam IdType theId) { if (theId == null || theId.hasIdPart() == false) { throw new ResourceNotFoundException(theId); } List<OperationMethodBinding> operationBindings = myOperationNameToBindings.get(theId.getIdPart()); if (operationBindings != null && !operationBindings.isEmpty()) { return readOperationDefinitionForOperation(operationBindings); } List<SearchMethodBinding> searchBindings = mySearchNameToBindings.get(theId.getIdPart()); if (searchBindings != null && !searchBindings.isEmpty()) { return readOperationDefinitionForNamedSearch(searchBindings); } throw new ResourceNotFoundException(theId); }
/** * Returns <code>true</code> if the unqualified ID is a valid {@link Long} * value (in other words, it consists only of digits) */ @Override public boolean isIdPartValidLong() { return isValidLong(getIdPart()); }
@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; }
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();
/** * Returns <code>true</code> if this ID contains an absolute URL (in other * words, a URL starting with "http://" or "https://" */ @Override public boolean isAbsolute() { if (StringUtils.isBlank(getValue())) { return false; } return isUrlAbsolute(getValue()); }