/** * Function used to retrieve Questions & Answers for the service of the amended investigation */ public GeneralQuestionAnswerVoCollection getServiceQuestionsAnswers(OcsOrderSessionRefVo orderDetails, ServiceRefVo service) { if (orderDetails == null || service == null) return null; StringBuilder query = new StringBuilder(); query.append("SELECT questions "); query.append(" FROM OcsOrderSession AS ocsOrder LEFT JOIN ocsOrder.clinicalInfo AS clinInfo LEFT JOIN clinInfo.categoryQuestionAnswers AS categoryQA "); query.append(" LEFT JOIN categoryQA.serviceQuestionAnswers AS serviceQA LEFT JOIN serviceQA.service AS service LEFT JOIN serviceQA.serviceQuestionAnswers AS questions"); query.append(" WHERE ocsOrder.id = :ID_ORDER AND service.id = :ID_SERVICE"); ArrayList<String> paramNames = new ArrayList<String>(); ArrayList<Object> paramValues = new ArrayList<Object>(); paramNames.add("ID_ORDER"); paramValues.add(orderDetails.getID_OcsOrderSession()); paramNames.add("ID_SERVICE"); paramValues.add(service.getID_Service()); return GeneralQuestionAnswerVoAssembler.createGeneralQuestionAnswerVoCollectionFromGeneralQuestionAnswer(getDomainFactory().find(query.toString(), paramNames, paramValues)); }
/** * Function used to retrieve Question & Answers for the category for amended investigation */ public GeneralQuestionAnswerVoCollection getCategoryQuestionsAnswers(OcsOrderSessionRefVo orderDetails, Category category) { if (orderDetails == null || category == null) return null; StringBuilder query = new StringBuilder(); query.append("SELECT questions "); query.append(" FROM OcsOrderSession AS ocsOrder LEFT JOIN ocsOrder.clinicalInfo AS clinInfo LEFT JOIN clinInfo.categoryQuestionAnswers AS categoryQA "); query.append(" LEFT JOIN categoryQA.categoryQuestionAnswers AS questions LEFT JOIN categoryQA.category AS category "); query.append(" WHERE ocsOrder.id = :ID_ORDER AND category.id = :ID_CATEGORY "); ArrayList<String> paramNames = new ArrayList<String>(); ArrayList<Object> paramValues = new ArrayList<Object>(); paramNames.add("ID_ORDER"); paramValues.add(orderDetails.getID_OcsOrderSession()); paramNames.add("ID_CATEGORY"); paramValues.add(category.getID()); return GeneralQuestionAnswerVoAssembler.createGeneralQuestionAnswerVoCollectionFromGeneralQuestionAnswer(getDomainFactory().find(query.toString(), paramNames, paramValues)); }
public GeneralQuestionAnswerVoCollection getRadiologyQuestions(OrderInvestigationRefVo invVo) { if (invVo == null) throw new DomainRuntimeException("Investigation must be supplied in order to retrieve questions"); DomainFactory factory = getDomainFactory(); List returnedList = new ArrayList(); OrderInvestigation domInv = (OrderInvestigation) factory.getDomainObject(OrderInvestigation.class, invVo.getID_OrderInvestigation()); // Category Questions String hql = " select o.clinicalInfo.categoryQuestionAnswers from OcsOrderSession o " + " join o.investigations inv where inv.id = :investigationId"; List categoryList = factory.find(hql, new String[]{"investigationId"}, new Object[]{invVo.getID_OrderInvestigation()}); // We now have the CategoryQuestionAnswerCollection, from here, // get Category, Service and Investigation questions? Iterator catIt = categoryList.iterator(); while (catIt.hasNext()) { CategoryQuestionAnswer domCat = (CategoryQuestionAnswer) catIt.next(); // Category if (domCat.getCategory().getId() == Category.CLINICALIMAGING.getId()) returnedList.addAll(domCat.getCategoryQuestionAnswers()); // Service Questions String serviceHql = " select svc from CategoryQuestionAnswer cat " + " join cat.serviceQuestionAnswers as svc " + " where cat.id = :categoryId and svc.service.id = :serviceId"; List svcLst = factory.find(serviceHql, new String[]{"categoryId", "serviceId"}, new Object[]{domCat.getId(), domInv.getInvestigation().getProviderService().getLocationService().getService().getId()}); Iterator svcIt = svcLst.iterator(); while (svcIt.hasNext()) { ServiceQuestionAnswer svc = (ServiceQuestionAnswer) svcIt.next(); returnedList.addAll(svc.getServiceQuestionAnswers()); List invList = svc.getInvestigationQuestionAnswers(); Iterator invIt = invList.iterator(); while (invIt.hasNext()) { InvestigationQuestionAnswer inv = (InvestigationQuestionAnswer) invIt.next(); if (inv.getInvestigation().getId().equals(domInv.getInvestigation().getId())) returnedList.addAll(inv.getInvestigationQuestionAnswers()); } } } GeneralQuestionAnswerVoCollection returnColl = new GeneralQuestionAnswerVoCollection(); GeneralQuestionAnswerVoCollection questionColl = GeneralQuestionAnswerVoAssembler.createGeneralQuestionAnswerVoCollectionFromGeneralQuestionAnswer(returnedList); // wdev-3018 Remove all non-questions and non-answered questions for (int i=0; i<questionColl.size(); i++) { GeneralQuestionAnswerVo vo = questionColl.get(i); if (vo.getQuestion().getIsQuestionIsNotNull() && vo.getQuestion().getIsQuestion().booleanValue() == true) returnColl.add(vo); } return returnColl; }