π€πˆ 𝐦𝐨𝐧𝐀𝐬.𝐒𝐨

AImonks (https://medium.com/aimonks) is an AI-Educational Publication.

Building a Computer Assisted Coding (CAC) in ASP.NET 7 based on AutoICD API

Computer-assisted coding (CAC) is a rapidly evolving technology that has transformed the way medical coding is done. It uses natural language processing (NLP) algorithms to analyze medical records and assist coders in identifying the appropriate medical codes for diagnoses and procedures. ASP.NET 7 is a powerful web application framework for building modern, scalable web applications. In this article, we will explore how to build an ICD-10 CAC system in ASP.NET 7 using the AutoICD API (Documentation here). AutoICD is a cloud-based NLP platform that uses machine learning algorithms to identify and extract medical codes from unstructured clinical notes. By integrating AutoICD with ASP.NET 7, we can build a powerful CAC system that streamlines the coding process and reduces errors, ultimately improving patient care and outcomes. Let’s get started!

Step 0) Get Visual Studio

For the rest of this guide we are assuming you already have Visual Studio 2022+ installed on your development environment.

Step 1 - Create the solution

On Visual Studio create a new ASP.NET Core Web App project

Create the AutoICD CAC ASP.NET Core Web App project

You can call it β€œAutoICD CAC”

Step 2 - Setup the UI

We want to create a single page where the user can enter a clinical text, a β€œCode” button that will invoke AutoICD API to process it, and a results section where we will show the generated ICD-10 coded result.
We will add this content under Index.cshtml file; edit its content to the following:

@page
@model IndexModel
@{
ViewData["Title"] = "Home page";
}

<div class="text-center">
<h1 class="display-4">AutoICD API</h1>
<p>Learn about automated clinical text coding with <a href="https:\\www.autoicdapi.com">AutoICD API</a>.</p>
</div>

<div class="container">
<div class="row">
<br class="col-md-4">
<form method="post">
<div class="form-group">
<label for="inputText">Enter the clinical text to code to ICD10:</label>
<textarea asp-for="ClinicalText" class="form-control" required style="height: 120px;" placeholder="Enter the clinical text to code..."></textarea>
</div>
<br />

<button type="submit" class="btn btn-primary float-right" style="float: right;">Code with AutoICD API</button>

</form>
</div>
</div>

<br />
<label for="outputText">API Response::</label>
<div class="code-block">
<pre><code>@Html.Raw(Model.Output)</code></pre>
</div>

Run the project and you should get something like the following:

AutoICD CAC project UI

Now that our UI is all set, we can proceed with our controller.

Step 3 β€” Invoke the API from the controller

At this point we need to invoke the AutoICD API, passing the clinical text entered by the user and populating the API Response section with the response.

Open Index.cshtml.cs file and paste the following piece of code:

using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Options;
using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;

namespace AutoICD10_Example.Pages
{
public class IndexModel : PageModel
{
private readonly ILogger<IndexModel> _logger;
[BindProperty]
public string Output { get; set; }

[BindProperty]
public string ClinicalText { get; set; } = "Acute kidney injury on chronic kidney disease. Anemia. Chronic renal failure. No evidence of cardiovascular disease or liver dysfunction was found. Patient presents with uncontrolled hypertension, hyperlipidemia, and obesity. Blood tests indicate impaired glucose tolerance. Family history includes a high incidence of coronary artery disease and type 2 diabetes. Physical exam reveals peripheral edema and mild shortness of breath upon exertion.";
private readonly AutoIcdSettings _autoIcdSettings;
public IndexModel(ILogger<IndexModel> logger, IOptions<AutoIcdSettings> autoIcdSettings)
{
_logger = logger;
_autoIcdSettings = autoIcdSettings.Value;
}

public async Task OnPost()
{
using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _autoIcdSettings.AuthToken);
var jsonContent = new { text = ClinicalText };
var content = new StringContent(JsonSerializer.Serialize(jsonContent), Encoding.UTF8, "application/json");
var response = await client.PostAsync(_autoIcdSettings.BaseApiUrl + "code", content);

if (response.IsSuccessStatusCode)
{
var responseContent = await response.Content.ReadAsStringAsync();
var prettyJson = JsonDocument.Parse(responseContent).RootElement.GetRawText();
var options = new JsonSerializerOptions { WriteIndented = true };
Output = JsonSerializer.Serialize(JsonSerializer.Deserialize<object>(prettyJson), options);
}
}
}
}

Note that we’re initializing the input text with a good sample clinical text so the user can try it right away.

Also note that the AutoICD auth token is configured under the appsettings.json file, so make sure to put yours there:


"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"AutoICD": {
"authToken": "your-key-here",
"baseApiUrl": "https://icd10-5mryyszqna-ue.a.run.app/"
}
}

If you don’t have an API key you can get a demo one for free by contacting Auto ICD support.

Step 4 β€” Try it out!

All done, you can now run the project and try it by yourself, enter a clinical text, press the button and check out the result in JSON format:

Finished AutoICD CAC Example

Hope you enjoyed, you can check the whole code in this repo!
Also, you can access AutoICD API Docs here.

--

--

ICD-10 Coder
ICD-10 Coder

Written by ICD-10 Coder

ICD10 medical coder and Python/ML enthusiast. Sharing insights on healthcare and tech trends. Exploring machine learning APIs for clinical coding.

Responses (2)