Skip to content

Commit 3effdbc

Browse files
Suppress pertinentInformation element in output XML when no related data present in input JSON (#1258)
* Start work on suppressing pertinentInformation block in output XML when no related data present in input JSON * Fix test name for When_NoPertinentInformation_Expect_ContentSuppressed * Fix line length for test variable * Adjust mustache template for observation statement so to make the fields of value, interpretation, comment and referenceRange optional. * Edit name of xml file, dropping the word 'block'.
1 parent 9005bbe commit 3effdbc

8 files changed

+51
-118
lines changed

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,23 @@
1010
{{#confidentialityCode}}
1111
{{{confidentialityCode}}}
1212
{{/confidentialityCode}}
13-
{{{value}}}
14-
{{{interpretation}}}
13+
{{#value}}
14+
{{{value}}}
15+
{{/value}}
16+
{{#interpretation}}
17+
{{{interpretation}}}
18+
{{/interpretation}}
19+
{{#comment}}
1520
<pertinentInformation typeCode="PERT">
1621
<sequenceNumber value="+1" />
1722
<pertinentAnnotation classCode="OBS" moodCode="EVN">
1823
<text>{{comment}}</text>
1924
</pertinentAnnotation>
2025
</pertinentInformation>
21-
{{{referenceRange}}}
26+
{{/comment}}
27+
{{#referenceRange}}
28+
{{{referenceRange}}}
29+
{{/referenceRange}}
2230
{{#participant}}
2331
{{{.}}}
2432
{{/participant}}

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ public class ObservationStatementMapperTest {
4545
private static final String INPUT_JSON_WITH_EFFECTIVE_DATE_TIME = TEST_FILE_DIRECTORY
4646
+ "example-observation-resource-1.json";
4747
private static final String INPUT_JSON_WITH_NOPAT = TEST_FILE_DIRECTORY + "example-observation-resource-with-nopat.json";
48+
private static final String INPUT_JSON_WITH_NO_PERTINENT_INFORMATION_DATA = TEST_FILE_DIRECTORY
49+
+ "example-observation-resource-with-no-pertinent-information-data.json";
4850
private static final String INPUT_JSON_WITH_NULL_EFFECTIVE_DATE_TIME = TEST_FILE_DIRECTORY
4951
+ "example-observation-resource-2.json";
5052
private static final String INPUT_JSON_WITH_EFFECTIVE_PERIOD = TEST_FILE_DIRECTORY
@@ -131,6 +133,8 @@ public class ObservationStatementMapperTest {
131133
+ "expected-output-observation-statement-3.xml";
132134
private static final String OUTPUT_XML_WITH_NOPAT = TEST_FILE_DIRECTORY
133135
+ "expected-observation-statement-with-confidentiality-code.xml";
136+
private static final String OUTPUT_XML_WITH_NO_PERTINENT_INFORMATION = TEST_FILE_DIRECTORY
137+
+ "expected-observation-statement-without-pertinent-information.xml";
134138
private static final String OUTPUT_XML_USES_EFFECTIVE_PERIOD = TEST_FILE_DIRECTORY
135139
+ "expected-output-observation-statement-4.xml";
136140
private static final String OUTPUT_XML_WITH_STRING_VALUE = TEST_FILE_DIRECTORY
@@ -225,6 +229,17 @@ public void tearDown() {
225229
messageContext.resetMessageContext();
226230
}
227231

232+
@Test
233+
void When_NoPertinentInformation_Expect_ContentSuppressed() {
234+
expectedOutputMessage = ResourceTestFileUtils.getFileContent(OUTPUT_XML_WITH_NO_PERTINENT_INFORMATION);
235+
var jsonInput = ResourceTestFileUtils.getFileContent(INPUT_JSON_WITH_NO_PERTINENT_INFORMATION_DATA);
236+
Observation parsedObservation = new FhirParseService().parseResource(jsonInput, Observation.class);
237+
238+
String outputMessage = observationStatementMapper.mapObservationToObservationStatement(parsedObservation, true);
239+
240+
assertThat(outputMessage).isEqualTo(expectedOutputMessage);
241+
}
242+
228243
@Test
229244
void When_MappingParsedObservationWithNopat_Expect_ObservationStatementWithConfidentialityCode() {
230245
expectedOutputMessage = ResourceTestFileUtils.getFileContent(OUTPUT_XML_WITH_NOPAT);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"resourceType": "Observation",
3+
"id": "3377543D-5B1B-4C4F-BFF6-9F7BC3A1C3B8",
4+
"meta": {
5+
"profile": [
6+
"https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-Immunization-1"
7+
]
8+
},
9+
"code": {
10+
"text": "test"
11+
},
12+
"effectiveDateTime": "2010-07-14T16:32:51.42+01:00",
13+
"issued": "2010-01-13T15:29:50.3+00:00"
14+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<component typeCode="COMP" contextConductionInd="true">
2+
<ObservationStatement classCode="OBS" moodCode="EVN">
3+
<id root="394559384658936" />
4+
<code nullFlavor="UNK"><originalText>Mocked code</originalText></code>
5+
<statusCode code="COMPLETE" />
6+
<effectiveTime>
7+
<center value="20100714163251"/>
8+
</effectiveTime>
9+
<availabilityTime value="20100714163251"/>
10+
</ObservationStatement>
11+
</component>

service/src/test/resources/ehr/mapper/observation/expected-output-observation-statement-3.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
<center value="20100714163251"/>
88
</effectiveTime>
99
<availabilityTime value="20100714163251"/>
10-
11-
1210
<pertinentInformation typeCode="PERT">
1311
<sequenceNumber value="+1" />
1412
<pertinentAnnotation classCode="OBS" moodCode="EVN">
@@ -27,6 +25,5 @@ The line below contains special characters...
2725
¬`1234567890!&quot;£$%^&amp;*()_+=-{}][~@#&apos;:;&lt;&gt;?,./|\</text>
2826
</pertinentAnnotation>
2927
</pertinentInformation>
30-
3128
</ObservationStatement>
3229
</component>

service/src/test/resources/ehr/request/fhir/output/expected-ehr-extract-response-from-json-with-nopat.xml

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -398,14 +398,6 @@
398398
</effectiveTime>
399399
<availabilityTime value="20100123134800"/>
400400
<confidentialityCode code="NOPAT" codeSystem="2.16.840.1.113883.4.642.3.47" displayName="no disclosure to patient, family or caregivers without attending provider's authorization" />
401-
402-
<pertinentInformation typeCode="PERT">
403-
<sequenceNumber value="+1" />
404-
<pertinentAnnotation classCode="OBS" moodCode="EVN">
405-
<text></text>
406-
</pertinentAnnotation>
407-
</pertinentInformation>
408-
409401
<Participant typeCode="PRF" contextControlCode="OP">
410402
<agentRef classCode="AGNT">
411403
<id root="test-id-3"/>
@@ -457,15 +449,6 @@
457449
<center value="20100123134800"/>
458450
</effectiveTime>
459451
<availabilityTime value="20100123134800"/>
460-
461-
462-
<pertinentInformation typeCode="PERT">
463-
<sequenceNumber value="+1" />
464-
<pertinentAnnotation classCode="OBS" moodCode="EVN">
465-
<text></text>
466-
</pertinentAnnotation>
467-
</pertinentInformation>
468-
469452
<Participant typeCode="PRF" contextControlCode="OP">
470453
<agentRef classCode="AGNT">
471454
<id root="test-id-3"/>
@@ -7635,14 +7618,6 @@
76357618
</effectiveTime>
76367619
<availabilityTime value="20091102"/>
76377620
<value xsi:type="PQ" value="120" unit="1"><translation value="120"><originalText>mmHg</originalText></translation></value>
7638-
7639-
<pertinentInformation typeCode="PERT">
7640-
<sequenceNumber value="+1" />
7641-
<pertinentAnnotation classCode="OBS" moodCode="EVN">
7642-
<text></text>
7643-
</pertinentAnnotation>
7644-
</pertinentInformation>
7645-
76467621
<Participant typeCode="PRF" contextControlCode="OP">
76477622
<agentRef classCode="AGNT">
76487623
<id root="test-id-3"/>
@@ -7682,14 +7657,6 @@
76827657
</effectiveTime>
76837658
<availabilityTime value="20091102"/>
76847659
<value xsi:type="PQ" value="90" unit="1"><translation value="90"><originalText>mmHg</originalText></translation></value>
7685-
7686-
<pertinentInformation typeCode="PERT">
7687-
<sequenceNumber value="+1" />
7688-
<pertinentAnnotation classCode="OBS" moodCode="EVN">
7689-
<text></text>
7690-
</pertinentAnnotation>
7691-
</pertinentInformation>
7692-
76937660
<Participant typeCode="PRF" contextControlCode="OP">
76947661
<agentRef classCode="AGNT">
76957662
<id root="test-id-3"/>
@@ -7916,15 +7883,6 @@
79167883
<center value="20100609160800"/>
79177884
</effectiveTime>
79187885
<availabilityTime value="20100609160800"/>
7919-
7920-
7921-
<pertinentInformation typeCode="PERT">
7922-
<sequenceNumber value="+1" />
7923-
<pertinentAnnotation classCode="OBS" moodCode="EVN">
7924-
<text></text>
7925-
</pertinentAnnotation>
7926-
</pertinentInformation>
7927-
79287886
<Participant typeCode="PRF" contextControlCode="OP">
79297887
<agentRef classCode="AGNT">
79307888
<id root="test-id-3"/>
@@ -8127,15 +8085,6 @@
81278085
<center value="20201026"/>
81288086
</effectiveTime>
81298087
<availabilityTime value="20201026"/>
8130-
8131-
8132-
<pertinentInformation typeCode="PERT">
8133-
<sequenceNumber value="+1" />
8134-
<pertinentAnnotation classCode="OBS" moodCode="EVN">
8135-
<text></text>
8136-
</pertinentAnnotation>
8137-
</pertinentInformation>
8138-
81398088
<Participant typeCode="PRF" contextControlCode="OP">
81408089
<agentRef classCode="AGNT">
81418090
<id root="test-id-3"/>

service/src/test/resources/ehr/request/fhir/output/expected-ehr-extract-response-from-json.xml

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -397,15 +397,6 @@
397397
<center value="20100123134800"/>
398398
</effectiveTime>
399399
<availabilityTime value="20100123134800"/>
400-
401-
402-
<pertinentInformation typeCode="PERT">
403-
<sequenceNumber value="+1" />
404-
<pertinentAnnotation classCode="OBS" moodCode="EVN">
405-
<text></text>
406-
</pertinentAnnotation>
407-
</pertinentInformation>
408-
409400
<Participant typeCode="PRF" contextControlCode="OP">
410401
<agentRef classCode="AGNT">
411402
<id root="test-id-3"/>
@@ -457,15 +448,6 @@
457448
<center value="20100123134800"/>
458449
</effectiveTime>
459450
<availabilityTime value="20100123134800"/>
460-
461-
462-
<pertinentInformation typeCode="PERT">
463-
<sequenceNumber value="+1" />
464-
<pertinentAnnotation classCode="OBS" moodCode="EVN">
465-
<text></text>
466-
</pertinentAnnotation>
467-
</pertinentInformation>
468-
469451
<Participant typeCode="PRF" contextControlCode="OP">
470452
<agentRef classCode="AGNT">
471453
<id root="test-id-3"/>
@@ -7635,14 +7617,6 @@
76357617
</effectiveTime>
76367618
<availabilityTime value="20091102"/>
76377619
<value xsi:type="PQ" value="120" unit="1"><translation value="120"><originalText>mmHg</originalText></translation></value>
7638-
7639-
<pertinentInformation typeCode="PERT">
7640-
<sequenceNumber value="+1" />
7641-
<pertinentAnnotation classCode="OBS" moodCode="EVN">
7642-
<text></text>
7643-
</pertinentAnnotation>
7644-
</pertinentInformation>
7645-
76467620
<Participant typeCode="PRF" contextControlCode="OP">
76477621
<agentRef classCode="AGNT">
76487622
<id root="test-id-3"/>
@@ -7682,14 +7656,6 @@
76827656
</effectiveTime>
76837657
<availabilityTime value="20091102"/>
76847658
<value xsi:type="PQ" value="90" unit="1"><translation value="90"><originalText>mmHg</originalText></translation></value>
7685-
7686-
<pertinentInformation typeCode="PERT">
7687-
<sequenceNumber value="+1" />
7688-
<pertinentAnnotation classCode="OBS" moodCode="EVN">
7689-
<text></text>
7690-
</pertinentAnnotation>
7691-
</pertinentInformation>
7692-
76937659
<Participant typeCode="PRF" contextControlCode="OP">
76947660
<agentRef classCode="AGNT">
76957661
<id root="test-id-3"/>
@@ -7916,15 +7882,6 @@
79167882
<center value="20100609160800"/>
79177883
</effectiveTime>
79187884
<availabilityTime value="20100609160800"/>
7919-
7920-
7921-
<pertinentInformation typeCode="PERT">
7922-
<sequenceNumber value="+1" />
7923-
<pertinentAnnotation classCode="OBS" moodCode="EVN">
7924-
<text></text>
7925-
</pertinentAnnotation>
7926-
</pertinentInformation>
7927-
79287885
<Participant typeCode="PRF" contextControlCode="OP">
79297886
<agentRef classCode="AGNT">
79307887
<id root="test-id-3"/>
@@ -8127,15 +8084,6 @@
81278084
<center value="20201026"/>
81288085
</effectiveTime>
81298086
<availabilityTime value="20201026"/>
8130-
8131-
8132-
<pertinentInformation typeCode="PERT">
8133-
<sequenceNumber value="+1" />
8134-
<pertinentAnnotation classCode="OBS" moodCode="EVN">
8135-
<text></text>
8136-
</pertinentAnnotation>
8137-
</pertinentInformation>
8138-
81398087
<Participant typeCode="PRF" contextControlCode="OP">
81408088
<agentRef classCode="AGNT">
81418089
<id root="test-id-3"/>

service/src/test/resources/ehr/request/fhir/output/expected-xml-with-standalone-observations.xml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -236,15 +236,6 @@
236236
<center nullFlavor="UNK"/>
237237
</effectiveTime>
238238
<availabilityTime nullFlavor="UNK"/>
239-
240-
241-
<pertinentInformation typeCode="PERT">
242-
<sequenceNumber value="+1"/>
243-
<pertinentAnnotation classCode="OBS" moodCode="EVN">
244-
<text></text>
245-
</pertinentAnnotation>
246-
</pertinentInformation>
247-
248239
<Participant typeCode="PRF" contextControlCode="OP">
249240
<agentRef classCode="AGNT">
250241
<id root="test-id-3"/>

0 commit comments

Comments
 (0)