private CategoryCollection getCategoryCollection(InvestigationOcsQuestionsVoCollection investigationOcsQuestionsColl) { CategoryCollection categoryColl = new CategoryCollection(); for (int i = 0; investigationOcsQuestionsColl != null && i < investigationOcsQuestionsColl.size(); i++) { InvestigationOcsQuestionsVo voOrderInv = investigationOcsQuestionsColl.get(i); if (voOrderInv.getInvestigationIndexIsNotNull()) { Category category = voOrderInv.getInvestigationIndex().getCategory(); if (categoryColl.indexOf(category) < 0) categoryColl.add(category); } } categoryColl.sort(); return categoryColl; }
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 GeneralQuestionAnswerVoCollection getInvestigationQuestions(InvestigationOcsQuestionsVo voInvOcs) { if(voInvOcs == null) return null; GeneralQuestionAnswerVoCollection invQuestions = new GeneralQuestionAnswerVoCollection(); for (int i = 0; i < voInvOcs.getAssocQuestions().size(); i++) { InvestigationQuestionShortVo voInvestigationQuestion = voInvOcs.getAssocQuestions().get(i); if(isQuestionRelevant(voInvestigationQuestion.getQuestion(), getAge(), getSex())) { GeneralQuestionAnswerVo voGeneralQuestionAnswer = new GeneralQuestionAnswerVo(); voGeneralQuestionAnswer.setQuestion(voInvestigationQuestion.getQuestion()); voGeneralQuestionAnswer.setWasMandatory(voInvestigationQuestion.getIsMandatory()); invQuestions.add(voGeneralQuestionAnswer); } } return invQuestions; }
private boolean isSameService(ServiceQuestionShortVo voServiceQ, InvestigationOcsQuestionsVo voInvOcs) { if(voServiceQ == null || voInvOcs == null) return false; ServiceLiteVo serviceConfigVo = voServiceQ.getServiceIsNotNull() ? voServiceQ.getService() : null; ServiceLiteVo serviceInvestigationVo = voInvOcs.getProviderServiceIsNotNull() && voInvOcs.getProviderService().getLocationServiceIsNotNull() ? voInvOcs.getProviderService().getLocationService().getService() : null; // Check against the same service if (serviceConfigVo != null && serviceConfigVo.equals(serviceInvestigationVo)) return true; return false; }
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); } }
public OcsQASessionVo setOcsQASessionAnswers(OcsQASessionVo voOcsQASession, CategoryQuestionShortVoCollection categoryConfigQuestions, ServiceQuestionShortVoCollection serviceConfigQuestions, InvestigationOcsQuestionsVoCollection investigationOcsQuestionsColl) { //Everything is driven by the Investigations if(investigationOcsQuestionsColl == null || investigationOcsQuestionsColl.size() == 0) return null; if(voOcsQASession == null) throw new CodingRuntimeException("Cannot set answers for null OcsQASessionVo"); if(voOcsQASession.getCategoryQuestionAnswers() == null) voOcsQASession.setCategoryQuestionAnswers(new CategoryQuestionAnswerVoCollection()); //Get a list of top Categories CategoryCollection categoryColl = getCategoryCollection(investigationOcsQuestionsColl); //Add new Category /Investigations/Service Questions for (int i = 0; i < categoryColl.size(); i++) { Category category = categoryColl.get(i); for (int j = 0; investigationOcsQuestionsColl != null && j < investigationOcsQuestionsColl.size(); j++) { InvestigationOcsQuestionsVo voInvestigation = investigationOcsQuestionsColl.get(j); CategoryQuestionAnswerVo voCategoryQuestionAnswerVo = getCategoryQuestionAnswer(category, voOcsQASession); if(voInvestigation.getInvestigationIndex().getCategory().equals(category) && isInvestigationAdded(voInvestigation, voOcsQASession) == false) { //Category Questions Hierarchy buildCategoryQuestions(category, voCategoryQuestionAnswerVo, categoryConfigQuestions); //Get Questions that have to be asked in every Investigations GeneralQuestionAnswerVoCollection askedInEveryInvestigations = getQuestionsToBeAskedInEveryInvestigation(category, categoryConfigQuestions, serviceConfigQuestions, voInvestigation); //Build Service and Investigation Questions buildServiceQuestions(category, voCategoryQuestionAnswerVo, serviceConfigQuestions, askedInEveryInvestigations, voInvestigation); //Aa CategoryQuestionAnswerVo if there is at least one Question added if(isAtLeastOneQuestionAdded(voCategoryQuestionAnswerVo)) { int index = voOcsQASession.getCategoryQuestionAnswers().indexOf(voCategoryQuestionAnswerVo); if(index < 0) voOcsQASession.getCategoryQuestionAnswers().add(voCategoryQuestionAnswerVo); else voOcsQASession.getCategoryQuestionAnswers().set(index, voCategoryQuestionAnswerVo); } if(voInvestigation.getProviderService() == null) { if(voCategoryQuestionAnswerVo.getClinicalInvestigationQuestionAnswers() == null) voCategoryQuestionAnswerVo.setClinicalInvestigationQuestionAnswers(new InvestigationQuestionAnswerVoCollection()); InvestigationQuestionAnswerVo voInvQuestionAnswer = getInstInvestigationQuestionAnswerFromConfigInvestigation(voInvestigation, voCategoryQuestionAnswerVo.getClinicalInvestigationQuestionAnswers(), askedInEveryInvestigations); voCategoryQuestionAnswerVo.getClinicalInvestigationQuestionAnswers().add(voInvQuestionAnswer); voOcsQASession.getCategoryQuestionAnswers().add(voCategoryQuestionAnswerVo); } } } } removeUnusedCategoryQuestions(categoryColl, voOcsQASession); removeUnusedInvestigations(investigationOcsQuestionsColl, voOcsQASession); return voOcsQASession; }
private GeneralQuestionAnswerVoCollection getQuestionsToBeAskedInEveryInvestigation(Category category, CategoryQuestionShortVoCollection categoryConfigQuestions, ServiceQuestionShortVoCollection serviceConfigQuestions, InvestigationOcsQuestionsVo voInvOcs) { //Category Questions GeneralQuestionAnswerVoCollection voColl = new GeneralQuestionAnswerVoCollection(); for (int i = 0; categoryConfigQuestions != null && i < categoryConfigQuestions.size(); i++) { CategoryQuestionShortVo categoryQuestion = categoryConfigQuestions.get(i); if(categoryQuestion.getOCRRCategoryIsNotNull() && categoryQuestion.getOCRRCategory().equals(category)) { if(categoryQuestion.getAskForInvestigationsIsNotNull() && categoryQuestion.getAskForInvestigations().booleanValue()) { //WDEV-3332 if(isCategoryQuestionActive(categoryQuestion)) { GeneralQuestionAnswerVo voGCQ = createNewCategoryQuestion(categoryQuestion); if(voGCQ != null) voColl.add(voGCQ); } } } } //Service Questions Category investigationCategory = voInvOcs != null && voInvOcs.getInvestigationIndexIsNotNull() && voInvOcs.getInvestigationIndex().getCategoryIsNotNull()?voInvOcs.getInvestigationIndex().getCategory():null; if(investigationCategory != null && investigationCategory .equals(category)) { for (int j = 0; serviceConfigQuestions != null && j < serviceConfigQuestions.size(); j++) { ServiceQuestionShortVo voServiceQ = serviceConfigQuestions.get(j); if(voServiceQ.getAskForInvestigationsIsNotNull() && voServiceQ.getAskForInvestigations().booleanValue()) { if(isSameService(voServiceQ, voInvOcs)) { GeneralQuestionAnswerVo voGSQ = createNewServiceQuestion(voServiceQ); if(voGSQ != null) voColl.add(voGSQ); } } } } return voColl; }