Skip to content

Commit 859b945

Browse files
author
Adrian Clay
authored
Test that NarrativeStatement is only generated for filing comment (#962)
We have code which looks for filing comments which filters for related, with type "has-member", and coded as a filing comment. This behaviour is currently untested. This test is an example of a test result with a "has-member" which isn't a filing comment. (It's referncing itself)
1 parent 5104d2d commit 859b945

File tree

4 files changed

+198
-2
lines changed

4 files changed

+198
-2
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ class ObservationMapperTest {
9090
"observation_test_result.json";
9191
private static final String OBSERVATION_FILING_COMMENT_JSON =
9292
"observation_filing_comment.json";
93+
private static final String OBSERVATION_ASSOCIATED_WITH_IGNORED_MEMBER_JSON =
94+
"observation_associated_with_specimen_1_with_ignored_member.json";
9395

9496
private static final String OBSERVATION_COMPOUND_STATEMENT_1_XML =
9597
"observation_compound_statement_1.xml";
@@ -121,6 +123,8 @@ class ObservationMapperTest {
121123
"observation_compound_statement_clustered_by_diagnosticreport_reference.xml";
122124
private static final String OBSERVATION_COMPOUND_STATEMENT_1_WITH_RELATED_COMMENT_XML =
123125
"observation_compound_statement_1_with_related_comment.xml";
126+
private static final String OBSERVATION_COMPOUND_STATEMENT_WITH_BATTERY_TEST_RESULT_XML =
127+
"observation_compound_statement_with_battery_test_result.xml";
124128
private static final String DIAGNOSTIC_REPORT_REFERENCE_ID = "Observation/TEST_REFERENCE_ID";
125129

126130
@Mock
@@ -180,7 +184,7 @@ void When_MappingObservationJson_Expect_CompoundStatementXmlOutput(String inputJ
180184
final Observation observationAssociatedWithSpecimen = getObservationResourceFromJson(inputJson);
181185
final String expectedXml = getXmlStringFromFile(outputXml);
182186

183-
when(randomIdGeneratorService.createNewId())
187+
lenient().when(randomIdGeneratorService.createNewId())
184188
.thenReturn("random-unmapped-id");
185189

186190
final String actualXml = observationMapper.mapObservationToCompoundStatement(
@@ -306,7 +310,6 @@ private Observation getObservationResourceFromJson(String filename) {
306310
return FileParsingUtility.parseResourceFromJsonFile(filePath, Observation.class);
307311
}
308312

309-
@SuppressWarnings("unused")
310313
private static Stream<Arguments> resourceFileParams() {
311314
return Stream.of(
312315
Arguments.of(OBSERVATION_ASSOCIATED_WITH_SPECIMEN_1_JSON, OBSERVATION_COMPOUND_STATEMENT_1_XML),
@@ -353,6 +356,10 @@ private static Stream<Arguments> resourceFileParams() {
353356
Arguments.of(
354357
OBSERVATION_ASSOCIATED_WITH_SPECIMEN_1_WITH_RELATED_COMMENT_JSON,
355358
OBSERVATION_COMPOUND_STATEMENT_1_WITH_RELATED_COMMENT_XML
359+
),
360+
Arguments.of(
361+
OBSERVATION_ASSOCIATED_WITH_IGNORED_MEMBER_JSON,
362+
OBSERVATION_COMPOUND_STATEMENT_WITH_BATTERY_TEST_RESULT_XML
356363
)
357364
);
358365
}

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

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,74 @@
778778
],
779779
"name": "TEMPLE SOWERBY MEDICAL PRACTICE"
780780
}
781+
},
782+
{
783+
"resource":{
784+
"resourceType":"Observation",
785+
"id":"TestResult-WithRelatedMember-WhichIsntAFilingComment",
786+
"meta":{
787+
"profile":[
788+
"https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-Observation-1"
789+
]
790+
},
791+
"identifier":[
792+
{
793+
"system":"https://EMISWeb/A82038",
794+
"value":"TestResult-WithRelatedMember-WhichIsntAFilingComment"
795+
}
796+
],
797+
"code":{
798+
"coding":[
799+
{
800+
"system":"http://read.info/readv2",
801+
"code":"4465.00",
802+
"display":"Serum oestradiol level",
803+
"userSelected":true
804+
},
805+
{
806+
"extension":[
807+
{
808+
"url":"https://fhir.nhs.uk/STU3/StructureDefinition/Extension-coding-sctdescid",
809+
"extension":[
810+
{
811+
"url":"descriptionId",
812+
"valueId":"2551971000000110"
813+
}
814+
]
815+
}
816+
],
817+
"system":"http://snomed.info/sct",
818+
"code":"1010521000000102",
819+
"display":"Serum oestradiol level"
820+
}
821+
]
822+
},
823+
"valueQuantity":{
824+
"value":8.800,
825+
"unit":"mmol/L"
826+
},
827+
"comment": "Notes provided alongside test result",
828+
"status":"unknown",
829+
"subject":{
830+
"reference":"Patient/DAED5527-1985-45D9-993E-C5FF51F36828"
831+
},
832+
"effectiveDateTime":"2020-12-15T15:17:04.917+00:00",
833+
"issued":"2020-12-15T15:17:04.917+00:00",
834+
"performer":[
835+
{
836+
"reference":"Practitioner/C8FD0E2C-3124-4C72-AC8D-ABEA65537D1B"
837+
}
838+
],
839+
"related":[
840+
{
841+
"type":"has-member",
842+
"target":{
843+
"display": "Referencing itself as a member, as opposed to a filing comment. This is invalid according to GP Connect.",
844+
"reference":"Observation/TestResult-WithRelatedMember-WhichIsntAFilingComment"
845+
}
846+
}
847+
]
848+
}
781849
}
782850
]
783851
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"resourceType":"Observation",
3+
"id":"B7F05EA7-A1A4-48C0-9C4C-CDB5768796B2",
4+
"meta":{
5+
"profile":[
6+
"https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-Observation-1"
7+
]
8+
},
9+
"identifier":[
10+
{
11+
"system":"https://EMISWeb/A82038",
12+
"value":"B7F05EA7-A1A4-48C0-9C4C-CDB5768796B2"
13+
}
14+
],
15+
"status":"unknown",
16+
"category":[
17+
{
18+
"coding":[
19+
{
20+
"system":"http://hl7.org/fhir/observation-category",
21+
"code":"laboratory",
22+
"display":"Laboratory"
23+
}
24+
]
25+
}
26+
],
27+
"code":{
28+
"coding":[
29+
{
30+
"system":"http://read.info/readv2",
31+
"code":"465..00",
32+
"display":"Urine pregnancy test",
33+
"userSelected":true
34+
},
35+
{
36+
"extension":[
37+
{
38+
"url":"https://fhir.nhs.uk/STU3/StructureDefinition/Extension-coding-sctdescid",
39+
"extension":[
40+
{
41+
"url":"descriptionId",
42+
"valueId":"2564081000000118"
43+
}
44+
]
45+
}
46+
],
47+
"system":"http://snomed.info/sct",
48+
"code":"1003161000000106",
49+
"display":"Urine pregnancy test"
50+
}
51+
]
52+
},
53+
"subject":{
54+
"reference":"Patient/DAED5527-1985-45D9-993E-C5FF51F36828"
55+
},
56+
"effectiveDateTime":"2010-02-23",
57+
"issued":"2010-02-25T15:41:00+00:00",
58+
"specimen":{
59+
"reference":"Specimen/96B93E28-293D-46E7-B4C2-D477EEBF7098-SPEC-0"
60+
},
61+
"related":[
62+
{
63+
"type":"has-member",
64+
"target":{
65+
"reference":"Observation/TestResult-WithRelatedMember-WhichIsntAFilingComment"
66+
}
67+
}
68+
]
69+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<component typeCode="COMP" contextConductionInd="true">
2+
<CompoundStatement classCode="BATTERY" moodCode="EVN">
3+
<id root="Mapped-From-Observation/B7F05EA7-A1A4-48C0-9C4C-CDB5768796B2"/>
4+
<code code="2564081000000118" codeSystem="2.16.840.1.113883.2.1.3.2.4.15" displayName="Urine pregnancy test">
5+
</code>
6+
<statusCode code="COMPLETE"/>
7+
<effectiveTime>
8+
<center value="20100223"/>
9+
</effectiveTime>
10+
<availabilityTime value="20100223"/>
11+
<component typeCode="COMP" contextConductionInd="true">
12+
<CompoundStatement classCode="CLUSTER" moodCode="EVN">
13+
<id root="random-unmapped-id"/>
14+
<code code="2551971000000110" codeSystem="2.16.840.1.113883.2.1.3.2.4.15" displayName="Serum oestradiol level">
15+
</code>
16+
<statusCode code="COMPLETE"/>
17+
<effectiveTime>
18+
<center value="20201215151704"/>
19+
</effectiveTime>
20+
<availabilityTime value="20201215151704"/>
21+
<component typeCode="COMP" contextConductionInd="true">
22+
<ObservationStatement classCode="OBS" moodCode="EVN">
23+
<id root="Mapped-From-Observation/TestResult-WithRelatedMember-WhichIsntAFilingComment"/>
24+
<code code="2551971000000110" codeSystem="2.16.840.1.113883.2.1.3.2.4.15" displayName="Serum oestradiol level">
25+
</code>
26+
<statusCode code="COMPLETE"/>
27+
<effectiveTime>
28+
<center value="20201215151704"/>
29+
</effectiveTime>
30+
<availabilityTime value="20201215151704"/>
31+
<value xsi:type="PQ" value="8.800" unit="1">
32+
<translation value="8.800">
33+
<originalText>mmol/L</originalText>
34+
</translation>
35+
</value>
36+
</ObservationStatement>
37+
</component>
38+
<component typeCode="COMP" contextConductionInd="true">
39+
<NarrativeStatement classCode="OBS" moodCode="EVN">
40+
<id root="random-unmapped-id"/>
41+
<text mediaType="text/x-h7uk-pmip">CommentType:AGGREGATE COMMENT SET
42+
CommentDate:20201215151704
43+
44+
Notes provided alongside test result</text>
45+
<statusCode code="COMPLETE"/>
46+
<availabilityTime value="20201215151704"/>
47+
</NarrativeStatement>
48+
</component>
49+
</CompoundStatement>
50+
</component>
51+
</CompoundStatement>
52+
</component>

0 commit comments

Comments
 (0)