public FhirResponse Handle(IKey key, SearchParams searchParameters)
        {
            Validate.TypeName(key.TypeName);

            Validate.HasSearchParameters(searchParameters);

            var hl7Type = key.TypeName.GetHl7ModelType();

            var modelFactory = this._provider.GetService(typeof(ResourceSearchHandlerFactory)) as ResourceSearchHandlerFactory;

            IResourceSearchHandler synapseModelHandler = modelFactory.GetHandler(hl7Type);

            var fhirParam = FHIRParam.Create(key.TypeName, key.ResourceId, key.VersionId);

            var searchResultData = synapseModelHandler.Handle(fhirParam, searchParameters);

            var fhirResponseFactory = this._provider.GetService(typeof(IFhirResponseFactory)) as IFhirResponseFactory;

            var resourcesData = searchResultData.ResourcesData;

            Bundle bundle = new Bundle()
            {
                Type  = Bundle.BundleType.Searchset,
                Total = resourcesData.Count,
                Id    = resourcesData.IsCollectionValid()? Guid.NewGuid().ToString() : SearchWarningMsg
            };

            bundle.Append(resourcesData);

            return(fhirResponseFactory.GetFhirResponse(bundle));
        }
        public SynapseResource Handle(IKey key, SynapseResource resource) // Just for the observation, temporary implementation -- can be removed later
        {
            var hl7Type = key.TypeName.GetHl7ModelType();

            var modelFactory = this._provider.GetService(typeof(ResourceCommandHandlerFactory)) as ResourceCommandHandlerFactory;

            IResourceCommandHandler commandHandler = modelFactory.GetHandler(hl7Type);

            var fhirParam = FHIRParam.Create(key.TypeName, key.ResourceId, key.VersionId);

            var synapseResource = commandHandler.Handle(resource);

            if (synapseResource == null)
            {
                throw new InterneuronBusinessException(StatusCodes.Status500InternalServerError);
            }

            return(synapseResource);
        }
        public FhirResponse Handle(IKey key)
        {
            Validate.HasTypeName(key);
            Validate.HasResourceId(key);
            Validate.HasNoVersion(key);
            Validate.Key(key);

            var hl7Type = key.TypeName.GetHl7ModelType();

            //Startup.AutofacContainer.Resolve<ISynapseResourceService<CorePerson>>();

            var modelFactory = this._provider.GetService(typeof(ResourceQueryHandlerFactory)) as ResourceQueryHandlerFactory;

            IResourceQueryHandler synapseModelHandler = modelFactory.GetHandler(hl7Type);

            var fhirParam = FHIRParam.Create(key.TypeName, key.ResourceId, key.VersionId);

            var resourceData = synapseModelHandler.Handle(fhirParam);

            var fhirResponseFactory = this._provider.GetService(typeof(IFhirResponseFactory)) as IFhirResponseFactory;

            return(fhirResponseFactory.GetFhirResponse(resourceData, key));
        }