本文整理汇总了C#中Hl7.Fhir.Model.Bundle类的典型用法代码示例。如果您正苦于以下问题:C# Bundle类的具体用法?C# Bundle怎么用?C# Bundle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Bundle类属于Hl7.Fhir.Model命名空间,在下文中一共展示了Bundle类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ProcessEncounters
private static void ProcessEncounters(List<TimelineEntry> timeline, Bundle matchingEncounters)
{
foreach (var encounter in matchingEncounters.Entries.Select(x => (ResourceEntry<Encounter>)x))
{
DateTimeOffset? startTime;
DateTimeOffset? endTime;
if (encounter.Resource.Hospitalization != null)
{
startTime = DateTimeOffset.Parse(encounter.Resource.Hospitalization.Period.Start);
endTime = DateTimeOffset.Parse(encounter.Resource.Hospitalization.Period.End);
}
else
{
startTime = encounter.Published;
endTime = encounter.Published;
}
timeline.Add(new TimelineEntry
{
StartTime = startTime,
EndTime = endTime,
TypeOfEntry = TimelineEntryType.Encounter,
Summary = encounter.Resource.Reason.ToString()
});
}
}
开发者ID:nagyistoce,项目名称:PatientTimelineFhir,代码行数:27,代码来源:TimelineBuilder.cs
示例2: TestSigning
public void TestSigning()
{
Bundle b = new Bundle();
b.Title = "Updates to resource 233";
b.Id = new Uri("urn:uuid:0d0dcca9-23b9-4149-8619-65002224c3");
b.LastUpdated = new DateTimeOffset(2012, 11, 2, 14, 17, 21, TimeSpan.Zero);
b.AuthorName = "Ewout Kramer";
ResourceEntry<Patient> p = new ResourceEntry<Patient>();
p.Id = new ResourceIdentity("http://test.com/fhir/Patient/233");
p.Resource = new Patient();
p.Resource.Name = new List<HumanName> { HumanName.ForFamily("Kramer").WithGiven("Ewout") };
b.Entries.Add(p);
var myAssembly = typeof(TestXmlSignature).Assembly;
var stream = myAssembly.GetManifestResourceStream("Spark.Tests.spark.pfx");
var data = new byte[stream.Length];
stream.Read(data,0,(int)stream.Length);
var certificate = new X509Certificate2(data);
var bundleData = FhirSerializer.SerializeBundleToXmlBytes(b);
var bundleXml = Encoding.UTF8.GetString(bundleData);
var bundleSigned = XmlSignatureHelper.Sign(bundleXml, certificate);
Assert.IsTrue(XmlSignatureHelper.IsSigned(bundleSigned));
Assert.IsTrue(XmlSignatureHelper.VerifySignature(bundleSigned));
var changedBundle = bundleSigned.Replace("<name>Ewout", "<name>Ewald");
Assert.AreEqual(bundleSigned.Length, changedBundle.Length);
Assert.IsFalse(XmlSignatureHelper.VerifySignature(changedBundle));
}
开发者ID:TonyAbell,项目名称:spark,代码行数:35,代码来源:TestXmlSignature.cs
示例3: Load
internal static Bundle Load(JsonReader reader)
{
JObject feed;
try
{
reader.DateParseHandling = DateParseHandling.None;
reader.FloatParseHandling = FloatParseHandling.Decimal;
feed = JObject.Load(reader);
if( feed.Value<string>(JsonDomFhirReader.RESOURCETYPE_MEMBER_NAME) != "Bundle")
throw Error.Format("Input data is not an json FHIR bundle", null);
}
catch (Exception exc)
{
throw Error.Format("Exception while parsing feed: " + exc.Message, null);
}
Bundle result;
try
{
result = new Bundle()
{
Title = feed.Value<string>(BundleXmlParser.XATOM_TITLE),
LastUpdated = instantOrNull(feed[BundleXmlParser.XATOM_UPDATED]),
Id = SerializationUtil.UriValueOrNull(feed[BundleXmlParser.XATOM_ID]),
Links = getLinks(feed[BundleXmlParser.XATOM_LINK]),
Tags = TagListParser.ParseTags(feed[BundleXmlParser.XATOM_CATEGORY]),
AuthorName = feed[BundleXmlParser.XATOM_AUTHOR] as JArray != null ?
feed[BundleXmlParser.XATOM_AUTHOR]
.Select(auth => auth.Value<string>(BundleXmlParser.XATOM_AUTH_NAME))
.FirstOrDefault()
: null,
AuthorUri = feed[BundleXmlParser.XATOM_AUTHOR] as JArray != null ?
feed[BundleXmlParser.XATOM_AUTHOR]
.Select(auth => auth.Value<string>(BundleXmlParser.XATOM_AUTH_URI))
.FirstOrDefault() : null,
TotalResults = intValueOrNull(feed[BundleXmlParser.XATOM_TOTALRESULTS])
};
}
catch (Exception exc)
{
throw Error.Format("Exception while parsing json feed attributes: " + exc.Message, null);
}
var entries = feed[BundleXmlParser.XATOM_ENTRY];
if (entries != null)
{
if (!(entries is JArray))
{
throw Error.Format("The json feed contains a single entry, instead of an array", null);
}
result.Entries = loadEntries((JArray)entries, result);
}
return result;
}
开发者ID:ranjancse26,项目名称:fhir-net-api,代码行数:60,代码来源:BundleJsonParser.cs
示例4: CreateBundle
public static Bundle CreateBundle(this ILocalhost localhost, Bundle.BundleType type)
{
Bundle bundle = new Bundle();
bundle.Base = localhost.Base.ToString();
bundle.Type = type;
return bundle;
}
开发者ID:raysearchlabs,项目名称:spark,代码行数:7,代码来源:LocalhostExtensions.cs
示例5: WriteTo
public static void WriteTo(Bundle bundle, XmlWriter writer, bool summary = false)
{
if (bundle == null) throw new ArgumentException("Bundle cannot be null");
var root = new XElement(BundleXmlParser.XATOMNS + BundleXmlParser.XATOM_FEED);
if (!String.IsNullOrWhiteSpace(bundle.Title)) root.Add(xmlCreateTitle(bundle.Title));
if (SerializationUtil.UriHasValue(bundle.Id)) root.Add(xmlCreateId(bundle.Id));
if (bundle.LastUpdated != null) root.Add(new XElement(BundleXmlParser.XATOMNS + BundleXmlParser.XATOM_UPDATED, bundle.LastUpdated));
if (!String.IsNullOrWhiteSpace(bundle.AuthorName))
root.Add(xmlCreateAuthor(bundle.AuthorName, bundle.AuthorUri));
if (bundle.TotalResults != null) root.Add(new XElement(BundleXmlParser.XOPENSEARCHNS + BundleXmlParser.XATOM_TOTALRESULTS, bundle.TotalResults));
if (bundle.Links != null)
{
foreach (var l in bundle.Links)
root.Add(xmlCreateLink(l.Rel, l.Uri));
}
if (bundle.Tags != null)
{
foreach (var tag in bundle.Tags)
root.Add(TagListSerializer.CreateTagCategoryPropertyXml(tag));
}
foreach (var entry in bundle.Entries)
root.Add(createEntry(entry, summary));
root.WriteTo(writer);
//var result = new XDocument(root);
//result.WriteTo(writer);
}
开发者ID:ranjancse26,项目名称:fhir-net-api,代码行数:33,代码来源:BundleXmlSerializer.cs
示例6: ResourceListFiltering
public void ResourceListFiltering()
{
var testBundle = new Bundle();
testBundle.Entry.Add(new Bundle.BundleEntryComponent { Resource = new Patient { Id = "1234", Meta = new Meta { VersionId = "v2" } } });
testBundle.Entry.Add(new Bundle.BundleEntryComponent { Resource = new Patient { Id = "1234", Meta = new Meta { VersionId = "v3" } } });
testBundle.Entry.Add(new Bundle.BundleEntryComponent { Resource = new Patient { Id = "1234", Meta = new Meta { VersionId = "v4"} },
Transaction = new Bundle.BundleEntryTransactionComponent {Method = Bundle.HTTPVerb.DELETE} });
testBundle.Entry.Add(new Bundle.BundleEntryComponent { Resource = new Patient { Id = "5678" }, Base = "http://server1.com/fhir" });
testBundle.Entry.Add(new Bundle.BundleEntryComponent { Resource = new Patient { Id = "1.2.3.4.5" }, Base = "urn:oid:" });
var result = testBundle.FindEntry("Patient", "1234");
Assert.AreEqual(2, result.Count());
result = testBundle.FindEntry("Patient", "1234", includeDeleted: true);
Assert.AreEqual(3, result.Count());
result = testBundle.FindEntry("Patient", "1234", "v3", includeDeleted: true);
Assert.AreEqual(1, result.Count());
result = testBundle.FindEntry(new Uri("http://server3.org/fhir/Patient/1234"));
Assert.AreEqual(0, result.Count());
result = testBundle.FindEntry("Patient", "5678");
Assert.AreEqual(1, result.Count());
result = testBundle.FindEntry(new Uri("http://server1.com/fhir/Patient/5678"));
Assert.AreEqual(1, result.Count());
result = testBundle.FindEntry(new Uri("http://server2.com/fhir/Patient/5678"));
Assert.AreEqual(0, result.Count());
result = testBundle.FindEntry(new Uri("urn:oid:1.2.3.4.5"));
Assert.AreEqual(1, result.Count());
}
开发者ID:alexandru360,项目名称:fhir-net-api,代码行数:32,代码来源:BundleExtensionsTest.cs
示例7: ExtractKey
public static Key ExtractKey(this Localhost localhost, Bundle.BundleEntryComponent entry)
{
Uri uri = new Uri(entry.Request.Url, UriKind.RelativeOrAbsolute);
Key compare = ExtractKey(uri); // This fails!! ResourceIdentity does not work in this case.
return localhost.LocalUriToKey(uri);
}
开发者ID:Condeti,项目名称:spark,代码行数:7,代码来源:KeyExtensions.cs
示例8: Append
public static void Append(this Bundle bundle, Bundle.HTTPVerb method, IEnumerable<Resource> resources)
{
foreach (Resource resource in resources)
{
bundle.Append(method, resource);
}
}
开发者ID:raysearchlabs,项目名称:spark,代码行数:7,代码来源:BundleExtensions.cs
示例9: CreateSnapshot
/// <summary>
/// Creates a snapshot for search commands
/// </summary>
public Snapshot CreateSnapshot(Bundle.BundleType type, Uri link, IEnumerable<string> keys, string sortby = null, int? count = null, IList<string> includes = null)
{
Snapshot snapshot = Snapshot.Create(type, link, keys, sortby, NormalizeCount(count), includes);
snapshotstore.AddSnapshot(snapshot);
return snapshot;
}
开发者ID:Condeti,项目名称:spark,代码行数:10,代码来源:Pager.cs
示例10: TryValidate
public static bool TryValidate(Bundle bundle, ICollection<ValidationResult> validationResults = null)
{
if (bundle == null) throw new ArgumentNullException("bundle");
var results = validationResults ?? new List<ValidationResult>();
return Validator.TryValidateObject(bundle, ValidationContextFactory.Create(bundle, null), results, true);
}
开发者ID:nagyistoce,项目名称:kevinpeterson-fhir,代码行数:7,代码来源:ModelValidator.cs
示例11: ResourceListFiltering
public void ResourceListFiltering()
{
var testBundle = new Bundle();
testBundle.AddResourceEntry(new Patient { Id = "1234", Meta = new Meta { VersionId = "v2" } }, "http://nu.nl/fhir/Patient/1234");
testBundle.AddResourceEntry(new Patient { Id = "1234", Meta = new Meta { VersionId = "v3" } }, "http://nu.nl/fhir/Patient/1234");
testBundle.AddResourceEntry(new Patient { Id = "1234", Meta = new Meta { VersionId = "v4" } }, "http://nu.nl/fhir/Patient/1234")
.Request = new Bundle.BundleEntryRequestComponent { Method = Bundle.HTTPVerb.DELETE } ;
testBundle.AddResourceEntry(new Patient { Id = "5678" }, "http://server1.com/fhir/Patient/5678");
testBundle.AddResourceEntry(new Patient { Id = "1.2.3.4.5" }, "urn:oid:1.2.3.4.5");
var result = testBundle.FindEntry("http://nu.nl/fhir/Patient/1234");
Assert.AreEqual(2, result.Count());
result = testBundle.FindEntry("http://nu.nl/fhir/Patient/1234", includeDeleted: true);
Assert.AreEqual(3, result.Count());
result = testBundle.FindEntry("http://nu.nl/fhir/Patient/1234/_history/v3", includeDeleted: true);
Assert.AreEqual(1, result.Count());
result = testBundle.FindEntry(new Uri("http://server3.org/fhir/Patient/1234"));
Assert.AreEqual(0, result.Count());
result = testBundle.FindEntry(new Uri("http://server1.com/fhir/Patient/5678"));
Assert.AreEqual(1, result.Count());
result = testBundle.FindEntry(new Uri("http://server2.com/fhir/Patient/5678"));
Assert.AreEqual(0, result.Count());
result = testBundle.FindEntry(new Uri("urn:oid:1.2.3.4.5"));
Assert.AreEqual(1, result.Count());
}
开发者ID:012345789,项目名称:fhir-net-api,代码行数:29,代码来源:BundleExtensionsTest.cs
示例12: WriteTo
public static void WriteTo(Bundle bundle, JsonWriter writer, bool summary = false)
{
if (bundle == null) throw new ArgumentException("Bundle cannot be null");
JObject result = new JObject();
result.Add(new JProperty(JsonDomFhirReader.RESOURCETYPE_MEMBER_NAME, "Bundle"));
if (!String.IsNullOrWhiteSpace(bundle.Title))
result.Add(new JProperty(BundleXmlParser.XATOM_TITLE, bundle.Title));
if (SerializationUtil.UriHasValue(bundle.Id)) result.Add(new JProperty(BundleXmlParser.XATOM_ID, bundle.Id));
if (bundle.LastUpdated != null)
result.Add(new JProperty(BundleXmlParser.XATOM_UPDATED, bundle.LastUpdated));
if (!String.IsNullOrWhiteSpace(bundle.AuthorName))
result.Add(jsonCreateAuthor(bundle.AuthorName, bundle.AuthorUri));
if (bundle.TotalResults != null) result.Add(new JProperty(BundleXmlParser.XATOM_TOTALRESULTS, bundle.TotalResults.ToString()));
if (bundle.Links.Count > 0)
result.Add(new JProperty(BundleXmlParser.XATOM_LINK, jsonCreateLinkArray(bundle.Links)));
if (bundle.Tags != null && bundle.Tags.Count() > 0)
result.Add( TagListSerializer.CreateTagCategoryPropertyJson(bundle.Tags));
var entryArray = new JArray();
foreach (var entry in bundle.Entries)
entryArray.Add(createEntry(entry,summary));
result.Add(new JProperty(BundleXmlParser.XATOM_ENTRY, entryArray));
result.WriteTo(writer);
}
开发者ID:ranjancse26,项目名称:fhir-net-api,代码行数:32,代码来源:BundleJsonSerializer.cs
示例13: TestSigning
public void TestSigning()
{
Bundle b = new Bundle();
b.Title = "Updates to resource 233";
b.Id = new Uri("urn:uuid:0d0dcca9-23b9-4149-8619-65002224c3");
b.LastUpdated = new DateTimeOffset(2012, 11, 2, 14, 17, 21, TimeSpan.Zero);
b.AuthorName = "Ewout Kramer";
ResourceEntry<Patient> p = new ResourceEntry<Patient>();
p.Id = new ResourceIdentity("http://test.com/fhir/Patient/233");
p.Resource = new Patient();
p.Resource.Name = new List<HumanName> { HumanName.ForFamily("Kramer").WithGiven("Ewout") };
b.Entries.Add(p);
var certificate = getCertificate();
var bundleData = FhirSerializer.SerializeBundleToXmlBytes(b);
var bundleXml = Encoding.UTF8.GetString(bundleData);
var bundleSigned = XmlSignatureHelper.Sign(bundleXml, certificate);
_signedXml = bundleSigned;
using (var response = postBundle(bundleSigned))
{
if (response.StatusCode != HttpStatusCode.OK) TestResult.Fail("Server refused POSTing signed document at /");
}
}
开发者ID:nagyistoce,项目名称:furore-sprinkler,代码行数:27,代码来源:DigSigTest.cs
示例14: newEntry
private Bundle.EntryComponent newEntry(Bundle.HTTPVerb method)
{
var newEntry = new Bundle.EntryComponent();
newEntry.Request = new Bundle.RequestComponent();
newEntry.Request.Method = method;
return newEntry;
}
开发者ID:tiloc,项目名称:fhir-net-api,代码行数:8,代码来源:TransactionBuilder.cs
示例15: newEntry
private Bundle.BundleEntryComponent newEntry(Bundle.HTTPVerb method)
{
var newEntry = new Bundle.BundleEntryComponent();
newEntry.Transaction = new Bundle.BundleEntryTransactionComponent();
newEntry.Transaction.Method = method;
return newEntry;
}
开发者ID:alexandru360,项目名称:fhir-net-api,代码行数:8,代码来源:TransactionBuilder.cs
示例16: AssertEntryIdsArePresentAndAbsoluteUrls
public static void AssertEntryIdsArePresentAndAbsoluteUrls(Bundle b)
{
if (b.Entries.Any(e => e.Id == null || e.SelfLink == null))
TestResult.Fail("Some id/selflinks in the bundle are null");
if (!b.Entries.All(e => e.Id.IsAbsoluteUri && e.SelfLink.IsAbsoluteUri))
TestResult.Fail("Some id/selflinks in the bundle are relative");
}
开发者ID:richardschneider,项目名称:sprinkler,代码行数:8,代码来源:HttpTests.cs
示例17: Append
public static void Append(this Bundle bundle, Bundle.HTTPVerb method, Resource resource)
{
Bundle.BundleEntryComponent entry = CreateEntryForResource(resource);
if (entry.Request == null) entry.Request = new Bundle.BundleEntryRequestComponent();
entry.Request.Method = method;
bundle.Entry.Add(entry);
}
开发者ID:Condeti,项目名称:spark,代码行数:8,代码来源:BundleExtensions.cs
示例18: Bundle
public static Bundle Bundle()
{
Bundle bundle = new Bundle();
Patient p = Test.Patient();
BundleEntry entry = ResourceEntry.Create(p);
bundle.Entries.Add(entry);
return bundle;
}
开发者ID:TonyAbell,项目名称:spark,代码行数:8,代码来源:Test.cs
示例19: SetBody
public void SetBody(Bundle bundle, ResourceFormat format)
{
if (bundle == null) throw Error.ArgumentNull("bundle");
_body = format == ResourceFormat.Xml ?
FhirSerializer.SerializeBundleToXmlBytes(bundle, summary: false) :
FhirSerializer.SerializeBundleToJsonBytes(bundle, summary: false);
_contentType = ContentType.BuildContentType(format, forBundle: true);
}
开发者ID:wdebeau1,项目名称:fhir-net-api,代码行数:10,代码来源:FhirRequest.cs
示例20: TakeSnapshotFromBundle
public static Snapshot TakeSnapshotFromBundle(Bundle bundle)
{
// Is Snapshot not a type of bundle???
Snapshot snapshot = new Snapshot();
snapshot.FeedTitle = bundle.Title;
snapshot.Id = Guid.NewGuid().ToString();
snapshot.FeedSelfLink = bundle.Links.SelfLink.ToString();
snapshot.Contents = bundle.SelfLinks();
snapshot.MatchCount = snapshot.Contents.Count();
return snapshot;
}
开发者ID:TonyAbell,项目名称:spark,代码行数:11,代码来源:Snapshot.cs
注:本文中的Hl7.Fhir.Model.Bundle类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论