private boolean isClinicalQuestionAlreadyAdded(GeneralQuestionAnswerVo generalQuestionAnswerVo, CategoryQuestionAnswerVoCollection categoryQuestionAnswerVoCollection) { if(categoryQuestionAnswerVoCollection != null) { for(CategoryQuestionAnswerVo voCatQuestionAnswer : categoryQuestionAnswerVoCollection) { if(voCatQuestionAnswer.getCategoryQuestionAnswersIsNotNull()) { for(GeneralQuestionAnswerVo voGenQuestAns : voCatQuestionAnswer.getCategoryQuestionAnswers()) { if(voGenQuestAns.getQuestion().equals(generalQuestionAnswerVo.getQuestion())) return true; } } } } return false; }
public OcsQASessionVo removeUnusedCategoryQuestions(OcsQASessionVo ocsQASession, CategoryCollection usedCategories) { if (ocsQASession == null || ocsQASession.getCategoryQuestionAnswers() == null) return ocsQASession; for (int i = ocsQASession.getCategoryQuestionAnswers().size() - 1; i >= 0; i--) { CategoryQuestionAnswerVo categoryQuestion = ocsQASession.getCategoryQuestionAnswers().get(i); if (!usedCategories.contains(categoryQuestion.getCategory())) ocsQASession.getCategoryQuestionAnswers().remove(categoryQuestion); } return ocsQASession; }
public OcsQASessionVo removeUnusedServiceQuestions(OcsQASessionVo ocsQASession, ArrayList<Integer> usedServices) { if (ocsQASession == null || ocsQASession.getCategoryQuestionAnswers() == null) return ocsQASession; for (int i = ocsQASession.getCategoryQuestionAnswers().size() - 1; i >= 0; i--) { CategoryQuestionAnswerVo categoryQuestion = ocsQASession.getCategoryQuestionAnswers().get(i); if (categoryQuestion.getServiceQuestionAnswers() != null) { for (int j = categoryQuestion.getServiceQuestionAnswers().size() - 1; j >= 0; j--) { ServiceQuestionAnswerVo serviceQuestion = categoryQuestion.getServiceQuestionAnswers().get(j); if (!usedServices.contains(serviceQuestion.getService().getID_Service())) categoryQuestion.getServiceQuestionAnswers().remove(serviceQuestion); } } } return ocsQASession; }
private InvestigationLiteVoCollection getExistingInvestigations(OcsQASessionVo voOcsQA) { if (voOcsQA == null) return null; InvestigationLiteVoCollection voColl = new InvestigationLiteVoCollection(); for (int i = 0; voOcsQA.getCategoryQuestionAnswersIsNotNull() && i < voOcsQA.getCategoryQuestionAnswers().size(); i++) { CategoryQuestionAnswerVo categoryQuestionAnswerVo = voOcsQA.getCategoryQuestionAnswers().get(i); for (int j = 0; categoryQuestionAnswerVo.getServiceQuestionAnswersIsNotNull() && j < categoryQuestionAnswerVo.getServiceQuestionAnswers().size(); j++) { ServiceQuestionAnswerVo serviceQuestionAnswerVo = categoryQuestionAnswerVo.getServiceQuestionAnswers().get(j); for (int k = 0; serviceQuestionAnswerVo.getInvestigationQuestionAnswers() != null && k < serviceQuestionAnswerVo.getInvestigationQuestionAnswers().size(); k++) { voColl.add(serviceQuestionAnswerVo.getInvestigationQuestionAnswers().get(k).getInvestigation()); } } } return voColl; }
private boolean isInvestigationAdded(InvestigationRefVo voRefInvestigation, OcsQASessionVo voOcsQA) { if(voRefInvestigation == null || voOcsQA == null) return false; for (int i = 0; voOcsQA.getCategoryQuestionAnswersIsNotNull() && i < voOcsQA.getCategoryQuestionAnswers().size(); i++) { CategoryQuestionAnswerVo categoryQuestionAnswerVo = voOcsQA.getCategoryQuestionAnswers().get(i); for (int j = 0; categoryQuestionAnswerVo.getServiceQuestionAnswersIsNotNull() && j < categoryQuestionAnswerVo.getServiceQuestionAnswers().size(); j++) { ServiceQuestionAnswerVo serviceQuestionAnswerVo = categoryQuestionAnswerVo.getServiceQuestionAnswers().get(j); for (int k = 0; serviceQuestionAnswerVo.getInvestigationQuestionAnswers() != null && k < serviceQuestionAnswerVo.getInvestigationQuestionAnswers().size(); k++) { if(voRefInvestigation.equals(serviceQuestionAnswerVo.getInvestigationQuestionAnswers().get(k).getInvestigation())) return true; } } } return false; }
private boolean isAtLeastOneQuestionAdded(CategoryQuestionAnswerVo voCategoryQuestionAnswerVo) { if(voCategoryQuestionAnswerVo == null) return false; if(voCategoryQuestionAnswerVo.getCategoryQuestionAnswers() != null && voCategoryQuestionAnswerVo.getCategoryQuestionAnswers().size() > 0) return true; for (int i = 0; voCategoryQuestionAnswerVo.getServiceQuestionAnswersIsNotNull() && i < voCategoryQuestionAnswerVo.getServiceQuestionAnswers().size(); i++) { ServiceQuestionAnswerVo serviceQuestionAnswerVo = voCategoryQuestionAnswerVo.getServiceQuestionAnswers().get(i); if(serviceQuestionAnswerVo.getServiceQuestionAnswers().size() > 0) return true; for (int j = 0; serviceQuestionAnswerVo.getInvestigationQuestionAnswersIsNotNull() && j < serviceQuestionAnswerVo.getInvestigationQuestionAnswers().size(); j++) { if(serviceQuestionAnswerVo.getInvestigationQuestionAnswers().get(j).getInvestigationQuestionAnswers().size() > 0) return true; } } return false; }
private DynamicGridRow addCategoryRow(CategoryQuestionAnswerVo voCatQAnswer) { DynamicGridRow topCategoryRow = addTreeRow(gridQuestions.getRows().newRow(), voCatQAnswer.getCategory().getText()); topCategoryRow.setSelectable(false); topCategoryRow.setIdentifier(voCatQAnswer.getCategory()); topCategoryRow.setBackColor(Color.Bisque); topCategoryRow.setBold(true); return topCategoryRow; }
private boolean categoryOrServiceOrQuestionsAdded(CategoryQuestionAnswerVo voCatQAnswer) { if (voCatQAnswer == null) return false; boolean serviceQuestionsAdded = voCatQAnswer.getServiceQuestionAnswersIsNotNull() && voCatQAnswer.getServiceQuestionAnswers().size() > 0 && voCatQAnswer.getServiceQuestionAnswers().get(0).getInvestigationQuestionAnswersIsNotNull() && voCatQAnswer.getServiceQuestionAnswers().get(0).getInvestigationQuestionAnswers().size() > 0; //WDEV-16804 boolean categoryQuestionsAdded = voCatQAnswer.getCategoryQuestionAnswersIsNotNull() && voCatQAnswer.getCategoryQuestionAnswers().size() > 0; return categoryQuestionsAdded || serviceQuestionsAdded; }
private void removeUnusedCategoryQuestions(CategoryCollection categoryColl, OcsQASessionVo voOcsQASession) { if (voOcsQASession == null || voOcsQASession.getCategoryQuestionAnswers() == null) return; for (int i = voOcsQASession.getCategoryQuestionAnswers().size() - 1; i >= 0; i--) { CategoryQuestionAnswerVo question = voOcsQASession.getCategoryQuestionAnswers().get(i); if (categoryColl == null || !categoryColl.contains(question.getCategory())) { voOcsQASession.getCategoryQuestionAnswers().remove(question); } } }
public OcsQASessionVo removeInvestigationFromVo(Integer investigationId, OcsQASessionVo ocsQASession) { if (investigationId == null) return ocsQASession; for (int i = 0; ocsQASession != null && ocsQASession.getCategoryQuestionAnswersIsNotNull() && i < ocsQASession.getCategoryQuestionAnswers().size(); i++) { CategoryQuestionAnswerVo categoryQuestionAnswerVo = ocsQASession.getCategoryQuestionAnswers().get(i); for (int j = 0; categoryQuestionAnswerVo.getServiceQuestionAnswersIsNotNull() && j < categoryQuestionAnswerVo.getServiceQuestionAnswers().size(); j++) { ServiceQuestionAnswerVo serviceQuestionAnswerVo = categoryQuestionAnswerVo.getServiceQuestionAnswers().get(j); if (serviceQuestionAnswerVo.getInvestigationQuestionAnswers() != null) { //Remove the Investigation Question Answer for (int k = serviceQuestionAnswerVo.getInvestigationQuestionAnswers().size() - 1; k >= 0; k--) { InvestigationQuestionAnswerVo invQAVo = serviceQuestionAnswerVo.getInvestigationQuestionAnswers().get(k); if (invQAVo.getInvestigationIsNotNull() && invQAVo.getInvestigation().getID_InvestigationIsNotNull() && invQAVo.getInvestigation().getID_Investigation().equals(investigationId)) { serviceQuestionAnswerVo.getInvestigationQuestionAnswers().remove(invQAVo); } } } } } return ocsQASession; }
private CategoryQuestionAnswerVo getCategoryQuestionAnswer(Category category, OcsQASessionVo voOcsQASession) { for (int i = 0; voOcsQASession != null && i < voOcsQASession.getCategoryQuestionAnswers().size(); i++) { if(voOcsQASession.getCategoryQuestionAnswers().get(i).getCategory().equals(category)) return voOcsQASession.getCategoryQuestionAnswers().get(i); } CategoryQuestionAnswerVo voCategoryQuestionAnswer = new CategoryQuestionAnswerVo(); voCategoryQuestionAnswer.setCategory(category); voCategoryQuestionAnswer.setServiceQuestionAnswers(new ServiceQuestionAnswerVoCollection()); voCategoryQuestionAnswer.setCategoryQuestionAnswers(new GeneralQuestionAnswerVoCollection()); return voCategoryQuestionAnswer; }
private boolean isCategoryQuestionAdded(CategoryQuestionAnswerVo voCategoryQuestionAnswer, QuestionInformationShortVo voQuestionInformation) { if(voQuestionInformation != null && voCategoryQuestionAnswer != null && voCategoryQuestionAnswer.getCategoryQuestionAnswersIsNotNull()) { for (int i = 0; i < voCategoryQuestionAnswer.getCategoryQuestionAnswers().size(); i++) { if(voQuestionInformation.equals(voCategoryQuestionAnswer.getCategoryQuestionAnswers().get(i).getQuestion())) { return true; } } } return false; }
private void buildCategoryQuestions(Category category, CategoryQuestionAnswerVo voCategoryQuestionAnswer, CategoryQuestionShortVoCollection categoryConfigQuestions) { // Add the Category question if now added before if (categoryConfigQuestions != null && categoryConfigQuestions.size() > 0) { if (voCategoryQuestionAnswer.getCategoryQuestionAnswers() == null) voCategoryQuestionAnswer.setCategoryQuestionAnswers(new GeneralQuestionAnswerVoCollection()); for (int i = 0; i < categoryConfigQuestions.size(); i++) { CategoryQuestionShortVo categoryQuestionShortVo = categoryConfigQuestions.get(i); if (categoryQuestionShortVo.getOCRRCategoryIsNotNull() && categoryQuestionShortVo.getOCRRCategory().equals(category)) { boolean categoryQuestionAdded = isCategoryQuestionAdded(voCategoryQuestionAnswer, categoryQuestionShortVo.getQuestionInformation()); boolean askedForEveryInvestigation = categoryQuestionShortVo.getAskForInvestigationsIsNotNull() && categoryQuestionShortVo.getAskForInvestigations().booleanValue(); //Don't add duplicated questions or questions marked as "Ask for every Investigation" if (categoryQuestionAdded == false && askedForEveryInvestigation == false && isCategoryQuestionActive(categoryQuestionShortVo)) voCategoryQuestionAnswer.getCategoryQuestionAnswers().add(createNewCategoryQuestion(categoryQuestionShortVo)); } } } else { // Clear category questions voCategoryQuestionAnswer.setCategoryQuestionAnswers(null); } }
private void buildServiceQuestions(Category category, CategoryQuestionAnswerVo voCategoryQuestionAnswerVo, ServiceQuestionShortVoCollection serviceConfigQuestions, GeneralQuestionAnswerVoCollection askedInEveryInvestigations, InvestigationOcsQuestionsVo voInvOcs) { if (voInvOcs != null) { Category investigationCategory = voInvOcs.getInvestigationIndexIsNotNull() && voInvOcs.getInvestigationIndex().getCategoryIsNotNull() ? voInvOcs.getInvestigationIndex().getCategory() : null; if (investigationCategory != null && investigationCategory.equals(category)) { ServiceLiteVo serviceVo = voInvOcs.getProviderServiceIsNotNull() && voInvOcs.getProviderService().getLocationServiceIsNotNull() ? voInvOcs.getProviderService().getLocationService().getService() : null; if(serviceVo != null) { ServiceQuestionAnswerVo voServiceQA = getInstServiceQuestionAnswerFromConfigService(serviceConfigQuestions, voCategoryQuestionAnswerVo, askedInEveryInvestigations, serviceVo, voInvOcs); boolean questionsAdded = voServiceQA != null && voServiceQA.getServiceQuestionAnswersIsNotNull() && voServiceQA.getServiceQuestionAnswers().size() > 0; boolean investigationQuestionsAdded = voServiceQA != null && voServiceQA.getInvestigationQuestionAnswersIsNotNull() && voServiceQA.getInvestigationQuestionAnswers().size() > 0; //Add the Service only if there is at least one Service or Investigation Question if(questionsAdded || investigationQuestionsAdded) { if (voCategoryQuestionAnswerVo.getServiceQuestionAnswers() == null) voCategoryQuestionAnswerVo.setServiceQuestionAnswers(new ServiceQuestionAnswerVoCollection()); int index = voCategoryQuestionAnswerVo.getServiceQuestionAnswers().indexOf(voServiceQA); if(index < 0) voCategoryQuestionAnswerVo.getServiceQuestionAnswers().add(voServiceQA); else voCategoryQuestionAnswerVo.getServiceQuestionAnswers().set(index, voServiceQA); } } } } else { voCategoryQuestionAnswerVo.setServiceQuestionAnswers(null); } }
private static GeneralQuestionAnswerVoCollection getGeneralQuestionAnswerCollection(OcsQASessionVo voOcsQASession) { GeneralQuestionAnswerVoCollection voColl = new GeneralQuestionAnswerVoCollection(); for (int j = 0; voOcsQASession != null && voOcsQASession.getCategoryQuestionAnswersIsNotNull() && j < voOcsQASession.getCategoryQuestionAnswers().size(); j++) { CategoryQuestionAnswerVo voCatQAnswer = voOcsQASession.getCategoryQuestionAnswers().get(j); // Category for (int k = 0; k < voCatQAnswer.getCategoryQuestionAnswers().size(); k++) { voColl.add(voCatQAnswer.getCategoryQuestionAnswers().get(k)); } // Service for (int k = 0; k < voCatQAnswer.getServiceQuestionAnswers().size(); k++) { ServiceQuestionAnswerVo voServiceQAnswer = voCatQAnswer.getServiceQuestionAnswers().get(k); for (int index = 0; index < voServiceQAnswer.getServiceQuestionAnswers().size(); index++) { voColl.add(voServiceQAnswer.getServiceQuestionAnswers().get(index)); } for (int i = 0; i < voServiceQAnswer.getInvestigationQuestionAnswers().size(); i++) { InvestigationQuestionAnswerVo voSQAnswer = voServiceQAnswer.getInvestigationQuestionAnswers().get(i); for (int index = 0; voSQAnswer != null && index < voSQAnswer.getInvestigationQuestionAnswers().size(); index++) { voColl.add(voSQAnswer.getInvestigationQuestionAnswers().get(index)); } } } } return voColl; }
public String[] validateAnswers() { OcsQASessionVo voValidate = new OcsQASessionVo(); voValidate = this.getAnswers(voValidate); ArrayList<String> errors = new ArrayList<String>(); if (voValidate != null) { for (int i = 0; voValidate.getCategoryQuestionAnswersIsNotNull() && i < voValidate.getCategoryQuestionAnswers().size(); i++) { CategoryQuestionAnswerVo voCQA = voValidate.getCategoryQuestionAnswers().get(i); // Category Questions getMandatoryQuestionErrors(errors, voCQA.getCategoryQuestionAnswers(), voCQA.getCategory().toString()); for (int j = 0; j < voCQA.getServiceQuestionAnswers().size(); j++) { ServiceQuestionAnswerVo voSQA = voCQA.getServiceQuestionAnswers().get(j); //ServiceQuestions getMandatoryQuestionErrors(errors, voSQA.getServiceQuestionAnswers(), voSQA.getService().getServiceName()); for (int k = 0; k < voSQA.getInvestigationQuestionAnswers().size(); k++) { InvestigationQuestionAnswerVo voIQA = voSQA.getInvestigationQuestionAnswers().get(k); //Investigation Questions getMandatoryQuestionErrors(errors, voIQA.getInvestigationQuestionAnswers(), voIQA.getInvestigation().getInvestigationIndex().getName()); } } } } if (errors.size() > 0) { String[] errs = new String[errors.size()]; errors.toArray(errs); return errs; } return null; }