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 ServiceQuestionAnswerVo createDummyServiceQuaetionAnswerVo(InvestigationOcsQuestionsVo voInvOcs) { ServiceQuestionAnswerVo voServiceQuestionAnswer = new ServiceQuestionAnswerVo(); voServiceQuestionAnswer.setService(new ServiceLiteVo()); voServiceQuestionAnswer.getService().setServiceName("No Service"); voServiceQuestionAnswer.getService().setServiceCategory(ServiceCategory.CLINICAL); voServiceQuestionAnswer.setInvestigationQuestionAnswers(new InvestigationQuestionAnswerVoCollection()); voServiceQuestionAnswer.getInvestigationQuestionAnswers().add(new InvestigationQuestionAnswerVo()); voServiceQuestionAnswer.getInvestigationQuestionAnswers().get(0).setInvestigationQuestionAnswers(new GeneralQuestionAnswerVoCollection()); voServiceQuestionAnswer.getInvestigationQuestionAnswers().get(0).setInvestigation(voInvOcs); GeneralQuestionAnswerVoCollection voGQAColl = getInvestigationQuestions(voInvOcs); for( GeneralQuestionAnswerVo voItem : voGQAColl) voServiceQuestionAnswer.getInvestigationQuestionAnswers().get(0).getInvestigationQuestionAnswers().add(voItem); return voServiceQuestionAnswer; }
private DynamicGridRow addServiceRow(DynamicGridRow topCategoryRow, ServiceQuestionAnswerVo voServiceQAnswer) { DynamicGridRow serviceRow = addTreeRow(topCategoryRow.getRows().newRow(), voServiceQAnswer.getService().getServiceName()); serviceRow.setSelectable(false); serviceRow.setIdentifier(voServiceQAnswer); serviceRow.setBackColor(Color.AntiqueWhite); serviceRow.setBold(true); return serviceRow; }
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 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; }