Skip to content

Commit d96112e

Browse files
committed
Started adding tests for current behaviour for blood pressure codeable concept mapping
1 parent bd5c47c commit d96112e

File tree

1 file changed

+113
-1
lines changed

1 file changed

+113
-1
lines changed

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

Lines changed: 113 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ void When_MappingStubbedCodeableConceptAsActiveAllergy_Expect_HL7CdObjectXml(Str
233233
}
234234

235235
@Test
236-
void When_MappingStubbedCodableConceptWithoutCoding_Expect_NullFlavorCdXmlWithoutOriginalText() {
236+
void When_MappingStubbedCodeableConceptWithoutCoding_Expect_NullFlavorCdXmlWithoutOriginalText() {
237237
var inputJson = """
238238
{
239239
"resourceType": "Observation"
@@ -248,6 +248,118 @@ void When_MappingStubbedCodableConceptWithoutCoding_Expect_NullFlavorCdXmlWithou
248248
assertThat(outputMessage).isEqualToIgnoringWhitespace(expectedOutput);
249249
}
250250

251+
@Test
252+
void When_MappingStubbedCodeableConceptWithNonSnomedCodingWithDisplay_Expect_NullFlavorCdXmlWithOriginalText() {
253+
var inputJson = """
254+
{
255+
"resourceType": "Observation",
256+
"code": {
257+
"coding": [
258+
{
259+
"display": "Prothrombin time"
260+
}
261+
]
262+
}
263+
}""";
264+
var expectedOutput = """
265+
<code nullFlavor="UNK">
266+
<originalText>Prothrombin time</originalText>
267+
</code>""";
268+
var codeableConcept = fhirParseService.parseResource(inputJson, Observation.class).getCode();
269+
270+
var outputMessage = codeableConceptCdMapper.mapCodeableConceptToCdForBloodPressure(codeableConcept);
271+
272+
assertThat(outputMessage).isEqualToIgnoringWhitespace(expectedOutput);
273+
}
274+
275+
@Test
276+
void When_MappingStubbedCodeableConceptWithSnomedCodingWithDisplay_Expect_SnomedCdXmlWithOriginalText() {
277+
var inputJson = """
278+
{
279+
"resourceType": "Observation",
280+
"code": {
281+
"coding": [
282+
{
283+
"system": "http://snomed.info/sct",
284+
"display": "Prothrombin time",
285+
"code": "852471000000107"
286+
}
287+
]
288+
}
289+
}""";
290+
var expectedOutput = """
291+
<code code="852471000000107" codeSystem="2.16.840.1.113883.2.1.3.2.4.15" displayName="Prothrombin time">
292+
<originalText>Prothrombin time</originalText>
293+
</code>""";
294+
var codeableConcept = fhirParseService.parseResource(inputJson, Observation.class).getCode();
295+
296+
var outputMessage = codeableConceptCdMapper.mapCodeableConceptToCdForBloodPressure(codeableConcept);
297+
298+
assertThat(outputMessage).isEqualToIgnoringWhitespace(expectedOutput);
299+
}
300+
301+
@Test
302+
void When_MappingStubbedCodeableConceptWithSnomedCodingWithoutCode_Expect_SnomedCdXmlWithOriginalTextFromText() {
303+
var inputJson = """
304+
{
305+
"resourceType": "Observation",
306+
"code": {
307+
"coding": [
308+
{
309+
"system": "http://snomed.info/sct",
310+
"display": "Prothrombin time",
311+
"code": "852471000000107"
312+
}
313+
],
314+
"text": "Prothrombin time observed"
315+
}
316+
}""";
317+
var expectedOutput = """
318+
<code code="852471000000107" codeSystem="2.16.840.1.113883.2.1.3.2.4.15" displayName="Prothrombin time">
319+
<originalText>Prothrombin time observed</originalText>
320+
</code>""";
321+
var codeableConcept = fhirParseService.parseResource(inputJson, Observation.class).getCode();
322+
323+
var outputMessage = codeableConceptCdMapper.mapCodeableConceptToCdForBloodPressure(codeableConcept);
324+
325+
assertThat(outputMessage).isEqualToIgnoringWhitespace(expectedOutput);
326+
}
327+
328+
@Test
329+
void When_MappingStubbedCodeableConceptWithSnomedCodingWithPartialExtensionWithoutCode_Expect_SnomedCdXmlWithOriginalTextFromExtension() {
330+
var inputJson = """
331+
{
332+
"resourceType": "Observation",
333+
"code": {
334+
"coding": [
335+
{
336+
"system": "http://snomed.info/sct",
337+
"code": "852471000000107",
338+
"extension": [
339+
{
340+
"url": "https://fhir.nhs.uk/STU3/StructureDefinition/Extension-coding-sctdescid",
341+
"extension": [
342+
{
343+
"url": "descriptionDisplay",
344+
"valueId": "Prothrombin time (observed)"
345+
}
346+
]
347+
}
348+
]
349+
}
350+
]
351+
}
352+
}""";
353+
var expectedOutput = """
354+
<code code="852471000000107" codeSystem="2.16.840.1.113883.2.1.3.2.4.15" displayName="Prothrombin time">
355+
<originalText>Prothrombin time (observed)</originalText>
356+
</code>""";
357+
var codeableConcept = fhirParseService.parseResource(inputJson, Observation.class).getCode();
358+
359+
var outputMessage = codeableConceptCdMapper.mapCodeableConceptToCdForBloodPressure(codeableConcept);
360+
361+
assertThat(outputMessage).isEqualToIgnoringWhitespace(expectedOutput);
362+
}
251363
// @ParameterizedTest
252364
// @MethodSource("getTestArgumentsBloodPressure")
253365
// void When_MappingStubbedCodeableConceptForBloodPressure_Expect_HL7CdObjectXml(String inputJson, String outputXml) {

0 commit comments

Comments
 (0)