Skip to content

Commit 1452a8c

Browse files
authored
Merge branch 'main' into NIAD-3152-testing-new
2 parents f0d87b3 + 51e22e4 commit 1452a8c

File tree

13 files changed

+116
-79
lines changed

13 files changed

+116
-79
lines changed

CHANGELOG.md

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

77
## [Unreleased]
88

9+
### Added
10+
* When the ReferralRequest.meta.security field contains NOPAT, the GP2GP Adaptor will now populate the RequestStatement / confidentialityCode field accordingly.
11+
* The GP2GP Adaptor now populates the CompoundStatement / confidentialityCode field when Observation.meta.security field contains NOPAT
12+
13+
## [2.3.0] - 2025-03-24
14+
915
### Fixed
1016

11-
* When mapping to `<code nullFlavor="UNK">` XML elements from an existing `CodeableConcept` the element will now contain
12-
the original text value from the DisplayExtension, if a separate text field is not provided.
13-
In the case that neither of these are present, the existing behavior of using the `code.display` element is used.
17+
* When mapping to `<code nullFlavor="UNK">` XML elements from an existing `CodeableConcept` the element will now contain the original text value from the DisplayExtension, if a separate text field is not provided. In the case that neither of these are present, the existing behavior of using the `code.display` element is used.
1418

1519
### Added
1620

21+
* Legacy codes are preserved as translations within the XML when mapping `CodeableConcepts`, when a SNOMEDCT code is provided along with additional codings for Egton, READ (v2 or v3), or EMIS drug codes. For other unknown code systems, these will not be preserved.
1722
* GP2GP Adaptor now populates the PlanStatement / confidentialityCode field when the ProcedureRequest.meta.security field contains NOPAT
18-
* When the ReferralRequest.meta.security field contains NOPAT, the GP2GP Adaptor will now populate the RequestStatement / confidentialityCode field accordingly.
19-
* The GP2GP Adaptor now populates the CompoundStatement / confidentialityCode field when Observation.meta.security field contains NOPAT
2023

2124
## [2.2.2] - 2025-02-07
2225

