Skip to content

Commit a2f924c

Browse files
Merge branch 'main' into feat/DTOSS-10476-snow-participant-to-cohort
2 parents 42fee8d + 86f266a commit a2f924c

20 files changed

Lines changed: 310 additions & 333 deletions

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
3+
name: $(Build.SourceBranchName)-$(Date:yyyyMMdd)_$(Rev:r)
4+
trigger: none
5+
pr: none
6+
7+
resources:
8+
repositories:
9+
- repository: dtos-devops-templates
10+
type: github
11+
name: NHSDigital/dtos-devops-templates
12+
ref: 8570bd32f8da7dfbf2f88fcc9190181e4757fcca
13+
endpoint: NHSDigital
14+
15+
variables:
16+
- group: PRD_hub_backend_remote_state
17+
18+
stages:
19+
- stage: db_changes_stage
20+
displayName: Database changes
21+
jobs:
22+
- job: db_changes
23+
pool:
24+
name: private-pool-prod-uks
25+
displayName: Apply database changes
26+
variables:
27+
- group: PRE_core_backend
28+
- group: PRE_image_pipelines
29+
steps:
30+
- checkout: self
31+
- checkout: dtos-devops-templates
32+
- template: .azuredevops/templates/steps/app-container-job-start.yaml@dtos-devops-templates
33+
parameters:
34+
serviceConnection: $(SERVICE_CONNECTION)
35+
targetSubscriptionId: $(TF_VAR_TARGET_SUBSCRIPTION_ID)
36+
resourceGroupName: $(RESOURCE_GROUP_NAME_SQL)
37+
jobName: $(DATABASE_MANAGEMENT_JOB_NAME)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
3+
name: $(Build.SourceBranchName)-$(Date:yyyyMMdd)_$(Rev:r)
4+
trigger: none
5+
pr: none
6+
7+
resources:
8+
repositories:
9+
- repository: dtos-devops-templates
10+
type: github
11+
name: NHSDigital/dtos-devops-templates
12+
ref: 8570bd32f8da7dfbf2f88fcc9190181e4757fcca
13+
endpoint: NHSDigital
14+
15+
variables:
16+
- group: PRD_hub_backend_remote_state
17+
18+
stages:
19+
- stage: db_changes_stage
20+
displayName: Database changes
21+
jobs:
22+
- job: db_changes
23+
pool:
24+
name: private-pool-prod-uks
25+
displayName: Apply database changes
26+
variables:
27+
- group: PROD_core_backend
28+
- group: PROD_image_pipelines
29+
steps:
30+
- checkout: self
31+
- checkout: dtos-devops-templates
32+
- template: .azuredevops/templates/steps/app-container-job-start.yaml@dtos-devops-templates
33+
parameters:
34+
serviceConnection: $(SERVICE_CONNECTION)
35+
targetSubscriptionId: $(TF_VAR_TARGET_SUBSCRIPTION_ID)
36+
resourceGroupName: $(RESOURCE_GROUP_NAME_SQL)
37+
jobName: $(DATABASE_MANAGEMENT_JOB_NAME)

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ appsettings.json
6363
application/CohortManager/SampleData/
6464
*.csv
6565
*.parquet
66+
*.xml
6667
!tests/UnitTests/CaasIntegrationTests/receiveCaasFileTest/*.parquet
6768

6869
# csv to sql statement scripts

application/CohortManager/compose.core.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ services:
5858
- ExceptionFunctionURL=http://create-exception:7070/api/CreateException
5959
- RetrievePdsDemographicURL=http://retrieve-pds-demographic:8082/api/RetrievePDSDemographic
6060
- UnsubscribeNemsSubscriptionUrl=http://manage-nems-subscription:9081/api/Unsubscribe
61-
- ParticipantDemographicDataServiceURL=http://participant-demographic-data-service:7993/api/ParticipantDemographicDataService
61+
- DemographicDataServiceURL=http://participant-demographic-data-service:7993/api/ParticipantDemographicDataService
6262
- ServiceBusConnectionString_client_internal=Endpoint=sb://service-bus;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=SAS_KEY_VALUE;UseDevelopmentEmulator=true;
6363
- ParticipantManagementTopic=participant-management-topic
6464

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ public async Task<HttpResponseData> Subscribe([HttpTrigger(AuthorizationLevel.An
4949

5050
string? nhsNumber = req.Query["nhsNumber"];
5151

52-
if (!ValidationHelper.ValidateNHSNumber(nhsNumber))
52+
if (!ValidationHelper.ValidateNHSNumber(nhsNumber!))
5353
{
5454
_logger.LogError("NHS number is required and must be valid format");
5555
return await _createResponse.CreateHttpResponseWithBodyAsync(HttpStatusCode.BadRequest, req, "NHS number is required and must be valid format.");
5656
}
5757

58-
var result = await _subscriptionManager.CreateAndSendSubscriptionAsync(nhsNumber);
58+
var result = await _subscriptionManager.CreateAndSendSubscriptionAsync(nhsNumber!);
5959

6060
if (!result.Success)
6161
{

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

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ namespace NHS.CohortManager.DemographicServices;
1212
using Microsoft.Extensions.Options;
1313
using System.Threading.Tasks;
1414
using Model;
15+
using System.Net.Http.Json;
16+
using Hl7.Fhir.Support;
1517

1618
public class RetrievePdsDemographic
1719
{
@@ -71,12 +73,8 @@ public async Task<HttpResponseData> Run([HttpTrigger(AuthorizationLevel.Anonymou
7173

7274
if (response.StatusCode == HttpStatusCode.NotFound)
7375
{
74-
var demographicRecordDeletedFromDatabase = await DeleteDemographicRecord(nhsNumber);
75-
if (!demographicRecordDeletedFromDatabase)
76-
{
77-
return _createResponse.CreateHttpResponse(HttpStatusCode.NotFound, req, "could not delete record from database. See logs for more details.");
78-
}
79-
return _createResponse.CreateHttpResponse(HttpStatusCode.NotFound, req, "Record not found in PDS and successfully removed from cohort manager database.");
76+
var pdsErrorResponse = await response.Content.ReadAsStringAsync();
77+
return _createResponse.CreateHttpResponse(HttpStatusCode.NotFound, req, pdsErrorResponse);
8078
}
8179

8280
response.EnsureSuccessStatusCode();
@@ -129,36 +127,4 @@ private async Task<bool> UpsertDemographicRecordFromPDS(ParticipantDemographic p
129127
_logger.LogError("Failed to update Participant Demographic.");
130128
return false;
131129
}
132-
133-
private async Task<bool> DeleteDemographicRecord(string nhsNumber)
134-
{
135-
var nhsNumberParsed = long.TryParse(nhsNumber, out long parsedNhsNumber);
136-
if (!nhsNumberParsed)
137-
{
138-
_logger.LogError("could not parse nhs number when trying to get record for deletion.");
139-
return false;
140-
}
141-
var oldParticipantDemographic = await _participantDemographicClient.GetSingleByFilter(i => i.NhsNumber == parsedNhsNumber);
142-
143-
if (oldParticipantDemographic == null)
144-
{
145-
146-
_logger.LogWarning("Failed to delete Participant Demographic as record did not exist in database.");
147-
return false;
148-
}
149-
150-
_logger.LogInformation("Participant Demographic record found, attempting to delete Participant Demographic.");
151-
bool updateSuccess = await _participantDemographicClient.Delete(oldParticipantDemographic.ParticipantId.ToString());
152-
153-
if (updateSuccess)
154-
{
155-
_logger.LogInformation("Successfully deleted Participant Demographic.");
156-
return true;
157-
}
158-
159-
_logger.LogError("Failed to delete Participant Demographic.");
160-
return false;
161-
}
162-
163-
164130
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace NHS.Screening.ProcessNemsUpdate;
2+
3+
public class PdsCoding
4+
{
5+
public string? code { get; set; }
6+
public string? display { get; set; }
7+
public string? system { get; set; }
8+
public string? version { get; set; }
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace NHS.Screening.ProcessNemsUpdate;
2+
3+
public class PdsErrorResponse
4+
{
5+
public List<PdsIssue>? issue { get; set; }
6+
public string? resourceType { get; set; }
7+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace NHS.Screening.ProcessNemsUpdate;
2+
3+
public class PdsIssue
4+
{
5+
public string? code { get; set; }
6+
public PdsErrorDetails? details { get; set; }
7+
public string? severity { get; set; }
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace NHS.Screening.ProcessNemsUpdate;
2+
3+
public class PdsErrorDetails
4+
{
5+
public List<PdsCoding>? coding { get; set; }
6+
}
7+

0 commit comments

Comments
 (0)