-
Notifications
You must be signed in to change notification settings - Fork 0
Add C# #375
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
Merged
Merged
Add C# #375
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
321f9d1
Initial C# SDK
jeremytwfortune 8b7e96b
Fix Dotnet Setup Reference
jeremytwfortune 3ad8a28
Publish to Proget
jeremytwfortune 623890d
Fix Dotnet Setup Reference
jeremytwfortune 7df3777
Potential fix for code scanning alert no. 9: Workflow does not contai…
jeremytwfortune 3ba511e
Remove Premaure Using
jeremytwfortune 2ff4a24
Address Different Casing in Authorization Scheme
jeremytwfortune 853a29a
Use RouteBuilder to Escape TerminologyApi URI
jeremytwfortune 61e97e0
Make BaseUrl Failures More Clear
jeremytwfortune 6afbb6e
Fix README
jeremytwfortune 6f8cdff
Provide Exception Docs, Rename
jeremytwfortune 9051b76
Add RouteBuilder Unit Tests
jeremytwfortune 950a92a
Force Users to Come With HttpClient
jeremytwfortune e2c6857
Add Unit Tests for BuildUri
jeremytwfortune 297cf2a
Parse Operational Outcomes
jeremytwfortune e4d1acf
Ensure Unparseable JSON is Returned as ResponseText
jeremytwfortune 84ffc38
Format
jeremytwfortune c9793aa
Fix Header Auth Tests for Identity
jeremytwfortune c007a35
Fix Auth for Tests
jeremytwfortune 115d11c
Fix Auth for Tests
jeremytwfortune 1584bcf
Simplify Basic Credential Normalization
jeremytwfortune File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -6,4 +6,5 @@ | |
| **/.mypy_cache/ | ||
| **/.pytest_cache/ | ||
| **/.ipynb_checkpoints/ | ||
| **/__pycache__/ | ||
| **/__pycache__/ | ||
| .codex | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -1,13 +1,15 @@ | ||
| # Orchestrate SDK Contribution Guide | ||
|
|
||
| The Orchestrate SDK is a TypeScript and JavaScript library for interacting with the Orchestrate API at <https://api.careevolutionapi.com>. Releases are tagged and generated from `main`. Development should be forked from `main` and a PR created to merge back into it. | ||
| The Orchestrate SDK is a TypeScript, Python, and C# library for interacting with the Orchestrate API at <https://api.careevolutionapi.com>. Releases are tagged and generated from `main`. Development should be forked from `main` and a PR created to merge back into it. | ||
|
|
||
| ## Installation | ||
|
|
||
| For TypeScript, navigate to the `./typescript` directory and install dependencies with `npm i`. For Python, navigate to the `./python` directory and install dependencies with `poetry install`. | ||
| For TypeScript, navigate to the `./typescript` directory and install dependencies with `npm i`. | ||
| For Python, navigate to the `./python` directory and install dependencies with `poetry install`. | ||
| For C#, navigate to the `./dotnet` directory and restore dependencies with `dotnet restore`. | ||
|
|
||
| ## Tests | ||
|
|
||
| TypeScript tests can be run and watched with `npm run test:watch`. Python tests can be run with `poetry run pytest`. | ||
| TypeScript tests can be run and watched with `npm run test:watch`. Python tests can be run with `poetry run pytest`. C# tests can be run with `dotnet test`. | ||
|
|
||
| To run Local Hashing Service tests, docker must be installed and running. Tests against the Identity API do not use data directly from the Local Hashing Service, so any valid hash key can be used to start the container. See the [Orchestrate Docs](https://orchestrate.docs.careevolution.com/identity/local_hash/hosting.html) for information on starting the container. |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| # Orchestrate SDK | ||
|
|
||
| The Orchestrate SDK is a TypeScript and JavaScript library for interacting with the Orchestrate API at <https://api.careevolutionapi.com>. | ||
| The Orchestrate SDK provides TypeScript, Python, and C# clients for interacting with the Orchestrate API at <https://api.careevolutionapi.com>. | ||
|
|
||
| Full documentation of the API is available at <https://rosetta-api.docs.careevolution.com/>. | ||
|
|
||
|
|
@@ -18,9 +18,15 @@ Python: | |
| pip install orchestrate-api | ||
| ``` | ||
|
|
||
| C#: | ||
|
|
||
| ```bash | ||
| dotnet add package CareEvolution.Orchestrate | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| TypeScript: | ||
| ### TypeScript | ||
|
|
||
| ```typescript | ||
| import { OrchestrateApi } from '@careevolution/orchestrate'; | ||
|
|
@@ -32,7 +38,7 @@ await orchestrate.terminology.classifyCondition({ | |
| }); | ||
| ``` | ||
|
|
||
| Python: | ||
| ### Python | ||
|
|
||
| ```python | ||
| from orchestrate import OrchestrateApi | ||
|
|
@@ -41,11 +47,38 @@ api = OrchestrateApi(api_key="your-api-key") | |
| api.terminology.classify_condition(code="119981000146107", system="SNOMED") | ||
| ``` | ||
|
|
||
| ### C\# | ||
|
|
||
| ```csharp | ||
| using CareEvolution.Orchestrate; | ||
|
|
||
| var api = new OrchestrateApi(new OrchestrateClientOptions | ||
| { | ||
| ApiKey = "your-api-key", | ||
| }); | ||
|
|
||
| await api.Terminology.ClassifyConditionAsync(new ClassifyConditionRequest | ||
| { | ||
| Code = "119981000146107", | ||
| System = "SNOMED", | ||
| }); | ||
| ``` | ||
|
|
||
| Additionally, C# also supports dependency injection with `IOrchestrateApi` and `OrchestrateApi` registered in the service collection. | ||
|
|
||
| ```csharp | ||
| using CareEvolution.Orchestrate; | ||
| using Microsoft.Extensions.DependencyInjection; | ||
|
|
||
| var services = new ServiceCollection(); | ||
| services.AddOrchestrateApi(); | ||
| ``` | ||
|
Comment on lines
+69
to
+75
|
||
|
|
||
| ## Configuration | ||
|
|
||
| The SDK supports environment variables for configuring HTTP behavior. These can be used for local development, CI, or shared runtime configuration. | ||
|
|
||
| For the primary `OrchestrateApi` clients in both TypeScript and Python: | ||
| For the primary `OrchestrateApi` clients in TypeScript, Python, and C#: | ||
|
|
||
| | Environment variable | Purpose | Default | | ||
| | --- | --- | --- | | ||
|
|
@@ -60,7 +93,7 @@ Environment variables used by the identity clients: | |
| | --- | --- | | ||
| | `ORCHESTRATE_IDENTITY_URL` | Base URL for `IdentityApi`. Required unless the URL is passed directly when creating the client. | | ||
| | `ORCHESTRATE_IDENTITY_API_KEY` | API key sent as the `x-api-key` header for `IdentityApi`. | | ||
| | `ORCHESTRATE_IDENTITY_METRICS_KEY` | Metrics key sent as the `Authorization` header for `IdentityApi`. A value with or without the `Basic ` prefix is accepted. | | ||
| | `ORCHESTRATE_IDENTITY_METRICS_KEY` | Metrics key sent as the `Authorization` header for `IdentityApi`. A value with or without the `Basic` prefix is accepted. | | ||
| | `ORCHESTRATE_IDENTITY_LOCAL_HASHING_URL` | Base URL for `LocalHashingApi`. Required unless the URL is passed directly when creating the client. | | ||
|
|
||
| ### Configuration Precedence | ||
|
|
@@ -71,13 +104,13 @@ When the same setting is provided in more than one place, the SDK resolves it in | |
| 2. The matching environment variable | ||
| 3. The SDK default, when one exists | ||
|
|
||
| For example, passing `api_key` or `timeout_ms` in Python, or `apiKey` or `timeoutMs` in TypeScript, overrides the corresponding environment variable. | ||
| For example, passing `api_key` or `timeout_ms` in Python, `apiKey` or `timeoutMs` in TypeScript, or `ApiKey` or `TimeoutMs` in C# overrides the corresponding environment variable. | ||
|
|
||
| `ORCHESTRATE_ADDITIONAL_HEADERS` is additive. It is merged into the request headers before the SDK applies its standard `Accept`, `Content-Type`, authentication, and metrics headers, so the SDK-managed headers take precedence if the same header name is supplied in multiple places. | ||
|
|
||
| ### Examples | ||
|
|
||
| TypeScript: | ||
| #### TypeScript Example | ||
|
|
||
| ```bash | ||
| export ORCHESTRATE_API_KEY="your-api-key" | ||
|
|
@@ -91,7 +124,7 @@ import { OrchestrateApi } from '@careevolution/orchestrate'; | |
| const orchestrate = new OrchestrateApi(); | ||
| ``` | ||
|
|
||
| Python: | ||
| #### Python Example | ||
|
|
||
| ```bash | ||
| export ORCHESTRATE_API_KEY="your-api-key" | ||
|
|
@@ -104,3 +137,19 @@ from orchestrate import OrchestrateApi | |
|
|
||
| api = OrchestrateApi() | ||
| ``` | ||
|
|
||
| #### C\# Example | ||
|
|
||
| With environment values as above or DI configuration: | ||
|
|
||
| ```csharp | ||
| using Microsoft.Extensions.DependencyInjection; | ||
| using CareEvolution.Orchestrate; | ||
|
|
||
| var services = new ServiceCollection(); | ||
| services.AddOrchestrateApi(options => | ||
| { | ||
| options.ApiKey = "your-api-key"; | ||
| options.TimeoutMs = 30000; | ||
| }); | ||
| ``` | ||
This file contains hidden or 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,13 @@ | ||
| { | ||
| "version": 1, | ||
| "isRoot": true, | ||
| "tools": { | ||
| "csharpier": { | ||
| "version": "1.2.6", | ||
| "commands": [ | ||
| "csharpier" | ||
| ], | ||
| "rollForward": false | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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,3 @@ | ||
| **/bin | ||
| **/obj | ||
| tests/CareEvolution.Orchestrate.Tests/LiveData/** |
This file contains hidden or 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,3 @@ | ||
| **/bin/ | ||
| **/obj/ | ||
| TestResults/ |
This file contains hidden or 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,27 @@ | ||
| Microsoft Visual Studio Solution File, Format Version 12.00 | ||
| # Visual Studio Version 17 | ||
| VisualStudioVersion = 17.0.31903.59 | ||
| MinimumVisualStudioVersion = 10.0.40219.1 | ||
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CareEvolution.Orchestrate", "src/CareEvolution.Orchestrate/CareEvolution.Orchestrate.csproj", "{B21EA726-0E99-4CDB-8F56-7A3300565A0B}" | ||
| EndProject | ||
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CareEvolution.Orchestrate.Tests", "tests/CareEvolution.Orchestrate.Tests/CareEvolution.Orchestrate.Tests.csproj", "{3259B89E-A60A-432D-A4B5-547646506A24}" | ||
| EndProject | ||
| Global | ||
| GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
| Debug|Any CPU = Debug|Any CPU | ||
| Release|Any CPU = Release|Any CPU | ||
| EndGlobalSection | ||
| GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
| {B21EA726-0E99-4CDB-8F56-7A3300565A0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
| {B21EA726-0E99-4CDB-8F56-7A3300565A0B}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
| {B21EA726-0E99-4CDB-8F56-7A3300565A0B}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
| {B21EA726-0E99-4CDB-8F56-7A3300565A0B}.Release|Any CPU.Build.0 = Release|Any CPU | ||
| {3259B89E-A60A-432D-A4B5-547646506A24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
| {3259B89E-A60A-432D-A4B5-547646506A24}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
| {3259B89E-A60A-432D-A4B5-547646506A24}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
| {3259B89E-A60A-432D-A4B5-547646506A24}.Release|Any CPU.Build.0 = Release|Any CPU | ||
| EndGlobalSection | ||
| GlobalSection(SolutionProperties) = preSolution | ||
| HideSolutionNode = FALSE | ||
| EndGlobalSection | ||
| EndGlobal |
This file contains hidden or 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,3 @@ | ||
| using System.Runtime.CompilerServices; | ||
|
|
||
| [assembly: InternalsVisibleTo("CareEvolution.Orchestrate.Tests")] |
This file contains hidden or 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,6 @@ | ||
| namespace CareEvolution.Orchestrate; | ||
|
|
||
| internal sealed class BatchRequest<T> | ||
| { | ||
| public required IReadOnlyList<T> Items { get; init; } | ||
| } |
This file contains hidden or 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,6 @@ | ||
| namespace CareEvolution.Orchestrate; | ||
|
|
||
| internal sealed class BatchResponse<T> | ||
| { | ||
| public required List<T> Items { get; init; } | ||
| } |
26 changes: 26 additions & 0 deletions
26
dotnet/src/CareEvolution.Orchestrate/CareEvolution.Orchestrate.csproj
This file contains hidden or 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,26 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <TargetFrameworks>net8.0;net10.0</TargetFrameworks> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <Nullable>enable</Nullable> | ||
| <LangVersion>latest</LangVersion> | ||
| <GenerateDocumentationFile>true</GenerateDocumentationFile> | ||
| <NoWarn>$(NoWarn);1591</NoWarn> | ||
| <PackageId>CareEvolution.Orchestrate</PackageId> | ||
| <Title>CareEvolution Orchestrate SDK</Title> | ||
| <Description>SDK for the Orchestrate API at api.careevolutionapi.com</Description> | ||
| <PackageProjectUrl>https://rosetta-api.docs.careevolution.com/</PackageProjectUrl> | ||
| <RepositoryUrl>https://github.com/CareEvolution/OrchestrateSDK</RepositoryUrl> | ||
| <PackageLicenseExpression>Apache-2.0</PackageLicenseExpression> | ||
| <Authors>CareEvolution</Authors> | ||
| <Version>0.0.0</Version> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <PackageReference Include="CareEvolution.Fhir.Core" Version="1.11.0" /> | ||
| <PackageReference | ||
| Include="Microsoft.Extensions.DependencyInjection.Abstractions" | ||
| Version="8.0.2" | ||
| /> | ||
| <PackageReference Include="Microsoft.Extensions.Http" Version="8.0.1" /> | ||
| </ItemGroup> | ||
| </Project> |
10 changes: 10 additions & 0 deletions
10
dotnet/src/CareEvolution.Orchestrate/ClassifyConditionRequest.cs
This file contains hidden or 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,10 @@ | ||
| namespace CareEvolution.Orchestrate; | ||
|
|
||
| public sealed class ClassifyConditionRequest | ||
| { | ||
| public required string Code { get; set; } | ||
|
|
||
| public required string System { get; set; } | ||
|
|
||
| public string? Display { get; set; } | ||
| } |
27 changes: 27 additions & 0 deletions
27
dotnet/src/CareEvolution.Orchestrate/ClassifyConditionResponse.cs
This file contains hidden or 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,27 @@ | ||
| using System.Text.Json.Serialization; | ||
|
|
||
| namespace CareEvolution.Orchestrate; | ||
|
|
||
| public sealed class ClassifyConditionResponse | ||
| { | ||
| [JsonPropertyName("ccsrCatgory")] | ||
| public CodeableConcept? CcsrCategory { get; set; } | ||
|
|
||
| public Coding? CcsrDefaultInpatient { get; set; } | ||
|
|
||
| public Coding? CcsrDefaultOutpatient { get; set; } | ||
|
|
||
| public bool CciChronic { get; set; } | ||
|
|
||
| public bool CciAcute { get; set; } | ||
|
|
||
| public CodeableConcept? HccCategory { get; set; } | ||
|
|
||
| public bool Behavioral { get; set; } | ||
|
|
||
| public bool Substance { get; set; } | ||
|
|
||
| public bool SocialDeterminant { get; set; } | ||
|
|
||
| public string? Covid19Condition { get; set; } | ||
| } |
10 changes: 10 additions & 0 deletions
10
dotnet/src/CareEvolution.Orchestrate/ClassifyMedicationRequest.cs
This file contains hidden or 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,10 @@ | ||
| namespace CareEvolution.Orchestrate; | ||
|
|
||
| public sealed class ClassifyMedicationRequest | ||
| { | ||
| public required string Code { get; set; } | ||
|
|
||
| public required string System { get; set; } | ||
|
|
||
| public string? Display { get; set; } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.