Skip to content

Commit 87a467f

Browse files
GP2GP Sending Adaptor not preserving legacy read codes on export for blood pressures (#1151)
* * Add tests to handle non snomed code translations * Add functionality when mapping blood pressures to preserve non snomed codes * * Update blood pressure mapper tests to reflect new functionality
1 parent 23918de commit 87a467f

File tree

3 files changed

+79
-6
lines changed

3 files changed

+79
-6
lines changed

service/src/main/java/uk/nhs/adaptors/gp2gp/ehr/mapper/CodeableConceptCdMapper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ public String mapCodeableConceptToCdForBloodPressure(CodeableConcept codeableCon
162162

163163
code.ifPresent(builder::mainCode);
164164
displayText.ifPresent(builder::mainDisplayName);
165+
builder.translations(getNonSnomedCodeCodings(codeableConcept));
165166
}
166167

167168
return TemplateUtils.fillTemplate(CODEABLE_CONCEPT_CD_TEMPLATE, builder.build());

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

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,44 @@ <originalText>Prothrombin time (observed)</originalText>
324324
assertThat(outputMessage).isEqualToIgnoringWhitespace(expectedOutput);
325325
}
326326

327+
@Test
328+
void When_WithSnomedCodingAndLegacyCodings_Expect_SnomedCdXmlWithTranslations() {
329+
var inputJson = """
330+
{
331+
"resourceType": "Observation",
332+
"code": {
333+
"coding": [
334+
{
335+
"system": "http://snomed.info/sct",
336+
"display": "Prothrombin time",
337+
"code": "852471000000107"
338+
},
339+
{
340+
"system": "http://read.info/readv2",
341+
"code": "42Q5.00",
342+
"display": "Observed Prothrombin time"
343+
},
344+
{
345+
"system": "http://read.info/ctv3",
346+
"code": "123456",
347+
"display": "Prothrombin time (observed)"
348+
}
349+
]
350+
}
351+
}""";
352+
var expectedOutput = """
353+
<code code="852471000000107" codeSystem="2.16.840.1.113883.2.1.3.2.4.15" displayName="Prothrombin time">
354+
<translation code="42Q5.00" codeSystem="2.16.840.1.113883.2.1.6.2" displayName="Observed Prothrombin time" />
355+
<translation code="123456" codeSystem="2.16.840.1.113883.2.1.3.2.4.14" displayName="Prothrombin time (observed)" />
356+
<originalText>Prothrombin time</originalText>
357+
</code>""";
358+
var codeableConcept = fhirParseService.parseResource(inputJson, Observation.class).getCode();
359+
360+
var outputMessage = codeableConceptCdMapper.mapCodeableConceptToCdForBloodPressure(codeableConcept);
361+
362+
assertThat(outputMessage).isEqualToIgnoringWhitespace(expectedOutput);
363+
}
364+
327365
@Test
328366
void When_WithNonSnomedCodingWithText_Expect_NullFlavorUnkCDWithOriginalTextFromText() {
329367
var inputJson = """
@@ -451,6 +489,37 @@ <originalText>Prothrombin time (observed)</originalText>
451489

452490
assertThat(outputMessage).isEqualToIgnoringWhitespace(expectedOutput);
453491
}
492+
493+
@Test
494+
void When_WithoutSnomedCodingAndWithLegacyCodings_Expect_NullFlavorSnomedCdXmlWithoutTranslations() {
495+
var inputJson = """
496+
{
497+
"resourceType": "Observation",
498+
"code": {
499+
"coding": [
500+
{
501+
"system": "http://read.info/readv2",
502+
"code": "42Q5.00",
503+
"display": "Observed Prothrombin time"
504+
},
505+
{
506+
"system": "http://read.info/ctv3",
507+
"code": "123456",
508+
"display": "Prothrombin time (observed)"
509+
}
510+
]
511+
}
512+
}""";
513+
var expectedOutput = """
514+
<code nullFlavor="UNK">
515+
<originalText>Observed Prothrombin time</originalText>
516+
</code>""";
517+
var codeableConcept = fhirParseService.parseResource(inputJson, Observation.class).getCode();
518+
519+
var outputMessage = codeableConceptCdMapper.mapCodeableConceptToCdForBloodPressure(codeableConcept);
520+
521+
assertThat(outputMessage).isEqualToIgnoringWhitespace(expectedOutput);
522+
}
454523
}
455524

456525
@Nested

service/src/test/resources/ehr/mapper/blood_pressure/blood-pressure-with-codeable-concepts.xml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
<CompoundStatement classCode="BATTERY" moodCode="EVN">
33
<id root="5E496953-065B-41F2-9577-BE8F2FBD0757"/>
44
<code code="852471000000107" codeSystem="2.16.840.1.113883.2.1.3.2.4.15" displayName="Prothrombin time">
5-
<originalText>Prothrombin time</originalText>
6-
</code>
5+
<translation code="42Q5.00" codeSystem="2.16.840.1.113883.2.1.6.2" displayName="Prothrombin time" />
6+
<originalText>Prothrombin time</originalText>
7+
</code>
78
<statusCode code="COMPLETE"/>
89
<effectiveTime>
910
<center value="20121008104149"/>
@@ -13,8 +14,9 @@
1314
<ObservationStatement classCode="OBS" moodCode="EVN">
1415
<id root="5E496953-065B-41F2-9577-BE8F2FBD0757"/>
1516
<code code="72313002" codeSystem="2.16.840.1.113883.2.1.3.2.4.15" displayName="Systolic arterial pressure">
16-
<originalText>Systolic arterial pressure</originalText>
17-
</code>
17+
<translation code="2469" codeSystem="2.16.840.1.113883.2.1.6.3" displayName="Systolic arterial pressure" />
18+
<originalText>Systolic arterial pressure</originalText>
19+
</code>
1820
<statusCode code="COMPLETE"/>
1921
<effectiveTime>
2022
<center value="20121008104149"/>
@@ -34,8 +36,9 @@
3436
<ObservationStatement classCode="OBS" moodCode="EVN">
3537
<id root="5E496953-065B-41F2-9577-BE8F2FBD0757"/>
3638
<code code="1091811000000102" codeSystem="2.16.840.1.113883.2.1.3.2.4.15" displayName="Diastolic arterial pressure">
37-
<originalText>Diastolic arterial pressure</originalText>
38-
</code>
39+
<translation code="246A" codeSystem="2.16.840.1.113883.2.1.6.3" displayName="Diastolic arterial pressure" />
40+
<originalText>Diastolic arterial pressure</originalText>
41+
</code>
3942
<statusCode code="COMPLETE"/>
4043
<effectiveTime>
4144
<center value="20121008104149"/>

0 commit comments

Comments
 (0)