Updataes to spreadsheet processing

added npe check
modified file name column
diff --git a/cda/plugins/org.eclipse.mdht.cda.xml.ui/src/org/eclipse/mdht/cda/xml/ui/handlers/CDAValueUtil.java b/cda/plugins/org.eclipse.mdht.cda.xml.ui/src/org/eclipse/mdht/cda/xml/ui/handlers/CDAValueUtil.java
index c080a95..584b18f 100644
--- a/cda/plugins/org.eclipse.mdht.cda.xml.ui/src/org/eclipse/mdht/cda/xml/ui/handlers/CDAValueUtil.java
+++ b/cda/plugins/org.eclipse.mdht.cda.xml.ui/src/org/eclipse/mdht/cda/xml/ui/handlers/CDAValueUtil.java
@@ -505,7 +505,6 @@
 	}
 
 	static String getValueAsString(Section section, CD cd) {
-
 		StringBuffer sb = new StringBuffer();
 
 		if (cd != null) {
@@ -513,17 +512,17 @@
 			if (!StringUtils.isEmpty(cd.getDisplayName())) {
 				sb.append(cd.getDisplayName());
 			} else if (cd.getOriginalText() != null && cd.getOriginalText().getReference() != null) {
-				String s = cd.getOriginalText().getReference().getValue();
-
-				String result = section.getText() != null
-						? section.getText().getText(s.substring(1))
-						: "";
-				if (!StringUtils.isEmpty(result)) {
-					sb.append(result);
+				String reference = cd.getOriginalText().getReference().getValue();
+				if (!StringUtils.isEmpty(reference) && section.getText() != null) {
+					String result = section.getText().getText(reference.substring(1));
+					if (!StringUtils.isEmpty(result)) {
+						sb.append(result);
+					} else {
+						sb.append("Missing in narrative " + reference);
+					}
 				} else {
-					sb.append("Missing in narrative " + s);
+					sb.append("Reference Value Missing.");
 				}
-
 			} else if (cd.getOriginalText() != null && !StringUtils.isEmpty(cd.getOriginalText().getText())) {
 
 				sb.append(cd.getOriginalText().getText());
diff --git a/cda/plugins/org.eclipse.mdht.cda.xml.ui/src/org/eclipse/mdht/cda/xml/ui/handlers/GenerateCDADataHandler.java b/cda/plugins/org.eclipse.mdht.cda.xml.ui/src/org/eclipse/mdht/cda/xml/ui/handlers/GenerateCDADataHandler.java
index 916de1c..159e184 100644
--- a/cda/plugins/org.eclipse.mdht.cda.xml.ui/src/org/eclipse/mdht/cda/xml/ui/handlers/GenerateCDADataHandler.java
+++ b/cda/plugins/org.eclipse.mdht.cda.xml.ui/src/org/eclipse/mdht/cda/xml/ui/handlers/GenerateCDADataHandler.java
@@ -424,9 +424,12 @@
 				ILog log = Activator.getDefault().getLog();
 				log.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error generating report", e));
 				throw new InvocationTargetException(e);
-			} catch (Exception e) {
+			} catch (NullPointerException e) {
 				ILog log = Activator.getDefault().getLog();
 				log.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error generating report", e));
+			} catch (Exception e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
 			}
 		}
 	}
@@ -557,11 +560,14 @@
 
 				for (Object element : treeSelection.toList()) {
 					// IStructuredSelection aslection = (IStructuredSelection) element;
-
-					pd.run(
-						true, true,
-						new ProcessSelection(element, splitOption, filterOption, theSections, theSectionCache));
-
+					try {
+						pd.run(
+							true, true,
+							new ProcessSelection(element, splitOption, filterOption, theSections, theSectionCache));
+					} catch (Throwable e) {
+						ILog log = Activator.getDefault().getLog();
+						log.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error generating report", e));
+					}
 				}
 
 				if (completed) {
@@ -601,14 +607,11 @@
 
 									}
 								}
-							} catch (IOException e) {
-								ILog log = Activator.getDefault().getLog();
-								log.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error generating report", e));
-								throw new InvocationTargetException(e);
-							} catch (Exception e) {
+							} catch (Throwable e) {
 								ILog log = Activator.getDefault().getLog();
 								log.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error generating report", e));
 							}
+
 						}
 					});
 				} catch (InvocationTargetException e) {
@@ -1147,10 +1150,14 @@
 
 		String filesFilter;
 
+		String fileName;
+
 		/**
+		 * @param fileName
 		 * @param zipInputStream
 		 */
-		public ZIPIterator(ZipInputStream zipInputStream, String filesFilter) {
+		public ZIPIterator(String fileName, ZipInputStream zipInputStream, String filesFilter) {
+			this.fileName = fileName;
 			zipInputStreams.push(zipInputStream);
 
 			if (!StringUtils.isEmpty(filesFilter)) {
@@ -1186,7 +1193,7 @@
 								// zipInputStream is now the input stream for the xml document
 								byte[] buffer = ByteStreams.toByteArray(zipInputStream);
 								ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(buffer);
-								wrapper = new WrapperForZipEnty("", entry, byteArrayInputStream);
+								wrapper = new WrapperForZipEnty(fileName, entry, byteArrayInputStream);
 								return true;
 							}
 							if ("ZIP".equalsIgnoreCase(FilenameUtils.getExtension(entry.getName()))) {
@@ -1315,7 +1322,8 @@
 
 		if (selectedFile != null) {
 			folder = (IFolder) selectedFile.getParent();
-			documentsIterator = new ZIPIterator(new ZipInputStream(selectedFile.getContents()), fileNameFilters);
+			documentsIterator = new ZIPIterator(
+				selectedFile.getName(), new ZipInputStream(selectedFile.getContents()), fileNameFilters);
 		}
 
 		fileCount = documents.size() + 50;
@@ -1568,7 +1576,10 @@
 					 */
 					clinicalDocument = null;
 				} catch (Exception exception) {
-					exception.printStackTrace();
+					ILog log = Activator.getDefault().getLog();
+					log.log(
+						new Status(
+							IStatus.ERROR, Activator.PLUGIN_ID, "Error processing file " + file.getName(), exception));
 					errors.put(file, exception);
 				}
 
@@ -1796,7 +1807,7 @@
 		}
 
 		public WrapperForZipEnty(String prefix, ZipEntry zipEntry, InputStream inputStream) {
-			this.prefix = prefix;
+			this.prefix = FilenameUtils.getBaseName(prefix);
 			this.zipEntry = zipEntry;
 			this.inputStream = inputStream;
 		}
@@ -2808,7 +2819,7 @@
 		 */
 		@Override
 		public String getName() {
-			return FilenameUtils.getName(zipEntry.getName());
+			return prefix + " " + FilenameUtils.getName(zipEntry.getName());
 		}
 
 		/*