Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NET 9 upgrade #15

Merged
merged 5 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Client/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@
#endregion

using Blazored.LocalStorage;
using BQuery;
using Hl7.Fhir.FhirPath;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.FluentUI.AspNetCore.Components;
using MudBlazor.Services;
using UdapEd.Client.Services;
using UdapEd.Client.Services.Search;
using UdapEd.Shared;
using UdapEd.Shared.Services;
using UdapEd.Shared.Services.Search;
using CdsService = UdapEd.Client.Services.CdsService;


var builder = WebAssemblyHostBuilder.CreateDefault(args);
Expand All @@ -43,8 +44,10 @@
builder.Services.AddSingleton<ICapabilityLookup, CapabilityLookup>();
builder.Services.AddScoped<IClipboardService, ClipboardService>();
builder.Services.AddScoped<IMutualTlsService, MutualTlsService>();
builder.Services.AddScoped<ICdsService, CdsService>();
builder.Services.AddFluentUIComponents();

// Add this so that the resolve() extension will be available when including in FhirPath
Hl7.FhirPath.FhirPathCompiler.DefaultSymbolTable.AddFhirExtensions();

await builder.Build().UseBQuery().RunAsync();
await builder.Build().RunAsync();
45 changes: 45 additions & 0 deletions Client/Services/CdsService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#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.Net.Http.Json;
using System.Text.Json;
using Udap.CdsHooks.Model;
using UdapEd.Shared.Model.CdsHooks;
using UdapEd.Shared.Services;

namespace UdapEd.Client.Services;

public class CdsService : ICdsService
{
private readonly HttpClient _httpClient;

private static JsonSerializerOptions jsonOptions = new JsonSerializerOptions()
{
PropertyNameCaseInsensitive = true,
Converters = { new FhirResourceConverter() }
};

public CdsService(HttpClient httpClient)
{
_httpClient = httpClient;
}

public Task<List<CdsServiceViewModel>?> FetchCdsServices()
{
return _httpClient.GetFromJsonAsync<List<CdsServiceViewModel>> ("CdsServices/FetchCdsServices");
}

public async Task<CdsResponse?> GetCdsService(CdsRequest request)
{
var response = await _httpClient.PostAsJsonAsync("CdsServices/GetCdsService", request, jsonOptions);
var cdsResponses = await response.Content.ReadFromJsonAsync<CdsResponse>();

return cdsResponses;
}
}
121 changes: 121 additions & 0 deletions Client/Services/FhirService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,127 @@ public async Task<FhirResultModel<Bundle>> SearchPost(SearchForm searchForm)
return await SearchHandler(response);
}

public async Task<FhirResultModel<Resource>> Get(string resourcePath)
{
var controller = await GetControllerPath();
var response = await _httpClient.PostAsJsonAsync($"{controller}/Get", resourcePath);
return await GetHandler(response);
}

private async Task<FhirResultModel<Resource>> GetHandler(HttpResponseMessage response)
{
if (response.IsSuccessStatusCode)
{
var result = await response.Content.ReadAsStringAsync();
var resource = new FhirJsonParser().Parse<Resource>(result);


if (resource is OperationOutcome operationOutcome)
{
return new FhirResultModel<Hl7.Fhir.Model.Resource>(operationOutcome);
}

return new FhirResultModel<Hl7.Fhir.Model.Resource>(resource);
}

return await HandleGetResponseError(response);
}

