Handling MRNs (Medical Record Numbers) with Compensating Transactions in .NET Core Micro services using the Saga Pattern

Binu S 0 Reputation points
2024-06-20T13:54:23.2666667+00:00

In a hospital management system built with micro services using .NET Core and Entity Framework, how can we ensure data consistency when generating Medical Record Numbers (MRNs)? Since MRNs cannot be deleted, how can we handle situations where a downstream service failure occurs after MRN generation using the Saga pattern with compensating transactions?

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,328 questions
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,167 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,551 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 59,966 Reputation points
    2024-06-20T15:40:51.0266667+00:00

    you have two options:

    • throw away MRN that get rolled back. This is how sqlserver handles identity column on rollback. the number is never reused.
    • assign the MRN as the last step of the saga.