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; }
public InvestigationOcsQuestionsVoCollection listInvestigationOcsQuestions(Integer[] serviceIds) { if (serviceIds == null || serviceIds.length == 0) return null; StringBuffer sb = new StringBuffer(); sb.append(" from Investigation as i1_1 where i1_1.id in "); sb.append("("); for (int i = 0; i < serviceIds.length; i++) { sb.append(serviceIds[i]); if (i < (serviceIds.length - 1)) sb.append(", "); } sb.append(")"); List list = getDomainFactory().find(sb.toString()); return InvestigationOcsQuestionsVoAssembler.createInvestigationOcsQuestionsVoCollectionFromInvestigation(list); }
private boolean isInvestigationRemoved(InvestigationRefVo voRefInvestigation, InvestigationOcsQuestionsVoCollection investigationOcsQuestionsColl) { for (int i = 0; investigationOcsQuestionsColl != null && i < investigationOcsQuestionsColl.size(); i++) { if(investigationOcsQuestionsColl.get(i).equals(voRefInvestigation)) return false; } return true; }
private void removeUnusedInvestigations(InvestigationOcsQuestionsVoCollection investigationOcsQuestionsColl, OcsQASessionVo ocsQASession) { InvestigationLiteVoCollection voExistingInvColl = getExistingInvestigations(ocsQASession); for (int i = 0; voExistingInvColl != null && i < voExistingInvColl.size(); i++) { //Check if the investigation was removed if(isInvestigationRemoved(voExistingInvColl.get(i), investigationOcsQuestionsColl)) { removeInvestigationFromVo(voExistingInvColl.get(i).getID_Investigation(), ocsQASession); } } }
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; }