Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add skos display name to equivalence #160

Merged
merged 1 commit into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/org/ohdsi/usagi/CodeMapping.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
48 changes: 48 additions & 0 deletions src/org/ohdsi/usagi/Equivalence.java
Original file line number Diff line number Diff line change
@@ -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<String> getAllDisplayNames() {
List<String> 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));
}
}
2 changes: 1 addition & 1 deletion src/org/ohdsi/usagi/ReadCodeMappingsFromFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/org/ohdsi/usagi/dataImport/ImportData.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private void createInitialMapping(List<SourceCode> 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();
Expand Down
2 changes: 1 addition & 1 deletion src/org/ohdsi/usagi/ui/ImportDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down
8 changes: 5 additions & 3 deletions src/org/ohdsi/usagi/ui/MappingDetailPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/org/ohdsi/usagi/ui/MappingTablePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/org/ohdsi/usagi/ui/ShowReviewStatsDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public ShowReviewStatsDialog() {
// Equivalence status
addHeaderLabel(g,"By equivalence status:");

Map<CodeMapping.Equivalence, Long> countByEquivalence = codeMappings.stream()
Map<Equivalence, Long> countByEquivalence = codeMappings.stream()
.collect(Collectors.groupingBy(CodeMapping::getEquivalence, Collectors.counting()));

countByEquivalence.forEach((key, value) -> addLabel(g, String.format("%s - %d", key, value)));
Expand Down
2 changes: 1 addition & 1 deletion src/org/ohdsi/usagi/ui/UsagiTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down