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

Release 1.2.9 #74

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c4184e8
when applying previous mapping, also add codes not present in current…
Jan 6, 2020
8b49a3d
remember last folder used to select file
May 2, 2020
53d33a5
remember folder for import and export
May 2, 2020
26e919b
open usagi file from commandline
May 3, 2020
80401af
fix writing of null columns to csv
May 3, 2020
795c33a
ask to export unapproved mappings
May 3, 2020
c154983
add os specific menu shortcut key
May 3, 2020
e202b24
add option to export unapproved to source_to_concept_map
May 3, 2020
2a339d7
set vocabulary_id = None if target concept is 0
May 3, 2020
5f45b72
Merge pull request #72 from OHDSI/save-last-folder
May 3, 2020
452924b
when applying previous mapping, also add codes not present in current…
Jan 6, 2020
222b75d
open usagi file from commandline
May 3, 2020
7c951eb
show error if applied mapping is invalid file format
May 3, 2020
1588b85
report count of illegal targets and reindex after adding new codes
May 3, 2020
929f01c
Merge branch 'apply-previous' of https://github.com/OHDSI/Usagi into …
May 3, 2020
3edd19a
show warning dialog before exiting application
May 3, 2020
b335427
solves #70. plus some refactorings
May 3, 2020
bba6bda
Merge pull request #73 from OHDSI/export
May 14, 2020
ef4a2cc
Merge branch 'develop' into apply-previous
May 14, 2020
0bdfba3
Merge pull request #71 from OHDSI/apply-previous
May 14, 2020
e8932b0
Merge pull request #75 from OHDSI/index-build-warnings
May 14, 2020
9be7e0c
fixes #45
May 3, 2020
4e1fc5e
add version and display in the ui
May 13, 2020
85e1bf9
disable editing of cells
May 15, 2020
108bed6
add link out to Athena web browser
May 15, 2020
f5aea9a
add google web search of source terms
May 15, 2020
63f0ca4
remember all codes in multi and replace/add all
May 15, 2020
279b545
fix create mappings list and update model correctly
May 15, 2020
a98c71d
code cleanup
May 15, 2020
0b3a432
add shortkey for approve all
May 15, 2020
561c8f7
warn if there are no mappings to export
Jun 12, 2020
bc5f67a
Merge pull request #76 from OHDSI/web-links
Jun 19, 2020
d8c41ad
Merge branch 'develop' into multi-replace-concept
Jun 19, 2020
f28219f
Merge pull request #77 from EHDEN/multi-replace-concept
Jun 19, 2020
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
101 changes: 101 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,104 @@
/bin
build/
dist/

### Usagi index files ###
derivedIndex/
mainIndex/
sleepyCat/
ConceptClassIds.txt
DomainIds.txt
VocabularyIds.txt
vocabularyVersion.txt

### Intellij ###
# Created by https://www.gitignore.io/api/intellij
# Edit at https://www.gitignore.io/?templates=intellij
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
.idea/
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721

# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr

# Sonarlint plugin
.idea/**/sonarlint/

# SonarQube Plugin
.idea/**/sonarIssues.xml

# Markdown Navigator plugin
.idea/**/markdown-navigator.xml
.idea/**/markdown-navigator/

# End of https://www.gitignore.io/api/intellij
14 changes: 14 additions & 0 deletions Usagi.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="lib" level="project" />
<orderEntry type="library" name="R User Library" level="project" />
<orderEntry type="library" name="R Skeletons" level="application" />
</component>
</module>
25 changes: 20 additions & 5 deletions src/org/ohdsi/usagi/ReadCodeMappingsFromFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import org.ohdsi.utilities.files.ReadCSVFileWithHeader;
import org.ohdsi.utilities.files.Row;

import javax.swing.*;

