4141
4242@ ExtendWith (MockitoExtension .class )
4343@ MockitoSettings (strictness = Strictness .LENIENT )
44- public class EhrExtractMapperComponentTest {
44+ class EhrExtractMapperComponentTest {
45+
4546 private static final String TEST_FILE_DIRECTORY = "/ehr/request/fhir/" ;
4647 private static final String INPUT_DIRECTORY = "input/" ;
4748 private static final String OUTPUT_DIRECTORY = "output/" ;
4849 private static final String INPUT_PATH = TEST_FILE_DIRECTORY + INPUT_DIRECTORY ;
4950 private static final String OUTPUT_PATH = TEST_FILE_DIRECTORY + OUTPUT_DIRECTORY ;
50-
5151 private static final String JSON_INPUT_FILE = "gpc-access-structured.json" ;
5252 private static final String JSON_INPUT_FILE_WITH_NOPAT = "gpc-access-structured-with-nopat.json" ;
5353 private static final String DUPLICATE_RESOURCE_BUNDLE = INPUT_PATH + "duplicated-resource-bundle.json" ;
5454 private static final String ONE_CONSULTATION_RESOURCE_BUNDLE = INPUT_PATH + "1-consultation-resource.json" ;
55+ private static final String FHIR_BUNDLE_WITH_DUPLICATED_MEDICATION_REQUESTS = "fhir_bundle_with_duplicated_medication_requests.json" ;
56+ private static final String EXPECTED_XML_FOR_ONE_CONSULTATION_RESOURCE = "ExpectedResponseFrom1ConsultationResponse.xml" ;
57+
58+ private static final String EXPECTED_XML_TO_JSON_FILE = "expected-ehr-extract-response-from-json.xml" ;
59+ private static final String EXPECTED_XML_TO_JSON_FILE_WITH_NOPAT = "expected-ehr-extract-response-from-json-with-nopat.xml" ;
60+
5561 private static final String FHIR_BUNDLE_WITHOUT_EFFECTIVE_TIME = "fhir-bundle-without-effective-time.json" ;
5662 private static final String FHIR_BUNDLE_WITHOUT_HIGH_EFFECTIVE_TIME = "fhir-bundle-without-high-effective-time.json" ;
5763 private static final String FHIR_BUNDLE_WITH_EFFECTIVE_TIME = "fhir-bundle-with-effective-time.json" ;
@@ -63,12 +69,7 @@ public class EhrExtractMapperComponentTest {
6369 private static final String FHIR_BUNDLE_WITH_OBSERVATIONS_UNRELATED_TO_DIAGNOSTIC_REPORT =
6470 "fhir-bundle-observations-unrelated-to-diagnostic-report.json" ;
6571 private static final String FHIR_BUNDLE_WITH_OBSERVATIONS_WITH_RELATED_OBSERVATIONS =
66- "fhir-bundle-observations-with-related-observations.json" ;
67-
68- private static final String EXPECTED_XML_FOR_ONE_CONSULTATION_RESOURCE = "ExpectedResponseFrom1ConsultationResponse.xml" ;
69-
70- private static final String EXPECTED_XML_TO_JSON_FILE = "expected-ehr-extract-response-from-json.xml" ;
71- private static final String EXPECTED_XML_TO_JSON_FILE_WITH_NOPAT = "expected-ehr-extract-response-from-json-with-nopat.xml" ;
72+ "fhir-bundle-observations-with-related-observations.json" ;
7273 private static final String EXPECTED_XML_WITHOUT_EFFECTIVE_TIME = "expected-xml-without-effective-time.xml" ;
7374 private static final String EXPECTED_XML_WITHOUT_HIGH_EFFECTIVE_TIME = "expected-xml-without-high-effective-time.xml" ;
7475 private static final String EXPECTED_XML_WITH_EFFECTIVE_TIME = "expected-xml-with-effective-time.xml" ;
@@ -231,7 +232,7 @@ public void tearDown() {
231232 }
232233
233234 @ Test
234- public void When_MappingUncategorizedObservationWithNOPAT_Expect_ObservationStatementWithConfidentialityCode () {
235+ void When_MappingUncategorizedObservationWithNOPAT_Expect_ObservationStatementWithConfidentialityCode () {
235236
236237 String expectedJsonToXmlContent = ResourceTestFileUtils .getFileContent (OUTPUT_PATH + EXPECTED_XML_TO_JSON_FILE_WITH_NOPAT );
237238 String inputJsonFileContent = ResourceTestFileUtils .getFileContent (INPUT_PATH + JSON_INPUT_FILE_WITH_NOPAT );
@@ -259,7 +260,7 @@ public void When_MappingUncategorizedObservationWithNOPAT_Expect_ObservationStat
259260
260261 @ ParameterizedTest
261262 @ MethodSource ("testData" )
262- public void When_MappingProperJsonRequestBody_Expect_ProperXmlOutput (String input , String expected ) {
263+ void When_MappingProperJsonRequestBody_Expect_ProperXmlOutput (String input , String expected ) {
263264 String expectedJsonToXmlContent = ResourceTestFileUtils .getFileContent (OUTPUT_PATH + expected );
264265 String inputJsonFileContent = ResourceTestFileUtils .getFileContent (INPUT_PATH + input );
265266 Bundle bundle = new FhirParseService ().parseResource (inputJsonFileContent , Bundle .class );
@@ -274,6 +275,20 @@ public void When_MappingProperJsonRequestBody_Expect_ProperXmlOutput(String inpu
274275 assertThat (output ).isEqualToIgnoringWhitespace (expectedJsonToXmlContent );
275276 }
276277
278+ @ Test
279+ void When_MappingProperJsonRequestBody_Expect_NonDuplicatedMedicationRequestRemainingResources () {
280+ String inputJsonFileContent =
281+ ResourceTestFileUtils .getFileContent (INPUT_PATH + FHIR_BUNDLE_WITH_DUPLICATED_MEDICATION_REQUESTS );
282+ Bundle bundle = new FhirParseService ().parseResource (inputJsonFileContent , Bundle .class );
283+ messageContext .initialize (bundle );
284+
285+ EhrExtractTemplateParameters ehrExtractTemplateParameters = ehrExtractMapper .mapBundleToEhrFhirExtractParams (
286+ getGpcStructuredTaskDefinition ,
287+ bundle );
288+
289+ assertThat (ehrExtractTemplateParameters .getComponents ()).hasSize (2 );
290+ }
291+
277292 private static Stream <Arguments > testData () {
278293 return Stream .of (
279294 Arguments .of (JSON_INPUT_FILE , EXPECTED_XML_TO_JSON_FILE ),
@@ -288,7 +303,7 @@ private static Stream<Arguments> testData() {
288303 }
289304
290305 @ Test
291- public void When_MappingJsonBody_Expect_OnlyOneConsultationResource () {
306+ void When_MappingJsonBody_Expect_OnlyOneConsultationResource () {
292307 String expectedJsonToXmlContent = ResourceTestFileUtils .getFileContent (OUTPUT_PATH + EXPECTED_XML_FOR_ONE_CONSULTATION_RESOURCE );
293308 String inputJsonFileContent = ResourceTestFileUtils .getFileContent (ONE_CONSULTATION_RESOURCE_BUNDLE );
294309 Bundle bundle = new FhirParseService ().parseResource (inputJsonFileContent , Bundle .class );
@@ -302,7 +317,7 @@ public void When_MappingJsonBody_Expect_OnlyOneConsultationResource() {
302317 }
303318
304319 @ Test
305- public void When_TransformingResourceToEhrComp_Expect_NoDuplicateMappings () {
320+ void When_TransformingResourceToEhrComp_Expect_NoDuplicateMappings () {
306321 String bundle = ResourceTestFileUtils .getFileContent (DUPLICATE_RESOURCE_BUNDLE );
307322 Bundle parsedBundle = new FhirParseService ().parseResource (bundle , Bundle .class );
308323 messageContext .initialize (parsedBundle );
0 commit comments