Skip to content

Commit ea96588

Browse files
committed
Merge remote-tracking branch 'origin/main' into NIAD-3217
2 parents 913631b + 5b0f9f7 commit ea96588

14 files changed

+118
-30
lines changed

.github/workflows/build_workflow.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ jobs:
9494
steps:
9595
- name: Checkout Repository
9696
uses: actions/checkout@v4
97-
97+
with:
98+
# Disabling shallow clone is recommended for improving relevancy of Sonar reporting
99+
fetch-depth: 0
98100
- name: Setup Java 21 LTS
99101
uses: actions/setup-java@v4
100102
with:
@@ -105,8 +107,10 @@ jobs:
105107
uses: gradle/actions/setup-gradle@v4
106108

107109
- name: Execute Unit Tests
108-
run: ./gradlew test --parallel --build-cache
110+
run: ./gradlew test jacocoTestReport sonar --parallel --build-cache
109111
working-directory: ./service
112+
env:
113+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
110114

111115
- name: Collect Artifacts
112116
if: always()

CHANGELOG.md

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

77
## [Unreleased]
88

9-
## Fixed
10-
11-
* When mapping an `Observation` related to a diagnostic report which does not contain a `code` element, the adaptor will
12-
now throw an error reporting that an observation requires a code element and provide the affected resource ID.
13-
* When mapping a `valueQuantity` contained in an `Observation`, the produced XML `<value>` element now correctly escapes
14-
any contained XML characters.
15-
169
## Added
1710

1811
* When mapping a `DocumentReference` which contains a `NOPAT` `meta.security` or `NOPAT` `securityLabel` tag the resultant XML for that resource
@@ -32,8 +25,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3225
* When mapping `Immunizations` which contain a `NOPAT` `meta.security` tag, the resultant XML for that resource
3326
will contain a `NOPAT` `confidentialityCode` element.
3427

35-
### Fixed
36-
* Removed the 20 MB data processing limit to enable the GP2GP Adaptor to handle larger documents.
28+
## [2.1.4] - 2014-11-07
29+
30+
## Fixed
31+
32+
* When mapping an `Observation` related to a diagnostic report which does not contain a `code` element, the adaptor will
33+
now throw an error reporting that an observation requires a code element and provide the affected resource ID.
34+
Previously the adaptor was generating an invalid GP2GP payload which was being rejected by the requesting system with
35+
a vague error code.
36+
* When mapping a `valueQuantity` contained in an `Observation`, the generated XML element now correctly escapes any
37+
contained XML characters.
38+
* Removed a 20 MB data processing limit which was causing large document transfers to fail.
3739

3840
## [2.1.3] - 2014-10-25
3941

