use of de.symeda.sormas.backend.caze.CaseQueryContext in project SORMAS-Project by hzi-braunschweig.
the class ClinicalVisitFacadeEjb method getExportList.
@Override
public List<ClinicalVisitExportDto> getExportList(CaseCriteria criteria, Collection<String> selectedRows, int first, int max) {
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<ClinicalVisitExportDto> cq = cb.createQuery(ClinicalVisitExportDto.class);
Root<ClinicalVisit> clinicalVisit = cq.from(ClinicalVisit.class);
ClinicalVisitJoins joins = new ClinicalVisitJoins(clinicalVisit);
CaseQueryContext caseQueryContext = new CaseQueryContext(cb, cq, joins.getCaze());
cq.multiselect(joins.getCaze().get(Case.UUID), joins.getCasePerson().get(Person.FIRST_NAME), joins.getCasePerson().get(Person.LAST_NAME), clinicalVisit.get(ClinicalVisit.DISEASE), clinicalVisit.get(ClinicalVisit.VISIT_DATE_TIME), clinicalVisit.get(ClinicalVisit.VISIT_REMARKS), clinicalVisit.get(ClinicalVisit.VISITING_PERSON), joins.getSymptoms().get(Symptoms.ID), JurisdictionHelper.booleanSelector(cb, caseService.inJurisdictionOrOwned(caseQueryContext)));
Predicate filter = service.createUserFilter(cb, cq, clinicalVisit);
Predicate criteriaFilter = caseService.createCriteriaFilter(criteria, caseQueryContext);
filter = CriteriaBuilderHelper.and(cb, filter, criteriaFilter);
filter = CriteriaBuilderHelper.andInValues(selectedRows, filter, cb, joins.getCaze().get(Case.UUID));
cq.where(filter);
cq.orderBy(cb.desc(joins.getCaze().get(Case.UUID)), cb.desc(clinicalVisit.get(ClinicalVisit.VISIT_DATE_TIME)));
List<ClinicalVisitExportDto> resultList = QueryHelper.getResultList(em, cq, first, max);
Pseudonymizer pseudonymizer = Pseudonymizer.getDefault(userService::hasRight, I18nProperties.getCaption(Captions.inaccessibleValue));
for (ClinicalVisitExportDto exportDto : resultList) {
exportDto.setSymptoms(SymptomsFacadeEjb.toDto(symptomsService.getById(exportDto.getSymptomsId())));
Boolean inJurisdiction = exportDto.getInJurisdiction();
pseudonymizer.pseudonymizeDto(ClinicalVisitExportDto.class, exportDto, inJurisdiction, (v) -> {
pseudonymizer.pseudonymizeDto(SymptomsDto.class, v.getSymptoms(), inJurisdiction, null);
});
}
return resultList;
}
use of de.symeda.sormas.backend.caze.CaseQueryContext in project SORMAS-Project by hzi-braunschweig.
the class SampleService method getJurisdictionSelections.
public List<Selection<?>> getJurisdictionSelections(SampleQueryContext qc) {
CriteriaBuilder cb = qc.getCriteriaBuilder();
SampleJoins joins = (SampleJoins) qc.getJoins();
CriteriaQuery cq = qc.getQuery();
ContactJoins<Sample> contactJoins = new ContactJoins(joins.getContact());
return Arrays.asList(JurisdictionHelper.booleanSelector(cb, inJurisdictionOrOwned(qc)), JurisdictionHelper.booleanSelector(cb, cb.and(cb.isNotNull(joins.getCaze()), caseService.inJurisdictionOrOwned(new CaseQueryContext(cb, cq, joins.getCaze())))), JurisdictionHelper.booleanSelector(cb, cb.and(cb.isNotNull(joins.getContact()), contactService.inJurisdictionOrOwned(new ContactQueryContext(cb, cq, joins.getContact())))), JurisdictionHelper.booleanSelector(cb, cb.and(cb.isNotNull(joins.getContact()), cb.isNotNull(contactJoins.getCaze()), caseService.inJurisdictionOrOwned(new CaseQueryContext(cb, cq, contactJoins.getCaze())))), JurisdictionHelper.booleanSelector(cb, cb.and(cb.isNotNull(joins.getEventParticipant()), eventParticipantService.inJurisdictionOrOwned(new EventParticipantQueryContext(cb, cq, joins.getEventParticipant())))));
}
use of de.symeda.sormas.backend.caze.CaseQueryContext in project SORMAS-Project by hzi-braunschweig.
the class ClinicalVisitFacadeEjb method getIndexList.
@Override
public List<ClinicalVisitIndexDto> getIndexList(ClinicalVisitCriteria criteria, Integer first, Integer max, List<SortProperty> sortProperties) {
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<ClinicalVisitIndexDto> cq = cb.createQuery(ClinicalVisitIndexDto.class);
Root<ClinicalVisit> visit = cq.from(ClinicalVisit.class);
ClinicalVisitJoins joins = new ClinicalVisitJoins(visit);
cq.multiselect(visit.get(ClinicalVisit.UUID), visit.get(ClinicalVisit.VISIT_DATE_TIME), visit.get(ClinicalVisit.VISITING_PERSON), visit.get(ClinicalVisit.VISIT_REMARKS), joins.getSymptoms().get(Symptoms.TEMPERATURE), joins.getSymptoms().get(Symptoms.TEMPERATURE_SOURCE), joins.getSymptoms().get(Symptoms.BLOOD_PRESSURE_SYSTOLIC), joins.getSymptoms().get(Symptoms.BLOOD_PRESSURE_DIASTOLIC), joins.getSymptoms().get(Symptoms.HEART_RATE), joins.getSymptoms().get(Symptoms.ID), JurisdictionHelper.booleanSelector(cb, caseService.inJurisdictionOrOwned(new CaseQueryContext(cb, cq, joins.getCaze()))));
if (criteria != null) {
cq.where(service.buildCriteriaFilter(criteria, cb, visit));
}
if (CollectionUtils.isNotEmpty(sortProperties)) {
List<Order> order = new ArrayList<>(sortProperties.size());
for (SortProperty sortProperty : sortProperties) {
Expression<?> expression;
switch(sortProperty.propertyName) {
case ClinicalVisitDto.UUID:
case ClinicalVisitDto.DISEASE:
case ClinicalVisitDto.VISIT_DATE_TIME:
case ClinicalVisitDto.CLINICAL_COURSE:
expression = visit.get(sortProperty.propertyName);
break;
default:
throw new IllegalArgumentException(sortProperty.propertyName);
}
order.add(sortProperty.ascending ? cb.asc(expression) : cb.desc(expression));
}
cq.orderBy(order);
} else {
cq.orderBy(cb.desc(visit.get(ClinicalVisit.VISIT_DATE_TIME)));
}
List<ClinicalVisitIndexDto> results = QueryHelper.getResultList(em, cq, first, max);
Pseudonymizer pseudonymizer = Pseudonymizer.getDefault(userService::hasRight, I18nProperties.getCaption(Captions.inaccessibleValue));
pseudonymizer.pseudonymizeDtoCollection(ClinicalVisitIndexDto.class, results, v -> v.getInJurisdiction(), null);
return results;
}
use of de.symeda.sormas.backend.caze.CaseQueryContext in project SORMAS-Project by hzi-braunschweig.
the class UserFacadeEjb method getUsersHavingCaseInJurisdiction.
@Override
public List<UserReferenceDto> getUsersHavingCaseInJurisdiction(CaseReferenceDto caseReferenceDto) {
return getUsersHavingEntityInJurisdiction((cb, cq, userRoot) -> {
final Subquery<Case> caseJurisdictionSubquery = cq.subquery(Case.class);
final Root<Case> caseRoot = caseJurisdictionSubquery.from(Case.class);
final CaseJurisdictionPredicateValidator caseJurisdictionPredicateValidator = CaseJurisdictionPredicateValidator.of(new CaseQueryContext(cb, cq, caseRoot), userRoot);
caseJurisdictionSubquery.select(caseRoot).where(cb.and(cb.equal(caseRoot.get(AbstractDomainObject.UUID), caseReferenceDto.getUuid()), cb.isTrue(caseJurisdictionPredicateValidator.inJurisdictionOrOwned())));
return caseJurisdictionSubquery;
});
}
use of de.symeda.sormas.backend.caze.CaseQueryContext in project SORMAS-Project by hzi-braunschweig.
the class PrescriptionFacadeEjb method getExportList.
@Override
public List<PrescriptionExportDto> getExportList(CaseCriteria criteria, Collection<String> selectedRows, int first, int max) {
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<PrescriptionExportDto> cq = cb.createQuery(PrescriptionExportDto.class);
Root<Prescription> prescription = cq.from(Prescription.class);
PrescriptionJoins joins = new PrescriptionJoins(prescription);
CaseQueryContext caseQueryContext = new CaseQueryContext(cb, cq, joins.getCaze());
cq.multiselect(joins.getCaze().get(Case.UUID), joins.getCasePerson().get(Person.FIRST_NAME), joins.getCasePerson().get(Person.LAST_NAME), prescription.get(Prescription.PRESCRIPTION_DATE), prescription.get(Prescription.PRESCRIPTION_START), prescription.get(Prescription.PRESCRIPTION_END), prescription.get(Prescription.PRESCRIBING_CLINICIAN), prescription.get(Prescription.PRESCRIPTION_TYPE), prescription.get(Prescription.PRESCRIPTION_DETAILS), prescription.get(Prescription.TYPE_OF_DRUG), prescription.get(Prescription.FREQUENCY), prescription.get(Prescription.DOSE), prescription.get(Prescription.ROUTE), prescription.get(Prescription.ROUTE_DETAILS), prescription.get(Prescription.ADDITIONAL_NOTES), JurisdictionHelper.booleanSelector(cb, caseService.inJurisdictionOrOwned(caseQueryContext)));
Predicate filter = service.createUserFilter(cb, cq, prescription);
Predicate criteriaFilter = caseService.createCriteriaFilter(criteria, caseQueryContext);
filter = CriteriaBuilderHelper.and(cb, filter, criteriaFilter);
filter = CriteriaBuilderHelper.andInValues(selectedRows, filter, cb, joins.getCaze().get(Case.UUID));
cq.where(filter);
cq.orderBy(cb.desc(joins.getCaze().get(Case.UUID)), cb.desc(prescription.get(Prescription.PRESCRIPTION_DATE)));
List<PrescriptionExportDto> exportList = QueryHelper.getResultList(em, cq, first, max);
Pseudonymizer pseudonymizer = Pseudonymizer.getDefault(userService::hasRight, I18nProperties.getCaption(Captions.inaccessibleValue));
pseudonymizer.pseudonymizeDtoCollection(PrescriptionExportDto.class, exportList, p -> p.getInJurisdiction(), null);
return exportList;
}
Aggregations