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-3132 Populate the "no disclosure to patient" label for Encounter #695

Merged
merged 29 commits into from
Jul 15, 2024
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8ea91f4
[NIAD-3132] Added initial tests for ConfidentialityService.java
martin-nhs Jul 11, 2024
fdc90e8
[NIAD-3132] Added initial tests for ConfidentialityService.java
martin-nhs Jul 11, 2024
c087f62
[NIAD-3132] Updated AllergyIntoleranceMapper.java and EncounterMapper…
martin-nhs Jul 11, 2024
6ca34bd
[NIAD-3132] Removed old logic
martin-nhs Jul 11, 2024
ed490e7
[NIAD-3132] Addressed failing tests
martin-nhs Jul 11, 2024
c013de5
[NIAD-3132] Refactor failing tests
martin-nhs Jul 11, 2024
9b21d81
[NIAD-3132] Removed old tests
martin-nhs Jul 11, 2024
e13d44a
[NIAD-3132] Updated CHANGELOG.md
martin-nhs Jul 11, 2024
d4f8291
[NIAD-3132] Updated CHANGELOG.md
martin-nhs Jul 11, 2024
5c816a9
[NIAD-3132] Delegate generation of META to ConfidentialityService.java
martin-nhs Jul 11, 2024
b9d3c01
[NIAD-3132] Delegate generation of META to ConfidentialityService.java
martin-nhs Jul 11, 2024
e918d6f
[NIAD-3132] Converted to unit test, away from integration test.
martin-nhs Jul 11, 2024
0bc1db3
[NIAD-3132] Further enhancements to ConfidentialityServiceTest.java
martin-nhs Jul 11, 2024
4bce13a
Merge branch 'main' into NIAD-3132
MartinWheelerMT Jul 12, 2024
5566b56
[NIAD-3132] Address failing tests within AllergyIntoleranceMapperTest…
martin-nhs Jul 12, 2024
a041f82
[NIAD-3132] Address failing tests within AllergyIntoleranceMapperTest…
martin-nhs Jul 12, 2024
6a5a71d
[NIAD-3132] Tidy EncounterMapperTest.java imports
martin-nhs Jul 12, 2024
3fea402
[NIAD-3132] Addressed PR Comment https://github.com/NHSDigital/nia-pa…
martin-nhs Jul 12, 2024
be0ea9f
[NIAD-3132] Moved from using Collection to utilising variable arguments
martin-nhs Jul 12, 2024
ec268ce
[NIAD-3132] Updated AllergyIntoleranceMapperTest.java for https://git…
martin-nhs Jul 12, 2024
2fd7ab1
[NIAD-3132] Updated EncounterMapperTest.java.java for https://github.…
martin-nhs Jul 12, 2024
989202d
[NIAD-3132] Address checkstyle violations
martin-nhs Jul 12, 2024
ce75db9
Merge branch 'main' into NIAD-3132
martin-nhs Jul 12, 2024
8f35126
Refactor ConfidentialityService
MartinWheelerMT Jul 15, 2024
82b7703
[NIAD-3132] Added further test coverage
martin-nhs Jul 15, 2024
211d7bb
[NIAD-3132] Dried test code up
martin-nhs Jul 15, 2024
d38005c
[NIAD-3132] Enhancements to unit tests
martin-nhs Jul 15, 2024
24ea7f9
[NIAD-3132] Enhancements to unit tests
martin-nhs Jul 15, 2024
2c0a6e8
[NIAD-3132] Addressed checkstyle violations
martin-nhs Jul 15, 2024
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
Prev Previous commit
Next Next commit
[NIAD-3132] Addressed failing tests
martin-nhs committed Jul 11, 2024
commit ed490e7e4f435ebc9831c612047e6d0f71648908
Original file line number Diff line number Diff line change
@@ -11,17 +11,13 @@

import static uk.nhs.adaptors.pss.translator.util.XmlUnmarshallUtil.unmarshallFile;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;
import org.hl7.fhir.dstu3.model.DomainResource;
import org.hl7.fhir.dstu3.model.Encounter;

import org.hl7.fhir.dstu3.model.*;
import org.hl7.fhir.dstu3.model.Encounter.EncounterStatus;
import org.hl7.fhir.dstu3.model.ListResource;
import org.hl7.fhir.dstu3.model.Patient;
import org.hl7.fhir.dstu3.model.Period;
import org.hl7.fhir.dstu3.model.Reference;
import org.hl7.fhir.dstu3.model.Location;
import org.hl7.v3.RCMRMT030101UKCompoundStatement;
import org.hl7.v3.RCMRMT030101UKEhrExtract;

