public static Bundle RefreshBundle(this FhirClient client, Bundle bundle) { if (bundle == null) throw Error.ArgumentNull("bundle"); if (bundle.Type != Bundle.BundleType.Searchset) throw Error.Argument("Refresh is only applicable to bundles of type 'searchset'"); // Clone old bundle, without the entries (so, just the header) Bundle result = (Bundle)bundle.DeepCopy(); result.Id = "urn:uuid:" + Guid.NewGuid().ToString("n"); result.Meta = new Meta(); result.Meta.LastUpdated = DateTimeOffset.Now; foreach (var entry in result.Entry) { if (entry.Resource != null) { entry.Resource = client.Read<Resource>(entry.FullUrl); } } return result; }