Search in sources :

Example 1 with PrescriptionExportDto

use of de.symeda.sormas.api.therapy.PrescriptionExportDto in project SORMAS-Project by hzi-braunschweig.

the class PresicriptionFacadeEjbPseudonymizationTest method testPseudonymizeExportList.

@Test
public void testPseudonymizeExportList() {
    CaseDataDto case1 = creator.createCase(user2.toReference(), rdcf2, null);
    createPrescription(case1);
    CaseDataDto case2 = creator.createCase(user1.toReference(), rdcf1, null);
    creator.createContact(user2.toReference(), creator.createPerson().toReference(), case2);
    createPrescription(case2);
    List<PrescriptionExportDto> prescriptions = getPrescriptionFacade().getExportList(new CaseCriteria(), Collections.emptySet(), 0, 100);
    PrescriptionExportDto export1 = prescriptions.stream().filter(p -> p.getCaseUuid().equals(case1.getUuid())).findFirst().get();
    assertThat(export1.getCaseName(), is("FirstName LASTNAME"));
    assertThat(export1.getPrescribingClinician(), is("John Smith"));
    assertThat(export1.getPrescriptionDetails(), is("Test details"));
    assertThat(export1.getRouteDetails(), is("Test route details"));
    assertThat(export1.getAdditionalNotes(), is("Test additional notes"));
    PrescriptionExportDto export2 = prescriptions.stream().filter(p -> p.getCaseUuid().equals(case2.getUuid())).findFirst().get();
    assertThat(export2.getCaseName(), is("Confidential"));
    assertThat(export2.getPrescribingClinician(), is("Confidential"));
    assertThat(export2.getPrescriptionDetails(), is("Confidential"));
    assertThat(export2.getRouteDetails(), is("Confidential"));
    assertThat(export2.getAdditionalNotes(), is("Confidential"));
}
Also used : CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) CaseCriteria(de.symeda.sormas.api.caze.CaseCriteria) PrescriptionExportDto(de.symeda.sormas.api.therapy.PrescriptionExportDto) Test(org.junit.Test) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest)

Example 2 with PrescriptionExportDto

use of de.symeda.sormas.api.therapy.PrescriptionExportDto 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.getCaseJoins());
    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;
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) Pseudonymizer(de.symeda.sormas.backend.util.Pseudonymizer) CaseQueryContext(de.symeda.sormas.backend.caze.CaseQueryContext) PrescriptionExportDto(de.symeda.sormas.api.therapy.PrescriptionExportDto) Predicate(javax.persistence.criteria.Predicate)

Aggregations

PrescriptionExportDto (de.symeda.sormas.api.therapy.PrescriptionExportDto)2 CaseCriteria (de.symeda.sormas.api.caze.CaseCriteria)1 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)1 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)1 CaseQueryContext (de.symeda.sormas.backend.caze.CaseQueryContext)1 Pseudonymizer (de.symeda.sormas.backend.util.Pseudonymizer)1 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)1 Predicate (javax.persistence.criteria.Predicate)1 Test (org.junit.Test)1