e2e-tests/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ dependencies {
1818
implementation 'org.mongodb:mongo-java-driver:3.12.14'
1919
testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.17.2'
2020
testImplementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.17.2'
21-
testImplementation 'commons-io:commons-io:2.16.1'
21+
testImplementation 'commons-io:commons-io:2.17.0'
2222
testImplementation 'org.awaitility:awaitility:4.2.2'
2323
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.11.0'
2424
testImplementation "org.assertj:assertj-core:3.26.3"

service/build.gradle

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ plugins {
66
id "com.github.spotbugs" version "6.0.25"
77
id "io.freefair.lombok" version "8.10.2"
88
id 'jacoco'
9+
id 'org.sonarqube' version '5.1.0.4882'
910

1011
// Mutation testing
1112
id 'info.solidsoft.pitest' version '1.15.0'
@@ -128,7 +129,6 @@ tasks.withType(Test) {
128129
}
129130

130131
check.dependsOn integrationTest
131-
jacocoTestReport.dependsOn integrationTest
132132

133133
spotbugsTest.enabled = false
134134
spotbugsIntegrationTest.enabled = false
@@ -164,6 +164,14 @@ pitestGithub {
164164
deleteOldSummaries = true
165165
}
166166

167+
sonar {
168+
properties {
169+
property("sonar.host.url", "https://sonarcloud.io")
170+
property("sonar.projectKey", "NHSDigital_integration-adaptor-gp2gp")
171+
property("sonar.organization", "nhsdigital")
172+
}
173+
}
174+
167175
bootJar {
168176
exclude("**/TransformJsonToXml*")
169177
}

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class DiagnosticReportMapperTest {
7777
private static final String INPUT_JSON_MULTIPLE_CODED_DIAGNOSIS = "diagnostic-report-with-multiple-coded-diagnosis.json";
7878
private static final String INPUT_JSON_EXTENSION_ID = "diagnostic-report-with-extension-id.json";
7979
private static final String INPUT_JSON_URN_OID_EXTENSION_ID = "diagnostic-report-with-urn-oid-extension-id.json";
80+
private static final String INPUT_JSON_UNRELATED_TEST_RESULT = "diagnostic-report-with-one-specimen-and-one-unrelated-observation.json";
8081

8182
private static final String OUTPUT_XML_REQUIRED_DATA = "diagnostic-report-with-required-data.xml";
8283
private static final String OUTPUT_XML_STATUS_NARRATIVE = "diagnostic-report-with-status-narrative.xml";
@@ -88,6 +89,7 @@ class DiagnosticReportMapperTest {
8889
private static final String OUTPUT_XML_MULTIPLE_CODED_DIAGNOSIS = "diagnostic-report-with-multiple-coded-diagnosis.xml";
8990
private static final String OUTPUT_XML_EXTENSION_ID = "diagnostic-report-with-extension-id.xml";
9091
private static final String OUTPUT_XML_MULTIPLE_RESULTS = "diagnostic-report-with-multiple-results.xml";
92+
private static final String OUTPUT_XML_UNRELATED_TEST_RESULT = "diagnostic-report-with-one-specimen-and-one-unrelated-observation.xml";
9193
private static final String REGEXP_UUID = "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}";
9294
private static final String MOCKED_SPECIMEN_PREFIX = "Mapped Specimen with id";
9395
private static final String MOCKED_SPECIMEN_LINKED_OBSERVATION = "with linked Observations";
@@ -141,7 +143,7 @@ void When_MappingDiagnosticReportJson_Expect_CompoundStatementXmlOutput(String i
141143

142144
final String outputMessage = mapper.mapDiagnosticReportToCompoundStatement(diagnosticReport);
143145

144-
assertThat(removeLineEndings(outputMessage)).isEqualToIgnoringWhitespace(removeLineEndings(expectedOutputMessage.toString()));
146+
assertThat(outputMessage).isEqualToIgnoringWhitespace(expectedOutputMessage.toString());
145147
}
146148

147149
@Test
@@ -305,7 +307,7 @@ void When_DiagnosticReport_Has_SpecimenAndUnlinkedTestResult_Expect_ADummySpecim
305307
final DiagnosticReport diagnosticReport = getDiagnosticReportResourceFromJson(diagnosticReportFileName);
306308
final Bundle bundle = getBundleResourceFromJson(INPUT_JSON_BUNDLE);
307309
final InputBundle inputBundle = new InputBundle(bundle);
308-
final String expectObservation = "Observation/AD373CA7-3940-4249-85A2-D3A22E9F17C7";
310+
final String expectObservation = "Observation/TestResult-WithoutSpecimenReference";
309311
final String dummyNamePrefix = DiagnosticReportMapper.DUMMY_SPECIMEN_ID_PREFIX;
310312

311313
when(messageContext.getInputBundleHolder()).thenReturn(inputBundle);
@@ -360,10 +362,6 @@ private DiagnosticReport getDiagnosticReportResourceFromJson(String filename) {
360362
return FileParsingUtility.parseResourceFromJsonFile(filePath, DiagnosticReport.class);
361363
}
362364

363-
private String removeLineEndings(String input) {
364-
return input.replace("\n", "").replace("\r", "");
365-
}
366-
367365
private static Stream<Arguments> resourceFileParams() {
368366
return Stream.of(
369367
Arguments.of(INPUT_JSON_REQUIRED_DATA, OUTPUT_XML_STATUS_NARRATIVE),
@@ -379,7 +377,8 @@ private static Stream<Arguments> resourceFileParams() {
379377
Arguments.of(INPUT_JSON_CODED_DIAGNOSIS, OUTPUT_XML_CODED_DIAGNOSIS),
380378
Arguments.of(INPUT_JSON_MULTIPLE_CODED_DIAGNOSIS, OUTPUT_XML_MULTIPLE_CODED_DIAGNOSIS),
381379
Arguments.of(INPUT_JSON_EXTENSION_ID, OUTPUT_XML_EXTENSION_ID),
382-
Arguments.of(INPUT_JSON_URN_OID_EXTENSION_ID, OUTPUT_XML_EXTENSION_ID)
380+
Arguments.of(INPUT_JSON_URN_OID_EXTENSION_ID, OUTPUT_XML_EXTENSION_ID),
381+
Arguments.of(INPUT_JSON_UNRELATED_TEST_RESULT, OUTPUT_XML_UNRELATED_TEST_RESULT)
383382
);
384383
}
385384

service/src/test/resources/ehr/mapper/diagnosticreport/diagnostic-report-with-one-specimen-and-one-unrelated-observation.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"issued": "2010-02-25T15:41:00+00:00",
3838
"result": [
3939
{
40-
"reference": "Observation/AD373CA7-3940-4249-85A2-D3A22E9F17C7"
40+
"reference": "Observation/TestResult-WithoutSpecimenReference"
4141
}
4242
],
4343
"specimen":[

service/src/test/resources/ehr/mapper/diagnosticreport/diagnostic-report-with-one-specimen-and-one-unrelated-observation.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Status: unknown</text>
2020
<availabilityTime value="20100225154100"/>
2121
</NarrativeStatement>
2222
</component>
23+
<!-- Mapped Specimen with id: DUMMY-SPECIMEN-5E496953-065B-41F2-9577-BE8F2FBD0757 with linked Observations: Observation/TestResult-WithoutSpecimenReference-->
2324
<!-- Mapped Specimen with id: Specimen/96B93E28-293D-46E7-B4C2-D477EEBF7098-SPEC-0 -->
24-
<!-- Mapped Specimen with id: DUMMY-SPECIMEN-5E496953-065B-41F2-9577-BE8F2FBD0757 -->
2525
</CompoundStatement>
2626
</component>

service/src/test/resources/ehr/mapper/diagnosticreport/fhir_bundle.json

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,73 @@
398398
]
399399
}
400400
},
401+
402+
{
403+
"resource":{
404+
"resourceType":"Observation",
405+
"id":"TestResult-WithoutSpecimenReference",
406+
"meta":{
407+
"profile":[
408+
"https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-Observation-1"
409+
]
410+
},
411+
"identifier":[
412+
{
413+
"system":"https://EMISWeb/A82038",
414+
"value":"AD373CA7-3940-4249-85A2-D3A22E9F17C7"
415+
}
416+
],
417+
"status":"unknown",
418+
"category":[
419+
{
420+
"coding":[
421+
{
422+
"system":"http://hl7.org/fhir/observation-category",
423+
"code":"laboratory",
424+
"display":"Laboratory"
425+
}
426+
]
427+
}
428+
],
429+
"code":{
430+
"coding":[
431+
{
432+
"system":"http://read.info/readv2",
433+
"code":"4483.00",
434+
"display":"Serum ACTH",
435+
"userSelected":true
436+
},
437+
{
438+
"extension":[
439+
{
440+
"url":"https://fhir.nhs.uk/STU3/StructureDefinition/Extension-coding-sctdescid",
441+
"extension":[
442+
{
443+
"url":"descriptionId",
444+
"valueId":"2563401000000119"
445+
}
446+
]
447+
}
448+
],
449+
"system":"http://snomed.info/sct",
450+
"code":"997201000000100",
451+
"display":"Normal levels detected"
452+
}
453+
]
454+
},
455+
"subject":{
456+
"reference":"Patient/DAED5527-1985-45D9-993E-C5FF51F36828"
457+
},
458+
"effectiveDateTime":"2010-02-23",
459+
"issued":"2010-02-25T15:41:00+00:00",
460+
"performer":[
461+
{
462+
"reference":"Practitioner/C8FD0E2C-3124-4C72-AC8D-ABEA65537D1B"
463+
}
464+
],
465+
"comment":"This is a test result without a specimen."
466+
}
467+
},
401468
{
402469
"resource":{
403470
"resourceType":"Observation",

wiremock/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ To change the patient record returned to have 100 3.5MB = 350MB total attachment
105105
curl --request PUT --data '{"state": "350MB Attachments"}' http://localhost:8110/__admin/scenarios/migrateStructuredRecord/state
106106
```
107107

108-
To change the patient record returned to have a 10MB attachment (useful for testing fragments) [10MBDocument](stubs/__files/correctPatientStructuredRecordResponse10MBAttachment.json):
108+
To change the patient record returned to have a 30MB attachment (useful for testing fragments) [30MBDocument](stubs/__files/correctPatientStructuredRecordResponse30MBAttachment.json):
109109

110110
```shell
111-
curl --request PUT --data '{"state": "10MB Attachment"}' http://localhost:8110/__admin/scenarios/migrateStructuredRecord/state
111+
curl --request PUT --data '{"state": "30MB Attachment"}' http://localhost:8110/__admin/scenarios/migrateStructuredRecord/state
112112
```
113113

114114
To change the patient record returned to be NOT FOUND:

wiremock/stubs/__files/correct10MBDocumentResponse.json renamed to wiremock/stubs/__files/correct30MBDocumentResponse.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"resourceType": "Binary",
33
"id": "2cb1f113-3b15-41e8-b6b1-21e761838b19",
44
"contentType": "text/plain",
5-
"content": "{{#base64}}{{randomValue length=10485760 type='ALPHANUMERIC'}}{{/base64}}"
5+
"content": "{{#base64}}{{randomValue length=31457280 type='ALPHANUMERIC'}}{{/base64}}"
66
}

0 commit comments

Comments
 (0)