diff --git a/src/org/ohdsi/usagi/CodeMapping.java b/src/org/ohdsi/usagi/CodeMapping.java index e7c8f77..4a4f587 100644 --- a/src/org/ohdsi/usagi/CodeMapping.java +++ b/src/org/ohdsi/usagi/CodeMapping.java @@ -16,6 +16,7 @@ package org.ohdsi.usagi; import org.ohdsi.usagi.ui.Global; +import org.ohdsi.usagi.Equivalence; import java.util.ArrayList; import java.util.List; @@ -31,10 +32,6 @@ public enum MappingStatus { APPROVED, UNCHECKED, AUTO_MAPPED, AUTO_MAPPED_TO_1, INVALID_TARGET, FLAGGED, IGNORED } - public enum Equivalence { - EQUAL, EQUIVALENT, WIDER, NARROWER, INEXACT, UNMATCHED, UNREVIEWED - } - private SourceCode sourceCode; private double matchScore; private MappingStatus mappingStatus; diff --git a/src/org/ohdsi/usagi/Equivalence.java b/src/org/ohdsi/usagi/Equivalence.java new file mode 100644 index 0000000..949235e --- /dev/null +++ b/src/org/ohdsi/usagi/Equivalence.java @@ -0,0 +1,48 @@ +package org.ohdsi.usagi; + +import java.util.ArrayList; +import java.util.List; + +public enum Equivalence { + EQUAL("exactMatch"), + EQUIVALENT("closeMatch"), + WIDER("broadMatch"), + NARROWER("narrowMatch"), + INEXACT("relatedMatch"), + UNMATCHED("unmatched"), + UNREVIEWED("unreviewed"); + + private String displayName; + + private Equivalence(String displayName) { + this.displayName = displayName; + } + + public String getDisplayName() { + return displayName; + } + + public static Equivalence fromDisplayName(String displayName) { + for (Equivalence equivalence : Equivalence.values()) { + if (equivalence.getDisplayName().equals(displayName)) { + return equivalence; + } + } + return null; + } + + public static List getAllDisplayNames() { + List names = new ArrayList<>(); + for (Equivalence equivalence : Equivalence.values()) { + names.add(equivalence.getDisplayName()); + } + return names; + } + + + public static void main(String[] args) { + System.out.println(Equivalence.getAllDisplayNames()); + String spam = Equivalence.getAllDisplayNames().get(3); + System.out.println(Equivalence.fromDisplayName(spam)); + } +} \ No newline at end of file diff --git a/src/org/ohdsi/usagi/ReadCodeMappingsFromFile.java b/src/org/ohdsi/usagi/ReadCodeMappingsFromFile.java index c4611e2..c5463e6 100644 --- a/src/org/ohdsi/usagi/ReadCodeMappingsFromFile.java +++ b/src/org/ohdsi/usagi/ReadCodeMappingsFromFile.java @@ -18,7 +18,7 @@ import java.util.Iterator; import org.ohdsi.usagi.CodeMapping.MappingStatus; -import org.ohdsi.usagi.CodeMapping.Equivalence; +import org.ohdsi.usagi.Equivalence; import org.ohdsi.usagi.ui.Global; import org.ohdsi.utilities.files.ReadCSVFileWithHeader; import org.ohdsi.utilities.files.Row; diff --git a/src/org/ohdsi/usagi/dataImport/ImportData.java b/src/org/ohdsi/usagi/dataImport/ImportData.java index 2d0e43c..1df8d83 100644 --- a/src/org/ohdsi/usagi/dataImport/ImportData.java +++ b/src/org/ohdsi/usagi/dataImport/ImportData.java @@ -86,7 +86,7 @@ private void createInitialMapping(List sourceCodes, ImportSettings s } else if (sourceCode.sourceAutoAssignedConceptIds.size() > 1 && concepts.size() > 0) { codeMapping.setMappingStatus(MappingStatus.AUTO_MAPPED); } - codeMapping.setEquivalence(CodeMapping.Equivalence.UNREVIEWED); + codeMapping.setEquivalence(Equivalence.UNREVIEWED); out.write(codeMapping); } out.close(); diff --git a/src/org/ohdsi/usagi/ui/ImportDialog.java b/src/org/ohdsi/usagi/ui/ImportDialog.java index 998e1e6..34f4614 100644 --- a/src/org/ohdsi/usagi/ui/ImportDialog.java +++ b/src/org/ohdsi/usagi/ui/ImportDialog.java @@ -439,7 +439,7 @@ public void run() { } else if (sourceCode.sourceAutoAssignedConceptIds.size() > 1 && concepts.size() > 0) { codeMapping.setMappingStatus(MappingStatus.AUTO_MAPPED); } - codeMapping.setEquivalence(CodeMapping.Equivalence.UNREVIEWED); + codeMapping.setEquivalence(Equivalence.UNREVIEWED); synchronized (globalMappingList) { globalMappingList.add(codeMapping); progressBar.setValue(Math.round(100 * globalMappingList.size() / sourceCodes.size())); diff --git a/src/org/ohdsi/usagi/ui/MappingDetailPanel.java b/src/org/ohdsi/usagi/ui/MappingDetailPanel.java index f3b3049..3cb2bc5 100644 --- a/src/org/ohdsi/usagi/ui/MappingDetailPanel.java +++ b/src/org/ohdsi/usagi/ui/MappingDetailPanel.java @@ -33,6 +33,7 @@ import org.ohdsi.usagi.CodeMapping; import org.ohdsi.usagi.CodeMapping.MappingStatus; import org.ohdsi.usagi.Concept; +import org.ohdsi.usagi.Equivalence; import org.ohdsi.usagi.MappingTarget; import org.ohdsi.usagi.UsagiSearchEngine.ScoredConcept; @@ -276,7 +277,7 @@ public void changedUpdate(DocumentEvent arg0) { flagButton.setBackground(new Color(151, 220, 141)); panel.add(flagButton); - equivalenceOptionChooser = new JComboBox<>(CodeMapping.Equivalence.values()); + equivalenceOptionChooser = new JComboBox<>(Equivalence.getAllDisplayNames().toArray()); equivalenceOptionChooser.setToolTipText("Choose mapping equivalence"); equivalenceOptionChooser.setMaximumSize(equivalenceOptionChooser.getPreferredSize()); panel.add(equivalenceOptionChooser); @@ -407,7 +408,8 @@ public void flagOrUnflag() { } public void approveSelected() { - CodeMapping.Equivalence equivalenceToApply = (CodeMapping.Equivalence) equivalenceOptionChooser.getSelectedItem(); + Equivalence equivalenceToApply = Equivalence.fromDisplayName((String) equivalenceOptionChooser.getSelectedItem()); + codeMapping.approve(equivalenceToApply); for (CodeMapping codeMappingMulti : codeMappingsFromMulti) { codeMappingMulti.approve(equivalenceToApply); @@ -420,7 +422,7 @@ public void approveSelected() { } public void flagSelected() { - CodeMapping.Equivalence equivalenceToApply = (CodeMapping.Equivalence) equivalenceOptionChooser.getSelectedItem(); + Equivalence equivalenceToApply = Equivalence.fromDisplayName((String) equivalenceOptionChooser.getSelectedItem()); codeMapping.flag(equivalenceToApply); for (CodeMapping codeMappingMulti : codeMappingsFromMulti) { codeMappingMulti.flag(equivalenceToApply); diff --git a/src/org/ohdsi/usagi/ui/MappingTablePanel.java b/src/org/ohdsi/usagi/ui/MappingTablePanel.java index 005d7f4..b4dfb80 100644 --- a/src/org/ohdsi/usagi/ui/MappingTablePanel.java +++ b/src/org/ohdsi/usagi/ui/MappingTablePanel.java @@ -32,7 +32,7 @@ import javax.swing.table.TableRowSorter; import org.ohdsi.usagi.CodeMapping; -import org.ohdsi.usagi.CodeMapping.Equivalence; +import org.ohdsi.usagi.Equivalence; import org.ohdsi.usagi.CodeMapping.MappingStatus; import org.ohdsi.usagi.Concept; @@ -202,7 +202,7 @@ public Object getValueAt(int row, int col) { case ASSIGNED_REVIEWER_COL: return codeMapping.getAssignedReviewer(); case 18: - if (codeMapping.getEquivalence() != CodeMapping.Equivalence.UNREVIEWED) { + if (codeMapping.getEquivalence() != Equivalence.UNREVIEWED) { return codeMapping.getEquivalence(); } else { return null; diff --git a/src/org/ohdsi/usagi/ui/ShowReviewStatsDialog.java b/src/org/ohdsi/usagi/ui/ShowReviewStatsDialog.java index 9d6a599..3e56a2d 100644 --- a/src/org/ohdsi/usagi/ui/ShowReviewStatsDialog.java +++ b/src/org/ohdsi/usagi/ui/ShowReviewStatsDialog.java @@ -62,7 +62,7 @@ public ShowReviewStatsDialog() { // Equivalence status addHeaderLabel(g,"By equivalence status:"); - Map countByEquivalence = codeMappings.stream() + Map countByEquivalence = codeMappings.stream() .collect(Collectors.groupingBy(CodeMapping::getEquivalence, Collectors.counting())); countByEquivalence.forEach((key, value) -> addLabel(g, String.format("%s - %d", key, value))); diff --git a/src/org/ohdsi/usagi/ui/UsagiTable.java b/src/org/ohdsi/usagi/ui/UsagiTable.java index 2800edb..2195b50 100644 --- a/src/org/ohdsi/usagi/ui/UsagiTable.java +++ b/src/org/ohdsi/usagi/ui/UsagiTable.java @@ -31,7 +31,7 @@ import javax.swing.table.TableModel; import org.ohdsi.usagi.CodeMapping.MappingStatus; -import org.ohdsi.usagi.CodeMapping.Equivalence; +import org.ohdsi.usagi.Equivalence; public class UsagiTable extends JTable {