private void concatenatePatientDocumentsToFinalPDF(String fileName, StringBuilder msg) { PatientDocumentForICPReportsVoCollection patientDocuments = domain.getPatientDocuments(form.getGlobalContext().ICP.getPatientICPRecord()); if(patientDocuments == null || patientDocuments.size() == 0) { msg.append("No Scanned documents found!"); msg.append("<br>"); return; } for(int i=0; i<patientDocuments.size(); i++) { PatientDocumentForICPReportsVo document = patientDocuments.get(i); if(document == null || !document.getServerDocumentIsNotNull()) continue; String documentName = getPDFStorePath() + document.getServerDocument().getFileName(); byte[] result = readFile(documentName); if(result != null && result.length > 0) { if(appendToFile(fileName, result) == false) { msg.append("Could not append Scanned documents!"); msg.append("<br>"); return; } } else { msg.append("Could not read Scanned document from path '" + documentName + "' !"); msg.append("<br>"); return; } } }
@SuppressWarnings("rawtypes") public PatientDocumentForICPReportsVoCollection getPatientDocuments(PatientICPRefVo patientICPRef) { if(patientICPRef == null || !patientICPRef.getID_PatientICPIsNotNull()) throw new CodingRuntimeException("Parameter patientIcpRef cannot be null !"); Integer careContextId = null; DomainFactory factory = getDomainFactory(); String hql = "select p1_1.careContext.id from PatientICP as p1_1 where (p1_1.id = :ID)"; List list = factory.find(hql, new String[] {"ID"}, new Object[] {patientICPRef.getID_PatientICP()}); if(list != null && list.size() > 0) { careContextId = (Integer)list.get(0); } if(careContextId == null) { //it should never get here as every patientICP has a care context System.out.println("Could not get careContext for patientICP " + patientICPRef.getID_PatientICP()); } hql = "select pdoc from CatsReferral as cats join cats.referralDocuments as pdoc where (cats.careContext.id = :CCID)"; list = factory.find(hql, new String[] {"CCID"}, new Object[] {careContextId}); return PatientDocumentForICPReportsVoAssembler.createPatientDocumentForICPReportsVoCollectionFromPatientDocument(list); }