/** * On Grid Selection Changed event handler */ protected void onGrdTargetSelectionChanged() throws PresentationLogicException { // Get the latest information from domain if (form.grdTarget().getValue() instanceof PatientGoalRefVo) { form.getLocalContext().setSelectedRowValue(domain.getPatientGoal((PatientGoalRefVo) form.grdTarget().getValue())); form.getLocalContext().setSelectedPatientGoalVo((PatientGoalVo) form.getLocalContext().getSelectedRowValue()); populateInstanceControls((PatientGoalVo) form.getLocalContext().getSelectedRowValue(), null); } else if (form.grdTarget().getValue() instanceof PatientGoalTargetRefVo) { if (!(form.grdTarget().getSelectedRow().getParentRow().getValue() instanceof PatientGoalRefVo)) throw new CodingRuntimeException("Major logical error - A PatientGoalTarget must be child of a PatientGoal"); form.getLocalContext().setSelectedRowValue(domain.getPatientGoalTarget((PatientGoalTargetRefVo) form.grdTarget().getValue())); populateInstanceControls(domain.getPatientGoal((PatientGoalRefVo) form.grdTarget().getSelectedRow().getParentRow().getValue()), (PatientGoalTargetVo) form.getLocalContext().getSelectedRowValue()); } // Update controls state updateControlsState(); }
/** * Function used to update the context menu options visibility */ private void updateContextMenuState() { form.getContextMenus().getGenericGridAddItem().setVisible(FormMode.VIEW.equals(form.getMode())); // Determine the text on update option in context menu if (form.getLocalContext().getSelectedRowValue() instanceof PatientGoalRefVo) { form.getContextMenus().getGenericGridUpdateItem().setText("Edit"); } else if (form.getLocalContext().getSelectedRowValue() instanceof PatientGoalTargetRefVo) { form.getContextMenus().getGenericGridUpdateItem().setText("Edit Target"); } form.getContextMenus().getGenericGridUpdateItem().setVisible(FormMode.VIEW.equals(form.getMode()) && form.getLocalContext().getSelectedRowValueIsNotNull()); }
/** * Function used to populate grid, instance controls based on selection, set * form in VIEW mode */ public void open() throws PresentationLogicException { // Clear the screen clear(); // Populate grid populateGrid(domain.listPatientGoals(form.getGlobalContext().Core.getCurrentCareContext())); // Reselect value in grid form.grdTarget().setValue(form.getLocalContext().getSelectedRowValue()); // Reread from grid (just in case the local context in no longer in grid // - KEEP THIS LINE) form.getLocalContext().setSelectedRowValue(form.grdTarget().getValue()); // Populate instance controls // (we need to populate according to our selection) if (form.getLocalContext().getSelectedRowValue() instanceof PatientGoalRefVo) { populateInstanceControls(domain.getPatientGoal((PatientGoalRefVo) form.getLocalContext().getSelectedRowValue()), null); } else if (form.getLocalContext().getSelectedRowValue() instanceof PatientGoalTargetRefVo) { if (form.grdTarget().getSelectedRow() == null || form.grdTarget().getSelectedRow().getParentRow() == null || !(form.grdTarget().getSelectedRow().getParentRow().getValue() instanceof PatientGoalRefVo)) { throw new CodingRuntimeException("Major logical error - A PatientGoalTarget must be child of a PatientGoal"); } populateInstanceControls(domain.getPatientGoal((PatientGoalRefVo) form.grdTarget().getSelectedRow().getParentRow().getValue()), domain.getPatientGoalTarget((PatientGoalTargetRefVo) form.getLocalContext().getSelectedRowValue())); } else form.getLocalContext().setSelectedPatientGoalVo(null); // Set form mode to View form.setMode(FormMode.VIEW); }
/** * Function used to edit a PatientGoal or a PatientGoalTarget instance */ public void updateInstance() { if (form.getLocalContext().getSelectedRowValue() instanceof PatientGoalRefVo) { // Get PatientGoal object data from domain form.getLocalContext().setSelectedRowValue(domain.getPatientGoal((PatientGoalRefVo) form.getLocalContext().getSelectedRowValue())); // Populate instance controls with fresh data populateInstanceControls((PatientGoalVo) form.getLocalContext().getSelectedRowValue(), null); } else if (form.getLocalContext().getSelectedRowValue() instanceof PatientGoalTargetRefVo) { // Check for a valid value in parent row if (form.grdTarget().getSelectedRow() == null || form.grdTarget().getSelectedRow().getParentRow() == null || !(form.grdTarget().getSelectedRow().getParentRow().getValue() instanceof PatientGoalRefVo)) throw new CodingRuntimeException("Major Logical Error - PatientGoalTarget rows must have a PatientGoal target"); // Get parent PatientGoal object data from domain PatientGoalVo patientGoal = domain.getPatientGoal((PatientGoalRefVo) form.grdTarget().getSelectedRow().getParentRow().getValue()); // Get PatientGoalTarget object data from domain form.getLocalContext().setSelectedRowValue(domain.getPatientGoalTarget((PatientGoalTargetRefVo) form.getLocalContext().getSelectedRowValue())); // Populate instance controls with fresh data populateInstanceControls(patientGoal, (PatientGoalTargetVo) form.getLocalContext().getSelectedRowValue()); } // Set form in EDIT mode form.setMode(FormMode.EDIT); }
/** * Function used to get a PatientGoalTarget from database */ public PatientGoalTargetVo getPatientGoalTarget(PatientGoalTargetRefVo patientGoalTargetRef) { // If no PatientGoalTargetRefVo is provided or no ID is present return null if (patientGoalTargetRef == null || !patientGoalTargetRef.getID_PatientGoalTargetIsNotNull()) return null; // Return PatientGoalTarget based on ID return PatientGoalTargetVoAssembler.create((PatientGoalTarget) getDomainFactory().getDomainObject(PatientGoalTarget.class, patientGoalTargetRef.getID_PatientGoalTarget())); }
/** * Function used to update the controls state */ public void updateControlsState() { // Set state of the container form.ctnGoals().setCollapsed(FormMode.VIEW.equals(form.getMode()) && !form.getLocalContext().getSelectedRowValueIsNotNull()); // Enable & select appropriate tabs form.ctnGoals().lyrGoals().Goal().setHeaderEnabled(true); form.ctnGoals().lyrGoals().Target().setHeaderEnabled(FormMode.VIEW.equals(form.getMode()) || form.getLocalContext().getSelectedRowValueIsNotNull()); if (form.getLocalContext().getSelectedRowValue() instanceof PatientGoalTargetRefVo) { form.ctnGoals().lyrGoals().showTarget(); } else { form.ctnGoals().lyrGoals().showGoal(); } // Set the state of 'Edit' button if (FormMode.VIEW.equals(form.getMode())) { form.btnEdit().setVisible(form.getLocalContext().getSelectedRowValueIsNotNull()); } else if (FormMode.EDIT.equals(form.getMode())) { boolean editPatientGoal = form.getLocalContext().getSelectedRowValue() instanceof PatientGoalRefVo; boolean editPatientGoalTarget = form.getLocalContext().getSelectedRowValue() instanceof PatientGoalTargetRefVo; // Goal tab controls form.ctnGoals().lyrGoals().Goal().cmbAreaOfNeed().setEnabled(!editPatientGoalTarget); form.ctnGoals().lyrGoals().Goal().cmbGoalType().setEnabled(!editPatientGoalTarget); form.ctnGoals().lyrGoals().Goal().txtGoal().setEnabled(!editPatientGoalTarget); form.ctnGoals().lyrGoals().Goal().dtimCreated().setEnabled(!editPatientGoalTarget); form.ctnGoals().lyrGoals().Goal().qmbAuthoringHCP().setEnabled(!editPatientGoalTarget); form.ctnGoals().lyrGoals().Goal().dteAchieved().setEnabled(!editPatientGoalTarget); // Target tab controls form.ctnGoals().lyrGoals().Target().txtTarget().setEnabled(editPatientGoal || editPatientGoalTarget); form.ctnGoals().lyrGoals().Target().cmbLOA().setEnabled(editPatientGoal || editPatientGoalTarget); form.ctnGoals().lyrGoals().Target().txtReasonNonA().setEnabled(editPatientGoal || editPatientGoalTarget); form.ctnGoals().lyrGoals().Target().dteTargetDate().setEnabled(editPatientGoal || editPatientGoalTarget); form.ctnGoals().lyrGoals().Target().dteAchievedDate().setEnabled(editPatientGoal || editPatientGoalTarget); // Target tab buttons form.ctnGoals().lyrGoals().Target().btnAdd().setVisible(editPatientGoal); form.ctnGoals().lyrGoals().Target().btnClear().setVisible(editPatientGoal); } // Call function to update context menu updateContextMenuState(); }