From d8ccbe9b5c9cdaf698ccafc2d68caf2366c00a04 Mon Sep 17 00:00:00 2001 From: James Friel Date: Tue, 4 Nov 2025 11:29:51 +0000 Subject: [PATCH 1/3] allow mod10 chis --- HICPlugin/DataFlowComponents/CHIColumnFinder.cs | 12 +++++++++--- HICPlugin/Mutilators/CHIMutilator.cs | 9 +++++++-- HICPluginTests/HICPluginTests.csproj | 6 +++--- HICPluginTests/Integration/CHIColumnFinderTests.cs | 11 +++++++++++ RDMP | 2 +- SCIStorePlugin/SCIStorePlugin.csproj | 2 +- SharedAssemblyInfo.cs | 6 +++--- 7 files changed, 35 insertions(+), 13 deletions(-) diff --git a/HICPlugin/DataFlowComponents/CHIColumnFinder.cs b/HICPlugin/DataFlowComponents/CHIColumnFinder.cs index 94c678f9..eac77d27 100644 --- a/HICPlugin/DataFlowComponents/CHIColumnFinder.cs +++ b/HICPlugin/DataFlowComponents/CHIColumnFinder.cs @@ -176,9 +176,15 @@ public void Check(ICheckNotifier notifier) // True if date exists and checksum matches private static bool ValidBits(int d, int m, int y, int c) { - c %= 11; - if (c != 0) return false; - + var modElevenCheck = c % 11; + if (modElevenCheck != 0) + { + var modTenCheck = c % 10; + if (modTenCheck != 0) + { + return false; + } + } return m switch { 1 or 3 or 5 or 7 or 8 or 10 or 12 => d is > 0 and < 32, diff --git a/HICPlugin/Mutilators/CHIMutilator.cs b/HICPlugin/Mutilators/CHIMutilator.cs index f66c18ef..4eeac0ad 100644 --- a/HICPlugin/Mutilators/CHIMutilator.cs +++ b/HICPlugin/Mutilators/CHIMutilator.cs @@ -60,7 +60,6 @@ private static string CreateCHIFunction() CREATE FUNCTION [dbo].[checkCHI](@CHI as varchar(255)) RETURNS bit AS BEGIN - DECLARE @SumTotal int DECLARE @CheckDigit int DECLARE @Result bit @@ -99,7 +98,13 @@ WHILE @i < 9 --Compare Check Digit IF @CheckDigit = convert(int,substring(@CHI,10,1)) SET @Result = 1 - + ELSE + DECLARE @Mod10CheckDigit int + SET @Mod10CheckDigit = 10- (@SumTotal % 10) + IF @Mod10CheckDigit =10 + SET @Mod10CheckDigit =0 + IF @Mod10CheckDigit = convert(int,substring(@CHI,10,1)) + SET @Result = 1 RETURN @Result END diff --git a/HICPluginTests/HICPluginTests.csproj b/HICPluginTests/HICPluginTests.csproj index 58fccdcb..52dbf933 100644 --- a/HICPluginTests/HICPluginTests.csproj +++ b/HICPluginTests/HICPluginTests.csproj @@ -11,13 +11,13 @@ - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/HICPluginTests/Integration/CHIColumnFinderTests.cs b/HICPluginTests/Integration/CHIColumnFinderTests.cs index 0c5c1775..dda61ba3 100644 --- a/HICPluginTests/Integration/CHIColumnFinderTests.cs +++ b/HICPluginTests/Integration/CHIColumnFinderTests.cs @@ -39,4 +39,15 @@ public void IgnoreColumnsAvoidsCHIChecking() _chiFinder.PreInitialize(_request, ThrowImmediatelyDataLoadEventListener.Quiet); Assert.DoesNotThrow(() => _chiFinder.ProcessPipelineData(toProcess, _listener, null)); } + + [Test] + public void CHIMod10Check() + { + using var toProcess = new DataTable(); + toProcess.Columns.Add("Height"); + toProcess.Columns.Add("CHI"); + toProcess.Rows.Add(new object[] { 145, "0106851230" }); + DataTable result; + var exc= Assert.Throws(() => result = _chiFinder.ProcessPipelineData(toProcess, _listener, null)); + } } diff --git a/RDMP b/RDMP index 2d888af2..a60bb305 160000 --- a/RDMP +++ b/RDMP @@ -1 +1 @@ -Subproject commit 2d888af249bae7208efbef1a73135938edb71c94 +Subproject commit a60bb305224f9f10cc5c39e6333bc685e4d89b05 diff --git a/SCIStorePlugin/SCIStorePlugin.csproj b/SCIStorePlugin/SCIStorePlugin.csproj index 1b2d28ba..fcb10467 100644 --- a/SCIStorePlugin/SCIStorePlugin.csproj +++ b/SCIStorePlugin/SCIStorePlugin.csproj @@ -126,7 +126,7 @@ - + diff --git a/SharedAssemblyInfo.cs b/SharedAssemblyInfo.cs index 07963d11..5395179f 100644 --- a/SharedAssemblyInfo.cs +++ b/SharedAssemblyInfo.cs @@ -10,6 +10,6 @@ [assembly: AssemblyCulture("")] // These should be overwritten by release builds -[assembly: AssemblyVersion("6.1.15")] -[assembly: AssemblyFileVersion("6.1.15")] -[assembly: AssemblyInformationalVersion("6.1.15")] +[assembly: AssemblyVersion("6.1.16")] +[assembly: AssemblyFileVersion("6.1.16")] +[assembly: AssemblyInformationalVersion("6.1.16")] From f30e2e11b8c8e56ad55cdb19834982c8d3e9949f Mon Sep 17 00:00:00 2001 From: James Friel Date: Tue, 4 Nov 2025 11:31:16 +0000 Subject: [PATCH 2/3] bump rdmp version --- .github/workflows/dotnet-core.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dotnet-core.yml b/.github/workflows/dotnet-core.yml index ca690cf5..b085dec6 100644 --- a/.github/workflows/dotnet-core.yml +++ b/.github/workflows/dotnet-core.yml @@ -15,7 +15,7 @@ jobs: - uses: actions/checkout@v4 with: repository: HicServices/RDMP - ref: v9.0.0-rc1 + ref: v9.0.3 path: RDMP - uses: actions/setup-dotnet@v4 with: From 1e1352b459d9f1167fb364b698241fea8a31bd33 Mon Sep 17 00:00:00 2001 From: James Friel Date: Tue, 4 Nov 2025 12:44:25 +0000 Subject: [PATCH 3/3] update sql --- HICPlugin/Mutilators/CHIMutilator.cs | 91 +++++++++++++--------------- 1 file changed, 43 insertions(+), 48 deletions(-) diff --git a/HICPlugin/Mutilators/CHIMutilator.cs b/HICPlugin/Mutilators/CHIMutilator.cs index 4eeac0ad..4bfa0746 100644 --- a/HICPlugin/Mutilators/CHIMutilator.cs +++ b/HICPlugin/Mutilators/CHIMutilator.cs @@ -61,54 +61,49 @@ CREATE FUNCTION [dbo].[checkCHI](@CHI as varchar(255)) RETURNS bit AS BEGIN DECLARE @SumTotal int - DECLARE @CheckDigit int - DECLARE @Result bit - DECLARE @i int - SET @i = 0 - SET @SumTotal = 0 - SET @Result = 0 - --return 0 if the CHI is non-numeric - IF(ISNUMERIC(@CHI) <> 1) - RETURN 0 - - --return 0 if the day of birth is greater than 31 - IF(LEFT(@CHI, 2) > 31) - RETURN 0 - - --return 0 if the month of birth is greater than 12 - IF(SUBSTRING(@CHI, 3, 2) > 12) - RETURN 0 - - --return 0 if the CHI is not 10 digits long - IF(LEN(@CHI) = 10) - BEGIN - --Calculate the sum - WHILE @i < 9 - BEGIN - SET @SumTotal = @SumTotal + (convert(int,substring(@CHI,@i+1,1)) * (10 - @i)) - SET @i = @i + 1 - END - - --Obtain Check Digit - SET @CheckDigit = 11 - (@SumTotal % 11) - - IF @CheckDigit = 11 - SET @CheckDigit = 0 - - --Compare Check Digit - IF @CheckDigit = convert(int,substring(@CHI,10,1)) - SET @Result = 1 - ELSE - DECLARE @Mod10CheckDigit int - SET @Mod10CheckDigit = 10- (@SumTotal % 10) - IF @Mod10CheckDigit =10 - SET @Mod10CheckDigit =0 - IF @Mod10CheckDigit = convert(int,substring(@CHI,10,1)) - SET @Result = 1 - RETURN @Result - END - - RETURN 0 +  DECLARE @CheckDigit11Mod int +  DECLARE @CheckDigit10Mod int +  DECLARE @Result bit +  DECLARE @i int +  SET @i = 0 +  SET @SumTotal = 0 +  SET @Result = 0 +  --return 0 if the CHI is non-numeric +  SET @CHI=REPLACE(@CHI,'.','-') -- remove '.' from the CHI as ISNUMERIC will consider CHI a number even if it has '.' +  IF(ISNUMERIC(@CHI) <> 1) +    RETURN 0 +  --return 0 if the CHI is not 10 digits long +  IF(LEN(@CHI) = 10) +  BEGIN +    --Calculate the sum +    WHILE @i < 9 +    BEGIN +      SET @SumTotal = @SumTotal + (convert(int,substring(@CHI,@i+1,1)) * (10 - @i)) +      SET @i = @i + 1 +    END + +    --Obtain Check Digit +    SET @CheckDigit11Mod = 11 - (@SumTotal % 11) + +    SET @CheckDigit10Mod = 10 - (@SumTotal % 10) + +    IF @CheckDigit11Mod = 11 +      SET @CheckDigit11Mod = 0 + +    IF @CheckDigit10Mod = 10 +      SET @CheckDigit10Mod = 0 + +    --Compare Check Digit +    IF @CheckDigit11Mod = convert(int,substring(@CHI,10,1)) +      SET @Result = 1 + +    IF @CheckDigit10Mod = convert(int,substring(@CHI,10,1)) +      SET @Result = 1 + +    RETURN @Result +  END + +  RETURN 0 END "; }