Skip to content

Commit 9328450

Browse files
committed
Merge branch 'main' into NIAD-3154
2 parents 541db64 + 27e3f34 commit 9328450

File tree

6 files changed

+649
-79
lines changed

6 files changed

+649
-79
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
### Fixed
10+
11+
* When mapping to `<code nullFlavor="UNK">` XML elements from an existing `CodeableConcept` the element will now contain
12+
the original text value from the DisplayExtension, if a separate text field is not provided.
13+
In the case that neither of these are present, the existing behavior of using the `code.display` element is used.
14+
915
### Added
1016

1117
* GP2GP Adaptor now populates the PlanStatement / confidentialityCode field when the ProcedureRequest.meta.security field contains NOPAT

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

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ public String mapCodeableConceptToCdForBloodPressure(CodeableConcept codeableCon
161161

162162
code.ifPresent(builder::mainCode);
163163
displayText.ifPresent(builder::mainDisplayName);
164+
builder.translations(getNonSnomedCodeCodings(codeableConcept));
164165
}
165166

166167
return TemplateUtils.fillTemplate(CODEABLE_CONCEPT_CD_TEMPLATE, builder.build());
@@ -324,23 +325,20 @@ private List<Coding> getNonSnomedCodeCodings(CodeableConcept codeableConcept) {
324325
}
325326

326327
private Optional<String> findOriginalText(CodeableConcept codeableConcept, Optional<Coding> coding) {
328+
329+
if (codeableConcept.hasText()) {
330+
return Optional.ofNullable(codeableConcept.getText());
331+
}
332+
327333
if (coding.isPresent()) {
328-
if (codeableConcept.hasText()) {
329-
return Optional.ofNullable(codeableConcept.getText());
330-
} else {
331-
if (coding.get().hasDisplay()) {
332-
return getCodingDisplayName(coding.get());
333-
} else {
334-
var extension = retrieveDescriptionExtension(coding.get());
335-
return extension.stream()
336-
.filter(displayExtension -> DESCRIPTION_DISPLAY.equals(displayExtension.getUrl()))
337-
.map(extension1 -> extension1.getValue().toString())
338-
.findFirst();
339-
}
334+
if (coding.get().hasDisplay()) {
335+
return getCodingDisplayName(coding.get());
340336
}
341-
} else {
342-
return CodeableConceptMappingUtils.extractTextOrCoding(codeableConcept);
337+
338+
return getDisplayTextFromDescriptionExtension(coding.get());
343339
}
340+
341+
return CodeableConceptMappingUtils.extractTextOrCoding(codeableConcept);
344342
}
345343

346344
private Optional<String> findOriginalTextForAllergy(
@@ -353,13 +351,13 @@ private Optional<String> findOriginalTextForAllergy(
353351
}
354352

355353
if (ACTIVE_CLINICAL_STATUS.equals(allergyIntoleranceClinicalStatus.toCode())) {
356-
return getOriginalTextForActiveAllergy(coding.get());
354+
return getDisplayTextFromDescriptionExtension(coding.get());
357355
}
358356

359357
return CodeableConceptMappingUtils.extractTextOrCoding(codeableConcept);
360358
}
361359

362-
private Optional<String> getOriginalTextForActiveAllergy(Coding coding) {
360+
private Optional<String> getDisplayTextFromDescriptionExtension(Coding coding) {
363361
return retrieveDescriptionExtension(coding)
364362
.flatMap(value -> value
365363
.getExtension().stream()

0 commit comments

Comments
 (0)