Products Technologies Demo Docs Blog Support Company

Document Protection in ASP.NET with TX Text Control: Healthcare Use Cases

This article explores document protection use cases in the healthcare domain. It also explains how to assign usernames, configure edit modes, and use editable regions based on user roles using the Document Editor in an ASP.NET Core application.

Document Protection in ASP.NET with TX Text Control: Healthcare Use Cases

With TX Text Control, document content can be protected by restricting formatting and editing options. Additionally, exceptions can be applied to specific regions within the document and assigned to users with editing permissions. This article explores document protection use cases in the healthcare domain. It also explains how to assign usernames, configure edit modes, and use editable regions based on user roles using the Document Editor in an ASP.NET Core application.

Document Protection in Healthcare Systems

Document protection is a valuable feature in TX Text Control that can be implemented in healthcare systems. Healthcare providers maintain documents for each patient to store and process important information, such as medical records, forms, and insurance billing. Below are some key use cases that show how document protection can be applied to these documents:

  • Electronic medical and health records (EMR and EHR): With TX Text Control, developers and users (admins) can protect records from unauthorized edits while allowing specific roles, such as doctors, nurses, or patients, to modify relevant sections by specifying editable regions and user permissions using the ribbon.
  • Consent forms: Developers can lock the content of the consent form to prevent changes. At the same time, they can allow patients to fill in specific fields, such as their name and signature.
  • Insurance and billing documents: Editable sections can be assigned to the billing department and patients while keeping the rest of the document protected.

By integrating document protection, hospitals, clinics, and insurance providers ensure data security and accuracy by allowing role-based access control to modify necessary fields. While these are key use cases, TX Text Control's document protection can be applied across various industries beyond healthcare, tailored to individual needs and specific requirements.

Learn More

To learn more about digital form workflows with electronic signatures and further use cases related to insurance claim forms, refer to these articles:

Healthcare Use Case: Digital Forms Workflow with Electronic Signatures
Use Case: Create, Deploy and Process Insurance Claim Forms

How to Use Document Protection with the TX Text Control Document Editor

Tutorial

Follow this tutorial to initialize and configure the TX Text Control Document Editor with ASP.NET Core:

Getting Started: Document Editor with ASP.NET Core

When applying document protection using TX Text Control, you can choose to fully lock the document, allow certain formatting options, or define editable regions for specific users. All the editing and formatting restrictions apply only when the Editmode is set to ReadAndSelect. From a technical perspective, the document is password-encrypted. When this encrypted file is loaded, it remains restricted or read-only. To enable editing, the user must provide the correct password.

This tutorial shows how to create and load a protected document, display the current user, and switch users using a dropdown button to test document protection.

Create the Protected Document

Assume that you are an admin editor responsible for managing all user-specific actions, such as configuring document permissions. Begin by creating an encrypted document.

Learn More

Text Control offers options to create an encrypted document, either via the UI or programmatically. Refer to the following articles:

Sneak Peek X15: MS Word Compatible Document Protection and Editable Regions
X15: Protected Documents Explained Simply

X15: Protected Documents Explained Simply - Part II

In this example, a Text Control formatted (.tx) document is generated using the TX Text Control Words with encryption enabled. The encrypted document includes editable regions exclusively assigned to the Doctor and Insurer roles. It is then uploaded to the Documents folder of the ASP.NET Core application.

Create Protected Document

Load the Protected Document, Set Up Usernames, and Edit Modes

To load the protected document and set the default user, update HomeController.cs under the Controllers folder in your ASP.NET Core MVC application. The following code retrieves the username from the query string, defaulting to the Insurer role if none is provided, and sets the path of the encrypted document to be loaded into the view.

public IActionResult Index([FromQuery] string? user) 
{ 
    ViewData["User"] = user ?? "Insurer"; 
    ViewData["DocumentPath"] = Path.Combine("Documents", "sampledoc.tx"); 
    return View(); 
}

To add the control to the view, open the Index.cshtml file located in the Views/Home folder. Add the following Razor markup to include the document path and current user.

@using TXTextControl.Web.MVC 

@{ 
   var userName = (string) ViewData["User"]!; 
   var docPath = (string) ViewData["DocumentPath"]!; 
}

The Editmode can be set to ReadOnly, ReadAndSelect, or Edit. Also, it can be set to UsePassword, but this option must be combined exclusively with the ReadAndSelect option using a bitwise OR operation. The following code snippet shows how to initialize the Document Editor with the ReadAndSelect and UsePassword edit modes. A specific username is set (Insurer in this case) using the UserNames property that accepts an array of names, where the first entry represents the current user.