e2e-tests/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ dependencies {
2222
testImplementation 'org.awaitility:awaitility:4.3.0'
2323
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.11.4'
2424
testImplementation "org.assertj:assertj-core:3.27.3"
25-
testImplementation 'ch.qos.logback:logback-classic:1.5.17'
25+
testImplementation 'ch.qos.logback:logback-classic:1.5.18'
2626
testImplementation 'org.xmlunit:xmlunit-assertj3:2.10.0'
2727
testImplementation 'org.apache.httpcomponents.client5:httpclient5:5.4.2'
2828

mock-mhs-adaptor/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
plugins {
2-
id 'org.springframework.boot' version '3.4.3'
2+
id 'org.springframework.boot' version '3.4.4'
33
id 'io.spring.dependency-management' version '1.1.7'
44
id 'java'
5-
id "io.freefair.lombok" version "8.12.2.1"
5+
id "io.freefair.lombok" version "8.13"
66
}
77

88
apply plugin: 'java'

service/build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ plugins {
1010

1111
// Mutation testing
1212
id 'info.solidsoft.pitest' version '1.15.0'
13-
id 'com.arcmutate.github' version '2.0.0'
13+
id 'com.arcmutate.github' version '2.1.0'
1414
}
1515

1616
apply plugin: 'java'
@@ -50,8 +50,8 @@ dependencies {
5050
implementation 'org.springframework.boot:spring-boot-starter-logging'
5151

5252
// Infrastructure
53-
implementation 'software.amazon.awssdk:s3:2.30.31'
54-
implementation ('com.azure:azure-storage-blob:12.29.1')
53+
implementation 'software.amazon.awssdk:s3:2.31.6'
54+
implementation ('com.azure:azure-storage-blob:12.30.0')
5555
implementation 'org.apache.qpid:qpid-jms-client:2.6.1'
5656

5757
// Utils
@@ -66,15 +66,15 @@ dependencies {
6666
// Test
6767
testImplementation 'org.springframework.boot:spring-boot-starter-test'
6868
testImplementation "org.assertj:assertj-core:3.27.3"
69-
testImplementation 'org.testcontainers:testcontainers:1.20.5'
69+
testImplementation 'org.testcontainers:testcontainers:1.20.6'
7070
testImplementation 'org.awaitility:awaitility:4.2.2'
7171
testImplementation 'org.wiremock:wiremock-standalone:3.12.1'
7272
testImplementation 'com.squareup.okhttp3:okhttp:4.12.0'
7373
testImplementation 'com.squareup.okhttp3:mockwebserver:4.12.0'
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.0.0'
77+
pitest 'com.arcmutate:pitest-git-plugin:2.1.0'
7878
}
7979

8080
test {

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

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package uk.nhs.adaptors.gp2gp.ehr.mapper;
22

3+
import java.util.ArrayList;
34
import java.util.Collections;
45
import java.util.List;
56
import java.util.Optional;
@@ -310,20 +311,21 @@ private Optional<Coding> getSnomedCodeCoding(CodeableConcept codeableConcept) {
310311
}
311312

312313
private List<Coding> getNonSnomedCodeCodings(CodeableConcept codeableConcept) {
313-
return List.of();
314-
//
315-
// var nonSnomedCodeCodings = codeableConcept.getCoding()
316-
// .stream()
317-
// .filter(coding -> !isSnomed(coding))
318-
// .filter(coding -> !CodeSystemsUtil.getHl7code(coding.getSystem()).isEmpty())
319-
// .toList();
320-
//
321-
// for (Coding coding : nonSnomedCodeCodings) {
322-
// var hl7CodeSystem = CodeSystemsUtil.getHl7code(coding.getSystem());
323-
// coding.setSystem(hl7CodeSystem);
324-
// }
325-
//
326-
// return nonSnomedCodeCodings;
314+
var nonSnomedCodeCodings = codeableConcept.getCoding()
315+
.stream()
316+
.filter(coding -> !isSnomed(coding))
317+
.toList();
318+
319+
List<Coding> nonSnomedCodings = new ArrayList<>();
320+
321+
for (Coding coding : nonSnomedCodeCodings) {
322+
var hl7CodeSystem = CodeSystemsUtil.getHl7code(coding.getSystem());
323+
if (!hl7CodeSystem.isEmpty()) {
324+
nonSnomedCodings.add(new Coding(hl7CodeSystem, coding.getCode(), coding.getDisplay()));
325+
}
326+
}
327+
328+
return nonSnomedCodings;
327329
}
328330

329331
private Optional<String> findOriginalText(CodeableConcept codeableConcept, Optional<Coding> coding) {

service/src/main/java/uk/nhs/adaptors/gp2gp/ehr/utils/CodeSystemsUtil.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ public final class CodeSystemsUtil {
1212
"http://snomed.info/sct", "2.16.840.1.113883.2.1.3.2.4.15",
1313
"https://fhir.hl7.org.uk/Id/egton-codes", "2.16.840.1.113883.2.1.6.3",
1414
"http://read.info/readv2", "2.16.840.1.113883.2.1.6.2",
15-
"http://read.info/ctv3", "2.16.840.1.113883.2.1.3.2.4.14"
15+
"http://read.info/ctv3", "2.16.840.1.113883.2.1.3.2.4.14",
16+
"https://fhir.hl7.org.uk/Id/emis-drug-codes", "2.16.840.1.113883.2.1.6.9"
1617
);
1718

1819
public static String getHl7code(String fhirCodeSystem) {
19-
return SYSTEM_CODES.getOrDefault(fhirCodeSystem, fhirCodeSystem);
20+
return SYSTEM_CODES.getOrDefault(fhirCodeSystem, "");
2021
}
2122
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<code{{#nullFlavor}} nullFlavor="UNK"{{/nullFlavor}}{{^nullFlavor}} code="{{mainCode}}" codeSystem="{{mainCodeSystem}}" displayName="{{mainDisplayName}}"{{/nullFlavor}}>
2+
{{#mainOriginalText}}
3+
<originalText>{{mainOriginalText}}</originalText>
4+
{{/mainOriginalText}}
25
{{#translations}}
36
<translation code="{{code}}" codeSystem="{{system}}" displayName="{{display}}" />
47
{{/translations}}
5-
{{#mainOriginalText}}
6-
<originalText>{{mainOriginalText}}</originalText>
7-
{{/mainOriginalText}}
88
</code>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ public void tearDown() {
9494
messageContext.resetMessageContext();
9595
}
9696

97+
9798
@Test
9899
public void When_MappingBloodPressureWithNopat_Expect_CompoundStatementWithConfidentialityCode() {
99100
when(mockCodeableConceptCdMapper.mapCodeableConceptToCdForBloodPressure(any(CodeableConcept.class)))

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

Lines changed: 67 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,36 @@ public void When_MappingStubbedCodeableConcept_Expect_HL7CdObjectXml(String inpu
123123
// assertThat(outputMessageXml).isEqualToIgnoringWhitespace(expectedOutputXml);
124124
// }
125125

126+
@Test
127+
void When_MappingCodeableConceptWithUnknownNonSnomedCodeSystem_Expect_ManifestedXmlDoesNotContainTranslations() {
128+
var inputJson = """
129+
{
130+
"resourceType" : "Observation",
131+
"code": {
132+
"coding": [
133+
{
134+
"system": "http://snomed.info/sct",
135+
"code": "123456",
136+
"display": "Endometriosis of uterus"
137+
},
138+
{
139+
"system": "http://unknown.code/systen",
140+
"code": "UNKNOWN01",
141+
"display": "Unknown Code System Display"
142+
}
143+
]
144+
}
145+
}""";
146+
var expectedOutputXml = """
147+
<code code="123456" codeSystem="2.16.840.1.113883.2.1.3.2.4.15" displayName="Endometriosis of uterus">
148+
</code>""";
149+
var codeableConcept = fhirParseService.parseResource(inputJson, Observation.class).getCode();
150+
151+
var outputMessageXml = codeableConceptCdMapper.mapCodeableConceptToCd(codeableConcept);
152+
153+
assertThat(outputMessageXml).isEqualToIgnoringWhitespace(expectedOutputXml);
154+
}
155+
126156
@Test
127157
void When_MapToNullFlavorCodeableConceptForAllergyWithoutSnomedCode_Expect_OriginalTextIsNotPresent() {
128158
var inputJson = """
@@ -324,43 +354,43 @@ <originalText>Prothrombin time (observed)</originalText>
324354
assertThat(outputMessage).isEqualToIgnoringWhitespace(expectedOutput);
325355
}
326356

327-
// @Test
328-
// void When_WithSnomedCodingAndLegacyCodings_Expect_SnomedCdXmlWithTranslations() {
329-
// var inputJson = """
330-
// {
331-
// "resourceType": "Observation",
332-
// "code": {
333-
// "coding": [
334-
// {
335-
// "system": "http://snomed.info/sct",
336-
// "display": "Prothrombin time",
337-
// "code": "852471000000107"
338-
// },
339-
// {
340-
// "system": "http://read.info/readv2",
341-
// "code": "42Q5.00",
342-
// "display": "Observed Prothrombin time"
343-
// },
344-
// {
345-
// "system": "http://read.info/ctv3",
346-
// "code": "123456",
347-
// "display": "Prothrombin time (observed)"
348-
// }
349-
// ]
350-
// }
351-
// }""";
352-
// var expectedOutput = """
353-
// <code code="852471000000107" codeSystem="2.16.840.1.113883.2.1.3.2.4.15" displayName="Prothrombin time">
354-
// <translation code="42Q5.00" codeSystem="2.16.840.1.113883.2.1.6.2" displayName="Observed Prothrombin time" />
355-
// <translation code="123456" codeSystem="2.16.840.1.113883.2.1.3.2.4.14" displayName="Prothrombin time (observed)" />
356-
// <originalText>Prothrombin time</originalText>
357-
// </code>""";
358-
// var codeableConcept = fhirParseService.parseResource(inputJson, Observation.class).getCode();
359-
//
360-
// var outputMessage = codeableConceptCdMapper.mapCodeableConceptToCdForBloodPressure(codeableConcept);
361-
//
362-
// assertThat(outputMessage).isEqualToIgnoringWhitespace(expectedOutput);
363-
// }
357+
@Test
358+
void When_WithSnomedCodingAndLegacyCodings_Expect_SnomedCdXmlWithTranslations() {
359+
var inputJson = """
360+
{
361+
"resourceType": "Observation",
362+
"code": {
363+
"coding": [
364+
{
365+
"system": "http://snomed.info/sct",
366+
"display": "Prothrombin time",
367+
"code": "852471000000107"
368+
},
369+
{
370+
"system": "http://read.info/readv2",
371+
"code": "42Q5.00",
372+
"display": "Observed Prothrombin time"
373+
},
374+
{
375+
"system": "http://read.info/ctv3",
376+
"code": "123456",
377+
"display": "Prothrombin time (observed)"
378+
}
379+
]
380+
}
381+
}""";
382+
var expectedOutput = """
383+
<code code="852471000000107" codeSystem="2.16.840.1.113883.2.1.3.2.4.15" displayName="Prothrombin time">
384+
<originalText>Prothrombin time</originalText>
385+
<translation code="42Q5.00" codeSystem="2.16.840.1.113883.2.1.6.2" displayName="Observed Prothrombin time" />
386+
<translation code="123456" codeSystem="2.16.840.1.113883.2.1.3.2.4.14" displayName="Prothrombin time (observed)" />
387+
</code>""";
388+
var codeableConcept = fhirParseService.parseResource(inputJson, Observation.class).getCode();
389+
390+
var outputMessage = codeableConceptCdMapper.mapCodeableConceptToCdForBloodPressure(codeableConcept);
391+
392+
assertThat(outputMessage).isEqualToIgnoringWhitespace(expectedOutput);
393+
}
364394

365395
@Test
366396
void When_WithNonSnomedCodingWithText_Expect_NullFlavorUnkCDWithOriginalTextFromText() {

service/src/test/java/uk/nhs/adaptors/gp2gp/utils/CodeSystemUtilTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010

1111
import java.util.stream.Stream;
1212

13-
public class CodeSystemUtilTest {
14-
13+
class CodeSystemUtilTest {
1514
private static Stream<Arguments> knownCodeSystems() {
1615
return Stream.of(
1716
Arguments.of("http://snomed.info/sct", "2.16.840.1.113883.2.1.3.2.4.15"),
1817
Arguments.of("https://fhir.hl7.org.uk/Id/egton-codes", "2.16.840.1.113883.2.1.6.3"),
1918
Arguments.of("http://read.info/readv2", "2.16.840.1.113883.2.1.6.2"),
20-
Arguments.of("http://read.info/ctv3", "2.16.840.1.113883.2.1.3.2.4.14")
19+
Arguments.of("http://read.info/ctv3", "2.16.840.1.113883.2.1.3.2.4.14"),
20+
Arguments.of("https://fhir.hl7.org.uk/Id/emis-drug-codes", "2.16.840.1.113883.2.1.6.9")
2121
);
2222
}
2323

@@ -30,9 +30,9 @@ void When_FhirCodeSystemIsKnown_Expect_CorrectHl7Code(String fhirCodeSystem, Str
3030
}
3131

3232
@Test
33-
void When_FhirCodeSystemIsUnknown_Expect_FhirCodeSystemIsProvided() {
33+
void When_FhirCodeSystemIsUnknown_Expect_EmptyString() {
3434
var hl7Code = CodeSystemsUtil.getHl7code("https://unknown.code/system");
3535

36-
assertThat(hl7Code).isEqualTo("https://unknown.code/system");
36+
assertThat(hl7Code).isEmpty();
3737
}
3838
}

0 commit comments

Comments
 (0)