private synchronized void saveJob(EDDischargeSummaryScheduleVo job) { if(job == null) return; job.setGeneratedLettersNo(job.getGeneratedLettersNo() != null ? job.getGeneratedLettersNo() + GeneratedLettersNo : GeneratedLettersNo); job.setPrintedLettersNo(job.getPrintedLettersNo() != null ? job.getPrintedLettersNo() + PrintedLettersNo : PrintedLettersNo); if (!Boolean.TRUE.equals(job.getPrintLettersOnly())) { job.setSuccessfulEmailsNo(job.getSuccessfulEmailsNo() != null ? job.getSuccessfulEmailsNo() + SuccessfulEmailsNo : SuccessfulEmailsNo); job.setFailedEmailsNo(job.getFailedEmailsNo() != null ? job.getFailedEmailsNo() + FailedEmailsNo : FailedEmailsNo); } DomainFactoryBridge factory = getDomainFactory(); EDDischargeSummarySchedule doJob = EDDischargeSummaryScheduleVoAssembler.extractEDDischargeSummarySchedule(factory, job); try { factory.save(doJob); } catch (StaleObjectException e) { trace("Job details save failed! " + e.getMessage()); return; } }
private void populateScreenFromData(EDDischargeSummaryScheduleVo record) { clear(); if(record == null) return; form.cmbPrint().setValue(record.getPrintAgentTo()); if (!Boolean.TRUE.equals(record.getPrintLettersOnly())) { form.intFailedEmailsNo().setValue(record.getFailedEmailsNo()); form.intSuccessfulEmailsNo().setValue(record.getSuccessfulEmailsNo()); } form.intGeneratedLettersNo().setValue(record.getGeneratedLettersNo()); form.intPrintedLettersNo().setValue(record.getPrintedLettersNo()); form.chkDisableEmail().setValue(record.getPrintLettersOnly()); form.lblPrinter().setValue(Boolean.TRUE.equals(record.getPrintLettersOnly()) ? "Print all discharge summary reports to:" : "For GPs without e-mail, print the discharge summary report to:"); }
private void populateScreenFromData(EDDischargeSummaryScheduleVo record) { clear(); if(record == null) return; form.cmbPrint().setValue(record.getPrintAgentTo()); form.intFailedEmailsNo().setValue(record.getFailedEmailsNo()); form.intGeneratedLettersNo().setValue(record.getGeneratedLettersNo()); form.intPrintedLettersNo().setValue(record.getPrintedLettersNo()); form.intSuccessfulEmailsNo().setValue(record.getSuccessfulEmailsNo()); }
public void saveData() throws Exception { EDDischargeSummaryScheduleVo record = getData(); String[] errors = record.validate(getUIErrors()); if(errors != null && errors.length > 0) throw new Exception("Validation Errors"); domain.saveConfiguration(record); }
public EDDischargeSummaryScheduleVo getData() { EDDischargeSummaryScheduleVo record = populateDataFromScreen(form.getLocalContext().getRecord()); record.setConfiguredJobDetails(form.getGlobalContext().Admin.getCurrentJobConfiguration()); return record; }
public void loadData() { EDDischargeSummaryScheduleVo record = domain.getConfiguration(form.getGlobalContext().Admin.getCurrentJobConfiguration()); form.getLocalContext().setRecord(record); populateScreenFromData(record); }
@Override public SchedulerJobExecutionSummary doExecute() throws JobExecutionException { long start = System.currentTimeMillis(); StringBuilder summaryMessage = new StringBuilder(); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); summaryMessage.append("Start job at: " + calendar.getTime()); summaryMessage.append("\n"); trace("Scheduled job has started"); EDDischargeSummaryScheduleVo job = getJobDetails(); if (job == null) { throw new JobExecutionException("Job configuration missing"); } printer = job.getPrintAgentTo(); TrackingJobVoCollection dischargedTrackings = getDischargedTrackings(); try { savePatientDocuments(dischargedTrackings, job); } catch(Exception e) { trace("Conversion error: " + e.getMessage()); summaryMessage.append("Scheduled job failed!"); summaryMessage.append("\n"); summaryMessage.append("Total generated letters: " + GeneratedLettersNo); //WDEV-18840 return new SchedulerJobExecutionSummary(SchedulerJobExecutionStatus.FAILED, e.getMessage()); } saveJob(job); long end = System.currentTimeMillis(); calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); summaryMessage.append("End job at: " + calendar.getTime()); summaryMessage.append("\n"); int d = (int) (((end - start) / 1000) / 86400); int h = (int) (((end - start) / 1000) / 3600); int m = (int) ((((end - start) / 1000) / 60) % 60); int s = (int) (((end - start) / 1000) % 60); summaryMessage.append("Total time for execution: " + d + " days, " + h + " hours, " + m + " minutes, " + s + " seconds"); summaryMessage.append("\n"); summaryMessage.append("Total generated letters: " + GeneratedLettersNo); summaryMessage.append("\n"); summaryMessage.append("Total printed letters: " + PrintedLettersNo); summaryMessage.append("\n"); //WDEV-23034 if (Boolean.TRUE.equals(job.getPrintLettersOnly())) { summaryMessage.append("E-mail function of the job is currently disabled. No letters were e-mailed."); summaryMessage.append("\n"); } else { summaryMessage.append("Total successful e-mails: " + SuccessfulEmailsNo); summaryMessage.append("\n"); summaryMessage.append("Total failed e-mails: " + FailedEmailsNo); summaryMessage.append("\n"); } summaryMessage.append("Scheduled job was completed successfully."); trace("Scheduled job has ended"); return new SchedulerJobExecutionSummary(SchedulerJobExecutionStatus.SUCCEEDED, summaryMessage.toString()); }
private EDDischargeSummaryScheduleVo getJobDetails() { EDDischargeSummarySchedule doEDDischargeSummarySchedule = EDDischargeSummarySchedule.getEDDischargeSummaryScheduleFromConfiguredJobDetails(getDomainFactory(), super.getConfiguredJob().getConfiguredScheduledJobID()); return EDDischargeSummaryScheduleVoAssembler.create(doEDDischargeSummarySchedule); }
private synchronized void savePatientDocuments(TrackingJobVoCollection dischargedTrackings, EDDischargeSummaryScheduleVo job) throws Exception { if(dischargedTrackings == null || dischargedTrackings.size() == 0) return; urlQueryServer = ConfigFlag.GEN.QUERY_SERVER_URL.getValue(); urlReportServer = ConfigFlag.GEN.REPORT_SERVER_URL.getValue(); urlPdfUploadServer = ConfigFlag.GEN.PDF_UPLOAD_URL.getValue(); pdfStorePath = ConfigFlag.GEN.PDF_STORE_PATH.getValue(); if (urlQueryServer == "") { throw new JobExecutionException("QUERY_SERVER_URL flag need to be set"); } if (urlReportServer == "") { throw new JobExecutionException("REPORT_SERVER_URL flag need to be set"); } if (urlPdfUploadServer == "") { throw new JobExecutionException("PDF_UPLOAD_URL flag need to be set"); } if (pdfStorePath == "") { throw new JobExecutionException("PDF_STORE_PATH flag need to be set"); } Object[] obj = getSystemReportAndTemplate(ED_DISCHARGE_SUMMARY_REPORT_ID); if(obj == null || obj.length < 2) { throw new JobExecutionException("getSystemReportAndTemplate return null"); } if(obj[0] == null || obj[1] == null) { throw new JobExecutionException("getSystemReportAndTemplate return null"); } GeneratedLettersNo = 0; SuccessfulEmailsNo = 0; FailedEmailsNo = 0; PrintedLettersNo = 0; //WDEV-23034 boolean disableEmail = Boolean.TRUE.equals(job.getPrintLettersOnly()); for (TrackingJobVo tracking : dischargedTrackings) { createPatientDocument(tracking, obj[0], obj[1], disableEmail); } }
@Override public SchedulerJobExecutionSummary doExecute() throws JobExecutionException { long start = System.currentTimeMillis(); StringBuilder summaryMessage = new StringBuilder(); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); summaryMessage.append("Start job at: " + calendar.getTime()); summaryMessage.append("\n"); trace("Scheduled job has started"); EDDischargeSummaryScheduleVo job = getJobDetails(); if (job == null) { throw new JobExecutionException("Job configuration missing"); } printer = job.getPrintAgentTo(); TrackingJobVoCollection dischargedTrackings = getDischargedTrackingsRequiringLetter(); try { savePatientDocuments(dischargedTrackings, job); } catch(Exception e) { trace("Conversion error: " + e.getMessage()); summaryMessage.append("Scheduled job failed!"); summaryMessage.append("\n"); summaryMessage.append("Total generated letters: " + GeneratedLettersNo); //WDEV-18840 return new SchedulerJobExecutionSummary(SchedulerJobExecutionStatus.FAILED, e.getMessage()); } saveJob(job); long end = System.currentTimeMillis(); calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); summaryMessage.append("End job at: " + calendar.getTime()); summaryMessage.append("\n"); int d = (int) (((end - start) / 1000) / 86400); int h = (int) (((end - start) / 1000) / 3600); int m = (int) ((((end - start) / 1000) / 60) % 60); int s = (int) (((end - start) / 1000) % 60); summaryMessage.append("Total time for execution: " + d + " days, " + h + " hours, " + m + " minutes, " + s + " seconds"); summaryMessage.append("\n"); summaryMessage.append("Total generated letters: " + GeneratedLettersNo); summaryMessage.append("\n"); summaryMessage.append("Total printed letters: " + PrintedLettersNo); summaryMessage.append("\n"); //WDEV-23034 if (Boolean.TRUE.equals(job.getPrintLettersOnly())) { summaryMessage.append("E-mail function of the job is currently disabled. No letters were e-mailed."); summaryMessage.append("\n"); } else { summaryMessage.append("Total successful e-mails: " + SuccessfulEmailsNo); summaryMessage.append("\n"); summaryMessage.append("Total failed e-mails: " + FailedEmailsNo); summaryMessage.append("\n"); } summaryMessage.append("Scheduled job has completed successfully."); trace("Scheduled job has ended"); return new SchedulerJobExecutionSummary(SchedulerJobExecutionStatus.SUCCEEDED, summaryMessage.toString()); }
private synchronized void savePatientDocuments(TrackingJobVoCollection dischargedTrackings, EDDischargeSummaryScheduleVo job) throws Exception { if(dischargedTrackings == null || dischargedTrackings.size() == 0) return; urlQueryServer = ConfigFlag.GEN.QUERY_SERVER_URL.getValue(); urlReportServer = ConfigFlag.GEN.REPORT_SERVER_URL.getValue(); urlPdfUploadServer = ConfigFlag.GEN.PDF_UPLOAD_URL.getValue(); pdfStorePath = ConfigFlag.GEN.PDF_STORE_PATH.getValue(); if (urlQueryServer == "") { throw new JobExecutionException("QUERY_SERVER_URL flag need to be set"); } if (urlReportServer == "") { throw new JobExecutionException("REPORT_SERVER_URL flag need to be set"); } if (urlPdfUploadServer == "") { throw new JobExecutionException("PDF_UPLOAD_URL flag need to be set"); } if (pdfStorePath == "") { throw new JobExecutionException("PDF_STORE_PATH flag need to be set"); } Object[] obj = getSystemReportAndTemplate(ED_DISCHARGE_SUMMARY_REPORT_ID); if(obj == null || obj.length < 2) { throw new JobExecutionException("getSystemReportAndTemplate return null"); } if(obj[0] == null || obj[1] == null) { throw new JobExecutionException("getSystemReportAndTemplate return null"); } GeneratedLettersNo = 0; SuccessfulEmailsNo = 0; FailedEmailsNo = 0; PrintedLettersNo = 0; //WDEV-23034 boolean disableEmail = Boolean.TRUE.equals(job.getPrintLettersOnly()); for(TrackingJobVo tracking : dischargedTrackings) { createPatientDocument(tracking, obj[0], obj[1],disableEmail); } }