本文整理汇总了C#中Hl7.Fhir.Model.Bundle.GetBundleType方法的典型用法代码示例。如果您正苦于以下问题:C# Bundle.GetBundleType方法的具体用法?C# Bundle.GetBundleType怎么用?C# Bundle.GetBundleType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hl7.Fhir.Model.Bundle
的用法示例。
在下文中一共展示了Bundle.GetBundleType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BundleTypeHandling
public void BundleTypeHandling()
{
Bundle b = new Bundle();
Assert.IsTrue(b.GetBundleType() == BundleType.Unspecified);
b.SetBundleType(BundleType.Message);
Assert.AreEqual(BundleType.Message, b.GetBundleType());
Assert.AreEqual(1,b.Tags.Count());
b.SetBundleType(BundleType.Document);
Assert.AreEqual(BundleType.Document, b.GetBundleType());
Assert.AreEqual(1, b.Tags.Count());
b.SetBundleType(BundleType.Unspecified);
Assert.AreEqual(0, b.Tags.Count());
}
示例2: Mailbox
public Bundle Mailbox(Bundle bundle, Binary body)
{
// todo: this is not DSTU-1 conformant.
if(bundle == null || body == null) throw new SparkException("Mailbox requires a Bundle body payload");
// For the connectathon, this *must* be a document bundle
if (bundle.GetBundleType() != BundleType.Document)
throw new SparkException("Mailbox endpoint currently only accepts Document feeds");
Bundle result = new Bundle("Transaction result from posting of Document " + bundle.Id, DateTimeOffset.Now);
// Build a binary with the original body content (=the unparsed Document)
var binaryEntry = new ResourceEntry<Binary>(new Uri("cid:" + Guid.NewGuid()), DateTimeOffset.Now, body);
binaryEntry.SelfLink = new Uri("cid:" + Guid.NewGuid());
// Build a new DocumentReference based on the 1 composition in the bundle, referring to the binary
var compositions = bundle.Entries.OfType<ResourceEntry<Composition>>();
if (compositions.Count() != 1) throw new SparkException("Document feed should contain exactly 1 Composition resource");
var composition = compositions.First().Resource;
var reference = ConnectathonDocumentScenario.DocumentToDocumentReference(composition, bundle, body, binaryEntry.SelfLink);
// Start by copying the original entries to the transaction, minus the Composition
List<BundleEntry> entriesToInclude = new List<BundleEntry>();
//TODO: Only include stuff referenced by DocumentReference
//if(reference.Subject != null) entriesToInclude.AddRange(bundle.Entries.ById(new Uri(reference.Subject.Reference)));
//if (reference.Author != null) entriesToInclude.AddRange(
// reference.Author.Select(auth => bundle.Entries.ById(auth.Id)).Where(be => be != null));
//reference.Subject = composition.Subject;
//reference.Author = new List<ResourceReference>(composition.Author);
//reference.Custodian = composition.Custodian;
foreach (var entry in bundle.Entries.Where(be => !(be is ResourceEntry<Composition>)))
result.Entries.Add(entry);
// Now add the newly constructed DocumentReference and the Binary
result.Entries.Add(new ResourceEntry<DocumentReference>(new Uri("cid:" + Guid.NewGuid()), DateTimeOffset.Now, reference));
result.Entries.Add(binaryEntry);
// Process the constructed bundle as a Transaction and return the result
return Transaction(result);
}