Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -42,7 +42,7 @@ public RetrieveMeshFile(ILogger<RetrieveMeshFile> logger, IMeshToBlobTransferHan
[Function("RetrieveMeshFile")]
public async Task RunAsync([TimerTrigger("0 */5 * * * *")] TimerInfo myTimer)
{
_logger.LogInformation("C# Timer trigger function executed at: ,{datetime}", DateTime.UtcNow);
_logger.LogInformation("C# Timer trigger function executed at: ,{DateTime}", DateTime.UtcNow);

static bool messageFilter(MessageMetaData i) => true; // No current filter defined there might be business rules here

Expand All @@ -65,7 +65,7 @@ public async Task RunAsync([TimerTrigger("0 */5 * * * *")] TimerInfo myTimer)

if (myTimer.ScheduleStatus is not null)
{
_logger.LogInformation("Next timer schedule at: {scheduleStatus}", myTimer.ScheduleStatus.Next);
_logger.LogInformation("Next timer schedule at: {ScheduleStatus}", myTimer.ScheduleStatus.Next);
}
}

Expand Down Expand Up @@ -127,7 +127,7 @@ private async Task<bool> ShouldExecuteHandShake()
return true;

}
_logger.LogInformation("Next handshake scheduled for {nextHandShakeDateTime}", nextHandShakeDateTime);
_logger.LogInformation("Next handshake scheduled for {NextHandShakeDateTime}", nextHandShakeDateTime);
return false;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
namespace NHS.Screening.ReceiveCaasFile;