@Html.TXTextControl().TextControl(settings => 
{ 
  settings.UserNames = new[] { userName }; 
    settings.EditMode = TXTextControl.Web.EditMode.ReadAndSelect | TXTextControl.Web.EditMode.UsePassword; 
}).LoadText(docPath, TXTextControl.Web.StreamType.InternalUnicodeFormat).Render()

A dialog box appears, prompting the user to enter a password to unlock the edit mode. This example reproduces a scenario where only the admin editor, or a user with password access, can unlock and edit the protected regions of the document. In the above code, UsePassword is enabled to show how password-protected editing looks and works in the Document Editor.

Load Protected Document

Switch Between User Roles to Test Document Protection

Use the following HTML snippet to simulate logging in as different user roles. It displays the current user, allows role selection via a dropdown, and updates the view based on the selected role when the "Set User" button is clicked. The selected username is added to the URL as a query string, letting the page reload with the new user context.

<div class="form-group col-lg-5 mt-3"> 
   <p>Logged in as: <strong>@userName</strong></p> 
   <select class="form-control mt-3" id="users"> 
      <option value="Doctor">Doctor</option> 
      <option value="Insurer">Insurer</option> 
   </select> 
   <button onclick="ReloadWithUser()" class="btn btn-success mt-3">Set User</button> 
</div>

And the corresponding JavaScript function ReloadWithUser is triggered:

function ReloadWithUser() { 
   window.location = document.location.origin + 
       document.location.pathname + 
       "?user=" + document.getElementById("users").value; 
}

By default, the Insurer is set as a current user when the document is initialized. The Insurer can edit only the region assigned to the Insurer role, as well as any section marked as editable by all users. The Insurer does not have permission to edit the region assigned to the Doctor role or any fully protected sections. This supports role-based editing and highlights the importance of document protection in managing user-specific access.

Test Document Protection

The user role is set to Doctor when Doctor is selected from the dropdown and the "Set User" button is triggered:

Test Document Protection

Conclusion

This article explains how to use TX Text Control's document protection features in an ASP.NET Core application, including key properties for setting edit modes, usernames, and editable regions. As a result, your application can easily be configured to meet the document protection needs of your business processes.

Stay in the loop!

Subscribe to the newsletter to receive the latest updates.

Also See

This post references the following in the documentation:

  • TXTextControl.Web.TextControl.EditMode Property
  • TXTextControl.Web.TextControl.UserNames Property

GitHub

Download and Fork This Sample on GitHub

We proudly host our sample code on github.com/TextControl.

Please fork and contribute.

Download ZIP

Open on GitHub

Open in Visual Studio

Requirements for this sample

  • TX Text Control .NET Server 33.0
  • Visual Studio 2022

ASP.NET

Integrate document processing into your applications to create documents such as PDFs and MS Word documents, including client-side document editing, viewing, and electronic signatures.

ASP.NET Core
Angular
Blazor
JavaScript
React
  • Angular
  • Blazor
  • React
  • JavaScript
  • ASP.NET MVC, ASP.NET Core, and WebForms

Learn more Trial token Download trial

Related Posts

ASP.NETASP.NET CoreDocument Editor

Getting Started Video Tutorial: Document Editor in ASP.NET Core C# on Linux

This video tutorial shows how to use the Document Editor in an ASP.NET Core application using C# and deploy on Linux using Docker. This tutorial is part of the TX Text Control Getting Started…


ASP.NETApp ServicesASP.NET Core

Deploying the TX Text Control Document Editor in an ASP.NET Core Web App to…

This tutorial shows how to deploy the TX Text Control Document Editor to Azure App Services using an ASP.NET Core Web App. The Document Editor is a powerful word processing component that can be…


AngularASP.NETBlazor

Building an ASP.NET Core Backend (Linux and Windows) for the Document Editor…

This article shows how to create a backend for the Document Editor and Viewer using ASP.NET Core. The backend can be hosted on Windows and Linux and can be used in Blazor, Angular, JavaScript, and…


ASP.NETBlazorASP.NET Core

TX Text Control for Blazor: Mail Merge Integration Tutorial

This tutorial shows how to integrate the TX Text Control MailMerge component into a Blazor application using the TX Text Control .NET Server.


ASP.NETBlazorASP.NET Core

TX Text Control Document Editor and Viewer for Blazor Released

We are very happy to announce the immediate availability of TX Text Control packages for Blazor. This article gives an overview of the available packages and how to use them.