public MedicationDoseUnitCollection getUnits(MedicationRefVo medication, DoseFormIndicator form, MedicationRoute route) { if (!medication.getID_MedicationIsNotNull()) throw new DomainRuntimeException("Medication with null as id"); String hql = "select routes from Medication as medication left join medication.forms as forms left join forms.formRoutes as routes " + "left join routes.route as route left join forms.form as form where " + "(medication.id = :medId and form.id = :formId and route.id = :routeId) "; List<?> dos = getDomainFactory().find(hql,new String[]{"medId","formId","routeId"},new Object[]{medication.getID_Medication(),new Integer(form.getID()),new Integer(route.getID())}); if (dos == null || dos.size() == 0) return null; MedicationRouteVo routeVo = MedicationRouteVoAssembler.create((ims.core.clinical.domain.objects.MedicationRoute) dos.get(0)); if (routeVo==null || !routeVo.getRouteUnitsIsNotNull() ) return null; MedicationDoseUnitCollection result = new MedicationDoseUnitCollection(); for (int i = 0 ; i < routeVo.getRouteUnits().size() ; i++) { if( routeVo.getRouteUnits().get(i)!=null && routeVo.getRouteUnits().get(i).getDoseUnitIsNotNull()) result.add(routeVo.getRouteUnits().get(i).getDoseUnit()); } return result; }