private MedicationRouteVoCollection getRoutes(DynamicGridRowCollection rows) { if (rows == null) return null; MedicationRouteVoCollection result = new MedicationRouteVoCollection(); for (int i = 0 ; i < rows.size() ; i++) { if (rows.get(i).getValue() instanceof MedicationRouteVo) { MedicationRouteVo x = (MedicationRouteVo) rows.get(i).getValue(); x.setRouteUnits(getUnits(rows.get(i).getRows())); if (x.getRouteIsNotNull() || x.getRouteUnitsIsNotNull()) { result.add(x); } } } if (result.size() == 0) return null; return result; }
private void removeSelectedRow() { DynamicGridRow row = form.lyrDetails().tabFRU().dyngrdFRU().getSelectedRow(); if (row == null) return; Object rowValue =row.getValue(); DynamicGridRow parent = row.getParent(); form.lyrDetails().tabFRU().dyngrdFRU().getRows().remove(row); if (rowValue instanceof MedicationFormVo) rebindFormRows(); else if (rowValue instanceof MedicationRouteVo) rebindRouteRows(parent); else if (rowValue instanceof MedicationUnitVo) rebindUnitRows(parent); }
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; }
private void rebindRouteRows(DynamicGridRow formRow) { if (formRow == null) return; DynamicGridRowCollection rows = formRow.getRows(); MedicationRouteCollection mRoutes = ims.core.vo.lookups.LookupHelper.getMedicationRoute(this.domain.getLookupService()); for (int i = 0 ; i < rows.size() ; i++) { if (rows.get(i).getValue() instanceof MedicationRouteVo) { MedicationRouteVo x = (MedicationRouteVo) rows.get(i).getValue(); if (!x.getRouteIsNotNull()) continue; mRoutes.remove(x.getRoute()); } } for (int i = 0 ; i < rows.size() ; i++) { DynamicGridCell cell = rows.get(i).getCells().get(form.lyrDetails().tabFRU().dyngrdFRU().getColumns().getByIdentifier(COL_MAIN)); Object back = cell.getValue(); cell.getItems().clear(); if (back!=null) cell.getItems().newItem(back); for (int j = 0 ; j < mRoutes.size() ;j++) cell.getItems().newItem(mRoutes.get(j)); cell.setValue(back); } }