Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
4f605be
Added AddCohortDistributionDataConfig.cs and used in AddCohortDistrib…
SamAinsworth-NHS Mar 7, 2025
c6a62fe
Added config class + changed Program.cs in RetrieveParticipantData fu…
SamAinsworth-NHS Mar 7, 2025
a256e4f
Added config class to ValidateCohortDistributionRecord + used in prog…
SamAinsworth-NHS Mar 7, 2025
025a1ea
Added config class and program.cs treatment to DemographicDataManagem…
SamAinsworth-NHS Mar 7, 2025
ebdfff6
Added new config scheme to DemographicDurableFunction
SamAinsworth-NHS Mar 7, 2025
7b4b375
Added config class to RetrievePDSDemographic
SamAinsworth-NHS Mar 7, 2025
1c4ea2b
Added CreateExceptionConfig for CreateException function
SamAinsworth-NHS Mar 7, 2025
936cebc
Added AddParticipantConfig to AddParticipant Function
SamAinsworth-NHS Mar 7, 2025
9ad92b9
Add CheckParticipantExistsConfig to CheckParticipantExists function
SamAinsworth-NHS Mar 7, 2025
cb60745
Merge branch 'main' into continued-config-classes
SamAinsworth-NHS Mar 10, 2025
6fb3a1c
Added config class to GetParticipantReferenceData function
SamAinsworth-NHS Mar 10, 2025
d940c30
Added config class to RemoveParticipant function
SamAinsworth-NHS Mar 10, 2025
a8161bc
Added config class to UpdateParticipant function
SamAinsworth-NHS Mar 10, 2025
9e388b4
Added config class to UpdateParticipantFromScreeningProvider function
SamAinsworth-NHS Mar 10, 2025
ee92ce7
Added config class to CreateParticipant function app
SamAinsworth-NHS Mar 10, 2025
8f9d9c1
Added config class to GetValidationExceptions function
SamAinsworth-NHS Mar 10, 2025
2f22c6a
Added config classes to 3 functions: markParticipantAsEligible, markP…
SamAinsworth-NHS Mar 10, 2025
6e15666
Added config class to RemoveValidationException function
SamAinsworth-NHS Mar 10, 2025
488bd91
Merge branch 'main' into continued-config-classes
SamAinsworth-NHS Mar 10, 2025
1333c20
Merge branch 'main' into continued-config-classes
SamAinsworth-NHS Mar 11, 2025
d3eda01
Cleared environment variable usage from rest of RetrieveMeshFile func…
SamAinsworth-NHS Mar 11, 2025
ba76b4b
Removed env var direct usage from CreateCohortDistribution function
SamAinsworth-NHS Mar 11, 2025
88af1e7
Removed all direct calls to env vars in RetrieveParticipantData function
SamAinsworth-NHS Mar 11, 2025
a05abfe
Removed environment variable usage from ValidateCohortDistributionRec…
SamAinsworth-NHS Mar 12, 2025
790a630
Removed direct usage of env vars from RetrievePDSDemographic and addP…
SamAinsworth-NHS Mar 12, 2025
85efd0a
Removed env var usage from RemoveParticipant function app
SamAinsworth-NHS Mar 12, 2025
6d4a4e8
Removed env var direct usage from updateParticipant
SamAinsworth-NHS Mar 12, 2025
73a6395
Removed env var direct usage from createParticipant function
SamAinsworth-NHS Mar 12, 2025
8b2d70b
Removed env var direct usage from markParticipantAsIneligible function
SamAinsworth-NHS Mar 12, 2025
e4455a1
Removed direct env var usage from updateParticipantDetails function
SamAinsworth-NHS Mar 12, 2025
d8b2b2b
Removed env var usage from FileValidation function, added config class
SamAinsworth-NHS Mar 12, 2025
c57b3c3
Updated FileValidation function Program.cs to include new config class
SamAinsworth-NHS Mar 12, 2025
a88cc1f
Removed env var usage from StaticValidation function, added new Stati…
SamAinsworth-NHS Mar 12, 2025
117a76f
Removed required flag on markParticipantAsIneligible in updatePartici…
SamAinsworth-NHS Mar 12, 2025
255a6d4
Corrected FileValidationTests to inject new config object
SamAinsworth-NHS Mar 13, 2025
79bc860
Corrected MarkParticipantAsIneligible unit tests to inject new config…
SamAinsworth-NHS Mar 13, 2025
b419f50
Corrected CreateParticipantTest.cs unit tests to inject new config ob…
SamAinsworth-NHS Mar 13, 2025
88eab7c
Corrected more unit tests with prefilled config object
SamAinsworth-NHS Mar 13, 2025
c8efc7a
Merge branch 'main' into continued-config-classes
SamAinsworth-NHS Mar 13, 2025
620f74a
Merge branch 'main' into continued-config-classes
SamAinsworth-NHS Mar 18, 2025
bd21933
Merge branch 'main' into continued-config-classes
SamAinsworth-NHS Mar 18, 2025
3078a06
Merge branch 'main' into continued-config-classes
SamAinsworth-NHS Mar 18, 2025
753650f
Expanded and corrected config setup for RetrieveMeshFileTest
SamAinsworth-NHS Mar 18, 2025
c5b5060
Merge branch 'main' into continued-config-classes
SamAinsworth-NHS Mar 18, 2025
3690eb3
Updated RetrievePdsDemographicTests to include new config item
SamAinsworth-NHS Mar 20, 2025
a076fa0
Updated UpdateParticipantDetailsTests to include new config
SamAinsworth-NHS Mar 20, 2025
740fd87
Removed incorrect change to CreateParticipantTest.cs
SamAinsworth-NHS Mar 20, 2025
7ca3eef
Merge branch 'main' into continued-config-classes
SamAinsworth-NHS Mar 20, 2025
da2ee1f
cleaned up and fixed MarkParticipantAsIneligibleTests
SamAinsworth-NHS Mar 20, 2025
5d7df76
Merge branch 'main' into continued-config-classes
SamAinsworth-NHS Mar 20, 2025
8597d7b
Merge branch 'main' into continued-config-classes
SamAinsworth-NHS Mar 20, 2025
114062f
Made markParticipantAsIneligible in UpdateParticipantConfig Required
SamAinsworth-NHS Mar 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@

