Skip to content

Commit 2895776

Browse files
Joseph2910MWClayson-NHS
authored andcommitted
test: Rule 8 transformations (#1542)
* feat: Update rule 8 transformation * test: Add playwright tests for rule 8 * fix: Test file names * chore: Simplify transform rule * chore: Add in rule8 tests to runner * fix: Updated some tests * chore: delete unused tests * chore: Small fixes * chore: push debug * fix: Remove logging * fix lookup methods * chore: Add Terraform and Docker * fix: update Unit test signature * fix: Test --------- Co-authored-by: Michael Clayson <michael.clayson1@nhs.net>
1 parent 866cf90 commit 2895776

29 files changed

Lines changed: 1211 additions & 16 deletions

application/CohortManager/compose.cohort-distribution.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ services:
7676
- BsSelectGpPracticeUrl=http://reference-data-service:7988/api/BsSelectGpPractice
7777
- DtOsDatabaseConnectionString=Server=db,1433;Database=${DB_NAME};User Id=SA;Password=${PASSWORD};TrustServerCertificate=True
7878
- LanguageCodeUrl=http://reference-data-service:7988/api/LanguageCode
79+
- CurrentPostingUrl=http://reference-data-service:7988/api/CurrentPosting
7980
- ExcludedSMULookupUrl=http://reference-data-service:7988/api/ExcludedSMU
8081
- AcceptableLatencyThresholdMs=500
8182

application/CohortManager/src/Functions/CohortDistributionServices/TransformDataService/ITransformDataLookupFacade.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ public interface ITransformDataLookupFacade
99
public string GetBsoCodeUsingPCP(string primaryCareProvider);
1010
public bool ValidateLanguageCode(string languageCode);
1111
public Task<HashSet<string>> GetCachedExcludedSMUValues();
12+
string RetrievePostingCategory(string currentPosting);
1213
}

application/CohortManager/src/Functions/CohortDistributionServices/TransformDataService/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
.AddDataServiceStaticCachedClient<BsSelectGpPractice>(config.BsSelectGpPracticeUrl)
1818
.AddDataServiceStaticCachedClient<LanguageCode>(config.LanguageCodeUrl)
1919
.AddDataServiceStaticCachedClient<ExcludedSMULookup>(config.ExcludedSMULookupUrl)
20+
.AddDataServiceStaticCachedClient<CurrentPosting>(config.CurrentPostingUrl)
2021
.Build()
2122
.ConfigureServices(services =>
2223
{

application/CohortManager/src/Functions/CohortDistributionServices/TransformDataService/TransformDataLookupFacade.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class TransformDataLookupFacade : ITransformDataLookupFacade
1414
private readonly IDataServiceClient<BsSelectGpPractice> _bsSelectGPPracticeClient;
1515
private readonly IDataServiceClient<LanguageCode> _languageCodeClient;
1616
private readonly IDataServiceClient<ExcludedSMULookup> _excludedSMUClient;
17+
private readonly IDataServiceClient<CurrentPosting> _currentPostingClient;
1718
private readonly IMemoryCache _memoryCache;
1819
private readonly TransformDataServiceConfig _transformDataServiceConfig;
1920

@@ -22,6 +23,7 @@ public TransformDataLookupFacade(IDataServiceClient<BsSelectOutCode> outcodeClie
2223
IDataServiceClient<BsSelectGpPractice> bsSelectGPPracticeClient,
2324
IDataServiceClient<LanguageCode> languageCodeClient,
2425
IDataServiceClient<ExcludedSMULookup> excludedSMUClient,
26+
IDataServiceClient<CurrentPosting> currentPostingClient,
2527
ILogger<TransformDataLookupFacade> logger,
2628
IMemoryCache memoryCache,
2729
IOptions<TransformDataServiceConfig> transformDataServiceConfig)
@@ -30,6 +32,7 @@ public TransformDataLookupFacade(IDataServiceClient<BsSelectOutCode> outcodeClie
3032
_bsSelectGPPracticeClient = bsSelectGPPracticeClient;
3133
_languageCodeClient = languageCodeClient;
3234
_excludedSMUClient = excludedSMUClient;
35+
_currentPostingClient = currentPostingClient;
3336
_memoryCache = memoryCache;
3437
_logger = logger;
3538
_transformDataServiceConfig = transformDataServiceConfig.Value;
@@ -113,4 +116,14 @@ public string GetBsoCodeUsingPCP(string primaryCareProvider)
113116

114117
return gpPractice.BsoCode;
115118
}
119+
120+
public string RetrievePostingCategory(string currentPosting)
121+
{
122+
if (string.IsNullOrEmpty(currentPosting))
123+
{
124+
return null;
125+
}
126+
var result = _currentPostingClient.GetSingle(currentPosting).Result;
127+
return result.PostingCategory;
128+
}
116129
}

application/CohortManager/src/Functions/CohortDistributionServices/TransformDataService/TransformDataServiceConfig.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class TransformDataServiceConfig
1414
public string LanguageCodeUrl { get; set; }
1515
[Required]
1616
public string ExcludedSMULookupUrl { get; set; }
17-
17+
[Required]
18+
public string CurrentPostingUrl { get; set; }
1819
public int CacheTimeOutHours { get; set; } = 24;
1920
}

