private bool GetProcessing(Bundle.EntryComponent GetEntry, int GetEntryIndex) { IRequestMeta RequestMeta = IRequestMetaFactory.CreateRequestMeta(); RequestMeta.Set(GetEntry.Request); RequestMeta.RequestHeader.Prefer = _RequestHeader.Prefer; IResourceServiceOutcome ResourceServiceOutcome = null; if (RequestMeta.SearchParameterGeneric.ParameterList.Count > 0) { ResourceServiceOutcome = IResourceServices.GetSearch(RequestMeta); } else { ResourceServiceOutcome = IResourceServices.GetRead(RequestMeta.PyroRequestUri.FhirRequestUri.ResourceId, RequestMeta); } if (ResourceServiceOutcome.SuccessfulTransaction) { GetEntry.FullUrl = CreateFullUrl(ResourceServiceOutcome); GetEntry.Response = new Bundle.ResponseComponent(); GetEntry.Response.Status = FormatHTTPStatusCodeAsString(ResourceServiceOutcome.HttpStatusCode); if (ResourceServiceOutcome.ResourceResult != null) { if (ResourceServiceOutcome.ResourceResult.ResourceType == ResourceType.OperationOutcome) { GetEntry.Response.Outcome = ResourceServiceOutcome.ResourceResult; } else { GetEntry.Resource = ResourceServiceOutcome.ResourceResult; } } if (ResourceServiceOutcome.LastModified.HasValue) { GetEntry.Response.Etag = HttpHeaderSupport.GetEntityTagHeaderValueFromVersion(ResourceServiceOutcome.ResourceVersionNumber).ToString(); if (ResourceServiceOutcome.IsDeleted.HasValue && !ResourceServiceOutcome.IsDeleted.Value) { GetEntry.Response.LastModified = ResourceServiceOutcome.LastModified; } GetEntry.Response.Location = FormatResponseLocation(RequestMeta.PyroRequestUri.FhirRequestUri.OriginalString, ResourceServiceOutcome.FhirResourceId, ResourceServiceOutcome.ResourceVersionNumber); } return(true); } else { if (ResourceServiceOutcome.ResourceResult != null && ResourceServiceOutcome.ResourceResult is OperationOutcome Op) { IdentifieBatchEntityToClient(Op, GetEntry.FullUrl, "GET", GetEntryIndex); } _ServiceOperationOutcome = ResourceServiceOutcome; return(false); } }
public IResourceServiceOutcome Search(string BaseRequestUri, HttpRequestMessage Request, string ResourceName) { using (DbContextTransaction Transaction = IUnitOfWork.BeginTransaction()) { try { IRequestServiceRootValidate.Validate(BaseRequestUri); IRequestMeta RequestMeta = IRequestMetaFactory.CreateRequestMeta().Set(Request); IResourceServiceOutcome ResourceServiceOutcome = IResourceApiServices.GetSearch(RequestMeta); ResourceServiceOutcome.SummaryType = RequestMeta.SearchParameterGeneric.SummaryType; Transaction.Commit(); return(ResourceServiceOutcome); } catch (Exception Exec) { Transaction.Rollback(); ILog.Error(Exec, $"PyroService.Search, 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 Resource ResolveByCanonicalUri(string uri) { IRequestMeta RequestMeta = IRequestMetaFactory.CreateRequestMeta().Set($"{ResourceType.StructureDefinition.GetLiteral()}?url={uri}"); IResourceServiceOutcome ResourceServiceOutcome = IResourceServices.GetSearch(RequestMeta); if (ResourceServiceOutcome.ResourceResult != null && (ResourceServiceOutcome.ResourceResult as Bundle).Entry.Count > 1) { throw new System.Exception($"More than a single {ResourceType.StructureDefinition.GetLiteral()} instance was found with the Canonical Uri of {uri} at the endpoint {RequestMeta.PyroRequestUri.FhirRequestUri.OriginalString}."); } else if (ResourceServiceOutcome.ResourceResult != null && ResourceServiceOutcome.ResourceResult is Bundle bundle && bundle.Entry.Count == 1) { return(bundle.Entry[0].Resource); }
private List <Task> GetServerStartupTaskList() { var TaskResultList = new List <Task>(); string SearchQuery = string.Empty; try { //Get Tasks that are PyroFhirServer 'ServerStartupTask' tasks that have a status of Ready or InProgress or OnHold string IdentifierValue = string.Empty; foreach (var Id in _TaskIdentifierToRunList) { IdentifierValue += $",{IPyroFhirServerCodeSystem.GetSystem()}|{IPyroFhirServerCodeSystem.GetCode(Id)}"; } IdentifierValue = IdentifierValue.TrimStart(','); string SearchTaskIdentifier = $"identifier={IdentifierValue}"; string SearchTaskStatus = $"status={Task.TaskStatus.Ready.GetLiteral()},{Task.TaskStatus.InProgress.GetLiteral()},{Task.TaskStatus.OnHold.GetLiteral()}"; SearchQuery = $"{SearchTaskIdentifier}&{SearchTaskStatus}"; var RequestMeta = IRequestMetaFactory.CreateRequestMeta().Set($"{ResourceType.Task}?{SearchQuery}"); IResourceServiceOutcome PutResourceServiceOutcome = IResourceServices.GetSearch(RequestMeta); if (PutResourceServiceOutcome.HttpStatusCode == System.Net.HttpStatusCode.OK && PutResourceServiceOutcome.SuccessfulTransaction) { if (PutResourceServiceOutcome.ResourceResult != null && PutResourceServiceOutcome.ResourceResult is Bundle Bundle) { foreach (var Entry in Bundle.Entry) { if (Entry.Resource != null && Entry.Resource.ResourceType == ResourceType.Task) { TaskResultList.Add(Entry.Resource as Task); } } } } } catch (Exception Exec) { ILog.Error(Exec, $"Internal Server Error: Unable to load the list of Tasks of Tasks to process on Pyro Server Start-up. Search Query was: {ResourceType.Task.GetLiteral()}?{SearchQuery}"); } return(TaskResultList); }