@@ -39,6 +35,7 @@
import org.mockito.stubbing.Answer;

import lombok.SneakyThrows;
import uk.nhs.adaptors.pss.translator.service.ConfidentialityService;
import uk.nhs.adaptors.pss.translator.util.DatabaseImmunizationChecker;
import uk.nhs.adaptors.pss.translator.util.DegradedCodeableConcepts;
import uk.nhs.adaptors.pss.translator.util.ResourceReferenceUtil;
@@ -98,6 +95,9 @@ public class EncounterMapperTest {
@Mock
private ResourceReferenceUtil resourceReferenceUtil;

@Mock
private ConfidentialityService confidentialityService;

@InjectMocks
private EncounterMapper encounterMapper;

@@ -109,6 +109,17 @@ public class EncounterMapperTest {

private static final String SNOMED_SYSTEM = "http://snomed.info/sct";

private static final Meta META;

static {
META = new Meta();
META.setProfile(
List.of(
new UriType(ENCOUNTER_META_PROFILE)
)
);
}

@BeforeEach
public void setup() {
patient = new Patient();
@@ -138,6 +149,9 @@ public void testEncountersWithMultipleCompoundStatements() {
.thenReturn(getList());
when(consultationListMapper.mapToCategory(any(ListResource.class), any(RCMRMT030101UKCompoundStatement.class)))
.thenReturn(getList());
when(confidentialityService.addSecurityToMetaIfConfidentialityCodesPresent(any(), any(Meta.class)))
.thenReturn(META);

var ehrExtract = unmarshallEhrExtractElement(ENCOUNTER_WITH_MULTIPLE_COMPOUND_STATEMENTS_XML);

Map<String, List<? extends DomainResource>> mappedResources = encounterMapper.mapEncounters(
@@ -160,6 +174,9 @@ public void testMapValidEncounterWithSnomedCode() {
.thenReturn(getList());
when(consultationListMapper.mapToCategory(any(ListResource.class), any(RCMRMT030101UKCompoundStatement.class)))
.thenReturn(getList());
when(confidentialityService.addSecurityToMetaIfConfidentialityCodesPresent(any(), any(Meta.class)))
.thenReturn(META);

var ehrExtract = unmarshallEhrExtractElement(FULL_VALID_STRUCTURED_ENCOUNTER_XML);

Map<String, List<? extends DomainResource>> mappedResources = encounterMapper.mapEncounters(
@@ -189,6 +206,9 @@ public void testMapValidEncounterWithoutSnomedCode() {
.thenReturn(getList());
when(consultationListMapper.mapToCategory(any(ListResource.class), any(RCMRMT030101UKCompoundStatement.class)))
.thenReturn(getList());
when(confidentialityService.addSecurityToMetaIfConfidentialityCodesPresent(any(), any(Meta.class)))
.thenReturn(META);

var ehrExtract = unmarshallEhrExtractElement(FULL_VALID_STRUCTURED_ENCOUNTER_XML);

Map<String, List<? extends DomainResource>> mappedResources = encounterMapper.mapEncounters(
@@ -214,6 +234,9 @@ public void testValidEncounterWithFullDataWithStructuredConsultation() {
.thenReturn(getList());
when(consultationListMapper.mapToCategory(any(ListResource.class), any(RCMRMT030101UKCompoundStatement.class)))
.thenReturn(getList());
when(confidentialityService.addSecurityToMetaIfConfidentialityCodesPresent(any(), any(Meta.class)))
.thenReturn(META);

var ehrExtract = unmarshallEhrExtractElement(FULL_VALID_STRUCTURED_ENCOUNTER_XML);

Map<String, List<? extends DomainResource>> mappedResources = encounterMapper.mapEncounters(
@@ -247,11 +270,14 @@ public void testValidEncounterWithFullDataWithStructuredConsultation() {
@Test
public void testValidEncounterWithLinkSetWithStructuredConsultation() {
when(consultationListMapper.mapToConsultation(any(RCMRMT030101UKEhrComposition.class), any(Encounter.class)))
.thenReturn(getList());
.thenReturn(getList());
when(consultationListMapper.mapToTopic(any(ListResource.class), any(RCMRMT030101UKCompoundStatement.class)))
.thenReturn(getList());
.thenReturn(getList());
when(consultationListMapper.mapToCategory(any(ListResource.class), any(RCMRMT030101UKCompoundStatement.class)))
.thenReturn(getList());
.thenReturn(getList());
when(confidentialityService.addSecurityToMetaIfConfidentialityCodesPresent(any(), any(Meta.class)))
.thenReturn(META);

var ehrExtract = unmarshallEhrExtractElement(FULL_VALID_STRUCTURED_ENCOUNTER_WITH_LINKSET_XML);

Map<String, List<? extends DomainResource>> mappedResources = encounterMapper.mapEncounters(
@@ -302,6 +328,9 @@ public void testValidEncounterWithFlatConsultationWithLinkSet() {
.thenReturn(getList());
when(consultationListMapper.mapToTopic(any(ListResource.class), isNull()))
.thenReturn(getList());
when(confidentialityService.addSecurityToMetaIfConfidentialityCodesPresent(any(), any(Meta.class)))
.thenReturn(META);

var ehrExtract = unmarshallEhrExtractElement(FULL_VALID_FLAT_ENCOUNTER_WITH_LINK_SET_XML);

Map<String, List<? extends DomainResource>> mappedResources = encounterMapper.mapEncounters(
@@ -335,6 +364,9 @@ public void testValidEncounterWithFullDataWithFlatConsultation() {
.thenReturn(getList());
when(consultationListMapper.mapToTopic(any(ListResource.class), isNull()))
.thenReturn(getList());
when(confidentialityService.addSecurityToMetaIfConfidentialityCodesPresent(any(), any(Meta.class)))
.thenReturn(META);

var ehrExtract = unmarshallEhrExtractElement(FULL_VALID_FLAT_ENCOUNTER_XML);

Map<String, List<? extends DomainResource>> mappedResources = encounterMapper.mapEncounters(
@@ -365,6 +397,9 @@ public void testValidEncounterWithNoOptionalDataWithFlatConsultation() {
.thenReturn(getList());
when(consultationListMapper.mapToTopic(any(ListResource.class), isNull()))
.thenReturn(getList());
when(confidentialityService.addSecurityToMetaIfConfidentialityCodesPresent(any(), any(Meta.class)))
.thenReturn(META);

var ehrExtract = unmarshallEhrExtractElement(NO_OPTIONAL_FLAT_ENCOUNTER_XML);

Map<String, List<? extends DomainResource>> mappedResources = encounterMapper.mapEncounters(
@@ -396,6 +431,9 @@ public void testEncounterWithMappedResourcesWithStructuredConsultation() {
.thenReturn(getList());
when(consultationListMapper.mapToCategory(any(ListResource.class), any(RCMRMT030101UKCompoundStatement.class)))
.thenReturn(getList());
when(confidentialityService.addSecurityToMetaIfConfidentialityCodesPresent(any(), any(Meta.class)))
.thenReturn(META);

var ehrExtract = unmarshallEhrExtractElement(FULL_VALID_STRUCTURED_ENCOUNTER_WITH_RESOURCES_XML);

Map<String, List<? extends DomainResource>> mappedResources = encounterMapper.mapEncounters(
@@ -434,6 +472,9 @@ public void testEncounterWithMappedResourcesWithFlatConsultation() {
.thenReturn(getList());
when(consultationListMapper.mapToTopic(any(ListResource.class), isNull()))
.thenReturn(getList());
when(confidentialityService.addSecurityToMetaIfConfidentialityCodesPresent(any(), any(Meta.class)))
.thenReturn(META);

var ehrExtract = unmarshallEhrExtractElement(FULL_VALID_FLAT_ENCOUNTER_WITH_RESOURCES_XML);

Map<String, List<? extends DomainResource>> mappedResources = encounterMapper.mapEncounters(
@@ -467,6 +508,9 @@ public void testEncounterPeriod(String inputXML, String startDate, String endDat
.thenReturn(getList());
when(consultationListMapper.mapToTopic(any(ListResource.class), isNull()))
.thenReturn(getList());
when(confidentialityService.addSecurityToMetaIfConfidentialityCodesPresent(any(), any(Meta.class)))
.thenReturn(META);

final RCMRMT030101UKEhrExtract ehrExtract = unmarshallEhrExtractElement(inputXML);

Map<String, List<? extends DomainResource>> mappedResources = encounterMapper.mapEncounters(