-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NIAD-3148 - Immunizations outside of consultation are mapped to Obser…
…vation (#752) * [NIAD-3148] Add method to TestUtility.java `getEhrFolderComponent` * [NIAD-3148] Add method to TestUtility.java `getEhrFolderComponent` * [NIAD-3148] Add some unit tests for current logic * [NIAD-3148] Remove redundant test file * [NIAD-3148] Initial refactor of DatabaseImmunizationChecker.java * [NIAD-3148] Create DatabaseImmunizationCheckerTest * [NIAD-3148] Create utility to create CD values * [NIAD-3148] Add functionality to create-database-postgres.sql to join the description ID and concept ID * [NIAD-3148] Method signature renamed to `getImmunizationSnomedUsingConceptOrDescriptionId` * [NIAD-3148] Address problem with test-load-immunization-codes.sh * Add DirtiesContext to DatabaseImmunizationCheckerIT * [NIAD-3148] Address PR to #752 (comment) * [NIAD-3148] Address PR comments https://github.com/NHSDigital/nia-patient-switching-standard-adaptor/pull/752/files#r1710239250 and https://github.com/NHSDigital/nia-patient-switching-standard-adaptor/pull/752/files#r1710234310 * [NIAD-3148] Address PR comment https://github.com/NHSDigital/nia-patient-switching-standard-adaptor/pull/752/files#r1710219516 * [NIAD-3148] Update CHANGELOG.md * [NIAD-3148] Update CHANGELOG.md --------- Co-authored-by: MartinWheelerMT <[email protected]>
- Loading branch information
1 parent
58e6022
commit fccd428
Showing
14 changed files
with
495 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,5 @@ | |
@Setter | ||
@Builder | ||
public class ImmunizationSnomedCT { | ||
private String conceptId; | ||
private String snomedId; | ||
} |
2 changes: 1 addition & 1 deletion
2
.../uk/nhs/adaptors/connector/dao/ImmunizationSnomedCTDao/select_immunization_concept_id.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
SELECT i.conceptid FROM "snomedct".immunization_codes i WHERE conceptid = :conceptId; | ||
SELECT i.concept_or_description_id FROM "snomedct".immunization_codes i WHERE i.concept_or_description_id = :snomedId; |
4 changes: 2 additions & 2 deletions
4
...ces/uk/nhs/adaptors/connector/dao/ImmunizationSnomedCTDao/verify_immunizations_loaded.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...rc/integrationTest/java/uk/nhs/adaptors/pss/translator/DatabaseImmunizationCheckerIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package uk.nhs.adaptors.pss.translator; | ||
|
||
import org.hl7.v3.CD; | ||
import org.hl7.v3.RCMRMT030101UKObservationStatement; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.annotation.DirtiesContext; | ||
import org.springframework.test.context.junit.jupiter.SpringExtension; | ||
import uk.nhs.adaptors.pss.translator.util.DatabaseImmunizationChecker; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static uk.nhs.adaptors.pss.translator.TestUtility.createCd; | ||
|
||
@SpringBootTest | ||
@DirtiesContext | ||
@ExtendWith(SpringExtension.class) | ||
class DatabaseImmunizationCheckerIT { | ||
private static final String SNOMED_CODE_SYSTEM_OID = "2.16.840.1.113883.2.1.3.2.4.15"; | ||
private static final String DISPLAY_NAME = "Influenza vaccination"; | ||
|
||
@Autowired | ||
private DatabaseImmunizationChecker databaseImmunizationChecker; | ||
|
||
@Test | ||
void When_Immunization_With_SnomedDescriptionId_Expect_True() { | ||
final String immunizationDescriptionSnomedId = "142934010"; | ||
final CD cd = getCdForSnomedId(immunizationDescriptionSnomedId); | ||
final RCMRMT030101UKObservationStatement observationStatement = | ||
new RCMRMT030101UKObservationStatement(); | ||
|
||
observationStatement.setCode(cd); | ||
|
||
final boolean result = databaseImmunizationChecker.isImmunization(observationStatement); | ||
|
||
assertThat(result).isTrue(); | ||
} | ||
|
||
@Test | ||
void When_Immunization_With_SnomedConceptId_Expect_True() { | ||
final String immunizationConceptSnomedId = "86198006"; | ||
final CD cd = getCdForSnomedId(immunizationConceptSnomedId); | ||
final RCMRMT030101UKObservationStatement observationStatement = | ||
new RCMRMT030101UKObservationStatement(); | ||
|
||
observationStatement.setCode(cd); | ||
|
||
final boolean result = databaseImmunizationChecker.isImmunization(observationStatement); | ||
|
||
assertThat(result).isTrue(); | ||
} | ||
|
||
private CD getCdForSnomedId(String snomedId) { | ||
return createCd( | ||
snomedId, | ||
SNOMED_CODE_SYSTEM_OID, | ||
DISPLAY_NAME | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
...or/src/test/java/uk/nhs/adaptors/pss/translator/util/DatabaseImmunizationCheckerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
package uk.nhs.adaptors.pss.translator.util; | ||
|
||
import jakarta.xml.bind.JAXBException; | ||
import org.hl7.v3.RCMRMT030101UKComponent3; | ||
import org.hl7.v3.RCMRMT030101UKEhrExtract; | ||
import org.hl7.v3.RCMRMT030101UKObservationStatement; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.ArgumentCaptor; | ||
import org.mockito.Captor; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
import uk.nhs.adaptors.connector.dao.ImmunizationSnomedCTDao; | ||
import uk.nhs.adaptors.connector.model.ImmunizationSnomedCT; | ||
import uk.nhs.adaptors.pss.translator.FileFactory; | ||
|
||
import java.io.File; | ||
import java.util.List; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.jupiter.api.Assertions.assertAll; | ||
import static org.mockito.Mockito.when; | ||
import static uk.nhs.adaptors.pss.translator.TestUtility.getEhrFolderComponents; | ||
import static uk.nhs.adaptors.pss.translator.util.XmlUnmarshallUtil.unmarshallFile; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class DatabaseImmunizationCheckerTest { | ||
@Mock | ||
private ImmunizationSnomedCTDao immunizationSnomedCTDao; | ||
|
||
@InjectMocks | ||
private DatabaseImmunizationChecker databaseImmunizationChecker; | ||
|
||
@Captor | ||
private ArgumentCaptor<String> snomedCtIdCaptor; | ||
|
||
private static final String TEST_FILES_DIRECTORY = "Immunization"; | ||
|
||
@Test | ||
void When_IsObservationStatementImmunization_With_ImmunizationCode_Expect_True() throws JAXBException { | ||
final String expectedCode = "3955997015"; | ||
final RCMRMT030101UKObservationStatement observationStatement = getObservationStatementFromExtract( | ||
"full_valid_immunization_with_no_translation.xml"); | ||
final ImmunizationSnomedCT immunizationSnomedCT = ImmunizationSnomedCT.builder() | ||
.snomedId(expectedCode) | ||
.build(); | ||
|
||
when(immunizationSnomedCTDao.getImmunizationSnomedUsingConceptOrDescriptionId( | ||
snomedCtIdCaptor.capture() | ||
)).thenReturn(immunizationSnomedCT); | ||
|
||
final boolean result = databaseImmunizationChecker.isImmunization(observationStatement); | ||
|
||
assertAll( | ||
() -> assertThat(result).isTrue(), | ||
() -> assertThat(snomedCtIdCaptor.getValue()).isEqualTo(expectedCode) | ||
); | ||
} | ||
|
||
@Test | ||
void When_IsObservationStatementImmunization_With_ImmunizationCodeAndNonImmunizationTranslation_Expect_True() throws JAXBException { | ||
final String snomedCode = "142934010"; | ||
final String readsV2Code = "65E..00"; | ||
final RCMRMT030101UKObservationStatement observationStatement = getObservationStatementFromExtract( | ||
"full_valid_immunization_with_translation.xml" | ||
); | ||
|
||
final ImmunizationSnomedCT immunizationSnomedCT = ImmunizationSnomedCT.builder() | ||
.snomedId(snomedCode) | ||
.build(); | ||
|
||
when(immunizationSnomedCTDao.getImmunizationSnomedUsingConceptOrDescriptionId( | ||
snomedCtIdCaptor.capture() | ||
)).thenReturn(null, immunizationSnomedCT); | ||
|
||
final boolean result = databaseImmunizationChecker.isImmunization(observationStatement); | ||
|
||
assertAll( | ||
() -> assertThat(result).isTrue(), | ||
() -> assertThat(snomedCtIdCaptor.getAllValues().getFirst()).isEqualTo(readsV2Code), | ||
() -> assertThat(snomedCtIdCaptor.getAllValues().get(1)).isEqualTo(snomedCode) | ||
); | ||
} | ||
|
||
private RCMRMT030101UKObservationStatement getObservationStatementFromExtract(String filename) throws JAXBException { | ||
final RCMRMT030101UKEhrExtract ehrExtract = getEhrExtractFromFile(filename); | ||
final List<RCMRMT030101UKComponent3> components = getEhrFolderComponents(ehrExtract, 0); | ||
|
||
return components.getFirst() | ||
.getEhrComposition() | ||
.getComponent() | ||
.getFirst() | ||
.getObservationStatement(); | ||
} | ||
|
||
private RCMRMT030101UKEhrExtract getEhrExtractFromFile(String filename) throws JAXBException { | ||
final File file = FileFactory.getXmlFileFor(TEST_FILES_DIRECTORY, filename); | ||
return unmarshallFile(file, RCMRMT030101UKEhrExtract.class); | ||
} | ||
} |
Oops, something went wrong.