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

new import tool #3182

Merged
merged 9 commits into from
Apr 21, 2023
Merged
Show file tree
Hide file tree
Changes from 6 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: 7 additions & 0 deletions Microsoft.Health.Fhir.sln
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Health.TaskManage
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Health.Fhir.Store.Utils", "src\Microsoft.Health.Fhir.Store.Utils\Microsoft.Health.Fhir.Store.Utils.csproj", "{7A736E5F-DA6E-483F-AD5B-EE8F66828E36}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RegisterAndMonitorImport", "tools\RegisterAndMonitorImport\RegisterAndMonitorImport.csproj", "{E85BCB9A-5D6E-45AD-BE67-AEFA060FEBF1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Importer", "tools\Importer\Importer.csproj", "{F6B94905-B496-46AD-B2A7-2ABCB0B2A6B4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Exporter", "tools\Exporter\Exporter.csproj", "{E468B6C6-9098-4293-AFD6-3B1675D67063}"
Expand Down Expand Up @@ -344,6 +346,10 @@ Global
{7A736E5F-DA6E-483F-AD5B-EE8F66828E36}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7A736E5F-DA6E-483F-AD5B-EE8F66828E36}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7A736E5F-DA6E-483F-AD5B-EE8F66828E36}.Release|Any CPU.Build.0 = Release|Any CPU
{E85BCB9A-5D6E-45AD-BE67-AEFA060FEBF1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E85BCB9A-5D6E-45AD-BE67-AEFA060FEBF1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E85BCB9A-5D6E-45AD-BE67-AEFA060FEBF1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E85BCB9A-5D6E-45AD-BE67-AEFA060FEBF1}.Release|Any CPU.Build.0 = Release|Any CPU
{F6B94905-B496-46AD-B2A7-2ABCB0B2A6B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F6B94905-B496-46AD-B2A7-2ABCB0B2A6B4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F6B94905-B496-46AD-B2A7-2ABCB0B2A6B4}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -474,6 +480,7 @@ Global
{03AD4FC4-A56F-4E94-B295-B02A9E3E3CCD} = {7457B218-2651-49B5-BED8-22233889516A}
{BB7512E7-E148-4AF8-9D34-AA47A6AE692D} = {7457B218-2651-49B5-BED8-22233889516A}
{7A736E5F-DA6E-483F-AD5B-EE8F66828E36} = {B70945F4-01A6-4351-955B-C4A2943B5E3B}
{E85BCB9A-5D6E-45AD-BE67-AEFA060FEBF1} = {B70945F4-01A6-4351-955B-C4A2943B5E3B}
{F6B94905-B496-46AD-B2A7-2ABCB0B2A6B4} = {B70945F4-01A6-4351-955B-C4A2943B5E3B}
{E468B6C6-9098-4293-AFD6-3B1675D67063} = {B70945F4-01A6-4351-955B-C4A2943B5E3B}
{A0320AE9-3F87-44A3-8263-5AF7E00085D4} = {38B3BA4A-3510-4615-BCC4-4C9B96A486C4}
Expand Down
56 changes: 56 additions & 0 deletions tools/RegisterAndMonitorImport/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<!--
This code allows to import resources from a storage container to a FHIR service.
Input data must be provided in ndjson format in one container in Azure blobs storage.
-->
<appSettings>
<!--
If you just want to monitor an import then provide a url for this key/value
Note that if this is provided then it only performs this operation and will not do any import.
https://{your fhir endpoint}/_operations/import/{import id}
The expected endpoint would be similar to this:
-->
<add key="MonitorImportStatusEndpoint" value="" />

<!--
The amount of time to delay between calls to get the import status
The value should be a timespan value
-->
<add key="ImportStatusDelay" value="00:02:00" />

<!-- Azure blob storage parameters -->
<add key="ConnectionString" value="{Add your BlobServiceClient connection string here}" />
<add key="ContainerName" value="{Add your container}" />
<!--
the type of files it'll search for in the container
do not add a file extension as ndjson is assumed and added to the ResourceType automatically
if this is empty then it defaults to all
-->
<add key="ResourceType" value="Observation" />

<!--
a simple flag to indicate that when true we're going to use the token for our http POST/GET
this is useful when you have a Paas deployment
if you set to false then you could use it against an oss fhir service
-->
<add key="UseBearerToken" value="false" />

<!--
the number we want to import at a time
of course this can be a much larger value than 20 so adjust as needed
-->
<add key="NumberOfBlobsForImport" value="2" />

<!--
the following are for getting a token
note that the "resource" is required as that is the FHIR endpoint and is always used
even if the UseBearerToken is set to false
-->
<add key="TokenEndpoint" value="{add login url to your oauth2/token endpoint}" />
<add key="grant_type" value="Client_Credentials" />
<add key="client_id" value="{add your client id}" />
<add key="client_secret" value="{add your client secret}" />
<add key="resource" value="{add your FHIR endpoint}" />
</appSettings>
</configuration>
33 changes: 33 additions & 0 deletions tools/RegisterAndMonitorImport/ImportResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// -------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
// -------------------------------------------------------------------------------------------------

using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace Microsoft.Health.Fhir.RegisterAndMonitorImport
{
#pragma warning disable CA1812 // Avoid uninstantiated internal classes
internal sealed class ImportResponse
{
[JsonPropertyName("error")]
public List<Json> Error { get; set; } = new();

[JsonPropertyName("output")]
public List<Json> Output { get; set; } = new();

public sealed class Json
{
[JsonPropertyName("type")]
public string Type { get; set; } = string.Empty;

[JsonPropertyName("count")]
public int Count { get; set; }

[JsonPropertyName("inputUrl")]
public string InputUrl { get; set; } = string.Empty;
}
}
#pragma warning disable CA1812 // Avoid uninstantiated internal classes
}
17 changes: 17 additions & 0 deletions tools/RegisterAndMonitorImport/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// -------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
// -------------------------------------------------------------------------------------------------

using System.Threading.Tasks;

namespace Microsoft.Health.Fhir.RegisterAndMonitorImport
{
public static class Program
{
public static async Task Main()
{
await RegisterAndMonitorImport.Run();
}
}
}
Loading