private void rollback(EDischargeSTHKSummaryVo summaryVo, PatientDocumentVo document, DocumentCategory category) throws ForeignKeyViolationException, StaleObjectException { DomainFactory factory = getDomainFactory(); Summary boSUMM = (Summary) factory.getDomainObject(Summary.class, summaryVo.getID_Summary()); summaryVo = EDischargeSTHKSummaryVoAssembler.create(boSUMM); PatientDocumentVoCollection documents = summaryVo.getDischargeDocuments(); documents.remove(document); summaryVo.setDischargeDocuments(documents); if (category.equals(DocumentCategory.DISCHARGE_SUMMARY)) summaryVo.setDischargeLetterStatus(DischargeLetterStatus.IN_PROGRESS); else if (category.equals(DocumentCategory.DISCHARGE_SUPPLEMENTARY)) summaryVo.setDischargeSupplementaryLetterStatus(DischargeSupplementaryLetterStatus.REQUIRED); String[] str = summaryVo.validate(); if (str != null && str.length > 0) { LOG.error("summaryVo is not validate"); return; } summaryVo = saveSummary(summaryVo); try { deletePatientDocument(document); } catch(Exception e) { throw new StaleObjectException(null); } getDomainFactory().getTransaction().commit(); getDomainFactory().setTransaction(null); }
public DischargeReadyToLeaveVo saveReadyToLeave(DischargeReadyToLeaveVo voReady, SummaryRefVo voSummary) throws DomainInterfaceException, StaleObjectException { if(voReady == null) throw new CodingRuntimeException("DischargeReadyToLeaveVo is null"); if(!voReady.isValidated()) throw new CodingRuntimeException("DischargeReadyToLeaveVo Value Object has not been validated"); DomainFactory factory = getDomainFactory(); //There is a situation where is possible that the scheduled jobs have run while you //are editing the ready to leave record. This should be dealt with by throwing a StaleObjectException String hql = "select count(summa.id) from Summary as summa where (summa.id=:sumId and (summa.dischargeLetterStatus.id =:dischLettId or summa.dischargeSupplementaryLetterStatus.id = :dischSuppLettId))"; long isCompleted = factory.countWithHQL(hql, new String[]{"sumId","dischLettId","dischSuppLettId"}, new Object[]{voSummary.getID_Summary(),DischargeLetterStatus.GENERATED.getId(),DischargeSupplementaryLetterStatus.GENERATED.getID()}); if (isCompleted > 0) { throw new StaleObjectException(null); } ReadyToLeave doRTL = DischargeReadyToLeaveVoAssembler.extractReadyToLeave(factory, voReady); factory.save(doRTL); //updating summary WDEV-11348 IEDischargeHelper impl = (IEDischargeHelper) getDomainImpl(EDischargeHelper.class); impl.updateSummaryIfRequired(voReady, voSummary, factory); return DischargeReadyToLeaveVoAssembler.create(doRTL); }
public DischargeReportDetailVoCollection getSuppPatientDocuments() { List<CareContext> careContexts = new ArrayList<CareContext>(); String careContextIDs = ""; List domainObjectList = null; DomainFactory factory = getDomainFactory(); StringBuffer hql = new StringBuffer(" select dd.careContext from DischargeDetails dd where "); String andStr = " "; ArrayList<String> markers = new ArrayList<String>(); ArrayList<Serializable> values = new ArrayList<Serializable>(); hql.append(andStr + " dd.dischargeSupplementaryLetterStatus = :stat"); markers.add("stat"); values.add(getDomLookup(DischargeSupplementaryLetterStatus.REQUIRED)); andStr = " and "; List list = factory.find(hql.toString(), markers,values); if(list != null && !list.isEmpty()) { for (Iterator iter = list.iterator(); iter.hasNext();) { CareContext careContext = (CareContext) iter.next(); if (careContext != null) { if (careContextIDs != "") careContextIDs += " , "; careContexts.add(careContext); careContextIDs += careContext.getId(); } } } else return null; if (careContexts.size() > 0) { domainObjectList = factory.find("select drd from DischargeReportDetail as drd left join drd.careContext as cc where cc.id in ( " + careContextIDs + " )"); return DischargeReportDetailVoAssembler.createDischargeReportDetailVoCollectionFromDischargeReportDetail(domainObjectList); } return null; }
private void rollback(DischargeDetailsVo dischargeDetails, DischargeReportDetailVo report, PatientDocumentVo document, DocumentCategory category) throws ForeignKeyViolationException, StaleObjectException { DomainFactory factory = getDomainFactory(); DischargeDetails boDischarge = (DischargeDetails) factory.getDomainObject(DischargeDetails.class, dischargeDetails.getID_DischargeDetails()); dischargeDetails = DischargeDetailsVoAssembler.create(boDischarge); DischargeReportDetail boDischargeReport = (DischargeReportDetail) factory.getDomainObject(DischargeReportDetail.class, report.getID_DischargeReportDetail()); report = DischargeReportDetailVoAssembler.create(boDischargeReport); PatientDocumentVoCollection documents = report.getDischargeDocuments(); documents.remove(document); report.setDischargeDocuments(documents); if (category.equals(DocumentCategory.DISCHARGE_SUMMARY)) { dischargeDetails.setDischargeLetterStatus(DischargeLetterStatus.IN_PROGRESS); } else if (category.equals(DocumentCategory.DISCHARGE_SUPPLEMENTARY)) { dischargeDetails.setDischargeSupplementaryLetterStatus(DischargeSupplementaryLetterStatus.REQUIRED); } String[] str = dischargeDetails.validate(); if (str != null && str.length > 0) { LOG.error("DischargeDetailsVo is not validate"); return; } str = report.validate(); if (str != null && str.length > 0) { LOG.error("DischargeReportDetailsVo is not validate"); return; } dischargeDetails = saveDischargeDetails(dischargeDetails); report = saveDischargeReportDetail(report); try { deletePatientDocument(document); } catch(Exception e) { throw new StaleObjectException(null); } getDomainFactory().getTransaction().commit(); getDomainFactory().setTransaction(null); }