application/CohortManager/src/Functions/CohortDistributionServices/TransformDataService/transformRules.json

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,19 @@
66
"RuleName": "8.Transform.UpdatedRecordExcludedAndDMS",
77
"LocalParams": [
88
{
9-
"Name": "IsPrimaryCareProviderNullOnUpdatedParticipant",
10-
"Expression": "participant.PrimaryCareProvider == null"
9+
"Name": "DMSInSMU",
10+
"Expression": "participant.CurrentPosting == \"DMS\" && excludedSMUList.Contains(participant.PrimaryCareProvider)"
1111
},
1212
{
13-
"Name": "IsPrimaryCareProviderNullDatabaseParticipant",
14-
"Expression": "databaseParticipant.PrimaryCareProvider == null"
13+
"Name": "WelshCurrentPosting",
14+
"Expression": "dbLookup.RetrievePostingCategory(participant.CurrentPosting) == \"WALES\""
1515
},
1616
{
17-
"Name": "IsNewRecordInSMU",
18-
"Expression": "participant.CurrentPosting == \"DMS\" && (IsPrimaryCareProviderNullOnUpdatedParticipant ? false : !excludedSMUList.Contains(participant.PrimaryCareProvider)) || new string[] { \"English\", \"NHAIS\", \"Cipher\", \"ENG\", \"IM\" }.Contains(participant.CurrentPosting)"
19-
},
20-
{
21-
"Name": "IsOldRecordInSMU",
22-
"Expression": "databaseParticipant.CurrentPosting == \"DMS\" && (IsPrimaryCareProviderNullDatabaseParticipant ? false : excludedSMUList.Contains(databaseParticipant.PrimaryCareProvider)) || new string[] { \"Welsh\", \"NHAIS\", \"Cipher\", \"CYM\" }.Contains(databaseParticipant.CurrentPosting)"
17+
"Name": "NoTransformationRequired",
18+
"Expression": "existingParticipant.PrimaryCareProvider == null && existingParticipant.ReasonForRemoval == \"ORR\""
2319
}
2420
],
25-
"Expression": "participant.RecordType == Actions.Amended && IsNewRecordInSMU && IsOldRecordInSMU",
21+
"Expression": "participant.RecordType == Actions.Amended && (DMSInSMU || WelshCurrentPosting) && !NoTransformationRequired",
2622
"Actions": {
2723
"OnSuccess": {
2824
"Name": "TransformAction",
@@ -48,6 +44,37 @@
4844
}
4945
}
5046
},
47+
{
48+
"RuleName": "8a.Transform.NoTransformButError",
49+
"LocalParams": [
50+
{
51+
"Name": "DMSInSMU",
52+
"Expression": "participant.CurrentPosting == \"DMS\" && excludedSMUList.Contains(participant.PrimaryCareProvider)"
53+
},
54+
{
55+
"Name": "WelshCurrentPosting",
56+
"Expression": "dbLookup.RetrievePostingCategory(participant.CurrentPosting) == \"WALES\""
57+
},{
58+
"Name": "NoTransformationRequired",
59+
"Expression": "existingParticipant.PrimaryCareProvider == null && existingParticipant.ReasonForRemoval == \"ORR\""
60+
}
61+
],
62+
"Expression": "participant.RecordType == Actions.Amended && (DMSInSMU || WelshCurrentPosting) && NoTransformationRequired",
63+
"Actions": {
64+
"OnSuccess": {
65+
"Name": "TransformAction",
66+
"Context": {
67+
"transformFields": [
68+
{
69+
"isExpression": false,
70+
"field": "PrimaryCareProvider",
71+
"value": null
72+
}
73+
]
74+
}
75+
}
76+
}
77+
},
5178
{
5279
"RuleName": "00.Other.InvalidFlag.TrueAndNoPrimaryCareProvider",
5380
"Expression": "(!string.IsNullOrEmpty(participant.PrimaryCareProvider) && participant.InvalidFlag == \"1\") OR participant.RecordType == Actions.Removed",

infrastructure/tf-core/environments/development.tfvars

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,11 @@ function_apps = {
670670
function_app_key = "ReferenceDataService"
671671
endpoint_name = "LanguageCode"
672672
},
673+
{
674+
env_var_name = "CurrentPostingUrl"
675+
function_app_key = "ReferenceDataService"
676+
endpoint_name = "CurrentPosting"
677+
},
673678
{
674679
env_var_name = "ExcludedSMULookupUrl"
675680
function_app_key = "ReferenceDataService"

infrastructure/tf-core/environments/integration.tfvars

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,11 @@ function_apps = {
671671
function_app_key = "ReferenceDataService"
672672
endpoint_name = "LanguageCode"
673673
},
674+
{
675+
env_var_name = "CurrentPostingUrl"
676+
function_app_key = "ReferenceDataService"
677+
endpoint_name = "CurrentPosting"
678+
},
674679
{
675680
env_var_name = "ExcludedSMULookupUrl"
676681
function_app_key = "ReferenceDataService"

infrastructure/tf-core/environments/nft.tfvars

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,11 @@ function_apps = {
670670
function_app_key = "ReferenceDataService"
671671
endpoint_name = "LanguageCode"
672672
},
673+
{
674+
env_var_name = "CurrentPostingUrl"
675+
function_app_key = "ReferenceDataService"
676+
endpoint_name = "CurrentPosting"
677+
},
673678
{
674679
env_var_name = "ExcludedSMULookupUrl"
675680
function_app_key = "ReferenceDataService"

infrastructure/tf-core/environments/preprod.tfvars

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,11 @@ function_apps = {
671671
function_app_key = "ReferenceDataService"
672672
endpoint_name = "LanguageCode"
673673
},
674+
{
675+
env_var_name = "CurrentPostingUrl"
676+
function_app_key = "ReferenceDataService"
677+
endpoint_name = "CurrentPosting"
678+
},
674679
{
675680
env_var_name = "ExcludedSMULookupUrl"
676681
function_app_key = "ReferenceDataService"

0 commit comments

Comments
 (0)