private bool CommitTransactionBundle(Bundle Bundle, string FileName)
 {
     try
     {
         var RequestMeta = IRequestMetaFactory.CreateRequestMeta().Set($"");
         IBundleTransactionOperation BundleTransactionOperation = IBundleTransactionOperationFactory.CreateBundleTransactionOperation();
         this.IResourceTriggerService.TriggersActive = false;
         IResourceServiceOutcome ResourceServiceOutcome = BundleTransactionOperation.Transact(Bundle, RequestMeta);
         this.IResourceTriggerService.TriggersActive = true;
         if (ResourceServiceOutcome.SuccessfulTransaction)
         {
             return(true);
         }
         else
         {
             string OperationOutcomeMessage = string.Empty;
             if (ResourceServiceOutcome.ResourceResult != null && ResourceServiceOutcome.ResourceResult is OperationOutcome OptOut)
             {
                 OptOut.Issue.ForEach(x => OperationOutcomeMessage = OperationOutcomeMessage + " " + x.Details);
             }
             ILog.Error($"Internal Server Error: Transaction bundle from the FHIR specification zip file named: {_ZipFileName}, file '{FileName} did not commit in a single transaction. " +
                        $"The POST bundle transaction reported: HTTP Status: {ResourceServiceOutcome.HttpStatusCode} and the detail: {OperationOutcomeMessage}");
             return(false);
         }
     }
     catch (Exception Exec)
     {
         ILog.Error(Exec, $"Internal Server Error: Could not commit the transaction bundle from the FHIR specification zip file named: {_ZipFileName}, file '{FileName}.");
         return(false);
     }
 }
Exemplo n.º 2
0
 public IResourceServiceOutcome Base(string BaseRequestUri, HttpRequestMessage Request, Resource resource)
 {
     using (DbContextTransaction Transaction = IUnitOfWork.BeginTransaction())
     {
         try
         {
             IRequestServiceRootValidate.Validate(BaseRequestUri);
             IRequestMeta RequestMeta = IRequestMetaFactory.CreateRequestMeta().Set(Request);
             IBundleTransactionOperation BundleTransactionOperation = IBundleTransactionOperationFactory.CreateBundleTransactionOperation();
             IResourceServiceOutcome     ResourceServiceOutcome     = BundleTransactionOperation.Transact(resource, RequestMeta);
             ResourceServiceOutcome.SummaryType = RequestMeta.SearchParameterGeneric.SummaryType;
             if (ResourceServiceOutcome.SuccessfulTransaction)
             {
                 Transaction.Commit();
             }
             else
             {
                 Transaction.Rollback();
             }
             return(ResourceServiceOutcome);
         }
         catch (Exception Exec)
         {
             Transaction.Rollback();
             ILog.Error(Exec, $"PyroService.Base, Request: {Request.RequestUri.OriginalString}");
             throw new PyroException(System.Net.HttpStatusCode.InternalServerError,
                                     Common.Tools.FhirOperationOutcomeSupport.Create(OperationOutcome.IssueSeverity.Error, OperationOutcome.IssueType.Exception, Exec.Message), Exec.Message);
         }
     }
 }
        public IResourceServiceOutcome Initialize(OperationClass OperationClass, IRequestMeta RequestMeta, string FhirId)
        {
            if (OperationClass == null)
            {
                throw new NullReferenceException("OperationClass cannot be null.");
            }
            if (IResourceServices == null)
            {
                throw new NullReferenceException("ResourceServices cannot be null.");
            }
            if (RequestMeta == null)
            {
                throw new NullReferenceException("RequestMeta cannot be null.");
            }
            if (RequestMeta.PyroRequestUri == null)
            {
                throw new NullReferenceException("RequestUri cannot be null.");
            }
            if (RequestMeta.RequestHeader == null)
            {
                throw new NullReferenceException("RequestHeaders cannot be null.");
            }
            if (RequestMeta.SearchParameterGeneric == null)
            {
                throw new NullReferenceException("SearchParameterGeneric cannot be null.");
            }

            ResourceServiceOutcome = IResourceServiceOutcomeFactory.CreateResourceServiceOutcome();



            var ResourceRepository = IRepositorySwitcher.GetRepository(FHIRAllTypes.Patient);



            List <Resource> ResourceList = new List <Resource>();

            if (ResourceList.Count > 0)
            {
                Bundle TransactionBundle  = GenerateTransactionBundle(ResourceList);
                var    CurrentRequestMeta = IRequestMetaFactory.CreateRequestMeta().Set($"{FHIRAllTypes.Bundle.GetLiteral()}/{TransactionBundle.Id}");
                IResourceServiceOutcome ResourceServiceOutcome = IBundleTransactionOperation.Transact(TransactionBundle, CurrentRequestMeta);
                return(ResourceServiceOutcome);
            }


            //  var OutCome = IResourceServices.Put(Res.Id, Res, CurrentRequestMeta);

            //var ResourceRepository = IRepositorySwitcher.GetRepository(FHIRAllTypes.Patient);


            return(ResourceServiceOutcome);
        }