public byte[] SerializeToJsonBytes(Common.FhirTools.FhirResource fhirResource) { return(fhirResource.FhirVersion switch { Common.Enums.FhirVersion.Stu3 => IStu3SerializationToJsonBytes.SerializeToJsonBytes(fhirResource), Common.Enums.FhirVersion.R4 => IR4SerializationToJsonBytes.SerializeToJsonBytes(fhirResource), _ => throw new FhirVersionFatalException(fhirResource.FhirVersion), });
/// <summary> /// Get at OperationOutcome with a issue status of Information: The issue has no relation to the degree of success of the action. /// </summary> /// <param name="fhirMajorVersion"></param> /// <param name="errorMessages"></param> /// <returns></returns> public Common.FhirTools.FhirResource GetInformation(Common.Enums.FhirVersion fhirMajorVersion, string[] errorMessages) { switch (fhirMajorVersion) { case Common.Enums.FhirVersion.Stu3: var Stu3Tool = IOperationOutcomeSupportFactory.GetStu3(); var Stu3FhirResource = new Common.FhirTools.FhirResource(fhirMajorVersion); Stu3FhirResource.Stu3 = Stu3Tool.GetInformation(errorMessages); return(Stu3FhirResource); case Common.Enums.FhirVersion.R4: var R4Tool = IOperationOutcomeSupportFactory.GetR4(); var R4FhirResource = new Common.FhirTools.FhirResource(fhirMajorVersion); R4FhirResource.R4 = R4Tool.GetInformation(errorMessages); return(R4FhirResource); default: throw new FhirVersionFatalException(fhirMajorVersion); } }
public UpdateQuery(HttpVerb HttpVerb, Common.Enums.FhirVersion FhirVersion, Uri RequestUri, Dictionary <string, StringValues> RequestQuery, Dictionary <string, StringValues> HeaderDictionary, string ResourceName, string ResourceId, Common.FhirTools.FhirResource FhirResource) : base(HttpVerb, FhirVersion, RequestUri, RequestQuery, HeaderDictionary, ResourceName, ResourceId) { this.FhirResource = FhirResource; }
public async Task <IndexerOutcome> Process(Common.FhirTools.FhirResource fhirResource, Bug.Common.Enums.ResourceType resourceType) { var IndexerOutcome = new IndexerOutcome(); List <SearchParameter> SearchParameterList = await ISearchParameterCache.GetForIndexingAsync(fhirResource.FhirVersion, resourceType); foreach (SearchParameter SearchParameter in SearchParameterList) { //Composite searchParameters do not require populating as they are a Composite of other SearchParameter Types //searchParameters with an empty or null FHIRPath can not be indexed, this is true for _query and _content which //in my view should not be searchParameter, just as _sort or _count are not. if (SearchParameter.SearchParamTypeId != Common.Enums.SearchParamType.Composite && !string.IsNullOrWhiteSpace(SearchParameter.FhirPath)) { IEnumerable <ITypedElement>?ResultList; try { ResultList = ITypedElementSupport.Select(fhirResource, SearchParameter.FhirPath); } catch (Exception Exec) { throw new Bug.Common.Exceptions.FhirFatalException(System.Net.HttpStatusCode.InternalServerError, $"Error indexing the FhirPath select expression for the SearchParameter with the name of : {SearchParameter.Name} for a resource type of : {resourceType.GetCode()} with the SearchParameter database primary key of {SearchParameter.Id.ToString()}. The FhirPath expression was : {SearchParameter.FhirPath}. See inner exception for more info.", Exec); } //This null check of ResultList is only here due to the exception issue above. if (ResultList is object) { foreach (ITypedElement TypedElement in ResultList) { if (TypedElement != null) { switch (SearchParameter.SearchParamTypeId) { case Common.Enums.SearchParamType.Number: IndexerOutcome.QuantityIndexList.AddRange(INumberSetterSupport.Set(fhirResource.FhirVersion, TypedElement, resourceType, SearchParameter.Id, SearchParameter.Name)); break; case Common.Enums.SearchParamType.Date: IndexerOutcome.DateTimeIndexList.AddRange(IDateTimeSetterSupport.Set(fhirResource.FhirVersion, TypedElement, resourceType, SearchParameter.Id, SearchParameter.Name)); break; case Common.Enums.SearchParamType.String: IndexerOutcome.StringIndexList.AddRange(IStringSetterSupport.Set(fhirResource.FhirVersion, TypedElement, resourceType, SearchParameter.Id, SearchParameter.Name)); break; case Common.Enums.SearchParamType.Token: IndexerOutcome.TokenIndexList.AddRange(ITokenSetterSupport.Set(fhirResource.FhirVersion, TypedElement, resourceType, SearchParameter.Id, SearchParameter.Name)); break; case Common.Enums.SearchParamType.Reference: IndexerOutcome.ReferenceIndexList.AddRange(await IReferenceSetterSupport.SetAsync(fhirResource.FhirVersion, TypedElement, resourceType, SearchParameter.Id, SearchParameter.Name)); break; case Common.Enums.SearchParamType.Composite: //Composite searchParameters do not require populating as they are a Composite of other SearchParameter Types break; case Common.Enums.SearchParamType.Quantity: IndexerOutcome.QuantityIndexList.AddRange(IQuantitySetterSupport.Set(fhirResource.FhirVersion, TypedElement, resourceType, SearchParameter.Id, SearchParameter.Name)); break; case Common.Enums.SearchParamType.Uri: IndexerOutcome.UriIndexList.AddRange(IUriSetterSupport.Set(fhirResource.FhirVersion, TypedElement, resourceType, SearchParameter.Id, SearchParameter.Name)); break; case Common.Enums.SearchParamType.Special: string SpecialMessage = $"Encountered a search parameter of type: {Common.Enums.SearchParamType.Special.GetCode()} which is not supported by the server. " + $"The search parameter had the name of : {SearchParameter.Name} with a SearchParameter database primary key of {SearchParameter.Id.ToString()}. The " + $"resource type being processed was of type : {resourceType.GetCode()}"; this.ILogger.LogWarning(SpecialMessage); break; default: throw new Bug.Common.Exceptions.FhirFatalException(System.Net.HttpStatusCode.InternalServerError, $"Internal Server Error: Encountered an unknown SearchParamType of type {SearchParameter.SearchParamTypeId.GetCode()}"); } } } } } } return(IndexerOutcome); }
public UpdateResource(Common.FhirTools.FhirResource FhirResource) { this.FhirResource = FhirResource; }