55import org .hl7 .fhir .dstu3 .model .CodeableConcept ;
66import org .hl7 .fhir .dstu3 .model .Encounter ;
77import org .hl7 .fhir .dstu3 .model .IdType ;
8+ import org .hl7 .fhir .dstu3 .model .ListResource ;
89import org .hl7 .fhir .dstu3 .model .QuestionnaireResponse ;
910import org .hl7 .fhir .dstu3 .model .Reference ;
1011import org .hl7 .fhir .dstu3 .model .Resource ;
@@ -54,6 +55,7 @@ public class EncounterComponentsMapperTest {
5455 private static final String TEST_DIRECTORY = "/ehr/mapper/encountercomponents/" ;
5556 private static final String INPUT_BUNDLE_WITH_ALL_MAPPERS_USED = TEST_DIRECTORY + "input-bundle-1.json" ;
5657 private static final String EXPECTED_COMPONENTS_MAPPED_WITH_ALL_MAPPERS_USED = TEST_DIRECTORY + "expected-components-1.xml" ;
58+ private static final String EXPECTED_COMPONENTS_MAPPED_WITH_NOPAT = TEST_DIRECTORY + "expected-components-with-nopat.xml" ;
5759 private static final String INPUT_BUNDLE_WITH_EMPTY_CONSULTATION_LIST = TEST_DIRECTORY + "input-bundle-2.json" ;
5860 private static final String INPUT_BUNDLE_WITH_EMPTY_TOPIC_LIST = TEST_DIRECTORY + "input-bundle-3.json" ;
5961 private static final String INPUT_BUNDLE_WITH_EMPTY_CATEGORY_LIST = TEST_DIRECTORY + "input-bundle-4.json" ;
@@ -63,6 +65,7 @@ public class EncounterComponentsMapperTest {
6365 private static final String INPUT_BUNDLE_WITH_NON_TOPIC_CONSULTATION_LIST_ENTRY = TEST_DIRECTORY + "input-bundle-8.json" ;
6466 private static final String INPUT_BUNDLE_WITH_UNSUPPORTED_RESOURCES = TEST_DIRECTORY + "input-bundle-9-unsupported-resource.json" ;
6567 private static final String INPUT_BUNDLE_WITH_IGNORED_RESOURCE = TEST_DIRECTORY + "input-bundle-10-ignored-resource.json" ;
68+ private static final String INPUT_BUNDLE_WITH_META_SECURITY = TEST_DIRECTORY + "input-bundle-10-with-meta.json" ;
6669 private static final String INPUT_BUNDLE_WITH_NON_CATEGORY_TOPIC_LIST_ENTRY = TEST_DIRECTORY
6770 + "input-bundle-11-invalid-category-list.json" ;
6871 private static final String INPUT_BUNDLE_WITH_RELATED_PROBLEM_IN_TOPIC = TEST_DIRECTORY + "input-bundle-12-related-problem.json" ;
@@ -270,6 +273,18 @@ public void When_MappingEncounterComponents_Expect_IgnoredResourceNotMapped() {
270273 assertThat (mappedXml ).isEqualToIgnoringWhitespace (expectedXml );
271274 }
272275
276+ @ Test
277+ public void When_EncounterComponentsIncludeListWithMetaSecurity_Expect_CompoundStatementWithNOPAT () {
278+ String expectedXml = ResourceTestFileUtils .getFileContent (EXPECTED_COMPONENTS_MAPPED_WITH_NOPAT );
279+
280+ var bundle = initializeMessageContext (INPUT_BUNDLE_WITH_META_SECURITY );
281+ var encounter = extractEncounter (bundle );
282+ when (confidentialityService .generateConfidentialityCode (any (ListResource .class ))).thenReturn (Optional .of (CONFIDENTIALITY_CODE ));
283+
284+ String mappedXml = encounterComponentsMapper .mapComponents (encounter );
285+ assertThat (mappedXml ).isEqualToIgnoringWhitespace (expectedXml );
286+ }
287+
273288 @ ParameterizedTest
274289 @ MethodSource ("emptyResult" )
275290 public void When_MappingEncounterComponents_Expect_NoResourceMapped (String inputJsonPath ) {
0 commit comments