diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/api/server/storage/ResourcePersistentId.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/api/server/storage/ResourcePersistentId.java index 1a45a9c9256..79a622e268f 100644 --- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/api/server/storage/ResourcePersistentId.java +++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/api/server/storage/ResourcePersistentId.java @@ -21,6 +21,7 @@ package ca.uhn.fhir.rest.api.server.storage; */ import ca.uhn.fhir.util.ObjectUtil; +import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IIdType; import java.util.ArrayList; @@ -125,4 +126,12 @@ public class ResourcePersistentId { } return retVal; } + + public static ResourcePersistentId fromResource(IBaseResource theResource) { + IIdType id = theResource.getIdElement(); + ResourcePersistentId retval = new ResourcePersistentId(id.getIdPart()); + retval.setAssociatedResourceId(id); + retval.setVersion(id.getVersionIdPartAsLong()); + return retval; + } }