host.AddConfiguration<RetrieveMeshFileConfig>(out RetrieveMeshFileConfig config);

if (!string.IsNullOrEmpty(KeyVaultConnectionString))
if (!string.IsNullOrEmpty(config.KeyVaultConnectionString))
{
logger.LogInformation("Pulling Mesh Certificate from KeyVault");
var client = new CertificateClient(vaultUri: new Uri(KeyVaultConnectionString), credential: new DefaultAzureCredential());
var client = new CertificateClient(vaultUri: new Uri(config.KeyVaultConnectionString), credential: new DefaultAzureCredential());
var certificate = await client.DownloadCertificateAsync(config.MeshKeyName);
cert = certificate.Value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class RetrieveMeshFile
private readonly string _mailboxId;
private readonly string _blobConnectionString;
private readonly IBlobStorageHelper _blobStorageHelper;
private readonly RetrieveMeshFileConfig _config;
private const string NextHandShakeTimeConfigKey = "NextHandShakeTime";
private const string ConfigFileName = "MeshState.json";

Expand All @@ -31,7 +32,8 @@ public RetrieveMeshFile(ILogger<RetrieveMeshFile> logger, IMeshToBlobTransferHan
_meshToBlobTransferHandler = meshToBlobTransferHandler;
_blobStorageHelper = blobStorageHelper;
_mailboxId = options.Value.BSSMailBox;
_blobConnectionString = Environment.GetEnvironmentVariable("caasfolder_STORAGE");
_config = options.Value;
_blobConnectionString = _config.caasfolder_STORAGE;
}
/// <summary>
/// This function polls the MESH Mailbox every 5 minutes, if there is a file posted to the mailbox.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ public class RetrieveMeshFileConfig
[Required]
public string MeshPassword { get; set; }
[Required]
public string MeshSharedKey { get; set; }
public string MeshKeyPassphrase { get; set; }
public string MeshKeyName { get; set; }

public string MeshSharedKey {get; set;}
public string MeshKeyPassphrase {get; set;}
public string MeshKeyName {get; set;}
public string KeyVaultConnectionString {get; set;}
[Required]
public string caasfolder_STORAGE {get; set;}
public string ServerSideCerts { get; set; }

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace NHS.Screening.AddCohortDistribution;

using System.ComponentModel.DataAnnotations;

public class AddCohortDistributionDataConfig
{
[Required]
public string CohortDistributionDataServiceURL {get; set;}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
using Microsoft.Extensions.Hosting;
using Model;
using HealthChecks.Extensions;
using NHS.Screening.AddCohortDistribution;

var host = new HostBuilder()
.AddDataServicesHandler()
.AddDataService<CohortDistribution>(Environment.GetEnvironmentVariable("CohortDistributionDataServiceURL"))
.Build()
.AddConfiguration<AddCohortDistributionDataConfig>(out AddCohortDistributionDataConfig config)
.AddDataServicesHandler()
.AddDataService<CohortDistribution>(config.CohortDistributionDataServiceURL)
.Build()
.ConfigureFunctionsWorkerDefaults()
.ConfigureServices(services =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ namespace NHS.CohortManager.CohortDistributionService;
using Model.Enums;
using Data.Database;
using DataServices.Client;
using NHS.Screening.CreateCohortDistribution;
using Microsoft.Extensions.Options;

public class CreateCohortDistribution
{
Expand All @@ -18,18 +20,21 @@ public class CreateCohortDistribution
private readonly ICohortDistributionHelper _CohortDistributionHelper;
private readonly IExceptionHandler _exceptionHandler;
private readonly IAzureQueueStorageHelper _azureQueueStorageHelper;
private readonly CreateCohortDistributionConfig _config;

public CreateCohortDistribution(ILogger<CreateCohortDistribution> logger,
ICallFunction callFunction,
ICohortDistributionHelper CohortDistributionHelper,
IExceptionHandler exceptionHandler,
IAzureQueueStorageHelper azureQueueStorageHelper)
IAzureQueueStorageHelper azureQueueStorageHelper,
IOptions<CreateCohortDistributionConfig> createCohortDistributionConfig)
{
_logger = logger;
_callFunction = callFunction;
_CohortDistributionHelper = CohortDistributionHelper;
_exceptionHandler = exceptionHandler;
_azureQueueStorageHelper = azureQueueStorageHelper;
_config = createCohortDistributionConfig.Value;
}

[Function(nameof(CreateCohortDistribution))]
Expand Down Expand Up @@ -64,7 +69,7 @@ public async Task RunAsync([QueueTrigger("%CohortQueueName%", Connection = "Azur
}

// Check if participant has exceptions
bool ignoreParticipantExceptions = Environment.GetEnvironmentVariable("IgnoreParticipantExceptions") == "true";
bool ignoreParticipantExceptions = _config.IgnoreParticipantExceptions;
_logger.LogInformation("Environment variable IgnoreParticipantExceptions is set to {IgnoreParticipantExceptions}", ignoreParticipantExceptions);
bool participantHasException = participantData.ExceptionFlag == 1;

Expand Down Expand Up @@ -121,14 +126,14 @@ private async Task HandleErrorResponseAsync(string errorMessage, CohortDistribut
}

await _exceptionHandler.CreateSystemExceptionLog(new Exception(errorMessage), participant, fileName);
await _azureQueueStorageHelper.AddItemToQueueAsync<CohortDistributionParticipant>(cohortDistributionParticipant, Environment.GetEnvironmentVariable("CohortQueueNamePoison"));
await _azureQueueStorageHelper.AddItemToQueueAsync<CohortDistributionParticipant>(cohortDistributionParticipant, _config.CohortQueueNamePoison);
}

private async Task<HttpWebResponse> AddCohortDistribution(CohortDistributionParticipant transformedParticipant)
{
transformedParticipant.Extracted = DatabaseHelper.ConvertBoolStringToBoolByType("IsExtractedToBSSelect", DataTypes.Integer).ToString();
var json = JsonSerializer.Serialize(transformedParticipant);
var response = await _callFunction.SendPost(Environment.GetEnvironmentVariable("AddCohortDistributionURL"), json);
var response = await _callFunction.SendPost(_config.AddCohortDistributionURL, json);

_logger.LogInformation("Called {AddCohortDistribution} function", nameof(AddCohortDistribution));
return response;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace NHS.Screening.CreateCohortDistribution;

using System.ComponentModel.DataAnnotations;

public class CreateCohortDistributionConfig
{
[Required]
public bool IgnoreParticipantExceptions {get; set;}
[Required]
public string CohortQueueNamePoison {get; set;}
[Required]
public string AddCohortDistributionURL {get; set;}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Hosting;
using DataServices.Client;
using Model;
using NHS.Screening.CreateCohortDistribution;
using HealthChecks.Extensions;

var host = new HostBuilder()
.AddConfiguration<CreateCohortDistributionConfig>(out CreateCohortDistributionConfig config)
.ConfigureFunctionsWorkerDefaults()
.ConfigureServices(services =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Model;
using NHS.Screening.RetrieveParticipantData;

var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults()
.AddConfiguration<RetrieveParticipantDataConfig>(out RetrieveParticipantDataConfig config)
.AddDataServicesHandler()
.AddDataService<ParticipantManagement>(Environment.GetEnvironmentVariable("ParticipantManagementUrl"))
.AddDataService<ParticipantManagement>(config.ParticipantManagementUrl)
.Build()
.ConfigureServices(services =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ namespace NHS.CohortManager.CohortDistributionService;
using System.Text;
using System.Text.Json;
using DataServices.Client;
using Microsoft.Extensions.Options;
using NHS.Screening.RetrieveParticipantData;

public class RetrieveParticipantData
{
Expand All @@ -19,18 +21,20 @@ public class RetrieveParticipantData
private readonly ICreateParticipant _createParticipant;
private readonly IExceptionHandler _exceptionHandler;
private readonly IDataServiceClient<ParticipantManagement> _participantManagementClient;
private readonly RetrieveParticipantDataConfig _config;

public RetrieveParticipantData(ICreateResponse createResponse, ILogger<RetrieveParticipantData> logger,
IDataServiceClient<ParticipantManagement> participantManagementClient,
ICreateParticipant createParticipant, IExceptionHandler exceptionHandler,
ICallFunction callFunction)
ICallFunction callFunction, IOptions<RetrieveParticipantDataConfig> retrieveParticipantDataConfig)
{
_createResponse = createResponse;
_logger = logger;
_callFunction = callFunction;
_createParticipant = createParticipant;
_exceptionHandler = exceptionHandler;
_participantManagementClient = participantManagementClient;
_config = retrieveParticipantDataConfig.Value;
}

[Function("RetrieveParticipantData")]
Expand Down Expand Up @@ -68,7 +72,7 @@ public async Task<HttpResponseData> RunAsync([HttpTrigger(AuthorizationLevel.Ano
{"Id", requestBody.NhsNumber }
};

var demographicDataJson = await _callFunction.SendGet(Environment.GetEnvironmentVariable("DemographicDataFunctionURL"), demographicFunctionParams);
var demographicDataJson = await _callFunction.SendGet(_config.DemographicDataFunctionURL, demographicFunctionParams);

var demographicData = JsonSerializer.Deserialize<Demographic>(demographicDataJson);
if (demographicData == null)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace NHS.Screening.RetrieveParticipantData;

using System.ComponentModel.DataAnnotations;

public class RetrieveParticipantDataConfig
{
[Required]
public string ParticipantManagementUrl {get; set;}
[Required]
public string DemographicDataFunctionURL {get; set;}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Hosting;
using Model;
using NHS.Screening.ValidateCohortDistributionRecord;

var host = new HostBuilder()
.AddDataServicesHandler()
.AddDataService<CohortDistribution>(Environment.GetEnvironmentVariable("CohortDistributionDataServiceURL"))
.Build()
.AddConfiguration<ValidateCohortDistributionRecordConfig>(out ValidateCohortDistributionRecordConfig config)
.AddDataServicesHandler()
.AddDataService<CohortDistribution>(config.CohortDistributionDataServiceURL)
.Build()
.ConfigureFunctionsWorkerDefaults()
.ConfigureServices(services =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,36 @@ namespace NHS.CohortManager.CohortDistribution.ValidateCohortDistributionRecord;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Model;
using Model.Enums;
using NHS.Screening.ValidateCohortDistributionRecord;

public class ValidateCohortDistributionRecord
{
private readonly ILogger<ValidateCohortDistributionRecord> _logger;
private readonly ICreateResponse _createResponse;
private readonly IExceptionHandler _exceptionHandler;
private readonly ICallFunction _callFunction;

private readonly IDataServiceClient<CohortDistribution> _cohortDistributionDataService;
private readonly ValidateCohortDistributionRecordConfig _config;


public ValidateCohortDistributionRecord(ILogger<ValidateCohortDistributionRecord> logger, ICreateResponse createResponse, IExceptionHandler exceptionHandler, ICallFunction callFunction, IDataServiceClient<CohortDistribution> cohortDistributionDataService)
public ValidateCohortDistributionRecord(
ILogger<ValidateCohortDistributionRecord> logger,
ICreateResponse createResponse,
IExceptionHandler exceptionHandler,
ICallFunction callFunction,
IDataServiceClient<CohortDistribution> cohortDistributionDataService,
IOptions<ValidateCohortDistributionRecordConfig> validateCohortDistributionRecordConfig
)
{
_createResponse = createResponse;
_exceptionHandler = exceptionHandler;
_callFunction = callFunction;
_logger = logger;
_cohortDistributionDataService = cohortDistributionDataService;
_config = validateCohortDistributionRecordConfig.Value;
}
/// <summary>
/// Deserializes a ValidateCohortDistributionRecordBody object.
Expand Down Expand Up @@ -122,7 +132,7 @@ private async Task<ValidationExceptionLog> ValidateDataAsync(CohortDistributionP

_logger.LogInformation("Sending record to validation in ValidateCohortDistributionRecord");

var response = await _callFunction.SendPost(Environment.GetEnvironmentVariable("LookupValidationURL"), json);
var response = await _callFunction.SendPost(_config.LookupValidationURL, json);
var responseBodyJson = await _callFunction.GetResponseText(response);

_logger.LogInformation("validation response in ValidateCohortDistributionRecord was {response}", responseBodyJson);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace NHS.Screening.ValidateCohortDistributionRecord;

using System.ComponentModel.DataAnnotations;

public class ValidateCohortDistributionRecordConfig
{
[Required]
public string CohortDistributionDataServiceURL {get; set;}
[Required]
public string LookupValidationURL {get; set;}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace NHS.Screening.DemographicDataManagementFunction;

using System.ComponentModel.DataAnnotations;

public class DemographicDataManagementFunctionConfig
{
[Required]
public string ParticipantDemographicDataServiceURL {get; set;}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Model;
using NHS.Screening.DemographicDataManagementFunction;

var host = new HostBuilder()
.AddConfiguration<DemographicDataManagementFunctionConfig>(out DemographicDataManagementFunctionConfig config)
.AddDataServicesHandler()
.AddDataService<ParticipantDemographic>(Environment.GetEnvironmentVariable("ParticipantDemographicDataServiceURL"))
.AddDataService<ParticipantDemographic>(config.ParticipantDemographicDataServiceURL)
.Build()
.ConfigureFunctionsWorkerDefaults()
.ConfigureServices(services =>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace NHS.Screening.DemographicDurableFunction;

using System.ComponentModel.DataAnnotations;

public class DemographicDurableFunctionConfig
{
[Required]
public string DemographicDataServiceURL {get; set;}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
using Data.Database;
using Model;
using DataServices.Client;
using NHS.Screening.DemographicDurableFunction;
using HealthChecks.Extensions;

var host = new HostBuilder()
.AddConfiguration<DemographicDurableFunctionConfig>(out DemographicDurableFunctionConfig config)
.AddDataServicesHandler()
.AddDataService<ParticipantDemographic>(Environment.GetEnvironmentVariable("DemographicDataServiceURL"))
.AddDataService<ParticipantDemographic>(config.DemographicDataServiceURL)
.Build()
.ConfigureFunctionsWebApplication()
.ConfigureServices(services =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Model;
using NHS.Screening.RetrievePDSDemographic;

var host = new HostBuilder()
.AddConfiguration<RetrievePDSDemographicConfig>(out RetrievePDSDemographicConfig config)
.AddDataServicesHandler()
.AddDataService<ParticipantDemographic>(Environment.GetEnvironmentVariable("ParticipantDemographicDataServiceURL"))
.AddDataService<ParticipantDemographic>(config.ParticipantDemographicDataServiceURL)
.Build()
.ConfigureFunctionsWorkerDefaults()
.ConfigureServices(services =>
Expand Down
Loading