public SupportedSearchParameterDefinitionManager(ISearchParameterDefinitionManager inner) { EnsureArg.IsNotNull(inner, nameof(inner)); _inner = inner; }
protected ParallelTaskWorker(TOptions options, int maxParallelism = 1) { _options = EnsureArg.IsNotNull(options, nameof(options)); _maxParallelism = EnsureArg.IsGt(maxParallelism, 0, nameof(maxParallelism)); }
public SearchParameterInfo(string name) { EnsureArg.IsNotNullOrWhiteSpace(name, nameof(name)); Name = name; }
public static string CompartmentTypeToResourceType(string compartmentType) { EnsureArg.IsTrue(Enum.IsDefined(typeof(CompartmentType), compartmentType), nameof(compartmentType)); return(compartmentType); }
/// <summary> /// Initializes a new instance of the class <see cref="FigureInfoFactory"/>. /// </summary> public FigureInfoFactory(IFigureInfoTypeProvider figureInfoTypeProvider) { _figureInfoTypeProvider = EnsureArg.IsNotNull(figureInfoTypeProvider, nameof(figureInfoTypeProvider)); }
public static Task <RetrieveMetadataResponse> RetrieveDicomInstanceMetadataAsync( this IMediator mediator, string studyInstanceUid, string seriesInstanceUid, string sopInstanceUid, string ifNoneMatch, CancellationToken cancellationToken) { EnsureArg.IsNotNull(mediator, nameof(mediator)); return(mediator.Send(new RetrieveMetadataRequest(studyInstanceUid, seriesInstanceUid, sopInstanceUid, ifNoneMatch), cancellationToken)); }
public NormalizationDataMappingException(Exception ex) : base(BuildMessage(ex), ex) { EnsureArg.IsNotNull(ex, nameof(ex)); }
/// <inheritdoc /> public ReferenceSearchValue Parse(string s) { EnsureArg.IsNotNullOrWhiteSpace(s, nameof(s)); Match match = ReferenceRegex.Match(s); if (match.Success) { string resourceTypeInString = match.Groups[ResourceTypeCapture].Value; ModelInfoProvider.EnsureValidResourceType(resourceTypeInString, nameof(s)); string resourceId = match.Groups[ResourceIdCapture].Value; int resourceTypeStartIndex = match.Groups[ResourceTypeCapture].Index; if (resourceTypeStartIndex == 0) { // This is relative URL. return(new ReferenceSearchValue( ReferenceKind.InternalOrExternal, null, resourceTypeInString, resourceId)); } Uri baseUri = null; try { baseUri = new Uri(s.Substring(0, resourceTypeStartIndex), UriKind.RelativeOrAbsolute); if (baseUri == _fhirRequestContextAccessor.FhirRequestContext.BaseUri) { // This is an absolute URL pointing to an internal resource. return(new ReferenceSearchValue( ReferenceKind.Internal, null, resourceTypeInString, resourceId)); } else if (baseUri.IsAbsoluteUri && SupportedSchemes.Contains(baseUri.Scheme, StringComparer.OrdinalIgnoreCase)) { // This is an absolute URL pointing to an external resource. return(new ReferenceSearchValue( ReferenceKind.External, baseUri, resourceTypeInString, resourceId)); } } catch (UriFormatException) { // The reference is not a relative reference but is not a valid absolute reference either. } } return(new ReferenceSearchValue( ReferenceKind.InternalOrExternal, baseUri: null, resourceType: null, resourceId: s)); }
/// <summary> /// Initializes a new instance of the <see cref="SearchParameterNotSupportedException"/> class. /// </summary> /// <param name="definitionUri">The search parameter definition URL.</param> public SearchParameterNotSupportedException(Uri definitionUri) { EnsureArg.IsNotNull(definitionUri, nameof(definitionUri)); AddIssue(string.Format(Core.Resources.SearchParameterByDefinitionUriNotSupported, definitionUri.ToString())); }
public SqlRootExpressionRewriter(NormalizedSearchParameterQueryGeneratorFactory normalizedSearchParameterQueryGeneratorFactory) { EnsureArg.IsNotNull(normalizedSearchParameterQueryGeneratorFactory, nameof(normalizedSearchParameterQueryGeneratorFactory)); _normalizedSearchParameterQueryGeneratorFactory = normalizedSearchParameterQueryGeneratorFactory; }
public ReferenceSearchValueParser(IFhirRequestContextAccessor fhirRequestContextAccessor) { EnsureArg.IsNotNull(fhirRequestContextAccessor, nameof(fhirRequestContextAccessor)); _fhirRequestContextAccessor = fhirRequestContextAccessor; }
protected override Observation MergeObservationImpl(CodeValueFhirTemplate template, IObservationGroup grp, Observation existingObservation) { EnsureArg.IsNotNull(grp, nameof(grp)); EnsureArg.IsNotNull(existingObservation, nameof(existingObservation)); existingObservation.Status = ObservationStatus.Amended; existingObservation.Category = null; if (template?.Category?.Count > 0) { existingObservation.Category = ResolveCategory(template.Category); } var values = grp.GetValues(); (DateTime start, DateTime end)observationPeriod = GetObservationPeriod(existingObservation); // Update observation value if (!string.IsNullOrWhiteSpace(template?.Value?.ValueName) && values.TryGetValue(template?.Value?.ValueName, out var obValues)) { existingObservation.Value = _valueProcessor.MergeValue(template.Value, CreateMergeData(grp.Boundary, observationPeriod, obValues), existingObservation.Value); } // Update observation component values if (template?.Components?.Count > 0) { if (existingObservation.Component == null) { existingObservation.Component = new List <Observation.ComponentComponent>(template.Components.Count); } foreach (var component in template.Components) { if (values.TryGetValue(component.Value.ValueName, out var compValues)) { var foundComponent = existingObservation.Component .Where(c => c.Code.Coding.Any(code => code.Code == component.Value.ValueName && code.System == FhirImportService.ServiceSystem)) .FirstOrDefault(); if (foundComponent == null) { existingObservation.Component.Add( new Observation.ComponentComponent { Code = ResolveCode(component.Value.ValueName, component.Codes), Value = _valueProcessor.CreateValue(component.Value, CreateMergeData(grp.Boundary, observationPeriod, compValues)), }); } else { foundComponent.Value = _valueProcessor.MergeValue(component.Value, CreateMergeData(grp.Boundary, observationPeriod, compValues), foundComponent.Value); } } } } // Update observation effective period if merge values exist outside the current period. if (grp.Boundary.Start < observationPeriod.start) { observationPeriod.start = grp.Boundary.Start; } if (grp.Boundary.End > observationPeriod.end) { observationPeriod.end = grp.Boundary.End; } existingObservation.Effective = observationPeriod.ToPeriod(); return(existingObservation); }
public CodeValueFhirTemplateProcessor(IFhirValueProcessor <IObservationData, Element> valueProcessor) { EnsureArg.IsNotNull(valueProcessor); _valueProcessor = valueProcessor; }
public MetadataResult(RetrieveMetadataResponse response) : base(EnsureArg.IsNotNull(response, nameof(response)).ResponseMetadata) { _response = response; }
public static Task <UpdateExtendedQueryTagResponse> UpdateExtendedQueryTagAsync( this IMediator mediator, string tagPath, UpdateExtendedQueryTagEntry newValue, CancellationToken cancellationToken) { EnsureArg.IsNotNull(mediator, nameof(mediator)); return(mediator.Send(new UpdateExtendedQueryTagRequest(tagPath, newValue), cancellationToken)); }
protected override bool CanReadType(Type type) { EnsureArg.IsNotNull(type, nameof(type)); return(typeof(Resource).IsAssignableFrom(type)); }
public static Task <StoreResponse> StoreDicomResourcesAsync( this IMediator mediator, Stream requestBody, string requestContentType, string studyInstanceUid, CancellationToken cancellationToken) { EnsureArg.IsNotNull(mediator, nameof(mediator)); return(mediator.Send(new StoreRequest(requestBody, requestContentType, studyInstanceUid), cancellationToken)); }
public AccessTokenProviderException(string message) : base(message) { EnsureArg.IsNotNullOrWhiteSpace(message, nameof(message)); }
public static Task <DeleteResourcesResponse> DeleteDicomSeriesAsync( this IMediator mediator, string studyInstanceUid, string seriesInstanceUid, CancellationToken cancellationToken = default) { EnsureArg.IsNotNull(mediator, nameof(mediator)); return(mediator.Send(new DeleteResourcesRequest(studyInstanceUid, seriesInstanceUid), cancellationToken)); }
public DevelopmentAuthEnvironmentConfigurationSource(string filePath) { EnsureArg.IsNotNullOrWhiteSpace(filePath, nameof(filePath)); _filePath = filePath; }
public CompartmentDefinitionManager(IModelInfoProvider modelInfoProvider) { EnsureArg.IsNotNull(modelInfoProvider, nameof(modelInfoProvider)); _modelInfoProvider = modelInfoProvider; }
/// <summary> /// Adds an in-process identity provider if enabled in configuration. /// </summary> /// <param name="services">The services collection.</param> /// <param name="configuration">The configuration root. The "DevelopmentIdentityProvider" section will be used to populate configuration values.</param> /// <returns>The same services collection.</returns> public static IServiceCollection AddDevelopmentIdentityProvider(this IServiceCollection services, IConfiguration configuration) { EnsureArg.IsNotNull(services, nameof(services)); EnsureArg.IsNotNull(configuration, nameof(configuration)); var authorizationConfiguration = new AuthorizationConfiguration(); configuration.GetSection("FhirServer:Security:Authorization").Bind(authorizationConfiguration); var developmentIdentityProviderConfiguration = new DevelopmentIdentityProviderConfiguration(); configuration.GetSection("DevelopmentIdentityProvider").Bind(developmentIdentityProviderConfiguration); services.AddSingleton(Options.Create(developmentIdentityProviderConfiguration)); if (developmentIdentityProviderConfiguration.Enabled) { services.AddIdentityServer() .AddDeveloperSigningCredential() .AddInMemoryApiResources(new[] { new ApiResource( DevelopmentIdentityProviderConfiguration.Audience, claimTypes: new List <string>() { authorizationConfiguration.RolesClaim, ClaimTypes.Name, ClaimTypes.NameIdentifier }) { UserClaims = { authorizationConfiguration.RolesClaim }, }, new ApiResource( WrongAudienceClient, claimTypes: new List <string>() { authorizationConfiguration.RolesClaim, ClaimTypes.Name, ClaimTypes.NameIdentifier }) { UserClaims = { authorizationConfiguration.RolesClaim }, }, }) .AddTestUsers(developmentIdentityProviderConfiguration.Users?.Select(user => new TestUser { Username = user.Id, Password = user.Id, IsActive = true, SubjectId = user.Id, Claims = user.Roles.Select(r => new Claim(authorizationConfiguration.RolesClaim, r)).ToList(), }).ToList()) .AddInMemoryClients( developmentIdentityProviderConfiguration.ClientApplications.Select( applicationConfiguration => new Client { ClientId = applicationConfiguration.Id, // client credentials and ROPC for testing AllowedGrantTypes = GrantTypes.ResourceOwnerPasswordAndClientCredentials, // secret for authentication ClientSecrets = { new Secret(applicationConfiguration.Id.Sha256()) }, // scopes that client has access to AllowedScopes = { DevelopmentIdentityProviderConfiguration.Audience, WrongAudienceClient }, // app roles that the client app may have Claims = applicationConfiguration.Roles.Select(r => new Claim(authorizationConfiguration.RolesClaim, r)).Concat(new[] { new Claim("appid", applicationConfiguration.Id) }).ToList(), ClientClaimsPrefix = string.Empty, })); } return(services); }
private static Dictionary <CompartmentType, (CompartmentType, Uri, IList <(string, IList <string>)>)> ValidateAndGetCompartmentDict(BundleWrapper bundle) { EnsureArg.IsNotNull(bundle, nameof(bundle)); var issues = new List <OperationOutcomeIssue>(); var validatedCompartments = new Dictionary <CompartmentType, (CompartmentType, Uri, IList <(string, IList <string>)>)>(); IReadOnlyList <BundleEntryWrapper> entries = bundle.Entries; for (int entryIndex = 0; entryIndex < entries.Count; entryIndex++) { // Make sure resources are not null and they are Compartment. BundleEntryWrapper entry = entries[entryIndex]; var compartment = entry.Resource; if (compartment == null || !string.Equals(KnownResourceTypes.CompartmentDefinition, compartment.InstanceType, StringComparison.Ordinal)) { AddIssue(Core.Resources.CompartmentDefinitionInvalidResource, entryIndex); continue; } string code = compartment.Scalar("code")?.ToString(); string url = compartment.Scalar("url")?.ToString(); if (code == null) { AddIssue(Core.Resources.CompartmentDefinitionInvalidCompartmentType, entryIndex); continue; } CompartmentType typeCode = EnumUtility.ParseLiteral <CompartmentType>(code).GetValueOrDefault(); if (validatedCompartments.ContainsKey(typeCode)) { AddIssue(Core.Resources.CompartmentDefinitionIsDupe, entryIndex); continue; } if (string.IsNullOrWhiteSpace(url) || !Uri.IsWellFormedUriString(url, UriKind.Absolute)) { AddIssue(Core.Resources.CompartmentDefinitionInvalidUrl, entryIndex); continue; } var resources = compartment.Select("resource") .Select(x => (x.Scalar("code")?.ToString(), (IList <string>)x.Select("param").AsStringValues().ToList())) .ToList(); var resourceNames = resources.Select(x => x.Item1).ToArray(); if (resourceNames.Length != resourceNames.Distinct().Count()) { AddIssue(Core.Resources.CompartmentDefinitionDupeResource, entryIndex); continue; } validatedCompartments.Add( typeCode, (typeCode, new Uri(url), new List <(string, IList <string>)>(resources))); } if (issues.Count != 0) { throw new InvalidDefinitionException( Core.Resources.CompartmentDefinitionContainsInvalidEntry, issues.ToArray()); } return(validatedCompartments); void AddIssue(string format, params object[] args) { issues.Add(new OperationOutcomeIssue( OperationOutcomeConstants.IssueSeverity.Fatal, OperationOutcomeConstants.IssueType.Invalid, string.Format(CultureInfo.InvariantCulture, format, args))); } }
public static Task <AddExtendedQueryTagResponse> AddExtendedQueryTagsAsync( this IMediator mediator, IEnumerable <AddExtendedQueryTagEntry> extendedQueryTags, CancellationToken cancellationToken) { EnsureArg.IsNotNull(mediator, nameof(mediator)); return(mediator.Send(new AddExtendedQueryTagRequest(extendedQueryTags), cancellationToken)); }
public CustomerConsoleCommandEventHandler(IMediator mediator) { EnsureArg.IsNotNull(mediator, nameof(mediator)); this.mediator = mediator; }
public static Task <GetExtendedQueryTagResponse> GetExtendedQueryTagAsync( this IMediator mediator, string extendedQueryTagPath, CancellationToken cancellationToken) { EnsureArg.IsNotNull(mediator, nameof(mediator)); return(mediator.Send(new GetExtendedQueryTagRequest(extendedQueryTagPath), cancellationToken)); }
public static bool IsSortSupported(this SearchParameterInfo searchParameterInfo) { EnsureArg.IsNotNull(searchParameterInfo, nameof(searchParameterInfo)); return(supportedSortParameters.Contains(searchParameterInfo.Name)); }
public static Task <GetExtendedQueryTagErrorsResponse> GetExtendedQueryTagErrorsAsync( this IMediator mediator, string extendedQueryTagPath, int limit, int offset, CancellationToken cancellationToken) { EnsureArg.IsNotNull(mediator, nameof(mediator)); return(mediator.Send(new GetExtendedQueryTagErrorsRequest(extendedQueryTagPath, limit, offset), cancellationToken)); }
public CompartmentDefinitionManager(FhirJsonParser fhirJsonParser) { EnsureArg.IsNotNull(fhirJsonParser, nameof(fhirJsonParser)); _fhirJsonParser = fhirJsonParser; }
protected internal override void AcceptVisitor(IExpressionVisitor visitor) { EnsureArg.IsNotNull(visitor, nameof(visitor)); visitor.Visit(this); }