From 62d1eca7029627cb1fe24e1a7284d73ac56337b8 Mon Sep 17 00:00:00 2001 From: Dustin Burson <47367432+dustinburson@users.noreply.github.com> Date: Fri, 22 Apr 2022 16:41:33 -0700 Subject: [PATCH] Revert "Create patient resource using a deterministic id (#183)" (#186) This reverts commit 0600d8044268f4ccc96da6ef9171717b0d1b8a3d. --- .../Service/ResourceManagementService.cs | 27 +------------------ 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/src/lib/Microsoft.Health.Extensions.Fhir.R4/Service/ResourceManagementService.cs b/src/lib/Microsoft.Health.Extensions.Fhir.R4/Service/ResourceManagementService.cs index cec0f4b5..0c0420c6 100644 --- a/src/lib/Microsoft.Health.Extensions.Fhir.R4/Service/ResourceManagementService.cs +++ b/src/lib/Microsoft.Health.Extensions.Fhir.R4/Service/ResourceManagementService.cs @@ -4,8 +4,6 @@ // ------------------------------------------------------------------------------------------------- using System; -using System.Security.Cryptography; -using System.Text; using System.Threading.Tasks; using EnsureThat; using Hl7.Fhir.Model; @@ -71,10 +69,7 @@ protected async Task CreateResourceByIdentityAsync(Model.I propertySetter?.Invoke(resource, identifier); - // Generate id programatically and issue an update to FHIR service - // The resource will be created if the resource with the given id does not already exist. - resource.Id = ComputeSha256(identifier); - return await FhirService.UpdateResourceAsync(resource).ConfigureAwait(false); + return await FhirService.CreateResourceAsync(resource).ConfigureAwait(false); } private static Model.Identifier BuildIdentifier(string value, string system) @@ -82,25 +77,5 @@ private static Model.Identifier BuildIdentifier(string value, string system) var identifier = new Model.Identifier { Value = value, System = string.IsNullOrWhiteSpace(system) ? null : system }; return identifier; } - - private static string ComputeSha256(Model.Identifier identifier) - { - EnsureArg.IsNotNullOrWhiteSpace(identifier.Value, nameof(identifier.Value)); - - string plainTextSystemAndId = $"{identifier.System}_{identifier.Value}"; - - using (SHA256 hashAlgorithm = SHA256.Create()) - { - byte[] bytes = hashAlgorithm.ComputeHash(Encoding.UTF8.GetBytes(plainTextSystemAndId)); - - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < bytes.Length; i++) - { - sb.Append(bytes[i].ToString("x2")); - } - - return sb.ToString(); - } - } } } \ No newline at end of file