protected void onBtnOkClick() throws PresentationLogicException { QuestionInformationShortVoCollection voColl = getSelectedQuestions(); if(isUserAssessmentQuestion()) { AssessmentQuestionVoCollection voAssmntColl = new AssessmentQuestionVoCollection(); for(int i=0; voColl != null && i<voColl.size(); i++) { AssessmentQuestionVo voAssmntQ = new AssessmentQuestionVo(); voAssmntQ.setQuestion(domain.getQuestion(voColl.get(i).getID_QuestionInformation())); voAssmntQ.setLegendText(voAssmntQ.getQuestion().getLegendText()); voAssmntColl.add(voAssmntQ); } form.getGlobalContext().Core.setSelectedAssessmentQuestions(voAssmntColl); closeDialog(DialogResult.OK); } else { form.getGlobalContext().Admin.setSelectedQuestions(voColl); closeDialog(DialogResult.OK); } }
@SuppressWarnings("unchecked") private void removeQuestionFromMap(Integer roleId, AssessmentQuestionVo voAssessQuestions) { if (roleId == null || voAssessQuestions == null) return; HashMap map = form.getLocalContext().getAssessmentRoles(); if (map != null) { AssessmentQuestionVoCollection voAssQColl = (AssessmentQuestionVoCollection) map.get(roleId); int index = voAssQColl.indexOf(voAssessQuestions); if (index >= 0) { voAssQColl.remove(index); map.put(roleId, voAssQColl); form.getLocalContext().setAssessmentRoles(map); } } }
@SuppressWarnings("unchecked") private Boolean isQuestionSelected(AssessmentQuestionVo assessmentQuestionVo) { HashMap map = form.getLocalContext().getAssessmentRoles(); Integer roleId = form.getLocalContext().getSelectedRoleId(); if (map == null || roleId == null) return Boolean.FALSE; AssessmentQuestionVoCollection voAssQColl = (AssessmentQuestionVoCollection) map.get(roleId); if (voAssQColl != null) { int index = voAssQColl.indexOf(assessmentQuestionVo); if (index >= 0) return Boolean.TRUE; } return Boolean.FALSE; }
private AssessmentQuestionVoCollection buildExistingQuestions(PatientAssessmentDataVo data, AssessmentQuestionGroupVo group) throws PresentationLogicException { if (data.getAnswerGroups() == null || group == null) return new AssessmentQuestionVoCollection(); checkDataIntegrity(data); AssessmentQuestionVoCollection result = new AssessmentQuestionVoCollection(); for (int x = 0; x < data.getAnswerGroups().size(); x++) { if (data.getAnswerGroups().get(x).getAssessmentQuestionGroup() != null && data.getAnswerGroups().get(x).getAssessmentQuestionGroup().equals(group)) { PatientAssessmentQuestionVoCollection answers = sortAnswersBySequence(data.getAnswerGroups().get(x).getAssessmentAnswers()); for (int y = 0; y < answers.size(); y++) { result.add(data.getAnswerGroups().get(x).getAssessmentAnswers().get(y).getAssessmentQuestion()); } } } return result; }
private AssessmentQuestionVoCollection buildExistingQuestions(PatientAssessmentDataVo data, AssessmentQuestionGroupVo group) throws PresentationLogicException { if(data.getAnswerGroups() == null || group == null) return new AssessmentQuestionVoCollection(); checkDataIntegrity(data); AssessmentQuestionVoCollection result = new AssessmentQuestionVoCollection(); for(int x = 0; x < data.getAnswerGroups().size(); x++) { if(data.getAnswerGroups().get(x).getAssessmentQuestionGroup() != null && data.getAnswerGroups().get(x).getAssessmentQuestionGroup().equals(group)) { PatientAssessmentQuestionVoCollection answers = sortAnswersBySequence(data.getAnswerGroups().get(x).getAssessmentAnswers()); for(int y = 0; y < answers.size(); y++) { result.add(data.getAnswerGroups().get(x).getAssessmentAnswers().get(y).getAssessmentQuestion()); } } } return result; }
private boolean populateGroupCollectionFromScreenMultipleGroupNoFlat(UserAssessmentVo assessment) { assessment.getQuestionGroups().clear(); int seqNo = 1; for(int i = 0; i < form.lyrTabs().tabAssessments().dyngrdDetails().getRows().size(); i++) { DynamicGridRow row = form.lyrTabs().tabAssessments().dyngrdDetails().getRows().get(i); AssessmentQuestionGroupVo assessmentQuestionGroupVo = (AssessmentQuestionGroupVo) row.getValue(); if(assessmentQuestionGroupVo.getQuestionsIsNotNull()) assessmentQuestionGroupVo.getQuestions().clear(); else assessmentQuestionGroupVo.setQuestions(new AssessmentQuestionVoCollection()); for (int j = 0; j < row.getRows().size(); j++) { DynamicGridRow childRow = row.getRows().get(j); if(childRow.getValue() instanceof AssessmentQuestionVo) { AssessmentQuestionVo value = (AssessmentQuestionVo) childRow.getValue(); value.setIsMandatory((Boolean) childRow.getCells().get(getGridColumn(COLUMN_MANDATORY)).getValue()); if(value.getIsMandatory() == null) value.setIsMandatory(Boolean.FALSE); value.setAllowsMultipleAnswers((Boolean) childRow.getCells().get(getGridColumn(COLUMN_MULTIANSWERS)).getValue()); if(value.getAllowsMultipleAnswers() == null) value.setAllowsMultipleAnswers(Boolean.FALSE); value.setActiveStatus( (PreActiveActiveInactiveStatus) childRow.getCells().get(getGridColumn(COLUMN_STATUS)).getValue()); value.setSequence(new Integer(seqNo++)); value.setAssessmentAnswerRole(getQuestionRole(value)); assessmentQuestionGroupVo.getQuestions().add(value); } } if(assessment.getQuestionGroups().contains(assessmentQuestionGroupVo) == false) assessment.getQuestionGroups().add(assessmentQuestionGroupVo); } return true; }
private UserAssessmentVo getCopyOfAssessmentVo(UserAssessmentVo assessment) { if(assessment == null) return null; // Clear all ids where the aggregation is composite assessment.setID_UserAssessment(null); assessment.setActiveStatus(PreActiveActiveInactiveStatus.PREACTIVE); for (int i = 0; assessment.getAssessmentRolesIsNotNull() && i < assessment.getAssessmentRoles().size(); i++) { assessment.getAssessmentRoles().get(i).setID_AssessmentRole(null); } for (int i = 0; assessment.getQuestionGroupsIsNotNull() && i < assessment.getQuestionGroups().size(); i++) { assessment.getQuestionGroups().get(i).setID_AssessmentQuestionGroup(null); AssessmentQuestionVoCollection voColl = new AssessmentQuestionVoCollection(); for (int j = 0; assessment.getQuestionGroups().get(i).getQuestionsIsNotNull() && j < assessment.getQuestionGroups().get(i).getQuestions().size(); j++) { AssessmentQuestionVo voAssessmentQuestion = assessment.getQuestionGroups().get(i).getQuestions().get(j); if (voAssessmentQuestion.getActiveStatusIsNotNull() && voAssessmentQuestion.getActiveStatus().equals(PreActiveActiveInactiveStatus.INACTIVE)) continue; voAssessmentQuestion.setID_AssessmentQuestion(null); for (int k = 0; voAssessmentQuestion.getAssessmentAnswerRoleIsNotNull() && k < voAssessmentQuestion.getAssessmentAnswerRole().size(); k++) { voAssessmentQuestion.getAssessmentAnswerRole().get(k).setID_AssessmentQuestionRole(null); } voColl.add(voAssessmentQuestion); } assessment.getQuestionGroups().get(i).setQuestions(voColl); } // End clear return assessment; }
@SuppressWarnings("unchecked") private AssessmentQuestionRoleVoCollection getQuestionRole(AssessmentQuestionVo voAssessmentQuestion) { HashMap map = form.getLocalContext().getAssessmentRoles(); if (map == null) return null; AssessmentQuestionRoleVoCollection voColl = new AssessmentQuestionRoleVoCollection(); AssessmentRoleVoCollection roleVoColl = getRoles(); for (int i = 0; i < roleVoColl.size(); i++) { AssessmentRoleVo voAssessRole = roleVoColl.get(i); if (voAssessRole.getAnswerAllIsNotNull() && voAssessRole.getAnswerAll().booleanValue() == false) { AssessmentQuestionVoCollection voAssQColl = (AssessmentQuestionVoCollection) map.get(voAssessRole.getAppRole().getID_AppRole()); if (voAssQColl != null) { if (voAssQColl.indexOf(voAssessmentQuestion) >= 0) { AssessmentQuestionRoleVo voAssessQuestionRole = new AssessmentQuestionRoleVo(); voAssessQuestionRole.setAppRole(voAssessRole.getAppRole()); voColl.add(voAssessQuestionRole); } } } } return voColl; }
private int countActiveQuestions(AssessmentQuestionVoCollection questions) { if (questions == null) return 0; int count = 0; for (int x = 0; x < questions.size(); x++) { AssessmentQuestionVo question = questions.get(x); //WDEV-11366 if (question.getActiveStatusIsNotNull() && question.getActiveStatus().equals(PreActiveActiveInactiveStatus.ACTIVE) && !isQuestionInvalidForPatient(question.getQuestion())) count++; } return count; }
private void populateQuestionsHierarchical(PatientAssessmentDataVo data) throws PresentationLogicException { if (data.getAnswerGroups() == null) return; checkDataIntegrity(data); boolean flatView = data.getUserAssessment().getIsFlatView().booleanValue(); boolean userCanAnswerToAllQuestion = checkUserRole(data.getUserAssessment());//wdev-3709 AssessmentQuestionGroupVoCollection existingGroups = buildExistingGroups(data); for (int x = 0; x < existingGroups.size(); x++) { if (existingGroups.get(x) != null) { AssessmentQuestionVoCollection existingQuestions = buildExistingQuestions(data, existingGroups.get(x)); if (flatView) { for (int y = 0; y < existingQuestions.size(); y++) { addQuestionRow(existingQuestions.get(y), existingGroups.get(x), getInstAnswer(data, existingGroups.get(x), existingQuestions.get(y)), userCanAnswerToAllQuestion);//wdev- 3709 } } else { addGroupRow(existingGroups.get(x), existingQuestions, data, userCanAnswerToAllQuestion);//wdev-3709 } } } }
private AssessmentQuestionVoCollection sortQuestionsBySequence(AssessmentQuestionVoCollection questionsToBeSorted) { if (questionsToBeSorted == null) return new AssessmentQuestionVoCollection(); int size = questionsToBeSorted.size(); int[] sorted = new int[size]; for (int x = 0; x < size; x++) { sorted[x] = x; } for (int x = 0; x < size; x++) { for (int y = 0; y < size; y++) { AssessmentQuestionVo source = questionsToBeSorted.get(sorted[x]); AssessmentQuestionVo compare = questionsToBeSorted.get(sorted[y]); if (source.getSequenceIsNotNull() && compare.getSequenceIsNotNull()) { if (source.getSequence().compareTo(compare.getSequence()) < 0) { int temp = sorted[x]; sorted[x] = sorted[y]; sorted[y] = temp; } } } } AssessmentQuestionVoCollection sortedQuestions = new AssessmentQuestionVoCollection(); for (int x = 0; x < size; x++) { sortedQuestions.add(questionsToBeSorted.get(sorted[x])); } return sortedQuestions; }
private DynamicGridRow addGroupRow(AssessmentQuestionGroupVo group, AssessmentQuestionVoCollection questions, PatientAssessmentDataVo data, boolean userCanAnswerToAllQuestion) throws PresentationLogicException { checkDataIntegrity(group); if (group.getLegendTextIsNotNull() && group.getLegendText().trim().length() > 0) addGroupLegend(group); DynamicGridColumn column = this.grid.getColumns().getByIdentifier(QUESTION_COLUMN); DynamicGridRow row = this.grid.getRows().newRow(); row.setBackColor(Color.Beige); row.setBold(true); row.setIdentifier(new GroupRowData(group, null)); row.setExpanded(true); DynamicGridCell cell = row.getCells().newCell(column, DynamicCellType.WRAPTEXT); cell.setValue(group.getName()); cell.setReadOnly(true); if (questions != null) { for (int x = 0; x < questions.size(); x++) { if (questions.get(x).getActiveStatusIsNotNull() && (data != null || questions.get(x).getActiveStatus().equals(PreActiveActiveInactiveStatus.ACTIVE))) { if (data == null) { //WDEV-11366 if (!isQuestionInvalidForPatient(questions.get(x).getQuestion())) addQuestionRow(row, questions.get(x), group, null, userCanAnswerToAllQuestion);//wdev-3709 } else addQuestionRow(row, questions.get(x), group, getInstAnswer(data, group, questions.get(x)), userCanAnswerToAllQuestion);//wdev-3709 } } } return row; }
private int countActiveQuestions(AssessmentQuestionVoCollection questions) { if(questions == null) return 0; int count = 0; for(int x = 0; x < questions.size(); x++) { AssessmentQuestionVo question = questions.get(x); if(question.getActiveStatusIsNotNull() && question.getActiveStatus().equals(PreActiveActiveInactiveStatus.ACTIVE)) count++; } return count; }
private void populateQuestionsHierarchical(PatientAssessmentDataVo data) throws PresentationLogicException { if(data.getAnswerGroups() == null) return; checkDataIntegrity(data); boolean flatView = data.getUserAssessment().getIsFlatView().booleanValue(); AssessmentQuestionGroupVoCollection existingGroups = buildExistingGroups(data); for(int x = 0; x < existingGroups.size(); x++) { if(existingGroups.get(x) != null) { AssessmentQuestionVoCollection existingQuestions = buildExistingQuestions(data, existingGroups.get(x)); if(flatView) { for(int y = 0; y < existingQuestions.size(); y++) { addQuestionRow(existingQuestions.get(y), existingGroups.get(x), getInstAnswer(data, existingGroups.get(x), existingQuestions.get(y))); } } else { addGroupRow(existingGroups.get(x), existingQuestions, data); } } } }
private AssessmentQuestionVoCollection sortQuestionsBySequence(AssessmentQuestionVoCollection questionsToBeSorted) { if(questionsToBeSorted == null) return new AssessmentQuestionVoCollection(); int size = questionsToBeSorted.size(); int[] sorted = new int[size]; for(int x = 0; x < size; x++) { sorted[x] = x; } for(int x = 0; x < size; x++) { for(int y = 0; y < size; y++) { AssessmentQuestionVo source = questionsToBeSorted.get(sorted[x]); AssessmentQuestionVo compare = questionsToBeSorted.get(sorted[y]); if(source.getSequenceIsNotNull() && compare.getSequenceIsNotNull()) { if(source.getSequence().compareTo(compare.getSequence()) < 0) { int temp = sorted[x]; sorted[x] = sorted[y]; sorted[y] = temp; } } } } AssessmentQuestionVoCollection sortedQuestions = new AssessmentQuestionVoCollection(); for(int x = 0; x < size; x++) { sortedQuestions.add(questionsToBeSorted.get(sorted[x])); } return sortedQuestions; }
private DynamicGridRow addGroupRow(AssessmentQuestionGroupVo group, AssessmentQuestionVoCollection questions, PatientAssessmentDataVo data) throws PresentationLogicException { checkDataIntegrity(group); DynamicGridColumn column = this.grid.getColumns().getByIdentifier(QUESTION_COLUMN); DynamicGridRow row = this.grid.getRows().newRow(); row.setBackColor(Color.Beige); row.setBold(true); row.setIdentifier(new GroupRowData(group, null)); row.setExpanded(true); DynamicGridCell cell = row.getCells().newCell(column, DynamicCellType.WRAPTEXT); cell.setValue(group.getName()); cell.setReadOnly(true); if(questions != null) { for(int x = 0; x < questions.size(); x++) { if(questions.get(x).getActiveStatusIsNotNull() && (data != null || questions.get(x).getActiveStatus().equals(PreActiveActiveInactiveStatus.ACTIVE))) { if(data == null) addQuestionRow(row, questions.get(x), group, null); else addQuestionRow(row, questions.get(x), group, getInstAnswer(data, group, questions.get(x))); } } } return row; }
private AssessmentQuestionRoleVoCollection getQuestionRole(AssessmentQuestionVo voAssessmentQuestion, HashMap assessmentRoleMap) { if (assessmentRoleMap == null) return null; AssessmentQuestionRoleVoCollection voColl = new AssessmentQuestionRoleVoCollection(); for (int i = 0; roleVoColl != null && i < roleVoColl.size(); i++) { AssessmentRoleVo voAssessRole = roleVoColl.get(i); if (voAssessRole.getAnswerAllIsNotNull() && voAssessRole.getAnswerAll().booleanValue() == false) { AssessmentQuestionVoCollection voAssQColl = (AssessmentQuestionVoCollection) assessmentRoleMap.get(voAssessRole.getAppRole().getID_AppRole()); if (voAssQColl != null) { if (voAssQColl.indexOf(voAssessmentQuestion) >= 0) { AssessmentQuestionRoleVo voAssessQuestionRole = new AssessmentQuestionRoleVo(); voAssessQuestionRole.setAppRole(voAssessRole.getAppRole()); voColl.add(voAssessQuestionRole); } } } } return voColl; }
private Boolean isQuestionSelected(AssessmentQuestionVo assessmentQuestionVo) { if (map == null || roleId == null) return Boolean.FALSE; AssessmentQuestionVoCollection voAssQColl = (AssessmentQuestionVoCollection) map.get(roleId); if (voAssQColl != null) { int index = voAssQColl.indexOf(assessmentQuestionVo); if (index >= 0) return Boolean.TRUE; } return Boolean.FALSE; }