chore: deploy initial code base
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
namespace Strata.RxNorm.Client.FactNdcDeatils
|
||||
{
|
||||
public class FactNdcDetail
|
||||
{
|
||||
public string NdcCode { get; set; }
|
||||
public string BrandCode { get; set; }
|
||||
public string BrandDescription { get; set; }
|
||||
public string DoseFormCode { get; set; }
|
||||
public string DoseFormDescription { get; set; }
|
||||
public string BrandedClinicalDrugCode { get; set; }
|
||||
public string BrandedClinicalDrugDescription { get; set; }
|
||||
public string SemanticClinicalDrugCode { get; set; }
|
||||
public string SemanticClinicalDrugDescription { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using Strata.RxNorm.Client.FactNdcDeatils;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Strata.RxNorm.Client
|
||||
{
|
||||
public interface IRxNormService
|
||||
{
|
||||
Task<FactNdcDetail> GetAsync(string ndc, CancellationToken cancellationToken = default);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using Strata.ApiCommunication.Http;
|
||||
using Strata.RxNorm.Client.FactNdcDeatils;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Strata.RxNorm.Client
|
||||
{
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class RxNormService : IRxNormService
|
||||
{
|
||||
private readonly HttpClient _httpClient;
|
||||
|
||||
public RxNormService(HttpClient httpClient)
|
||||
{
|
||||
_httpClient = httpClient;
|
||||
}
|
||||
|
||||
public async Task<FactNdcDetail> GetAsync(string ndc, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, $"api/v1/rx-norm/{ndc}/ndc");
|
||||
return await _httpClient.SendAsync<FactNdcDetail>(request, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
|
||||
#if NETCOREAPP
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Strata.RxNorm.Client;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace Microsoft.Extensions.DependencyInjection
|
||||
{
|
||||
[ExcludeFromCodeCoverage]
|
||||
public static class RxNormServiceCollectionExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Registers an instance of an <see cref="IRxNormService"/> to the given <see cref="IServiceCollection"/>
|
||||
/// </summary>
|
||||
/// <returns>An <see cref="IHttpClientBuilder"/> that can be used to configure the client.</returns>
|
||||
public static IHttpClientBuilder AddRxNormService(this IServiceCollection services)
|
||||
{
|
||||
return services.AddHttpClientWithStrataHandlers<IRxNormService, RxNormService>((provider, client) =>
|
||||
{
|
||||
var config = provider.GetService<IConfiguration>();
|
||||
|
||||
var endpoint = config.GetValue<string>("endPoints:rxnorm");
|
||||
if (string.IsNullOrWhiteSpace(endpoint))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Endpoint for the RxNorm service was not found in the configuration with the key of 'endPoints:rxnorm'");
|
||||
}
|
||||
|
||||
client.BaseAddress = new Uri(endpoint);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;netstandard2.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Strata.ApiCommunication.Http" Version="7.0.4" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user