Skip to content

Commit 29a7072

Browse files
* Add a test case when mapping to nullFlavor codeable concept for allergy when a snomed code is not present.
1 parent 47f0576 commit 29a7072

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,46 @@ void When_MappingCodeableConceptWithNonSnomedCodeSystems_Expect_ManifestedXmlCon
127127
assertThat(outputMessageXml).isEqualToIgnoringWhitespace(expectedOutputXml);
128128
}
129129

130+
131+
@Test
132+
void When_mapToNullFlavorCodeableConceptForAllergyWithoutSnomedCode_ExpectOriginalTextIsNotPresent() {
133+
var inputJson = """
134+
{
135+
"resourceType": "AllergyIntolerance",
136+
"id": "0C1232CF-D34B-4C16-A5F4-0F6461C51A41",
137+
"meta": {
138+
"profile": [
139+
"https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-AllergyIntolerance-1"
140+
]
141+
},
142+
"identifier": [
143+
{
144+
"system": "https://EMISWeb/A82038",
145+
"value": "55D2363D57A248F49A745B2E03F5E93D0C1232CFD34B4C16A5F40F6461C51A41"
146+
}
147+
],
148+
"code": {
149+
"coding": [
150+
{
151+
"system": "http://read.info/readv2",
152+
"code": "TJ00800",
153+
"display": "Adverse reaction to pivampicillin rt"
154+
}
155+
],
156+
"text": "Adverse reaction to pivampicillin"
157+
}
158+
}""";
159+
var expectedOutputXML = """
160+
<code nullFlavor="UNK">
161+
</code>
162+
""";
163+
var codeableConcept = fhirParseService.parseResource(inputJson, AllergyIntolerance.class).getCode();
164+
165+
var outputXml = codeableConceptCdMapper.mapToNullFlavorCodeableConceptForAllergy(codeableConcept, AllergyIntolerance.AllergyIntoleranceClinicalStatus.ACTIVE);
166+
167+
assertThat(outputXml).isEqualToIgnoringWhitespace(expectedOutputXML);
168+
}
169+
130170
@ParameterizedTest
131171
@MethodSource("getTestArgumentsActualProblem")
132172
public void When_MappingStubbedCodeableConceptForActualProblemHeader_Expect_HL7CdObjectXml(String inputJson, String outputXml)
@@ -271,4 +311,5 @@ public void When_MapToCdForMedication_With_RelatedProblemAndTitle_Expect_Concept
271311

272312
assertThat(outputString).isEqualToIgnoringWhitespace(expectedOutput);
273313
}
314+
274315
}

0 commit comments

Comments
 (0)