Skip to content

Commit

Permalink
fix syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
mherman22 committed Jan 19, 2024
1 parent 8604017 commit 6329609
Show file tree
Hide file tree
Showing 28 changed files with 158 additions and 168 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public List<MedicationDispense> getSearchResults(@Nonnull SearchParameterMap the
}

@Override
protected void setupSearchParams(OpenmrsFhirCriteriaContext<MedicationDispense> criteriaContext, SearchParameterMap theParams) {
protected <U> void setupSearchParams(OpenmrsFhirCriteriaContext<MedicationDispense,U> criteriaContext, SearchParameterMap theParams) {
theParams.getParameters().forEach(entry -> {
switch (entry.getKey()) {
case FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER:
Expand Down Expand Up @@ -92,12 +92,12 @@ protected void setupSearchParams(OpenmrsFhirCriteriaContext<MedicationDispense>
}

@Override
protected <T> Optional<Predicate> handleLastUpdated(OpenmrsFhirCriteriaContext<T> criteriaContext, DateRangeParam param) {
protected <T,U> Optional<Predicate> handleLastUpdated(OpenmrsFhirCriteriaContext<T,U> criteriaContext, DateRangeParam param) {
return super.handleLastUpdatedImmutable(criteriaContext,param);
}

@Override
protected <V> String paramToProp(OpenmrsFhirCriteriaContext<V> criteriaContext, @NonNull String param) {
protected <V,U> String paramToProp(OpenmrsFhirCriteriaContext<V,U> criteriaContext, @NonNull String param) {
return super.paramToProp(criteriaContext, param);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ protected <T, U> Optional<Predicate> handleGender(OpenmrsFhirCriteriaContext<T,
});
}

protected <T> Optional<Predicate> handleLocationReference(OpenmrsFhirCriteriaContext<T> criteriaContext,
protected <T,U> Optional<Predicate> handleLocationReference(OpenmrsFhirCriteriaContext<T,U> criteriaContext,
@Nonnull String locationAlias, ReferenceAndListParam locationReference) {

if (locationReference == null) {
Expand Down Expand Up @@ -593,7 +593,7 @@ protected <T> Optional<Predicate> handleLocationReference(OpenmrsFhirCriteriaCon
});
}

protected <T> void handleParticipantReference(OpenmrsFhirCriteriaContext<T> criteriaContext,
protected <T,U> void handleParticipantReference(OpenmrsFhirCriteriaContext<T,U> criteriaContext,
ReferenceAndListParam participantReference) {
if (participantReference != null) {
Optional<Join<?, ?>> encounterProvider = criteriaContext.getJoin("ep");
Expand Down Expand Up @@ -666,7 +666,7 @@ protected <T> void handleParticipantReference(OpenmrsFhirCriteriaContext<T> crit
}

//Added this method to allow handling classes with provider instead of encounterProvider
protected <T> void handleProviderReference(OpenmrsFhirCriteriaContext<T> criteriaContext,
protected <T,U> void handleProviderReference(OpenmrsFhirCriteriaContext<T,U> criteriaContext,
ReferenceAndListParam providerReference) {
if (providerReference != null) {
Join<?, ?> orderer = criteriaContext.addJoin("orderer", "ord");
Expand Down Expand Up @@ -716,7 +716,7 @@ protected <T> void handleProviderReference(OpenmrsFhirCriteriaContext<T> criteri
}
}

protected <T> Optional<Predicate> handleCodeableConcept(OpenmrsFhirCriteriaContext<T> criteriaContext,
protected <T,U> Optional<Predicate> handleCodeableConcept(OpenmrsFhirCriteriaContext<T,U> criteriaContext,
TokenAndListParam concepts, @Nonnull String conceptAlias, @Nonnull String conceptMapAlias,
@Nonnull String conceptReferenceTermAlias) {
if (concepts == null) {
Expand Down Expand Up @@ -750,12 +750,12 @@ protected <T> Optional<Predicate> handleCodeableConcept(OpenmrsFhirCriteriaConte

}

protected <T> void handleNames(OpenmrsFhirCriteriaContext<T> criteriaContext, StringAndListParam name,
protected <T,U> void handleNames(OpenmrsFhirCriteriaContext<T,U> criteriaContext, StringAndListParam name,
StringAndListParam given, StringAndListParam family) {
handleNames(criteriaContext, name, given, family, criteriaContext.getRoot());
}

protected <T> void handleNames(OpenmrsFhirCriteriaContext<T> criteriaContext, StringAndListParam name,
protected <T,U> void handleNames(OpenmrsFhirCriteriaContext<T,U> criteriaContext, StringAndListParam name,
StringAndListParam given, StringAndListParam family, From<?, ?> person) {

if (name == null && given == null && family == null) {
Expand Down Expand Up @@ -793,40 +793,36 @@ protected <T> void handleNames(OpenmrsFhirCriteriaContext<T> criteriaContext, St
}
}

protected <T> void handlePatientReference(OpenmrsFhirCriteriaContext<T> criteriaContext,
protected <T,U> void handlePatientReference(OpenmrsFhirCriteriaContext<T,U> criteriaContext,
ReferenceAndListParam patientReference) {
handlePatientReference(criteriaContext, patientReference, "patient");
}

protected <T> void handlePatientReference(OpenmrsFhirCriteriaContext<T> criteriaContext,
protected <T,U> void handlePatientReference(OpenmrsFhirCriteriaContext<T,U> criteriaContext,
ReferenceAndListParam patientReference, String associationPath) {
if (patientReference != null) {
Join<?, ?> associationPathJoin = criteriaContext.addJoin(associationPath, "p");
handleAndListParam(criteriaContext.getCriteriaBuilder(), patientReference, patientToken -> {
if (patientToken.getChain() != null) {
switch (patientToken.getChain()) {
case Patient.SP_IDENTIFIER:
@SuppressWarnings("unchecked")
Join<?, ?> associationPathIdentifiersJoin = criteriaContext.addJoin(associationPathJoin,
"identifiers", "pi");
return Optional.of(criteriaContext.getCriteriaBuilder()
.like(associationPathIdentifiersJoin.get("identifier"), patientToken.getValue()));
case Patient.SP_GIVEN: {
@SuppressWarnings("unchecked")
Join<?, ?> associationPathNamesJoin = criteriaContext.addJoin(associationPathJoin, "names",
"pn");
return Optional.of(criteriaContext.getCriteriaBuilder()
.like(associationPathNamesJoin.get("givenName"), patientToken.getValue()));
}
case Patient.SP_FAMILY: {
@SuppressWarnings("unchecked")
Join<?, ?> associationPathNamesJoin = criteriaContext.addJoin(associationPathJoin, "names",
"pn");
return Optional.of(criteriaContext.getCriteriaBuilder()
.like(associationPathNamesJoin.get("familyName"), patientToken.getValue()));
}
case Patient.SP_NAME:
@SuppressWarnings("unchecked")
Join<?, ?> associationPathNamesJoin = criteriaContext.addJoin(associationPathJoin, "names",
"pn");

Expand Down Expand Up @@ -912,7 +908,7 @@ protected <T, U> Optional<Predicate> handlePersonAddress(OpenmrsFhirCriteriaCont
return Optional.of(criteriaContext.getCriteriaBuilder().and(toCriteriaArray(predicateList.stream())));
}

protected <T> Optional<Predicate> handleMedicationReference(OpenmrsFhirCriteriaContext<T> criteriaContext,
protected <T,U> Optional<Predicate> handleMedicationReference(OpenmrsFhirCriteriaContext<T,U> criteriaContext,
@Nonnull String medicationAlias, ReferenceAndListParam medicationReference) {
if (medicationReference == null) {
return Optional.empty();
Expand All @@ -923,7 +919,7 @@ protected <T> Optional<Predicate> handleMedicationReference(OpenmrsFhirCriteriaC
.equal(getRootOrJoin(criteriaContext, medicationAlias).get("uuid"), token.getIdPart())));
}

protected <T> Optional<Predicate> handleMedicationRequestReference(OpenmrsFhirCriteriaContext<T> criteriaContext,
protected <T,U> Optional<Predicate> handleMedicationRequestReference(OpenmrsFhirCriteriaContext<T,U> criteriaContext,
@Nonnull String drugOrderAlias, ReferenceAndListParam drugOrderReference) {
if (drugOrderReference == null) {
return Optional.empty();
Expand All @@ -943,14 +939,14 @@ protected <T> Optional<Predicate> handleMedicationRequestReference(OpenmrsFhirCr
* @param criteriaContext The {@link OpenmrsFhirCriteriaContext} for the current query
* @param sort the {@link SortSpec} which defines the sorting to be translated
*/
protected <T> void handleSort(OpenmrsFhirCriteriaContext<T> criteriaContext, SortSpec sort) {
protected <T,U> void handleSort(OpenmrsFhirCriteriaContext<T,U> criteriaContext, SortSpec sort) {
handleSort(criteriaContext, sort, this::paramToProps)
.ifPresent(l -> l.forEach(criteriaContext.getCriteriaQuery()::orderBy));
}

protected <T> Optional<List<javax.persistence.criteria.Order>> handleSort(OpenmrsFhirCriteriaContext<T> criteriaContext,
protected <T,U> Optional<List<javax.persistence.criteria.Order>> handleSort(OpenmrsFhirCriteriaContext<T,U> criteriaContext,
SortSpec sort,
BiFunction<OpenmrsFhirCriteriaContext<T>, SortState, Collection<javax.persistence.criteria.Order>> paramToProp) {
BiFunction<OpenmrsFhirCriteriaContext<T,U>, SortState, Collection<javax.persistence.criteria.Order>> paramToProp) {
List<javax.persistence.criteria.Order> orderings = new ArrayList<>();
SortSpec sortSpec = sort;
while (sortSpec != null) {
Expand All @@ -973,7 +969,7 @@ protected <T> Optional<List<javax.persistence.criteria.Order>> handleSort(Openmr
}

@SuppressWarnings("unchecked")
protected <T> Predicate generateSystemQuery(OpenmrsFhirCriteriaContext<T> criteriaContext, String system,
protected <T,U> Predicate generateSystemQuery(OpenmrsFhirCriteriaContext<T,U> criteriaContext, String system,
List<String> codes, String conceptReferenceTermAlias) {
//detached criteria
Specification<FhirConceptSource> spec = (root, query,
Expand All @@ -999,7 +995,7 @@ protected <T> Predicate generateSystemQuery(OpenmrsFhirCriteriaContext<T> criter
}
}

protected <T> Predicate generateActiveOrderQuery(OpenmrsFhirCriteriaContext<T> criteriaContext, String path,
protected <T,U> Predicate generateActiveOrderQuery(OpenmrsFhirCriteriaContext<T,U> criteriaContext, String path,
Date onDate) {
// ACTIVE = date activated null or less than or equal to current datetime, date stopped null or in the future, auto expire date null or in the future
return criteriaContext.getCriteriaBuilder().and(
Expand All @@ -1017,23 +1013,23 @@ protected <T> Predicate generateActiveOrderQuery(OpenmrsFhirCriteriaContext<T> c
onDate)));
}

protected <T> Predicate generateActiveOrderQuery(OpenmrsFhirCriteriaContext<T> criteriaContext, String path) {
protected <T,U> Predicate generateActiveOrderQuery(OpenmrsFhirCriteriaContext<T,U> criteriaContext, String path) {
return generateActiveOrderQuery(criteriaContext, path, new Date());
}

protected <T> Predicate generateActiveOrderQuery(OpenmrsFhirCriteriaContext<T> criteriaContext, Date onDate) {
protected <T,U> Predicate generateActiveOrderQuery(OpenmrsFhirCriteriaContext<T,U> criteriaContext, Date onDate) {
return generateActiveOrderQuery(criteriaContext, "", onDate);
}

protected <T> Predicate generateActiveOrderQuery(OpenmrsFhirCriteriaContext<T> criteriaContext) {
protected <T,U> Predicate generateActiveOrderQuery(OpenmrsFhirCriteriaContext<T,U> criteriaContext) {
return generateActiveOrderQuery(criteriaContext, new Date());
}

protected <T> Predicate generateNotCancelledOrderQuery(OpenmrsFhirCriteriaContext<T> criteriaContext) {
protected <T,U> Predicate generateNotCancelledOrderQuery(OpenmrsFhirCriteriaContext<T,U> criteriaContext) {
return generateNotCancelledOrderQuery(criteriaContext, "");
}

protected <T> Predicate generateNotCancelledOrderQuery(OpenmrsFhirCriteriaContext<T> criteriaContext, String path) {
protected <T,U> Predicate generateNotCancelledOrderQuery(OpenmrsFhirCriteriaContext<T,U> criteriaContext, String path) {
Date now = new Date();

return criteriaContext.getCriteriaBuilder().or(
Expand Down Expand Up @@ -1075,7 +1071,7 @@ protected TokenAndListParam convertStringStatusToBoolean(TokenAndListParam statu
* @param sortState a {@link SortState} object describing the current sort state
* @return the corresponding ordering(s) needed for this property
*/
protected <T> Collection<Order> paramToProps(OpenmrsFhirCriteriaContext<T> criteriaContext,
protected <T,U> Collection<Order> paramToProps(OpenmrsFhirCriteriaContext<T,U> criteriaContext,
@Nonnull SortState sortState) {
Collection<String> prop = paramToProps(criteriaContext, sortState.getParameter());
if (prop != null) {
Expand All @@ -1100,7 +1096,7 @@ protected <T> Collection<Order> paramToProps(OpenmrsFhirCriteriaContext<T> crite
* @param param the FHIR parameter to map
* @return the name of the corresponding property from the current query
*/
protected <T> Collection<String> paramToProps(OpenmrsFhirCriteriaContext<T> criteriaContext, @Nonnull String param) {
protected <T,U> Collection<String> paramToProps(OpenmrsFhirCriteriaContext<T,U> criteriaContext, @Nonnull String param) {
String prop = paramToProp(criteriaContext, param);

if (prop != null) {
Expand All @@ -1117,11 +1113,11 @@ protected <T> Collection<String> paramToProps(OpenmrsFhirCriteriaContext<T> crit
* @param param the FHIR parameter to map
* @return the name of the corresponding property from the current query
*/
protected <T> String paramToProp(OpenmrsFhirCriteriaContext<T> criteriaContext, @Nonnull String param) {
protected <T,U> String paramToProp(OpenmrsFhirCriteriaContext<T,U> criteriaContext, @Nonnull String param) {
return null;
}

protected <T> Optional<Predicate> propertyLike(OpenmrsFhirCriteriaContext<T> criteriaContext, From<?, ?> from,
protected <T,U> Optional<Predicate> propertyLike(OpenmrsFhirCriteriaContext<T,U> criteriaContext, From<?, ?> from,
@Nonnull String propertyName, String value) {
if (value == null) {
return Optional.empty();
Expand All @@ -1130,7 +1126,7 @@ protected <T> Optional<Predicate> propertyLike(OpenmrsFhirCriteriaContext<T> cri
return propertyLike(criteriaContext, from, propertyName, new StringParam(value));
}

protected <T> Optional<Predicate> propertyLike(OpenmrsFhirCriteriaContext<T> criteriaContext, From<?, ?> from,
protected <T,U> Optional<Predicate> propertyLike(OpenmrsFhirCriteriaContext<T,U> criteriaContext, From<?, ?> from,
@Nonnull String propertyName, StringParam param) {
if (param == null) {
return Optional.empty();
Expand Down Expand Up @@ -1198,7 +1194,7 @@ public static final class SortState {
private String parameter;
}

protected <T> Optional<Predicate> handleAgeByDateProperty(OpenmrsFhirCriteriaContext<T> criteriaContext,
protected <T,U> Optional<Predicate> handleAgeByDateProperty(OpenmrsFhirCriteriaContext<T,U> criteriaContext,
@Nonnull String datePropertyName, @Nonnull QuantityParam age) {
BigDecimal value = age.getValue();
if (value == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
public abstract class BaseEncounterDao<T extends OpenmrsObject & Auditable> extends BaseFhirDao<T> {

@Override
protected void setupSearchParams(OpenmrsFhirCriteriaContext<T> criteriaContext, SearchParameterMap theParams) {
protected <U> void setupSearchParams(OpenmrsFhirCriteriaContext<T,U> criteriaContext, SearchParameterMap theParams) {
theParams.getParameters().forEach(entry -> {
switch (entry.getKey()) {
case FhirConstants.DATE_RANGE_SEARCH_HANDLER:
Expand Down Expand Up @@ -82,7 +82,7 @@ protected void setupSearchParams(OpenmrsFhirCriteriaContext<T> criteriaContext,
* dependent resources
*/
@SuppressWarnings("UnstableApiUsage")
protected void handleHasAndListParam(OpenmrsFhirCriteriaContext<T> criteriaContext, HasAndListParam hasAndListParam) {
protected <U> void handleHasAndListParam(OpenmrsFhirCriteriaContext<T,U> criteriaContext, HasAndListParam hasAndListParam) {
if (hasAndListParam != null) {
log.debug("Handling hasAndListParam");
hasAndListParam.getValuesAsQueryTokens().forEach(hasOrListParam -> {
Expand Down Expand Up @@ -177,26 +177,26 @@ protected void handleHasAndListParam(OpenmrsFhirCriteriaContext<T> criteriaConte
}
}

protected abstract void handleDate(OpenmrsFhirCriteriaContext<T> criteriaContext, DateRangeParam dateRangeParam);
protected abstract <U> void handleDate(OpenmrsFhirCriteriaContext<T,U> criteriaContext, DateRangeParam dateRangeParam);

protected abstract void handleEncounterType(OpenmrsFhirCriteriaContext<T> criteriaContext,
protected abstract <U> void handleEncounterType(OpenmrsFhirCriteriaContext<T,U> criteriaContext,
TokenAndListParam tokenAndListParam);

protected abstract void handleParticipant(OpenmrsFhirCriteriaContext<T> criteriaContext,
protected abstract <U> void handleParticipant(OpenmrsFhirCriteriaContext<T,U> criteriaContext,
ReferenceAndListParam referenceAndListParam);

protected <T> Predicate generateNotCompletedOrderQuery(OpenmrsFhirCriteriaContext<T> criteriaContext, String path) {
protected <V,U> Predicate generateNotCompletedOrderQuery(OpenmrsFhirCriteriaContext<V,U> criteriaContext, String path) {
// not implemented in Core until 2.2; see override in FhirEncounterDaoImpl_2_2
return null;
}

protected <T> Predicate generateFulfillerStatusRestriction(OpenmrsFhirCriteriaContext<T> criteriaContext, String path,
protected <V,U> Predicate generateFulfillerStatusRestriction(OpenmrsFhirCriteriaContext<V,U> criteriaContext, String path,
String fulfillerStatus) {
// not implemented in Core until 2.2; see override in FhirEncounterDaoImpl_2_2
return null;
}

protected <V> Predicate generateNotFulfillerStatusRestriction(OpenmrsFhirCriteriaContext<V> criteriaContext, String path,
protected <V,U> Predicate generateNotFulfillerStatusRestriction(OpenmrsFhirCriteriaContext<V,U> criteriaContext, String path,
String fulfillerStatus) {
// not implemented in Core until 2.2; see override in FhirEncounterDaoImpl_2_2
return null;
Expand Down
Loading

0 comments on commit 6329609

Please sign in to comment.