diff --git a/api/src/main/java/org/openmrs/module/fhir2/FhirConstants.java b/api/src/main/java/org/openmrs/module/fhir2/FhirConstants.java index 72f8c40995..fedcf8cf3a 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/FhirConstants.java +++ b/api/src/main/java/org/openmrs/module/fhir2/FhirConstants.java @@ -50,7 +50,7 @@ public class FhirConstants { + "/condition-ver-status"; public static final String CLINICAL_FINDINGS_SYSTEM_URI = HL7_FHIR_CODE_SYSTEM_PREFIX + "/clinical-findings"; - + public static final String TASK_STATUS_VALUE_SET_URI = "http://hl7.org/fhir/task-status"; public static final String OBSERVATION_REFERENCE_RANGE_SYSTEM_URI = HL7_FHIR_CODE_SYSTEM_PREFIX @@ -255,6 +255,8 @@ public class FhirConstants { public static final String COMMON_SEARCH_HANDLER = "common.search.handler"; + public static final String HAS_PROPERTY = "_has"; + public static final String ID_PROPERTY = "_id.property"; public static final String LAST_UPDATED_PROPERTY = "_lastUpdated.property"; diff --git a/api/src/main/java/org/openmrs/module/fhir2/api/FhirObservationService.java b/api/src/main/java/org/openmrs/module/fhir2/api/FhirObservationService.java index 857d3dd13f..fd905a0abc 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/api/FhirObservationService.java +++ b/api/src/main/java/org/openmrs/module/fhir2/api/FhirObservationService.java @@ -29,8 +29,8 @@ public interface FhirObservationService extends FhirService { Observation get(@Nonnull String uuid); IBundleProvider searchForObservations(ReferenceAndListParam encounterReference, ReferenceAndListParam patientReference, - ReferenceAndListParam hasMemberReference, TokenAndListParam valueConcept, DateRangeParam valueDateParam, - QuantityAndListParam valueQuantityParam, StringAndListParam valueStringParam, DateRangeParam date, - TokenAndListParam code, TokenAndListParam category, TokenAndListParam id, DateRangeParam lastUpdated, - SortSpec sort, HashSet includes, HashSet revIncludes); + ReferenceAndListParam hasMemberReference, ReferenceAndListParam basedOnReference, TokenAndListParam valueConcept, + DateRangeParam valueDateParam, QuantityAndListParam valueQuantityParam, StringAndListParam valueStringParam, + DateRangeParam date, TokenAndListParam code, TokenAndListParam category, TokenAndListParam id, + DateRangeParam lastUpdated, SortSpec sort, HashSet includes, HashSet revIncludes); } diff --git a/api/src/main/java/org/openmrs/module/fhir2/api/FhirServiceRequestService.java b/api/src/main/java/org/openmrs/module/fhir2/api/FhirServiceRequestService.java index c4fa4ad11c..1827bc9b9a 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/api/FhirServiceRequestService.java +++ b/api/src/main/java/org/openmrs/module/fhir2/api/FhirServiceRequestService.java @@ -14,6 +14,7 @@ import ca.uhn.fhir.model.api.Include; import ca.uhn.fhir.rest.api.server.IBundleProvider; import ca.uhn.fhir.rest.param.DateRangeParam; +import ca.uhn.fhir.rest.param.HasAndListParam; import ca.uhn.fhir.rest.param.ReferenceAndListParam; import ca.uhn.fhir.rest.param.TokenAndListParam; import org.hl7.fhir.r4.model.ServiceRequest; @@ -22,5 +23,5 @@ public interface FhirServiceRequestService extends FhirService { IBundleProvider searchForServiceRequests(ReferenceAndListParam patientReference, TokenAndListParam code, ReferenceAndListParam encounterReference, ReferenceAndListParam participantReference, DateRangeParam occurrence, - TokenAndListParam uuid, DateRangeParam lastUpdated, HashSet includes); + TokenAndListParam uuid, DateRangeParam lastUpdated, HasAndListParam has, HashSet includes); } diff --git a/api/src/main/java/org/openmrs/module/fhir2/api/dao/impl/BaseDao.java b/api/src/main/java/org/openmrs/module/fhir2/api/dao/impl/BaseDao.java index 9d64ccfaca..7a8c95ec16 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/api/dao/impl/BaseDao.java +++ b/api/src/main/java/org/openmrs/module/fhir2/api/dao/impl/BaseDao.java @@ -52,13 +52,17 @@ import java.util.stream.Stream; import java.util.stream.StreamSupport; +import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.model.api.IQueryParameterAnd; import ca.uhn.fhir.model.api.IQueryParameterOr; import ca.uhn.fhir.model.api.IQueryParameterType; +import ca.uhn.fhir.rest.api.QualifiedParamList; import ca.uhn.fhir.rest.api.SortOrderEnum; import ca.uhn.fhir.rest.api.SortSpec; import ca.uhn.fhir.rest.param.DateParam; import ca.uhn.fhir.rest.param.DateRangeParam; +import ca.uhn.fhir.rest.param.HasAndListParam; +import ca.uhn.fhir.rest.param.HasParam; import ca.uhn.fhir.rest.param.ParamPrefixEnum; import ca.uhn.fhir.rest.param.QuantityAndListParam; import ca.uhn.fhir.rest.param.QuantityParam; @@ -82,6 +86,7 @@ import org.hibernate.internal.CriteriaImpl; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.r4.model.Location; +import org.hl7.fhir.r4.model.Observation; import org.hl7.fhir.r4.model.Patient; import org.hl7.fhir.r4.model.Practitioner; import org.hl7.fhir.r4.model.codesystems.AdministrativeGender; @@ -90,6 +95,7 @@ import org.openmrs.module.fhir2.api.util.LocalDateTimeFactory; import org.openmrs.module.fhir2.model.FhirConceptSource; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; /** *

@@ -171,6 +177,10 @@ public abstract class BaseDao { @Autowired private LocalDateTimeFactory localDateTimeFactory; + @Autowired + @Qualifier("fhirR4") + private FhirContext fhirContext; + /** * Converts an {@link Iterable} to a {@link Stream} * @@ -443,6 +453,49 @@ protected Optional handleDate(String propertyName, DateParam datePara return Optional.empty(); } + /** + * A handler for a {@link HasParam} + * + * @param propertyName the name of the property in the query to use + * @param hasParam the {@link HasParam} to handle + * @return a {@link Criterion} to be added to the query for the indicate has param + */ + protected Optional handleHas(String propertyName, HasParam hasParam) { + if (hasParam == null) { + return Optional.empty(); + } + ArrayList orValues = new ArrayList<>(); + String targetResourceType = null; + String paramReference = null; + String parameterName = null; + + String paramName = null; + targetResourceType = hasParam.getTargetResourceType(); + + if (targetResourceType.getClass().equals(Observation.class)) { + paramReference = hasParam.getReferenceFieldName(); + parameterName = hasParam.getParameterName(); + paramName = parameterName.replaceAll("\\..*", ""); + hasParam = new HasParam(targetResourceType, paramReference, parameterName, hasParam.getParameterValue()); + orValues.add(hasParam); + orValues.add( + (IQueryParameterType) QualifiedParamList.singleton(null, hasParam.getValueAsQueryToken(fhirContext))); + } + String qualifier = paramName.substring(4); + hasParam.setValueAsQueryToken(fhirContext, FhirConstants.HAS_PROPERTY, qualifier, + hasParam.getValueAsQueryToken(fhirContext)); + orValues.add(hasParam); + return Optional.of(eq(propertyName, orValues)); + } + + protected Optional handleHasParam(@Nonnull String propertyName, HasAndListParam hasAndListParam) { + if (hasAndListParam == null) { + return Optional.empty(); + } + + return handleAndListParam(hasAndListParam, hasParam -> handleHas(propertyName, hasParam)); + } + protected Optional handleQuantity(String propertyName, QuantityParam quantityParam) { if (quantityParam == null) { return Optional.empty(); diff --git a/api/src/main/java/org/openmrs/module/fhir2/api/dao/impl/FhirObservationDaoImpl.java b/api/src/main/java/org/openmrs/module/fhir2/api/dao/impl/FhirObservationDaoImpl.java index e22b6f30e0..80c8be778e 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/api/dao/impl/FhirObservationDaoImpl.java +++ b/api/src/main/java/org/openmrs/module/fhir2/api/dao/impl/FhirObservationDaoImpl.java @@ -9,15 +9,19 @@ */ package org.openmrs.module.fhir2.api.dao.impl; +import static org.hibernate.criterion.Restrictions.and; import static org.hibernate.criterion.Restrictions.eq; import javax.annotation.Nonnull; +import java.util.ArrayList; +import java.util.List; import java.util.Optional; import ca.uhn.fhir.rest.param.DateRangeParam; import ca.uhn.fhir.rest.param.QuantityAndListParam; import ca.uhn.fhir.rest.param.ReferenceAndListParam; +import ca.uhn.fhir.rest.param.ReferenceParam; import ca.uhn.fhir.rest.param.StringAndListParam; import ca.uhn.fhir.rest.param.TokenAndListParam; import ca.uhn.fhir.rest.param.TokenParam; @@ -59,6 +63,10 @@ protected void setupSearchParams(Criteria criteria, SearchParameterMap theParams entry.getValue() .forEach(category -> handleConceptClass(criteria, (TokenAndListParam) category.getParam())); break; + case FhirConstants.BASED_ON_REFERENCE_SEARCH_HANDLER: + entry.getValue().forEach(param -> handleReference(criteria, (ReferenceAndListParam) param.getParam(), + "basedOnReferences", "bo")); + break; case FhirConstants.VALUE_CODED_SEARCH_HANDLER: entry.getValue().forEach( valueCoded -> handleValueCodedConcept(criteria, (TokenAndListParam) valueCoded.getParam())); @@ -71,6 +79,7 @@ protected void setupSearchParams(Criteria criteria, SearchParameterMap theParams entry.getValue().forEach(hasMemberReference -> handleHasMemberReference(criteria, (ReferenceAndListParam) hasMemberReference.getParam())); break; + case FhirConstants.QUANTITY_SEARCH_HANDLER: entry.getValue().forEach( quantity -> handleQuantity(quantity.getPropertyName(), (QuantityAndListParam) quantity.getParam()) @@ -160,6 +169,27 @@ private void handleValueCodedConcept(Criteria criteria, TokenAndListParam valueC } } + private Boolean validReferenceParam(ReferenceParam ref) { + return (ref != null && ref.getIdPart() != null && ref.getResourceType() != null); + } + + private void handleReference(Criteria criteria, ReferenceAndListParam reference, String property, String alias) { + handleAndListParam(reference, param -> { + if (validReferenceParam(param)) { + if (lacksAlias(criteria, alias)) { + criteria.createAlias(property, alias); + } + + List> criterionList = new ArrayList<>(); + criterionList.add(Optional.of(eq(String.format("%s.reference", alias), param.getIdPart()))); + criterionList.add(Optional.of(eq(String.format("%s.type", alias), param.getResourceType()))); + return Optional.of(and(toCriteriaArray(criterionList))); + } + + return Optional.empty(); + }).ifPresent(criteria::add); + } + @Override protected String paramToProp(@Nonnull String paramName) { if (Observation.SP_DATE.equals(paramName)) { 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 8a0fca6992..e05f36ff92 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 @@ -15,7 +15,9 @@ import java.util.Optional; import java.util.stream.Stream; +import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.rest.param.DateRangeParam; +import ca.uhn.fhir.rest.param.HasAndListParam; import ca.uhn.fhir.rest.param.ReferenceAndListParam; import ca.uhn.fhir.rest.param.TokenAndListParam; import lombok.AccessLevel; @@ -26,12 +28,18 @@ import org.openmrs.module.fhir2.FhirConstants; import org.openmrs.module.fhir2.api.dao.FhirServiceRequestDao; import org.openmrs.module.fhir2.api.search.param.SearchParameterMap; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; @Component @Setter(AccessLevel.PACKAGE) public class FhirServiceRequestDaoImpl extends BaseFhirDao implements FhirServiceRequestDao { + @Autowired + @Qualifier("fhirR4") + private FhirContext fhirContext; + @Override protected void setupSearchParams(Criteria criteria, SearchParameterMap theParams) { theParams.getParameters().forEach(entry -> { @@ -51,6 +59,10 @@ protected void setupSearchParams(Criteria criteria, SearchParameterMap theParams entry.getValue().forEach(participantReference -> handleProviderReference(criteria, (ReferenceAndListParam) participantReference.getParam())); break; + case FhirConstants.HAS_PROPERTY: + entry.getValue().forEach(hasParameter -> handleHasParam(hasParameter.getPropertyName(), + (HasAndListParam) hasParameter.getParam()).ifPresent(criteria::add)); + break; case FhirConstants.DATE_RANGE_SEARCH_HANDLER: entry.getValue().forEach(dateRangeParam -> handleDateRange((DateRangeParam) dateRangeParam.getParam()) .ifPresent(criteria::add)); diff --git a/api/src/main/java/org/openmrs/module/fhir2/api/impl/FhirObservationServiceImpl.java b/api/src/main/java/org/openmrs/module/fhir2/api/impl/FhirObservationServiceImpl.java index 3740690082..06bd45d60b 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/api/impl/FhirObservationServiceImpl.java +++ b/api/src/main/java/org/openmrs/module/fhir2/api/impl/FhirObservationServiceImpl.java @@ -56,10 +56,11 @@ public class FhirObservationServiceImpl extends BaseFhirService includes, HashSet revIncludes) { + ReferenceAndListParam patientReference, ReferenceAndListParam hasMemberReference, + ReferenceAndListParam basedOnReference, TokenAndListParam valueConcept, DateRangeParam valueDateParam, + QuantityAndListParam valueQuantityParam, StringAndListParam valueStringParam, DateRangeParam date, + TokenAndListParam code, TokenAndListParam category, TokenAndListParam id, DateRangeParam lastUpdated, + SortSpec sort, HashSet includes, HashSet revIncludes) { SearchParameterMap theParams = new SearchParameterMap() .addParameter(FhirConstants.ENCOUNTER_REFERENCE_SEARCH_HANDLER, encounterReference) @@ -68,6 +69,7 @@ public IBundleProvider searchForObservations(ReferenceAndListParam encounterRefe .addParameter(FhirConstants.CATEGORY_SEARCH_HANDLER, category) .addParameter(FhirConstants.VALUE_CODED_SEARCH_HANDLER, valueConcept) .addParameter(FhirConstants.HAS_MEMBER_SEARCH_HANDLER, hasMemberReference) + .addParameter(FhirConstants.BASED_ON_REFERENCE_SEARCH_HANDLER, basedOnReference) .addParameter(FhirConstants.VALUE_STRING_SEARCH_HANDLER, "valueText", valueStringParam) .addParameter(FhirConstants.QUANTITY_SEARCH_HANDLER, "valueNumeric", valueQuantityParam) .addParameter(FhirConstants.DATE_RANGE_SEARCH_HANDLER, "obsDatetime", date) diff --git a/api/src/main/java/org/openmrs/module/fhir2/api/impl/FhirServiceRequestServiceImpl.java b/api/src/main/java/org/openmrs/module/fhir2/api/impl/FhirServiceRequestServiceImpl.java index 2f810da2b2..a2dd8a1596 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/api/impl/FhirServiceRequestServiceImpl.java +++ b/api/src/main/java/org/openmrs/module/fhir2/api/impl/FhirServiceRequestServiceImpl.java @@ -14,6 +14,7 @@ import ca.uhn.fhir.model.api.Include; import ca.uhn.fhir.rest.api.server.IBundleProvider; import ca.uhn.fhir.rest.param.DateRangeParam; +import ca.uhn.fhir.rest.param.HasAndListParam; import ca.uhn.fhir.rest.param.ReferenceAndListParam; import ca.uhn.fhir.rest.param.TokenAndListParam; import lombok.AccessLevel; @@ -53,11 +54,12 @@ public class FhirServiceRequestServiceImpl extends BaseFhirService includes) { + TokenAndListParam uuid, DateRangeParam lastUpdated, HasAndListParam has, HashSet includes) { SearchParameterMap theParams = new SearchParameterMap() .addParameter(FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER, patientReference) - .addParameter(FhirConstants.CODED_SEARCH_HANDLER, code) + .addParameter(FhirConstants.CODED_SEARCH_HANDLER, code) + .addParameter(FhirConstants.HAS_PROPERTY, has) .addParameter(FhirConstants.ENCOUNTER_REFERENCE_SEARCH_HANDLER, encounterReference) .addParameter(FhirConstants.PARTICIPANT_REFERENCE_SEARCH_HANDLER, participantReference) .addParameter(FhirConstants.DATE_RANGE_SEARCH_HANDLER, occurrence) diff --git a/api/src/main/java/org/openmrs/module/fhir2/api/search/SearchQueryInclude.java b/api/src/main/java/org/openmrs/module/fhir2/api/search/SearchQueryInclude.java index d4afa5dde3..62fa2975c9 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/api/search/SearchQueryInclude.java +++ b/api/src/main/java/org/openmrs/module/fhir2/api/search/SearchQueryInclude.java @@ -210,7 +210,7 @@ private IBundleProvider handleObservationReverseInclude(ReferenceAndListParam pa switch (targetType) { case FhirConstants.OBSERVATION: return observationService.searchForObservations(null, null, params, null, null, null, null, null, null, null, - null, null, null, null, null); + null, null, null, null, null, null); case FhirConstants.DIAGNOSTIC_REPORT: return diagnosticReportService.searchForDiagnosticReports(null, null, null, null, params, null, null, null, null); @@ -228,7 +228,8 @@ private IBundleProvider handlePractitionerReverseInclude(ReferenceAndListParam p null); case FhirConstants.PROCEDURE_REQUEST: case FhirConstants.SERVICE_REQUEST: - return serviceRequestService.searchForServiceRequests(null, null, null, params, null, null, null, null); + return serviceRequestService.searchForServiceRequests(null, null, null, params, null, null, null, null, + null); } return null; @@ -238,7 +239,7 @@ private IBundleProvider handleEncounterReverseInclude(ReferenceAndListParam para switch (targetType) { case FhirConstants.OBSERVATION: return observationService.searchForObservations(params, null, null, null, null, null, null, null, null, null, - null, null, null, null, null); + null, null, null, null, null, null); case FhirConstants.DIAGNOSTIC_REPORT: return diagnosticReportService.searchForDiagnosticReports(params, null, null, null, null, null, null, null, null); @@ -247,7 +248,8 @@ private IBundleProvider handleEncounterReverseInclude(ReferenceAndListParam para null); case FhirConstants.PROCEDURE_REQUEST: case FhirConstants.SERVICE_REQUEST: - return serviceRequestService.searchForServiceRequests(null, null, params, null, null, null, null, null); + return serviceRequestService.searchForServiceRequests(null, null, params, null, null, null, null, null, + null); } return null; @@ -267,7 +269,7 @@ private IBundleProvider handlePatientReverseInclude(ReferenceAndListParam params switch (targetType) { case FhirConstants.OBSERVATION: return observationService.searchForObservations(null, params, null, null, null, null, null, null, null, null, - null, null, null, null, null); + null, null, null, null, null, null); case FhirConstants.DIAGNOSTIC_REPORT: return diagnosticReportService.searchForDiagnosticReports(null, params, null, null, null, null, null, null, null); @@ -281,7 +283,8 @@ private IBundleProvider handlePatientReverseInclude(ReferenceAndListParam params null); case FhirConstants.SERVICE_REQUEST: case FhirConstants.PROCEDURE_REQUEST: - return serviceRequestService.searchForServiceRequests(params, null, null, null, null, null, null, null); + return serviceRequestService.searchForServiceRequests(params, null, null, null, null, null, null, null, + null); } return null; diff --git a/api/src/main/java/org/openmrs/module/fhir2/providers/r3/ObservationFhirResourceProvider.java b/api/src/main/java/org/openmrs/module/fhir2/providers/r3/ObservationFhirResourceProvider.java index 23083f6fa3..370070c982 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/providers/r3/ObservationFhirResourceProvider.java +++ b/api/src/main/java/org/openmrs/module/fhir2/providers/r3/ObservationFhirResourceProvider.java @@ -46,6 +46,7 @@ import org.hl7.fhir.dstu3.model.Patient; import org.hl7.fhir.dstu3.model.Resource; import org.hl7.fhir.instance.model.api.IBaseResource; +import org.hl7.fhir.r4.model.ServiceRequest; import org.openmrs.module.fhir2.api.FhirObservationService; import org.openmrs.module.fhir2.api.search.SearchQueryBundleProviderR3Wrapper; import org.openmrs.module.fhir2.providers.util.FhirProviderUtils; @@ -112,6 +113,8 @@ public IBundleProvider searchObservations( Patient.SP_FAMILY, Patient.SP_NAME }, targetTypes = Patient.class) ReferenceAndListParam patientParam, @OptionalParam(name = Observation.SP_RELATED_TYPE, chainWhitelist = { "", Observation.SP_CODE }, targetTypes = Observation.class) ReferenceAndListParam hasMemberReference, + @OptionalParam(name = Observation.SP_BASED_ON, chainWhitelist = { "", + ServiceRequest.SP_IDENTIFIER }, targetTypes = ServiceRequest.class) ReferenceAndListParam basedOnReference, @OptionalParam(name = Observation.SP_VALUE_CONCEPT) TokenAndListParam valueConcept, @OptionalParam(name = Observation.SP_VALUE_DATE) DateRangeParam valueDateParam, @OptionalParam(name = Observation.SP_VALUE_QUANTITY) QuantityAndListParam valueQuantityParam, @@ -138,8 +141,8 @@ public IBundleProvider searchObservations( } return new SearchQueryBundleProviderR3Wrapper(observationService.searchForObservations(encounterReference, - patientReference, hasMemberReference, valueConcept, valueDateParam, valueQuantityParam, valueStringParam, date, - code, category, id, lastUpdated, sort, includes, revIncludes)); + patientReference, basedOnReference, hasMemberReference, valueConcept, valueDateParam, valueQuantityParam, + valueStringParam, date, code, category, id, lastUpdated, sort, includes, revIncludes)); } } diff --git a/api/src/main/java/org/openmrs/module/fhir2/providers/r3/ProcedureRequestFhirResourceProvider.java b/api/src/main/java/org/openmrs/module/fhir2/providers/r3/ProcedureRequestFhirResourceProvider.java index e88a29a809..0850e546fc 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/providers/r3/ProcedureRequestFhirResourceProvider.java +++ b/api/src/main/java/org/openmrs/module/fhir2/providers/r3/ProcedureRequestFhirResourceProvider.java @@ -23,6 +23,7 @@ import ca.uhn.fhir.rest.api.MethodOutcome; import ca.uhn.fhir.rest.api.server.IBundleProvider; import ca.uhn.fhir.rest.param.DateRangeParam; +import ca.uhn.fhir.rest.param.HasAndListParam; import ca.uhn.fhir.rest.param.ReferenceAndListParam; import ca.uhn.fhir.rest.param.TokenAndListParam; import ca.uhn.fhir.rest.server.IResourceProvider; @@ -114,6 +115,7 @@ public IBundleProvider searchForProcedureRequests( @OptionalParam(name = ProcedureRequest.SP_OCCURRENCE) DateRangeParam occurrence, @OptionalParam(name = ProcedureRequest.SP_RES_ID) TokenAndListParam uuid, @OptionalParam(name = "_lastUpdated") DateRangeParam lastUpdated, + @OptionalParam(name = "_has") HasAndListParam has, @IncludeParam(allow = { "ProcedureRequest:" + ProcedureRequest.SP_PATIENT, "ProcedureRequest:" + ProcedureRequest.SP_REQUESTER, "ProcedureRequest:" + ProcedureRequest.SP_ENCOUNTER }) HashSet includes) { @@ -126,6 +128,6 @@ public IBundleProvider searchForProcedureRequests( } return new SearchQueryBundleProviderR3Wrapper(serviceRequestService.searchForServiceRequests(patientReference, code, - encounterReference, participantReference, occurrence, uuid, lastUpdated, includes)); + encounterReference, participantReference, occurrence, uuid, lastUpdated, has, includes)); } } diff --git a/api/src/main/java/org/openmrs/module/fhir2/providers/r4/ObservationFhirResourceProvider.java b/api/src/main/java/org/openmrs/module/fhir2/providers/r4/ObservationFhirResourceProvider.java index 05bc14e142..1bd779bcf0 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/providers/r4/ObservationFhirResourceProvider.java +++ b/api/src/main/java/org/openmrs/module/fhir2/providers/r4/ObservationFhirResourceProvider.java @@ -46,6 +46,7 @@ import org.hl7.fhir.r4.model.OperationOutcome; import org.hl7.fhir.r4.model.Patient; import org.hl7.fhir.r4.model.Resource; +import org.hl7.fhir.r4.model.ServiceRequest; import org.openmrs.module.fhir2.api.FhirObservationService; import org.openmrs.module.fhir2.providers.util.FhirProviderUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -108,6 +109,8 @@ public IBundleProvider searchObservations( Patient.SP_NAME }, targetTypes = Patient.class) ReferenceAndListParam patientReference, @OptionalParam(name = Observation.SP_HAS_MEMBER, chainWhitelist = { "", Observation.SP_CODE }, targetTypes = Observation.class) ReferenceAndListParam hasMemberReference, + @OptionalParam(name = Observation.SP_BASED_ON, chainWhitelist = { "", + ServiceRequest.SP_IDENTIFIER }, targetTypes = ServiceRequest.class) ReferenceAndListParam basedOnReference, @OptionalParam(name = Observation.SP_VALUE_CONCEPT) TokenAndListParam valueConcept, @OptionalParam(name = Observation.SP_VALUE_DATE) DateRangeParam valueDateParam, @OptionalParam(name = Observation.SP_VALUE_QUANTITY) QuantityAndListParam valueQuantityParam, @@ -136,7 +139,7 @@ public IBundleProvider searchObservations( } return observationService.searchForObservations(encounterReference, patientReference, hasMemberReference, - valueConcept, valueDateParam, valueQuantityParam, valueStringParam, date, code, category, id, lastUpdated, sort, - includes, revIncludes); + basedOnReference, valueConcept, valueDateParam, valueQuantityParam, valueStringParam, date, code, category, id, + lastUpdated, sort, includes, revIncludes); } } diff --git a/api/src/main/java/org/openmrs/module/fhir2/providers/r4/ServiceRequestFhirResourceProvider.java b/api/src/main/java/org/openmrs/module/fhir2/providers/r4/ServiceRequestFhirResourceProvider.java index 29fd9b14a7..29a179707e 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/providers/r4/ServiceRequestFhirResourceProvider.java +++ b/api/src/main/java/org/openmrs/module/fhir2/providers/r4/ServiceRequestFhirResourceProvider.java @@ -23,6 +23,7 @@ import ca.uhn.fhir.rest.api.MethodOutcome; import ca.uhn.fhir.rest.api.server.IBundleProvider; import ca.uhn.fhir.rest.param.DateRangeParam; +import ca.uhn.fhir.rest.param.HasAndListParam; import ca.uhn.fhir.rest.param.ReferenceAndListParam; import ca.uhn.fhir.rest.param.TokenAndListParam; import ca.uhn.fhir.rest.server.IResourceProvider; @@ -108,8 +109,10 @@ public IBundleProvider searchForServiceRequests( Practitioner.SP_GIVEN, Practitioner.SP_FAMILY, Practitioner.SP_NAME }, targetTypes = Practitioner.class) ReferenceAndListParam participantReference, @OptionalParam(name = ServiceRequest.SP_OCCURRENCE) DateRangeParam occurrence, + @OptionalParam(name = ServiceRequest.SP_RES_ID) TokenAndListParam uuid, @OptionalParam(name = "_lastUpdated") DateRangeParam lastUpdated, + @OptionalParam(name = "_has") HasAndListParam has, @IncludeParam(allow = { "ServiceRequest:" + ServiceRequest.SP_PATIENT, "ServiceRequest:" + ServiceRequest.SP_REQUESTER, "ServiceRequest:" + ServiceRequest.SP_ENCOUNTER }) HashSet includes) { @@ -122,6 +125,6 @@ public IBundleProvider searchForServiceRequests( } return serviceRequestService.searchForServiceRequests(patientReference, code, encounterReference, - participantReference, occurrence, uuid, lastUpdated, includes); + participantReference, occurrence, uuid, lastUpdated, has, includes); } } diff --git a/api/src/test/java/org/openmrs/module/fhir2/api/impl/FhirObservationServiceImplTest.java b/api/src/test/java/org/openmrs/module/fhir2/api/impl/FhirObservationServiceImplTest.java index ec07c49996..b11b6b26c9 100644 --- a/api/src/test/java/org/openmrs/module/fhir2/api/impl/FhirObservationServiceImplTest.java +++ b/api/src/test/java/org/openmrs/module/fhir2/api/impl/FhirObservationServiceImplTest.java @@ -126,7 +126,7 @@ public void searchForObservations_shouldReturnObservationsByParameters() { when(translator.toFhirResource(obs)).thenReturn(observation); IBundleProvider results = fhirObservationService.searchForObservations(null, patientReference, null, null, null, - null, null, null, null, null, null, null, null, null, null); + null, null, null, null, null, null, null, null, null, null, null); assertThat(results, notNullValue()); assertThat(results.size(), equalTo(1)); diff --git a/api/src/test/java/org/openmrs/module/fhir2/api/impl/FhirServiceRequestServiceImplTest.java b/api/src/test/java/org/openmrs/module/fhir2/api/impl/FhirServiceRequestServiceImplTest.java index c95a10e6e0..04c468d4a9 100644 --- a/api/src/test/java/org/openmrs/module/fhir2/api/impl/FhirServiceRequestServiceImplTest.java +++ b/api/src/test/java/org/openmrs/module/fhir2/api/impl/FhirServiceRequestServiceImplTest.java @@ -36,6 +36,9 @@ import ca.uhn.fhir.model.api.Include; import ca.uhn.fhir.rest.api.server.IBundleProvider; import ca.uhn.fhir.rest.param.DateRangeParam; +import ca.uhn.fhir.rest.param.HasAndListParam; +import ca.uhn.fhir.rest.param.HasOrListParam; +import ca.uhn.fhir.rest.param.HasParam; import ca.uhn.fhir.rest.param.ReferenceAndListParam; import ca.uhn.fhir.rest.param.ReferenceOrListParam; import ca.uhn.fhir.rest.param.ReferenceParam; @@ -156,7 +159,7 @@ public void searchForServiceRequest_shouldReturnCollectionOfServiceRequestByPati when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet()); IBundleProvider results = serviceRequestService.searchForServiceRequests(patientReference, null, null, null, null, - null, null, null); + null, null, null, null); List resultList = get(results); @@ -180,7 +183,7 @@ public void searchForServiceRequest_shouldReturnCollectionOfServiceRequestByCode when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet()); IBundleProvider results = serviceRequestService.searchForServiceRequests(null, code, null, null, null, null, null, - null); + null, null); List resultList = get(results); @@ -204,8 +207,8 @@ public void searchForServiceRequest_shouldReturnCollectionOfServiceRequestByEnco new SearchQueryBundleProvider<>(theParams, dao, translator, globalPropertyService, searchQueryInclude)); when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet()); - IBundleProvider results = serviceRequestService.searchForServiceRequests(null, null, encounterReference, null, null, - null, null, null); + IBundleProvider results = serviceRequestService.searchForServiceRequests(null, null, null, encounterReference, null, + null, null, null, null); List resultList = get(results); @@ -230,7 +233,7 @@ public void searchForServiceRequest_shouldReturnCollectionOfServiceRequestByRequ when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet()); IBundleProvider results = serviceRequestService.searchForServiceRequests(null, null, null, participantReference, - null, null, null, null); + null, null, null, null, null); List resultList = get(results); @@ -254,7 +257,7 @@ public void searchForServiceRequest_shouldReturnCollectionOfServiceRequestByOccu when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet()); IBundleProvider results = serviceRequestService.searchForServiceRequests(null, null, null, null, occurrence, null, - null, null); + null, null, null); List resultList = get(results); @@ -278,7 +281,7 @@ public void searchForServiceRequest_shouldReturnCollectionOfServiceRequestByUUID when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet()); IBundleProvider results = serviceRequestService.searchForServiceRequests(null, null, null, null, null, uuid, null, - null); + null, null); List resultList = get(results); @@ -302,7 +305,7 @@ public void searchForServiceRequest_shouldReturnCollectionOfServiceRequestByLast when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet()); IBundleProvider results = serviceRequestService.searchForServiceRequests(null, null, null, null, null, null, - lastUpdated, null); + lastUpdated, null, null); List resultList = get(results); @@ -326,7 +329,7 @@ public void searchForPeople_shouldAddRelatedResourcesWhenIncluded() { when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.singleton(new Patient())); IBundleProvider results = serviceRequestService.searchForServiceRequests(null, null, null, null, null, null, null, - includes); + null, includes); List resultList = get(results); @@ -336,6 +339,29 @@ public void searchForPeople_shouldAddRelatedResourcesWhenIncluded() { assertThat(resultList, hasItem(is(instanceOf(Patient.class)))); } + @Test + public void searchForServiceRequest_shouldReturnCollectionOfServiceRequestByHasParameter() { + HasParam hasParam = new HasParam("Observation", "based-on", "category", ":not=laboratory"); + HasOrListParam hasOrListParam = new HasOrListParam(); + HasAndListParam uuid = new HasAndListParam().addAnd(hasOrListParam.add(hasParam)); + SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.HAS_PROPERTY, hasParam); + + when(dao.getSearchResults(any(), any())).thenReturn(Collections.singletonList(order)); + when(dao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(SERVICE_REQUEST_UUID)); + when(translator.toFhirResource(order)).thenReturn(fhirServiceRequest); + when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn( + new SearchQueryBundleProvider<>(theParams, dao, translator, globalPropertyService, searchQueryInclude)); + when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet()); + + IBundleProvider results = serviceRequestService.searchForServiceRequests(null, null, null, null, null, null, null, + uuid, null); + List resultList = get(results); + + assertThat(results, notNullValue()); + assertThat(resultList, not(empty())); + assertThat(resultList.size(), equalTo(1)); + } + @Test public void searchForPeople_shouldAddRelatedResourcesWhenIncludedR3() { HashSet includes = new HashSet<>(); @@ -351,7 +377,7 @@ public void searchForPeople_shouldAddRelatedResourcesWhenIncludedR3() { when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.singleton(new Patient())); IBundleProvider results = serviceRequestService.searchForServiceRequests(null, null, null, null, null, null, null, - includes); + null, includes); List resultList = get(results); @@ -375,7 +401,7 @@ public void searchForPeople_shouldNotAddRelatedResourcesForEmptyInclude() { when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet()); IBundleProvider results = serviceRequestService.searchForServiceRequests(null, null, null, null, null, null, null, - includes); + null, includes); List resultList = get(results); diff --git a/api/src/test/java/org/openmrs/module/fhir2/api/search/ObservationSearchQueryTest.java b/api/src/test/java/org/openmrs/module/fhir2/api/search/ObservationSearchQueryTest.java index d7dfd74f48..120d3bba70 100644 --- a/api/src/test/java/org/openmrs/module/fhir2/api/search/ObservationSearchQueryTest.java +++ b/api/src/test/java/org/openmrs/module/fhir2/api/search/ObservationSearchQueryTest.java @@ -104,6 +104,8 @@ public class ObservationSearchQueryTest extends BaseModuleContextSensitiveTest { private static final String PATIENT_UUID = "5946f880-b197-400b-9caa-a3c661d23041"; + private static final String SERVICE_REQUEST_UUID = "7d96f25c-4949-4f72-9931-d808fbc226de"; + private static final String PATIENT_WRONG_UUID = "c2299800-cca9-11e0-9572-abcdef0c9a66"; private static final String PATIENT_GIVEN_NAME = "Collet"; @@ -308,6 +310,25 @@ public void searchForObs_shouldReturnObsByPatientUuid() { assertThat(resultList.size(), equalTo(10)); } + @Test + public void searchForObs_shouldReturnObsBasedOnServiceRequestUuid() { + ReferenceAndListParam serviceRequestReference = new ReferenceAndListParam() + .addAnd(new ReferenceOrListParam().add(new ReferenceParam().setValue(SERVICE_REQUEST_UUID))); + + SearchParameterMap theParams = new SearchParameterMap(); + theParams.addParameter(FhirConstants.BASED_ON_REFERENCE_SEARCH_HANDLER, serviceRequestReference); + + IBundleProvider results = search(theParams); + assertThat(results.size(), equalTo(21)); + + assertThat(results, notNullValue()); + + List resultList = get(results); + + assertThat(resultList, not(empty())); + assertThat(resultList.size(), equalTo(10)); + } + @Test public void searchForObs_shouldSearchForObsByMultiplePatientUuidOr() { ReferenceAndListParam referenceParam = new ReferenceAndListParam(); diff --git a/api/src/test/java/org/openmrs/module/fhir2/providers/r3/ObservationFhirResourceProviderTest.java b/api/src/test/java/org/openmrs/module/fhir2/providers/r3/ObservationFhirResourceProviderTest.java index c537ef9925..9f3ba515d7 100644 --- a/api/src/test/java/org/openmrs/module/fhir2/providers/r3/ObservationFhirResourceProviderTest.java +++ b/api/src/test/java/org/openmrs/module/fhir2/providers/r3/ObservationFhirResourceProviderTest.java @@ -55,6 +55,7 @@ import org.hl7.fhir.dstu3.model.Resource; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.r4.model.DiagnosticReport; +import org.hl7.fhir.r4.model.ServiceRequest; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -126,7 +127,7 @@ public void getObservationWithWrongUuid_shouldThrowResourceNotFoundException() { @Test public void searchObservations_shouldReturnMatchingObservations() { when(observationService.searchForObservations(any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), - any(), any(), any(), any(), any())) + any(), any(), any(), any(), any(), any())) .thenReturn(new MockIBundleProvider<>(Collections.singletonList(observation), 10, 1)); TokenAndListParam code = new TokenAndListParam(); @@ -135,7 +136,7 @@ public void searchObservations_shouldReturnMatchingObservations() { code.addAnd(codingToken); IBundleProvider results = resourceProvider.searchObservations(null, null, null, null, null, null, null, null, null, - code, null, null, null, null, null, null); + null, code, null, null, null, null, null, null); List resultList = get(results, 1, 5); @@ -149,14 +150,14 @@ public void searchObservations_shouldReturnMatchingObservations() { @Test public void searchObservations_shouldReturnMatchingObservationsWhenPatientParamIsSpecified() { when(observationService.searchForObservations(any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), - any(), any(), any(), any(), any())) + any(), any(), any(), any(), any(), any())) .thenReturn(new MockIBundleProvider<>(Collections.singletonList(observation), 10, 1)); ReferenceAndListParam patientParam = new ReferenceAndListParam(); patientParam.addValue(new ReferenceOrListParam().add(new ReferenceParam().setChain(Patient.SP_NAME))); IBundleProvider results = resourceProvider.searchObservations(null, patientParam, null, null, null, null, null, null, - null, null, null, null, null, null, null, null); + null, null, null, null, null, null, null, null, null); List resultList = get(results, 1, 5); @@ -173,11 +174,11 @@ public void searchObservations_shouldAddRelatedResourcesWhenIncluded() { includes.add(new Include("Observation:patient")); when(observationService.searchForObservations(any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), - any(), any(), any(), any(), any())).thenReturn( + any(), any(), any(), any(), any(), any())).thenReturn( new MockIBundleProvider<>(Arrays.asList(observation, new org.hl7.fhir.r4.model.Patient()), 10, 1)); IBundleProvider results = resourceProvider.searchObservations(null, null, null, null, null, null, null, null, null, - null, null, null, null, null, includes, null); + null, null, null, null, null, null, includes, null); List resultList = get(results, 1, 5); @@ -194,11 +195,11 @@ public void searchObservations_shouldNotAddRelatedResourcesForEmptyInclude() { HashSet includes = new HashSet<>(); when(observationService.searchForObservations(any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), - any(), any(), any(), isNull(), any())) + any(), any(), any(), any(), isNull(), any())) .thenReturn(new MockIBundleProvider<>(Collections.singletonList(observation), 10, 1)); IBundleProvider results = resourceProvider.searchObservations(null, null, null, null, null, null, null, null, null, - null, null, null, null, null, includes, null); + null, null, null, null, null, null, includes, null); List resultList = get(results, 1, 5); @@ -209,17 +210,38 @@ public void searchObservations_shouldNotAddRelatedResourcesForEmptyInclude() { assertThat(resultList.get(0).getIdElement().getIdPart(), equalTo(OBSERVATION_UUID)); } + @Test + public void searchObservations_shouldReturnMatchingObservationsWhenBasedOnParamIsSpecified() { + when(observationService.searchForObservations(any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), + any(), any(), any(), any(), any(), any())) + .thenReturn(new MockIBundleProvider<>(Collections.singletonList(observation), 10, 1)); + + ReferenceAndListParam basedOnParam = new ReferenceAndListParam(); + basedOnParam.addValue(new ReferenceOrListParam().add(new ReferenceParam().setChain(ServiceRequest.SP_IDENTIFIER))); + + IBundleProvider results = resourceProvider.searchObservations(null, null, basedOnParam, null, null, null, null, null, + null, null, null, null, null, null, null, null, null); + + List resultList = get(results, 0, 0); + + assertThat(results, notNullValue()); + assertThat(resultList, hasSize(equalTo(1))); + assertThat(resultList.get(0), notNullValue()); + assertThat(resultList.get(0).fhirType(), equalTo(FhirConstants.OBSERVATION)); + assertThat(resultList.get(0).getIdElement().getIdPart(), equalTo(OBSERVATION_UUID)); + } + @Test public void searchObservations_shouldAddRelatedResourcesWhenReverseIncluded() { HashSet includes = new HashSet<>(); includes.add(new Include("DiagnosticReport:result")); when(observationService.searchForObservations(any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), - any(), any(), any(), any(), any())) + any(), any(), any(), any(), any(), any())) .thenReturn(new MockIBundleProvider<>(Arrays.asList(observation, new DiagnosticReport()), 10, 1)); IBundleProvider results = resourceProvider.searchObservations(null, null, null, null, null, null, null, null, null, - null, null, null, null, null, includes, null); + null, null, null, null, null, null, includes, null); List resultList = get(results, 1, 5); @@ -236,11 +258,11 @@ public void searchObservations_shouldNotAddRelatedResourcesForEmptyReverseInclud HashSet includes = new HashSet<>(); when(observationService.searchForObservations(any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), - any(), any(), any(), isNull(), any())) + any(), any(), any(), any(), isNull(), any())) .thenReturn(new MockIBundleProvider<>(Collections.singletonList(observation), 10, 1)); IBundleProvider results = resourceProvider.searchObservations(null, null, null, null, null, null, null, null, null, - null, null, null, null, null, includes, null); + null, null, null, null, null, null, includes, null); List resultList = get(results, 1, 5); diff --git a/api/src/test/java/org/openmrs/module/fhir2/providers/r3/ProcedureRequestFhirResourceProviderTest.java b/api/src/test/java/org/openmrs/module/fhir2/providers/r3/ProcedureRequestFhirResourceProviderTest.java index ef8af0b1f1..02f4dd135a 100644 --- a/api/src/test/java/org/openmrs/module/fhir2/providers/r3/ProcedureRequestFhirResourceProviderTest.java +++ b/api/src/test/java/org/openmrs/module/fhir2/providers/r3/ProcedureRequestFhirResourceProviderTest.java @@ -135,14 +135,14 @@ public void getServiceRequestByWithWrongId_shouldThrowResourceNotFoundException( @Test public void searchProcedureRequest_shouldReturnMatchingProcedureRequestByCode() { - when(serviceRequestService.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), any())) + when(serviceRequestService.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), any(), any())) .thenReturn( new MockIBundleProvider<>(Collections.singletonList(serviceRequest), PREFERRED_PAGE_SIZE, COUNT)); TokenAndListParam code = new TokenAndListParam().addAnd(new TokenParam(CODE)); IBundleProvider results = resourceProvider.searchForProcedureRequests(null, null, code, null, null, null, null, null, - null); + null, null); List resources = getResources(results); @@ -155,7 +155,7 @@ public void searchProcedureRequest_shouldReturnMatchingProcedureRequestByCode() @Test public void searchProcedureRequest_shouldReturnMatchingProcedureRequestWhenPatientParamIsSpecified() { - when(serviceRequestService.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), any())) + when(serviceRequestService.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), any(), any())) .thenReturn( new MockIBundleProvider<>(Collections.singletonList(serviceRequest), PREFERRED_PAGE_SIZE, COUNT)); @@ -163,7 +163,7 @@ public void searchProcedureRequest_shouldReturnMatchingProcedureRequestWhenPatie new ReferenceOrListParam().add(new ReferenceParam().setValue(PATIENT_GIVEN_NAME).setChain(Patient.SP_NAME))); IBundleProvider results = resourceProvider.searchForProcedureRequests(patientParam, null, null, null, null, null, - null, null, null); + null, null, null, null); List resources = getResources(results); @@ -176,7 +176,7 @@ public void searchProcedureRequest_shouldReturnMatchingProcedureRequestWhenPatie @Test public void searchProcedureRequest_shouldReturnMatchingProcedureRequestWhenSubjectParamIsSpecified() { - when(serviceRequestService.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), any())) + when(serviceRequestService.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), any(), any())) .thenReturn( new MockIBundleProvider<>(Collections.singletonList(serviceRequest), PREFERRED_PAGE_SIZE, COUNT)); @@ -184,7 +184,7 @@ public void searchProcedureRequest_shouldReturnMatchingProcedureRequestWhenSubje new ReferenceOrListParam().add(new ReferenceParam().setValue(PATIENT_GIVEN_NAME).setChain(Patient.SP_NAME))); IBundleProvider results = resourceProvider.searchForProcedureRequests(null, subjectParam, null, null, null, null, - null, null, null); + null, null, null, null); List resources = getResources(results); @@ -197,7 +197,7 @@ public void searchProcedureRequest_shouldReturnMatchingProcedureRequestWhenSubje @Test public void searchProcedureRequest_shouldReturnMatchingProcedureRequestByRequesterParam() { - when(serviceRequestService.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), any())) + when(serviceRequestService.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), any(), any())) .thenReturn( new MockIBundleProvider<>(Collections.singletonList(serviceRequest), PREFERRED_PAGE_SIZE, COUNT)); @@ -205,7 +205,7 @@ public void searchProcedureRequest_shouldReturnMatchingProcedureRequestByRequest .add(new ReferenceParam().setValue(PARTICIPANT_IDENTIFIER).setChain(Practitioner.SP_IDENTIFIER))); IBundleProvider results = resourceProvider.searchForProcedureRequests(null, null, null, null, practitionerParam, - null, null, null, null); + null, null, null, null, null); List resources = getResources(results); @@ -218,14 +218,14 @@ public void searchProcedureRequest_shouldReturnMatchingProcedureRequestByRequest @Test public void searchProcedureRequest_shouldReturnMatchingProcedureRequestByOccurrence() { - when(serviceRequestService.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), any())) + when(serviceRequestService.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), any(), any())) .thenReturn( new MockIBundleProvider<>(Collections.singletonList(serviceRequest), PREFERRED_PAGE_SIZE, COUNT)); DateRangeParam occurrence = new DateRangeParam().setLowerBound(OCCURRENCE).setUpperBound(OCCURRENCE); IBundleProvider results = resourceProvider.searchForProcedureRequests(null, null, null, null, null, occurrence, null, - null, null); + null, null, null); List resources = getResources(results); @@ -238,14 +238,14 @@ public void searchProcedureRequest_shouldReturnMatchingProcedureRequestByOccurre @Test public void searchProcedureRequest_shouldReturnMatchingProcedureRequestByEncounter() { - when(serviceRequestService.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), any())) + when(serviceRequestService.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), any(), any())) .thenReturn(new MockIBundleProvider<>(Collections.singletonList(serviceRequest), 10, 1)); ReferenceAndListParam encounterParam = new ReferenceAndListParam() .addAnd(new ReferenceOrListParam().add(new ReferenceParam().setValue(ENCOUNTER_UUID).setChain(null))); - IBundleProvider results = resourceProvider.searchForProcedureRequests(null, null, null, encounterParam, null, null, - null, null, null); + IBundleProvider results = resourceProvider.searchForProcedureRequests(null, null, null, null, encounterParam, null, + null, null, null, null); List resources = getResources(results); @@ -338,12 +338,12 @@ public void deleteProcedureRequest_shouldThrowResourceNotFoundExceptionWhenIdRef public void searchProcedureRequest_shouldReturnMatchingProcedureRequestWhenUUIDIsSpecified() { TokenAndListParam uuid = new TokenAndListParam().addAnd(new TokenParam(SERVICE_REQUEST_UUID)); - when(serviceRequestService.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), any())) + when(serviceRequestService.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), any(), any())) .thenReturn( new MockIBundleProvider<>(Collections.singletonList(serviceRequest), PREFERRED_PAGE_SIZE, COUNT)); IBundleProvider results = resourceProvider.searchForProcedureRequests(null, null, null, null, null, null, uuid, null, - null); + null, null); List resources = getResources(results); @@ -358,12 +358,12 @@ public void searchProcedureRequest_shouldReturnMatchingProcedureRequestWhenUUIDI public void searchProcedureRequest_shouldReturnMatchingProcedureRequestWhenLastUpdatedIsSpecified() { DateRangeParam lastUpdated = new DateRangeParam().setUpperBound(LAST_UPDATED_DATE).setLowerBound(LAST_UPDATED_DATE); - when(serviceRequestService.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), any())) + when(serviceRequestService.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), any(), any())) .thenReturn( new MockIBundleProvider<>(Collections.singletonList(serviceRequest), PREFERRED_PAGE_SIZE, COUNT)); IBundleProvider results = resourceProvider.searchForProcedureRequests(null, null, null, null, null, null, null, - lastUpdated, null); + lastUpdated, null, null); List resources = getResources(results); @@ -379,12 +379,12 @@ public void searchProcedureRequest_shouldAddRelatedResourcesToResultListWhenIncl HashSet includes = new HashSet<>(); includes.add(new Include("ProcedureRequest:patient")); - when(serviceRequestService.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), + when(serviceRequestService.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), any(), argThat(is(includes)))).thenReturn( new MockIBundleProvider<>(Arrays.asList(serviceRequest, new Patient()), PREFERRED_PAGE_SIZE, COUNT)); IBundleProvider results = resourceProvider.searchForProcedureRequests(null, null, null, null, null, null, null, null, - includes); + null, includes); List resources = getResources(results); @@ -400,12 +400,13 @@ public void searchProcedureRequest_shouldAddRelatedResourcesToResultListWhenIncl public void searchProcedureRequest_shouldNotAddRelatedResourcesToResultListForEmptyIncludes() { HashSet includes = new HashSet<>(); - when(serviceRequestService.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), isNull())) - .thenReturn( - new MockIBundleProvider<>(Collections.singletonList(serviceRequest), PREFERRED_PAGE_SIZE, COUNT)); + when( + serviceRequestService.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), any(), isNull())) + .thenReturn( + new MockIBundleProvider<>(Collections.singletonList(serviceRequest), PREFERRED_PAGE_SIZE, COUNT)); IBundleProvider results = resourceProvider.searchForProcedureRequests(null, null, null, null, null, null, null, null, - includes); + null, includes); List resources = getResources(results); diff --git a/api/src/test/java/org/openmrs/module/fhir2/providers/r4/ObservationFhirResourceProviderTest.java b/api/src/test/java/org/openmrs/module/fhir2/providers/r4/ObservationFhirResourceProviderTest.java index eb767ba7bc..11c9976d01 100644 --- a/api/src/test/java/org/openmrs/module/fhir2/providers/r4/ObservationFhirResourceProviderTest.java +++ b/api/src/test/java/org/openmrs/module/fhir2/providers/r4/ObservationFhirResourceProviderTest.java @@ -45,6 +45,7 @@ import org.hl7.fhir.r4.model.Patient; import org.hl7.fhir.r4.model.Provenance; import org.hl7.fhir.r4.model.Resource; +import org.hl7.fhir.r4.model.ServiceRequest; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -121,7 +122,7 @@ public void getObservationWithWrongUuid_shouldThrowResourceNotFoundException() { @Test public void searchObservations_shouldReturnMatchingObservations() { when(observationService.searchForObservations(any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), - any(), any(), any(), any(), any())) + any(), any(), any(), any(), any(), any())) .thenReturn(new MockIBundleProvider<>(Collections.singletonList(observation), 10, 1)); TokenAndListParam code = new TokenAndListParam(); @@ -129,8 +130,8 @@ public void searchObservations_shouldReturnMatchingObservations() { codingToken.setValue("1000"); code.addAnd(codingToken); - IBundleProvider results = resourceProvider.searchObservations(null, null, null, null, null, null, null, null, code, - null, null, null, null, null, null, null); + IBundleProvider results = resourceProvider.searchObservations(null, null, null, null, null, null, null, null, null, + code, null, null, null, null, null, null, null); List resultList = get(results); @@ -144,14 +145,14 @@ public void searchObservations_shouldReturnMatchingObservations() { @Test public void searchObservations_shouldReturnMatchingObservationsWhenPatientParamIsSpecified() { when(observationService.searchForObservations(any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), - any(), any(), any(), any(), any())) + any(), any(), any(), any(), any(), any())) .thenReturn(new MockIBundleProvider<>(Collections.singletonList(observation), 10, 1)); ReferenceAndListParam patientParam = new ReferenceAndListParam(); patientParam.addValue(new ReferenceOrListParam().add(new ReferenceParam().setChain(Patient.SP_NAME))); IBundleProvider results = resourceProvider.searchObservations(null, null, null, null, null, null, null, null, null, - null, null, null, null, patientParam, null, null); + null, null, null, null, null, patientParam, null, null); List resultList = get(results); @@ -168,11 +169,11 @@ public void searchObservations_shouldAddRelatedResourcesWhenIncluded() { includes.add(new Include("Observation:patient")); when(observationService.searchForObservations(any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), - any(), any(), any(), any(), any())) + any(), any(), any(), any(), any(), any())) .thenReturn(new MockIBundleProvider<>(Arrays.asList(observation, new Patient()), 10, 1)); IBundleProvider results = resourceProvider.searchObservations(null, null, null, null, null, null, null, null, null, - null, null, null, null, null, includes, null); + null, null, null, null, null, null, includes, null); List resultList = get(results); @@ -189,11 +190,11 @@ public void searchObservations_shouldNotAddRelatedResourcesForEmptyInclude() { HashSet includes = new HashSet<>(); when(observationService.searchForObservations(any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), - any(), any(), any(), isNull(), any())) + any(), any(), any(), any(), isNull(), any())) .thenReturn(new MockIBundleProvider<>(Collections.singletonList(observation), 10, 1)); IBundleProvider results = resourceProvider.searchObservations(null, null, null, null, null, null, null, null, null, - null, null, null, null, null, includes, null); + null, null, null, null, null, null, includes, null); List resultList = get(results); @@ -210,11 +211,11 @@ public void searchObservations_shouldAddRelatedResourcesWhenReverseIncluded() { includes.add(new Include("DiagnosticReport:result")); when(observationService.searchForObservations(any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), - any(), any(), any(), any(), any())) + any(), any(), any(), any(), any(), any())) .thenReturn(new MockIBundleProvider<>(Arrays.asList(observation, new DiagnosticReport()), 10, 1)); IBundleProvider results = resourceProvider.searchObservations(null, null, null, null, null, null, null, null, null, - null, null, null, null, null, includes, null); + null, null, null, null, null, null, includes, null); List resultList = get(results); @@ -226,16 +227,37 @@ public void searchObservations_shouldAddRelatedResourcesWhenReverseIncluded() { assertThat(resultList.get(0).getIdElement().getIdPart(), equalTo(OBSERVATION_UUID)); } + @Test + public void searchObservations_shouldReturnMatchingObservationsWhenBasedOnParamIsSpecified() { + when(observationService.searchForObservations(any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), + any(), any(), any(), any(), any(), any())) + .thenReturn(new MockIBundleProvider<>(Collections.singletonList(observation), 10, 1)); + + ReferenceAndListParam basedOnParam = new ReferenceAndListParam(); + basedOnParam.addValue(new ReferenceOrListParam().add(new ReferenceParam().setChain(ServiceRequest.SP_IDENTIFIER))); + + IBundleProvider results = resourceProvider.searchObservations(null, null, null, null, null, null, null, null, null, + null, null, null, null, null, basedOnParam, null, null); + + List resultList = get(results); + + assertThat(results, notNullValue()); + assertThat(resultList, hasSize(equalTo(1))); + assertThat(resultList.get(0), notNullValue()); + assertThat(resultList.get(0).fhirType(), equalTo(FhirConstants.OBSERVATION)); + assertThat(resultList.get(0).getIdElement().getIdPart(), equalTo(OBSERVATION_UUID)); + } + @Test public void searchObservations_shouldNotAddRelatedResourcesForEmptyReverseInclude() { HashSet includes = new HashSet<>(); when(observationService.searchForObservations(any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), - any(), any(), any(), isNull(), any())) + any(), any(), any(), any(), isNull(), any())) .thenReturn(new MockIBundleProvider<>(Collections.singletonList(observation), 10, 1)); IBundleProvider results = resourceProvider.searchObservations(null, null, null, null, null, null, null, null, null, - null, null, null, null, null, includes, null); + null, null, null, null, null, null, includes, null); List resultList = get(results); diff --git a/api/src/test/java/org/openmrs/module/fhir2/providers/r4/ServiceRequestFhirResourceProviderTest.java b/api/src/test/java/org/openmrs/module/fhir2/providers/r4/ServiceRequestFhirResourceProviderTest.java index bec65d2159..c1c762bdf5 100644 --- a/api/src/test/java/org/openmrs/module/fhir2/providers/r4/ServiceRequestFhirResourceProviderTest.java +++ b/api/src/test/java/org/openmrs/module/fhir2/providers/r4/ServiceRequestFhirResourceProviderTest.java @@ -131,14 +131,14 @@ public void getServiceRequestByWithWrongId_shouldThrowResourceNotFoundException( @Test public void searchServiceRequest_shouldReturnMatchingServiceRequestsByCode() { - when(serviceRequestService.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), any())) + when(serviceRequestService.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), any(), any())) .thenReturn( new MockIBundleProvider<>(Collections.singletonList(serviceRequest), PREFERRED_PAGE_SIZE, COUNT)); TokenAndListParam code = new TokenAndListParam().addAnd(new TokenParam(CODE)); IBundleProvider results = resourceProvider.searchForServiceRequests(null, null, code, null, null, null, null, null, - null); + null, null); List resources = getResources(results); @@ -151,7 +151,7 @@ public void searchServiceRequest_shouldReturnMatchingServiceRequestsByCode() { @Test public void searchServiceRequest_shouldReturnMatchingServiceRequestsWhenPatientParamIsSpecified() { - when(serviceRequestService.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), any())) + when(serviceRequestService.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), any(), any())) .thenReturn( new MockIBundleProvider<>(Collections.singletonList(serviceRequest), PREFERRED_PAGE_SIZE, COUNT)); @@ -159,7 +159,7 @@ public void searchServiceRequest_shouldReturnMatchingServiceRequestsWhenPatientP new ReferenceOrListParam().add(new ReferenceParam().setValue(PATIENT_GIVEN_NAME).setChain(Patient.SP_NAME))); IBundleProvider results = resourceProvider.searchForServiceRequests(patientParam, null, null, null, null, null, null, - null, null); + null, null, null); List resources = getResources(results); @@ -172,7 +172,7 @@ public void searchServiceRequest_shouldReturnMatchingServiceRequestsWhenPatientP @Test public void searchServiceRequest_shouldReturnMatchingServiceRequestsWhenSubjectParamIsSpecified() { - when(serviceRequestService.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), any())) + when(serviceRequestService.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), any(), any())) .thenReturn( new MockIBundleProvider<>(Collections.singletonList(serviceRequest), PREFERRED_PAGE_SIZE, COUNT)); @@ -180,7 +180,7 @@ public void searchServiceRequest_shouldReturnMatchingServiceRequestsWhenSubjectP new ReferenceOrListParam().add(new ReferenceParam().setValue(PATIENT_GIVEN_NAME).setChain(Patient.SP_NAME))); IBundleProvider results = resourceProvider.searchForServiceRequests(null, subjectParam, null, null, null, null, null, - null, null); + null, null, null); List resources = getResources(results); @@ -193,7 +193,7 @@ public void searchServiceRequest_shouldReturnMatchingServiceRequestsWhenSubjectP @Test public void searchServiceRequest_shouldReturnMatchingServiceRequestsByRequesterParam() { - when(serviceRequestService.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), any())) + when(serviceRequestService.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), any(), any())) .thenReturn( new MockIBundleProvider<>(Collections.singletonList(serviceRequest), PREFERRED_PAGE_SIZE, COUNT)); @@ -201,7 +201,7 @@ public void searchServiceRequest_shouldReturnMatchingServiceRequestsByRequesterP .add(new ReferenceParam().setValue(PARTICIPANT_IDENTIFIER).setChain(Practitioner.SP_IDENTIFIER))); IBundleProvider results = resourceProvider.searchForServiceRequests(null, null, null, null, practitionerParam, null, - null, null, null); + null, null, null, null); List resources = getResources(results); @@ -214,14 +214,14 @@ public void searchServiceRequest_shouldReturnMatchingServiceRequestsByRequesterP @Test public void searchServiceRequest_shouldReturnMatchingServiceRequestsByOccurrence() { - when(serviceRequestService.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), any())) + when(serviceRequestService.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), any(), any())) .thenReturn( new MockIBundleProvider<>(Collections.singletonList(serviceRequest), PREFERRED_PAGE_SIZE, COUNT)); DateRangeParam occurrence = new DateRangeParam().setLowerBound(OCCURRENCE).setUpperBound(OCCURRENCE); IBundleProvider results = resourceProvider.searchForServiceRequests(null, null, null, null, null, occurrence, null, - null, null); + null, null, null); List resources = getResources(results); @@ -234,14 +234,14 @@ public void searchServiceRequest_shouldReturnMatchingServiceRequestsByOccurrence @Test public void searchServiceRequests_shouldReturnMatchingServiceRequestsByEncounter() { - when(serviceRequestService.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), any())) + when(serviceRequestService.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), any(), any())) .thenReturn(new MockIBundleProvider<>(Collections.singletonList(serviceRequest), 10, 1)); ReferenceAndListParam encounterParam = new ReferenceAndListParam() .addAnd(new ReferenceOrListParam().add(new ReferenceParam().setValue(ENCOUNTER_UUID).setChain(null))); - IBundleProvider results = resourceProvider.searchForServiceRequests(null, null, null, encounterParam, null, null, - null, null, null); + IBundleProvider results = resourceProvider.searchForServiceRequests(null, null, null, null, encounterParam, null, + null, null, null, null); List resources = getResources(results); @@ -256,12 +256,12 @@ public void searchServiceRequests_shouldReturnMatchingServiceRequestsByEncounter public void searchServiceRequest_shouldReturnMatchingServiceRequestWhenUUIDIsSpecified() { TokenAndListParam uuid = new TokenAndListParam().addAnd(new TokenParam(SERVICE_REQUEST_UUID)); - when(serviceRequestService.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), any())) + when(serviceRequestService.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), any(), any())) .thenReturn( new MockIBundleProvider<>(Collections.singletonList(serviceRequest), PREFERRED_PAGE_SIZE, COUNT)); IBundleProvider results = resourceProvider.searchForServiceRequests(null, null, null, null, null, null, uuid, null, - null); + null, null); List resources = getResources(results); @@ -276,12 +276,12 @@ public void searchServiceRequest_shouldReturnMatchingServiceRequestWhenUUIDIsSpe public void searchServiceRequest_shouldReturnMatchingServiceRequestWhenLastUpdatedIsSpecified() { DateRangeParam lastUpdated = new DateRangeParam().setUpperBound(LAST_UPDATED_DATE).setLowerBound(LAST_UPDATED_DATE); - when(serviceRequestService.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), any())) + when(serviceRequestService.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), any(), any())) .thenReturn( new MockIBundleProvider<>(Collections.singletonList(serviceRequest), PREFERRED_PAGE_SIZE, COUNT)); IBundleProvider results = resourceProvider.searchForServiceRequests(null, null, null, null, null, null, null, - lastUpdated, null); + lastUpdated, null, null); List resources = getResources(results); @@ -364,12 +364,12 @@ public void searchServiceRequest_shouldAddRelatedResourcesToResultListWhenInclud HashSet includes = new HashSet<>(); includes.add(new Include("ServiceRequest:patient")); - when(serviceRequestService.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), + when(serviceRequestService.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), any(), argThat(is(includes)))).thenReturn( new MockIBundleProvider<>(Arrays.asList(serviceRequest, new Patient()), PREFERRED_PAGE_SIZE, COUNT)); IBundleProvider results = resourceProvider.searchForServiceRequests(null, null, null, null, null, null, null, null, - includes); + null, includes); List resources = getResources(results); @@ -385,12 +385,13 @@ public void searchServiceRequest_shouldAddRelatedResourcesToResultListWhenInclud public void searchServiceRequest_shouldNotAddRelatedResourcesToResultListForEmptyIncludes() { HashSet includes = new HashSet<>(); - when(serviceRequestService.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), isNull())) - .thenReturn( - new MockIBundleProvider<>(Collections.singletonList(serviceRequest), PREFERRED_PAGE_SIZE, COUNT)); + when( + serviceRequestService.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), any(), isNull())) + .thenReturn( + new MockIBundleProvider<>(Collections.singletonList(serviceRequest), PREFERRED_PAGE_SIZE, COUNT)); IBundleProvider results = resourceProvider.searchForServiceRequests(null, null, null, null, null, null, null, null, - includes); + null, includes); List resources = getResources(results); diff --git a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/ServiceRequestFhirResourceProviderIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/ServiceRequestFhirResourceProviderIntegrationTest.java index e4742b87c8..07f2732ddd 100644 --- a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/ServiceRequestFhirResourceProviderIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/ServiceRequestFhirResourceProviderIntegrationTest.java @@ -51,6 +51,7 @@ public class ServiceRequestFhirResourceProviderIntegrationTest extends BaseFhirR public void setup() throws Exception { super.setup(); executeDataSet(TEST_ORDER_INITIAL_DATA); + } @Test diff --git a/omod/src/test/java/org/openmrs/module/fhir2/providers/r3/ObservationFhirResourceProviderWebTest.java b/omod/src/test/java/org/openmrs/module/fhir2/providers/r3/ObservationFhirResourceProviderWebTest.java index a53b700436..0573b2c42d 100644 --- a/omod/src/test/java/org/openmrs/module/fhir2/providers/r3/ObservationFhirResourceProviderWebTest.java +++ b/omod/src/test/java/org/openmrs/module/fhir2/providers/r3/ObservationFhirResourceProviderWebTest.java @@ -200,7 +200,7 @@ public void shouldGetObservationsBySubjectUuid() throws Exception { verifyUri("/Observation?subject=" + PATIENT_UUID); verify(observationService).searchForObservations(isNull(), patientCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); List orListParams = patientCaptor.getValue().getValuesAsQueryTokens(); ReferenceParam referenceParam = orListParams.get(0).getValuesAsQueryTokens().get(0); @@ -214,7 +214,7 @@ public void shouldGetObservationsByPatientUuid() throws Exception { verifyUri("/Observation?subject:Patient=" + PATIENT_UUID); verify(observationService).searchForObservations(isNull(), patientCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); List orListParams = patientCaptor.getValue().getValuesAsQueryTokens(); ReferenceParam referenceParam = orListParams.get(0).getValuesAsQueryTokens().get(0); @@ -229,7 +229,7 @@ public void shouldGetObservationsByPatientIdentifier() throws Exception { verifyUri("/Observation?subject.identifier=M4001-1"); verify(observationService).searchForObservations(isNull(), patientCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); List orListParams = patientCaptor.getValue().getValuesAsQueryTokens(); ReferenceParam referenceParam = orListParams.get(0).getValuesAsQueryTokens().get(0); @@ -244,7 +244,7 @@ public void shouldGetObservationsByPatientIdentifierWithOr() throws Exception { verifyUri("/Observation?subject.identifier=M4001-1,ABS098,YT56RE,IU23O"); verify(observationService).searchForObservations(isNull(), patientCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); List orListParams = patientCaptor.getValue().getValuesAsQueryTokens(); ReferenceParam referenceParam = orListParams.get(0).getValuesAsQueryTokens().get(0); @@ -263,7 +263,7 @@ public void shouldGetObservationsByPatientIdentifierWithAnd() throws Exception { "/Observation?subject.identifier=M4001-1&subject.identifier=ABS098&subject.identifier=YT56RE&subject.identifier=IU23O"); verify(observationService).searchForObservations(isNull(), patientCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); List orListParams = patientCaptor.getValue().getValuesAsQueryTokens(); ReferenceParam referenceParam = orListParams.get(0).getValuesAsQueryTokens().get(0); @@ -279,7 +279,7 @@ public void shouldGetObservationsByPatientName() throws Exception { verifyUri("/Observation?subject.name=Hannibal Lector"); verify(observationService).searchForObservations(isNull(), patientCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); List orListParams = patientCaptor.getValue().getValuesAsQueryTokens(); ReferenceParam referenceParam = orListParams.get(0).getValuesAsQueryTokens().get(0); @@ -294,7 +294,7 @@ public void shouldGetObservationsByPatientGivenName() throws Exception { verifyUri("/Observation?subject.given=Hannibal"); verify(observationService).searchForObservations(isNull(), patientCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); List orListParams = patientCaptor.getValue().getValuesAsQueryTokens(); ReferenceParam referenceParam = orListParams.get(0).getValuesAsQueryTokens().get(0); @@ -309,7 +309,7 @@ public void shouldGetObservationsByPatientGivenNameWithOr() throws Exception { verifyUri("/Observation?subject.given=Hannibal,Smith"); verify(observationService).searchForObservations(isNull(), patientCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); List orListParams = patientCaptor.getValue().getValuesAsQueryTokens(); ReferenceParam referenceParam = orListParams.get(0).getValuesAsQueryTokens().get(0); @@ -325,7 +325,7 @@ public void shouldGetObservationsByPatientGivenNameWithAnd() throws Exception { verifyUri("/Observation?subject.given=Hannibal&subject.given=Smith"); verify(observationService).searchForObservations(isNull(), patientCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); List orListParams = patientCaptor.getValue().getValuesAsQueryTokens(); ReferenceParam referenceParam = orListParams.get(0).getValuesAsQueryTokens().get(0); @@ -341,7 +341,7 @@ public void shouldGetObservationsByPatientFamilyName() throws Exception { verifyUri("/Observation?subject.family=Lector"); verify(observationService).searchForObservations(isNull(), patientCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); List orListParams = patientCaptor.getValue().getValuesAsQueryTokens(); ReferenceParam referenceParam = orListParams.get(0).getValuesAsQueryTokens().get(0); @@ -356,7 +356,7 @@ public void shouldGetObservationsByPatientFamilyNameWithOr() throws Exception { verifyUri("/Observation?subject.family=Lector,Rick,Tom"); verify(observationService).searchForObservations(isNull(), patientCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); List orListParams = patientCaptor.getValue().getValuesAsQueryTokens(); ReferenceParam referenceParam = orListParams.get(0).getValuesAsQueryTokens().get(0); @@ -372,7 +372,7 @@ public void shouldGetObservationsByPatientFamilyNameWithAnd() throws Exception { verifyUri("/Observation?subject.family=Lector&subject.family=Rick&subject.family=Tom"); verify(observationService).searchForObservations(isNull(), patientCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); List orListParams = patientCaptor.getValue().getValuesAsQueryTokens(); ReferenceParam referenceParam = orListParams.get(0).getValuesAsQueryTokens().get(0); @@ -388,7 +388,7 @@ public void shouldGetObservationsByEncounterUuid() throws Exception { verifyUri("/Observation?encounter=c4aa5682-90cf-48e8-87c9-a6066ffd3a3f"); verify(observationService).searchForObservations(encounterCaptor.capture(), isNull(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); List orListParams = encounterCaptor.getValue().getValuesAsQueryTokens(); ReferenceParam referenceParam = orListParams.get(0).getValuesAsQueryTokens().get(0); @@ -402,7 +402,7 @@ public void shouldGetObservationsByEncounterUuidWithOr() throws Exception { verifyUri("/Observation?encounter=c4aa5682-90cf-48e8-87c9-a6066ffd3a3f,c4aa5682-90cf-48e8-87c9-auyt23ffd3a3f"); verify(observationService).searchForObservations(encounterCaptor.capture(), isNull(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); List orListParams = encounterCaptor.getValue().getValuesAsQueryTokens(); ReferenceParam referenceParam = orListParams.get(0).getValuesAsQueryTokens().get(0); @@ -418,7 +418,7 @@ public void shouldGetObservationsByEncounterUuidWithAnd() throws Exception { "/Observation?encounter=c4aa5682-90cf-48e8-87c9-a6066ffd3a3f&encounter=c4aa5682-90cf-48e8-87c9-auyt23ffd3a3f"); verify(observationService).searchForObservations(encounterCaptor.capture(), isNull(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); List orListParams = encounterCaptor.getValue().getValuesAsQueryTokens(); ReferenceParam referenceParam = orListParams.get(0).getValuesAsQueryTokens().get(0); @@ -433,7 +433,7 @@ public void shouldGetObservationsByConceptId() throws Exception { verifyUri("/Observation?code=5098"); verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), - isNull(), isNull(), codeCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), codeCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(codeCaptor.getValue(), notNullValue()); assertThat(codeCaptor.getValue().getValuesAsQueryTokens(), notNullValue()); assertThat(codeCaptor.getValue().getValuesAsQueryTokens().size(), equalTo(1)); @@ -449,8 +449,8 @@ public void shouldGetObservationsByConceptId() throws Exception { public void shouldGetObservationsByValueConceptId() throws Exception { verifyUri("/Observation?value-concept=5098"); - verify(observationService).searchForObservations(isNull(), isNull(), isNull(), valueCodeCaptor.capture(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), valueCodeCaptor.capture(), + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(valueCodeCaptor.getValue(), notNullValue()); assertThat(valueCodeCaptor.getValue().getValuesAsQueryTokens(), notNullValue()); assertThat(valueCodeCaptor.getValue().getValuesAsQueryTokens().size(), equalTo(1)); @@ -467,7 +467,7 @@ public void shouldGetObservationsByCategory() throws Exception { verifyUri("/Observation?category=laboratory"); verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), codeCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), codeCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(codeCaptor.getValue(), notNullValue()); assertThat(codeCaptor.getValue().getValuesAsQueryTokens(), notNullValue()); assertThat(codeCaptor.getValue().getValuesAsQueryTokens().size(), equalTo(1)); @@ -484,7 +484,7 @@ public void shouldGetObservationsByConceptAndSystem() throws Exception { verifyUri("/Observation?code=" + URL_ENCODED_CIEL_URI + "|5098"); verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), - isNull(), isNull(), codeCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), codeCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(codeCaptor.getValue(), notNullValue()); assertThat(codeCaptor.getValue().getValuesAsQueryTokens(), notNullValue()); assertThat(codeCaptor.getValue().getValuesAsQueryTokens().size(), equalTo(1)); @@ -501,7 +501,7 @@ public void shouldGetObservationsByConceptsAndSystem() throws Exception { verifyUri("/Observation?code=" + URL_ENCODED_CIEL_URI + "|5098," + URL_ENCODED_CIEL_URI + "|5001"); verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), - isNull(), isNull(), codeCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), codeCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(codeCaptor.getValue(), notNullValue()); assertThat(codeCaptor.getValue().getValuesAsQueryTokens(), notNullValue()); assertThat(codeCaptor.getValue().getValuesAsQueryTokens().size(), equalTo(1)); @@ -519,8 +519,8 @@ public void shouldGetObservationsByConceptsAndSystem() throws Exception { public void shouldGetObservationsByValueConceptsAndSystem() throws Exception { verifyUri("/Observation?value-concept=" + URL_ENCODED_CIEL_URI + "|5098," + URL_ENCODED_CIEL_URI + "|5001"); - verify(observationService).searchForObservations(isNull(), isNull(), isNull(), valueCodeCaptor.capture(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), valueCodeCaptor.capture(), + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(valueCodeCaptor.getValue(), notNullValue()); assertThat(valueCodeCaptor.getValue().getValuesAsQueryTokens(), notNullValue()); assertThat(valueCodeCaptor.getValue().getValuesAsQueryTokens().size(), equalTo(1)); @@ -539,7 +539,8 @@ public void shouldGetObservationsByPatientAndConcept() throws Exception { verifyUri("/Observation?code=" + URL_ENCODED_CIEL_URI + "|5098&subject:Patient=" + PATIENT_UUID); verify(observationService).searchForObservations(isNull(), patientCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), codeCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), codeCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull(), + isNull()); List orListParams = patientCaptor.getValue().getValuesAsQueryTokens(); ReferenceParam referenceParam = orListParams.get(0).getValuesAsQueryTokens().get(0); @@ -565,8 +566,9 @@ public void shouldGetObservationsByPatientAndConcept() throws Exception { public void shouldGetObservationsByMemberAndConcept() throws Exception { verifyUri("/Observation?code=" + URL_ENCODED_CIEL_URI + "|5098&related-type=" + MEMBER_UUID); - verify(observationService).searchForObservations(isNull(), isNull(), memberCaptor.capture(), isNull(), isNull(), - isNull(), isNull(), isNull(), codeCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + verify(observationService).searchForObservations(isNull(), isNull(), isNull(), memberCaptor.capture(), isNull(), + isNull(), isNull(), isNull(), isNull(), codeCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull(), + isNull()); // verify member parameter assertThat(memberCaptor.getValue(), notNullValue()); @@ -589,8 +591,8 @@ public void shouldGetObservationsByMemberAndConcept() throws Exception { public void shouldGetObservationsByMemberCode() throws Exception { verifyUri("/Observation?related-type.code=5098"); - verify(observationService).searchForObservations(isNull(), isNull(), memberCaptor.capture(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + verify(observationService).searchForObservations(isNull(), isNull(), isNull(), memberCaptor.capture(), isNull(), + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(memberCaptor.getValue(), notNullValue()); assertThat(memberCaptor.getValue().getValuesAsQueryTokens().get(0).getValuesAsQueryTokens().get(0).getChain(), @@ -603,8 +605,9 @@ public void shouldGetObservationsByMemberCode() throws Exception { public void shouldGetObservationsByValueDate() throws Exception { verifyUri("/Observation?value-date=ge1975-02-02"); - verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), valueDateCaptor.capture(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), isNull(), + valueDateCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), + isNull(), isNull()); Calendar calendar = Calendar.getInstance(); calendar.set(1975, Calendar.FEBRUARY, 2); @@ -618,7 +621,7 @@ public void shouldGetObservationsByValueDate() throws Exception { public void shouldGetObservationsByValueQuantity() throws Exception { verifyUri("/Observation?value-quantity=134.0"); - verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), isNull(), + verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), valueQuantityCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); @@ -633,7 +636,8 @@ public void shouldGetObservationsByValueString() throws Exception { verifyUri("/Observation?value-string=AFH56"); verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), - stringAndListCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), stringAndListCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), + isNull()); assertThat(stringAndListCaptor.getValue(), notNullValue()); assertThat(stringAndListCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -646,7 +650,7 @@ public void shouldGetObservationsByDate() throws Exception { verifyUri("/Observation?date=ge1975-02-02"); verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), - isNull(), dateCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), dateCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); Calendar calendar = Calendar.getInstance(); calendar.set(1975, Calendar.FEBRUARY, 2); @@ -661,7 +665,7 @@ public void shouldGetObservationsByUUID() throws Exception { verifyUri(String.format("/Observation?_id=%s", OBS_UUID)); verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), codeCaptor.capture(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), codeCaptor.capture(), isNull(), isNull(), isNull(), isNull()); assertThat(codeCaptor.getValue(), notNullValue()); assertThat(codeCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -674,7 +678,7 @@ public void shouldGetObservationsByLastUpdatedDate() throws Exception { verifyUri(String.format("/Observation?_lastUpdated=%s", LAST_UPDATED_DATE)); verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), dateCaptor.capture(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), dateCaptor.capture(), isNull(), isNull(), isNull()); assertThat(dateCaptor.getValue(), notNullValue()); @@ -692,7 +696,8 @@ public void shouldIncludeEncounterWithReturnedObservations() throws Exception { verifyUri("/Observation?_include=Observation:encounter"); verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), includeArgumentCaptor.capture(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), includeArgumentCaptor.capture(), + isNull()); assertThat(includeArgumentCaptor.getValue(), notNullValue()); assertThat(includeArgumentCaptor.getValue().size(), equalTo(1)); @@ -706,7 +711,8 @@ public void shouldIncludePatientWithReturnedObservations() throws Exception { verifyUri("/Observation?_include=Observation:patient"); verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), includeArgumentCaptor.capture(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), includeArgumentCaptor.capture(), + isNull()); assertThat(includeArgumentCaptor.getValue(), notNullValue()); assertThat(includeArgumentCaptor.getValue().size(), equalTo(1)); @@ -720,7 +726,8 @@ public void shouldIncludeObservationGroupMembersWithReturnedObservations() throw verifyUri("/Observation?_include=Observation:related-type"); verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), includeArgumentCaptor.capture(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), includeArgumentCaptor.capture(), + isNull()); assertThat(includeArgumentCaptor.getValue(), notNullValue()); assertThat(includeArgumentCaptor.getValue().size(), equalTo(1)); @@ -734,7 +741,8 @@ public void shouldHandleMultipleIncludes() throws Exception { verifyUri("/Observation?_include=Observation:related-type&_include=Observation:encounter"); verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), includeArgumentCaptor.capture(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), includeArgumentCaptor.capture(), + isNull()); assertThat(includeArgumentCaptor.getValue(), notNullValue()); assertThat(includeArgumentCaptor.getValue().size(), equalTo(2)); @@ -752,7 +760,8 @@ public void shouldReverseIncludeObservationsWithReturnedObservations() throws Ex verifyUri("/Observation?_revinclude=Observation:related-type"); verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), includeArgumentCaptor.capture()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), + includeArgumentCaptor.capture()); assertThat(includeArgumentCaptor.getValue(), notNullValue()); assertThat(includeArgumentCaptor.getValue().size(), equalTo(1)); @@ -766,7 +775,8 @@ public void shouldReverseIncludeDiagnosticReportsWithReturnedObservations() thro verifyUri("/Observation?_revinclude=DiagnosticReport:result"); verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), includeArgumentCaptor.capture()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), + includeArgumentCaptor.capture()); assertThat(includeArgumentCaptor.getValue(), notNullValue()); assertThat(includeArgumentCaptor.getValue().size(), equalTo(1)); @@ -781,7 +791,8 @@ public void shouldHandleMultipleReverseIncludes() throws Exception { verifyUri("/Observation?_revinclude=Observation:related-type&_revinclude=DiagnosticReport:result"); verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), includeArgumentCaptor.capture()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), + includeArgumentCaptor.capture()); assertThat(includeArgumentCaptor.getValue(), notNullValue()); assertThat(includeArgumentCaptor.getValue().size(), equalTo(2)); @@ -798,7 +809,7 @@ private void verifyUri(String uri) throws Exception { Observation observation = new Observation(); observation.setId(OBS_UUID); when(observationService.searchForObservations(any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), - any(), any(), any(), any(), any())) + any(), any(), any(), any(), any(), any())) .thenReturn(new MockIBundleProvider<>(Collections.singletonList(observation), 10, 1)); MockHttpServletResponse response = get(uri).accept(FhirMediaTypes.JSON).go(); diff --git a/omod/src/test/java/org/openmrs/module/fhir2/providers/r3/ProcedureRequestFhirResourceProviderWebTest.java b/omod/src/test/java/org/openmrs/module/fhir2/providers/r3/ProcedureRequestFhirResourceProviderWebTest.java index fd5e61159c..9ae5a9c699 100644 --- a/omod/src/test/java/org/openmrs/module/fhir2/providers/r3/ProcedureRequestFhirResourceProviderWebTest.java +++ b/omod/src/test/java/org/openmrs/module/fhir2/providers/r3/ProcedureRequestFhirResourceProviderWebTest.java @@ -145,7 +145,7 @@ public void searchForServiceRequests_shouldSearchForServiceRequestsByPatientUUID verifyUri(String.format("/ProcedureRequest?patient=%s", PATIENT_UUID)); verify(service).searchForServiceRequests(referenceAndListParamArgumentCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -162,7 +162,7 @@ public void searchForServiceRequests_shouldSearchForServiceRequestsByPatientName verifyUri(String.format("/ProcedureRequest?patient.name=%s", PATIENT_GIVEN_NAME)); verify(service).searchForServiceRequests(referenceAndListParamArgumentCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -179,7 +179,7 @@ public void searchForServiceRequests_shouldSearchForServiceRequestsByPatientGive verifyUri(String.format("/ProcedureRequest?patient.given=%s", PATIENT_GIVEN_NAME)); verify(service).searchForServiceRequests(referenceAndListParamArgumentCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -196,7 +196,7 @@ public void searchForServiceRequests_shouldSearchForServiceRequestsByPatientFami verifyUri(String.format("/ProcedureRequest?patient.family=%s", PATIENT_FAMILY_NAME)); verify(service).searchForServiceRequests(referenceAndListParamArgumentCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -213,7 +213,7 @@ public void searchForServiceRequests_shouldSearchForServiceRequestsByPatientIden verifyUri(String.format("/ProcedureRequest?patient.identifier=%s", PATIENT_IDENTIFIER)); verify(service).searchForServiceRequests(referenceAndListParamArgumentCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -230,7 +230,7 @@ public void searchForServiceRequests_shouldSearchForServiceRequestsBySubjectUUID verifyUri(String.format("/ProcedureRequest?subject=%s", PATIENT_UUID)); verify(service).searchForServiceRequests(referenceAndListParamArgumentCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -247,7 +247,7 @@ public void searchForServiceRequests_shouldSearchForServiceRequestsBySubjectName verifyUri(String.format("/ProcedureRequest?subject.name=%s", PATIENT_GIVEN_NAME)); verify(service).searchForServiceRequests(referenceAndListParamArgumentCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -264,7 +264,7 @@ public void searchForServiceRequests_shouldSearchForServiceRequestsBySubjectGive verifyUri(String.format("/ProcedureRequest?subject.given=%s", PATIENT_GIVEN_NAME)); verify(service).searchForServiceRequests(referenceAndListParamArgumentCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -281,7 +281,7 @@ public void searchForServiceRequests_shouldSearchForServiceRequestsBySubjectFami verifyUri(String.format("/ProcedureRequest?subject.family=%s", PATIENT_FAMILY_NAME)); verify(service).searchForServiceRequests(referenceAndListParamArgumentCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -298,7 +298,7 @@ public void searchForServiceRequests_shouldSearchForServiceRequestsBySubjectIden verifyUri(String.format("/ProcedureRequest?subject.identifier=%s", PATIENT_IDENTIFIER)); verify(service).searchForServiceRequests(referenceAndListParamArgumentCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -315,7 +315,7 @@ public void searchForServiceRequests_shouldSearchForServiceRequestsByParticipant verifyUri(String.format("/ProcedureRequest?requester=%s", PARTICIPANT_UUID)); verify(service).searchForServiceRequests(isNull(), isNull(), isNull(), referenceAndListParamArgumentCaptor.capture(), - isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -332,7 +332,7 @@ public void searchForServiceRequests_shouldSearchForServiceRequestsByParticipant verifyUri(String.format("/ProcedureRequest?requester.name=%s", PARTICIPANT_GIVEN_NAME)); verify(service).searchForServiceRequests(isNull(), isNull(), isNull(), referenceAndListParamArgumentCaptor.capture(), - isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -349,7 +349,7 @@ public void searchForServiceRequests_shouldSearchForServiceRequestsByParticipant verifyUri(String.format("/ProcedureRequest?requester.given=%s", PARTICIPANT_GIVEN_NAME)); verify(service).searchForServiceRequests(isNull(), isNull(), isNull(), referenceAndListParamArgumentCaptor.capture(), - 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 searchForServiceRequests_shouldSearchForServiceRequestsByParticipant verifyUri(String.format("/ProcedureRequest?requester.family=%s", PARTICIPANT_FAMILY_NAME)); verify(service).searchForServiceRequests(isNull(), isNull(), isNull(), referenceAndListParamArgumentCaptor.capture(), - isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -383,7 +383,7 @@ public void searchForServiceRequests_shouldSearchForServiceRequestsByParticipant verifyUri(String.format("/ProcedureRequest?requester.identifier=%s", PARTICIPANT_IDENTIFIER)); verify(service).searchForServiceRequests(isNull(), isNull(), isNull(), referenceAndListParamArgumentCaptor.capture(), - isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -400,7 +400,7 @@ public void searchForServiceRequests_shouldSearchForServiceRequestsByEncounterUU verifyUri(String.format("/ProcedureRequest?encounter=%s", ENCOUNTER_UUID)); verify(service).searchForServiceRequests(isNull(), isNull(), referenceAndListParamArgumentCaptor.capture(), isNull(), - isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -417,7 +417,7 @@ public void searchForServiceRequests_shouldSearchForServiceRequestsByCode() thro verifyUri(String.format("/ProcedureRequest?code=%s", CODE)); verify(service).searchForServiceRequests(isNull(), tokenAndListParamArgumentCaptor.capture(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(tokenAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(tokenAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -431,7 +431,7 @@ public void searchForServiceRequests_shouldSearchForServiceRequestsByOccurrence( verifyUri(String.format("/ProcedureRequest?occurrence=eq%s", OCCURRENCE_DATE)); verify(service).searchForServiceRequests(isNull(), isNull(), isNull(), isNull(), - dateRangeParamArgumentCaptor.capture(), isNull(), isNull(), isNull()); + dateRangeParamArgumentCaptor.capture(), isNull(), isNull(), isNull(), isNull()); assertThat(dateRangeParamArgumentCaptor.getValue(), notNullValue()); @@ -450,7 +450,7 @@ public void searchForServiceRequests_shouldHandleComplexQuery() throws Exception String.format("/ProcedureRequest?requester.given=%s&occurrence=eq%s", PARTICIPANT_GIVEN_NAME, OCCURRENCE_DATE)); verify(service).searchForServiceRequests(isNull(), isNull(), isNull(), referenceAndListParamArgumentCaptor.capture(), - dateRangeParamArgumentCaptor.capture(), isNull(), isNull(), isNull()); + dateRangeParamArgumentCaptor.capture(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -477,7 +477,7 @@ public void searchForProcedureRequests_shouldSearchForProcedureRequestsByUUID() verifyUri(String.format("/ProcedureRequest?_id=%s", SERVICE_REQUEST_UUID)); verify(service).searchForServiceRequests(isNull(), isNull(), isNull(), isNull(), isNull(), - tokenAndListParamArgumentCaptor.capture(), isNull(), isNull()); + tokenAndListParamArgumentCaptor.capture(), isNull(), isNull(), isNull()); assertThat(tokenAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(tokenAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -491,7 +491,7 @@ public void searchForProcedureRequests_shouldSearchForProcedureRequestsByLastUpd verifyUri(String.format("/ProcedureRequest?_lastUpdated=%s", LAST_UPDATED_DATE)); verify(service).searchForServiceRequests(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), - dateRangeParamArgumentCaptor.capture(), isNull()); + dateRangeParamArgumentCaptor.capture(), isNull(), isNull()); assertThat(dateRangeParamArgumentCaptor.getValue(), notNullValue()); @@ -509,7 +509,7 @@ public void searchForServiceRequests_shouldAddRelatedPatientsWhenIncluded() thro verifyUri("/ProcedureRequest?_include=ProcedureRequest:patient"); verify(service).searchForServiceRequests(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), - includeArgumentCaptor.capture()); + isNull(), includeArgumentCaptor.capture()); assertThat(includeArgumentCaptor.getValue(), notNullValue()); assertThat(includeArgumentCaptor.getValue().size(), equalTo(1)); @@ -524,7 +524,7 @@ public void searchForServiceRequests_shouldAddRelatedRequesterWhenIncluded() thr verifyUri("/ProcedureRequest?_include=ProcedureRequest:requester"); verify(service).searchForServiceRequests(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), - includeArgumentCaptor.capture()); + isNull(), includeArgumentCaptor.capture()); assertThat(includeArgumentCaptor.getValue(), notNullValue()); assertThat(includeArgumentCaptor.getValue().size(), equalTo(1)); @@ -539,7 +539,7 @@ public void searchForServiceRequests_shouldAddRelatedEncounterWhenIncluded() thr verifyUri("/ProcedureRequest?_include=ProcedureRequest:encounter"); verify(service).searchForServiceRequests(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), - includeArgumentCaptor.capture()); + isNull(), includeArgumentCaptor.capture()); assertThat(includeArgumentCaptor.getValue(), notNullValue()); assertThat(includeArgumentCaptor.getValue().size(), equalTo(1)); @@ -554,7 +554,7 @@ public void searchForServiceRequests_shouldHandleMultipleIncludes() throws Excep verifyUri("/ProcedureRequest?_include=ProcedureRequest:requester&_include=ProcedureRequest:patient"); verify(service).searchForServiceRequests(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), - includeArgumentCaptor.capture()); + isNull(), includeArgumentCaptor.capture()); assertThat(includeArgumentCaptor.getValue(), notNullValue()); assertThat(includeArgumentCaptor.getValue().size(), equalTo(2)); @@ -571,7 +571,7 @@ private void verifyUri(String uri) throws Exception { ProcedureRequest procedureRequest = new ProcedureRequest(); procedureRequest.setId(SERVICE_REQUEST_UUID); - when(service.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), any())) + when(service.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), any(), any())) .thenReturn(new MockIBundleProvider<>(Collections.singletonList(procedureRequest), 10, 1)); MockHttpServletResponse response = get(uri).accept(FhirMediaTypes.JSON).go(); diff --git a/omod/src/test/java/org/openmrs/module/fhir2/providers/r4/ObservationFhirResourceProviderWebTest.java b/omod/src/test/java/org/openmrs/module/fhir2/providers/r4/ObservationFhirResourceProviderWebTest.java index 8be4e886a0..9d74873e24 100644 --- a/omod/src/test/java/org/openmrs/module/fhir2/providers/r4/ObservationFhirResourceProviderWebTest.java +++ b/omod/src/test/java/org/openmrs/module/fhir2/providers/r4/ObservationFhirResourceProviderWebTest.java @@ -202,7 +202,7 @@ public void shouldGetObservationsBySubjectUuid() throws Exception { verifyUri("/Observation?subject=" + PATIENT_UUID); verify(observationService).searchForObservations(isNull(), patientCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); List orListParams = patientCaptor.getValue().getValuesAsQueryTokens(); ReferenceParam referenceParam = orListParams.get(0).getValuesAsQueryTokens().get(0); @@ -217,7 +217,7 @@ public void shouldGetObservationsByPatientUuid() throws Exception { verifyUri("/Observation?subject:Patient=" + PATIENT_UUID); verify(observationService).searchForObservations(isNull(), patientCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); List orListParams = patientCaptor.getValue().getValuesAsQueryTokens(); ReferenceParam referenceParam = orListParams.get(0).getValuesAsQueryTokens().get(0); @@ -233,7 +233,7 @@ public void shouldGetObservationsByPatientIdentifier() throws Exception { verifyUri("/Observation?subject.identifier=M4001-1"); verify(observationService).searchForObservations(isNull(), patientCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); List orListParams = patientCaptor.getValue().getValuesAsQueryTokens(); ReferenceParam referenceParam = orListParams.get(0).getValuesAsQueryTokens().get(0); @@ -248,7 +248,7 @@ public void shouldGetObservationsByPatientIdentifierWithOr() throws Exception { verifyUri("/Observation?subject.identifier=M4001-1,ABS098,YT56RE,IU23O"); verify(observationService).searchForObservations(isNull(), patientCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); List orListParams = patientCaptor.getValue().getValuesAsQueryTokens(); ReferenceParam referenceParam = orListParams.get(0).getValuesAsQueryTokens().get(0); @@ -267,7 +267,7 @@ public void shouldGetObservationsByPatientIdentifierWithAnd() throws Exception { "/Observation?subject.identifier=M4001-1&subject.identifier=ABS098&subject.identifier=YT56RE&subject.identifier=IU23O"); verify(observationService).searchForObservations(isNull(), patientCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); List orListParams = patientCaptor.getValue().getValuesAsQueryTokens(); ReferenceParam referenceParam = orListParams.get(0).getValuesAsQueryTokens().get(0); @@ -283,7 +283,7 @@ public void shouldGetObservationsByPatientName() throws Exception { verifyUri("/Observation?subject.name=Hannibal Lector"); verify(observationService).searchForObservations(isNull(), patientCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); List orListParams = patientCaptor.getValue().getValuesAsQueryTokens(); ReferenceParam referenceParam = orListParams.get(0).getValuesAsQueryTokens().get(0); @@ -298,7 +298,7 @@ public void shouldGetObservationsByPatientGivenName() throws Exception { verifyUri("/Observation?subject.given=Hannibal"); verify(observationService).searchForObservations(isNull(), patientCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); List orListParams = patientCaptor.getValue().getValuesAsQueryTokens(); ReferenceParam referenceParam = orListParams.get(0).getValuesAsQueryTokens().get(0); @@ -313,7 +313,7 @@ public void shouldGetObservationsByPatientGivenNameWithOr() throws Exception { verifyUri("/Observation?subject.given=Hannibal,Smith"); verify(observationService).searchForObservations(isNull(), patientCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); List orListParams = patientCaptor.getValue().getValuesAsQueryTokens(); ReferenceParam referenceParam = orListParams.get(0).getValuesAsQueryTokens().get(0); @@ -329,7 +329,7 @@ public void shouldGetObservationsByPatientGivenNameWithAnd() throws Exception { verifyUri("/Observation?subject.given=Hannibal&subject.given=Smith"); verify(observationService).searchForObservations(isNull(), patientCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); List orListParams = patientCaptor.getValue().getValuesAsQueryTokens(); ReferenceParam referenceParam = orListParams.get(0).getValuesAsQueryTokens().get(0); @@ -345,7 +345,7 @@ public void shouldGetObservationsByPatientFamilyName() throws Exception { verifyUri("/Observation?subject.family=Lector"); verify(observationService).searchForObservations(isNull(), patientCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); List orListParams = patientCaptor.getValue().getValuesAsQueryTokens(); ReferenceParam referenceParam = orListParams.get(0).getValuesAsQueryTokens().get(0); @@ -360,7 +360,7 @@ public void shouldGetObservationsByPatientFamilyNameWithOr() throws Exception { verifyUri("/Observation?subject.family=Lector,Rick,Tom"); verify(observationService).searchForObservations(isNull(), patientCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); List orListParams = patientCaptor.getValue().getValuesAsQueryTokens(); ReferenceParam referenceParam = orListParams.get(0).getValuesAsQueryTokens().get(0); @@ -376,7 +376,7 @@ public void shouldGetObservationsByPatientFamilyNameWithAnd() throws Exception { verifyUri("/Observation?subject.family=Lector&subject.family=Rick&subject.family=Tom"); verify(observationService).searchForObservations(isNull(), patientCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); List orListParams = patientCaptor.getValue().getValuesAsQueryTokens(); ReferenceParam referenceParam = orListParams.get(0).getValuesAsQueryTokens().get(0); @@ -392,7 +392,7 @@ public void shouldGetObservationsByEncounterUuid() throws Exception { verifyUri("/Observation?encounter=c4aa5682-90cf-48e8-87c9-a6066ffd3a3f"); verify(observationService).searchForObservations(encounterCaptor.capture(), isNull(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); List orListParams = encounterCaptor.getValue().getValuesAsQueryTokens(); ReferenceParam referenceParam = orListParams.get(0).getValuesAsQueryTokens().get(0); @@ -407,7 +407,7 @@ public void shouldGetObservationsByEncounterUuidWithOr() throws Exception { verifyUri("/Observation?encounter=c4aa5682-90cf-48e8-87c9-a6066ffd3a3f,c4aa5682-90cf-48e8-87c9-auyt23ffd3a3f"); verify(observationService).searchForObservations(encounterCaptor.capture(), isNull(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); List orListParams = encounterCaptor.getValue().getValuesAsQueryTokens(); ReferenceParam referenceParam = orListParams.get(0).getValuesAsQueryTokens().get(0); @@ -423,7 +423,7 @@ public void shouldGetObservationsByEncounterUuidWithAnd() throws Exception { "/Observation?encounter=c4aa5682-90cf-48e8-87c9-a6066ffd3a3f&encounter=c4aa5682-90cf-48e8-87c9-auyt23ffd3a3f"); verify(observationService).searchForObservations(encounterCaptor.capture(), isNull(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); List orListParams = encounterCaptor.getValue().getValuesAsQueryTokens(); ReferenceParam referenceParam = orListParams.get(0).getValuesAsQueryTokens().get(0); @@ -438,7 +438,7 @@ public void shouldGetObservationsByConceptId() throws Exception { verifyUri("/Observation?code=5098"); verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), - isNull(), isNull(), codeCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), codeCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(codeCaptor.getValue(), notNullValue()); assertThat(codeCaptor.getValue().getValuesAsQueryTokens(), notNullValue()); assertThat(codeCaptor.getValue().getValuesAsQueryTokens().size(), equalTo(1)); @@ -455,7 +455,7 @@ public void shouldGetObservationsByCategory() throws Exception { verifyUri("/Observation?category=laboratory"); verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), codeCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), codeCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(codeCaptor.getValue(), notNullValue()); assertThat(codeCaptor.getValue().getValuesAsQueryTokens(), notNullValue()); assertThat(codeCaptor.getValue().getValuesAsQueryTokens().size(), equalTo(1)); @@ -472,7 +472,7 @@ public void shouldGetObservationsByConceptAndSystem() throws Exception { verifyUri("/Observation?code=" + URL_ENCODED_CIEL_URI + "|5098"); verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), - isNull(), isNull(), codeCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), codeCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(codeCaptor.getValue(), notNullValue()); assertThat(codeCaptor.getValue().getValuesAsQueryTokens(), notNullValue()); assertThat(codeCaptor.getValue().getValuesAsQueryTokens().size(), equalTo(1)); @@ -489,7 +489,7 @@ public void shouldGetObservationsByConceptsAndSystem() throws Exception { verifyUri("/Observation?code=" + URL_ENCODED_CIEL_URI + "|5098," + URL_ENCODED_CIEL_URI + "|5001"); verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), - isNull(), isNull(), codeCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), codeCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(codeCaptor.getValue(), notNullValue()); assertThat(codeCaptor.getValue().getValuesAsQueryTokens(), notNullValue()); assertThat(codeCaptor.getValue().getValuesAsQueryTokens().size(), equalTo(1)); @@ -508,7 +508,8 @@ public void shouldGetObservationsByPatientAndConcept() throws Exception { verifyUri("/Observation?code=" + URL_ENCODED_CIEL_URI + "|5098&subject:Patient=" + PATIENT_UUID); verify(observationService).searchForObservations(isNull(), patientCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), codeCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), codeCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull(), + isNull()); List orListParams = patientCaptor.getValue().getValuesAsQueryTokens(); ReferenceParam referenceParam = orListParams.get(0).getValuesAsQueryTokens().get(0); @@ -535,7 +536,8 @@ public void shouldGetObservationsByMemberAndConcept() throws Exception { verifyUri("/Observation?code=" + URL_ENCODED_CIEL_URI + "|5098&has-member=" + MEMBER_UUID); verify(observationService).searchForObservations(isNull(), isNull(), memberCaptor.capture(), isNull(), isNull(), - isNull(), isNull(), isNull(), codeCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), codeCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull(), + isNull()); // verify member parameter assertThat(memberCaptor.getValue(), notNullValue()); @@ -559,7 +561,7 @@ public void shouldGetObservationsByMemberCode() throws Exception { verifyUri("/Observation?has-member.code=5098"); verify(observationService).searchForObservations(isNull(), isNull(), memberCaptor.capture(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(memberCaptor.getValue(), notNullValue()); assertThat(memberCaptor.getValue().getValuesAsQueryTokens().get(0).getValuesAsQueryTokens().get(0).getChain(), @@ -572,8 +574,9 @@ public void shouldGetObservationsByMemberCode() throws Exception { public void shouldGetObservationsByValueDate() throws Exception { verifyUri("/Observation?value-date=ge1975-02-02"); - verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), valueDateCaptor.capture(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), isNull(), + valueDateCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), + isNull(), isNull()); Calendar calendar = Calendar.getInstance(); calendar.set(1975, Calendar.FEBRUARY, 2); @@ -587,7 +590,7 @@ public void shouldGetObservationsByValueDate() throws Exception { public void shouldGetObservationsByValueQuantity() throws Exception { verifyUri("/Observation?value-quantity=134.0"); - verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), isNull(), + verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), valueQuantityCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); @@ -602,7 +605,8 @@ public void shouldGetObservationsByValueString() throws Exception { verifyUri("/Observation?value-string=AFH56"); verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), - stringAndListCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), stringAndListCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), + isNull()); assertThat(stringAndListCaptor.getValue(), notNullValue()); assertThat(stringAndListCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -615,7 +619,7 @@ public void shouldGetObservationsByDate() throws Exception { verifyUri("/Observation?date=ge1975-02-02"); verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), - isNull(), dateCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), dateCaptor.capture(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); Calendar calendar = Calendar.getInstance(); calendar.set(1975, Calendar.FEBRUARY, 2); @@ -629,8 +633,8 @@ public void shouldGetObservationsByDate() throws Exception { public void shouldGetObservationsByValueConcept() throws Exception { verifyUri("/Observation?value-concept=5098"); - verify(observationService).searchForObservations(isNull(), isNull(), isNull(), valueCodeCaptor.capture(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), valueCodeCaptor.capture(), + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(valueCodeCaptor.getValue(), notNullValue()); assertThat(valueCodeCaptor.getValue().getValuesAsQueryTokens(), notNullValue()); assertThat(valueCodeCaptor.getValue().getValuesAsQueryTokens().size(), equalTo(1)); @@ -646,8 +650,8 @@ public void shouldGetObservationsByValueConcept() throws Exception { public void shouldGetObservationsByValueConceptsAndSystem() throws Exception { verifyUri("/Observation?value-concept=" + URL_ENCODED_CIEL_URI + "|5098," + URL_ENCODED_CIEL_URI + "|5001"); - verify(observationService).searchForObservations(isNull(), isNull(), isNull(), valueCodeCaptor.capture(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); + verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), valueCodeCaptor.capture(), + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(valueCodeCaptor.getValue(), notNullValue()); assertThat(valueCodeCaptor.getValue().getValuesAsQueryTokens(), notNullValue()); assertThat(valueCodeCaptor.getValue().getValuesAsQueryTokens().size(), equalTo(1)); @@ -666,7 +670,7 @@ public void shouldGetObservationsByUUID() throws Exception { verifyUri(String.format("/Observation?_id=%s", OBS_UUID)); verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), codeCaptor.capture(), isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), codeCaptor.capture(), isNull(), isNull(), isNull(), isNull()); assertThat(codeCaptor.getValue(), notNullValue()); assertThat(codeCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -679,7 +683,7 @@ public void shouldGetObservationsByLastUpdatedDate() throws Exception { verifyUri(String.format("/Observation?_lastUpdated=%s", LAST_UPDATED_DATE)); verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), dateCaptor.capture(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), dateCaptor.capture(), isNull(), isNull(), isNull()); assertThat(dateCaptor.getValue(), notNullValue()); @@ -697,7 +701,8 @@ public void shouldIncludeEncounterWithReturnedObservations() throws Exception { verifyUri("/Observation?_include=Observation:encounter"); verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), includeArgumentCaptor.capture(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), includeArgumentCaptor.capture(), + isNull()); assertThat(includeArgumentCaptor.getValue(), notNullValue()); assertThat(includeArgumentCaptor.getValue().size(), equalTo(1)); @@ -711,7 +716,8 @@ public void shouldIncludePatientWithReturnedObservations() throws Exception { verifyUri("/Observation?_include=Observation:patient"); verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), includeArgumentCaptor.capture(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), includeArgumentCaptor.capture(), + isNull()); assertThat(includeArgumentCaptor.getValue(), notNullValue()); assertThat(includeArgumentCaptor.getValue().size(), equalTo(1)); @@ -725,7 +731,8 @@ public void shouldIncludeObservationGroupMembersWithReturnedObservations() throw verifyUri("/Observation?_include=Observation:has-member"); verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), includeArgumentCaptor.capture(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), includeArgumentCaptor.capture(), + isNull()); assertThat(includeArgumentCaptor.getValue(), notNullValue()); assertThat(includeArgumentCaptor.getValue().size(), equalTo(1)); @@ -739,7 +746,8 @@ public void shouldHandleMultipleIncludes() throws Exception { verifyUri("/Observation?_include=Observation:has-member&_include=Observation:encounter"); verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), includeArgumentCaptor.capture(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), includeArgumentCaptor.capture(), + isNull()); assertThat(includeArgumentCaptor.getValue(), notNullValue()); assertThat(includeArgumentCaptor.getValue().size(), equalTo(2)); @@ -757,7 +765,8 @@ public void shouldReverseIncludeObservationsWithReturnedObservations() throws Ex verifyUri("/Observation?_revinclude=Observation:has-member"); verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), includeArgumentCaptor.capture()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), + includeArgumentCaptor.capture()); assertThat(includeArgumentCaptor.getValue(), notNullValue()); assertThat(includeArgumentCaptor.getValue().size(), equalTo(1)); @@ -771,7 +780,8 @@ public void shouldReverseIncludeDiagnosticReportsWithReturnedObservations() thro verifyUri("/Observation?_revinclude=DiagnosticReport:result"); verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), includeArgumentCaptor.capture()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), + includeArgumentCaptor.capture()); assertThat(includeArgumentCaptor.getValue(), notNullValue()); assertThat(includeArgumentCaptor.getValue().size(), equalTo(1)); @@ -786,7 +796,8 @@ public void shouldHandleMultipleReverseIncludes() throws Exception { verifyUri("/Observation?_revinclude=Observation:has-member&_revinclude=DiagnosticReport:result"); verify(observationService).searchForObservations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), includeArgumentCaptor.capture()); + isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), + includeArgumentCaptor.capture()); assertThat(includeArgumentCaptor.getValue(), notNullValue()); assertThat(includeArgumentCaptor.getValue().size(), equalTo(2)); @@ -803,7 +814,7 @@ private void verifyUri(String uri) throws Exception { Observation observation = new Observation(); observation.setId(OBS_UUID); when(observationService.searchForObservations(any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), - any(), any(), any(), any(), any())) + any(), any(), any(), any(), any(), any())) .thenReturn(new MockIBundleProvider<>(Collections.singletonList(observation), 10, 1)); MockHttpServletResponse response = get(uri).accept(FhirMediaTypes.JSON).go(); diff --git a/omod/src/test/java/org/openmrs/module/fhir2/providers/r4/ServiceRequestFhirResourceProviderWebTest.java b/omod/src/test/java/org/openmrs/module/fhir2/providers/r4/ServiceRequestFhirResourceProviderWebTest.java index 8d00dea451..24c84a591c 100644 --- a/omod/src/test/java/org/openmrs/module/fhir2/providers/r4/ServiceRequestFhirResourceProviderWebTest.java +++ b/omod/src/test/java/org/openmrs/module/fhir2/providers/r4/ServiceRequestFhirResourceProviderWebTest.java @@ -146,7 +146,7 @@ public void searchForServiceRequests_shouldSearchForServiceRequestsByPatientUUID verifyUri(String.format("/ServiceRequest?patient=%s", PATIENT_UUID)); verify(service).searchForServiceRequests(referenceAndListParamArgumentCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -163,7 +163,7 @@ public void searchForServiceRequests_shouldSearchForServiceRequestsByPatientName verifyUri(String.format("/ServiceRequest?patient.name=%s", PATIENT_GIVEN_NAME)); verify(service).searchForServiceRequests(referenceAndListParamArgumentCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -180,7 +180,7 @@ public void searchForServiceRequests_shouldSearchForServiceRequestsByPatientGive verifyUri(String.format("/ServiceRequest?patient.given=%s", PATIENT_GIVEN_NAME)); verify(service).searchForServiceRequests(referenceAndListParamArgumentCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -197,7 +197,7 @@ public void searchForServiceRequests_shouldSearchForServiceRequestsByPatientFami verifyUri(String.format("/ServiceRequest?patient.family=%s", PATIENT_FAMILY_NAME)); verify(service).searchForServiceRequests(referenceAndListParamArgumentCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -214,7 +214,7 @@ public void searchForServiceRequests_shouldSearchForServiceRequestsByPatientIden verifyUri(String.format("/ServiceRequest?patient.identifier=%s", PATIENT_IDENTIFIER)); verify(service).searchForServiceRequests(referenceAndListParamArgumentCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -231,7 +231,7 @@ public void searchForServiceRequests_shouldSearchForServiceRequestsBySubjectUUID verifyUri(String.format("/ServiceRequest?subject=%s", PATIENT_UUID)); verify(service).searchForServiceRequests(referenceAndListParamArgumentCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -248,7 +248,7 @@ public void searchForServiceRequests_shouldSearchForServiceRequestsBySubjectName verifyUri(String.format("/ServiceRequest?subject.name=%s", PATIENT_GIVEN_NAME)); verify(service).searchForServiceRequests(referenceAndListParamArgumentCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -265,7 +265,7 @@ public void searchForServiceRequests_shouldSearchForServiceRequestsBySubjectGive verifyUri(String.format("/ServiceRequest?subject.given=%s", PATIENT_GIVEN_NAME)); verify(service).searchForServiceRequests(referenceAndListParamArgumentCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -282,7 +282,7 @@ public void searchForServiceRequests_shouldSearchForServiceRequestsBySubjectFami verifyUri(String.format("/ServiceRequest?subject.family=%s", PATIENT_FAMILY_NAME)); verify(service).searchForServiceRequests(referenceAndListParamArgumentCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -299,7 +299,7 @@ public void searchForServiceRequests_shouldSearchForServiceRequestsBySubjectIden verifyUri(String.format("/ServiceRequest?subject.identifier=%s", PATIENT_IDENTIFIER)); verify(service).searchForServiceRequests(referenceAndListParamArgumentCaptor.capture(), isNull(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -316,7 +316,7 @@ public void searchForServiceRequests_shouldSearchForServiceRequestsByParticipant verifyUri(String.format("/ServiceRequest?requester=%s", PARTICIPANT_UUID)); verify(service).searchForServiceRequests(isNull(), isNull(), isNull(), referenceAndListParamArgumentCaptor.capture(), - isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -333,7 +333,7 @@ public void searchForServiceRequests_shouldSearchForServiceRequestsByParticipant verifyUri(String.format("/ServiceRequest?requester.name=%s", PARTICIPANT_GIVEN_NAME)); verify(service).searchForServiceRequests(isNull(), isNull(), isNull(), referenceAndListParamArgumentCaptor.capture(), - isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -350,7 +350,7 @@ public void searchForServiceRequests_shouldSearchForServiceRequestsByParticipant verifyUri(String.format("/ServiceRequest?requester.given=%s", PARTICIPANT_GIVEN_NAME)); verify(service).searchForServiceRequests(isNull(), isNull(), isNull(), referenceAndListParamArgumentCaptor.capture(), - isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -367,7 +367,7 @@ public void searchForServiceRequests_shouldSearchForServiceRequestsByParticipant verifyUri(String.format("/ServiceRequest?requester.family=%s", PARTICIPANT_FAMILY_NAME)); verify(service).searchForServiceRequests(isNull(), isNull(), isNull(), referenceAndListParamArgumentCaptor.capture(), - isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -384,7 +384,7 @@ public void searchForServiceRequests_shouldSearchForServiceRequestsByParticipant verifyUri(String.format("/ServiceRequest?requester.identifier=%s", PARTICIPANT_IDENTIFIER)); verify(service).searchForServiceRequests(isNull(), isNull(), isNull(), referenceAndListParamArgumentCaptor.capture(), - isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -401,7 +401,7 @@ public void searchForServiceRequests_shouldSearchForServiceRequestsByEncounterUU verifyUri(String.format("/ServiceRequest?encounter=%s", ENCOUNTER_UUID)); verify(service).searchForServiceRequests(isNull(), isNull(), referenceAndListParamArgumentCaptor.capture(), isNull(), - isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -418,7 +418,7 @@ public void searchForServiceRequests_shouldSearchForServiceRequestsByCode() thro verifyUri(String.format("/ServiceRequest?code=%s", CODE)); verify(service).searchForServiceRequests(isNull(), tokenAndListParamArgumentCaptor.capture(), isNull(), isNull(), - isNull(), isNull(), isNull(), isNull()); + isNull(), isNull(), isNull(), isNull(), isNull()); assertThat(tokenAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(tokenAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -432,7 +432,7 @@ public void searchForServiceRequests_shouldSearchForServiceRequestsByOccurrence( verifyUri(String.format("/ServiceRequest?occurrence=eq%s", OCCURRENCE_DATE)); verify(service).searchForServiceRequests(isNull(), isNull(), isNull(), isNull(), - dateRangeParamArgumentCaptor.capture(), isNull(), isNull(), isNull()); + dateRangeParamArgumentCaptor.capture(), isNull(), isNull(), isNull(), isNull()); assertThat(dateRangeParamArgumentCaptor.getValue(), notNullValue()); @@ -451,7 +451,7 @@ public void searchForServiceRequests_shouldHandleComplexQuery() throws Exception String.format("/ServiceRequest?requester.given=%s&occurrence=eq%s", PARTICIPANT_GIVEN_NAME, OCCURRENCE_DATE)); verify(service).searchForServiceRequests(isNull(), isNull(), isNull(), referenceAndListParamArgumentCaptor.capture(), - dateRangeParamArgumentCaptor.capture(), isNull(), isNull(), isNull()); + dateRangeParamArgumentCaptor.capture(), isNull(), isNull(), isNull(), isNull()); assertThat(referenceAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(referenceAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -478,7 +478,7 @@ public void searchForServiceRequests_shouldSearchForServiceRequestsByUUID() thro verifyUri(String.format("/ServiceRequest?_id=%s", SERVICE_REQUEST_UUID)); verify(service).searchForServiceRequests(isNull(), isNull(), isNull(), isNull(), isNull(), - tokenAndListParamArgumentCaptor.capture(), isNull(), isNull()); + tokenAndListParamArgumentCaptor.capture(), isNull(), isNull(), isNull()); assertThat(tokenAndListParamArgumentCaptor.getValue(), notNullValue()); assertThat(tokenAndListParamArgumentCaptor.getValue().getValuesAsQueryTokens(), not(empty())); @@ -492,7 +492,7 @@ public void searchForServiceRequests_shouldSearchForServiceRequestsByLastUpdated verifyUri(String.format("/ServiceRequest?_lastUpdated=%s", LAST_UPDATED_DATE)); verify(service).searchForServiceRequests(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), - dateRangeParamArgumentCaptor.capture(), isNull()); + dateRangeParamArgumentCaptor.capture(), isNull(), isNull()); assertThat(dateRangeParamArgumentCaptor.getValue(), notNullValue()); @@ -510,7 +510,7 @@ public void searchForServiceRequests_shouldAddRelatedPatientsWhenIncluded() thro verifyUri("/ServiceRequest?_include=ServiceRequest:patient"); verify(service).searchForServiceRequests(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), - includeArgumentCaptor.capture()); + isNull(), includeArgumentCaptor.capture()); assertThat(includeArgumentCaptor.getValue(), notNullValue()); assertThat(includeArgumentCaptor.getValue().size(), equalTo(1)); @@ -525,7 +525,7 @@ public void searchForServiceRequests_shouldAddRelatedRequesterWhenIncluded() thr verifyUri("/ServiceRequest?_include=ServiceRequest:requester"); verify(service).searchForServiceRequests(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), - includeArgumentCaptor.capture()); + isNull(), includeArgumentCaptor.capture()); assertThat(includeArgumentCaptor.getValue(), notNullValue()); assertThat(includeArgumentCaptor.getValue().size(), equalTo(1)); @@ -540,7 +540,7 @@ public void searchForServiceRequests_shouldAddRelatedEncounterWhenIncluded() thr verifyUri("/ServiceRequest?_include=ServiceRequest:encounter"); verify(service).searchForServiceRequests(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), - includeArgumentCaptor.capture()); + isNull(), includeArgumentCaptor.capture()); assertThat(includeArgumentCaptor.getValue(), notNullValue()); assertThat(includeArgumentCaptor.getValue().size(), equalTo(1)); @@ -555,7 +555,7 @@ public void searchForServiceRequests_shouldHandleMultipleIncludes() throws Excep verifyUri("/ServiceRequest?_include=ServiceRequest:requester&_include=ServiceRequest:patient"); verify(service).searchForServiceRequests(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), - includeArgumentCaptor.capture()); + isNull(), includeArgumentCaptor.capture()); assertThat(includeArgumentCaptor.getValue(), notNullValue()); assertThat(includeArgumentCaptor.getValue().size(), equalTo(2)); @@ -569,7 +569,7 @@ public void searchForServiceRequests_shouldHandleMultipleIncludes() throws Excep } private void verifyUri(String uri) throws Exception { - when(service.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), any())) + when(service.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), any(), any())) .thenReturn(new MockIBundleProvider<>(Collections.singletonList(serviceRequest), 10, 1)); MockHttpServletResponse response = get(uri).accept(FhirMediaTypes.JSON).go();