Skip to content

Commit 5b0f9f7

Browse files
author
Adrian Clay
authored
Add test to characterise existing behaviour of DignosticReportMapper (#992)
Existing behaviour of DiagnosticReportMapper only generates a dummy specimen when there aren't any Specimens. However, we will want to generate a Dummy Specimen if there also exists an Observation without a reference to a Specimen. This test characterises the existing behaviour in advance of fixing it.
1 parent de100cb commit 5b0f9f7

File tree

4 files changed

+145
-6
lines changed

4 files changed

+145
-6
lines changed

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

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

8081
private static final String OUTPUT_XML_REQUIRED_DATA = "diagnostic-report-with-required-data.xml";
8182
private static final String OUTPUT_XML_STATUS_NARRATIVE = "diagnostic-report-with-status-narrative.xml";
@@ -87,6 +88,7 @@ class DiagnosticReportMapperTest {
8788
private static final String OUTPUT_XML_MULTIPLE_CODED_DIAGNOSIS = "diagnostic-report-with-multiple-coded-diagnosis.xml";
8889
private static final String OUTPUT_XML_EXTENSION_ID = "diagnostic-report-with-extension-id.xml";
8990
private static final String OUTPUT_XML_MULTIPLE_RESULTS = "diagnostic-report-with-multiple-results.xml";
91+
private static final String OUTPUT_XML_UNRELATED_TEST_RESULT = "diagnostic-report-with-one-specimen-and-one-unrelated-observation.xml";
9092

9193
@Mock
9294
private CodeableConceptCdMapper codeableConceptCdMapper;
@@ -137,7 +139,7 @@ void When_MappingDiagnosticReportJson_Expect_CompoundStatementXmlOutput(String i
137139

138140
final String outputMessage = mapper.mapDiagnosticReportToCompoundStatement(diagnosticReport);
139141

140-
assertThat(removeLineEndings(outputMessage)).isEqualTo(removeLineEndings(expectedOutputMessage.toString()));
142+
assertThat(outputMessage).isEqualToIgnoringWhitespace(expectedOutputMessage.toString());
141143
}
142144

143145
@Test
@@ -301,10 +303,6 @@ private DiagnosticReport getDiagnosticReportResourceFromJson(String filename) {
301303
return FileParsingUtility.parseResourceFromJsonFile(filePath, DiagnosticReport.class);
302304
}
303305

304-
private String removeLineEndings(String input) {
305-
return input.replace("\n", "").replace("\r", "");
306-
}
307-
308306
private static Stream<Arguments> resourceFileParams() {
309307
return Stream.of(
310308
Arguments.of(INPUT_JSON_REQUIRED_DATA, OUTPUT_XML_STATUS_NARRATIVE),
@@ -320,7 +318,8 @@ private static Stream<Arguments> resourceFileParams() {
320318
Arguments.of(INPUT_JSON_CODED_DIAGNOSIS, OUTPUT_XML_CODED_DIAGNOSIS),
321319
Arguments.of(INPUT_JSON_MULTIPLE_CODED_DIAGNOSIS, OUTPUT_XML_MULTIPLE_CODED_DIAGNOSIS),
322320
Arguments.of(INPUT_JSON_EXTENSION_ID, OUTPUT_XML_EXTENSION_ID),
323-
Arguments.of(INPUT_JSON_URN_OID_EXTENSION_ID, OUTPUT_XML_EXTENSION_ID)
321+
Arguments.of(INPUT_JSON_URN_OID_EXTENSION_ID, OUTPUT_XML_EXTENSION_ID),
322+
Arguments.of(INPUT_JSON_UNRELATED_TEST_RESULT, OUTPUT_XML_UNRELATED_TEST_RESULT)
324323
);
325324
}
326325

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"resourceType": "DiagnosticReport",
3+
"id": "96B93E28-293D-46E7-B4C2-D477EEBF7098",
4+
"meta": {
5+
"profile": [
6+
"https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-DiagnosticReport-1"
7+
]
8+
},
9+
"identifier": [
10+
{
11+
"system": "https://EMISWeb/A82038",
12+
"value": "96B93E28-293D-46E7-B4C2-D477EEBF7098"
13+
}
14+
],
15+
"status": "unknown",
16+
"category": {
17+
"coding": [
18+
{
19+
"system": "http://hl7.org/fhir/v2/0074",
20+
"code": "PAT",
21+
"display": "Pathology (gross & histopath, not surgical)"
22+
}
23+
]
24+
},
25+
"code": {
26+
"coding": [
27+
{
28+
"system": "http://snomed.info/sct",
29+
"code": "721981007",
30+
"display": "Diagnostic studies report"
31+
}
32+
]
33+
},
34+
"subject": {
35+
"reference": "Patient/DAED5527-1985-45D9-993E-C5FF51F36828"
36+
},
37+
"issued": "2010-02-25T15:41:00+00:00",
38+
"result": [
39+
{
40+
"reference": "Observation/TestResult-WithoutSpecimenReference"
41+
}
42+
],
43+
"specimen":[
44+
{
45+
"reference":"Specimen/96B93E28-293D-46E7-B4C2-D477EEBF7098-SPEC-0"
46+
}
47+
]
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<component typeCode="COMP">
2+
<CompoundStatement classCode="CLUSTER" moodCode="EVN">
3+
<id root="II-for-DiagnosticReport-DiagnosticReport/96B93E28-293D-46E7-B4C2-D477EEBF7098"/>
4+
<code code="16488004" codeSystem="2.16.840.1.113883.2.1.3.2.4.15" displayName="laboratory reporting">
5+
<originalText>Filed Report</originalText>
6+
</code>
7+
<statusCode code="COMPLETE"/>
8+
<effectiveTime>
9+
<center nullFlavor="NI"/>
10+
</effectiveTime>
11+
<availabilityTime value="20100225154100"/>
12+
<component typeCode="COMP" contextConductionInd="true">
13+
<NarrativeStatement classCode="OBS" moodCode="EVN">
14+
<id root="5E496953-065B-41F2-9577-BE8F2FBD0757"/>
15+
<text mediaType="text/x-h7uk-pmip">CommentType:LABORATORY RESULT COMMENT(E141)
16+
CommentDate:20100225154100
17+
18+
Status: unknown</text>
19+
<statusCode code="COMPLETE"/>
20+
<availabilityTime value="20100225154100"/>
21+
</NarrativeStatement>
22+
</component>
23+
<!-- Mapped Specimen with id: Specimen/96B93E28-293D-46E7-B4C2-D477EEBF7098-SPEC-0 -->
24+
</CompoundStatement>
25+
</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
@@ -374,6 +374,73 @@
374374
]
375375
}
376376
},
377+
378+
{
379+
"resource":{
380+
"resourceType":"Observation",
381+
"id":"TestResult-WithoutSpecimenReference",
382+
"meta":{
383+
"profile":[
384+
"https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-Observation-1"
385+
]
386+
},
387+
"identifier":[
388+
{
389+
"system":"https://EMISWeb/A82038",
390+
"value":"AD373CA7-3940-4249-85A2-D3A22E9F17C7"
391+
}
392+
],
393+
"status":"unknown",
394+
"category":[
395+
{
396+
"coding":[
397+
{
398+
"system":"http://hl7.org/fhir/observation-category",
399+
"code":"laboratory",
400+
"display":"Laboratory"
401+
}
402+
]
403+
}
404+
],
405+
"code":{
406+
"coding":[
407+
{
408+
"system":"http://read.info/readv2",
409+
"code":"4483.00",
410+
"display":"Serum ACTH",
411+
"userSelected":true
412+
},
413+
{
414+
"extension":[
415+
{
416+
"url":"https://fhir.nhs.uk/STU3/StructureDefinition/Extension-coding-sctdescid",
417+
"extension":[
418+
{
419+
"url":"descriptionId",
420+
"valueId":"2563401000000119"
421+
}
422+
]
423+
}
424+
],
425+
"system":"http://snomed.info/sct",
426+
"code":"997201000000100",
427+
"display":"Normal levels detected"
428+
}
429+
]
430+
},
431+
"subject":{
432+
"reference":"Patient/DAED5527-1985-45D9-993E-C5FF51F36828"
433+
},
434+
"effectiveDateTime":"2010-02-23",
435+
"issued":"2010-02-25T15:41:00+00:00",
436+
"performer":[
437+
{
438+
"reference":"Practitioner/C8FD0E2C-3124-4C72-AC8D-ABEA65537D1B"
439+
}
440+
],
441+
"comment":"This is a test result without a specimen."
442+
}
443+
},
377444
{
378445
"resource":{
379446
"resourceType":"Observation",

0 commit comments

Comments
 (0)