-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from JoeShook/main
Package updates and CDS Hooks
- Loading branch information
Showing
244 changed files
with
4,586 additions
and
2,957 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
Oops, something went wrong.