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: 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..4bfa0746 100644 --- a/HICPlugin/Mutilators/CHIMutilator.cs +++ b/HICPlugin/Mutilators/CHIMutilator.cs @@ -60,50 +60,50 @@ 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 - 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 - - 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 "; } 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")]