Skip to content

Commit dbe57dc

Browse files
Merge branch 'main' into fix/DTOSS-10515-Handling-not-found-in-pds-func
2 parents b677c11 + 751140c commit dbe57dc

29 files changed

Lines changed: 444 additions & 121 deletions

File tree

application/CohortManager/compose.core.yaml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ services:
2828
build:
2929
context: ./src/Functions/
3030
dockerfile: NemsSubscriptionService/NemsMeshRetrieval/Dockerfile
31-
profiles: [non-essential]
31+
profiles: [nems]
3232
environment:
3333
- AzureWebJobsStorage=${AZURITE_CONNECTION_STRING}
3434
- nemsmeshfolder_STORAGE=${AZURITE_CONNECTION_STRING}
@@ -241,7 +241,9 @@ services:
241241
build:
242242
context: ./src/Functions/
243243
dockerfile: DemographicServices/RetrievePDSDemographic/Dockerfile
244-
profiles: [not-implemented]
244+
profiles: [service-now, nems]
245+
ports:
246+
- 8082:8082
245247
environment:
246248
- ASPNETCORE_URLS=http://*:8082
247249
- ExceptionFunctionURL=http://create-exception:7070/api/CreateException
@@ -251,13 +253,14 @@ services:
251253
- Audience=https://int.api.service.nhs.uk/oauth2/token
252254
- AuthTokenURL=https://int.api.service.nhs.uk/oauth2/token
253255
- LocalPrivateKeyFileName=RetrievePdsDemographic-DEV1.pem.key
254-
- ClientId="Get-private-key-from-NHS-dev-portal"
256+
- ClientId=Get-private-key-from-NHS-dev-portal
257+
- UseFakePDSServices=true
255258

256259
manage-nems-subscription:
257260
container_name: manage-nems-subscription
258261
image: cohort-manager-manage-nems-subscription
259262
networks: [cohman-network]
260-
profiles: [non-essential]
263+
profiles: [nems]
261264
build:
262265
context: ./src/Functions/
263266
dockerfile: DemographicServices/ManageNemsSubscription/Dockerfile
@@ -306,7 +309,7 @@ services:
306309
build:
307310
context: ./src/Functions/
308311
dockerfile: ServiceNowIntegration/ServiceNowMessageHandler/Dockerfile
309-
profiles: [non-essential]
312+
profiles: [service-now]
310313
environment:
311314
- ASPNETCORE_URLS=http://*:9092
312315
- ServiceNowRefreshAccessTokenUrl=https://nhsdigitaldev.service-now.com/oauth_token.do
@@ -315,9 +318,10 @@ services:
315318
- ServiceNowClientId=${SERVICENOW_CLIENT_ID}
316319
- ServiceNowClientSecret=${SERVICENOW_CLIENT_SECRET}
317320
- ServiceNowRefreshToken=${SERVICENOW_REFRESH_TOKEN}
321+
- ServiceNowParticipantManagementTopic=servicenow-participant-management-topic
318322
- ServiceBusConnectionString_client_internal=Endpoint=sb://service-bus;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=SAS_KEY_VALUE;UseDevelopmentEmulator=true;
319323
ports:
320-
- "9092:9092"
324+
- 9092:9092
321325

322326
servicenow-cohort-lookup:
323327
container_name: servicenow-cohort-lookup
@@ -326,7 +330,7 @@ services:
326330
build:
327331
context: ./src/Functions/
328332
dockerfile: ServiceNowIntegration/ServiceNowCohortLookup/Dockerfile
329-
profiles: [non-essential]
333+
profiles: [service-now]
330334
environment:
331335
- ASPNETCORE_URLS=http://*:7180
332336
- ExceptionFunctionURL=http://create-exception:7070/api/CreateException

application/CohortManager/compose.data-services.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ services:
112112
container_name: nems-subscription-data-service
113113
image: cohort-manager-nems-subscription-data-service
114114
networks: [cohman-network]
115+
profiles: [nems]
115116
build:
116117
context: ./src/Functions/
117118
dockerfile: screeningDataServices/NemsSubscriptionDataService/Dockerfile
@@ -136,6 +137,7 @@ services:
136137
container_name: servicenow-cases-data-service
137138
image: cohort-manager-servicenow-cases-data-service
138139
networks: [cohman-network]
140+
profiles: [service-now]
139141
build:
140142
context: ./src/Functions/
141143
dockerfile: screeningDataServices/ServiceNowCasesDataService/Dockerfile

