本文整理汇总了C#中Hl7.Fhir.Model.Resource类的典型用法代码示例。如果您正苦于以下问题:C# Resource类的具体用法?C# Resource怎么用?C# Resource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Resource类属于Hl7.Fhir.Model命名空间,在下文中一共展示了Resource类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Create
public Resource Create(Resource entry)
{
var resourceJson = FHIRbaseHelper.FhirResourceToJson(entry);
var resource = FHIRbase.Call("fhir.create")
.WithJsonb(resourceJson)
.Cast<string>();
return FHIRbaseHelper.JsonToFhirResource(resource);
}
开发者ID:tamizhvendan,项目名称:fhirbase-net,代码行数:9,代码来源:FHIRbaseApi.cs
示例2: TryValidate
public static bool TryValidate(Resource resource, ICollection<ValidationResult> validationResults=null)
{
if(resource == null) throw new ArgumentNullException("resource");
var results = validationResults ?? new List<ValidationResult>();
return Validator.TryValidateObject(resource, ValidationContextFactory.Create(resource, null), results, true);
}
开发者ID:nagyistoce,项目名称:kevinpeterson-fhir,代码行数:7,代码来源:ModelValidator.cs
示例3: Append
public static void Append(this Bundle bundle, Resource resource)
{
var entry = new Bundle.BundleEntryComponent();
entry.Resource = resource;
entry.Base = bundle.Base;
bundle.Entry.Add(entry);
}
开发者ID:raysearchlabs,项目名称:spark,代码行数:7,代码来源:BundleExtensions.cs
示例4: CreateEntryForResource
private static Bundle.BundleEntryComponent CreateEntryForResource(Resource resource)
{
var entry = new Bundle.BundleEntryComponent();
entry.Resource = resource;
// entry.FullUrl = resource.ResourceIdentity().ToString();
entry.FullUrl = resource.ExtractKey().ToUriString();
return entry;
}
开发者ID:Condeti,项目名称:spark,代码行数:8,代码来源:BundleExtensions.cs
示例5: 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
示例6: CreateFromResource
internal static ResourceEntry CreateFromResource(Resource resource, Uri id, DateTimeOffset updated, string title = null)
{
var result = ResourceEntry.Create(resource);
initializeResourceEntry(result, id, updated, title);
result.Resource = resource;
return result;
}
开发者ID:TonyAbell,项目名称:spark,代码行数:9,代码来源:BundleEntryFactory.cs
示例7: put
private void put(IKey key, int level, Resource resource)
{
if (resource is DomainResource)
{
DomainResource d = resource as DomainResource;
put(key, level, d);
put(key, level + 1, d.Contained);
}
}
开发者ID:Condeti,项目名称:spark,代码行数:10,代码来源:MongoIndexer.cs
示例8: ConstructSelfLink
public static Uri ConstructSelfLink(string baseuri, Resource resource)
{
// you must assume the resource has a verion id, otherwise a selflink is not possible
string s = baseuri + "/" + resource.TypeName + "/" + resource.Id;
if (resource.HasVersionId)
{
s += "/_history/" + resource.VersionId;
}
return new Uri(s);
}
开发者ID:raysearchlabs,项目名称:spark,代码行数:10,代码来源:BundleExtensions.cs
示例9: CreateDocument
public static BsonDocument CreateDocument(Resource resource)
{
if (resource != null)
{
string json = FhirSerializer.SerializeResourceToJson(resource);
return BsonDocument.Parse(json);
}
else
{
return new BsonDocument();
}
}
开发者ID:Condeti,项目名称:spark,代码行数:12,代码来源:BsonHelper.cs
示例10: Create
public Resource Create(Resource resource)
{
var resourceJson = ResourceDataHelper.FhirResourceToJson(resource);
var createdResourceJson = _context
.Call(FhirSchema.Name, FhirSchema.Func.Create)
.WithJson(resourceJson)
.Cast<String>();
var createdResource = ResourceDataHelper.JsonToFhirResource(createdResourceJson);
return createdResource;
}
开发者ID:Netrika,项目名称:FhirbaseNet2,代码行数:13,代码来源:FhirbaseStore.cs
示例11: ResourceType
public static void ResourceType(IKey key, Resource resource)
{
if (resource == null)
throw Error.BadRequest("Request did not contain a body");
if (key.TypeName != resource.TypeName)
{
throw Error.BadRequest(
"Received a body with a '{0}' resource, which does not match the indicated collection '{1}' in the url.",
resource.TypeName, key.TypeName);
}
}
开发者ID:Condeti,项目名称:spark,代码行数:13,代码来源:Validate.cs
示例12: RemoveExtensions
// HACK: json extensions
// Since WGM Chicago, extensions in json have their url in the json-name.
// because MongoDB doesn't allow dots in the json-name, this hack will remove all extensions for now.
public static void RemoveExtensions(Resource resource)
{
if (resource is DomainResource)
{
DomainResource domain = (DomainResource)resource;
domain.Extension = null;
domain.ModifierExtension = null;
RemoveExtensionsFromElements(resource);
foreach (Resource r in domain.Contained)
{
Hack.RemoveExtensions(r);
}
}
}
开发者ID:Condeti,项目名称:spark,代码行数:17,代码来源:Hack.cs
示例13: Deserialize
public Resource Deserialize(Resource existing=null)
{
// If there's no a priori knowledge of the type of Resource we will encounter,
// we'll have to determine from the data itself.
var resourceTypeName = _reader.GetResourceTypeName();
var mapping = _inspector.FindClassMappingForResource(resourceTypeName);
if (mapping == null)
throw Error.Format("Asked to deserialize unknown resource '" + resourceTypeName + "'", _reader);
// Delegate the actual work to the ComplexTypeReader, since
// the serialization of Resources and ComplexTypes are virtually the same
var cplxReader = new ComplexTypeReader(_reader);
return (Resource)cplxReader.Deserialize(mapping, existing);
}
开发者ID:tiloc,项目名称:fhir-net-api,代码行数:15,代码来源:ResourceReader.cs
示例14: Interaction
private Interaction(Bundle.HTTPVerb method, IKey key, DateTimeOffset? when, Resource resource)
{
if (resource != null)
{
key.ApplyTo(resource);
}
else
{
this.Key = key;
}
this.Resource = resource;
this.Method = method;
this.When = when ?? DateTimeOffset.Now;
this.State = InteractionState.Undefined;
}
开发者ID:Condeti,项目名称:spark,代码行数:15,代码来源:Interaction.cs
示例15: AgainstModel
public static OperationOutcome AgainstModel(Resource resource)
{
// Phase 1, validate against low-level rules built into the FHIR datatypes
/*
(!FhirValidator.TryValidate(entry.Resource, vresults, recurse: true))
{
foreach (var vresult in vresults)
result.Issue.Add(createValidationResult("[.NET validation] " + vresult.ErrorMessage, vresult.MemberNames));
}
//doc.Validate(SchemaCollection.ValidationSchemaSet,
// (source, args) => result.Issue.Add( createValidationResult("[XSD validation] " + args.Message,null))
//);
*/
throw new NotImplementedException();
}
开发者ID:raysearchlabs,项目名称:spark,代码行数:17,代码来源:Validate.cs
示例16: AgainstProfile
public static OperationOutcome AgainstProfile(Resource resource)
{
throw new NotImplementedException();
/*
// Phase 3, validate against a profile, if present
var profileTags = entry.GetAssertedProfiles();
if (profileTags.Count() == 0)
{
// If there's no profile specified, at least compare it to the "base" profile
string baseProfile = CoreZipArtifactSource.CORE_SPEC_PROFILE_URI_PREFIX + entry.Resource.GetCollectionName();
profileTags = new Uri[] { new Uri(baseProfile, UriKind.Absolute) };
}
var artifactSource = ArtifactResolver.CreateOffline();
var specProvider = new SpecificationProvider(artifactSource);
foreach (var profileTag in profileTags)
{
var specBuilder = new SpecificationBuilder(specProvider);
specBuilder.Add(StructureFactory.PrimitiveTypes());
specBuilder.Add(StructureFactory.MetaTypes());
specBuilder.Add(StructureFactory.NonFhirNamespaces());
specBuilder.Add(profileTag.ToString());
specBuilder.Expand();
string path = Directory.GetCurrentDirectory();
var spec = specBuilder.ToSpecification();
var nav = doc.CreateNavigator();
nav.MoveToFirstChild();
Report report = spec.Validate(nav);
var errors = report.Errors;
foreach (var error in errors)
{
result.Issue.Add(createValidationResult("[Profile validator] " + error.Message, null));
}
}
if(result.Issue.Count == 0)
return null;
else
return result;
*/
}
开发者ID:raysearchlabs,项目名称:spark,代码行数:46,代码来源:Validate.cs
示例17: SetBody
public void SetBody(Resource resource, ResourceFormat format)
{
if (resource == null) throw Error.ArgumentNull("resource");
if (resource is Binary)
{
var bin = (Binary)resource;
_body = bin.Content;
_contentType = bin.ContentType;
}
else
{
_body = format == ResourceFormat.Xml ?
FhirSerializer.SerializeResourceToXmlBytes(resource, summary: false) :
FhirSerializer.SerializeResourceToJsonBytes(resource, summary: false);
_contentType = ContentType.BuildContentType(format, forBundle: false);
}
}
开发者ID:wdebeau1,项目名称:fhir-net-api,代码行数:19,代码来源:FhirRequest.cs
示例18: WriteMetaData
public void WriteMetaData(ResourceEntry entry, int level, Resource resource)
{
if (level == 0)
{
Write(InternalField.ID, container_id);
string selflink = entry.Links.SelfLink.ToString();
Write(InternalField.SELFLINK, selflink);
var resloc = new ResourceIdentity(container_id);
Write(InternalField.JUSTID, resloc.Id);
/*
//For testing purposes:
string term = resloc.Id;
List<Tag> tags = new List<Tag>() { new Tag(term, "http://tags.hl7.org", "labello"+term) } ;
tags.ForEach(Collect);
/* */
if (entry.Tags != null)
{
entry.Tags.ToList().ForEach(Collect);
}
}
else
{
string id = resource.Id;
Write(InternalField.ID, container_id + "#" + id);
}
string category = resource.GetCollectionName();
//ModelInfo.GetResourceNameForType(resource.GetType()).ToLower();
Write(InternalField.RESOURCE, category);
Write(InternalField.LEVEL, level);
}
开发者ID:TonyAbell,项目名称:spark,代码行数:37,代码来源:Document.cs
示例19: MakeContainedReferencesUnique
/// <summary>
/// The id of a contained resource is only unique in the context of its 'parent'.
/// We want to allow the indexStore implementation to treat the IndexValue that comes from the contained resources just like a regular resource.
/// Therefore we make the id's globally unique, and adjust the references that point to it from its 'parent' accordingly.
/// This method trusts on the knowledge that contained resources cannot contain any further nested resources. So one level deep only.
/// </summary>
/// <param name="resource"></param>
/// <returns>A copy of resource, with id's of contained resources and references in resource adjusted to unique values.</returns>
private Resource MakeContainedReferencesUnique(Resource resource)
{
//We may change id's of contained resources, and don't want that to influence other code. So we make a copy for our own needs.
//Resource result = (dynamic)resource.DeepCopy(); //CK: This is how it should work, but unfortunately there is an error in the API (#146). So we invent a method of our own.
Resource result = CloneResource(resource);
if (resource is DomainResource)
{
var domainResource = (DomainResource)result;
if (domainResource.Contained != null && domainResource.Contained.Any())
{
var refMap = new Dictionary<string, string>();
//Create a unique id for each contained resource.
foreach (var containedResource in domainResource.Contained)
{
var oldRef = "#" + containedResource.Id;
var newId = Guid.NewGuid().ToString();
containedResource.Id = newId;
var newRef = containedResource.TypeName + "/" + newId;
refMap.Add(oldRef, newRef);
}
//Replace references to these contained resources with the newly created id's.
A.ResourceVisitor.VisitByType(domainResource,
(el, path) =>
{ var currentRef = (el as ResourceReference);
string replacementId;
refMap.TryGetValue(currentRef.Reference, out replacementId);
if (replacementId != null)
currentRef.Reference = replacementId;
}
, typeof(ResourceReference));
}
}
return result;
}
开发者ID:Condeti,项目名称:spark,代码行数:45,代码来源:IndexService.cs
示例20: Resource_CRUD
public void Resource_CRUD(Resource resource)
{
resource.Id = null;
var createdResource = FHIRbase.Create(resource);
Assert.That(createdResource, Is.Not.Null);
Assert.That(createdResource.Id, Is.Not.Null.Or.Empty);
Assert.That(createdResource.HasVersionId, Is.True);
var readedResource = FHIRbase.Read(new ResourceKey
{
ResourceId = createdResource.Id,
TypeName = createdResource.TypeName
});
Assert.That(readedResource, Is.Not.Null);
Assert.That(readedResource.Id, Is.Not.Null.Or.Empty);
Assert.That(readedResource.HasVersionId, Is.True);
readedResource.Meta.Security.Add(new Coding("http://ehr.acme.org/identifiers/collections", "23234352356"));
var updatedResource = FHIRbase.Update(readedResource);
Assert.That(updatedResource, Is.Not.Null);
Assert.That(updatedResource.Id, Is.Not.Null.Or.Empty);
Assert.That(updatedResource.HasVersionId, Is.True);
Assert.That(updatedResource.Meta.Security.First().Code == "23234352356");
Assert.That(updatedResource.Meta.Security.First().System == "http://ehr.acme.org/identifiers/collections");
FHIRbase.Delete(updatedResource);
Assert.That(FHIRbase.IsDeleted(createdResource), Is.True);
Assert.That(FHIRbase.IsDeleted(readedResource), Is.True);
Assert.That(FHIRbase.IsDeleted(updatedResource), Is.True);
}
开发者ID:tamizhvendan,项目名称:fhirbase-net,代码行数:36,代码来源:AllResourcesCrud.cs
注:本文中的Hl7.Fhir.Model.Resource类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论