Skip to content

Commit

Permalink
Merge pull request #34 from JoeShook/main
Browse files Browse the repository at this point in the history
Package updates and CDS Hooks
  • Loading branch information
JoeShook authored Nov 5, 2024
2 parents bce3a35 + 9845a8b commit cb1e068
Show file tree
Hide file tree
Showing 244 changed files with 4,586 additions and 2,957 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "8.0.8",
"version": "8.0.10",
"commands": [
"dotnet-ef"
]
Expand Down
101 changes: 101 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
[*.cs]
dotnet_diagnostic.IDE0028.severity = none
dotnet_diagnostic.IDE0290.severity = none
dotnet_diagnostic.IDE0090.severity = none
dotnet_diagnostic.IDE0019.severity = none
dotnet_diagnostic.IDE0039.severity = none
dotnet_diagnostic.IDE0083.severity = none
dotnet_diagnostic.IDE0057.severity = none
dotnet_diagnostic.IDE0305.severity = none
dotnet_diagnostic.IDE0301.severity = none
dotnet_diagnostic.CA2208.severity = none
csharp_using_directive_placement = outside_namespace:silent
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_braces = true:silent
csharp_style_namespace_declarations = file_scoped:silent
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_style_prefer_primary_constructors = true:suggestion
csharp_style_expression_bodied_methods = false:silent
csharp_style_expression_bodied_constructors = false:silent
csharp_style_expression_bodied_operators = false:silent
csharp_style_expression_bodied_properties = true:silent
csharp_style_expression_bodied_indexers = true:silent
csharp_style_expression_bodied_accessors = true:silent
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent
csharp_style_throw_expression = true:suggestion
csharp_style_prefer_null_check_over_type_check = true:suggestion
csharp_prefer_simple_default_expression = true:suggestion
csharp_style_prefer_local_over_anonymous_function = true:suggestion
csharp_style_prefer_index_operator = true:suggestion
csharp_style_prefer_range_operator = true:suggestion
csharp_indent_labels = one_less_than_current
csharp_space_around_binary_operators = before_and_after
[*.{cs,vb}]
#### Naming styles ####

# Naming rules

dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i

dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case

dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case

# Symbol specifications

dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.interface.required_modifiers =

dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.types.required_modifiers =

dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.non_field_members.required_modifiers =

# Naming styles

