Skip to content

Commit 0faa1b4

Browse files
authored
NIAD-3157: Send over uncategorised data observation NOPAT field to incumbent (#1194)
* Send over uncategorised data observation NOPAT field to incumbent * small test optimization * com.arcmutate:base version upgrade * downgrade pitest version * changelog update
1 parent e790581 commit 0faa1b4

File tree

11 files changed

+85
-8
lines changed

11 files changed

+85
-8
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
## [Unreleased]
88

99
### Added
10-
The GP2GP Adaptor now adds the EhrComposition / confidentialityCode field when Encounter.meta.security contains NOPAT security entry
11-
10+
* The GP2GP Adaptor now adds the EhrComposition / confidentialityCode field when Encounter.meta.security contains NOPAT security entry
11+
* The GP2GP Adaptor now populates the ObservationStatement / confidentialityCode field when the .meta.security field of an Uncategorised Data Observation contains NOPAT
1212

1313
## [2.4.0] - 2025-04-02
1414

service/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ dependencies {
7474
testImplementation 'io.findify:s3mock_2.13:0.2.6'
7575

7676
pitest 'com.arcmutate:base:1.3.2'
77-
pitest 'com.arcmutate:pitest-git-plugin:2.2.1'
77+
pitest 'com.arcmutate:pitest-git-plugin:2.1.0'
7878
}
7979

8080
test {

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.github.mustachejava.Mustache;
2121
import lombok.RequiredArgsConstructor;
2222
import lombok.extern.slf4j.Slf4j;
23+
import uk.nhs.adaptors.gp2gp.common.service.ConfidentialityService;
2324
import uk.nhs.adaptors.gp2gp.ehr.exception.EhrMapperException;
2425
import uk.nhs.adaptors.gp2gp.ehr.mapper.parameters.ObservationStatementTemplateParameters;
2526
import uk.nhs.adaptors.gp2gp.ehr.mapper.wrapper.ConditionWrapper;
@@ -47,15 +48,20 @@ public class ObservationStatementMapper {
4748
private final PertinentInformationObservationValueMapper pertinentInformationObservationValueMapper;
4849
private final CodeableConceptCdMapper codeableConceptCdMapper;
4950
private final ParticipantMapper participantMapper;
51+
private final ConfidentialityService confidentialityService;
5052

5153
public String mapObservationToObservationStatement(Observation observation, boolean isNested) {
54+
55+
var confidentialityCode = confidentialityService.generateConfidentialityCode(observation);
56+
5257
final IdMapper idMapper = messageContext.getIdMapper();
5358
var observationStatementTemplateParametersBuilder = ObservationStatementTemplateParameters.builder()
5459
.observationStatementId(idMapper.getOrNew(ResourceType.Observation, observation.getIdElement()))
5560
.code(prepareCode(observation))
5661
.issued(StatementTimeMappingUtils.prepareAvailabilityTimeForObservation(observation))
5762
.isNested(isNested)
58-
.effectiveTime(StatementTimeMappingUtils.prepareEffectiveTimeForObservation(observation));
63+
.effectiveTime(StatementTimeMappingUtils.prepareEffectiveTimeForObservation(observation))
64+
.confidentialityCode(confidentialityCode.orElse(null));
5965

6066
if (observation.hasValue()) {
6167
Type value = observation.getValue();

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public class ObservationStatementTemplateParameters {
1111
private String observationStatementId;
1212
private String comment;
1313
private String effectiveTime;
14+
private String confidentialityCode;
1415
private String issued;
1516
private String value;
1617
private String referenceRange;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
<effectiveTime>
77
{{{effectiveTime}}}
88
</effectiveTime>
9+
{{#confidentialityCode}}
10+
{{{confidentialityCode}}}
11+
{{/confidentialityCode}}
912
{{{issued}}}
1013
{{{value}}}
1114
{{{interpretation}}}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ codeableConceptCdMapper, new ParticipantMapper(), confidentialityService),
185185
new StructuredObservationValueMapper(),
186186
new PertinentInformationObservationValueMapper(),
187187
codeableConceptCdMapper,
188-
participantMapper
188+
participantMapper,
189+
confidentialityService
189190
),
190191
new RequestStatementMapper(messageContext, codeableConceptCdMapper, participantMapper, confidentialityService),
191192
new DiagnosticReportMapper(

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ public void setUp() {
183183
messageContext,
184184
structuredObservationValueMapper,
185185
new PertinentInformationObservationValueMapper(), codeableConceptCdMapper,
186-
participantMapper
186+
participantMapper,
187+
confidentialityService
187188
);
188189
ImmunizationObservationStatementMapper immunizationObservationStatementMapper =
189190
new ImmunizationObservationStatementMapper(

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

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import static org.mockito.Mockito.lenient;
99
import static org.mockito.Mockito.when;
1010

11+
import static uk.nhs.adaptors.gp2gp.common.configuration.RedactionsContext.REDACTION_INTERACTION_ID;
1112
import static uk.nhs.adaptors.gp2gp.utils.IdUtil.buildReference;
1213

1314
import java.io.IOException;
@@ -29,6 +30,8 @@
2930
import org.mockito.Mock;
3031
import org.mockito.junit.jupiter.MockitoExtension;
3132

33+
import uk.nhs.adaptors.gp2gp.common.configuration.RedactionsContext;
34+
import uk.nhs.adaptors.gp2gp.common.service.ConfidentialityService;
3235
import uk.nhs.adaptors.gp2gp.common.service.FhirParseService;
3336
import uk.nhs.adaptors.gp2gp.common.service.RandomIdGeneratorService;
3437
import uk.nhs.adaptors.gp2gp.ehr.exception.EhrMapperException;
@@ -43,6 +46,7 @@ public class ObservationStatementMapperTest {
4346

4447
private static final String INPUT_JSON_WITH_EFFECTIVE_DATE_TIME = TEST_FILE_DIRECTORY
4548
+ "example-observation-resource-1.json";
49+
private static final String INPUT_JSON_WITH_NOPAT = TEST_FILE_DIRECTORY + "example-observation-resource-with-nopat.json";
4650
private static final String INPUT_JSON_WITH_NULL_EFFECTIVE_DATE_TIME = TEST_FILE_DIRECTORY
4751
+ "example-observation-resource-2.json";
4852
private static final String INPUT_JSON_WITH_EFFECTIVE_PERIOD = TEST_FILE_DIRECTORY
@@ -127,6 +131,8 @@ public class ObservationStatementMapperTest {
127131
+ "expected-output-observation-statement-2.xml";
128132
private static final String OUTPUT_XML_USES_NESTED_COMPONENT = TEST_FILE_DIRECTORY
129133
+ "expected-output-observation-statement-3.xml";
134+
private static final String OUTPUT_XML_WITH_NOPAT = TEST_FILE_DIRECTORY
135+
+ "expected-observation-statement-with-confidentiality-code.xml";
130136
private static final String OUTPUT_XML_USES_EFFECTIVE_PERIOD = TEST_FILE_DIRECTORY
131137
+ "expected-output-observation-statement-4.xml";
132138
private static final String OUTPUT_XML_WITH_STRING_VALUE = TEST_FILE_DIRECTORY
@@ -186,6 +192,10 @@ public class ObservationStatementMapperTest {
186192
private static final String OUTPUT_XML_WITH_BODY_SITE = TEST_FILE_DIRECTORY
187193
+ "expected-output-observation-with-body-site.xml";
188194

195+
private static final String CONFIDENTIALITY_CODE =
196+
"<confidentialityCode code=\"NOPAT\" codeSystem=\"2.16.840.1.113883.4.642.3.47\" "
197+
+ "displayName=\"no disclosure to patient, family or caregivers without attending provider's authorization\" />";
198+
189199
private CharSequence expectedOutputMessage;
190200
private ObservationStatementMapper observationStatementMapper;
191201
private MessageContext messageContext;
@@ -208,14 +218,26 @@ public void setUp() {
208218
new StructuredObservationValueMapper(),
209219
new PertinentInformationObservationValueMapper(),
210220
codeableConceptCdMapper,
211-
new ParticipantMapper());
221+
new ParticipantMapper(),
222+
new ConfidentialityService(new RedactionsContext(REDACTION_INTERACTION_ID)));
212223
}
213224

214225
@AfterEach
215226
public void tearDown() {
216227
messageContext.resetMessageContext();
217228
}
218229

230+
@Test
231+
void When_MappingParsedObservationWithNopat_Expect_ObservationStatementWithConfidentialityCode() {
232+
expectedOutputMessage = ResourceTestFileUtils.getFileContent(OUTPUT_XML_WITH_NOPAT);
233+
var jsonInput = ResourceTestFileUtils.getFileContent(INPUT_JSON_WITH_NOPAT);
234+
Observation parsedObservation = new FhirParseService().parseResource(jsonInput, Observation.class);
235+
236+
String outputMessage = observationStatementMapper.mapObservationToObservationStatement(parsedObservation, true);
237+
238+
assertThat(outputMessage).contains(CONFIDENTIALITY_CODE);
239+
}
240+
219241
@ParameterizedTest
220242
@MethodSource("resourceFileParams")
221243
public void When_MappingObservationJson_Expect_ObservationStatementXmlOutput(String inputJson, String outputXml) throws IOException {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,8 @@ codeableConceptCdMapper, new ParticipantMapper(), confidentialityService),
205205
new StructuredObservationValueMapper(),
206206
new PertinentInformationObservationValueMapper(),
207207
codeableConceptCdMapper,
208-
participantMapper
208+
participantMapper,
209+
confidentialityService
209210
),
210211
new RequestStatementMapper(messageContext, codeableConceptCdMapper, participantMapper, confidentialityService),
211212
new DiagnosticReportMapper(messageContext, specimenMapper, participantMapper, randomIdGeneratorService, confidentialityService),
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"resourceType": "Observation",
3+
"id": "3377543D-5B1B-4C4F-BFF6-9F7BC3A1C3B8",
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+
},
14+
"code": {
15+
"text": "test"
16+
},
17+
"effectiveDateTime": "2010-07-14T16:32:51.42+01:00",
18+
"issued": "2010-01-13T15:29:50.3+00:00",
19+
"comment": "1.This is a line of \"text\" with a line break at the end.\n2."
20+
}

0 commit comments

Comments
 (0)