From 65ef0320a06a06cdc49e0f3b2f190332a45c3771 Mon Sep 17 00:00:00 2001 From: ruhanga Date: Mon, 9 Nov 2020 10:56:35 +0300 Subject: [PATCH] FM2-312: MedicationRequestFihrResourceProvider to hundle 'identifier' parameter + fixing failing tests --- .../impl/FhirMedicationRequestDaoImpl.java | 16 +++++ .../dao/impl/FhirServiceRequestDaoImpl.java | 7 +-- .../FhirMedicationRequestServiceImpl.java | 1 + ...MedicationRequestFhirResourceProvider.java | 2 +- ...cationRequestFhirResourceProviderTest.java | 42 +++++-------- ...ionRequestFhirResourceProviderWebTest.java | 62 +++++++++---------- 6 files changed, 69 insertions(+), 61 deletions(-) diff --git a/api/src/main/java/org/openmrs/module/fhir2/api/dao/impl/FhirMedicationRequestDaoImpl.java b/api/src/main/java/org/openmrs/module/fhir2/api/dao/impl/FhirMedicationRequestDaoImpl.java index 576aceceb1..745876efaa 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/api/dao/impl/FhirMedicationRequestDaoImpl.java +++ b/api/src/main/java/org/openmrs/module/fhir2/api/dao/impl/FhirMedicationRequestDaoImpl.java @@ -9,11 +9,16 @@ */ package org.openmrs.module.fhir2.api.dao.impl; +import static org.hibernate.criterion.Restrictions.eq; + +import java.util.Optional; + import ca.uhn.fhir.rest.param.ReferenceAndListParam; import ca.uhn.fhir.rest.param.TokenAndListParam; import lombok.AccessLevel; import lombok.Setter; import org.hibernate.Criteria; +import org.hibernate.criterion.Criterion; import org.openmrs.DrugOrder; import org.openmrs.module.fhir2.FhirConstants; import org.openmrs.module.fhir2.api.dao.FhirMedicationRequestDao; @@ -50,6 +55,10 @@ protected void setupSearchParams(Criteria criteria, SearchParameterMap theParams case FhirConstants.COMMON_SEARCH_HANDLER: handleCommonSearchParameters(entry.getValue()).ifPresent(criteria::add); break; + case FhirConstants.IDENTIFIER: + entry.getValue().forEach(orderNumber -> handleOrderNumber((TokenAndListParam) orderNumber.getParam()) + .ifPresent(criteria::add)); + break; } }); } @@ -64,4 +73,11 @@ private void handleCodedConcept(Criteria criteria, TokenAndListParam code) { } } + private Optional handleOrderNumber(TokenAndListParam orderNumber) { + if (orderNumber != null) { + return handleAndListParam(orderNumber, param -> Optional.of(eq("orderNumber", param.getValue()))); + } + return Optional.empty(); + } + } diff --git a/api/src/main/java/org/openmrs/module/fhir2/api/dao/impl/FhirServiceRequestDaoImpl.java b/api/src/main/java/org/openmrs/module/fhir2/api/dao/impl/FhirServiceRequestDaoImpl.java index b44645e71d..def5d1c268 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/api/dao/impl/FhirServiceRequestDaoImpl.java +++ b/api/src/main/java/org/openmrs/module/fhir2/api/dao/impl/FhirServiceRequestDaoImpl.java @@ -59,10 +59,9 @@ protected void setupSearchParams(Criteria criteria, SearchParameterMap theParams case FhirConstants.COMMON_SEARCH_HANDLER: handleCommonSearchParameters(entry.getValue()).ifPresent(criteria::add); break; - case FhirConstants.IDENTIFIER: - entry.getValue() - .forEach(orderNumber -> handleOrderNumber((TokenAndListParam) orderNumber.getParam()) - .ifPresent(criteria::add)); + case FhirConstants.IDENTIFIER: + entry.getValue().forEach(orderNumber -> handleOrderNumber((TokenAndListParam) orderNumber.getParam()) + .ifPresent(criteria::add)); break; } }); diff --git a/api/src/main/java/org/openmrs/module/fhir2/api/impl/FhirMedicationRequestServiceImpl.java b/api/src/main/java/org/openmrs/module/fhir2/api/impl/FhirMedicationRequestServiceImpl.java index f3e50430e9..25409ac664 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/api/impl/FhirMedicationRequestServiceImpl.java +++ b/api/src/main/java/org/openmrs/module/fhir2/api/impl/FhirMedicationRequestServiceImpl.java @@ -61,6 +61,7 @@ public IBundleProvider searchForMedicationRequests(ReferenceAndListParam patient .addParameter(FhirConstants.PARTICIPANT_REFERENCE_SEARCH_HANDLER, participantReference) .addParameter(FhirConstants.MEDICATION_REFERENCE_SEARCH_HANDLER, medicationReference) .addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.ID_PROPERTY, id) + .addParameter(FhirConstants.IDENTIFIER, identifier) .addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.LAST_UPDATED_PROPERTY, lastUpdated) .addParameter(FhirConstants.INCLUDE_SEARCH_HANDLER, includes); diff --git a/api/src/main/java/org/openmrs/module/fhir2/providers/r4/MedicationRequestFhirResourceProvider.java b/api/src/main/java/org/openmrs/module/fhir2/providers/r4/MedicationRequestFhirResourceProvider.java index 767bb5a5ec..50c7bf5dc7 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/providers/r4/MedicationRequestFhirResourceProvider.java +++ b/api/src/main/java/org/openmrs/module/fhir2/providers/r4/MedicationRequestFhirResourceProvider.java @@ -131,6 +131,6 @@ public IBundleProvider searchForMedicationRequests( } return fhirMedicationRequestService.searchForMedicationRequests(patientReference, encounterReference, code, - participantReference, medicationReference, id, lastUpdated, includes); + participantReference, medicationReference, orderNumber, id, lastUpdated, includes); } } diff --git a/api/src/test/java/org/openmrs/module/fhir2/providers/r4/MedicationRequestFhirResourceProviderTest.java b/api/src/test/java/org/openmrs/module/fhir2/providers/r4/MedicationRequestFhirResourceProviderTest.java index e64e140241..784cafdb17 100644 --- a/api/src/test/java/org/openmrs/module/fhir2/providers/r4/MedicationRequestFhirResourceProviderTest.java +++ b/api/src/test/java/org/openmrs/module/fhir2/providers/r4/MedicationRequestFhirResourceProviderTest.java @@ -111,9 +111,8 @@ private List getResources(IBundleProvider results, int theFromInd @Test public void searchMedicationRequest_shouldReturnMatchingMedicationRequestUsingCode() { - when( - fhirMedicationRequestService.searchForMedicationRequests(any(), any(), any(), any(), any(), any(), any(), any())) - .thenReturn(new MockIBundleProvider<>(Collections.singletonList(medicationRequest), 10, 1)); + when(fhirMedicationRequestService.searchForMedicationRequests(any(), any(), any(), any(), any(), any(), any(), any(), + any())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(medicationRequest), 10, 1)); TokenAndListParam code = new TokenAndListParam(); TokenParam codingToken = new TokenParam(); @@ -135,9 +134,8 @@ public void searchMedicationRequest_shouldReturnMatchingMedicationRequestUsingCo @Test public void searchMedicationRequest_shouldReturnMatchingMedicationRequestWhenPatientParamIsSpecified() { - when( - fhirMedicationRequestService.searchForMedicationRequests(any(), any(), any(), any(), any(), any(), any(), any())) - .thenReturn(new MockIBundleProvider<>(Collections.singletonList(medicationRequest), 10, 1)); + when(fhirMedicationRequestService.searchForMedicationRequests(any(), any(), any(), any(), any(), any(), any(), any(), + any())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(medicationRequest), 10, 1)); ReferenceAndListParam patientParam = new ReferenceAndListParam(); patientParam.addValue(new ReferenceOrListParam().add(new ReferenceParam().setChain(Patient.SP_NAME))); @@ -157,9 +155,8 @@ public void searchMedicationRequest_shouldReturnMatchingMedicationRequestWhenPat @Test public void searchMedicationRequest_shouldReturnMatchingMedicationRequestWhenMedicationParamIsSpecified() { - when( - fhirMedicationRequestService.searchForMedicationRequests(any(), any(), any(), any(), any(), any(), any(), any())) - .thenReturn(new MockIBundleProvider<>(Collections.singletonList(medicationRequest), 10, 1)); + when(fhirMedicationRequestService.searchForMedicationRequests(any(), any(), any(), any(), any(), any(), any(), any(), + any())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(medicationRequest), 10, 1)); ReferenceAndListParam medicationParam = new ReferenceAndListParam(); medicationParam.addValue(new ReferenceOrListParam().add(new ReferenceParam().setChain(Medication.SP_IDENTIFIER))); @@ -179,9 +176,8 @@ public void searchMedicationRequest_shouldReturnMatchingMedicationRequestWhenMed @Test public void searchMedicationRequest_shouldReturnMatchingMedicationRequestWhenParticipantParamIsSpecified() { - when( - fhirMedicationRequestService.searchForMedicationRequests(any(), any(), any(), any(), any(), any(), any(), any())) - .thenReturn(new MockIBundleProvider<>(Collections.singletonList(medicationRequest), 10, 1)); + when(fhirMedicationRequestService.searchForMedicationRequests(any(), any(), any(), any(), any(), any(), any(), any(), + any())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(medicationRequest), 10, 1)); ReferenceAndListParam participantParam = new ReferenceAndListParam(); participantParam.addValue(new ReferenceOrListParam().add(new ReferenceParam().setChain(Practitioner.SP_NAME))); @@ -201,9 +197,8 @@ public void searchMedicationRequest_shouldReturnMatchingMedicationRequestWhenPar @Test public void searchMedicationRequest_shouldReturnMatchingMedicationRequestWhenEncounterParamIsSpecified() { - when( - fhirMedicationRequestService.searchForMedicationRequests(any(), any(), any(), any(), any(), any(), any(), any())) - .thenReturn(new MockIBundleProvider<>(Collections.singletonList(medicationRequest), 10, 1)); + when(fhirMedicationRequestService.searchForMedicationRequests(any(), any(), any(), any(), any(), any(), any(), any(), + any())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(medicationRequest), 10, 1)); ReferenceAndListParam encounterParam = new ReferenceAndListParam(); encounterParam.addValue(new ReferenceOrListParam().add(new ReferenceParam().setChain(Encounter.SP_IDENTIFIER))); @@ -224,9 +219,8 @@ public void searchMedicationRequest_shouldReturnMatchingMedicationRequestWhenEnc public void searchMedicationRequest_shouldReturnMatchingMedicationRequestWhenUUIDIsSpecified() { TokenAndListParam uuid = new TokenAndListParam().addAnd(new TokenParam(MEDICATION_REQUEST_UUID)); - when( - fhirMedicationRequestService.searchForMedicationRequests(any(), any(), any(), any(), any(), any(), any(), any())) - .thenReturn(new MockIBundleProvider<>(Collections.singletonList(medicationRequest), 10, 1)); + when(fhirMedicationRequestService.searchForMedicationRequests(any(), any(), any(), any(), any(), any(), any(), any(), + any())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(medicationRequest), 10, 1)); IBundleProvider results = resourceProvider.searchForMedicationRequests(null, null, null, null, null, null, null, uuid, null, null); @@ -244,9 +238,8 @@ public void searchMedicationRequest_shouldReturnMatchingMedicationRequestWhenUUI public void searchMedicationRequest_shouldReturnMatchingMedicationRequestWhenLastUpdatedIsSpecified() { DateRangeParam lastUpdated = new DateRangeParam().setUpperBound(LAST_UPDATED_DATE).setLowerBound(LAST_UPDATED_DATE); - when( - fhirMedicationRequestService.searchForMedicationRequests(any(), any(), any(), any(), any(), any(), any(), any())) - .thenReturn(new MockIBundleProvider<>(Collections.singletonList(medicationRequest), 10, 1)); + when(fhirMedicationRequestService.searchForMedicationRequests(any(), any(), any(), any(), any(), any(), any(), any(), + any())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(medicationRequest), 10, 1)); IBundleProvider results = resourceProvider.searchForMedicationRequests(null, null, null, null, null, null, null, null, lastUpdated, null); @@ -265,9 +258,8 @@ public void searchMedicationRequest_shouldAddRelatedMedicationsWhenIncluded() { HashSet includes = new HashSet<>(); includes.add(new Include("MedicationRequest:requester")); - when( - fhirMedicationRequestService.searchForMedicationRequests(any(), any(), any(), any(), any(), any(), any(), any())) - .thenReturn(new MockIBundleProvider<>(Arrays.asList(medicationRequest, new Practitioner()), 10, 1)); + when(fhirMedicationRequestService.searchForMedicationRequests(any(), any(), any(), any(), any(), any(), any(), any(), + any())).thenReturn(new MockIBundleProvider<>(Arrays.asList(medicationRequest, new Practitioner()), 10, 1)); IBundleProvider results = resourceProvider.searchForMedicationRequests(null, null, null, null, null, null, null, null, null, includes); @@ -286,7 +278,7 @@ public void searchMedicationRequest_shouldAddRelatedMedicationsWhenIncluded() { public void searchMedicationRequest_shouldNotAddRelatedMedicationsForEmptyInclude() { HashSet includes = new HashSet<>(); - when(fhirMedicationRequestService.searchForMedicationRequests(any(), any(), any(), any(), any(), any(), any(), + when(fhirMedicationRequestService.searchForMedicationRequests(any(), any(), any(), any(), any(), any(), any(), any(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(medicationRequest), 10, 1)); IBundleProvider results = resourceProvider.searchForMedicationRequests(null, null, null, null, null, null, null, diff --git a/omod/src/test/java/org/openmrs/module/fhir2/providers/r4/MedicationRequestFhirResourceProviderWebTest.java b/omod/src/test/java/org/openmrs/module/fhir2/providers/r4/MedicationRequestFhirResourceProviderWebTest.java index 122ae9861c..62ba748d10 100644 --- a/omod/src/test/java/org/openmrs/module/fhir2/providers/r4/MedicationRequestFhirResourceProviderWebTest.java +++ b/omod/src/test/java/org/openmrs/module/fhir2/providers/r4/MedicationRequestFhirResourceProviderWebTest.java @@ -141,7 +141,7 @@ public void searchForMedicationRequests_shouldSearchForMedicationRequestsByUUID( verifyUri(String.format("/MedicationRequest?_id=%s", MEDICATION_REQUEST_UUID)); verify(fhirMedicationRequestService).searchForMedicationRequests(isNull(), isNull(), isNull(), isNull(), isNull(), - tokenAndListParamArgumentCaptor.capture(), isNull(), isNull()); + isNull(), tokenAndListParamArgumentCaptor.capture(), isNull(), isNull()); assertThat(tokenAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(tokenAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -155,7 +155,7 @@ public void searchForMedicationRequests_shouldSearchForMedicationRequestsByLastU verifyUri(String.format("/MedicationRequest?_lastUpdated=%s", LAST_UPDATED_DATE)); verify(fhirMedicationRequestService).searchForMedicationRequests(isNull(), isNull(), isNull(), isNull(), isNull(), - isNull(), dateRangeParamArgumentCaptor.capture(), isNull()); + isNull(), isNull(), dateRangeParamArgumentCaptor.capture(), isNull()); assertThat(dateRangeParamArgumentCaptor.getValue(), notNullValue()); @@ -173,7 +173,7 @@ public void searchForMedicationRequests_shouldSearchForMedicationRequestsBySubje verifyUri(String.format("/MedicationRequest?subject=%s", PATIENT_UUID)); verify(fhirMedicationRequestService).searchForMedicationRequests(referenceAndListParamArgumentCaptor.capture(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -190,7 +190,7 @@ public void searchForMedicationRequests_shouldSearchForMedicationRequestsBySubje verifyUri(String.format("/MedicationRequest?subject.identifier=%s", PATIENT_IDENTIFIER)); verify(fhirMedicationRequestService).searchForMedicationRequests(referenceAndListParamArgumentCaptor.capture(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -207,7 +207,7 @@ public void searchForMedicationRequests_shouldSearchForMedicationRequestsBySubje verifyUri(String.format("/MedicationRequest?subject.given=%s", PATIENT_GIVEN_NAME)); verify(fhirMedicationRequestService).searchForMedicationRequests(referenceAndListParamArgumentCaptor.capture(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -224,7 +224,7 @@ public void searchForMedicationRequests_shouldSearchForMedicationRequestsBySubje verifyUri(String.format("/MedicationRequest?subject.family=%s", PATIENT_FAMILY_NAME)); verify(fhirMedicationRequestService).searchForMedicationRequests(referenceAndListParamArgumentCaptor.capture(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -241,7 +241,7 @@ public void searchForMedicationRequests_shouldSearchForMedicationRequestsBySubje verifyUri(String.format("/MedicationRequest?subject.name=%s", PATIENT_GIVEN_NAME)); verify(fhirMedicationRequestService).searchForMedicationRequests(referenceAndListParamArgumentCaptor.capture(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -260,7 +260,7 @@ public void searchForMedicationRequests_shouldSearchForMedicationRequestsBySubje PATIENT_IDENTIFIER)); verify(fhirMedicationRequestService).searchForMedicationRequests(referenceAndListParamArgumentCaptor.capture(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -279,7 +279,7 @@ public void searchForMedicationRequests_shouldSearchForMedicationRequestsByPatie verifyUri(String.format("/MedicationRequest?patient=%s", PATIENT_UUID)); verify(fhirMedicationRequestService).searchForMedicationRequests(referenceAndListParamArgumentCaptor.capture(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -296,7 +296,7 @@ public void searchForMedicationRequests_shouldSearchForMedicationRequestsByPatie verifyUri(String.format("/MedicationRequest?patient.identifier=%s", PATIENT_IDENTIFIER)); verify(fhirMedicationRequestService).searchForMedicationRequests(referenceAndListParamArgumentCaptor.capture(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -313,7 +313,7 @@ public void searchForMedicationRequests_shouldSearchForMedicationRequestsByPatie verifyUri(String.format("/MedicationRequest?patient.given=%s", PATIENT_GIVEN_NAME)); verify(fhirMedicationRequestService).searchForMedicationRequests(referenceAndListParamArgumentCaptor.capture(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -330,7 +330,7 @@ public void searchForMedicationRequests_shouldSearchForMedicationRequestsByPatie verifyUri(String.format("/MedicationRequest?patient.family=%s", PATIENT_FAMILY_NAME)); verify(fhirMedicationRequestService).searchForMedicationRequests(referenceAndListParamArgumentCaptor.capture(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -347,7 +347,7 @@ public void searchForMedicationRequests_shouldSearchForMedicationRequestsByPatie verifyUri(String.format("/MedicationRequest?patient.name=%s", PATIENT_GIVEN_NAME)); verify(fhirMedicationRequestService).searchForMedicationRequests(referenceAndListParamArgumentCaptor.capture(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -366,7 +366,7 @@ public void searchForMedicationRequests_shouldSearchForMedicationRequestsByPatie PATIENT_IDENTIFIER)); verify(fhirMedicationRequestService).searchForMedicationRequests(referenceAndListParamArgumentCaptor.capture(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -385,7 +385,8 @@ public void searchForMedicationRequests_shouldSearchForMedicationRequestsByEncou verifyUri(String.format("/MedicationRequest?encounter=%s", ENCOUNTER_UUID)); verify(fhirMedicationRequestService).searchForMedicationRequests(isNull(), - referenceAndListParamArgumentCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + referenceAndListParamArgumentCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), + isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -402,7 +403,7 @@ public void searchForMedicationRequests_shouldSearchForMedicationRequestsByParti verifyUri(String.format("/MedicationRequest?requester=%s", PARTICIPANT_UUID)); verify(fhirMedicationRequestService).searchForMedicationRequests(isNull(), isNull(), isNull(), - referenceAndListParamArgumentCaptor.capture(), isNull(), isNull(), isNull(), isNull()); + referenceAndListParamArgumentCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -419,7 +420,7 @@ public void searchForMedicationRequests_shouldSearchForMedicationRequestsByParti verifyUri(String.format("/MedicationRequest?requester.identifier=%s", PARTICIPANT_IDENTIFIER)); verify(fhirMedicationRequestService).searchForMedicationRequests(isNull(), isNull(), isNull(), - referenceAndListParamArgumentCaptor.capture(), isNull(), isNull(), isNull(), isNull()); + referenceAndListParamArgumentCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -436,7 +437,7 @@ public void searchForMedicationRequests_shouldSearchForMedicationRequestsByParti verifyUri(String.format("/MedicationRequest?requester.given=%s", PARTICIPANT_GIVEN_NAME)); verify(fhirMedicationRequestService).searchForMedicationRequests(isNull(), isNull(), isNull(), - referenceAndListParamArgumentCaptor.capture(), isNull(), isNull(), isNull(), isNull()); + referenceAndListParamArgumentCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -453,7 +454,7 @@ public void searchForMedicationRequests_shouldSearchForMedicationRequestsByParti verifyUri(String.format("/MedicationRequest?requester.family=%s", PARTICIPANT_FAMILY_NAME)); verify(fhirMedicationRequestService).searchForMedicationRequests(isNull(), isNull(), isNull(), - referenceAndListParamArgumentCaptor.capture(), isNull(), isNull(), isNull(), isNull()); + referenceAndListParamArgumentCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -470,7 +471,7 @@ public void searchForMedicationRequests_shouldSearchForMedicationRequestsByParti verifyUri(String.format("/MedicationRequest?requester.name=%s", PARTICIPANT_GIVEN_NAME)); verify(fhirMedicationRequestService).searchForMedicationRequests(isNull(), isNull(), isNull(), - referenceAndListParamArgumentCaptor.capture(), isNull(), isNull(), isNull(), isNull()); + referenceAndListParamArgumentCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -489,7 +490,7 @@ public void searchForMedicationRequests_shouldSearchForMedicationRequestsByParti PARTICIPANT_IDENTIFIER)); verify(fhirMedicationRequestService).searchForMedicationRequests(isNull(), isNull(), isNull(), - referenceAndListParamArgumentCaptor.capture(), isNull(), isNull(), isNull(), isNull()); + referenceAndListParamArgumentCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -509,7 +510,7 @@ public void searchForMedicationRequests_shouldSearchForMedicationRequestsByMedic verifyUri(String.format("/MedicationRequest?medication=%s", MEDICATION_UUID)); verify(fhirMedicationRequestService).searchForMedicationRequests(isNull(), isNull(), isNull(), isNull(), - referenceAndListParamArgumentCaptor.capture(), isNull(), isNull(), isNull()); + referenceAndListParamArgumentCaptor.capture(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -526,7 +527,7 @@ public void searchForMedicationRequests_shouldSearchForMedicationRequestsByCode( verifyUri(String.format("/MedicationRequest?code=%s", CODE)); verify(fhirMedicationRequestService).searchForMedicationRequests(isNull(), isNull(), - tokenAndListParamArgumentCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull()); + tokenAndListParamArgumentCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(tokenAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(tokenAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -540,7 +541,7 @@ public void searchForMedicationRequests_shouldAddRelatedRequesterWhenIncluded() verifyUri("/MedicationRequest?_include=MedicationRequest:requester"); verify(fhirMedicationRequestService).searchForMedicationRequests(isNull(), isNull(), isNull(), isNull(), isNull(), - isNull(), isNull(), includeArgumentCaptor.capture()); + isNull(), isNull(), isNull(), includeArgumentCaptor.capture()); assertThat(includeArgumentCaptor.getValue(), notNullValue()); assertThat(includeArgumentCaptor.getValue().size(), equalTo(1)); @@ -555,7 +556,7 @@ public void searchForMedicationRequests_shouldAddRelatedMedicationWhenIncluded() verifyUri("/MedicationRequest?_include=MedicationRequest:medication"); verify(fhirMedicationRequestService).searchForMedicationRequests(isNull(), isNull(), isNull(), isNull(), isNull(), - isNull(), isNull(), includeArgumentCaptor.capture()); + isNull(), isNull(), isNull(), includeArgumentCaptor.capture()); assertThat(includeArgumentCaptor.getValue(), notNullValue()); assertThat(includeArgumentCaptor.getValue().size(), equalTo(1)); @@ -570,7 +571,7 @@ public void searchForMedicationRequests_shouldAddRelatedPatientWhenIncluded() th verifyUri("/MedicationRequest?_include=MedicationRequest:patient"); verify(fhirMedicationRequestService).searchForMedicationRequests(isNull(), isNull(), isNull(), isNull(), isNull(), - isNull(), isNull(), includeArgumentCaptor.capture()); + isNull(), isNull(), isNull(), includeArgumentCaptor.capture()); assertThat(includeArgumentCaptor.getValue(), notNullValue()); assertThat(includeArgumentCaptor.getValue().size(), equalTo(1)); @@ -585,7 +586,7 @@ public void searchForMedicationRequests_shouldAddRelatedEncounterWhenIncluded() verifyUri("/MedicationRequest?_include=MedicationRequest:encounter"); verify(fhirMedicationRequestService).searchForMedicationRequests(isNull(), isNull(), isNull(), isNull(), isNull(), - isNull(), isNull(), includeArgumentCaptor.capture()); + isNull(), isNull(), isNull(), includeArgumentCaptor.capture()); assertThat(includeArgumentCaptor.getValue(), notNullValue()); assertThat(includeArgumentCaptor.getValue().size(), equalTo(1)); @@ -600,7 +601,7 @@ public void searchForMedicationRequests_shouldHandleMultipleIncludes() throws Ex verifyUri("/MedicationRequest?_include=MedicationRequest:medication&_include=MedicationRequest:requester"); verify(fhirMedicationRequestService).searchForMedicationRequests(isNull(), isNull(), isNull(), isNull(), isNull(), - isNull(), isNull(), includeArgumentCaptor.capture()); + isNull(), isNull(), isNull(), includeArgumentCaptor.capture()); assertThat(includeArgumentCaptor.getValue(), notNullValue()); assertThat(includeArgumentCaptor.getValue().size(), equalTo(2)); @@ -613,9 +614,8 @@ public void searchForMedicationRequests_shouldHandleMultipleIncludes() throws Ex } private void verifyUri(String uri) throws Exception { - when( - fhirMedicationRequestService.searchForMedicationRequests(any(), any(), any(), any(), any(), any(), any(), any())) - .thenReturn(new MockIBundleProvider<>(Collections.singletonList(medicationRequest), 10, 1)); + when(fhirMedicationRequestService.searchForMedicationRequests(any(), any(), any(), any(), any(), any(), any(), any(), + any())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(medicationRequest), 10, 1)); MockHttpServletResponse response = get(uri).accept(FhirMediaTypes.JSON).go();