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?

Developer technologies | ASP.NET | ASP.NET Core
SQL Server | Other
Developer technologies | C#
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 78,311 Reputation points Volunteer Moderator
    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.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.