Updates to CD Translation export

Export 3 Translations to allergy substance
Added preference to control
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 0f6757e..e6e0292 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
@@ -289,6 +289,8 @@
 
 	static HashSet<String> names = new HashSet<String>();
 
+	static boolean exportCDTranslations = false;
+
 	static boolean omitDOB = false;
 
 	static boolean omitDOD = false;
@@ -478,6 +480,8 @@
 		final String splitOption = event.getParameter(SPLITBYDOCUMENT);
 		final String filterOption = event.getParameter(FILTER);
 
+		exportCDTranslations = org.eclipse.mdht.uml.cda.ui.internal.Activator.getDefault().getPreferenceStore().getBoolean(
+			MDHTPreferences.EXPORT_CD_TRANSLATIONS_VALUE);
 		// Omit DOB from generated Spreadsheets
 		omitDOB = org.eclipse.mdht.uml.cda.ui.internal.Activator.getDefault().getPreferenceStore().getBoolean(
 			MDHTPreferences.OMIT_DOB_STORE_VALUE);
diff --git a/cda/plugins/org.eclipse.mdht.cda.xml.ui/src/org/eclipse/mdht/cda/xml/ui/handlers/SectionSwitch.java b/cda/plugins/org.eclipse.mdht.cda.xml.ui/src/org/eclipse/mdht/cda/xml/ui/handlers/SectionSwitch.java
index f8c332a..e7af201 100644
--- a/cda/plugins/org.eclipse.mdht.cda.xml.ui/src/org/eclipse/mdht/cda/xml/ui/handlers/SectionSwitch.java
+++ b/cda/plugins/org.eclipse.mdht.cda.xml.ui/src/org/eclipse/mdht/cda/xml/ui/handlers/SectionSwitch.java
@@ -1269,8 +1269,12 @@
 
 			}
 
-			offset = SpreadsheetSerializer.appendCodeShowNullFlavor(
-				row, offset, allergyProblemAct.getSection(), material, null);
+			if (GenerateCDADataHandler.exportCDTranslations) {
+				offset = SpreadsheetSerializer.appendExtendedCode(
+					row, offset, allergyProblemAct.getSection(), material, null, true);
+			} else {
+				offset = SpreadsheetSerializer.appendCode(row, offset, allergyProblemAct.getSection(), material, null);
+			}
 
 			SeverityObservation severity = null;
 
diff --git a/cda/plugins/org.eclipse.mdht.cda.xml.ui/src/org/eclipse/mdht/cda/xml/ui/handlers/SheetHeaderUtil.java b/cda/plugins/org.eclipse.mdht.cda.xml.ui/src/org/eclipse/mdht/cda/xml/ui/handlers/SheetHeaderUtil.java
index dbcb92f..9e12f45 100644
--- a/cda/plugins/org.eclipse.mdht.cda.xml.ui/src/org/eclipse/mdht/cda/xml/ui/handlers/SheetHeaderUtil.java
+++ b/cda/plugins/org.eclipse.mdht.cda.xml.ui/src/org/eclipse/mdht/cda/xml/ui/handlers/SheetHeaderUtil.java
@@ -27,7 +27,12 @@
 		row2.getSheet().setColumnHidden(offset - 1, hideColumns);
 		row2.createCell(offset++).setCellValue(replaceSpace("No Known Flag"));
 		offset = addCodeHeader(row2, offset, "Allergy");
-		offset = addCodeHeader(row2, offset, "Substance");
+		if (GenerateCDADataHandler.exportCDTranslations) {
+			offset = addExtendedCodeHeader(row2, offset, "Substance");
+		} else {
+			offset = addCodeHeader(row2, offset, "Substance");
+		}
+
 		offset = addCodeHeader(row2, offset, "Reaction");
 		offset = addCodeHeader(row2, offset, "Severity");
 		row2.createCell(offset++).setCellValue(replaceSpace("Organization"));
@@ -313,6 +318,54 @@
 		return offset;
 	}
 
