示例#1
0
        public ResourceWrapper(
            string resourceId,
            string versionId,
            string resourceTypeName,
            RawResource rawResource,
            ResourceRequest request,
            DateTimeOffset lastModified,
            bool deleted,
            IReadOnlyCollection <SearchIndexEntry> searchIndices,
            CompartmentIndices compartmentIndices,
            IReadOnlyCollection <KeyValuePair <string, string> > lastModifiedClaims,
            string searchParameterHash = null)
        {
            EnsureArg.IsNotNullOrEmpty(resourceId, nameof(resourceId));
            EnsureArg.IsNotNullOrEmpty(resourceTypeName, nameof(resourceTypeName));
            EnsureArg.IsNotNull(rawResource, nameof(rawResource));

            ResourceId          = resourceId;
            Version             = versionId;
            ResourceTypeName    = resourceTypeName;
            RawResource         = rawResource;
            Request             = request;
            IsDeleted           = deleted;
            LastModified        = lastModified;
            SearchIndices       = searchIndices;
            CompartmentIndices  = compartmentIndices;
            LastModifiedClaims  = lastModifiedClaims;
            SearchParameterHash = searchParameterHash;
        }
 public ResourceWrapper(Resource resource, RawResource rawResource, ResourceRequest request, bool deleted, IReadOnlyCollection <KeyValuePair <string, string> > lastModifiedClaims, CompartmentIndices compartmentIndices)
     : this(
         IsNotNull(resource).Id,
         resource.VersionId,
         resource.TypeName,
         rawResource,
         request,
         resource.Meta?.LastUpdated ?? Clock.UtcNow,
         deleted,
         lastModifiedClaims,
         compartmentIndices)
 {
 }
        /// <inheritdoc />
        public ResourceWrapper Create(Resource resource, bool deleted)
        {
            RawResource rawResource = _rawResourceFactory.Create(resource);
            IReadOnlyCollection <SearchIndexEntry> searchIndices = _searchIndexer.Extract(resource);

            IFhirRequestContext fhirRequestContext = _fhirRequestContextAccessor.FhirRequestContext;

            return(new ResourceWrapper(
                       resource,
                       rawResource,
                       new ResourceRequest(fhirRequestContext.Uri, fhirRequestContext.Method),
                       deleted,
                       searchIndices,
                       _compartmentIndexer.Extract(resource.ResourceType, searchIndices),
                       _claimsIndexer.Extract()));
        }
        /// <inheritdoc />
        public ResourceWrapper Create(ResourceElement resource, bool deleted, bool keepMeta)
        {
            RawResource rawResource = _rawResourceFactory.Create(resource, keepMeta);
            IReadOnlyCollection <SearchIndexEntry> searchIndices = _searchIndexer.Extract(resource);
            string searchParamHash = _searchParameterDefinitionManager.GetSearchParameterHashForResourceType(resource.InstanceType);

            IFhirRequestContext fhirRequestContext = _fhirRequestContextAccessor.FhirRequestContext;

            return(new ResourceWrapper(
                       resource,
                       rawResource,
                       new ResourceRequest(fhirRequestContext.Method, fhirRequestContext.Uri),
                       deleted,
                       searchIndices,
                       _compartmentIndexer.Extract(resource.InstanceType, searchIndices),
                       _claimsExtractor.Extract(),
                       searchParamHash));
        }
 public ResourceWrapper(
     ResourceElement resource,
     RawResource rawResource,
     ResourceRequest request,
     bool deleted,
     IReadOnlyCollection <SearchIndexEntry> searchIndices,
     CompartmentIndices compartmentIndices,
     IReadOnlyCollection <KeyValuePair <string, string> > lastModifiedClaims)
     : this(
         EnsureArg.IsNotNull(resource).Id,
         resource.VersionId,
         resource.InstanceType,
         rawResource,
         request,
         resource.LastUpdated ?? Clock.UtcNow,
         deleted,
         searchIndices,
         compartmentIndices,
         lastModifiedClaims)
 {
 }
        internal static Resource DeserializeRaw(RawResource rawResource)
        {
            EnsureArg.IsNotNull(rawResource, nameof(rawResource));

            Resource resource;

            switch (rawResource.Format)
            {
            case ResourceFormat.Xml:
                resource = FhirXmlParser.Parse <Resource>(rawResource.Data);
                break;

            case ResourceFormat.Json:
                resource = FhirJsonParser.Parse <Resource>(rawResource.Data);
                break;

            default:
                throw new NotSupportedException();
            }

            return(resource);
        }