private static async Task<FhirResultModel<Resource>> HandleGetResponseError(HttpResponseMessage response)
{
if (response.StatusCode == HttpStatusCode.Unauthorized)
{
return new FhirResultModel<Resource>(true);
}

if (response.StatusCode == HttpStatusCode.InternalServerError)
{
var result = await response.Content.ReadAsStringAsync();

if (result.Contains(nameof(UriFormatException)))
{
var operationOutCome = new OperationOutcome()
{
ResourceBase = null,
Issue =
[
new OperationOutcome.IssueComponent
{
Diagnostics = result
}
]
};

return new FhirResultModel<Resource>(operationOutCome, HttpStatusCode.PreconditionFailed, response.Version);
}

if (result.Contains(nameof(AuthenticationException)))
{
var operationOutCome = new OperationOutcome()
{
ResourceBase = null,
Issue =
[
new OperationOutcome.IssueComponent
{
Diagnostics = result
}
]
};

return new FhirResultModel<Resource>(operationOutCome, HttpStatusCode.Unauthorized, response.Version);
}
}

if (response.StatusCode == HttpStatusCode.MethodNotAllowed)
{
var operationOutCome = new OperationOutcome()
{
ResourceBase = null,
Issue =
[
new OperationOutcome.IssueComponent
{
Diagnostics = "UdapEd does not have a endpoint for this request yet"
}
]
};

return new FhirResultModel<Resource>(operationOutCome, HttpStatusCode.MethodNotAllowed, response.Version);
}

//todo constant :: and this whole routine is ugly. Should move logic upstream to controller
//This code exists from testing various FHIR servers like MEDITECH.
if (response.StatusCode == HttpStatusCode.NotFound)
{
var result = await response.Content.ReadAsStringAsync();

if (result.Contains("Resource Server Error:"))
{
var operationOutCome = new OperationOutcome()
{
ResourceBase = null,
Issue =
[
new OperationOutcome.IssueComponent
{
Diagnostics = result
}
]
};

return new FhirResultModel<Resource>(operationOutCome, HttpStatusCode.InternalServerError,
response.Version);
}
}

{
var result = await response.Content.ReadAsStringAsync();
var operationOutcome = new FhirJsonParser().Parse<OperationOutcome>(result);

return new FhirResultModel<Resource>(operationOutcome, response.StatusCode, response.Version);
}
}
private async Task<FhirResultModel<Bundle>> SearchHandler(HttpResponseMessage response)
{
if (response.IsSuccessStatusCode)
Expand Down
31 changes: 8 additions & 23 deletions Client/UdapEd.Client.csproj
Original file line number Diff line number Diff line change
@@ -1,41 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<PublishTrimmed>false</PublishTrimmed>
</PropertyGroup>


<ItemGroup>
<None Include="..\..\..\..\artwork\UDAP_Ecosystem_Gears 48X48.jpg" Link="UDAP_Ecosystem_Gears 48X48.jpg">
<PackagePath>\</PackagePath>
<Pack>true</Pack>
</None>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Blazored.LocalStorage" Version="4.5.0" />
<PackageReference Include="BQuery" Version="3.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.8" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="8.0.8" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="MudBlazor" Version="7.8.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="9.0.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.0" />
<PackageReference Include="MudBlazor" Version="7.15.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Shared\UdapEd.Shared.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Udap.Common" Version="0.3.87" />
<PackageReference Include="Udap.CdsHooks.Model" Version="0.4.0" />
<PackageReference Include="Udap.Common" Version="0.4.0" />
</ItemGroup>

<!-- From:: https://jonhilton.net/visual-studio-2022-blazor-css-intellisense/ -->
<Target Name="CollectMudBlazorStaticAssets" DependsOnTargets="ResolveStaticWebAssetsInputs" AfterTargets="Build" Condition=" '$(Configuration)' == 'Debug' ">
<Copy SourceFiles="%(StaticWebAsset.Identity)" DestinationFolder="wwwroot/temp" Condition="$([System.String]::Copy(%(StaticWebAsset.Identity)).Contains('mudblazor'))" />
</Target>

</Project>
</Project>
1 change: 0 additions & 1 deletion Client/_Imports.razor
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@
@* @using Udap.Model *@
@* @using UdapEd.Shared.Model *@
@* @using System.Reflection *@
@* @using BQuery *@
@* @using UdapEd.Shared *@
3 changes: 2 additions & 1 deletion Client/wwwroot/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" rel="stylesheet" />
<link href="_content/MudBlazor/MudBlazor.min.css" rel="stylesheet" />
<link href="_content/UdapEd.Shared/css/app.css" rel="stylesheet" asp-append-version="true" />
<link href="_content/UdapEd.Shared/css/cds.css" rel="stylesheet" asp-append-version="true" />
<link href="css/monaco.css" rel="stylesheet" />
<link rel="icon" type="image/png" href="favicon.png" />
<!-- <link href="UdapEd.Client.styles.css" rel="stylesheet" /> -->
Expand All @@ -30,9 +31,9 @@
</div>
<script src="_framework/blazor.webassembly.js"></script>
<script src="_content/MudBlazor/MudBlazor.min.js"></script>
<script src="_content/BQuery/bQuery.min.js"></script>
<script src="_content/UdapEd.Shared/scripts/AutoFocus.js"></script>
<script src="_content/UdapEd.Shared/scripts/UdapEdUtility.js"></script>
<script src="_content/UdapEd.Shared/scripts/EventHandlers.js"></script>

<script src="_content/BlazorMonaco/jsInterop.js"></script>
<script src="_content/BlazorMonaco/lib/monaco-editor/min/vs/loader.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion Client/wwwroot/temp/MudBlazor.min.css

Large diffs are not rendered by default.

Loading
Loading