From 38a38ee2eef5ae6f494e9ed33fce6f2991308b5b Mon Sep 17 00:00:00 2001 From: Arjun Date: Tue, 10 May 2016 15:39:41 +0530 Subject: [PATCH] 1363 : Arjun/Vikash : Sorting the referred out test in the desc order of request date, then sorting by accession number to group them together and then sorting by sort order which was the main requirement --- .../lims/referral/daoimpl/ReferralDAOImpl.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/openelis/src/us/mn/state/health/lims/referral/daoimpl/ReferralDAOImpl.java b/openelis/src/us/mn/state/health/lims/referral/daoimpl/ReferralDAOImpl.java index 99740d53b..e0593389f 100644 --- a/openelis/src/us/mn/state/health/lims/referral/daoimpl/ReferralDAOImpl.java +++ b/openelis/src/us/mn/state/health/lims/referral/daoimpl/ReferralDAOImpl.java @@ -89,9 +89,12 @@ public Referral getReferralByAnalysisId(String analysisId) throws LIMSRuntimeExc @SuppressWarnings("unchecked") public List getAllUncanceledOpenReferrals(int resultPageSize,int resultPageNumber) throws LIMSRuntimeException { - String sql = "From Referral r where" + - " r.analysis.statusId in (" + StatusOfSampleUtil.getStatusID(StatusOfSampleUtil.AnalysisStatus.ReferedOut) + "," + StatusOfSampleUtil.getStatusID(StatusOfSampleUtil.AnalysisStatus.BiologistRejectedRO) + ")" + - " and r.canceled = 'false' order by r.requestDate desc"; + String sql = "select r From Referral r, Analysis a, Test t, SampleItem si, Sample s where r.analysis.id = a.id and a.test.id = t.id " + + "and a.sampleItem.id = si.id and si.sample.id = s.id " + + "and a.statusId in (" + StatusOfSampleUtil.getStatusID(StatusOfSampleUtil.AnalysisStatus.ReferedOut) + "," + StatusOfSampleUtil.getStatusID(StatusOfSampleUtil.AnalysisStatus.BiologistRejectedRO) + ") " + + "and r.canceled = 'false' " + + "order by date(r.requestDate) DESC, s.accessionNumber DESC , t.sortOrder ASC"; + try { Query query = HibernateUtil.getSession().createQuery(sql).setMaxResults(resultPageSize).setFirstResult(resultPageSize*resultPageNumber); List referrals = query.list(); @@ -119,12 +122,13 @@ public long getAllUncanceledOpenReferralsCount() throws LIMSRuntimeException { } public List getAllUncanceledOpenReferralsByPatientSTNumber(String patientSTNumber) throws LIMSRuntimeException { - String sql = "select r From Referral r, SampleHuman sh, PatientIdentity pi"+ - " where r.analysis.sampleItem.sample.id = sh.sampleId" + + String sql = "select r From Referral r, SampleHuman sh, PatientIdentity pi, Test t, SampleItem si, Sample s"+ + " where r.analysis.sampleItem.sample.id = sh.sampleId and r.analysis.test.id = t.id and r.analysis.sampleItem.id = si.id and si.sample.id = s.id" + " and r.analysis.statusId in (" + StatusOfSampleUtil.getStatusID(StatusOfSampleUtil.AnalysisStatus.ReferedOut) + "," + StatusOfSampleUtil.getStatusID(StatusOfSampleUtil.AnalysisStatus.BiologistRejectedRO) + ")" + " and sh.patientId = pi.patientId and pi.identityTypeId = "+ PatientIdentityTypeMap.getInstance().getIDForType("ST") + " and pi.identityData in ( :patientSTNumber )" + - " and r.canceled = 'false' order by r.requestDate desc"; + " and r.canceled = 'false' " + + " order by date(r.requestDate) desc, s.accessionNumber DESC , t.sortOrder ASC"; try { Query query = HibernateUtil.getSession().createQuery(sql); query.setParameterList("patientSTNumber", getHealthPrefixedList(patientSTNumber));