Skip to content

Commit d903a92

Browse files
authored
NIAD-3144-OBSERVATIONS - Confidentiality Code (i.e. Redactions) Support for Observation > Test Group, Test Result and Narrative (#840)
* [NIAD-3144-OBSERVATIONS] Add initial tests * [NIAD-3144-OBSERVATIONS] Add test resources * [NIAD-3144-OBSERVATIONS] Update templates * [NIAD-3144-OBSERVATIONS] Add logic to ObservationMapper.java to add confidentialityCode support to `Observation` > `TestGroup`, `NarrativeStatement` and `TestResult` * [NIAD-3144-OBSERVATIONS] Add logic to ObservationMapper.java to add confidentialityCode support to `Observation` > `TestGroup`, `NarrativeStatement` and `TestResult` * [NIAD-3144-OBSERVATIONS] Update tests which constructs a new `ObservationMapper` to take a `confidentialityService` mock * [NIAD-3144-OBSERVATIONS] Address checkstyle violations * [NIAD-3144-OBSERVATIONS] Address failing mutation test * [NIAD-3144-OBSERVATIONS] Address failing mutation test * [NIAD-3144-OBSERVATIONS] Address failing mutation test * [NIAD-3144-OBSERVATIONS] Address failing mutation test * [NIAD-3112] Enhance tests, remove unnecessary XML resources, add utility methods * [NIAD-3112] Address PR comments #840 (comment) & #840 (comment) * [NIAD-3144-OBSERVATIONS] Update CHANGELOG.md * [NIAD-3144-OBSERVATIONS] Address Checkstyle violations
1 parent 9242989 commit d903a92

17 files changed

+420
-84
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
will contain a `NOPAT` `confidentialityCode` element.
1313
* When mapping a `DiagnosticReport` or `Specimen` which contains a `NOPAT` `meta.security` tag the resultant XML for that resource
1414
will contain a `NOPAT` `confidentialityCode` element.
15+
* When mapping a `TestResult`, `TestGroupHeader` or `FilingComment` which contains a `NOPAT` `meta.security` tag the resultant XML
16+
for that resource will contain a `NOPAT` `confidentialityCode` element.
1517

1618
## [2.0.6] - 2024-07-29
1719

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
import lombok.RequiredArgsConstructor;
3131
import lombok.extern.slf4j.Slf4j;
32+
import uk.nhs.adaptors.gp2gp.common.service.ConfidentialityService;
3233
import uk.nhs.adaptors.gp2gp.ehr.exception.EhrMapperException;
3334
import uk.nhs.adaptors.gp2gp.ehr.mapper.CodeableConceptCdMapper;
3435
import uk.nhs.adaptors.gp2gp.ehr.mapper.CommentType;
@@ -87,6 +88,7 @@ public class ObservationMapper {
8788
private final CodeableConceptCdMapper codeableConceptCdMapper;
8889
private final ParticipantMapper participantMapper;
8990
private final MultiStatementObservationHolderFactory multiStatementObservationHolderFactory;
91+
private final ConfidentialityService confidentialityService;
9092

9193
public String mapObservationToCompoundStatement(Observation observationAssociatedWithSpecimen) {
9294
var holder = multiStatementObservationHolderFactory.newInstance(observationAssociatedWithSpecimen);
@@ -156,6 +158,7 @@ private String outputWithCompoundStatement(MultiStatementObservationHolder obser
156158
.codeElement(codeElement)
157159
.effectiveTime(effectiveTime)
158160
.availabilityTimeElement(availabilityTimeElement)
161+
.confidentialityCode(confidentialityService.generateConfidentialityCode(observation).orElse(null))
159162
.observationStatement(observationStatement)
160163
.narrativeStatements(narrativeStatements)
161164
.statementsForDerivedObservations(statementsForDerivedObservations);
@@ -181,8 +184,10 @@ private List<MultiStatementObservationHolder> getRelatedObservations(
181184

182185
private String outputWithoutCompoundStatement(MultiStatementObservationHolder observationAssociatedWithSpecimen) {
183186
CompoundStatementClassCode classCode = CompoundStatementClassCode.CLUSTER;
187+
184188
String observationStatement = prepareObservationStatement(observationAssociatedWithSpecimen, classCode)
185189
.orElse(StringUtils.EMPTY);
190+
186191
String narrativeStatements = prepareNarrativeStatements(
187192
observationAssociatedWithSpecimen,
188193
isInterpretationCodeMapped(observationStatement))
@@ -205,7 +210,8 @@ private String mapObservationToObservationStatement(MultiStatementObservationHol
205210
.observationStatementId(holder.nextHl7InstanceIdentifier())
206211
.codeElement(prepareCodeElement(holder.getObservation()))
207212
.effectiveTime(StatementTimeMappingUtils.prepareEffectiveTimeForObservation(holder.getObservation()))
208-
.availabilityTimeElement(StatementTimeMappingUtils.prepareAvailabilityTimeForObservation(holder.getObservation()));
213+
.availabilityTimeElement(StatementTimeMappingUtils.prepareAvailabilityTimeForObservation(holder.getObservation()))
214+
.confidentialityCode(confidentialityService.generateConfidentialityCode(holder.getObservation()).orElse(null));
209215

210216
if (holder.getObservation().hasValue() && !holder.getObservation().hasValueStringType()) {
211217
Type value = holder.getObservation().getValue();
@@ -397,7 +403,8 @@ private String mapObservationToNarrativeStatement(MultiStatementObservationHolde
397403
.commentType(commentType)
398404
.commentDate(handleEffectiveToCommentDate(observation))
399405
.comment(comment)
400-
.availabilityTimeElement(StatementTimeMappingUtils.prepareAvailabilityTimeForObservation(observation));
406+
.availabilityTimeElement(StatementTimeMappingUtils.prepareAvailabilityTimeForObservation(observation))
407+
.confidentialityCode(confidentialityService.generateConfidentialityCode(observation).orElse(null));
401408

402409
return TemplateUtils.fillTemplate(NARRATIVE_STATEMENT_TEMPLATE, narrativeStatementTemplateParameters.build());
403410
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ public class NarrativeStatementTemplateParameters {
1313
private String commentDate;
1414
private String comment;
1515
private String availabilityTimeElement;
16+
private String confidentialityCode;
1617
private String participant;
1718
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class ObservationCompoundStatementTemplateParameters {
1313
private String codeElement;
1414
private String effectiveTime;
1515
private String availabilityTimeElement;
16+
private String confidentialityCode;
1617
private String observationStatement;
1718
private String narrativeStatements;
1819
private String statementsForDerivedObservations;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public class ObservationStatementTemplateParameters {
1212
private String codeElement;
1313
private String effectiveTime;
1414
private String availabilityTimeElement;
15+
private String confidentialityCode;
1516
private String value;
1617
private String referenceRange;
1718
private String interpretation;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ CommentDate:{{{.}}}
99
{{comment}}</text>
1010
<statusCode code="COMPLETE"/>
1111
{{{availabilityTimeElement}}}
12+
{{#confidentialityCode}}
13+
{{{confidentialityCode}}}
14+
{{/confidentialityCode}}
1215
{{#participant}}
1316
{{{.}}}
1417
{{/participant}}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
{{{effectiveTime}}}
88
</effectiveTime>
99
{{{availabilityTimeElement}}}
10+
{{#confidentialityCode}}
11+
{{{confidentialityCode}}}
12+
{{/confidentialityCode}}
1013
{{#observationStatement}}
1114
{{{.}}}
1215
{{/observationStatement}}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
{{{effectiveTime}}}
88
</effectiveTime>
99
{{{availabilityTimeElement}}}
10+
{{#confidentialityCode}}
11+
{{{confidentialityCode}}}
12+
{{/confidentialityCode}}
1013
{{#value}}
1114
{{{.}}}
1215
{{/value}}

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
@@ -152,7 +152,7 @@ public void setUp() {
152152
new MultiStatementObservationHolderFactory(messageContext, randomIdGeneratorService);
153153
ObservationMapper specimenObservationMapper = new ObservationMapper(
154154
messageContext, structuredObservationValueMapper, codeableConceptCdMapper,
155-
participantMapper, multiStatementObservationHolderFactory);
155+
participantMapper, multiStatementObservationHolderFactory, confidentialityService);
156156
SpecimenMapper specimenMapper = new SpecimenMapper(messageContext, specimenObservationMapper,
157157
randomIdGeneratorService, confidentialityService);
158158
DocumentReferenceToNarrativeStatementMapper documentReferenceToNarrativeStatementMapper

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
@@ -195,7 +195,7 @@ public void setUp() {
195195
new MultiStatementObservationHolderFactory(messageContext, randomIdGeneratorService);
196196
ObservationMapper specimenObservationMapper = new ObservationMapper(
197197
messageContext, structuredObservationValueMapper, codeableConceptCdMapper, participantMapper,
198-
multiStatementObservationHolderFactory);
198+
multiStatementObservationHolderFactory, confidentialityService);
199199
return new SpecimenMapper(messageContext, specimenObservationMapper, randomIdGeneratorService, confidentialityService);
200200
}
201201

0 commit comments

Comments
 (0)