Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FM2-626: Replace Hibernate Criteria Api with Jpa Criteria Api #530

Open
wants to merge 47 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
0cd2b79
Replace Hibernate Criteria Api with Jpa Criteria Api
mherman22 Oct 30, 2023
c18e524
Ian's mess
ibacher Dec 7, 2023
5a0d76c
more mess here
mherman22 Dec 9, 2023
ebe2c8b
more mess
mherman22 Dec 11, 2023
647e677
Yet more mess
ibacher Dec 12, 2023
287b9dd
added more mess
mherman22 Dec 13, 2023
4181a05
Hopefully less mess, i.e., it compiles
ibacher Dec 15, 2023
9121fdc
lil mess
mherman22 Dec 18, 2023
9e7338c
fixing some failing tests in dao/impl
mherman22 Dec 20, 2023
0bc9511
fixing more errors
mherman22 Dec 29, 2023
1d534db
more changes
mherman22 Dec 31, 2023
5cdaeb4
Another f*cking mess
ibacher Jan 12, 2024
ae73b76
fixed syntax errors
mherman22 Jan 13, 2024
5241aa8
wierd
mherman22 Jan 14, 2024
b7e0557
fix the getResults method in dao
mherman22 Jan 17, 2024
218953e
for testing purposes
mherman22 Jan 17, 2024
1db17fb
more changes
mherman22 Jan 18, 2024
6adf867
for testing purposes
mherman22 Jan 18, 2024
e57bf5d
automated reformats
ibacher Jan 19, 2024
f0555e1
Less mess
ibacher Jan 19, 2024
046d65d
fix syntax
mherman22 Jan 19, 2024
d61476e
fix some tests
mherman22 Jan 20, 2024
c6943ce
more fixes
mherman22 Jan 20, 2024
eb9888a
not sure
mherman22 Jan 20, 2024
386561d
more changes
mherman22 Jan 22, 2024
93f2298
Current messy state
ibacher Jan 29, 2024
e920e7e
Start of work on subqueries
ibacher Feb 9, 2024
bf07ec1
reduce
mherman22 Feb 14, 2024
467369a
not sure
mherman22 Feb 14, 2024
8b4a685
sorting in basefhirdao
mherman22 Feb 18, 2024
626ebdf
workaround for negative results
mherman22 Feb 18, 2024
1e1124a
work on BasePersonDao
mherman22 Feb 18, 2024
7cd792a
Improvements to subqueries for person names
ibacher Feb 20, 2024
8398865
implement jpa in patientdao
mherman22 Feb 21, 2024
56db269
caching
mherman22 Mar 4, 2024
d3fc3e7
handle more sorting
mherman22 Mar 4, 2024
3376c42
fix some IllegalArguments in Allergies
mherman22 Apr 15, 2024
2960413
more fixing of tests
mherman22 Apr 15, 2024
c76a513
add concept.defaultConceptMapType GP for the value set translator test
mherman22 Apr 21, 2024
f9adbcf
Initial pass at some of the sorting work
ibacher Oct 8, 2024
8bac94e
Merge remote-tracking branch 'origin/master' into FM2-626
ibacher Oct 9, 2024
90d4627
More clean-up
ibacher Oct 9, 2024
46446c3
fix
mherman22 Nov 12, 2024
db4f407
More minor improvements
ibacher Oct 31, 2024
e1681ce
Fix size() not applying criteria
ibacher Nov 26, 2024
d69bcb1
Adding lots of @Nonnull parameters
ibacher Nov 26, 2024
5d45c31
Some refactoring and more working (CategoryMaps)
ibacher Nov 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,24 @@
package org.openmrs.module.fhir2.api.dao.impl;

import javax.annotation.Nonnull;
import javax.persistence.criteria.From;
import javax.persistence.criteria.Path;
import javax.persistence.criteria.Predicate;

import java.util.List;
import java.util.Optional;

