Skip to content

Commit 6d77f0c

Browse files
Add unit tests for mapping allergy codeable concepts (#1135)
* Add unit tests for mapping allergy codeable concepts * Add unit tests for mapping allergy codeable concepts. * * Remove public modifier for new tests.
1 parent 496fa86 commit 6d77f0c

File tree

28 files changed

+607
-18
lines changed

28 files changed

+607
-18
lines changed

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

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ public class CodeableConceptCdMapperTest {
2424
private static final String TEST_FILE_DIRECTORY = "/ehr/mapper/codeableconcept/";
2525
private static final String TEST_FILE_DIRECTORY_NULL_FLAVOR = "/ehr/mapper/codeableconcept/nullFlavor/";
2626
private static final String TEST_FILE_DIRECTORY_ACTUAL_PROBLEM = "/ehr/mapper/codeableconcept/actualProblem/";
27-
private static final String TEST_FILE_DIRECTORY_ALLERGY_CLINICAL_STATUS = "/ehr/mapper/codeableconcept/allergyClinicalStatus/";
27+
private static final String TEST_FILE_DIRECTORY_ALLERGY_RESOLVED = "/ehr/mapper/codeableconcept/allergyResolved/";
28+
private static final String TEST_FILE_DIRECTORY_ALLERGY_ACTIVE = "/ehr/mapper/codeableconcept/allergyActive/";
2829
private static final String TEST_FILE_DIRECTORY_MEDICATION = "/ehr/mapper/codeableconcept/medication/";
2930

3031
private static final String TEST_FILE_TOPIC_RELATED_CONDITION = TEST_FILE_DIRECTORY
@@ -54,8 +55,12 @@ private static Stream<Arguments> getTestArgumentsActualProblem() {
5455
return TestArgumentsLoaderUtil.readTestCases(TEST_FILE_DIRECTORY_ACTUAL_PROBLEM);
5556
}
5657

57-
private static Stream<Arguments> getTestArgumentsAllergyClinicalStatus() {
58-
return TestArgumentsLoaderUtil.readTestCases(TEST_FILE_DIRECTORY_ALLERGY_CLINICAL_STATUS);
58+
private static Stream<Arguments> getTestArgumentsAllergyResolved() {
59+
return TestArgumentsLoaderUtil.readTestCases(TEST_FILE_DIRECTORY_ALLERGY_RESOLVED);
60+
}
61+
62+
private static Stream<Arguments> getTestArgumentsAllergyActive() {
63+
return TestArgumentsLoaderUtil.readTestCases(TEST_FILE_DIRECTORY_ALLERGY_ACTIVE);
5964
}
6065

6166
private static Stream<Arguments> getTestArgumentsMedication() {
@@ -151,15 +156,30 @@ public void When_MappingStubbedCodeableConceptAsNullFlavor_Expect_HL7CdObjectXml
151156
}
152157

153158
@ParameterizedTest
154-
@MethodSource("getTestArgumentsAllergyClinicalStatus")
155-
public void When_MappingStubbedCodeableConceptAsAllergy_Expect_HL7CdObjectXml(String inputJson, String outputXml)
156-
throws IOException {
159+
@MethodSource("getTestArgumentsAllergyResolved")
160+
void When_MappingStubbedCodeableConceptAsResolvedAllergy_Expect_HL7CdObjectXml(String inputJson, String outputXml) {
157161
var allergyCodeableConcept = ResourceTestFileUtils.getFileContent(inputJson);
158162
var expectedOutput = ResourceTestFileUtils.getFileContent(outputXml);
159163
var codeableConcept = fhirParseService.parseResource(allergyCodeableConcept, AllergyIntolerance.class).getCode();
160164

161165
var outputMessage = codeableConceptCdMapper.mapCodeableConceptToCdForAllergy(codeableConcept,
162166
AllergyIntolerance.AllergyIntoleranceClinicalStatus.RESOLVED);
167+
168+
assertThat(outputMessage)
169+
.describedAs(TestArgumentsLoaderUtil.FAIL_MESSAGE, inputJson, outputXml)
170+
.isEqualToIgnoringWhitespace(expectedOutput);
171+
}
172+
173+
@ParameterizedTest
174+
@MethodSource("getTestArgumentsAllergyActive")
175+
void When_MappingStubbedCodeableConceptAsActiveAllergy_Expect_HL7CdObjectXml(String inputJson, String outputXml) {
176+
var allergyCodeableConcept = ResourceTestFileUtils.getFileContent(inputJson);
177+
var expectedOutput = ResourceTestFileUtils.getFileContent(outputXml);
178+
var codeableConcept = fhirParseService.parseResource(allergyCodeableConcept, AllergyIntolerance.class).getCode();
179+
180+
var outputMessage = codeableConceptCdMapper.mapCodeableConceptToCdForAllergy(codeableConcept,
181+
AllergyIntolerance.AllergyIntoleranceClinicalStatus.ACTIVE);
182+
163183
assertThat(outputMessage)
164184
.describedAs(TestArgumentsLoaderUtil.FAIL_MESSAGE, inputJson, outputXml)
165185
.isEqualToIgnoringWhitespace(expectedOutput);

service/src/test/resources/ehr/mapper/codeableconcept/allergyClinicalStatus/codeable_concept_with_allergy.json renamed to service/src/test/resources/ehr/mapper/codeableconcept/allergyActive/allergy_with_both_description_extensions_no_text.json

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,25 @@
1919
],
2020
"code": {
2121
"coding": [
22-
{
23-
"system": "http://read.info/readv2",
24-
"code": "TJ00800",
25-
"display": "Adverse reaction to pivampicillin rt",
26-
"userSelected": true
27-
},
2822
{
2923
"extension": [
3024
{
3125
"url": "https://fhir.nhs.uk/STU3/StructureDefinition/Extension-coding-sctdescid",
3226
"extension": [
3327
{
3428
"url": "descriptionId",
35-
"valueId": "2164497013"
29+
"valueId": "442108015"
30+
},
31+
{
32+
"url": "descriptionDisplay",
33+
"valueString": "Chocolate allergy"
3634
}
3735
]
3836
}
3937
],
4038
"system": "http://snomed.info/sct",
41-
"code": "292971006",
42-
"display": "Pivampicillin adverse reaction pt"
39+
"code": "300912001",
40+
"display": "Allergy to chocolate"
4341
}
4442
]
4543
},
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<code code="442108015" codeSystem="2.16.840.1.113883.2.1.3.2.4.15" displayName="Allergy to chocolate">
2+
<originalText>Chocolate allergy</originalText>
3+
</code>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"resourceType": "AllergyIntolerance",
3+
"id": "0C1232CF-D34B-4C16-A5F4-0F6461C51A41",
4+
"meta": {
5+
"profile": [
6+
"https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-AllergyIntolerance-1"
7+
]
8+
},
9+
"identifier": [
10+
{
11+
"system": "https://EMISWeb/A82038",
12+
"value": "55D2363D57A248F49A745B2E03F5E93D0C1232CFD34B4C16A5F40F6461C51A41"
13+
}
14+
],
15+
"clinicalStatus": "resolved",
16+
"verificationStatus": "unconfirmed",
17+
"category": [
18+
"medication"
19+
],
20+
"code": {
21+
"coding": [
22+
{
23+
"extension": [
24+
{
25+
"url": "https://fhir.nhs.uk/STU3/StructureDefinition/Extension-coding-sctdescid",
26+
"extension": [
27+
{
28+
"url": "descriptionId",
29+
"valueId": "442108015"
30+
}
31+
]
32+
}
33+
],
34+
"system": "http://snomed.info/sct",
35+
"code": "300912001",
36+
"display": "Allergy to chocolate"
37+
}
38+
]
39+
},
40+
"patient": {
41+
"reference": "Patient/55D2363D-57A2-48F4-9A74-5B2E03F5E93D"
42+
},
43+
"assertedDate": "2019-01-28T13:43:36.107+00:00",
44+
"recorder": {
45+
"reference": "Practitioner/2DB481A3-306A-4133-9491-1558161D6A2B"
46+
},
47+
"note": [
48+
{
49+
"text": "allergy with no date recorded"
50+
}
51+
]
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<code code="442108015" codeSystem="2.16.840.1.113883.2.1.3.2.4.15" displayName="Allergy to chocolate">
2+
</code>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"resourceType": "AllergyIntolerance",
3+
"id": "0C1232CF-D34B-4C16-A5F4-0F6461C51A41",
4+
"meta": {
5+
"profile": [
6+
"https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-AllergyIntolerance-1"
7+
]
8+
},
9+
"identifier": [
10+
{
11+
"system": "https://EMISWeb/A82038",
12+
"value": "55D2363D57A248F49A745B2E03F5E93D0C1232CFD34B4C16A5F40F6461C51A41"
13+
}
14+
],
15+
"clinicalStatus": "resolved",
16+
"verificationStatus": "unconfirmed",
17+
"category": [
18+
"medication"
19+
],
20+
"code": {
21+
"coding": [
22+
{
23+
"extension": [
24+
{
25+
"url": "https://fhir.nhs.uk/STU3/StructureDefinition/Extension-coding-sctdescid",
26+
"extension": [
27+
{
28+
"url": "descriptionId",
29+
"valueId": "442108015"
30+
}
31+
]
32+
}
33+
],
34+
"system": "http://snomed.info/sct",
35+
"code": "300912001",
36+
"display": "Allergy to chocolate"
37+
}
38+
],
39+
"text": "Chocolate Allergy"
40+
},
41+
"patient": {
42+
"reference": "Patient/55D2363D-57A2-48F4-9A74-5B2E03F5E93D"
43+
},
44+
"assertedDate": "2019-01-28T13:43:36.107+00:00",
45+
"recorder": {
46+
"reference": "Practitioner/2DB481A3-306A-4133-9491-1558161D6A2B"
47+
},
48+
"note": [
49+
{
50+
"text": "allergy with no date recorded"
51+
}
52+
]
53+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<code code="442108015" codeSystem="2.16.840.1.113883.2.1.3.2.4.15" displayName="Allergy to chocolate">
2+
<originalText>Chocolate Allergy</originalText>
3+
</code>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"resourceType": "AllergyIntolerance",
3+
"id": "0C1232CF-D34B-4C16-A5F4-0F6461C51A41",
4+
"meta": {
5+
"profile": [
6+
"https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-AllergyIntolerance-1"
7+
]
8+
},
9+
"identifier": [
10+
{
11+
"system": "https://EMISWeb/A82038",
12+
"value": "55D2363D57A248F49A745B2E03F5E93D0C1232CFD34B4C16A5F40F6461C51A41"
13+
}
14+
],
15+
"clinicalStatus": "resolved",
16+
"verificationStatus": "unconfirmed",
17+
"category": [
18+
"medication"
19+
],
20+
"code": {
21+
"coding": [
22+
{
23+
"system": "http://snomed.info/sct",
24+
"code": "292971006",
25+
"display": "Pivampicillin adverse reaction pt"
26+
}
27+
]
28+
},
29+
"patient": {
30+
"reference": "Patient/55D2363D-57A2-48F4-9A74-5B2E03F5E93D"
31+
},
32+
"assertedDate": "2019-01-28T13:43:36.107+00:00",
33+
"recorder": {
34+
"reference": "Practitioner/2DB481A3-306A-4133-9491-1558161D6A2B"
35+
},
36+
"note": [
37+
{
38+
"text": "allergy with no date recorded"
39+
}
40+
]
41+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<code code="292971006" codeSystem="2.16.840.1.113883.2.1.3.2.4.15" displayName="Pivampicillin adverse reaction pt">
2+
</code>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"resourceType": "AllergyIntolerance",
3+
"id": "0C1232CF-D34B-4C16-A5F4-0F6461C51A41",
4+
"meta": {
5+
"profile": [
6+
"https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-AllergyIntolerance-1"
7+
]
8+
},
9+
"identifier": [
10+
{
11+
"system": "https://EMISWeb/A82038",
12+
"value": "55D2363D57A248F49A745B2E03F5E93D0C1232CFD34B4C16A5F40F6461C51A41"
13+
}
14+
],
15+
"clinicalStatus": "resolved",
16+
"verificationStatus": "unconfirmed",
17+
"category": [
18+
"medication"
19+
],
20+
"code": {
21+
"coding": [
22+
{
23+
"system": "http://snomed.info/sct",
24+
"code": "292971006",
25+
"display": "Pivampicillin adverse reaction pt"
26+
}
27+
],
28+
"text": "Pivampicillin adverse reaction"
29+
},
30+
"patient": {
31+
"reference": "Patient/55D2363D-57A2-48F4-9A74-5B2E03F5E93D"
32+
},
33+
"assertedDate": "2019-01-28T13:43:36.107+00:00",
34+
"recorder": {
35+
"reference": "Practitioner/2DB481A3-306A-4133-9491-1558161D6A2B"
36+
},
37+
"note": [
38+
{
39+
"text": "allergy with no date recorded"
40+
}
41+
]
42+
}

0 commit comments

Comments
 (0)