public class ReadCodeMappingsFromFile implements Iterable<CodeMapping> {
private String filename;

Expand All @@ -42,17 +44,29 @@ public class RowIterator implements Iterator<CodeMapping> {

public RowIterator() {
iterator = new ReadCSVFileWithHeader(filename).iterator();

if (iterator.hasNext()) {
row = iterator.next();
readNext();
} else
try {
readNext();
} catch (Exception e) {
JOptionPane.showMessageDialog(
Global.frame,
"Invalid File Format",
"Error",
JOptionPane.ERROR_MESSAGE
);
return;
}
} else {
buffer = null;
}
}

private void readNext() {
if (row == null)
if (row == null) {
buffer = null;
else {
} else {
buffer = new CodeMapping(new SourceCode(row));
buffer.matchScore = row.getDouble("matchScore");
buffer.mappingStatus = MappingStatus.valueOf(row.get("mappingStatus"));
Expand All @@ -66,7 +80,8 @@ && new SourceCode(row).sourceName.equals(buffer.sourceCode.sourceName)) {
if (row.getInt("conceptId") != 0) {
Concept concept = Global.dbEngine.getConcept(row.getInt("conceptId"));
if (concept == null) {
buffer.mappingStatus = CodeMapping.MappingStatus.INVALID_TARGET;
buffer.mappingStatus = MappingStatus.INVALID_TARGET;
buffer.comment = "Invalid existing target: " + row.get("conceptId");
} else {
buffer.targetConcepts.add(concept);
}
Expand Down
9 changes: 5 additions & 4 deletions src/org/ohdsi/usagi/ui/AboutDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@
public class AboutDialog extends JDialog {

private static final long serialVersionUID = 2028328868610404663L;
private JEditorPane text;

public AboutDialog() {
setTitle("About Usagi");
setTitle("About Usagi v" + UsagiMain.version);
setLayout(new GridBagLayout());

GridBagConstraints g = new GridBagConstraints();
Expand All @@ -60,9 +59,11 @@ public AboutDialog() {
g.gridx = 1;
g.gridy = 0;

text = new JEditorPane(
JEditorPane text = new JEditorPane(
"text/html",
"Usagi was developed by Martijn Schuemie in <a href=\"http://ohdsi.org\">Observational Health Data Sciences and Informatics</a> (OHDSI).<br/><br/>For help, please review the <a href =\"http://www.ohdsi.org/web/wiki/doku.php?id=documentation:software:usagi\">Usagi Wiki</a>.");
"Usagi was developed by Martijn Schuemie" +
"<br/>in <a href=\"http://ohdsi.org\">Observational Health Data Sciences and Informatics</a> (OHDSI)." +
"<br/><br/>For help, please review the <a href =\"http://www.ohdsi.org/web/wiki/doku.php?id=documentation:software:usagi\">Usagi Wiki</a>.");

text.setEditable(false);
text.setOpaque(false);
Expand Down
4 changes: 3 additions & 1 deletion src/org/ohdsi/usagi/ui/CodeSelectedListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@
import org.ohdsi.usagi.CodeMapping;

public interface CodeSelectedListener {
public void codeSelected(CodeMapping codeMapping);
void codeSelected(CodeMapping codeMapping);
void addCodeMultiSelected(CodeMapping codeMapping);
void clearCodeMultiSelected();
}
2 changes: 1 addition & 1 deletion src/org/ohdsi/usagi/ui/ConceptTableModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public Class<?> getColumnClass(int col) {
}

public boolean isCellEditable(int row, int col) {
return true;
return false;
}

public void setValueAt(Object value, int row, int col) {
Expand Down
19 changes: 11 additions & 8 deletions src/org/ohdsi/usagi/ui/DataChangeListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,22 @@

public interface DataChangeListener {

public static DataChangeEvent APPROVE_EVENT = new DataChangeEvent(true, false);
public static DataChangeEvent SIMPLE_UPDATE_EVENT = new DataChangeEvent(false, false);
public static DataChangeEvent RESTRUCTURE_EVENT = new DataChangeEvent(false, true);
DataChangeEvent APPROVE_EVENT = new DataChangeEvent(true, false, false);
DataChangeEvent SIMPLE_UPDATE_EVENT = new DataChangeEvent(false, false, false);
DataChangeEvent MULTI_UPDATE_EVENT = new DataChangeEvent(false, false, true);
DataChangeEvent RESTRUCTURE_EVENT = new DataChangeEvent(false, true, false);

public void dataChanged(DataChangeEvent event);
void dataChanged(DataChangeEvent event);

public static class DataChangeEvent {
public DataChangeEvent(boolean approved, boolean structureChange) {
class DataChangeEvent {
public DataChangeEvent(boolean approved, boolean structureChange, boolean multiUpdate) {
this.approved = approved;
this.structureChange = structureChange;
this.multiUpdate = multiUpdate;
}

public boolean approved = false;
public boolean structureChange = false;
public boolean approved;
public boolean structureChange;
public boolean multiUpdate = false;
}
}
26 changes: 10 additions & 16 deletions src/org/ohdsi/usagi/ui/ExportSourceToConceptMapDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class ExportSourceToConceptMapDialog extends JDialog {

private JTextField sourceVocabularyIdField;
private static final long serialVersionUID = -6846083121849826818L;
private boolean exportUnapproved = false;

public ExportSourceToConceptMapDialog() {
setTitle("Export to source_to_concept_map");
Expand Down Expand Up @@ -73,23 +74,11 @@ public ExportSourceToConceptMapDialog() {
buttonPanel.add(Box.createHorizontalGlue());
JButton cancelButton = new JButton("Cancel");
cancelButton.setToolTipText("Cancel the export");
cancelButton.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent arg0) {
setVisible(false);
}
});
cancelButton.addActionListener(arg0 -> setVisible(false));
buttonPanel.add(cancelButton);
JButton exportButton = new JButton("Export");
exportButton.setToolTipText("Select the filename and export using these settings");
exportButton.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent arg0) {
export();
}
});
exportButton.addActionListener(arg0 -> export());
buttonPanel.add(exportButton);
add(buttonPanel, g);

Expand All @@ -98,13 +87,18 @@ public void actionPerformed(ActionEvent arg0) {
setLocationRelativeTo(Global.frame);
}

public void setExportUnapproved(boolean exportUnapproved) {
this.exportUnapproved = exportUnapproved;
}

private void export() {
JFileChooser fileChooser = new JFileChooser(Global.folder);
FileFilter csvFilter = new FileNameExtensionFilter("CSV files", "csv");
fileChooser.setFileFilter(csvFilter);
fileChooser.setDialogTitle("Export");
if (fileChooser.showSaveDialog(Global.frame) == JFileChooser.APPROVE_OPTION) {
File file = fileChooser.getSelectedFile();
Global.folder = file.getParentFile().getAbsolutePath();
if (!file.getName().toLowerCase().endsWith(".csv"))
file = new File(file.getAbsolutePath() + ".csv");

Expand All @@ -116,7 +110,7 @@ private void export() {
private void writeToCsvFile(String filename) {
WriteCSVFileWithHeader out = new WriteCSVFileWithHeader(filename);
for (CodeMapping mapping : Global.mapping)
if (mapping.mappingStatus == MappingStatus.APPROVED) {
if (exportUnapproved || mapping.mappingStatus == MappingStatus.APPROVED) {
List<Concept> targetConcepts;
if (mapping.targetConcepts.size() == 0) {
targetConcepts = new ArrayList<Concept>(1);
Expand All @@ -131,7 +125,7 @@ private void writeToCsvFile(String filename) {
row.add("source_vocabulary_id", sourceVocabularyIdField.getText());
row.add("source_code_description", mapping.sourceCode.sourceName);
row.add("target_concept_id", targetConcept.conceptId);
row.add("target_vocabulary_id", targetConcept.vocabularyId);
row.add("target_vocabulary_id", targetConcept.conceptId == 0 ? "None" : targetConcept.vocabularyId );
row.add("valid_start_date", "1970-01-01");
row.add("valid_end_date", "2099-12-31");
row.add("invalid_reason", "");
Expand Down
18 changes: 3 additions & 15 deletions src/org/ohdsi/usagi/ui/Global.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,7 @@

import org.ohdsi.usagi.BerkeleyDbEngine;
import org.ohdsi.usagi.UsagiSearchEngine;
import org.ohdsi.usagi.ui.actions.AboutAction;
import org.ohdsi.usagi.ui.actions.ApplyPreviousMappingAction;
import org.ohdsi.usagi.ui.actions.ApproveAction;
import org.ohdsi.usagi.ui.actions.ApproveAllAction;
import org.ohdsi.usagi.ui.actions.ClearAllAction;
import org.ohdsi.usagi.ui.actions.ConceptInformationAction;
import org.ohdsi.usagi.ui.actions.ExitAction;
import org.ohdsi.usagi.ui.actions.ExportForReviewAction;
import org.ohdsi.usagi.ui.actions.ExportSourceToConceptMapAction;
import org.ohdsi.usagi.ui.actions.ImportAction;
import org.ohdsi.usagi.ui.actions.OpenAction;
import org.ohdsi.usagi.ui.actions.RebuildIndexAction;
import org.ohdsi.usagi.ui.actions.SaveAction;
import org.ohdsi.usagi.ui.actions.SaveAsAction;
import org.ohdsi.usagi.ui.actions.ShowStatsAction;
import org.ohdsi.usagi.ui.actions.*;

public class Global {
public static JFrame frame;
Expand All @@ -57,6 +43,8 @@ public class Global {
public static ApproveAllAction approveAllAction;
public static ClearAllAction clearAllAction;
public static ConceptInformationAction conceptInfoAction;
public static AthenaAction athenaAction;
public static GoogleSearchAction googleSearchAction;
public static AboutAction aboutAction;
public static ExportSourceToConceptMapAction exportAction;
public static ExportForReviewAction exportForReviewAction;
Expand Down
17 changes: 12 additions & 5 deletions src/org/ohdsi/usagi/ui/Mapping.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,21 @@ public class Mapping extends ArrayList<CodeMapping> {

public void loadFromFile(String filename) {
clear();
boolean invalidTargets = false;
int nInvalidTargets = 0;
for (CodeMapping codeMapping : new ReadCodeMappingsFromFile(filename)) {
add(codeMapping);
if (codeMapping.mappingStatus == CodeMapping.MappingStatus.INVALID_TARGET)
invalidTargets = true;
if (codeMapping.mappingStatus == CodeMapping.MappingStatus.INVALID_TARGET) {
nInvalidTargets += 1;
}
}
if (nInvalidTargets > 0) {
JOptionPane.showMessageDialog(
null,
nInvalidTargets + " illegal target concepts found. The corresponding source codes are marked in red.",
"Illegal target concepts",
JOptionPane.WARNING_MESSAGE
);
}
if (invalidTargets)
JOptionPane.showMessageDialog(null, "Illegal target concepts found. The corresponding source codes are marked in red.", "Illegal target concepts", JOptionPane.WARNING_MESSAGE);
fireDataChanged(DataChangeListener.RESTRUCTURE_EVENT);
}

Expand Down
Loading