Skip to content

Commit 1ae7f10

Browse files
authored
NIAD-3152: Send over ProcedureRequest.meta.security NOPAT field to incumbent (#1145)
* covering code with a test * checkstyle * changelog update
1 parent d166677 commit 1ae7f10

File tree

8 files changed

+56
-13
lines changed

8 files changed

+56
-13
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
### Added
10+
11+
* GP2GP Adaptor now populates the PlanStatement / confidentialityCode field
12+
when the ProcedureRequest.meta.security field contains NOPAT and the message type is RCMR_IN030000UK07
13+
914
## [2.2.2] - 2025-02-07
1015

1116
### Fixed

service/src/main/java/uk/nhs/adaptors/gp2gp/ehr/mapper/DiaryPlanStatementMapper.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import lombok.Getter;
2727
import lombok.RequiredArgsConstructor;
2828
import lombok.Setter;
29+
import uk.nhs.adaptors.gp2gp.common.service.ConfidentialityService;
2930
import uk.nhs.adaptors.gp2gp.ehr.exception.EhrMapperException;
3031
import uk.nhs.adaptors.gp2gp.ehr.mapper.DiaryPlanStatementMapper.PlanStatementMapperParameters.PlanStatementMapperParametersBuilder;
3132
import uk.nhs.adaptors.gp2gp.ehr.utils.CodeableConceptMappingUtils;
@@ -49,6 +50,7 @@ public class DiaryPlanStatementMapper {
4950
private final MessageContext messageContext;
5051
private final CodeableConceptCdMapper codeableConceptCdMapper;
5152
private final ParticipantMapper participantMapper;
53+
private final ConfidentialityService confidentialityService;
5254

5355
public String mapProcedureRequestToPlanStatement(ProcedureRequest procedureRequest, Boolean isNested) {
5456
if (procedureRequest.getIntent() == ProcedureRequest.ProcedureRequestIntent.PLAN) {
@@ -61,13 +63,16 @@ public String mapProcedureRequestToPlanStatement(ProcedureRequest procedureReque
6163
private String mapDiaryEntryToPlanStatement(ProcedureRequest procedureRequest, Boolean isNested) {
6264
var idMapper = messageContext.getIdMapper();
6365
var availabilityTime = buildAvailabilityTime(procedureRequest);
66+
var confidentialityCode = confidentialityService.generateConfidentialityCode(procedureRequest);
67+
6468
PlanStatementMapperParametersBuilder builder = PlanStatementMapperParameters.builder()
6569
.isNested(isNested)
6670
.id(idMapper.getOrNew(ResourceType.ProcedureRequest, procedureRequest.getIdElement()))
6771
.availabilityTime(availabilityTime)
6872
.effectiveTime(buildEffectiveTime(procedureRequest))
6973
.text(buildText(procedureRequest))
70-
.code(buildCode(procedureRequest));
74+
.code(buildCode(procedureRequest))
75+
.confidentialityCode(confidentialityCode.orElse(null));
7176

7277
buildParticipant(procedureRequest).ifPresent(builder::participant);
7378

@@ -139,7 +144,7 @@ private Optional<String> getSupportingInformation(ProcedureRequest procedureRequ
139144
if (procedureRequest.hasSupportingInfo()) {
140145
return Optional.of("Supporting Information: " + procedureRequest.getSupportingInfo().stream()
141146
.filter(this::checkIfReferenceIsObservation)
142-
.map((observationReference) -> extractObservation(messageContext, observationReference))
147+
.map(observationReference -> extractObservation(messageContext, observationReference))
143148
.collect(Collectors.joining(COMMA)));
144149
}
145150
return Optional.empty();
@@ -230,5 +235,6 @@ public static class PlanStatementMapperParameters {
230235
private String effectiveTime;
231236
private String code;
232237
private String participant;
238+
private String confidentialityCode;
233239
}
234240
}

service/src/main/resources/templates/ehr_plan_statement_template.mustache

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
<center {{{effectiveTime}}}/>
1313
</effectiveTime>
1414
{{#availabilityTime}}<availabilityTime value="{{.}}"/>{{/availabilityTime}}
15+
{{#confidentialityCode}}
16+
{{{confidentialityCode}}}
17+
{{/confidentialityCode}}
1518
{{#author}}
1619
<author typeCode="AUT" contextControlCode="OP">
1720
{{#authorTime}}<time value="{{.}}" />{{/authorTime}}

service/src/test/java/uk/nhs/adaptors/gp2gp/ehr/mapper/DiaryPlanStatementMapperTest.java

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
import static org.mockito.ArgumentMatchers.any;
66
import static org.mockito.ArgumentMatchers.anyString;
77
import static org.mockito.Mockito.when;
8-
9-
import java.io.IOException;
8+
import java.util.Optional;
109
import java.util.stream.Stream;
1110

1211
import org.hl7.fhir.dstu3.model.Bundle;
@@ -22,6 +21,7 @@
2221
import org.mockito.junit.jupiter.MockitoSettings;
2322
import org.mockito.quality.Strictness;
2423

24+
import uk.nhs.adaptors.gp2gp.common.service.ConfidentialityService;
2525
import uk.nhs.adaptors.gp2gp.common.service.FhirParseService;
2626
import uk.nhs.adaptors.gp2gp.common.service.RandomIdGeneratorService;
2727
import uk.nhs.adaptors.gp2gp.ehr.exception.EhrMapperException;
@@ -57,16 +57,23 @@ public class DiaryPlanStatementMapperTest {
5757
+ "expected-output-procedure-request-resource-with-multiple-supportInfo.xml";
5858
private static final String INPUT_BUNDLE = TEST_DIRECTORY + "input-bundle.json";
5959

60+
public static final String CONFIDENTIALITY_CODE = "<confidentialityCode code=\"NOPAT\" "
61+
+ "codeSystem=\"2.16.840.1.113883.4.642.3.47\" "
62+
+ "displayName=\"no disclosure to patient, family or "
63+
+ "caregivers without attending provider's authorization\" />";
64+
6065
@Mock
6166
private RandomIdGeneratorService randomIdGeneratorService;
6267
@Mock
6368
private CodeableConceptCdMapper codeableConceptCdMapper;
69+
@Mock
70+
private ConfidentialityService confidentialityService;
6471

6572
private MessageContext messageContext;
6673
private DiaryPlanStatementMapper diaryPlanStatementMapper;
6774

6875
@BeforeEach
69-
public void setUp() throws IOException {
76+
public void setUp() {
7077
String inputJson = ResourceTestFileUtils.getFileContent(INPUT_BUNDLE);
7178
Bundle bundle = new FhirParseService().parseResource(inputJson, Bundle.class);
7279

@@ -78,7 +85,7 @@ public void setUp() throws IOException {
7885
messageContext.initialize(bundle);
7986

8087
diaryPlanStatementMapper =
81-
new DiaryPlanStatementMapper(messageContext, codeableConceptCdMapper, new ParticipantMapper());
88+
new DiaryPlanStatementMapper(messageContext, codeableConceptCdMapper, new ParticipantMapper(), confidentialityService);
8289
}
8390

8491
@AfterEach
@@ -87,7 +94,19 @@ public void tearDown() {
8794
}
8895

8996
@Test
90-
public void When_MappingProcedureRequestIsNested_Expect_ResourceMappedWithIsNestedFlag() throws IOException {
97+
public void When_MappingProcedureRequestWithNopat_Expect_ResourceMappedWithConfidentialityCode() {
98+
String inputJson = ResourceTestFileUtils.getFileContent(INPUT_PROCEDURE_REQUEST_WITH_ALL_DATA);
99+
ProcedureRequest inputProcedureRequest = new FhirParseService().parseResource(inputJson, ProcedureRequest.class);
100+
101+
when(confidentialityService.generateConfidentialityCode(inputProcedureRequest)).thenReturn(Optional.of(CONFIDENTIALITY_CODE));
102+
103+
var mappedXml = diaryPlanStatementMapper.mapProcedureRequestToPlanStatement(inputProcedureRequest, true);
104+
assertThat(mappedXml).contains(CONFIDENTIALITY_CODE);
105+
}
106+
107+
108+
@Test
109+
public void When_MappingProcedureRequestIsNested_Expect_ResourceMappedWithIsNestedFlag() {
91110
String expectedXml = ResourceTestFileUtils.getFileContent(EXPECTED_PLAN_STATEMENT_WITH_IS_NESTED);
92111

93112
String inputJson = ResourceTestFileUtils.getFileContent(INPUT_PROCEDURE_REQUEST_WITH_ALL_DATA);
@@ -98,7 +117,7 @@ public void When_MappingProcedureRequestIsNested_Expect_ResourceMappedWithIsNest
98117
}
99118

100119
@Test
101-
public void When_MappingProcedureRequestThatIsNotPlan_Expect_ResourceNotMapped() throws IOException {
120+
public void When_MappingProcedureRequestThatIsNotPlan_Expect_ResourceNotMapped() {
102121
String inputJson = ResourceTestFileUtils.getFileContent(INPUT_PROCEDURE_REQUEST_IS_NOT_PLAN);
103122
ProcedureRequest inputProcedureRequest = new FhirParseService().parseResource(inputJson, ProcedureRequest.class);
104123

@@ -107,7 +126,7 @@ public void When_MappingProcedureRequestThatIsNotPlan_Expect_ResourceNotMapped()
107126
}
108127

109128
@Test
110-
public void When_MappingProcedureRequestWithoutRequiredAuthoredOn_Expect_MapperException() throws IOException {
129+
public void When_MappingProcedureRequestWithoutRequiredAuthoredOn_Expect_MapperException() {
111130
String inputJson = ResourceTestFileUtils.getFileContent(INPUT_PROCEDURE_REQUEST_WITHOUT_REQUIRED_AUTHORED_ON);
112131
ProcedureRequest inputProcedureRequest = new FhirParseService().parseResource(inputJson, ProcedureRequest.class);
113132

@@ -275,7 +294,7 @@ public void When_MappingWithDeviceReferenceWhereDeviceHasNoManufacturer_Expect_T
275294

276295
@ParameterizedTest
277296
@MethodSource("testData")
278-
public void When_MappingProcedureRequest_Expect_ResourceMapped(String inputJsonPath, String expectedXmlPath) throws IOException {
297+
public void When_MappingProcedureRequest_Expect_ResourceMapped(String inputJsonPath, String expectedXmlPath) {
279298
String expectedXml = ResourceTestFileUtils.getFileContent(expectedXmlPath);
280299

281300
String inputJson = ResourceTestFileUtils.getFileContent(inputJsonPath);

service/src/test/java/uk/nhs/adaptors/gp2gp/ehr/mapper/EhrExtractMapperComponentTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ messageContext, randomIdGeneratorService, new StructuredObservationValueMapper()
164164
codeableConceptCdMapper, new ParticipantMapper()),
165165
new ConditionLinkSetMapper(
166166
messageContext, randomIdGeneratorService, codeableConceptCdMapper, participantMapper, confidentialityService),
167-
new DiaryPlanStatementMapper(messageContext, codeableConceptCdMapper, participantMapper),
167+
new DiaryPlanStatementMapper(messageContext, codeableConceptCdMapper, participantMapper, confidentialityService),
168168
documentReferenceToNarrativeStatementMapper,
169169
new ImmunizationObservationStatementMapper(
170170
messageContext,

service/src/test/java/uk/nhs/adaptors/gp2gp/ehr/mapper/EncounterComponentsMapperTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public void setUp() {
152152
confidentialityService
153153
);
154154
DiaryPlanStatementMapper diaryPlanStatementMapper
155-
= new DiaryPlanStatementMapper(messageContext, codeableConceptCdMapper, participantMapper);
155+
= new DiaryPlanStatementMapper(messageContext, codeableConceptCdMapper, participantMapper, confidentialityService);
156156
DocumentReferenceToNarrativeStatementMapper documentReferenceToNarrativeStatementMapper
157157
= new DocumentReferenceToNarrativeStatementMapper(
158158
messageContext, new SupportedContentTypes(), participantMapper, confidentialityService);

service/src/test/java/uk/nhs/adaptors/gp2gp/uat/EhrExtractUATTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ messageContext, randomIdGeneratorService, new StructuredObservationValueMapper()
184184
codeableConceptCdMapper, new ParticipantMapper()),
185185
new ConditionLinkSetMapper(
186186
messageContext, randomIdGeneratorService, codeableConceptCdMapper, participantMapper, confidentialityService),
187-
new DiaryPlanStatementMapper(messageContext, codeableConceptCdMapper, participantMapper),
187+
new DiaryPlanStatementMapper(messageContext, codeableConceptCdMapper, participantMapper, confidentialityService),
188188
documentReferenceToNarrativeStatementMapper,
189189
new ImmunizationObservationStatementMapper(
190190
messageContext,

service/src/test/resources/ehr/mapper/procedurerequest/procedure-request-resource-1.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
{
22
"resourceType": "ProcedureRequest",
33
"id": "1B1C6F50-D8BE-4480-83D6-EF25AC5F1836",
4+
"meta": {
5+
"profile": [
6+
"https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-Immunization-1"
7+
],
8+
"security": [{
9+
"system":"http://hl7.org/fhir/v3/ActCode",
10+
"code":"NOPAT",
11+
"display":"no disclosure to patient, family or caregivers without attending provider's authorization"
12+
}]
13+
},
414
"status": "active",
515
"intent": "plan",
616
"code": {

0 commit comments

Comments
 (0)