public MedicationRouteCollection getRoutes(MedicationRefVo medication, DoseFormIndicator form) { 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 forms.form as form where (medication.id = :medId and form.id = :formId)"; List<?> dos = getDomainFactory().find(hql,new String[]{"medId","formId"},new Object[]{medication.getID_Medication(),form.getID()}); if (dos == null || dos.size() == 0) return null; MedicationRouteLiteVoCollection routes = MedicationRouteLiteVoAssembler.createMedicationRouteLiteVoCollectionFromMedicationRoute(dos); MedicationRouteCollection result = new MedicationRouteCollection(); for (int i = 0 ; i < routes.size() ; i++) { if( routes.get(i)!=null && routes.get(i).getRouteIsNotNull()) result.add(routes.get(i).getRoute()); } 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); } }
private void populateCmbRoute(MedicationRouteCollection routes) { form.cmbRoute().clear(); if (routes == null) return; for (int i = 0 ; i < routes.size() ; i++) { MedicationRoute route = routes.get(i); if (route != null) { form.cmbRoute().newRow(route, route.getText()); } } }
private void setDoseRowValue(DynamicGridRow row, MedicationDose dose) { if (row == null) throw new CodingRuntimeException("Major Logical Error - Can not set a dose to null row"); row.setValue(dose); if (dose == null) return; DynamicGridCell cell = row.getCells().newCell(form.dyngrdDoses().getColumns().getByIdentifier(COL_DOSE_DOSENAME), DynamicCellType.STRING); cell.setValidationMessage("Dose length is restricted to 255 characters."); cell.setValue(dose.getDose()); cell.setWidth(120); cell.setReadOnly(true); cell = row.getCells().newCell(form.dyngrdDoses().getColumns().getByIdentifier(COL_DOSE_ROUTE), DynamicCellType.ENUMERATION); // bind to lookup cell.getItems().clear(); MedicationRouteCollection medicationRouteCollection = LookupHelper.getMedicationRoute(domain.getLookupService()); for (int i = 0; i < medicationRouteCollection.size(); i++) { MedicationRoute route = medicationRouteCollection.get(i); cell.getItems().newItem(route, route.getText()); } cell.setValue(dose.getAdminRoute()); cell.setWidth(120); cell.setReadOnly(true); cell = row.getCells().newCell(form.dyngrdDoses().getColumns().getByIdentifier(COL_DOSE_COMMENCED_BY), DynamicCellType.STRING); cell.setIdentifier(dose.getDoseStartHcp()); cell.setValue(dose.getDoseStartHcp() != null ? dose.getDoseStartHcp().toString() : ""); cell.setWidth(200); cell.setReadOnly(true); cell = row.getCells().newCell(form.dyngrdDoses().getColumns().getByIdentifier(COL_DOSE_COMMENCED_DATE), DynamicCellType.DATE); cell.setValue(dose.getDoseStartDate()); cell.setWidth(-1); cell.setReadOnly(true); row.setIdentifier(ROW_STATE_NOT_EDITABLE); }
private void newDose() { DynamicGridRow row = form.dyngrdDoses().getRows().newRow(); DynamicGridCell cell = row.getCells().newCell(form.dyngrdDoses().getColumns().getByIdentifier(COL_DOSE_DOSENAME), DynamicCellType.STRING); cell.setReadOnly(false); cell.setStringMaxLength(255); cell.setValidationMessage("Dose length is restricted to 255 characters."); cell.setWidth(120); cell = row.getCells().newCell(form.dyngrdDoses().getColumns().getByIdentifier(COL_DOSE_ROUTE), DynamicCellType.ENUMERATION); cell.setReadOnly(false); // bind to lookup cell.getItems().clear(); MedicationRouteCollection medicationRouteCollection = LookupHelper.getMedicationRoute(domain.getLookupService()); for (int i = 0; i < medicationRouteCollection.size(); i++) { MedicationRoute route = medicationRouteCollection.get(i); cell.getItems().newItem(route, route.getText()); } cell.setWidth(120); cell = row.getCells().newCell(form.dyngrdDoses().getColumns().getByIdentifier(COL_DOSE_COMMENCED_BY), DynamicCellType.STRING); cell.setReadOnly(true); cell.setIdentifier(domain.getHcpUser()); cell.setValue(domain.getHcpUser() != null ? domain.getHcpUser().toString() : ""); cell.setWidth(200); cell = row.getCells().newCell(form.dyngrdDoses().getColumns().getByIdentifier(COL_DOSE_COMMENCED_DATE), DynamicCellType.DATE); cell.setReadOnly(true); cell.setValue(new Date()); cell.setWidth(-1); row.setValue(new MedicationDose()); row.setIdentifier(ROW_STATE_EDITABLE); // Update grid selection form.dyngrdDoses().setSelectedRow(row); }