Skip to content

Commit 82db252

Browse files
v-aljagtapAlankar Jagtap
and
Alankar Jagtap
authored
[TS] Terminology service POC extended for batch translate and batch validate option (#206)
* Batch Translate changes for TS * Batch translate changes with temporary response. * Batch Translate changes. * Batch validate temp changes * Removed NULL parameter from Batch validate * Code refactoring * Barchoperation change * Code review resolve * Label changes for Batch Operation * Removed empty parameter * Resolved Blank parameter issue * Local code added for batch translate * Dot net 8 version upgrade. * Removed old Textdiff dll * Updated dll added * Document Update for Batch translate and Dot net 8 * Document update * Rename file name * added image for blazor app * rename old image * updated images and Readme file * git ignore file added * Batch Operation added in FHIR collection --------- Co-authored-by: Alankar Jagtap <[email protected]>
1 parent e50c539 commit 82db252

34 files changed

+854
-51
lines changed

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
################################################################################
2+
# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
3+
################################################################################
4+
5+
/.vs/TS/v17
6+
/.vs

samples/fhir-terminology-service-integration/README.md

+45-20
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ This architecture explains how a web application communicates with a terminology
2626

2727
* Working External Terminology Service URL and authentication details.
2828

29-
* [.NET 6.0](https://dotnet.microsoft.com/download)
29+
* [.NET 8.0](https://dotnet.microsoft.com/download)
3030

3131
* [Azure Command-Line Interface (CLI)](https://docs.microsoft.com/cli/azure/install-azure-cli)
3232

@@ -37,7 +37,7 @@ This architecture explains how a web application communicates with a terminology
3737

3838
### Prerequisite check
3939

40-
- In a terminal or command window, run `dotnet --version` to check that the .NET SDK is version 6.0 or later.
40+
- In a terminal or command window, run `dotnet --version` to check that the .NET SDK is version 8.0 or later.
4141
- Run `az --version` and `azd version` to check that you have the appropriate Azure command-line tools installed.
4242
- Login to the Azure CLI
4343

@@ -62,51 +62,65 @@ This sample uses an Azure APIM which acts as Common Endpoint Application for Ext
6262
__Note:__ In this sample, The APIM uses client Id and client secret for authenticating calls to external third party terminology service. APIM will need changes in case external third party terminology service uses different kind of authentication.
6363

6464
## Azure APIM sample details:
65-
Here we will go through high level steps to create an Azure APIM instance with Backend, Policies and APIs, somilar to the one used for this sample.
65+
Here we will go through high level steps to create an Azure APIM instance with Backend, Policies and APIs, similar to the one used for this sample.
6666

6767
1. Create Azure APIM Instance
6868
Create an Azure APIM instance following steps [here](https://learn.microsoft.com/en-us/azure/api-management/get-started-create-service-instance) and come back for next step.
6969
2. Create APIs:
7070

7171
a. In the cloned repo, go to at location (../samples/fhir-terminology-service-integration/apim)
72+
7273
b. Open file "FHIR Terminology.openapi+json.json" in Editor.
73-
c. Add your fhir service url for backend at hoghlighted place and save the file.
74+
75+
c. Add your fhir service url for backend at highlighted place and save the file.
7476
![](./images/CreateAPI1.png)
77+
78+
7579
d. Go to "APIs" tab, click on "Add API" and select "OpenAPI" from "Create from definition" section as highlighted below:
76-
7780
![](./images/CreateAPI.png)
7881
7982
e. In the new popup window, click on "Select a file" and browse file "FHIR Terminology.openapi+json.json" at loaction (../samples/fhir-terminology-service-integration/apim).
80-
8183
![](./images/CreateAPI2.png)
8284
83-
f. After you select the file, fileds will be filled with values as shown below, you can change values of "Display Name" and "Name" fileds. Click on "Create".
84-
85+
f. After you select the file, fields will be filled with values as shown below, you can change values of "Display Name" and "Name" fields. Click on "Create".
8586
![](./images/CreateAPI3.png)
8687
8788
g. As shown below, API willget created with list of operations and backend is fhir service url for all operations.
88-
8989
![](./images/CreateAPI4.png)
9090

9191

9292
3. Create Policy Fragment:
93+
9394
a. In the cloned repo, go to at location (../samples/fhir-terminology-service-integration/apim)
95+
9496
b. Open file "PolicyFragments.xml file" in editor and update the values for highlighted fields as per your 3P teminology service requirements.
95-
![](./images/Policy1.png)
96-
c. After you are done editing save the changes and copy all the text.
97-
d. Go back to your APIM instance and go to "Polict Fragments" tab, click on "Create", new popup will open, Enter polict name, description and add copied text for policy and click in "Create".
97+
![](./images/Policy0.png)
98+
99+
c. Add below condition in PolicyFragments.
100+
![](./images/Policy1.png)
101+
102+
d. After you are done editing save the changes and copy all the text.
103+
e. Go back to your APIM instance and go to "Policy Fragments" tab, click on "Create", new popup will open, Enter policy name, description and add copied text for policy and click in "Create".
98104
![](./images/Policy2.png)
99-
d. Once policy is successfully created, you can see it in "Polict Fragments" tab.
105+
106+
f. Once policy is successfully created, you can see it in "Policy Fragments" tab.
100107
![](./images/Policy3.png)
101108

102109
4. Add Policy to API operations:
110+
103111
a. Go to "APIs" tab select "FHIR Terminology" select an operation to apply the policy and click on "Add Policy" in "inbound processing" section as shown below:
104112
![](./images/AddPolicy1.png)
105-
b. Select Other policies option as highlighted:
113+
114+
b. Add the UI app URL to the CORS policies in the "Inbound Processing" section as shown below:
115+
![](./images/corsPolicy.png)
116+
117+
c. Select Other policies option as highlighted:
106118
![](./images/AddPolicy2.png)
107-
c. In xml, Add a code fragment to include policy fragment "RedirectToterminology", as shown and click on "Save":
119+
120+
d. In xml, Add a code fragment to include policy fragment "RedirectToterminology", as shown and click on "Save":
108121
![](./images/AddPolicy3.png)
109-
d. Policy is added to API operation in inbound processing as shown:
122+
123+
e. Policy is added to API operation in inbound processing as shown:
110124
![](./images/AddPolicy4.png)
111125

112126
Following the above steps and sample templates users can create more APIs, Operations and Policies as needed.
@@ -116,7 +130,7 @@ Following the above steps and sample templates users can create more APIs, Opera
116130

117131
UI application and Postman queries use common APIM endpoint for termonology service operations and FHIR service Operations.
118132

119-
The UI application demonstartes $lookup and $translate operations, those operations are routed to external terminology service by APIM.
133+
The UI application demonstartes $lookup ,$translate operations and $Batch Translate operations, those operations are routed to external terminology service by APIM.
120134

121135
The UI Application also demonstartes operations for searching Observation resources from FHIR service and saving translated Observation resources to FHIR service, the search and save operations are routed to AHDS FHIR Service by APIM.
122136

@@ -144,13 +158,13 @@ Following the above steps and sample templates users can create more APIs, Opera
144158

145159
3. First/Landing page is "Lookup and Translate". It allows user to perform lookup and translate operations on terminology service.
146160

147-
4. For Lookup, Enter code & select code system, Click on lookup button to get thecode details from terminology service.
161+
4. For Lookup, Enter code & select code system, Click on lookup button to get the code details from terminology service.
148162

149163
<img src="./images/image3.png" height="380">
150164

151165
The reponse json is shown in "Response" text area and some important details from response are also shown in table at bottom of the page for easy readability.
152166

153-
5. For Translate, Enter code, select source system & target system, Click onTranslate button to get the default Terminology mappings between source code and target code.
167+
5. For Translate, Enter code, select source system & target system, Click on Translate button to get the default Terminology mappings between source code and target code.
154168

155169
<img src="./images/image4.png" height="380">
156170

@@ -186,5 +200,16 @@ Following the above steps and sample templates users can create more APIs, Opera
186200

187201
12. Click on the search button again to verify reset of `Observation` resource.
188202

189-
<img src="./images/Image10.png" height="380">
203+
<img src="./images/image10.png" height="380">
204+
205+
13. For Batch Translate, select a code for Batch Operation from the dropdown, which contains multiple codes for translation. It's a combination of the source system, target system, and code
206+
207+
<img src="./images/image11.png" height="380">
190208

209+
14. Click on Batch Operation,to get the default Terminology mappings between source code and target code in batch.
210+
211+
<img src="./images/image12.png" height="380">
212+
213+
15. Select Batch_Validate value from dropdown,to to validate the code details from terminology service.
214+
215+
<img src="./images/image13.png" height="380">
Binary file not shown.
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading

samples/fhir-terminology-service-integration/ui-app/FhirBlaze.SharedComponents/FhirBlaze.SharedComponents.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
</PropertyGroup>
66

77
<ItemGroup>
@@ -18,8 +18,8 @@
1818

1919
<ItemGroup>
2020
<PackageReference Include="Hl7.Fhir.R4" Version="3.4.0" />
21-
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="5.0.8" />
22-
<PackageReference Include="Microsoft.Authentication.WebAssembly.Msal" Version="5.0.8" />
21+
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.6" />
22+
<PackageReference Include="Microsoft.Authentication.WebAssembly.Msal" Version="8.0.6" />
2323
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
2424
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
2525
<PackageReference Include="Microsoft.Graph.Beta" Version="4.6.0-preview" />

samples/fhir-terminology-service-integration/ui-app/FhirBlaze.SharedComponents/Services/APIMService.cs

+26-11
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
1-
using Azure.Core;
2-
using Hl7.Fhir.Model;
3-
using Hl7.Fhir.Rest;
4-
using Microsoft.AspNetCore.Components.WebAssembly.Authentication;
5-
using Microsoft.IdentityModel.Tokens;
1+
using Microsoft.AspNetCore.Components.WebAssembly.Authentication;
62
using System;
7-
using System.Collections.Generic;
8-
using System.Linq;
93
using System.Net;
104
using System.Net.Http;
11-
using System.Net.Http.Headers;
12-
using System.Text;
135
using System.Threading.Tasks;
14-
using static Microsoft.Graph.CoreConstants;
156

167
namespace FhirBlaze.SharedComponents.Services
178
{
@@ -167,7 +158,7 @@ private async Task<HttpResponseMessage> PostAsync(string content)
167158
return _fhirResponse;
168159
}
169160
}
170-
161+
171162
private async Task<string> FetchToken()
172163
{
173164
string accessToken = string.Empty;
@@ -269,5 +260,29 @@ public async Task<HttpResponseMessage> ResetObservations(string observationBundl
269260
return httpResponseMessage;
270261
}
271262

263+
264+
public async Task<HttpResponseMessage> BatchOperationCall(string content)
265+
{
266+
HttpResponseMessage httpResponseMessage;
267+
try
268+
{
269+
string cacheToken = await FetchToken();
270+
if (cacheToken != "")
271+
{
272+
httpResponseMessage = await PostAsync(content);
273+
}
274+
else
275+
{
276+
httpResponseMessage = new HttpResponseMessage(HttpStatusCode.Unauthorized);
277+
httpResponseMessage.Content = new StringContent("Unauthorized: Access is denied due to invalid credentials.");
278+
}
279+
}
280+
catch
281+
{
282+
throw;
283+
}
284+
return httpResponseMessage;
285+
}
286+
272287
}
273288
}

samples/fhir-terminology-service-integration/ui-app/FhirBlaze.SharedComponents/Services/IAPIMService.cs

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
using Hl7.Fhir.Model;
2-
using System;
3-
using System.Collections.Generic;
4-
using System.Linq;
5-
using System.Net.Http;
6-
using System.Text;
1+
using System.Net.Http;
72
using System.Threading.Tasks;
83

94
namespace FhirBlaze.SharedComponents.Services
@@ -19,5 +14,6 @@ public interface IAPIMService
1914
Task<HttpResponseMessage> SaveObservation(string id, string observationJson);
2015

2116
Task<HttpResponseMessage> ResetObservations(string content);
17+
Task<HttpResponseMessage> BatchOperationCall(string content);
2218
}
2319
}

samples/fhir-terminology-service-integration/ui-app/FhirBlaze/FhirBlaze.csproj

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<UserSecretsId>d5d6b92a-009f-4333-aa32-2607d1ed3efc</UserSecretsId>
66
</PropertyGroup>
77

@@ -15,10 +15,10 @@
1515
<ItemGroup>
1616
<PackageReference Include="Blazored.Modal" Version="7.1.0" />
1717
<PackageReference Include="DiffPlex" Version="1.7.1" />
18-
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.5" />
19-
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.5" PrivateAssets="all" />
18+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.6" />
19+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.6" PrivateAssets="all" />
2020
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.2.0" />
21-
<PackageReference Include="Microsoft.Authentication.WebAssembly.Msal" Version="6.0.5" />
21+
<PackageReference Include="Microsoft.Authentication.WebAssembly.Msal" Version="8.0.6" />
2222
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
2323
<PackageReference Include="Microsoft.Graph.Beta" Version="4.6.0-preview" />
2424
<PackageReference Include="Microsoft.PowerBI.Api" Version="4.6.0" />
@@ -31,17 +31,18 @@
3131
</ItemGroup>
3232

3333
<ItemGroup>
34-
<Reference Include="BlazorTextDiff">
35-
<HintPath>bin\Debug\net6.0\BlazorTextDiff.dll</HintPath>
36-
</Reference>
34+
<TrimmerRootAssembly Include="Microsoft.Authentication.WebAssembly.Msal" />
3735
</ItemGroup>
3836

3937
<ItemGroup>
40-
<TrimmerRootAssembly Include="Microsoft.Authentication.WebAssembly.Msal" />
38+
<Folder Include="wwwroot\css\modal\" />
4139
</ItemGroup>
4240

4341
<ItemGroup>
44-
<Folder Include="wwwroot\css\modal\" />
42+
<Reference Include="BlazorTextDiff">
43+
<HintPath>wwwroot\dllreference\BlazorTextDiff.dll</HintPath>
44+
</Reference>
4545
</ItemGroup>
4646

47+
4748
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using Hl7.Fhir.Model;
2+
using System.Collections.Generic;
3+
4+
namespace FhirBlaze.Model
5+
{
6+
public class BatchTranslateModel
7+
{
8+
public List<CodingEntry> Coding { get; set; }
9+
public BatchTranslateModel()
10+
{
11+
Coding = new List<CodingEntry>();
12+
}
13+
}
14+
15+
public class CodingEntry
16+
{
17+
public string code { get; set; }
18+
public string system { get; set; }
19+
public string targetsystem { get; set; }
20+
public string display { get; set; }
21+
}
22+
23+
24+
public class BatchValidateModel
25+
{
26+
public List<CodingValidateEntry> Coding { get; set; }
27+
public BatchValidateModel()
28+
{
29+
Coding = new List<CodingValidateEntry>();
30+
}
31+
}
32+
33+
public class CodingValidateEntry
34+
{
35+
public string code { get; set; }
36+
public string url { get; set; }
37+
public string date { get; set; }
38+
public string system { get; set; }
39+
public string valueSetVersion { get; set; }
40+
public bool? result { get; set; }
41+
public string message { get; set; }
42+
public string display { get; set; }
43+
}
44+
}

samples/fhir-terminology-service-integration/ui-app/FhirBlaze/Model/TSFhirModel.cs

+5
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,10 @@ public class TSFhirModel
2424

2525
public string Message { get; set; } = string.Empty;
2626

27+
public List<string> Codelist { get; set; } = new List<string>();
28+
public string batchJson { get; set; } = string.Empty;
29+
public string batchTranslateJson { get; set; } = string.Empty;
30+
31+
2732
}
2833
}

0 commit comments

Comments
 (0)