Exemplo n.º 1
0
        /// <summary>
        /// Delete a resource.
        /// </summary>
        /// <param name="collection">The resource type, in lowercase</param>
        /// <param name="id">The id part of a Resource id</param>
        /// <remarks>
        /// Upon successful deletion the server should return
        ///   * 204 (No Content).
        ///   * If the resource does not exist on the server, the server must return 404 (Not found).
        ///   * Performing this operation on a resource that is already deleted has no effect, and should return 204 (No Content).
        /// </remarks>
        public FhirResponse Delete(IKey key)
        {
            Validate.Key(key);
            Validate.HasNoVersion(key);

            Interaction current = store.Get(key);

            if (current == null)
            {
                return(Respond.NotFound(key));
            }

            if (current.IsPresent)
            {
                // Add a new deleted-entry to mark this entry as deleted
                //Entry deleted = importer.ImportDeleted(location);
                key = generator.NextHistoryKey(key);
                Interaction deleted = Interaction.DELETE(key, DateTimeOffset.UtcNow);

                Store(deleted);
                return(Respond.WithCode(HttpStatusCode.NoContent));
            }
            else
            {
                return(Respond.Gone(current));
            }
        }
Exemplo n.º 2
0
        public ServerFhirResponse GetMetadataResponse(Entry entry, IKey key = null)
        {
            if (entry == null)
            {
                return(Respond.NotFound(key));
            }
            else if (entry.IsDeleted())
            {
                return(Respond.Gone(entry));
            }

            return(Respond.WithMeta(entry));
        }
Exemplo n.º 3
0
        public ServerFhirResponse GetFhirResponse(Entry entry, IKey key = null, IEnumerable <object> parameters = null)
        {
            if (entry == null)
            {
                return(Respond.NotFound(key));
            }
            if (entry.IsDeleted())
            {
                return(Respond.Gone(entry));
            }

            ServerFhirResponse response = null;

            return(response ?? Respond.WithResource(entry));
        }
Exemplo n.º 4
0
        public FhirResponse GetFhirResponse(Entry entry, IEnumerable <object> parameters = null)
        {
            if (entry.IsDeleted())
            {
                return(Respond.Gone(entry));
            }

            FhirResponse response = null;

            if (parameters != null)
            {
                response = interceptorRunner.RunInterceptors(entry, parameters);
            }

            return(response ?? Respond.WithResource(entry));
        }
        public FhirResponse GetFhirResponse(Interaction interaction, IEnumerable <object> parameters = null)
        {
            if (interaction.IsDeleted())
            {
                return(Respond.Gone(interaction));
            }

            FhirResponse response = null;

            if (parameters != null)
            {
                response = interceptorRunner.RunInterceptors(interaction, parameters);
            }

            return(response ?? Respond.WithResource(interaction));
        }
Exemplo n.º 6
0
        public FhirResponse AddMeta(Key key, Parameters parameters)
        {
            Entry entry = fhirStore.Get(key);

            if (entry == null)
            {
                return(Respond.NotFound(key));
            }
            else if (entry.IsDeleted())
            {
                return(Respond.Gone(entry));
            }

            entry.Resource.AffixTags(parameters);
            Store(entry);

            return(Respond.WithMeta(entry));
        }
Exemplo n.º 7
0
        public FhirResponse AddMeta(Key key, Parameters parameters)
        {
            Interaction interaction = fhirStore.Get(key);

            if (interaction == null)
            {
                return(Respond.NotFound(key));
            }
            else if (interaction.IsDeleted())
            {
                return(Respond.Gone(interaction));
            }

            interaction.Resource.AffixTags(parameters);
            Store(interaction);

            return(Respond.WithMeta(interaction));
        }
Exemplo n.º 8
0
        public FhirResponse ReadMeta(Key key)
        {
            _log.ServiceMethodCalled("readmeta");

            ValidateKey(key);

            Entry entry = fhirStore.Get(key);

            if (entry == null)
            {
                return(Respond.NotFound(key));
            }
            else if (entry.IsDeleted())
            {
                return(Respond.Gone(entry));
            }

            return(Respond.WithMeta(entry));
        }
Exemplo n.º 9
0
        public FhirResponse ReadMeta(Key key)
        {
            _log.ServiceMethodCalled("readmeta");

            ValidateKey(key);

            Interaction interaction = fhirStore.Get(key);

            if (interaction == null)
            {
                return(Respond.NotFound(key));
            }
            else if (interaction.IsDeleted())
            {
                return(Respond.Gone(interaction));
            }

            return(Respond.WithMeta(interaction));
        }
Exemplo n.º 10
0
        public FhirResponse ReadMeta(Key key)
        {
            Validate.HasTypeName(key);
            Validate.HasResourceId(key);
            Validate.HasNoVersion(key);
            Validate.Key(key);

            Interaction interaction = store.Get(key);

            if (interaction == null)
            {
                return(Respond.NotFound(key));
            }
            else if (interaction.IsDeleted())
            {
                return(Respond.Gone(interaction));
            }

            return(Respond.WithMeta(interaction));
        }
Exemplo n.º 11
0
        /// <summary>
        /// Read the state of a specific version of the resource.
        /// </summary>
        /// <param name="collectionName">The resource type, in lowercase</param>
        /// <param name="id">The id part of a version-specific reference</param>
        /// <param name="vid">The version part of a version-specific reference</param>
        /// <returns>A Result containing the resource, or an Issue</returns>
        /// <remarks>
        /// If the version referred to is actually one where the resource was deleted, the server should return a
        /// 410 status code.
        /// </remarks>
        public FhirResponse VersionRead(Key key)
        {
            Validate.HasTypeName(key);
            Validate.HasResourceId(key);
            Validate.HasVersion(key);
            Validate.Key(key);

            Interaction interaction = store.Get(key);

            if (interaction == null)
            {
                return(Respond.NotFound(key));
            }

            else if (interaction.IsDeleted())
            {
                return(Respond.Gone(interaction));
            }

            transfer.Externalize(interaction);
            return(Respond.WithResource(interaction));
        }