/** * Function used to populate the instance controls with data from a StoolScaleVo */ private void populateInstanceControlsFromData(StoolScaleVo stoolAssessment) { // Clear instance controls clearInstanceControls(); // Terminate the function if the stool is null if (stoolAssessment == null) return; // Populate instance controls AuthoringInformationVo voAuthoringInfo = new AuthoringInformationVo(); DateTime dt = new DateTime(stoolAssessment.getDateTimeInitiatedIsNotNull() ? stoolAssessment.getDateTimeInitiated().getDate() : null, stoolAssessment.getDateTimeInitiatedIsNotNull() ? stoolAssessment.getDateTimeInitiated().getTime() : null); voAuthoringInfo.setAuthoringDateTime(dt); voAuthoringInfo.setAuthoringHcp(stoolAssessment.getHcpInitiated()); form.customControlAuthoringInfo().setValue(voAuthoringInfo); form.cmbResult().setValue(stoolAssessment.getResult()); form.cmbType().setValue(stoolAssessment.getStoolType()); form.txtFrequency().setValue(stoolAssessment.getFrequency()); form.txtDetails().setValue(stoolAssessment.getDetails()); }
/** * Function used to perform extra validation on the VO and UI data * @param stoolAssessment - VO to be validated * @param errors - additional errors; pass null for no aditional errors * @return */ private String[] customValidate(StoolScaleVo stoolAssessment, String[] errors) { ArrayList<String> listOfErrors = new ArrayList<String>(); if (errors != null) { for (int i = 0; i < errors.length; i++) { listOfErrors.add(errors[i]); } } // Validate from VO if (stoolAssessment != null && (stoolAssessment.getDateTimeInitiated()==null || stoolAssessment.getHcpInitiated() == null)) listOfErrors.add("Authoring Information is mandatory."); if (stoolAssessment != null && !stoolAssessment.getResultIsNotNull()) listOfErrors.add("Result is mandatory."); int errorCount = listOfErrors.size(); if (errorCount == 0) return null; String[] errorsResult = new String[errorCount]; for (int i = 0; i < listOfErrors.size(); i++) { errorsResult[i] = listOfErrors.get(i); } return errorsResult; }
/** * Function used to display the stool scale assessments collection in the grid */ private void displayStoolScaleAssessments(StoolScaleVoCollection stoolScaleList) { // Clear grid form.grdStoolScale().getRows().clear(); // Terminate function if collection is null if (stoolScaleList == null) return; for (int i = 0; i < stoolScaleList.size(); i++) { StoolScaleVo stoolScale = stoolScaleList.get(i); if (stoolScale == null) continue; // Create a new row grdStoolScaleRow stoolScaleRow = form.grdStoolScale().getRows().newRow(); // Set row columns StringBuffer sb = new StringBuffer(); sb.append(stoolScale.getDateTimeInitiatedIsNotNull() ? stoolScale.getDateTimeInitiated().toString() : "" ); if(stoolScale.getHcpInitiatedIsNotNull() && stoolScale.getHcpInitiated().getMosIsNotNull()) sb.append(" " + stoolScale.getHcpInitiated().getMos().toString()); stoolScaleRow.setColDate(sb.toString()); stoolScaleRow.setColNoResult(stoolScale.getResult()); stoolScaleRow.setColStoolType(stoolScale.getStoolType()); stoolScaleRow.setColFrequency(stoolScale.getFrequency()); stoolScaleRow.setTooltipForColFrequency(stoolScale.getFrequency()); stoolScaleRow.setColDetails(stoolScale.getDetails()); stoolScaleRow.setTooltipForColDetails(stoolScale.getDetails()); // Set row value stoolScaleRow.setValue(stoolScale); } }
/** * Function used to get data from screen into a new StoolScaleVo */ @SuppressWarnings("unused") private StoolScaleVo populateDataFromInstaceControls() { // Call the function with argument - pass null return populateDataFromInstaceControls(null); }
public int compare(StoolScaleVo o1, StoolScaleVo o2) { if (o1 != null && o1.getDateTimeInitiatedIsNotNull() && o2!=null && o2.getDateTimeInitiatedIsNotNull()) { Time time1 = o1.getDateTimeInitiated().getTime(); Time time2 = o2.getDateTimeInitiated().getTime(); time1.setSecond(0); time2.setSecond(0); DateTime dateToCompare1 = new DateTime(o1.getDateTimeInitiated().getDate(), time1); DateTime dateToCompare2 = new DateTime(o2.getDateTimeInitiated().getDate(), time2); int dateOrder = order*dateToCompare1.compareTo(dateToCompare2); if(dateOrder == 0) { return compareByHcp(o1, o2); } return dateOrder; } if (o1 == null || !o1.getDateTimeInitiatedIsNotNull()) return -1*order; if (o2 == null || !o2.getDateTimeInitiatedIsNotNull()) return order; return 0; }
private int compareByHcp(StoolScaleVo o1, StoolScaleVo o2) { if(o1 != null && o1.getHcpInitiatedIsNotNull() && o2 != null && o2.getHcpInitiatedIsNotNull()) { return o1.getHcpInitiated().compareTo(o2.getHcpInitiated()); } return 0; }
public StoolScaleVo saveStoolScaleAssessment(StoolScaleVo voStoolScale) throws StaleObjectException, ForeignKeyViolationException, UniqueKeyViolationException { // Ensure the Value Object was validated if (!voStoolScale.isValidated()) throw new DomainRuntimeException("This Stool Scale has not been validated"); DomainFactory factory = getDomainFactory(); ims.nursing.assessmenttools.domain.objects.StoolScale domStoolScale = StoolScaleVoAssembler.extractStoolScale(factory, voStoolScale); factory.save(domStoolScale); return StoolScaleVoAssembler.create(domStoolScale); }