Exemple #1
0
        private async Task <FhirResponse> HandleOperation(
            ResourceManipulationOperation operation,
            IInteractionHandler interactionHandler,
            Mapper <string, IKey> mapper = null)
        {
            IList <Entry> interactions = operation.GetEntries().ToList();

            if (mapper != null)
            {
                await _transfer.Internalize(interactions, mapper).ConfigureAwait(false);
            }

            FhirResponse response = null;

            foreach (var interaction in interactions)
            {
                response = MergeFhirResponse(
                    response,
                    await interactionHandler.HandleInteraction(interaction).ConfigureAwait(false));
                if (!response.IsValid)
                {
                    throw new Exception();
                }

                interaction.Resource = response.Resource;
            }

            _transfer.Externalize(interactions);

            return(response);
        }
        public FhirResponse HandleOperation(ResourceManipulationOperation operation, IInteractionHandler interactionHandler, Mapper <string, IKey> mapper = null)
        {
            IList <Entry> interactions = operation.GetEntries().ToList();

            if (mapper != null)
            {
                transfer.Internalize(interactions, mapper);
            }

            FhirResponse response = null;

            foreach (Entry interaction in interactions)
            {
                response = MergeFhirResponse(response, interactionHandler.HandleInteraction(interaction));
                if (!response.IsValid)
                {
                    throw new Exception();
                }
                interaction.Resource = response.Resource;
            }

            transfer.Externalize(interactions);

            return(response);
        }