+	static int addExtendedCodeHeader(Row row1, int offset, String prefix) {
+		row1.createCell(offset++).setCellValue(replaceSpace(prefix + " Text"));
+		row1.createCell(offset++).setCellValue(replaceSpace(prefix + " Display Name"));
+		row1.createCell(offset++).setCellValue(replaceSpace(prefix + " Code"));
+		row1.getSheet().setColumnHidden(offset - 1, hideColumns);
+		row1.createCell(offset++).setCellValue(replaceSpace(prefix + " Code System"));
+		row1.getSheet().setColumnHidden(offset - 1, hideColumns);
+		row1.createCell(offset++).setCellValue(replaceSpace(prefix + " Code System Name"));
+		row1.getSheet().setColumnHidden(offset - 1, hideColumns);
+		row1.createCell(offset++).setCellValue(replaceSpace(prefix + " Location"));
+		row1.getSheet().setColumnHidden(offset - 1, hideColumns);
+
+		row1.createCell(offset++).setCellValue(replaceSpace(prefix + " Translation 1 Text"));
+		row1.createCell(offset++).setCellValue(replaceSpace(prefix + " Translation 1 Display Name"));
+		row1.createCell(offset++).setCellValue(replaceSpace(prefix + " Translation 1 Code"));
+		row1.getSheet().setColumnHidden(offset - 1, hideColumns);
+		row1.createCell(offset++).setCellValue(replaceSpace(prefix + " Translation 1 Code System"));
+		row1.getSheet().setColumnHidden(offset - 1, hideColumns);
+		row1.createCell(offset++).setCellValue(replaceSpace(prefix + " Translation 1 Code System Name"));
+		row1.getSheet().setColumnHidden(offset - 1, hideColumns);
+		row1.createCell(offset++).setCellValue(replaceSpace(prefix + " Translation 1 Location"));
+		row1.getSheet().setColumnHidden(offset - 1, hideColumns);
+
+		row1.createCell(offset++).setCellValue(replaceSpace(prefix + " Translation 2 Text"));
+		row1.createCell(offset++).setCellValue(replaceSpace(prefix + " Translation 2 Display Name"));
+		row1.createCell(offset++).setCellValue(replaceSpace(prefix + " Translation 2 Code"));
+		row1.getSheet().setColumnHidden(offset - 1, hideColumns);
+		row1.createCell(offset++).setCellValue(replaceSpace(prefix + " Translation 2 Code System"));
+		row1.getSheet().setColumnHidden(offset - 1, hideColumns);
+		row1.createCell(offset++).setCellValue(replaceSpace(prefix + " Translation 2 Code System Name"));
+		row1.getSheet().setColumnHidden(offset - 1, hideColumns);
+		row1.createCell(offset++).setCellValue(replaceSpace(prefix + " Translation 2 Location"));
+		row1.getSheet().setColumnHidden(offset - 1, hideColumns);
+
+		row1.createCell(offset++).setCellValue(replaceSpace(prefix + " Translation 2 Text"));
+		row1.createCell(offset++).setCellValue(replaceSpace(prefix + " Translation 3 Display Name"));
+		row1.createCell(offset++).setCellValue(replaceSpace(prefix + " Translation 3 Code"));
+		row1.getSheet().setColumnHidden(offset - 1, hideColumns);
+		row1.createCell(offset++).setCellValue(replaceSpace(prefix + " Translation 3 Code System"));
+		row1.getSheet().setColumnHidden(offset - 1, hideColumns);
+		row1.createCell(offset++).setCellValue(replaceSpace(prefix + " Translation 3 Code System Name"));
+		row1.getSheet().setColumnHidden(offset - 1, hideColumns);
+		row1.createCell(offset++).setCellValue(replaceSpace(prefix + " Translation 3 Location"));
+		row1.getSheet().setColumnHidden(offset - 1, hideColumns);
+
+		return offset;
+	}
+
 	static int addSectionHeader(Row row1, int offset) {
 		row1.createCell(offset++).setCellValue(replaceSpace("Section Title"));
 		row1.createCell(offset++).setCellValue(replaceSpace("File Location"));
diff --git a/cda/plugins/org.eclipse.mdht.cda.xml.ui/src/org/eclipse/mdht/cda/xml/ui/handlers/SpreadsheetSerializer.java b/cda/plugins/org.eclipse.mdht.cda.xml.ui/src/org/eclipse/mdht/cda/xml/ui/handlers/SpreadsheetSerializer.java
index 489f17d..fd3caa4 100644
--- a/cda/plugins/org.eclipse.mdht.cda.xml.ui/src/org/eclipse/mdht/cda/xml/ui/handlers/SpreadsheetSerializer.java
+++ b/cda/plugins/org.eclipse.mdht.cda.xml.ui/src/org/eclipse/mdht/cda/xml/ui/handlers/SpreadsheetSerializer.java
@@ -2518,4 +2518,48 @@
 		return offset;
 	}
 
+	/**
+	 * @param row
+	 * @param offset
+	 * @param section
+	 * @param cd
+	 * @param text
+	 * @return
+	 */
+	public static int appendExtendedCode(Row row, int offset, Section section, CD cd, ED text, boolean showNullFlavor) {
+		if (showNullFlavor) {
+			offset = SpreadsheetSerializer.appendCodeShowNullFlavor(row, offset, section, cd, text);
+		} else {
+			offset = SpreadsheetSerializer.appendCode(row, offset, section, cd, text);
+		}
+		if (cd.getTranslations().size() >= 1) {
+			offset = SpreadsheetSerializer.appendCode(row, offset, section, cd.getTranslations().get(0), null);
+		} else {
+			row.createCell(offset++).setCellValue("");
+			row.createCell(offset++).setCellValue("");
+			row.createCell(offset++).setCellValue("");
+			row.createCell(offset++).setCellValue("");
+			row.createCell(offset++).setCellValue("");
+		}
+		if (cd.getTranslations().size() >= 2) {
+			offset = SpreadsheetSerializer.appendCode(row, offset, section, cd.getTranslations().get(1), null);
+		} else {
+			row.createCell(offset++).setCellValue("");
+			row.createCell(offset++).setCellValue("");
+			row.createCell(offset++).setCellValue("");
+			row.createCell(offset++).setCellValue("");
+			row.createCell(offset++).setCellValue("");
+		}
+		if (cd.getTranslations().size() >= 3) {
+			offset = SpreadsheetSerializer.appendCode(row, offset, section, cd.getTranslations().get(2), null);
+		} else {
+			row.createCell(offset++).setCellValue("");
+			row.createCell(offset++).setCellValue("");
+			row.createCell(offset++).setCellValue("");
+			row.createCell(offset++).setCellValue("");
+			row.createCell(offset++).setCellValue("");
+		}
+		return offset;
+	}
+
 }