public IResourceServiceOutcome Process(string OperationName, Resource Resource, IRequestMeta RequestMeta) { if (string.IsNullOrWhiteSpace(OperationName)) { throw new NullReferenceException("OperationName cannot be null."); } if (Resource == null) { throw new NullReferenceException("Resource 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 (ICommonFactory == null) { throw new NullReferenceException("ICommonFactory cannot be null."); } if (RequestMeta.SearchParameterGeneric == null) { throw new NullReferenceException("SearchParameterGeneric cannot be null."); } IResourceServiceOutcome ResourceServiceOutcome = IResourceServiceOutcomeFactory.CreateResourceServiceOutcome(); ISearchParameterService SearchService = ISearchParameterServiceFactory.CreateSearchParameterService(); ISearchParametersServiceOutcome SearchParametersServiceOutcome = SearchService.ProcessBaseSearchParameters(RequestMeta.SearchParameterGeneric); if (SearchParametersServiceOutcome.FhirOperationOutcome != null) { ResourceServiceOutcome.ResourceResult = SearchParametersServiceOutcome.FhirOperationOutcome; ResourceServiceOutcome.HttpStatusCode = SearchParametersServiceOutcome.HttpStatusCode; ResourceServiceOutcome.FormatMimeType = SearchParametersServiceOutcome.SearchParameters.Format; return(ResourceServiceOutcome); } var OperationDic = FhirOperationEnum.GetOperationTypeByString(); if (!OperationDic.ContainsKey(Pyro.Common.Tools.StringSupport.ToLowerFast(OperationName))) { string Message = $"The resource operation named ${OperationName} is not supported by the server."; ResourceServiceOutcome.ResourceResult = Common.Tools.FhirOperationOutcomeSupport.Create(Hl7.Fhir.Model.OperationOutcome.IssueSeverity.Error, Hl7.Fhir.Model.OperationOutcome.IssueType.NotSupported, Message); ResourceServiceOutcome.FormatMimeType = SearchParametersServiceOutcome.SearchParameters.Format; ResourceServiceOutcome.HttpStatusCode = System.Net.HttpStatusCode.BadRequest; ResourceServiceOutcome.SuccessfulTransaction = false; return(ResourceServiceOutcome); } var Op = OperationDic[Pyro.Common.Tools.StringSupport.ToLowerFast(OperationName)]; OperationClass OperationClass = OperationClassFactory.OperationClassList.SingleOrDefault(x => x.Scope == FhirOperationEnum.OperationScope.Resource && x.Type == Op); if (OperationClass == null) { string Message = $"The resource operation named ${OperationName} is not supported by the server as a resource service operation type."; ResourceServiceOutcome.ResourceResult = Common.Tools.FhirOperationOutcomeSupport.Create(Hl7.Fhir.Model.OperationOutcome.IssueSeverity.Error, Hl7.Fhir.Model.OperationOutcome.IssueType.NotSupported, Message); ResourceServiceOutcome.FormatMimeType = SearchParametersServiceOutcome.SearchParameters.Format; ResourceServiceOutcome.HttpStatusCode = System.Net.HttpStatusCode.BadRequest; ResourceServiceOutcome.SuccessfulTransaction = false; return(ResourceServiceOutcome); } switch (OperationClass.Type) { case FhirOperationEnum.OperationType.Validate: { IFhirValidateOperation FhirValidateOperation = ICommonFactory.CreateFhirValidateOperation(); return(FhirValidateOperation.ValidateResource(OperationClass, Resource, RequestMeta)); } case FhirOperationEnum.OperationType.xIHISearchOrValidate: { IIHISearchOrValidateOperation IHISearchOrValidateOperation = ICommonFactory.CreateIHISearchOrValidateOperation(); return(IHISearchOrValidateOperation.IHISearchOrValidate(OperationClass, Resource, RequestMeta)); } default: throw new System.ComponentModel.InvalidEnumArgumentException(OperationClass.Type.GetPyroLiteral(), (int)OperationClass.Type, typeof(FhirOperationEnum.OperationType)); } }
public IResourceServiceOutcome Process( string OperationName, Resource Resource, IRequestMeta RequestMeta) { if (string.IsNullOrWhiteSpace(OperationName)) { throw new NullReferenceException("OperationName cannot be null."); } if (RequestMeta == null) { throw new NullReferenceException("RequestMeta cannot be null."); } if (RequestMeta.PyroRequestUri == null) { throw new NullReferenceException("PyroRequestUri cannot be null."); } if (RequestMeta.RequestHeader == null) { throw new NullReferenceException("RequestHeaders cannot be null."); } if (RequestMeta.SearchParameterGeneric == null) { throw new NullReferenceException("SearchPrameterGeneric cannot be null."); } IResourceServiceOutcome ResourceServiceOutcome = IResourceServiceOutcomeFactory.CreateResourceServiceOutcome(); ISearchParameterService SearchService = ISearchParameterServiceFactory.CreateSearchParameterService(); ISearchParametersServiceOutcome SearchParametersServiceOutcome = SearchService.ProcessBaseSearchParameters(RequestMeta.SearchParameterGeneric); if (SearchParametersServiceOutcome.FhirOperationOutcome != null) { ResourceServiceOutcome.ResourceResult = SearchParametersServiceOutcome.FhirOperationOutcome; ResourceServiceOutcome.HttpStatusCode = SearchParametersServiceOutcome.HttpStatusCode; ResourceServiceOutcome.FormatMimeType = SearchParametersServiceOutcome.SearchParameters.Format; return(ResourceServiceOutcome); } var OperationDic = FhirOperationEnum.GetOperationTypeByString(); if (!OperationDic.ContainsKey(OperationName)) { string Message = $"The base operation named ${OperationName} is not supported by the server."; ResourceServiceOutcome.ResourceResult = Common.Tools.FhirOperationOutcomeSupport.Create(Hl7.Fhir.Model.OperationOutcome.IssueSeverity.Error, Hl7.Fhir.Model.OperationOutcome.IssueType.NotSupported, Message); ResourceServiceOutcome.FormatMimeType = SearchParametersServiceOutcome.SearchParameters.Format; ResourceServiceOutcome.HttpStatusCode = System.Net.HttpStatusCode.BadRequest; ResourceServiceOutcome.SuccessfulTransaction = false; return(ResourceServiceOutcome); } var Op = OperationDic[OperationName]; OperationClass OperationClass = OperationClassFactory.OperationClassList.SingleOrDefault(x => x.Scope == FhirOperationEnum.OperationScope.Base && x.Type == Op); if (OperationClass == null) { string Message = $"The base operation named ${OperationName} is not supported by the server as a service base operation type."; ResourceServiceOutcome.ResourceResult = Common.Tools.FhirOperationOutcomeSupport.Create(Hl7.Fhir.Model.OperationOutcome.IssueSeverity.Error, Hl7.Fhir.Model.OperationOutcome.IssueType.NotSupported, Message); ResourceServiceOutcome.FormatMimeType = SearchParametersServiceOutcome.SearchParameters.Format; ResourceServiceOutcome.HttpStatusCode = System.Net.HttpStatusCode.BadRequest; ResourceServiceOutcome.SuccessfulTransaction = false; return(ResourceServiceOutcome); } switch (OperationClass.Type) { case FhirOperationEnum.OperationType.ServerIndexesDeleteHistoryIndexes: { IDeleteHistoryIndexesOperation DeleteManyHistoryIndexesService = ICommonFactory.CreateDeleteHistoryIndexesOperation(); return(DeleteManyHistoryIndexesService.DeleteMany(RequestMeta.PyroRequestUri, RequestMeta.SearchParameterGeneric, Resource)); } case FhirOperationEnum.OperationType.ServerIndexesSet: { IServerSearchParameterOperation ServerSearchParameterService = IServerSearchParameterServiceFactory.CreateServerSearchParameterService(); return(ServerSearchParameterService.ProcessSet(RequestMeta.PyroRequestUri, RequestMeta.SearchParameterGeneric, Resource)); } case FhirOperationEnum.OperationType.ServerSearchParameterIndexReport: { IServerSearchParameterOperation ServerSearchParameterService = IServerSearchParameterServiceFactory.CreateServerSearchParameterService(); return(ServerSearchParameterService.ProcessReport(RequestMeta.PyroRequestUri, RequestMeta.SearchParameterGeneric, Resource)); } case FhirOperationEnum.OperationType.ServerIndexesIndex: { IServerSearchParameterOperation ServerSearchParameterService = IServerSearchParameterServiceFactory.CreateServerSearchParameterService(); return(ServerSearchParameterService.ProcessIndex(RequestMeta.PyroRequestUri, RequestMeta.SearchParameterGeneric, Resource)); } case FhirOperationEnum.OperationType.ConnectathonAnswer: { IConnectathonAnswerOperation ConnectathonAnswerService = ICommonFactory.CreateConnectathonAnswerOperation(); return(ConnectathonAnswerService.Process(RequestMeta.PyroRequestUri, RequestMeta.SearchParameterGeneric, Resource)); } case FhirOperationEnum.OperationType.ServerResourceReport: { IResourceReportOperation ServerResourceReportService = ICommonFactory.CreateResourceReportOperation(); return(ServerResourceReportService.Process(RequestMeta.SearchParameterGeneric)); } default: throw new System.ComponentModel.InvalidEnumArgumentException(OperationClass.Type.GetPyroLiteral(), (int)OperationClass.Type, typeof(FhirOperationEnum.OperationType)); } }