Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NIAD-2853: Fixed issue with coding text being set from incorrect place when mapping allergy intolerances #324

Merged
merged 12 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

* Fixed issue with coding text being set from incorrect place when mapping allergy intolerances.

### Added

* Documented database requirements in [OPERATING.md](/OPERATING.md#database-requirements)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30538,27 +30538,17 @@
"code": {
"coding": [
{
"extension": [
{
"url": "https://fhir.nhs.uk/STU3/StructureDefinition/Extension-coding-sctdescid",
"extension": [
{
"url": "descriptionId",
"valueId": "250208012"
},
{
"url": "descriptionDisplay",
"valueString": "Civil state unknown"
}
]
}
],
"system": "http://snomed.info/sct",
"code": "160504008",
"display": "Marital state unknown"
"code": "41891011000001106",
"display": "Azelaic acid 20% cream"
},
{
"system": "2.16.840.1.113883.2.1.6.4",
"code": "00254001",
"display": "Azelaic acid 20% cream"
}
],
"text": "Adverse reaction to Mebeverine Hydrochloride"
"text": "Azelaic acid 20% cream"
},
"patient": {
"reference": "Patient/e2cf4cc1-08da-4971-845f-35b8447cabdd"
Expand All @@ -30573,7 +30563,10 @@
},
"note": [
{
"text": "Status: Active"
"text": "Skin Allergy"
},
{
"text": "Allergy Code: Allergy to drug"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18051,34 +18051,27 @@
</effectiveTime>
<availabilityTime value="20100323" />
<component typeCode="COMP" contextConductionInd="true">
<ObservationStatement classCode="OBS" moodCode="ENV">
<id root="BBB69294-9C3E-43CD-8A91-D4767E7CE4C8"/>
<code code="1020821000006116" codeSystem="2.16.840.1.113883.2.1.3.2.4.15" displayName="Adverse reaction to Mebeverine Hydrochloride">
<originalText>Adverse reaction to Mebeverine Hydrochloride</originalText>
<ObservationStatement classCode="OBS" moodCode="EVN">
<id root="F9768902-2D68-45F5-8B42-D01373CF8BD7"/>
<code code="14L.." codeSystem="2.16.840.1.113883.2.1.3.2.4.14" displayName="H/O: drug allergy">
<originalText>H/O: drug allergy</originalText>
<translation code="416098002" codeSystem="2.16.840.1.113883.2.1.3.2.4.15" displayName="Allergy to drug"/>
<translation code="14L..00" codeSystem="2.16.840.1.113883.2.1.6.2" displayName="H/O: drug allergy"/>
</code>
<value type="CD" code="250208012" codeSystem="2.16.840.1.113883.2.1.3.2.4.15" displayName="Civil state unknown">
</value>
<statusCode code="COMPLETE"/>
<effectiveTime>
<center value="20100323"/>
<low value="20230918"/>
</effectiveTime>
<availabilityTime value="20100323" />
<availabilityTime value="20230918"/>
<value code="00254001" codeSystem="2.16.840.1.113883.2.1.6.4" displayName="Azelaic acid 20% cream" xsi:type="CD">
<translation code="41891011000001106" codeSystem="2.16.840.1.113883.2.1.3.2.4.15" displayName="Azelaic acid 20% cream"/>
</value>
<pertinentInformation typeCode="PERT">
<sequenceNumber value="+1"/>
<pertinentAnnotation classCode="OBS" moodCode="EVN">
<text>Status: Active</text>
<text>Skin Allergy</text>
</pertinentAnnotation>
</pertinentInformation>
<Participant typeCode="AUT" contextControlCode="OP">
<agentRef classCode="AGNT">
<id root="2D70F602-6BB1-47E0-B2EC-39912A59787D"/>
</agentRef>
</Participant>
<Participant typeCode="PRF" contextControlCode="OP">
<agentRef classCode="AGNT">
<id root="2D70F602-6BB1-47E0-B2EC-39912A59787D"/>
</agentRef>
</Participant>
</ObservationStatement>
</component>
</CompoundStatement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,13 @@ private DateTimeType getAssertedDateElement(TS availabilityTime, RCMRMT030101UK0
private void buildAllergyIntoleranceText(RCMRMT030101UK04ObservationStatement observationStatement,
MartinWheelerMT marked this conversation as resolved.
Show resolved Hide resolved
AllergyIntolerance allergyIntolerance) {
if (allergyIntolerance.getCode() != null) {
if (observationStatement.hasValue() && observationStatement.getValue() instanceof CD value) {
var valueDisplayName = value.getDisplayName();
if (!StringUtils.isEmpty(valueDisplayName)) {
allergyIntolerance.getCode().setText(valueDisplayName);
return;
}
}
var originalTextFromCode = observationStatement.getCode().getOriginalText();
if (!StringUtils.isEmpty(originalTextFromCode)) {
allergyIntolerance.getCode().setText(originalTextFromCode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public class AllergyIntoleranceMapperTest {
private static final int THREE = 3;

private static final String ORIGINAL_TEXT_IN_CODE = "OriginalText from Code";
private static final String DISPLAY_NAME_IN_VALUE = "Value displayName";
private static final String MULTILEX_CODE_SYSTEM = "2.16.840.1.113883.2.1.6.4";
private static final String MULTILEX_COCONUT_OIL = "01142009";
private static final String SNOMED_CODE_SYSTEM = "2.16.840.1.113883.2.1.3.2.4.15";
Expand Down Expand Up @@ -159,7 +160,7 @@ public void testMapDegradedDrugAllergy() {
}

@Test
public void testMapAllergyWithOriginalTextInObservationCode() {
public void testMapAllergyWithOriginalTextInObservationCodeAndWithoutValue_MapsCodingTextFromCodeOriginalText() {
when(codeableConceptMapper.mapToCodeableConcept(any(CD.class)))
.thenReturn(defaultCodeableConcept())
.thenReturn(secondaryCodeableConcept());
Expand Down Expand Up @@ -270,6 +271,24 @@ public void testMapAllergyWithDrugTermText() {
assertThat(allergyIntolerance.getNote().size()).isOne();
}

@Test void testMapDrugAllergyWithValueElement_MapsCodingTextFromValueDescription() {
when(codeableConceptMapper.mapToCodeableConcept(any(CD.class)))
.thenReturn(defaultCodeableConcept())
.thenReturn(secondaryCodeableConcept());
var ehrExtract = unmarshallEhrExtract("drug-allergy-with-value.xml");
List<AllergyIntolerance> allergyIntolerances = allergyIntoleranceMapper.mapResources(ehrExtract, getPatient(),
getEncounterList(), PRACTISE_CODE);

assertThat(allergyIntolerances.size()).isEqualTo(1);
var allergyIntolerance = allergyIntolerances.get(0);

assertFixedValues(allergyIntolerance);

assertExtension(allergyIntolerance);

assertThat(allergyIntolerance.getCode().getText()).isEqualTo(DISPLAY_NAME_IN_VALUE);
}

@ParameterizedTest
@MethodSource("allergyStructuresWithTranslations")
public void testTppNamedSchemaInValue(String filename) {
Expand Down Expand Up @@ -345,6 +364,7 @@ private CodeableConcept defaultCodeableConcept() {
var codeableConcept = new CodeableConcept();
var coding = new Coding();
coding.setDisplay(CODING_DISPLAY_1);
coding.setSystem(SNOMED_CODE_SYSTEM);
codeableConcept.addCoding(coding);

return codeableConcept;
Expand All @@ -353,6 +373,7 @@ private CodeableConcept defaultCodeableConcept() {
private CodeableConcept secondaryCodeableConcept() {
var codeableConcept = new CodeableConcept();
var coding = new Coding();
coding.setSystem(SNOMED_CODE_SYSTEM);
coding.setDisplay(CODING_DISPLAY_2);
codeableConcept.addCoding(coding);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
<translation code="416098002" codeSystem="2.16.840.1.113883.2.1.3.2.4.15" displayName="Allergy to drug"/>
<translation code="14L..00" codeSystem="2.16.840.1.113883.2.1.6.2" displayName="H/O: drug allergy"/>
</code>
<value type="CD" codeSystem="1.3.6.1.4.1.17340.1.5" code="9006113"
displayName="Propranolol 10mg tablets (Almus Pharmaceuticals Ltd) @ 28 tablet(s)">
</value>
MartinWheelerMT marked this conversation as resolved.
Show resolved Hide resolved
<statusCode code="COMPLETE"/>
<effectiveTime>
<center value="19781231"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<EhrExtract xmlns="urn:hl7-org:v3" classCode="EXTRACT" moodCode="EVN">
<availabilityTime value="20200101010101" />
<component typeCode="COMP">
<ehrFolder classCode="FOLDER" moodCode="EVN">
<component typeCode="COMP">
<ehrComposition classCode="COMPOSITION" moodCode="EVN">
<id root="62A39454-299F-432E-993E-5A6232B4E099"/>
<availabilityTime value="20190708143500"/>
<Participant2 typeCode="PRF" contextControlCode="OP">
<agentRef classCode="AGNT">
<id root="2D70F602-6BB1-47E0-B2EC-39912A59787D"/>
</agentRef>
</Participant2>
<component typeCode="COMP">
<CompoundStatement classCode="CATEGORY" moodCode="EVN">
<id root="394559384658936"/>
<code code="14L..00" codeSystem="2.16.840.1.113883.2.1.6.2" displayName="H/O: drug allergy"/>
<statusCode code="COMPLETE"/>
<effectiveTime>
<low value="20230918"/>
</effectiveTime>
<availabilityTime value="20230918162054"/>
<component typeCode="COMP" contextConductionInd="true">
<ObservationStatement classCode="OBS" moodCode="EVN">
<id root="394559384658936"/>
<code code="14L.." codeSystem="2.16.840.1.113883.2.1.3.2.4.14" displayName="H/O: drug allergy">
<originalText>H/O: drug allergy</originalText>
<translation code="416098002" codeSystem="2.16.840.1.113883.2.1.3.2.4.15" displayName="Allergy to drug"/>
<translation code="14L..00" codeSystem="2.16.840.1.113883.2.1.6.2" displayName="H/O: drug allergy"/>
</code>
<statusCode code="COMPLETE"/>
<effectiveTime>
<low value="20230918"/>
</effectiveTime>
<availabilityTime value="20230918"/>
<value type="CD" code="00254001" codeSystem="2.16.840.1.113883.2.1.6.4" displayName="Value displayName">
<translation code="41891011000001106" codeSystem="2.16.840.1.113883.2.1.3.2.4.15" displayName="Azelaic acid 20% cream"/>
</value>
<pertinentInformation typeCode="PERT">
<sequenceNumber value="+1"/>
<pertinentAnnotation classCode="OBS" moodCode="EVN">
<text>Skin Allergy</text>
</pertinentAnnotation>
</pertinentInformation>
</ObservationStatement>
</component>
</CompoundStatement>
</component>
</ehrComposition>
</component>
</ehrFolder>
</component>
</EhrExtract>