private boolean checkExistingTime(DailyFluidBalanceVo voDaily, FluidBalanceInstanceVo voFluidBalInst) { FluidBalanceInstanceVoCollection voFluidBalInstances = voDaily.getFluidBalanceInstances(); boolean result = false; if(voFluidBalInstances != null) { for(int x=0; x<voFluidBalInstances.size(); x++) { FluidBalanceInstanceVo voFluidBalInstance = voFluidBalInstances.get(x); Time existingTime = voFluidBalInstance.getStartTime(); Time newTime = voFluidBalInst.getStartTime(); if(newTime.isLessOrEqualThan(existingTime)) { result = true; break; } } return result; } return result; }
private String createMissingPeriodsMessage(FluidBalanceInstanceVoCollection fluidBalanceInstances) { SignatoryPeriodConfigVo voPeriod = form.getLocalContext().getCurrentSignatoryPeriodConfigVo(); StringBuffer bfr = new StringBuffer(); if(voPeriod!=null) for (int periods = 0 ; periods < voPeriod.getTimePeriods().size() ; periods++) { boolean bFound = false; for (int i = 0 ; i < fluidBalanceInstances.size() ; i++) { FluidBalanceInstanceVo voFluidBalInst = fluidBalanceInstances.get(i); if (voPeriod.getTimePeriods().get(periods).equals(voFluidBalInst.getTimePeriod()) ) bFound = true; } if (!bFound) { bfr.append(getConfiguredTime(voPeriod.getTimePeriods().get(periods))); bfr.append(", "); } } if (bfr.length() == 0) return ""; else return "<B>Note: There are no Fluid Balance records recorded for " + bfr.toString().substring(0, bfr.length() - 2) + "</B>"; }
public FluidBalanceInstanceVoCollection getFluidBalanceInstancesForContextAndDate(CareContextRefVo contextVo, DateTime datetimeStartShift, DateTime datetimeEndShift) { DomainFactory factory = getDomainFactory(); ArrayList<String> markers = new ArrayList<String>(); ArrayList<Object> values = new ArrayList<Object>(); final String andStr = " and "; String query = "select distinct dfb.fluidBalanceInstances from DailyFluidBalance as dfb left join dfb.fluidBalanceInstances as fbi where dfb.isRIE is null"; StringBuffer hql = new StringBuffer(""); if (contextVo != null) { hql.append(andStr + " dfb.careContext.id = :cc"); markers.add("cc"); values.add(contextVo.getID_CareContext()); } if (datetimeStartShift != null) { hql.append(andStr + " dfb.shiftDetails.startDateTime >= :sdate "); markers.add("sdate"); values.add(datetimeStartShift.getJavaDate()); } if (datetimeEndShift != null) { hql.append(andStr + " ( dfb.shiftDetails.endDateTime <= :edate ) "); markers.add("edate"); values.add(datetimeEndShift.getJavaDate()); } query += hql.toString(); List<?> fluidList = factory.find(query, markers, values); return FluidBalanceInstanceVoAssembler.createFluidBalanceInstanceVoCollectionFromFluidBalanceInstance(fluidList).sort(SortOrder.DESCENDING); }
private void populateScreenFromData() { GenForm.grdShiftRow rowShift = null; GenForm.grdShiftRow rowInstance = null; SignatoryShiftDetailsVo voShift = form.getGlobalContext().Core.getChosenSignatoryShiftDetailsVo(); DailyFluidBalanceVo voDFB = form.getGlobalContext().Core.getCurrentDailyFluidBalanceVo(); clearLocalContexts(); //display parent if(voShift != null && voDFB != null) { rowShift = form.grdShift().getRows().newRow(); rowShift.setValue(voShift); if(voShift.getStartTimeIsNotNull()) rowShift.setColDate(getConfiguredTime(voShift.getStartTime()) + " " + getConfiguredTime(voShift.getEndTime())); rowShift.setValue(voShift); FluidBalanceInstanceVoCollection voInstanceColl = voDFB.getFluidBalanceInstances(); if (voInstanceColl != null) { voInstanceColl.sort(SortOrder.ASCENDING); for(int j = 0 ; j < voInstanceColl.size() ; j++) { if (isFluidBalanceInThisShift(voShift, voInstanceColl.get(j)) ) { rowInstance = rowShift.getRows().newRow(); FluidBalanceInstanceVo voFluidBalInst = voInstanceColl.get(j); if(voFluidBalInst.getFluidBalanceDate() != null && voFluidBalInst.getStartTime() != null) rowInstance.setColDate(voFluidBalInst.getFluidBalanceDate().toString() + " " + voFluidBalInst.getStartTime().toString()); if(voFluidBalInst.getTotalIntake() != null) rowInstance.setColTotalIn(voFluidBalInst.getTotalIntake().toString() + " / " + calculateTotalInput(voFluidBalInst)); if(voFluidBalInst.getTotalOutput() != null) rowInstance.setColTotalOut(voFluidBalInst.getTotalOutput().toString()+ " / " + calculateTotalOutput(voFluidBalInst)); if(voFluidBalInst.getBalanceIsNotNull()) rowInstance.setColBalance(calculateTotalBalance(voFluidBalInst.getBalance())); if(voFluidBalInst.getVentilationChartIsNotNull()) rowInstance.setBackColor(Color.AliceBlue); rowInstance.setValue(voFluidBalInst); } } if(rowInstance != null) rowInstance.setBold(true); } form.grdShift().sort(0, SortOrder.DESCENDING); form.grdShift().expandAll(); form.htmMissingPeriods().setHTML(createMissingPeriodsMessage(voDFB.getFluidBalanceInstances())); } }