using System.Net.Http.Headers;
using System.Text.Json;
using Common;
using Microsoft.Azure.Functions.Worker.Extensions.Abstractions;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Model;
Expand Down Expand Up @@ -84,7 +82,7 @@ public async Task<bool> PostDemographicDataAsync(List<ParticipantDemographic> pa

if (finalStatus == WorkFlowStatus.Completed)
{
_logger.LogWarning("Durable function completed {finalStatus}", finalStatus);
_logger.LogWarning("Durable function completed {FinalStatus}", finalStatus);
return true;
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ namespace NHS.Screening.ReceiveCaasFile;
using Common;
using DataServices.Client;
using Microsoft.Extensions.Options;
using Azure.Messaging.ServiceBus;

public class ReceiveCaasFile
{
Expand Down Expand Up @@ -117,7 +116,7 @@ public async Task Run([BlobTrigger("inbound/{name}", Connection = "caasfolder_ST
public async Task<ScreeningLkp> GetScreeningService(FileNameParser fileNameParser)
{
var screeningWorkflowId = fileNameParser.GetScreeningService();
_logger.LogInformation("Screening Acronym {screeningWorkflowId}", screeningWorkflowId);
_logger.LogInformation("Screening Acronym {ScreeningWorkflowId}", screeningWorkflowId);

ScreeningLkp screeningService = await _screeningLkpClient.GetSingleByFilter(x => x.ScreeningWorkflowId == screeningWorkflowId)
?? throw new ArgumentException("Could not get screening service data for screening id: " + screeningWorkflowId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,11 @@ namespace NHS.CohortManager.DemographicServices;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Common;
using System.Collections.Specialized;
using System.Text;
using DataServices.Core;
using Model;
using NHS.CohortManager.DemographicServices;
using Common.Interfaces;
using System.Text.Json;
using System.Linq;
using System.Security.Cryptography.X509Certificates;

/// <summary>
/// Azure Functions endpoints for managing CaaS subscriptions via MESH and data services.
Expand All @@ -30,6 +26,7 @@ public class ManageCaasSubscription
private readonly IDataServiceAccessor<NemsSubscription> _nemsSubscriptionAccessor;
private readonly IMeshPoller _meshPoller;
private readonly IExceptionHandler _exceptionHandler;
private const string? nhsNum = "nhsNumber";

public ManageCaasSubscription(
ILogger<ManageCaasSubscription> logger,
Expand Down Expand Up @@ -60,9 +57,9 @@ public ManageCaasSubscription(
[Function("Subscribe")]
public async Task<HttpResponseData> Subscribe([HttpTrigger(AuthorizationLevel.Anonymous, "post")] HttpRequestData req)
{
string? nhsNumber = req.Query[nhsNum];
try
{
var nhsNumber = req.Query["nhsNumber"];
if (!ValidationHelper.ValidateNHSNumber(nhsNumber!))
{
return await _createResponse.CreateHttpResponseWithBodyAsync(HttpStatusCode.BadRequest, req, "NHS number is required and must be valid format.");
Expand Down Expand Up @@ -117,7 +114,7 @@ public async Task<HttpResponseData> Subscribe([HttpTrigger(AuthorizationLevel.An
_logger.LogError(ex, "Error sending CAAS subscribe request");
try
{
string? rawNhs = req.Query["nhsNumber"];
string? rawNhs = req.Query[nhsNum];
var nhsForLog = ValidationHelper.ValidateNHSNumber(rawNhs!) ? rawNhs! : string.Empty;
await _exceptionHandler.CreateSystemExceptionLogFromNhsNumber(ex, nhsForLog, nameof(ManageCaasSubscription), "", string.Empty);
}
Expand Down Expand Up @@ -242,7 +239,7 @@ public async Task<HttpResponseData> SubscribeMany([HttpTrigger(AuthorizationLeve
[Function("Unsubscribe")]
public async Task<HttpResponseData> Unsubscribe([HttpTrigger(AuthorizationLevel.Anonymous, "post")] HttpRequestData req)
{
var nhsNumber = req.Query["nhsNumber"];
var nhsNumber = req.Query[nhsNum];
if (!ValidationHelper.ValidateNHSNumber(nhsNumber!))
{
return await _createResponse.CreateHttpResponseWithBodyAsync(HttpStatusCode.BadRequest, req, "NHS number is required and must be valid format.");
Expand All @@ -264,7 +261,7 @@ public async Task<HttpResponseData> CheckSubscriptionStatus([HttpTrigger(Authori
{
_logger.LogInformation("Received check subscription request");

string? nhsNumber = req.Query["nhsNumber"];
string? nhsNumber = req.Query[nhsNum];

if (!ValidationHelper.ValidateNHSNumber(nhsNumber!))
{
Expand All @@ -287,7 +284,7 @@ public async Task<HttpResponseData> CheckSubscriptionStatus([HttpTrigger(Authori
_logger.LogError(ex, "Error checking subscription status");
try
{
string? rawNhs = req.Query["nhsNumber"];
string? rawNhs = req.Query[nhsNum];
var nhsForLog = ValidationHelper.ValidateNHSNumber(rawNhs!) ? rawNhs! : string.Empty;
await _exceptionHandler.CreateSystemExceptionLogFromNhsNumber(ex, nhsForLog, nameof(ManageCaasSubscription), "", string.Empty);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
namespace NHS.Screening.NemsMeshRetrieval;

using System;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using Common;
Expand Down Expand Up @@ -42,7 +40,7 @@ public NemsMeshRetrieval(ILogger<NemsMeshRetrieval> logger, IMeshToBlobTransferH
[Function("RetrieveNemsMeshFile")]
public async Task RunAsync([TimerTrigger("0 */5 * * * *")] TimerInfo myTimer)
{
_logger.LogInformation("C# Timer trigger function executed at: ,{datetime}", DateTime.UtcNow);
_logger.LogInformation("C# Timer trigger function executed at: ,{Datetime}", DateTime.UtcNow);

static bool messageFilter(MessageMetaData i) => true; // No current filter defined there might be business rules here

Expand All @@ -65,7 +63,7 @@ public async Task RunAsync([TimerTrigger("0 */5 * * * *")] TimerInfo myTimer)

if (myTimer.ScheduleStatus is not null)
{
_logger.LogInformation("Next timer schedule at: {scheduleStatus}", myTimer.ScheduleStatus.Next);
_logger.LogInformation("Next timer schedule at: {ScheduleStatus}", myTimer.ScheduleStatus.Next);
}
}

Expand Down Expand Up @@ -127,7 +125,7 @@ private async Task<bool> ShouldExecuteHandShake()
return true;

}
_logger.LogInformation("Next handshake scheduled for {nextHandShakeDateTime}", nextHandShakeDateTime);
_logger.LogInformation("Next handshake scheduled for {NextHandShakeDateTime}", nextHandShakeDateTime);
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class BlockParticipantHandler : IBlockParticipantHandler
private readonly IDataServiceClient<ParticipantDemographic> _participantDemographicDataService;
private readonly IHttpClientFunction _httpClient;
private readonly UpdateBlockedFlagConfig _config;
private static readonly string CultureInfo = "en-GB";
public BlockParticipantHandler(ILogger<BlockParticipantHandler> logger,
IDataServiceClient<ParticipantManagement> participantManagementDataService,
IDataServiceClient<ParticipantDemographic> participantDemographicDataService,
Expand Down Expand Up @@ -241,12 +242,12 @@ private async Task<PdsDemographic> GetPDSParticipant(long nhsNumber)
private static bool ValidateRecordsMatch(ParticipantDemographic participant, BlockParticipantDto dto)
{

if (!DateOnly.TryParseExact(dto.DateOfBirth, "yyyy-MM-dd", new CultureInfo("en-GB"), DateTimeStyles.None, out var dtoDateOfBirth))
if (!DateOnly.TryParseExact(dto.DateOfBirth, "yyyy-MM-dd", new CultureInfo(CultureInfo), DateTimeStyles.None, out var dtoDateOfBirth))
{
throw new FormatException("Date of Birth not in the correct format");
}

if (!DateOnly.TryParseExact(participant.DateOfBirth, "yyyyMMdd", new CultureInfo("en-GB"), DateTimeStyles.None, out var parsedDob))
if (!DateOnly.TryParseExact(participant.DateOfBirth, "yyyyMMdd", new CultureInfo(CultureInfo), DateTimeStyles.None, out var parsedDob))
{
return false;
}
Expand All @@ -259,12 +260,12 @@ private static bool ValidateRecordsMatch(ParticipantDemographic participant, Blo
private static bool ValidateRecordsMatch(PdsDemographic participant, BlockParticipantDto dto)
{

if (!DateOnly.TryParseExact(dto.DateOfBirth, "yyyy-MM-dd", new CultureInfo("en-GB"), DateTimeStyles.None, out var dtoDateOfBirth))
if (!DateOnly.TryParseExact(dto.DateOfBirth, "yyyy-MM-dd", new CultureInfo(CultureInfo), DateTimeStyles.None, out var dtoDateOfBirth))
{
throw new FormatException("Date of Birth not in the correct format");
}

if (!DateOnly.TryParseExact(participant.DateOfBirth, "yyyy-MM-dd", new CultureInfo("en-GB"), DateTimeStyles.None, out var parsedDob))
if (!DateOnly.TryParseExact(participant.DateOfBirth, "yyyy-MM-dd", new CultureInfo(CultureInfo), DateTimeStyles.None, out var parsedDob))
{
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public async Task<HttpResponseData> Run(
}
catch (JsonException ex)
{
_logger.LogError(ex, "Failed to deserialize json request body to type {type}", nameof(ReceiveServiceNowMessageRequestBody));
_logger.LogError(ex, "Failed to deserialize json request body to type {Type}", nameof(ReceiveServiceNowMessageRequestBody));
return _createResponse.CreateHttpResponse(HttpStatusCode.BadRequest, req);
}
catch (Exception ex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private static HttpRequestMessage CreateRequest(string url, string json, string

if (!response.IsSuccessStatusCode)
{
_logger.LogError("Failed to refresh ServiceNow access token. StatusCode: {statusCode}", response.StatusCode);
_logger.LogError("Failed to refresh ServiceNow access token. StatusCode: {StatusCode}", response.StatusCode);
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public AuthorizationClientCredentials(IJwtTokenService jwtTokenService, HttpClie

if (response.StatusCode != HttpStatusCode.OK)
{
_logger.LogError("there was an error getting the bearer token from the NHS token service. Response: {resBody}", resBody);
_logger.LogError("there was an error getting the bearer token from the NHS token service. Response: {ResBody}", resBody);
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public async Task<bool> AddAsync<T>(T message, string queueName)
}
catch (Exception ex)
{
_logger.LogError(ex, "There was an error while putting item on queue for queue: {queueName}", queueName);
_logger.LogError(ex, "There was an error while putting item on queue for queue: {QueueName}", queueName);
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public async Task<bool> AddAsync<T>(T message, string queueName)
}
catch (Exception ex)
{
_logger.LogError(ex, "There was an error sending message to service bus queue {queueName} {errorMessage}", queueName, ex.Message);
_logger.LogError(ex, "There was an error sending message to service bus queue {QueueName} {ErrorMessage}", queueName, ex.Message);
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ public async Task<ValidationExceptionLog> CreateValidationExceptionLog(IEnumerab
if (!string.IsNullOrEmpty(error.ExceptionMessage))
{
errorMessage = error.ExceptionMessage;
_logger.LogError("an exception was raised while running the rules. Exception Message: {exceptionMessage}", error.ExceptionMessage);
_logger.LogError("an exception was raised while running the rules. Exception Message: {ExceptionMessage}", error.ExceptionMessage);
}

var exception = new ValidationException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public async Task<bool> MoveFilesFromMeshToBlob(Func<MessageMetaData,bool> predi

messageCount = checkForMessages.Response.Messages.Count();

_logger.LogInformation("{messageCount} Messages were found within mailbox {mailboxId}",messageCount,mailboxId);
_logger.LogInformation("{MessageCount} Messages were found within mailbox {MailboxId}",messageCount,mailboxId);

if(messageCount == 0)
{
Expand All @@ -72,7 +72,7 @@ public async Task<bool> MoveFilesFromMeshToBlob(Func<MessageMetaData,bool> predi

var messagesMoved = await MoveAllMessagesToBlobStorage(checkForMessages.Response.Messages,predicate);

_logger.LogInformation("{messagesMoved} out of {messageCount} Messages were moved mailbox: {mailboxId} to Blob Storage",messagesMoved,messageCount,mailboxId);
_logger.LogInformation("{MessagesMoved} out of {MessageCount} Messages were moved mailbox: {MailboxId} to Blob Storage",messagesMoved,messageCount,mailboxId);

if(messagesMoved == 0 && messageCount == 500)
{
Expand Down Expand Up @@ -150,7 +150,7 @@ private async Task<bool> TransferMessageToBlobStorage(MessageMetaData messageHea
var result = await _meshInboxService.GetChunkedMessageByIdAsync(_mailboxId,messageId);
if(!result.IsSuccessful)
{
_logger.LogError("Failed to download chunked message from MESH MessageId: {messageId}",messageId);
_logger.LogError("Failed to download chunked message from MESH MessageId: {MessageId}",messageId);
return null;
}

Expand All @@ -165,7 +165,7 @@ private async Task<bool> TransferMessageToBlobStorage(MessageMetaData messageHea
var result = await _meshInboxService.GetMessageByIdAsync(_mailboxId,messageId);
if(!result.IsSuccessful)
{
_logger.LogError("Failed to download chunked message from MESH MessageId: {messageId}",messageId);
_logger.LogError("Failed to download chunked message from MESH MessageId: {MessageId}",messageId);
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ public async Task<string> GetRulesFromDirectory(string jsonFileName)

// Construct the path to the JSON file (assuming it was copied to the output directory)
var filePath = Path.Combine(currentDirectory, jsonFileName);
_logger.LogInformation("file path: {filePath}", filePath);
_logger.LogInformation("file path: {FilePath}", filePath);

// Check if the file exists
if (!File.Exists(filePath))
{
_logger.LogError("File not found: {filePath}", filePath);
_logger.LogError("File not found: {FilePath}", filePath);
return string.Empty;
}

Expand All @@ -37,7 +37,7 @@ public async Task<string> GetRulesFromDirectory(string jsonFileName)
}
catch (Exception ex)
{
_logger.LogError(ex, "error while getting rules from directory: {ex} {fileName}", ex.Message, jsonFileName);
_logger.LogError(ex, "error while getting rules from directory: {Ex} {FileName}", ex.Message, jsonFileName);
return string.Empty;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ public async Task<List<CohortDistributionParticipantDto>> GetUnextractedCohortDi

public async Task<List<CohortDistributionParticipantDto>> GetCohortDistributionParticipantsByRequestId(Guid requestId)
{
var requestIdString = requestId.ToString();
if (requestId == Guid.Empty)
{
CohortDistributionParticipantDto(new List<CohortDistributionParticipant>());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ public override async Task<TEntity> GetSingle(string id)
{
if (_cache.TryGetValue<TEntity>(id, out TEntity entity))
{
_logger.LogInformation("Cache Hit reading key {key} for entity : {entity}", id, typeof(TEntity).FullName);
_logger.LogInformation("Cache Hit reading key {Key} for entity : {Entity}", id, typeof(TEntity).FullName);
return entity;
}
_logger.LogInformation("Cache Miss reading key {key} for entity : {entity}", id, typeof(TEntity).FullName);
_logger.LogInformation("Cache Miss reading key {Key} for entity : {Entity}", id, typeof(TEntity).FullName);
entity = await base.GetSingle(id);
if (entity == null)
{
Expand Down
Loading
Loading