private DateTime calculateTurnaround(Integer expectedTurnaround, LookupInstance turnaroundMeasure, DateTime dateTimeReceived) { if (expectedTurnaround == null || turnaroundMeasure == null || dateTimeReceived == null) return null; if (turnaroundMeasure.getId() == MinReorderPeriod.MINUTES.getID() ) return (dateTimeReceived.addMinutes(expectedTurnaround)); if (turnaroundMeasure.getId() == MinReorderPeriod.HOURS.getID()) return (dateTimeReceived.addHours(expectedTurnaround)); if (turnaroundMeasure.getId() == MinReorderPeriod.DAYS.getID()) return (dateTimeReceived.addDays(expectedTurnaround)); if (turnaroundMeasure.getId() == MinReorderPeriod.WEEKS.getID() ) return (dateTimeReceived.addDays(expectedTurnaround*7)); if (turnaroundMeasure.getId() == MinReorderPeriod.MONTHS.getID() ) return (dateTimeReceived.addMonth(expectedTurnaround)); return null; }
public DateTime[] calculateDateTimeRange(Integer val, MinReorderPeriod unit) { DateTime now = new DateTime(); DateTime[] arrDateTimes = new DateTime[2]; arrDateTimes[1] = new DateTime(); if (unit != null) { // WDEV-14182 if (val == null) { arrDateTimes[0] = now; } else if (unit.equals(MinReorderPeriod.MINUTES)) { arrDateTimes[0] = now.addMinutes(-val.intValue()); } else if (unit.equals(MinReorderPeriod.HOURS)) { arrDateTimes[0] = now.addMinutes(-val.intValue() * 60); } else if (unit.equals(MinReorderPeriod.DAYS)) { arrDateTimes[0] = now.addDays(-val.intValue()); } else if (unit.equals(MinReorderPeriod.WEEKS)) { arrDateTimes[0] = now.addDays(-val.intValue() * 7); } else if (unit.equals(MinReorderPeriod.MONTHS)) { arrDateTimes[0] = now.addMonth(-val.intValue()); } } else return null; return arrDateTimes; }
private ReOrderPeriodMessageVoCollection listMessages(Investigation doInv, PatientShort patient, boolean isFemale, BreachedInvestigationsVoCollection breachedInvestigations, Integer parentId) //WDEV-16762 { if(doInv == null) return null; if(Boolean.TRUE.equals(doInv.getInvestigationIndex().isIsProfile())) { if(doInv.getAssocInvestigations() != null) { Iterator it = doInv.getAssocInvestigations().iterator(); ReOrderPeriodMessageVoCollection messages = new ReOrderPeriodMessageVoCollection();//WDEV-16624 while(it.hasNext()) { Object comp = it.next(); if(!(comp instanceof Investigation)) continue; addMessagesCollection(messages, listMessages((Investigation)comp, patient, isFemale, breachedInvestigations, doInv.getId()));//WDEV-16624, WDEV-16762 } return messages;//WDEV-16624 } } else { if(isInvestigationInBreachedList(doInv, breachedInvestigations)) return null; } LookupInstance femaleUnit = doInv.getFemaleMinReorderPeriodUnit(); LookupInstance maleUnit = doInv.getMinReorderPeriodUnit(); MinReorderPeriod unit = null; if(isFemale && femaleUnit != null) unit = LookupHelper.getMinReorderPeriodInstance(getLookupService(), doInv.getFemaleMinReorderPeriodUnit().getId()); else if(!isFemale && maleUnit != null) unit = LookupHelper.getMinReorderPeriodInstance(getLookupService(), doInv.getMinReorderPeriodUnit().getId()); Integer dataValue = isFemale ? doInv.getFemaleMinReorderPeriodVal() : doInv.getMinReorderPeriodVal(); if(dataValue == null && unit == null) return null; DateTime[] dateTimes = calculateDateTimeRange(dataValue, unit); return listInvOrderedWithinMinReOrderPeriod(doInv.getId(),dateTimes[0] , dateTimes[1], patient, dataValue, unit, assembleCategory(doInv.getInvestigationIndex().getCategory()), parentId);//WDEV-16580, WDEV-16762 }