import ca.uhn.fhir.rest.param.DateRangeParam;
import ca.uhn.fhir.rest.param.ReferenceAndListParam;
import lombok.AccessLevel;
import lombok.NonNull;
import lombok.Setter;
import org.hibernate.Criteria;
import org.hibernate.criterion.Criterion;
import org.openmrs.MedicationDispense;
import org.openmrs.annotation.Authorized;
import org.openmrs.annotation.OpenmrsProfile;
import org.openmrs.module.fhir2.FhirConstants;
import org.openmrs.module.fhir2.api.dao.FhirMedicationDispenseDao;
import org.openmrs.module.fhir2.api.dao.internals.OpenmrsFhirCriteriaContext;
import org.openmrs.module.fhir2.api.search.param.SearchParameterMap;
import org.openmrs.util.PrivilegeConstants;
import org.springframework.stereotype.Component;
Expand Down Expand Up @@ -59,36 +62,39 @@ public List<MedicationDispense> getSearchResults(@Nonnull SearchParameterMap the
}

@Override
protected void setupSearchParams(Criteria criteria, SearchParameterMap theParams) {
protected <U> void setupSearchParams(@Nonnull OpenmrsFhirCriteriaContext<MedicationDispense, U> criteriaContext,
@Nonnull SearchParameterMap theParams) {
theParams.getParameters().forEach(entry -> {
switch (entry.getKey()) {
case FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER:
entry.getValue()
.forEach(param -> handlePatientReference(criteria, (ReferenceAndListParam) param.getParam()));
entry.getValue().forEach(
param -> handlePatientReference(criteriaContext, (ReferenceAndListParam) param.getParam()));
break;
case FhirConstants.ENCOUNTER_REFERENCE_SEARCH_HANDLER:
entry.getValue()
.forEach(e -> handleEncounterReference(criteria, (ReferenceAndListParam) e.getParam(), "e"));
entry.getValue().forEach(
e -> handleEncounterReference(criteriaContext, (ReferenceAndListParam) e.getParam(), "e"));
break;
case FhirConstants.MEDICATION_REQUEST_REFERENCE_SEARCH_HANDLER:
entry.getValue()
.forEach(e -> handleMedicationRequestReference("drugOrder", (ReferenceAndListParam) e.getParam())
.ifPresent(c -> createAlias(criteria, "drugOrder", "drugOrder").add(c)));
From<?,?> drugOrder = criteriaContext.addJoin("drugOrder", "drugOrder");
entry.getValue().forEach(e -> handleMedicationRequestReference(criteriaContext, drugOrder,
(ReferenceAndListParam) e.getParam()).ifPresent(criteriaContext::addPredicate));
break;
case FhirConstants.COMMON_SEARCH_HANDLER:
handleCommonSearchParameters(entry.getValue()).ifPresent(criteria::add);
handleCommonSearchParameters(criteriaContext, entry.getValue()).ifPresent(criteriaContext::addPredicate);
criteriaContext.finalizeQuery();
break;
}
});
}

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

@Override
protected String paramToProp(@Nonnull String param) {
return super.paramToProp(param);
protected <V, U> Path<?> paramToProp(@Nonnull OpenmrsFhirCriteriaContext<V, U> criteriaContext, @NonNull String param) {
return super.paramToProp(criteriaContext, param);
}
}
2 changes: 2 additions & 0 deletions api/src/main/java/org/openmrs/module/fhir2/FhirConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ private FhirConstants() {

public static final String GLOBAL_PROPERTY_OTHER = "allergy.concept.severity.other";

public static final String GLOBAL_PROPERTY_DEFAULT_CONCEPT_MAP_TYPE = "concept.defaultConceptMapType";

public static final String GLOBAL_PROPERTY_URI_PREFIX = "fhir2.uriPrefix";

public static final String ENCOUNTER_REFERENCE_SEARCH_HANDLER = "encounter.reference.search.handler";
Expand Down
Loading