application/CohortManager/src/Functions/DemographicServices/RetrievePDSDemographic/RetrievePDSDemographic.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,17 @@ public async Task<HttpResponseData> Run([HttpTrigger(AuthorizationLevel.Anonymou
6969
var response = await _httpClientFunction.SendPdsGet(url, bearerToken);
7070
string jsonResponse = "";
7171

72-
if (response.StatusCode == HttpStatusCode.NotFound)
72+
jsonResponse = await _httpClientFunction.GetResponseText(response);
73+
var pdsDemographic = _fhirPatientDemographicMapper.ParseFhirJson(jsonResponse);
74+
75+
if (response.StatusCode == HttpStatusCode.NotFound || pdsDemographic.ConfidentialityCode == "R")
7376
{
7477
await _pdsProcessor.ProcessPdsNotFoundResponse(response, nhsNumber);
7578
return _createResponse.CreateHttpResponse(HttpStatusCode.NotFound, req, "PDS returned a 404 please database for details");
7679
}
7780

7881
response.EnsureSuccessStatusCode();
7982

80-
jsonResponse = await _httpClientFunction.GetResponseText(response);
81-
var pdsDemographic = _fhirPatientDemographicMapper.ParseFhirJson(jsonResponse);
8283
var participantDemographic = pdsDemographic.ToParticipantDemographic();
8384
var upsertResult = await _pdsProcessor.UpsertDemographicRecordFromPDS(participantDemographic);
8485

application/CohortManager/src/Functions/NemsSubscriptionService/ProcessNemsUpdate/ProcessNemsUpdate.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using Microsoft.Extensions.Options;
1313
using Model;
1414
using DataServices.Client;
15+
using System.Net;
1516
using FluentValidation.Validators;
1617

1718
public class ProcessNemsUpdate
@@ -73,7 +74,7 @@ public async Task Run([BlobTrigger("nems-updates/{name}", Connection = "nemsmesh
7374
nhsNumberLong = long.Parse(nhsNumber!);
7475

7576
var pdsResponse = await RetrievePdsRecord(nhsNumber!);
76-
if (pdsResponse!.StatusCode == System.Net.HttpStatusCode.NotFound)
77+
if (pdsResponse!.StatusCode == HttpStatusCode.NotFound)
7778
{
7879
_logger.LogError("the PDS function has returned a 404 error. function now stopping processing");
7980
// we can stop processing here as we know that not found means the participant ether needed an update or they were actually not found
@@ -166,7 +167,7 @@ private async Task<HttpResponseMessage> RetrievePdsRecord(string nhsNumber)
166167
{"nhsNumber", nhsNumber }
167168
};
168169

169-
return await _httpClientFunction.SendGetHttpResponse(_config.RetrievePdsDemographicURL, queryParams);
170+
return await _httpClientFunction.SendGetResponse(_config.RetrievePdsDemographicURL, queryParams);
170171
}
171172

172173
private async Task ProcessRecord(Participant participant)

application/CohortManager/src/Functions/ParticipantManagementServices/ManageServiceNowParticipant/ManageServiceNowParticipantFunction.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,14 @@ public async Task Run([ServiceBusTrigger(topicName: "%ServiceNowParticipantManag
7676
private async Task<ParticipantDemographic?> ValidateAndRetrieveParticipantFromPds(ServiceNowParticipant serviceNowParticipant)
7777
{
7878
var pdsResponse = await _httpClientFunction.SendGetResponse($"{_config.RetrievePdsDemographicURL}?nhsNumber={serviceNowParticipant.NhsNumber}");
79+
string responseMessage = await _httpClientFunction.GetResponseText(pdsResponse);
7980

8081
if (pdsResponse.StatusCode == HttpStatusCode.NotFound)
8182
{
82-
await HandleException(new Exception("Request to PDS for ServiceNow Participant returned a 404 NotFound response."), serviceNowParticipant, ServiceNowMessageType.UnableToAddParticipant);
83+
await HandleException(new Exception(responseMessage), serviceNowParticipant, ServiceNowMessageType.UnableToAddParticipant);
8384
return null;
8485
}
85-
86+
8687
if (pdsResponse.StatusCode != HttpStatusCode.OK)
8788
{
8889
await HandleException(new Exception($"Request to PDS for ServiceNow Participant returned an unexpected response. Status code: {pdsResponse.StatusCode}"), serviceNowParticipant, ServiceNowMessageType.AddRequestInProgress);

application/CohortManager/src/Functions/ScreeningValidationService/StaticValidation/Breast_Screening_staticRules.json

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,6 @@
2626
}
2727
}
2828
},
29-
{
30-
"RuleName": "47.NewParticipantWithRemovalOrDeath.NBO.NonFatal",
31-
"Expression": "participant.RecordType != Actions.New OR (string.IsNullOrEmpty(participant.ReasonForRemoval) AND string.IsNullOrEmpty(participant.ReasonForRemovalEffectiveFromDate) AND string.IsNullOrEmpty(participant.DateOfDeath))",
32-
"Actions": {
33-
"OnFailure": {
34-
"Name": "OutputExpression",
35-
"Context": {
36-
"Expression": "\"Removal fields incompatible with record type\""
37-
}
38-
}
39-
}
40-
},
4129
{
4230
"RuleName": "62.ValidateReasonForRemoval.NBO.NonFatal",
4331
"Expression": "!(participant.ReasonForRemoval == \"LDN\" AND string.IsNullOrEmpty(participant.SupersededByNhsNumber))",

application/CohortManager/src/Functions/Shared/Common/HttpClientFunction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public async Task<string> SendGet(string url, Dictionary<string, string> paramet
6060
return await GetAsync(client);
6161
}
6262

63-
public async Task<HttpResponseMessage> SendGetHttpResponse(string url, Dictionary<string, string> parameters)
63+
public async Task<HttpResponseMessage> SendGetResponse(string url, Dictionary<string, string> parameters)
6464
{
6565
using var client = _factory.CreateClient();
6666

application/CohortManager/src/Functions/Shared/Common/Interfaces/IHttpClientFunction.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,21 @@ public interface IHttpClientFunction
2424
/// <returns>string</returns>
2525
Task<string> SendGet(string url, Dictionary<string, string> parameters);
2626

27-
Task<HttpResponseMessage> SendGetHttpResponse(string url, Dictionary<string, string> parameters);
28-
2927
/// <summary>
3028
/// Performs a GET request using HttpClient and returns the entire HTTP response.
3129
/// </summary>
3230
/// <param name="url">URL to be used in request.</param>
3331
/// <returns>HttpResponseMessage</returns>
3432
Task<HttpResponseMessage> SendGetResponse(string url);
3533

34+
/// <summary>
35+
/// Performs a GET request using HttpClient and returns the entire HTTP response.
36+
/// </summary>
37+
/// <param name="url">URL to be used in request.</param>
38+
/// <param name="parameters">Parameters to be added to the url and used in request.</param>
39+
/// <returns>HttpResponseMessage</returns>
40+
Task<HttpResponseMessage> SendGetResponse(string url, Dictionary<string, string> parameters);
41+
3642
/// <summary>
3743
/// Sends a get request or throws an error
3844
/// </summary>

application/CohortManager/src/Functions/Shared/Common/PdsHttpClientMock.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ public async Task<HttpResponseMessage> SendGetResponse(string url)
9999
throw new NotImplementedException();
100100
}
101101

102+
public async Task<HttpResponseMessage> SendGetResponse(string url, Dictionary<string, string> parameters)
103+
{
104+
await Task.CompletedTask;
105+
throw new NotImplementedException();
106+
}
102107

103108
/// <summary>
104109
/// takes in a fake string content and returns 200 OK response
@@ -119,9 +124,4 @@ private static HttpResponseMessage CreateFakeHttpResponse(string url, string con
119124
httpResponseData.StatusCode = HttpStatusCode.OK;
120125
return httpResponseData;
121126
}
122-
123-
public Task<HttpResponseMessage> SendGetHttpResponse(string url, Dictionary<string, string> parameters)
124-
{
125-
throw new NotImplementedException();
126-
}
127127
}

docs/user-guides/user_guide.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,10 @@ To make the application more manageable to run, some functions have had [docker
5656

5757
Key of profiles:
5858

59-
- bi-analytics - Functions that are only used by the external BI & Analytics product
6059
- bs-select - Functions that are only used by external requests from BS Select
6160
- ui - only used by the user interface
61+
- service-now - Functions that are only used in manual service now adds
62+
- nems - Functions that are only used in NEMS requests
6263
- non-essential - Functions that are not needed to run the application
6364
- not-implemented - Functions that do not yet have an implementation and are not in use
6465

0 commit comments

Comments
 (0)