dotnet_naming_style.begins_with_i.required_prefix = I
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.capitalization = pascal_case

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
dotnet_style_prefer_auto_properties = true:silent
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
dotnet_style_prefer_conditional_expression_over_return = true:silent
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_compound_assignment = true:suggestion
dotnet_style_prefer_simplified_interpolation = true:suggestion
dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion
dotnet_style_namespace_match_folder = true:suggestion
dotnet_style_operator_placement_when_wrapping = beginning_of_line
tab_width = 4
indent_size = 4
end_of_line = crlf
7 changes: 7 additions & 0 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ jobs:
dotnet pack -v normal -c Release --include-source -p:PackageVersion=${VERSION} ./Udap.Smart.Model/Udap.Smart.Model.csproj
dotnet pack -v normal -c Release --include-source -p:PackageVersion=${VERSION} ./Udap.Smart.Metadata/Udap.Smart.Metadata.csproj
dotnet pack -v normal -c Release --include-source -p:PackageVersion=${VERSION} ./Udap.CdsHooks.Endpoint/Udap.CdsHooks.Endpoint.csproj
dotnet pack -v normal -c Release --include-source -p:PackageVersion=${VERSION} ./Udap.CdsHooks.Model/Udap.CdsHooks.Model.csproj
- name: Push
run: |
dotnet nuget push ./Udap.Model/bin/Release/*.symbols.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
Expand All @@ -48,3 +52,6 @@ jobs:
dotnet nuget push ./Udap.Smart.Model/bin/Release/*.symbols.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
dotnet nuget push ./Udap.Smart.Metadata/bin/Release/*.symbols.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
dotnet nuget push ./Udap.CdsHooks.Endpoint/bin/Release/*.symbols.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
dotnet nuget push ./Udap.CdsHooks.Model/bin/Release/*.symbols.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
7 changes: 7 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ jobs:
dotnet pack -v normal -c Release --include-source -p:PackageVersion=${VERSION} ./Udap.Smart.Model/Udap.Smart.Model.csproj
dotnet pack -v normal -c Release --include-source -p:PackageVersion=${VERSION} ./Udap.Smart.Metadata/Udap.Smart.Metadata.csproj
dotnet pack -v normal -c Release --include-source -p:PackageVersion=${VERSION} ./Udap.CdsHooks.Endpoint/Udap.CdsHooks.Endpoint.csproj
dotnet pack -v normal -c Release --include-source -p:PackageVersion=${VERSION} ./Udap.CdsHooks.Model/Udap.CdsHooks.Model.csproj
- name: Push
run: |
dotnet nuget push ./Udap.Model/bin/Release/*.symbols.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
Expand All @@ -48,6 +52,9 @@ jobs:
dotnet nuget push ./Udap.Smart.Model/bin/Release/*.symbols.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
dotnet nuget push ./Udap.Smart.Metadata/bin/Release/*.symbols.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
dotnet nuget push ./Udap.CdsHooks.Endpoint/bin/Release/*.symbols.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
dotnet nuget push ./Udap.CdsHooks.Model/bin/Release/*.symbols.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
31 changes: 16 additions & 15 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,31 @@
</PropertyGroup>
<ItemGroup>
<!-- https://learn.microsoft.com/en-us/nuget/concepts/package-versioning#version-ranges -->
<PackageVersion Include="Duende.IdentityServer.Storage" Version="7.0.6" />
<PackageVersion Include="Duende.IdentityServer.Storage" Version="7.0.8" />
<PackageVersion Include="Google.Apis.Auth" Version="1.68.0" />
<PackageVersion Include="Hl7.Fhir.R4B" Version="5.9.1" />
<PackageVersion Include="Hl7.Fhir.Base" Version="5.10.3" />
<PackageVersion Include="Hl7.Fhir.R4B" Version="5.10.3" />
<PackageVersion Include="LazyCache" Version="2.4.0" />
<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="[6.0.32,8.0.8]" />
<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="[6.0.32,8.0.10]" />
<PackageVersion Include="AspNetCoreRateLimit" Version="5.0.0" />
<PackageVersion Include="Hl7.Fhir.Specification.R4B" Version="5.9.1" />
<PackageVersion Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.8" />
<PackageVersion Include="Microsoft.AspNetCore.DataProtection.Abstractions" Version="8.0.8" />
<PackageVersion Include="Microsoft.AspNetCore.DataProtection.EntityFrameworkCore" Version="8.0.8" />
<PackageVersion Include="Hl7.Fhir.Specification.R4B" Version="5.10.3" />
<PackageVersion Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.10" />
<PackageVersion Include="Microsoft.AspNetCore.DataProtection.Abstractions" Version="8.0.10" />
<PackageVersion Include="Microsoft.AspNetCore.DataProtection.EntityFrameworkCore" Version="8.0.10" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.2" />
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.2" />
<PackageVersion Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageVersion Include="MSTest.TestFramework" Version="3.1.1" />
<PackageVersion Include="IdentityModel" Version="7.0.0" />
<!-- <PackageVersion Include="System.Text.Json" Version="[6.0.7,8.0.3]" /> -->
<PackageVersion Include="AutoMapper" Version="13.0.1" />
<PackageVersion Include="Duende.IdentityServer" Version="7.0.6" />
<PackageVersion Include="Duende.IdentityServer.AspNetIdentity" Version="7.0.6" />
<PackageVersion Include="Duende.IdentityServer.EntityFramework.Storage" Version="7.0.6" />
<PackageVersion Include="Duende.IdentityServer" Version="7.0.8" />
<PackageVersion Include="Duende.IdentityServer.AspNetIdentity" Version="7.0.8" />
<PackageVersion Include="Duende.IdentityServer.EntityFramework.Storage" Version="7.0.8" />
<PackageVersion Include="IdentityModel.AspNetCore.OAuth2Introspection" Version="6.2.0" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="8.0.8" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="8.0.10" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="[7.0.13,8.0.1]" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="[7.0.13,8.0.0]" />
<PackageVersion Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
Expand All @@ -37,7 +38,7 @@
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="[6.0.0,7.0.1]" />
<PackageVersion Include="Microsoft.Extensions.Options" Version="8.0.2" />
<PackageVersion Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
<PackageVersion Include="Microsoft.IdentityModel.JsonWebTokens" Version="8.0.2" />
<PackageVersion Include="Microsoft.IdentityModel.JsonWebTokens" Version="8.2.0" />
<PackageVersion Include="OpenTelemetry" Version="1.9.0" />
<PackageVersion Include="OpenTelemetry.Exporter.Console" Version="1.9.0" />
<PackageVersion Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.9.0" />
Expand All @@ -48,7 +49,7 @@
<PackageVersion Include="Serilog.AspNetCore" Version="[6.1.0,7.0.0]" />
<PackageVersion Include="Serilog.Extensions.Logging" Version="[3.1.0,7.0.0]" />
<PackageVersion Include="Portable.BouncyCastle" Version="1.9.0" />
<PackageVersion Include="System.IdentityModel.Tokens.Jwt" Version="8.0.2" />
<PackageVersion Include="System.IdentityModel.Tokens.Jwt" Version="8.2.0" />
<PackageVersion Include="Udap.Metadata.Server" Version="0.3.24" />
<PackageVersion Include="Yarp.ReverseProxy" Version="2.1.0" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# udap-dotnet

UDAP reference implementation for .NET.
UDAP SDK and reference implementation for .NET.

In short UDAP is a PKI extension profile to OAuth2. One or more PKIs can be hosted by a `Community`. Joining a `Community` results in a public/private key issued to a client. The client also chooses to explicitly trust one of the issuing certificates in that chain by installing in your client. In addition, all certificate chain validation including certificate revocation to a trusted root are performed.

Expand Down
96 changes: 96 additions & 0 deletions Udap.CdsHooks.Endpoint/CdsHooksEndpoint.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#region (c) 2024 Joseph Shook. All rights reserved.
// /*
// Authors:
// Joseph Shook [email protected]
//
// See LICENSE in the project root for license information.
// */
#endregion

