Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        private async Task <IList <Tuple <Entry, FhirResponse> > > HandleTransaction(
            IList <Entry> interactions,
            IInteractionHandler interactionHandler,
            Mapper <string, IKey> mapper)
        {
            var responses = new List <Tuple <Entry, FhirResponse> >();

            await _transfer.Internalize(interactions, mapper).ConfigureAwait(false);

            foreach (var interaction in interactions)
            {
                var response = await interactionHandler.HandleInteraction(interaction).ConfigureAwait(false);

                if (!response.IsValid)
                {
                    throw new Exception();
                }

                interaction.Resource = response.Resource;
                response.Resource    = null;

                responses.Add(
                    new Tuple <Entry, FhirResponse>(
                        interaction,
                        response)); //CCR: How to handle responses for transactions?
                //The specifications says only one response should be sent per EntryComponent,
                //but one EntryComponent might correspond to multiple atomic entries (Entry)
                //Example: conditional delete
            }

            _transfer.Externalize(interactions);
            return(responses);
        }
Ejemplo n.º 4
0
 public void Interact(Character actor)
 {
     handler.HandleInteraction(mapObject, actor);
 }