зеркало из https://github.com/microsoft/Graphir.git
Merge pull request #28 from nirzaf/main
Project updated From .NET 5 to .NET 6 and related NuGet packages updated
This commit is contained in:
Коммит
334d42ce96
|
@ -1,17 +1,17 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UserSecretsId>ec15c71b-620a-4186-aa44-53f511572277</UserSecretsId>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Hl7.Fhir.R4" Version="3.7.0" />
|
||||
<PackageReference Include="HotChocolate.AspNetCore" Version="12.3.2" />
|
||||
<PackageReference Include="HotChocolate.AspNetCore.Authorization" Version="12.3.2" />
|
||||
<PackageReference Include="HotChocolate.Data" Version="12.3.2" />
|
||||
<PackageReference Include="Microsoft.Identity.Web" Version="1.21.1" />
|
||||
<PackageReference Include="Hl7.Fhir.R4" Version="4.0.0" />
|
||||
<PackageReference Include="HotChocolate.AspNetCore" Version="12.12.0" />
|
||||
<PackageReference Include="HotChocolate.AspNetCore.Authorization" Version="12.12.0" />
|
||||
<PackageReference Include="HotChocolate.Data" Version="12.12.0" />
|
||||
<PackageReference Include="Microsoft.Identity.Web" Version="1.25.1" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace Graphir.API.Practitioners
|
|||
var results = new List<Practitioner>();
|
||||
var searchStr = string.Join(",", keys.Select(k => k));
|
||||
var response = await _fhirService.SearchAsync<Practitioner>(new[] { $"_id={searchStr}" });
|
||||
if (response != null)
|
||||
if (response is not null)
|
||||
{
|
||||
results = response.Entry.Select(p => (Practitioner)p.Resource).ToList();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
using Hl7.Fhir.Model;
|
||||
using Hl7.Fhir.Rest;
|
||||
using Hl7.Fhir.Support;
|
||||
using HotChocolate;
|
||||
using HotChocolate.Types;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
|
|
@ -66,18 +66,9 @@ namespace Graphir.API.Practitioners
|
|||
[GraphQLName("PractitionerList")]
|
||||
public async Task<IList<Practitioner>> GetPractitionerList(string name = "")
|
||||
{
|
||||
IList<Practitioner>? results;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
{
|
||||
results = await GetPractitionersAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
results = await SearchPractitionerByName(name);
|
||||
}
|
||||
|
||||
return results;
|
||||
return string.IsNullOrWhiteSpace(name)
|
||||
? await GetPractitionersAsync()
|
||||
: await SearchPractitionerByName(name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -103,9 +94,9 @@ namespace Graphir.API.Practitioners
|
|||
|
||||
var edges = allPractitioners.Select(practitioner => new Edge<Practitioner>(practitioner, practitioner.Id)).Take(pageSize).ToList();
|
||||
bool hasNext = allPractitioners.Count() > pageSize;
|
||||
bool hasPrevious = (string.IsNullOrEmpty(after) ? false : true);
|
||||
string firstCursor = edges.FirstOrDefault().Node.Id;
|
||||
string lastCursor = edges.LastOrDefault().Node.Id;
|
||||
bool hasPrevious = !string.IsNullOrEmpty(after);
|
||||
string firstCursor = edges.FirstOrDefault()?.Node.Id;
|
||||
string lastCursor = edges.LastOrDefault()?.Node.Id;
|
||||
var pageInfo = new ConnectionPageInfo(hasNext, hasPrevious, firstCursor, lastCursor);
|
||||
var connection = new Connection<Practitioner>(edges, pageInfo, ct => ValueTask.FromResult(0));
|
||||
|
||||
|
|
|
@ -1,17 +1,7 @@
|
|||
using Graphir.API.Services;
|
||||
using Hl7.Fhir.Rest;
|
||||
using Hl7.Fhir.Model;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Identity.Web;
|
||||
using Hl7.Fhir.Rest;
|
||||
using Newtonsoft.Json;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http.Headers;
|
||||
using Microsoft.Extensions.Options;
|
||||
using static Hl7.Fhir.Model.Bundle;
|
||||
using System.Linq;
|
||||
|
||||
namespace Graphir.API
|
||||
{
|
||||
|
@ -25,15 +15,13 @@ namespace Graphir.API
|
|||
}
|
||||
|
||||
public async Task<string> Meta()
|
||||
{
|
||||
var meta = await _fhirService.CapabilityStatementAsync();
|
||||
|
||||
return JsonConvert.SerializeObject(meta);
|
||||
{
|
||||
return JsonConvert.SerializeObject(await _fhirService.CapabilityStatementAsync());
|
||||
}
|
||||
|
||||
public string GetMe(ClaimsPrincipal principal)
|
||||
public string? GetMe(ClaimsPrincipal principal)
|
||||
{
|
||||
return principal.Identity.Name;
|
||||
return principal.Identity?.Name;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
|
||||
using System;
|
||||
|
||||
namespace Graphir.API.Schema
|
||||
{
|
||||
public record AddressInput(
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
using System;
|
||||
using HotChocolate.Execution;
|
||||
using HotChocolate.Execution.Instrumentation;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Graphir.API.Services
|
||||
{
|
||||
public class ConsoleQueryLogger : ExecutionDiagnosticEventListener
|
||||
{
|
||||
private readonly ILogger<ConsoleQueryLogger> _logger;
|
||||
|
||||
public ConsoleQueryLogger(ILogger<ConsoleQueryLogger> logger) => _logger = logger;
|
||||
|
||||
// this is invoked at the start of the `ExecuteRequest` operation
|
||||
public override IDisposable ExecuteRequest(IRequestContext context)
|
||||
{
|
||||
var start = DateTime.UtcNow;
|
||||
|
||||
return new RequestScope(start, _logger);
|
||||
}
|
||||
}
|
||||
|
||||
public class RequestScope : IDisposable
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly DateTime _start;
|
||||
|
||||
public RequestScope(DateTime start, ILogger logger)
|
||||
{
|
||||
_start = start;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
// this is invoked at the end of the `ExecuteRequest` operation
|
||||
public void Dispose()
|
||||
{
|
||||
var end = DateTime.UtcNow;
|
||||
var elapsed = end - _start;
|
||||
|
||||
_logger.LogInformation("Request finished after {Ticks} ticks",
|
||||
elapsed.Ticks);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -12,17 +12,17 @@ namespace Graphir.API.Utils
|
|||
var result = new Patient
|
||||
{
|
||||
Id = patient.Id ?? string.Empty,
|
||||
Identifier = patient.Identifier?.Select(i => ToIdentifier(i)).ToList(),
|
||||
Identifier = patient.Identifier?.Select(ToIdentifier).ToList(),
|
||||
Active = patient.Active ?? true,
|
||||
Name = patient.Name?.Select(n => ToHumanName(n)).ToList(),
|
||||
Name = patient.Name?.Select(ToHumanName).ToList(),
|
||||
Language = patient.Language ?? string.Empty,
|
||||
Gender = (patient.Gender != null) ? ToEnum<AdministrativeGender>(patient.Gender) : null,
|
||||
BirthDate = patient.BirthDate ?? string.Empty,
|
||||
Telecom = patient.Telecom?.Select(t => ToContactPoint(t)).ToList(),
|
||||
Address = patient.Address?.Select(a => ToAddress(a)).ToList(),
|
||||
Telecom = patient.Telecom?.Select(ToContactPoint).ToList(),
|
||||
Address = patient.Address?.Select(ToAddress).ToList(),
|
||||
MaritalStatus = (patient.MaritalStatus != null) ? ToCodeableConcept(patient.MaritalStatus) : null,
|
||||
Communication = patient.Communication?.Select(c => ToCommunicationComponent(c)).ToList(),
|
||||
GeneralPractitioner = patient.GeneralPractitioner?.Select(p => ToResourceReference(p)).ToList()
|
||||
Communication = patient.Communication?.Select(ToCommunicationComponent).ToList(),
|
||||
GeneralPractitioner = patient.GeneralPractitioner?.Select(ToResourceReference).ToList()
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
@ -32,15 +32,15 @@ namespace Graphir.API.Utils
|
|||
var result = new Practitioner
|
||||
{
|
||||
Id = practitioner.Id ?? string.Empty,
|
||||
Identifier = practitioner.Identifier?.Select(i => ToIdentifier(i)).ToList(),
|
||||
Identifier = practitioner.Identifier?.Select(ToIdentifier).ToList(),
|
||||
Active = practitioner.Active ?? true,
|
||||
Name = practitioner.Name?.Select(n => ToHumanName(n)).ToList(),
|
||||
Name = practitioner.Name?.Select(ToHumanName).ToList(),
|
||||
Language = practitioner.Language ?? string.Empty,
|
||||
Gender = (practitioner.Gender != null) ? ToEnum<AdministrativeGender>(practitioner.Gender) : null,
|
||||
BirthDate = practitioner.BirthDate ?? string.Empty,
|
||||
Telecom = practitioner.Telecom?.Select(t => ToContactPoint(t)).ToList(),
|
||||
Address = practitioner.Address?.Select(a => ToAddress(a)).ToList(),
|
||||
Communication = practitioner.Communication?.Select(c => ToCodeableConcept(c)).ToList()
|
||||
Telecom = practitioner.Telecom?.Select(ToContactPoint).ToList(),
|
||||
Address = practitioner.Address?.Select(ToAddress).ToList(),
|
||||
Communication = practitioner.Communication?.Select(ToCodeableConcept).ToList()
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ namespace Graphir.API.Utils
|
|||
{
|
||||
var result = new CodeableConcept
|
||||
{
|
||||
Coding = (input.Coding != null) ? input.Coding.Select(c => ToCoding(c)).ToList() : null,
|
||||
Coding = input.Coding?.Select(ToCoding).ToList(),
|
||||
Text = input.Text ?? string.Empty
|
||||
};
|
||||
return result;
|
||||
|
|
|
@ -28,7 +28,7 @@ The FHIR schema encompasses large objects that can be cumbersome to develop clie
|
|||
|
||||
To follow this guide for running locally you will need the following
|
||||
|
||||
* dotnet 5.0
|
||||
* dotnet 6.0
|
||||
* Visual Studio 2022 (Professional or Enterprise)
|
||||
* [API app registration & client App Registration](https://github.com/microsoft/Graphir/blob/master/docs/Readme-Registering-Prerequisite-Apps.md)
|
||||
|
||||
|
@ -54,7 +54,7 @@ To follow this guide for running locally you will need the following
|
|||
|
||||
## With Postman
|
||||
|
||||
* Install [Postman]()
|
||||
* Install [Postman](https://www.postman.com/downloads/)
|
||||
* Add a new POST request
|
||||
* Add the URI https://localhost:5001/GraphQL
|
||||
* Add the body of your request in the "Body" tab e.g.
|
||||
|
@ -72,8 +72,8 @@ query patientList {
|
|||
* In the Configure New Token section
|
||||
* select 'Authorization Code' for Grant Type (*if you have multi-factor enabled, select 'Authorization Code (with PKCE)')
|
||||
* Leave 'Authorize with browser' checked
|
||||
* Auth URL: https://login.microsoftonline.com/<tenant>/oauth2/v2.0/authorize
|
||||
* Access Token URL: https://login.microsoftonline.com/<tenant>/oauth2/v2.0/token
|
||||
* Auth URL: https://login.microsoftonline.com/{{tenantId}}/oauth2/v2.0/authorize
|
||||
* Access Token URL: https://login.microsoftonline.com/{{tenantId}}/oauth2/v2.0/token
|
||||
* ClientId: <client id>
|
||||
* Scope: <insert scope from API app registration>
|
||||
* Click 'Get New Access Token'
|
||||
|
|
Загрузка…
Ссылка в новой задаче