using System.Text.Json;
using Hl7.Fhir.Model;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Udap.CdsHooks.Model;
using Task = System.Threading.Tasks.Task;

namespace Udap.CdsHooks.Endpoint;

/// <summary>
/// See <a href="https://cds-hooks.org/quickstart/#endpoint-for-discovery">CDS Hooks Endpoint for discovery</a>
/// </summary>
public class CdsHooksEndpoint
{
private readonly IOptionsMonitor<CdsServices>? _cdsService;
private readonly ILogger<CdsHooksEndpoint> _logger;
private JsonSerializerOptions jsonSerializerOptions = new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true,
Converters = { new FhirResourceConverter() }
};

public CdsHooksEndpoint(IOptionsMonitor<CdsServices>? cdsService, ILogger<CdsHooksEndpoint> logger)
{
_cdsService = cdsService;
_logger = logger;
}

public Task<IResult> Process()
{
if (_cdsService == null)
{
return Task.FromResult(Results.NotFound());
}

return Task.FromResult(Results.Ok(_cdsService.CurrentValue));
}

public async Task<IResult> ProcessPost(HttpRequest request)
{
if (_cdsService == null)
{
return Results.NotFound();
}

// Read the request body
using var reader = new StreamReader(request.Body);
var requestBody = await reader.ReadToEndAsync();

// Deserialize the request body to a JSON object
var cdsRequest = JsonSerializer.Deserialize<CdsRequest>(requestBody, jsonSerializerOptions);

// Serialize it back with indentation
var indentedJson = JsonSerializer.Serialize(cdsRequest, new JsonSerializerOptions { WriteIndented = true });

// Log the indented JSON
_logger.LogDebug(indentedJson);
// Process the request body as needed
// For example, you might deserialize it to a specific model
// var model = JsonSerializer.Deserialize<YourModel>(requestBody);

// Return an appropriate response
var patient = cdsRequest?.Prefetch?["patient"] as Patient;

var card = new CdsCard()
{
Uuid = Guid.NewGuid().ToString(),
Summary = "Patient Greeting",
Indicator = "info",
Detail = $"Hello, {patient?.Name[0].Given.First()}",
Source = new CdsSource()
{
Label = "UDAP CDS Service",
Url = new Uri("https://fhirlabs.net/fhir/r4")
}

};

var response = new CdsResponse()
{
Cards = new List<CdsCard> { card }
};

return Results.Ok(response);
}
}
Loading

0 comments on commit cb1e068

Please sign in to comment.