diff --git a/core/src/main/java/org/phoenixctms/ctsms/domain/ECRFFieldStatusEntryDaoImpl.java b/core/src/main/java/org/phoenixctms/ctsms/domain/ECRFFieldStatusEntryDaoImpl.java index 6fefc7b5666b..ad8c4f1e0555 100644 --- a/core/src/main/java/org/phoenixctms/ctsms/domain/ECRFFieldStatusEntryDaoImpl.java +++ b/core/src/main/java/org/phoenixctms/ctsms/domain/ECRFFieldStatusEntryDaoImpl.java @@ -485,20 +485,22 @@ protected long handleGetCount(ECRFFieldStatusQueue queue, Long probandListEntryI } @Override - protected long handleGetCount(ECRFFieldStatusQueue queue, Long trialId, Long probandListEntryId, Long ecrfId, Long visitId, boolean last) + protected long handleGetCount(ECRFFieldStatusQueue queue, Long trialId, Long departmentId, Long probandListEntryId, Long ecrfId, Long visitId, boolean last) throws Exception { org.hibernate.Criteria ecrfFieldStatusEntryCriteria = createEcrfFieldStatusEntryCriteria("ecrfFieldStatusEntry0"); if (queue != null) { ecrfFieldStatusEntryCriteria.add(Restrictions.eq("queue", queue)); } org.hibernate.Criteria listEntryCriteria = ecrfFieldStatusEntryCriteria.createCriteria("listEntry", "probandListEntry0"); - if (trialId != null || probandListEntryId != null) { - if (trialId != null) { - listEntryCriteria.add(Restrictions.eq("trial.id", trialId.longValue())); - } - if (probandListEntryId != null) { - listEntryCriteria.add(Restrictions.idEq(probandListEntryId.longValue())); - } + if (trialId != null) { + listEntryCriteria.add(Restrictions.eq("trial.id", trialId.longValue())); + } + if (probandListEntryId != null) { + listEntryCriteria.add(Restrictions.idEq(probandListEntryId.longValue())); + } + if (departmentId != null) { + org.hibernate.Criteria probandCriteria = listEntryCriteria.createCriteria("proband"); + probandCriteria.add(Restrictions.eq("department.id", departmentId.longValue())); } org.hibernate.Criteria ecrfFieldCriteria = ecrfFieldStatusEntryCriteria.createCriteria("ecrfField", "ecrfField0"); if (ecrfId != null) { @@ -565,20 +567,22 @@ protected long handleGetCount(ECRFFieldStatusQueue queue, Long probandListEntryI } @Override - protected long handleGetCount(ECRFFieldStatusQueue queue, Long trialId, Long probandListEntryId, Long ecrfId, Long visitId, String section, boolean last) + protected long handleGetCount(ECRFFieldStatusQueue queue, Long trialId, Long departmentId, Long probandListEntryId, Long ecrfId, Long visitId, String section, boolean last) throws Exception { org.hibernate.Criteria ecrfFieldStatusEntryCriteria = createEcrfFieldStatusEntryCriteria("ecrfFieldStatusEntry0"); if (queue != null) { ecrfFieldStatusEntryCriteria.add(Restrictions.eq("queue", queue)); } org.hibernate.Criteria listEntryCriteria = ecrfFieldStatusEntryCriteria.createCriteria("listEntry", "probandListEntry0"); - if (trialId != null || probandListEntryId != null) { - if (trialId != null) { - listEntryCriteria.add(Restrictions.eq("trial.id", trialId.longValue())); - } - if (probandListEntryId != null) { - listEntryCriteria.add(Restrictions.idEq(probandListEntryId.longValue())); - } + if (trialId != null) { + listEntryCriteria.add(Restrictions.eq("trial.id", trialId.longValue())); + } + if (probandListEntryId != null) { + listEntryCriteria.add(Restrictions.idEq(probandListEntryId.longValue())); + } + if (departmentId != null) { + org.hibernate.Criteria probandCriteria = listEntryCriteria.createCriteria("proband"); + probandCriteria.add(Restrictions.eq("department.id", departmentId.longValue())); } org.hibernate.Criteria ecrfFieldCriteria = ecrfFieldStatusEntryCriteria.createCriteria("ecrfField", "ecrfField0"); if (ecrfId != null) { @@ -743,7 +747,7 @@ protected Collection handleGetLog(ECRFFieldStatusQueue que listEntryCriteria.add(Restrictions.idEq(probandListEntryId.longValue())); } if (departmentId != null) { - org.hibernate.Criteria probandCriteria = ecrfFieldStatusEntryCriteria.createCriteria("proband"); + org.hibernate.Criteria probandCriteria = listEntryCriteria.createCriteria("proband"); probandCriteria.add(Restrictions.eq("department.id", departmentId.longValue())); } org.hibernate.Criteria ecrfFieldCriteria = ecrfFieldStatusEntryCriteria.createCriteria("ecrfField", "ecrfField0"); @@ -798,7 +802,7 @@ protected Collection handleGetLog(ECRFFieldStatusQueue que listEntryCriteria.add(Restrictions.idEq(probandListEntryId.longValue())); } if (departmentId != null) { - org.hibernate.Criteria probandCriteria = ecrfFieldStatusEntryCriteria.createCriteria("proband"); + org.hibernate.Criteria probandCriteria = listEntryCriteria.createCriteria("proband"); probandCriteria.add(Restrictions.eq("department.id", departmentId.longValue())); } org.hibernate.Criteria ecrfFieldCriteria = ecrfFieldStatusEntryCriteria.createCriteria("ecrfField", "ecrfField0"); diff --git a/core/src/main/java/org/phoenixctms/ctsms/service/trial/TrialServiceImpl.java b/core/src/main/java/org/phoenixctms/ctsms/service/trial/TrialServiceImpl.java index 6fb919e5b959..d00de074d9c1 100644 --- a/core/src/main/java/org/phoenixctms/ctsms/service/trial/TrialServiceImpl.java +++ b/core/src/main/java/org/phoenixctms/ctsms/service/trial/TrialServiceImpl.java @@ -5817,11 +5817,14 @@ protected ECRFFieldStatusEntryOutVO handleGetEcrfFieldStatusEntry( } @Override - protected long handleGetEcrfFieldStatusEntryCount(AuthenticationVO auth, ECRFFieldStatusQueue queue, Long trialId, Long probandListEntryId, + protected long handleGetEcrfFieldStatusEntryCount(AuthenticationVO auth, ECRFFieldStatusQueue queue, Long trialId, Long departmentId, Long probandListEntryId, Long ecrfId, Long visitId, boolean last) throws Exception { if (trialId != null) { CheckIDUtil.checkTrialId(trialId, this.getTrialDao()); } + if (departmentId != null) { + CheckIDUtil.checkDepartmentId(departmentId, this.getDepartmentDao()); + } if (probandListEntryId != null) { CheckIDUtil.checkProbandListEntryId(probandListEntryId, this.getProbandListEntryDao()); } @@ -5835,7 +5838,7 @@ protected long handleGetEcrfFieldStatusEntryCount(AuthenticationVO auth, ECRFFie throw L10nUtil.initServiceException(ServiceExceptionCodes.ECRF_VISIT_ID_IS_NULL); } } - return this.getECRFFieldStatusEntryDao().getCount(queue, trialId, probandListEntryId, ecrfId, visitId, last); + return this.getECRFFieldStatusEntryDao().getCount(queue, trialId, departmentId, probandListEntryId, ecrfId, visitId, last); } @Override @@ -5851,11 +5854,14 @@ protected long handleGetEcrfFieldStatusEntryCount(AuthenticationVO auth, ECRFFie } @Override - protected long handleGetEcrfFieldStatusEntryCount(AuthenticationVO auth, ECRFFieldStatusQueue queue, Long trialId, Long probandListEntryId, + protected long handleGetEcrfFieldStatusEntryCount(AuthenticationVO auth, ECRFFieldStatusQueue queue, Long trialId, Long departmentId, Long probandListEntryId, Long ecrfId, Long visitId, String section, boolean last) throws Exception { if (trialId != null) { CheckIDUtil.checkTrialId(trialId, this.getTrialDao()); } + if (departmentId != null) { + CheckIDUtil.checkDepartmentId(departmentId, this.getDepartmentDao()); + } if (probandListEntryId != null) { CheckIDUtil.checkProbandListEntryId(probandListEntryId, this.getProbandListEntryDao()); } @@ -5869,7 +5875,7 @@ protected long handleGetEcrfFieldStatusEntryCount(AuthenticationVO auth, ECRFFie throw L10nUtil.initServiceException(ServiceExceptionCodes.ECRF_VISIT_ID_IS_NULL); } } - return this.getECRFFieldStatusEntryDao().getCount(queue, trialId, probandListEntryId, ecrfId, visitId, section, last); + return this.getECRFFieldStatusEntryDao().getCount(queue, trialId, departmentId, probandListEntryId, ecrfId, visitId, section, last); } @Override diff --git a/web/src/main/java/org/phoenixctms/ctsms/web/util/WebUtil.java b/web/src/main/java/org/phoenixctms/ctsms/web/util/WebUtil.java index 57c8f7559546..60ad0cfff90d 100644 --- a/web/src/main/java/org/phoenixctms/ctsms/web/util/WebUtil.java +++ b/web/src/main/java/org/phoenixctms/ctsms/web/util/WebUtil.java @@ -2035,7 +2035,7 @@ public static ECRFFieldStatusEntryOutVO getEcrfFieldStatusEntry(Long id) { public static Long getEcrfFieldStatusEntryCount(ECRFFieldStatusQueue queue, Long trialId, Long probandListEntryId, Long ecrfId, Long visitId, boolean last) { if (trialId != null || probandListEntryId != null || ecrfId != null) { try { - return getServiceLocator().getTrialService().getEcrfFieldStatusEntryCount(getAuthentication(), queue, trialId, probandListEntryId, ecrfId, visitId, last); + return getServiceLocator().getTrialService().getEcrfFieldStatusEntryCount(getAuthentication(), queue, trialId, null, probandListEntryId, ecrfId, visitId, last); } catch (ServiceException | AuthorisationException | IllegalArgumentException e) { } catch (AuthenticationException e) { publishException(e);